-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add hygen script for bootstrapping new templates
- Loading branch information
1 parent
6983a66
commit 1e87ee7
Showing
19 changed files
with
1,380 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 14 additions & 0 deletions
14
_templates/generator/template/code.js.CREDENTIALS_EXCHANGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: "<%= trigger == 'CREDENTIALS_EXCHANGE' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a Client Credentials exchange. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about client credentials grant request. | ||
* @param {CredentialsExchangeAPI} api - Interface whose methods can be used to change the behavior of client credentials grant. | ||
*/ | ||
exports.onExecuteCredentialsExchange = async (event, api) => { | ||
}; |
25 changes: 25 additions & 0 deletions
25
_templates/generator/template/code.js.PASSWORD_RESET_POST_CHALLENGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
to: "<%= trigger == 'PASSWORD_RESET_POST_CHALLENGE' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a Password Reset / Post Challenge Flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the post challenge request. | ||
* @param {PasswordResetPostChallengeAPI} api - Interface whose methods can be used to change the behavior of the post challenge flow. | ||
*/ | ||
exports.onExecutePostChallenge = async (event, api) => { | ||
}; | ||
|
||
|
||
/** | ||
* Handler that will be invoked when this action is resuming after an external redirect. If your | ||
* onExecutePostChallenge function does not perform a redirect, this function can be safely ignored. | ||
* | ||
* @param {Event} event - Details about the user and the context in which they are logging in. | ||
* @param {PasswordResetPostChallengeAPI} api - Interface whose methods can be used to change the behavior of the post challenge flow. | ||
*/ | ||
// exports.onContinuePostChallenge = async (event, api) => { | ||
// }; |
14 changes: 14 additions & 0 deletions
14
_templates/generator/template/code.js.POST_CHANGE_PASSWORD.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: "<%= trigger == 'POST_CHANGE_PASSWORD' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a PostChangePassword flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the user and the context in which the change password is happening. | ||
* @param {PostChangePasswordAPI} api - Methods and utilities to help change the behavior after a user changes their password. | ||
*/ | ||
exports.onExecutePostChangePassword = async (event, api) => { | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
to: "<%= trigger == 'POST_LOGIN' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a PostLogin flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the user and the context in which they are logging in. | ||
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. | ||
*/ | ||
exports.onExecutePostLogin = async (event, api) => { | ||
}; | ||
|
||
/** | ||
* Handler that will be invoked when this action is resuming after an external redirect. If your | ||
* onExecutePostLogin function does not perform a redirect, this function can be safely ignored. | ||
* | ||
* @param {Event} event - Details about the user and the context in which they are logging in. | ||
* @param {PostLoginAPI} api - Interface whose methods can be used to change the behavior of the login. | ||
*/ | ||
// exports.onContinuePostLogin = async (event, api) => { | ||
// }; |
14 changes: 14 additions & 0 deletions
14
_templates/generator/template/code.js.POST_USER_REGISTRATION.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: "<%= trigger == 'POST_USER_REGISTRATION' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a PostUserRegistration flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the context and user that has registered. | ||
* @param {PostUserRegistrationAPI} api - Methods and utilities to help change the behavior after a signup. | ||
*/ | ||
exports.onExecutePostUserRegistration = async (event, api) => { | ||
}; |
14 changes: 14 additions & 0 deletions
14
_templates/generator/template/code.js.PRE_USER_REGISTRATION.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: "<%= trigger == 'PRE_USER_REGISTRATION' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a PreUserRegistration flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the context and user that is attempting to register. | ||
* @param {PreUserRegistrationAPI} api - Interface whose methods can be used to change the behavior of the signup. | ||
*/ | ||
exports.onExecutePreUserRegistration = async (event, api) => { | ||
}; |
14 changes: 14 additions & 0 deletions
14
_templates/generator/template/code.js.SEND_PHONE_MESSAGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
to: "<%= trigger == 'SEND_PHONE_MESSAGE' ? `templates/${fileName}-${trigger}/code.js` : null %>" | ||
--- | ||
|
||
/** | ||
* Handler that will be called during the execution of a SendPhoneMessage flow. | ||
* | ||
* --- AUTH0 ACTIONS TEMPLATE https://github.com/auth0/opensource-marketplace/blob/main/templates/<%= fileName %>-<%= trigger %> --- | ||
* | ||
* @param {Event} event - Details about the user and the context in which they are logging in. | ||
* @param {SendPhoneMessageAPI} api - Methods and utilities to help change the behavior of sending a phone message. | ||
*/ | ||
exports.onExecuteSendPhoneMessage = async (event, api) => { | ||
}; |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.CREDENTIALS_EXCHANGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'CREDENTIALS_EXCHANGE' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "CREDENTIALS_EXCHANGE" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.PASSWORD_RESET_POST_CHALLENGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'PASSWORD_RESET_POST_CHALLENGE' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "PASSWORD_RESET_POST_CHALLENGE" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.POST_CHANGE_PASSWORD.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'POST_CHANGE_PASSWORD' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "POST_CHANGE_PASSWORD" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'POST_LOGIN' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "POST_LOGIN" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.POST_USER_REGISTRATION.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'POST_USER_REGISTRATION' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "POST_USER_REGISTRATION" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.PRE_USER_REGISTRATION.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'PRE_USER_REGISTRATION' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "PRE_USER_REGISTRATION" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
20 changes: 20 additions & 0 deletions
20
_templates/generator/template/manifest.yaml.SEND_PHONE_MESSAGE.t
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--- | ||
to: "<%= trigger == 'SEND_PHONE_MESSAGE' ? `templates/${fileName}-${trigger}/manifest.yaml` : null %>" | ||
--- | ||
name: "<%= name %>" | ||
triggers: | ||
- "SEND_PHONE_MESSAGE" | ||
useCases: | ||
- | ||
public: true | ||
description: "<%= description %>" | ||
version: "1.0.0" | ||
runtime: "node18" | ||
secrets: | ||
- | ||
config: | ||
- | ||
sourceUrl: "https://github.com/auth0/opensource-marketplace/tree/main/templates/<%= fileName %>-<%= trigger %>/manifest.yaml" | ||
modules: | ||
- | ||
notes: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
const { kebabCase } = require('lodash'); | ||
|
||
const TRIGGERS = [ | ||
'POST_LOGIN', | ||
'CREDENTIALS_EXCHANGE', | ||
'PRE_USER_REGISTRATION', | ||
'POST_USER_REGISTRATION', | ||
'POST_CHANGE_PASSWORD', | ||
'SEND_PHONE_MESSAGE', | ||
'PASSWORD_RESET_POST_CHALLENGE', | ||
]; | ||
|
||
module.exports = { | ||
prompt: ({ inquirer }) => { | ||
const questions = [ | ||
{ | ||
type: 'input', | ||
name: 'name', | ||
message: | ||
"Please provide a concise title for the actions template you'd like to create. For example: 'Quadruple Factor Authentication'", | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'description', | ||
message: | ||
"Please provide a short description of this actions template. For example: 'Enforces quadruple factor authentication when John Doe logs in on a Tuesday'", | ||
}, | ||
{ | ||
type: 'input', | ||
name: 'trigger', | ||
message: `What trigger is this actions template for? Your options are: ${TRIGGERS.map((t) => `\n ${t}`).join('')}`, | ||
}, | ||
]; | ||
|
||
return inquirer.prompt(questions).then((answers) => { | ||
const { name, description, trigger } = answers; | ||
|
||
let error = false; | ||
|
||
if (!name) { | ||
console.log('Must specify a name for your actions template'); | ||
error = true; | ||
} | ||
|
||
if (!description) { | ||
console.log('Must specify a name for your actions template'); | ||
error = true; | ||
} | ||
|
||
if (TRIGGERS.indexOf(trigger) === -1) { | ||
console.log( | ||
'Must specify a valid trigger for your actions template' | ||
); | ||
error = true; | ||
} | ||
|
||
if (error) { | ||
throw new Error('inout validation failed'); | ||
} | ||
|
||
const fileName = kebabCase(name); | ||
|
||
return { | ||
...answers, | ||
name, | ||
description, | ||
trigger, | ||
fileName, | ||
}; | ||
}); | ||
}, | ||
}; |
Oops, something went wrong.