@baseplate-dev/plugin-auth 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +390 -0
- package/dist/auth/core/common.d.ts +7 -0
- package/dist/auth/core/common.d.ts.map +1 -0
- package/dist/auth/core/common.js +26 -0
- package/dist/auth/core/common.js.map +1 -0
- package/dist/auth/core/components/auth-definition-editor.d.ts +5 -0
- package/dist/auth/core/components/auth-definition-editor.d.ts.map +1 -0
- package/dist/auth/core/components/auth-definition-editor.js +57 -0
- package/dist/auth/core/components/auth-definition-editor.js.map +1 -0
- package/dist/auth/core/components/role-editor-form.d.ts +10 -0
- package/dist/auth/core/components/role-editor-form.d.ts.map +1 -0
- package/dist/auth/core/components/role-editor-form.js +27 -0
- package/dist/auth/core/components/role-editor-form.js.map +1 -0
- package/dist/auth/core/node.d.ts +5 -0
- package/dist/auth/core/node.d.ts.map +1 -0
- package/dist/auth/core/node.js +58 -0
- package/dist/auth/core/node.js.map +1 -0
- package/dist/auth/core/schema/models.d.ts +9 -0
- package/dist/auth/core/schema/models.d.ts.map +1 -0
- package/dist/auth/core/schema/models.js +187 -0
- package/dist/auth/core/schema/models.js.map +1 -0
- package/dist/auth/core/schema/plugin-definition.d.ts +88 -0
- package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -0
- package/dist/auth/core/schema/plugin-definition.js +29 -0
- package/dist/auth/core/schema/plugin-definition.js.map +1 -0
- package/dist/auth/core/web.d.ts +6 -0
- package/dist/auth/core/web.d.ts.map +1 -0
- package/dist/auth/core/web.js +14 -0
- package/dist/auth/core/web.js.map +1 -0
- package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts +65 -0
- package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts.map +1 -0
- package/dist/auth/generators/fastify/auth-module/auth-module.generator.js +62 -0
- package/dist/auth/generators/fastify/auth-module/auth-module.generator.js.map +1 -0
- package/dist/auth/generators/fastify/auth-module/generated/ts-templates.d.ts +96 -0
- package/dist/auth/generators/fastify/auth-module/generated/ts-templates.d.ts.map +1 -0
- package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js +94 -0
- package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js.map +1 -0
- package/dist/auth/generators/fastify/auth-module/templates/management.ts +22 -0
- package/dist/auth/generators/fastify/auth-module/templates/schema/user-session-payload.object-type.ts +23 -0
- package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.mutations.ts +22 -0
- package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.queries.ts +20 -0
- package/dist/auth/generators/fastify/auth-module/templates/services/user-session.service.ts +251 -0
- package/dist/auth/generators/fastify/auth-module/templates/user-session.constants.ts +19 -0
- package/dist/auth/generators/fastify/auth-module/templates/user-session.service.ts +101 -0
- package/dist/auth/generators/fastify/auth-module/templates/utils/cookie-signer.ts +71 -0
- package/dist/auth/generators/fastify/auth-module/templates/utils/session-cookie.ts +42 -0
- package/dist/auth/generators/fastify/auth-module/templates/utils/verify-request-origin.ts +45 -0
- package/dist/auth/generators/fastify/index.d.ts +2 -0
- package/dist/auth/generators/fastify/index.d.ts.map +1 -0
- package/dist/auth/generators/fastify/index.js +2 -0
- package/dist/auth/generators/fastify/index.js.map +1 -0
- package/dist/auth/generators/index.d.ts +2 -0
- package/dist/auth/generators/index.d.ts.map +1 -0
- package/dist/auth/generators/index.js +2 -0
- package/dist/auth/generators/index.js.map +1 -0
- package/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +2 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/metadata.json +8 -0
- package/dist/auth/static/icon.svg +1 -0
- package/dist/auth0/constants/packages.d.ts +6 -0
- package/dist/auth0/constants/packages.d.ts.map +1 -0
- package/dist/auth0/constants/packages.js +6 -0
- package/dist/auth0/constants/packages.js.map +1 -0
- package/dist/auth0/core/common.d.ts +7 -0
- package/dist/auth0/core/common.d.ts.map +1 -0
- package/dist/auth0/core/common.js +28 -0
- package/dist/auth0/core/common.js.map +1 -0
- package/dist/auth0/core/components/auth-definition-editor.d.ts +5 -0
- package/dist/auth0/core/components/auth-definition-editor.d.ts.map +1 -0
- package/dist/auth0/core/components/auth-definition-editor.js +57 -0
- package/dist/auth0/core/components/auth-definition-editor.js.map +1 -0
- package/dist/auth0/core/components/role-dialog.d.ts +14 -0
- package/dist/auth0/core/components/role-dialog.d.ts.map +1 -0
- package/dist/auth0/core/components/role-dialog.js +27 -0
- package/dist/auth0/core/components/role-dialog.js.map +1 -0
- package/dist/auth0/core/components/role-editor-form.d.ts +10 -0
- package/dist/auth0/core/components/role-editor-form.d.ts.map +1 -0
- package/dist/auth0/core/components/role-editor-form.js +52 -0
- package/dist/auth0/core/components/role-editor-form.js.map +1 -0
- package/dist/auth0/core/node.d.ts +5 -0
- package/dist/auth0/core/node.d.ts.map +1 -0
- package/dist/auth0/core/node.js +86 -0
- package/dist/auth0/core/node.js.map +1 -0
- package/dist/auth0/core/schema/migrations.d.ts +3 -0
- package/dist/auth0/core/schema/migrations.d.ts.map +1 -0
- package/dist/auth0/core/schema/migrations.js +17 -0
- package/dist/auth0/core/schema/migrations.js.map +1 -0
- package/dist/auth0/core/schema/models.d.ts +6 -0
- package/dist/auth0/core/schema/models.d.ts.map +1 -0
- package/dist/auth0/core/schema/models.js +33 -0
- package/dist/auth0/core/schema/models.js.map +1 -0
- package/dist/auth0/core/schema/plugin-definition.d.ts +73 -0
- package/dist/auth0/core/schema/plugin-definition.d.ts.map +1 -0
- package/dist/auth0/core/schema/plugin-definition.js +17 -0
- package/dist/auth0/core/schema/plugin-definition.js.map +1 -0
- package/dist/auth0/core/web.d.ts +6 -0
- package/dist/auth0/core/web.d.ts.map +1 -0
- package/dist/auth0/core/web.js +14 -0
- package/dist/auth0/core/web.js.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts +67 -0
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js +125 -0
- package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts +3 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js +12 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.d.ts +43 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.d.ts.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.js +25 -0
- package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.js.map +1 -0
- package/dist/auth0/generators/fastify/auth0-module/templates/management.ts +22 -0
- package/dist/auth0/generators/fastify/auth0-module/templates/user-session.service.ts +101 -0
- package/dist/auth0/generators/fastify/index.d.ts +2 -0
- package/dist/auth0/generators/fastify/index.d.ts.map +1 -0
- package/dist/auth0/generators/fastify/index.js +2 -0
- package/dist/auth0/generators/fastify/index.js.map +1 -0
- package/dist/auth0/generators/index.d.ts +3 -0
- package/dist/auth0/generators/index.d.ts.map +1 -0
- package/dist/auth0/generators/index.js +3 -0
- package/dist/auth0/generators/index.js.map +1 -0
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +10 -0
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js +41 -0
- package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js.map +1 -0
- package/dist/auth0/generators/react/auth0-apollo/templates/auth-link.ts +11 -0
- package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts +61 -0
- package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js +59 -0
- package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js.map +1 -0
- package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts +106 -0
- package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.js +28 -0
- package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.js.map +1 -0
- package/dist/auth0/generators/react/auth0-callback/templates/auth0-callback.page.tsx +61 -0
- package/dist/auth0/generators/react/auth0-callback/templates/signup.page.tsx +48 -0
- package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts +53 -0
- package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js +44 -0
- package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js.map +1 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts +3 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js +12 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js.map +1 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts +45 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js +13 -0
- package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js.map +1 -0
- package/dist/auth0/generators/react/auth0-components/templates/RequireAuth.tsx +22 -0
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +28 -0
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js +65 -0
- package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts +8 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js +12 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts +3 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js +16 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts +33 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js +50 -0
- package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js.map +1 -0
- package/dist/auth0/generators/react/auth0-hooks/templates/useCurrentUser.gql +10 -0
- package/dist/auth0/generators/react/auth0-hooks/templates/useCurrentUser.ts +29 -0
- package/dist/auth0/generators/react/auth0-hooks/templates/useLogOut.ts +14 -0
- package/dist/auth0/generators/react/auth0-hooks/templates/useRequiredUserId.ts +11 -0
- package/dist/auth0/generators/react/auth0-hooks/templates/useSession.ts +23 -0
- package/dist/auth0/generators/react/index.d.ts +6 -0
- package/dist/auth0/generators/react/index.d.ts.map +1 -0
- package/dist/auth0/generators/react/index.js +6 -0
- package/dist/auth0/generators/react/index.js.map +1 -0
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts +23 -0
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts.map +1 -0
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js +64 -0
- package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js.map +1 -0
- package/dist/auth0/metadata.json +8 -0
- package/dist/auth0/static/icon.svg +7 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/roles/constants.d.ts +4 -0
- package/dist/roles/constants.d.ts.map +1 -0
- package/dist/roles/constants.js +25 -0
- package/dist/roles/constants.js.map +1 -0
- package/dist/roles/index.d.ts +3 -0
- package/dist/roles/index.d.ts.map +1 -0
- package/dist/roles/index.js +3 -0
- package/dist/roles/index.js.map +1 -0
- package/dist/roles/schema.d.ts +65 -0
- package/dist/roles/schema.d.ts.map +1 -0
- package/dist/roles/schema.js +43 -0
- package/dist/roles/schema.js.map +1 -0
- package/dist/utils/cn.d.ts +2 -0
- package/dist/utils/cn.d.ts.map +1 -0
- package/dist/utils/cn.js +2 -0
- package/dist/utils/cn.js.map +1 -0
- package/dist/web/assets/__federation_expose_auth0CoreCommon--n6esVYP.js +54 -0
- package/dist/web/assets/__federation_expose_auth0CoreCommon--n6esVYP.js.map +1 -0
- package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js +377 -0
- package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js.map +1 -0
- package/dist/web/assets/__federation_fn_import-BiwmVFwy.js +421 -0
- package/dist/web/assets/__federation_fn_import-BiwmVFwy.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js +330 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js +10559 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js.map +1 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js +12718 -0
- package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js.map +1 -0
- package/dist/web/assets/__federation_shared_react-dom-Bwq4pLax.js +250 -0
- package/dist/web/assets/__federation_shared_react-dom-Bwq4pLax.js.map +1 -0
- package/dist/web/assets/__federation_shared_react-uocnGSER.js +7 -0
- package/dist/web/assets/__federation_shared_react-uocnGSER.js.map +1 -0
- package/dist/web/assets/__federation_shared_zod-BK7IELHt.js +4380 -0
- package/dist/web/assets/__federation_shared_zod-BK7IELHt.js.map +1 -0
- package/dist/web/assets/index-B1hOKVPw.js +574 -0
- package/dist/web/assets/index-B1hOKVPw.js.map +1 -0
- package/dist/web/assets/index-CgJx-krK.js +95 -0
- package/dist/web/assets/index-CgJx-krK.js.map +1 -0
- package/dist/web/assets/index-l0sNRNKZ.js.map +1 -0
- package/dist/web/assets/index.esm-BcxPd7Ha.js +2584 -0
- package/dist/web/assets/index.esm-BcxPd7Ha.js.map +1 -0
- package/dist/web/assets/model-utils-CbQJy1wE.js +1263 -0
- package/dist/web/assets/model-utils-CbQJy1wE.js.map +1 -0
- package/dist/web/assets/plugin-definition-BQRupXoQ.js +78 -0
- package/dist/web/assets/plugin-definition-BQRupXoQ.js.map +1 -0
- package/dist/web/assets/react-2jQE8aG0.js +47 -0
- package/dist/web/assets/react-2jQE8aG0.js.map +1 -0
- package/dist/web/assets/remoteEntry.js +54 -0
- package/dist/web/assets/remoteEntry.js.map +1 -0
- package/dist/web/assets/style-BdgwWjAf.css +95 -0
- package/dist/web/index.html +24 -0
- package/dist/web-export.d.ts +2 -0
- package/dist/web-export.js +2 -0
- package/dist/web-export.js.map +1 -0
- package/manifest.json +4 -0
- package/package.json +80 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { tsCodeFragment, TsCodeUtils, tsImportBuilder, } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { reactApolloConfigProvider } from '@baseplate-dev/react-generators';
|
|
3
|
+
import { createGenerator, createGeneratorTask } from '@baseplate-dev/sync';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
const descriptorSchema = z.object({});
|
|
6
|
+
export const auth0ApolloGenerator = createGenerator({
|
|
7
|
+
name: 'auth0/auth0-apollo',
|
|
8
|
+
generatorFileUrl: import.meta.url,
|
|
9
|
+
descriptorSchema,
|
|
10
|
+
buildTasks: () => ({
|
|
11
|
+
main: createGeneratorTask({
|
|
12
|
+
dependencies: {
|
|
13
|
+
reactApolloConfig: reactApolloConfigProvider,
|
|
14
|
+
},
|
|
15
|
+
run({ reactApolloConfig }) {
|
|
16
|
+
reactApolloConfig.createApolloClientArguments.add({
|
|
17
|
+
name: 'getAccessToken',
|
|
18
|
+
type: '() => Promise<string | undefined>',
|
|
19
|
+
reactRenderBody: tsCodeFragment('const { getAccessTokenSilently: getAccessToken } = useAuth0();', tsImportBuilder(['useAuth0']).from('@auth0/auth0-react')),
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
providers: {
|
|
23
|
+
auth0Apollo: {},
|
|
24
|
+
},
|
|
25
|
+
build: async (builder) => {
|
|
26
|
+
const linkTemplate = await builder.readTemplate('auth-link.ts');
|
|
27
|
+
const authLink = TsCodeUtils.extractTemplateSnippet(linkTemplate, 'AUTH_LINK');
|
|
28
|
+
reactApolloConfig.apolloLinks.add({
|
|
29
|
+
name: 'authLink',
|
|
30
|
+
bodyFragment: tsCodeFragment(authLink, [
|
|
31
|
+
tsImportBuilder(['setContext']).from('@apollo/client/link/context'),
|
|
32
|
+
]),
|
|
33
|
+
priority: 'auth',
|
|
34
|
+
});
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
}),
|
|
40
|
+
});
|
|
41
|
+
//# sourceMappingURL=auth0-apollo.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-apollo.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-apollo/auth0-apollo.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,yBAAyB,EAAE,MAAM,iCAAiC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,oBAAoB,GAAG,eAAe,CAAC;IAClD,IAAI,EAAE,oBAAoB;IAC1B,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACjC,gBAAgB;IAChB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;YACxB,YAAY,EAAE;gBACZ,iBAAiB,EAAE,yBAAyB;aAC7C;YACD,GAAG,CAAC,EAAE,iBAAiB,EAAE;gBACvB,iBAAiB,CAAC,2BAA2B,CAAC,GAAG,CAAC;oBAChD,IAAI,EAAE,gBAAgB;oBACtB,IAAI,EAAE,mCAAmC;oBACzC,eAAe,EAAE,cAAc,CAC7B,gEAAgE,EAChE,eAAe,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CACzD;iBACF,CAAC,CAAC;gBAEH,OAAO;oBACL,SAAS,EAAE;wBACT,WAAW,EAAE,EAAE;qBAChB;oBACD,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;wBACvB,MAAM,YAAY,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC;wBAChE,MAAM,QAAQ,GAAG,WAAW,CAAC,sBAAsB,CACjD,YAAY,EACZ,WAAW,CACZ,CAAC;wBAEF,iBAAiB,CAAC,WAAW,CAAC,GAAG,CAAC;4BAChC,IAAI,EAAE,UAAU;4BAChB,YAAY,EAAE,cAAc,CAAC,QAAQ,EAAE;gCACrC,eAAe,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,IAAI,CAClC,6BAA6B,CAC9B;6BACF,CAAC;4BACF,QAAQ,EAAE,MAAM;yBACjB,CAAC,CAAC;oBACL,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
// AUTH_LINK:START
|
|
4
|
+
const authLink = setContext(async () => {
|
|
5
|
+
const accessToken = await getAccessToken();
|
|
6
|
+
if (!accessToken) {
|
|
7
|
+
return {};
|
|
8
|
+
}
|
|
9
|
+
return { headers: { authorization: `Bearer ${accessToken}` } };
|
|
10
|
+
});
|
|
11
|
+
// AUTH_LINK:END
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export declare const auth0CallbackGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{}, {
|
|
2
|
+
main: import("@baseplate-dev/sync").GeneratorTask<any, {
|
|
3
|
+
typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
|
|
4
|
+
reactComponentsImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
5
|
+
Alert: {};
|
|
6
|
+
AlertIcon: {};
|
|
7
|
+
BackButton: {};
|
|
8
|
+
Button: {};
|
|
9
|
+
ButtonGroup: {};
|
|
10
|
+
Card: {};
|
|
11
|
+
CheckedInput: {};
|
|
12
|
+
ConfirmDialog: {};
|
|
13
|
+
ErrorableLoader: {};
|
|
14
|
+
ErrorDisplay: {};
|
|
15
|
+
FormError: {};
|
|
16
|
+
FormLabel: {};
|
|
17
|
+
LinkButton: {};
|
|
18
|
+
ListGroup: {};
|
|
19
|
+
Modal: {};
|
|
20
|
+
NotFoundCard: {};
|
|
21
|
+
ReactDatePickerInput: {};
|
|
22
|
+
ReactSelectInput: {};
|
|
23
|
+
SelectInput: {};
|
|
24
|
+
Sidebar: {};
|
|
25
|
+
Spinner: {};
|
|
26
|
+
Status: {
|
|
27
|
+
isTypeOnly: true;
|
|
28
|
+
};
|
|
29
|
+
StatusType: {
|
|
30
|
+
isTypeOnly: true;
|
|
31
|
+
};
|
|
32
|
+
Table: {};
|
|
33
|
+
TextAreaInput: {};
|
|
34
|
+
TextInput: {};
|
|
35
|
+
Toast: {};
|
|
36
|
+
useConfirmDialog: {};
|
|
37
|
+
UseConfirmDialogRequestOptions: {
|
|
38
|
+
isTypeOnly: true;
|
|
39
|
+
};
|
|
40
|
+
useConfirmDialogState: {};
|
|
41
|
+
useStatus: {};
|
|
42
|
+
useToast: {};
|
|
43
|
+
}>>;
|
|
44
|
+
authHooksImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
45
|
+
SessionData: {
|
|
46
|
+
isTypeOnly: true;
|
|
47
|
+
};
|
|
48
|
+
useCurrentUser: {};
|
|
49
|
+
useLogOut: {};
|
|
50
|
+
useRequiredUserId: {};
|
|
51
|
+
useSession: {};
|
|
52
|
+
}>>;
|
|
53
|
+
reactErrorImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
54
|
+
formatError: {};
|
|
55
|
+
logAndFormatError: {};
|
|
56
|
+
logError: {};
|
|
57
|
+
}>>;
|
|
58
|
+
reactRoutes: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/react-generators").ReactRoutesProvider>;
|
|
59
|
+
}, any>;
|
|
60
|
+
}>;
|
|
61
|
+
//# sourceMappingURL=auth0-callback.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-callback.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-callback/auth0-callback.generator.ts"],"names":[],"mappings":"AAgBA,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAyEjC,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { typescriptFileProvider } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { authHooksImportsProvider, createRouteElement, reactComponentsImportsProvider, reactErrorImportsProvider, reactRoutesProvider, } from '@baseplate-dev/react-generators';
|
|
3
|
+
import { createGenerator, createGeneratorTask } from '@baseplate-dev/sync';
|
|
4
|
+
import path from 'node:path/posix';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { AUTH_0_AUTH_0_CALLBACK_TS_TEMPLATES } from './generated/ts-templates.js';
|
|
7
|
+
const descriptorSchema = z.object({});
|
|
8
|
+
export const auth0CallbackGenerator = createGenerator({
|
|
9
|
+
name: 'auth0/auth0-callback',
|
|
10
|
+
generatorFileUrl: import.meta.url,
|
|
11
|
+
descriptorSchema,
|
|
12
|
+
buildTasks: () => ({
|
|
13
|
+
main: createGeneratorTask({
|
|
14
|
+
dependencies: {
|
|
15
|
+
typescriptFile: typescriptFileProvider,
|
|
16
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
17
|
+
authHooksImports: authHooksImportsProvider,
|
|
18
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
19
|
+
reactRoutes: reactRoutesProvider,
|
|
20
|
+
},
|
|
21
|
+
run({ typescriptFile, reactComponentsImports, authHooksImports, reactErrorImports, reactRoutes, }) {
|
|
22
|
+
const callbackPagePath = path.join(reactRoutes.getDirectoryBase(), 'auth0-callback.page.tsx');
|
|
23
|
+
const signupPagePath = path.join(reactRoutes.getDirectoryBase(), 'signup.page.tsx');
|
|
24
|
+
return {
|
|
25
|
+
build: async (builder) => {
|
|
26
|
+
// Callback page
|
|
27
|
+
reactRoutes.registerRoute({
|
|
28
|
+
path: 'auth0-callback',
|
|
29
|
+
element: createRouteElement('Auth0CallbackPage', callbackPagePath),
|
|
30
|
+
});
|
|
31
|
+
await builder.apply(typescriptFile.renderTemplateFile({
|
|
32
|
+
template: AUTH_0_AUTH_0_CALLBACK_TS_TEMPLATES.auth0CallbackPage,
|
|
33
|
+
destination: callbackPagePath,
|
|
34
|
+
importMapProviders: {
|
|
35
|
+
authHooksImports,
|
|
36
|
+
reactComponentsImports,
|
|
37
|
+
reactErrorImports,
|
|
38
|
+
},
|
|
39
|
+
}));
|
|
40
|
+
// Signup page
|
|
41
|
+
reactRoutes.registerRoute({
|
|
42
|
+
path: 'signup',
|
|
43
|
+
element: createRouteElement('SignupPage', signupPagePath),
|
|
44
|
+
});
|
|
45
|
+
await builder.apply(typescriptFile.renderTemplateFile({
|
|
46
|
+
template: AUTH_0_AUTH_0_CALLBACK_TS_TEMPLATES.signupPage,
|
|
47
|
+
destination: signupPagePath,
|
|
48
|
+
importMapProviders: {
|
|
49
|
+
reactComponentsImports,
|
|
50
|
+
reactErrorImports,
|
|
51
|
+
},
|
|
52
|
+
}));
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
}),
|
|
57
|
+
}),
|
|
58
|
+
});
|
|
59
|
+
//# sourceMappingURL=auth0-callback.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-callback.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-callback/auth0-callback.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AACxE,OAAO,EACL,wBAAwB,EACxB,kBAAkB,EAClB,8BAA8B,EAC9B,yBAAyB,EACzB,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,IAAI,MAAM,iBAAiB,CAAC;AACnC,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,mCAAmC,EAAE,MAAM,6BAA6B,CAAC;AAElF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,sBAAsB,GAAG,eAAe,CAAC;IACpD,IAAI,EAAE,sBAAsB;IAC5B,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACjC,gBAAgB;IAChB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;YACxB,YAAY,EAAE;gBACZ,cAAc,EAAE,sBAAsB;gBACtC,sBAAsB,EAAE,8BAA8B;gBACtD,gBAAgB,EAAE,wBAAwB;gBAC1C,iBAAiB,EAAE,yBAAyB;gBAC5C,WAAW,EAAE,mBAAmB;aACjC;YACD,GAAG,CAAC,EACF,cAAc,EACd,sBAAsB,EACtB,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,GACZ;gBACC,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAChC,WAAW,CAAC,gBAAgB,EAAE,EAC9B,yBAAyB,CAC1B,CAAC;gBACF,MAAM,cAAc,GAAG,IAAI,CAAC,IAAI,CAC9B,WAAW,CAAC,gBAAgB,EAAE,EAC9B,iBAAiB,CAClB,CAAC;gBAEF,OAAO;oBACL,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;wBACvB,gBAAgB;wBAChB,WAAW,CAAC,aAAa,CAAC;4BACxB,IAAI,EAAE,gBAAgB;4BACtB,OAAO,EAAE,kBAAkB,CACzB,mBAAmB,EACnB,gBAAgB,CACjB;yBACF,CAAC,CAAC;wBAEH,MAAM,OAAO,CAAC,KAAK,CACjB,cAAc,CAAC,kBAAkB,CAAC;4BAChC,QAAQ,EAAE,mCAAmC,CAAC,iBAAiB;4BAC/D,WAAW,EAAE,gBAAgB;4BAC7B,kBAAkB,EAAE;gCAClB,gBAAgB;gCAChB,sBAAsB;gCACtB,iBAAiB;6BAClB;yBACF,CAAC,CACH,CAAC;wBAEF,cAAc;wBACd,WAAW,CAAC,aAAa,CAAC;4BACxB,IAAI,EAAE,QAAQ;4BACd,OAAO,EAAE,kBAAkB,CAAC,YAAY,EAAE,cAAc,CAAC;yBAC1D,CAAC,CAAC;wBAEH,MAAM,OAAO,CAAC,KAAK,CACjB,cAAc,CAAC,kBAAkB,CAAC;4BAChC,QAAQ,EAAE,mCAAmC,CAAC,UAAU;4BACxD,WAAW,EAAE,cAAc;4BAC3B,kBAAkB,EAAE;gCAClB,sBAAsB;gCACtB,iBAAiB;6BAClB;yBACF,CAAC,CACH,CAAC;oBACJ,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
export declare const AUTH_0_AUTH_0_CALLBACK_TS_TEMPLATES: {
|
|
2
|
+
auth0CallbackPage: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
3
|
+
authHooksImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
4
|
+
SessionData: {
|
|
5
|
+
isTypeOnly: true;
|
|
6
|
+
};
|
|
7
|
+
useCurrentUser: {};
|
|
8
|
+
useLogOut: {};
|
|
9
|
+
useRequiredUserId: {};
|
|
10
|
+
useSession: {};
|
|
11
|
+
}>>;
|
|
12
|
+
reactComponentsImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
13
|
+
Alert: {};
|
|
14
|
+
AlertIcon: {};
|
|
15
|
+
BackButton: {};
|
|
16
|
+
Button: {};
|
|
17
|
+
ButtonGroup: {};
|
|
18
|
+
Card: {};
|
|
19
|
+
CheckedInput: {};
|
|
20
|
+
ConfirmDialog: {};
|
|
21
|
+
ErrorableLoader: {};
|
|
22
|
+
ErrorDisplay: {};
|
|
23
|
+
FormError: {};
|
|
24
|
+
FormLabel: {};
|
|
25
|
+
LinkButton: {};
|
|
26
|
+
ListGroup: {};
|
|
27
|
+
Modal: {};
|
|
28
|
+
NotFoundCard: {};
|
|
29
|
+
ReactDatePickerInput: {};
|
|
30
|
+
ReactSelectInput: {};
|
|
31
|
+
SelectInput: {};
|
|
32
|
+
Sidebar: {};
|
|
33
|
+
Spinner: {};
|
|
34
|
+
Status: {
|
|
35
|
+
isTypeOnly: true;
|
|
36
|
+
};
|
|
37
|
+
StatusType: {
|
|
38
|
+
isTypeOnly: true;
|
|
39
|
+
};
|
|
40
|
+
Table: {};
|
|
41
|
+
TextAreaInput: {};
|
|
42
|
+
TextInput: {};
|
|
43
|
+
Toast: {};
|
|
44
|
+
useConfirmDialog: {};
|
|
45
|
+
UseConfirmDialogRequestOptions: {
|
|
46
|
+
isTypeOnly: true;
|
|
47
|
+
};
|
|
48
|
+
useConfirmDialogState: {};
|
|
49
|
+
useStatus: {};
|
|
50
|
+
useToast: {};
|
|
51
|
+
}>>;
|
|
52
|
+
reactErrorImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
53
|
+
formatError: {};
|
|
54
|
+
logAndFormatError: {};
|
|
55
|
+
logError: {};
|
|
56
|
+
}>>;
|
|
57
|
+
}>;
|
|
58
|
+
signupPage: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
59
|
+
reactComponentsImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
60
|
+
Alert: {};
|
|
61
|
+
AlertIcon: {};
|
|
62
|
+
BackButton: {};
|
|
63
|
+
Button: {};
|
|
64
|
+
ButtonGroup: {};
|
|
65
|
+
Card: {};
|
|
66
|
+
CheckedInput: {};
|
|
67
|
+
ConfirmDialog: {};
|
|
68
|
+
ErrorableLoader: {};
|
|
69
|
+
ErrorDisplay: {};
|
|
70
|
+
FormError: {};
|
|
71
|
+
FormLabel: {};
|
|
72
|
+
LinkButton: {};
|
|
73
|
+
ListGroup: {};
|
|
74
|
+
Modal: {};
|
|
75
|
+
NotFoundCard: {};
|
|
76
|
+
ReactDatePickerInput: {};
|
|
77
|
+
ReactSelectInput: {};
|
|
78
|
+
SelectInput: {};
|
|
79
|
+
Sidebar: {};
|
|
80
|
+
Spinner: {};
|
|
81
|
+
Status: {
|
|
82
|
+
isTypeOnly: true;
|
|
83
|
+
};
|
|
84
|
+
StatusType: {
|
|
85
|
+
isTypeOnly: true;
|
|
86
|
+
};
|
|
87
|
+
Table: {};
|
|
88
|
+
TextAreaInput: {};
|
|
89
|
+
TextInput: {};
|
|
90
|
+
Toast: {};
|
|
91
|
+
useConfirmDialog: {};
|
|
92
|
+
UseConfirmDialogRequestOptions: {
|
|
93
|
+
isTypeOnly: true;
|
|
94
|
+
};
|
|
95
|
+
useConfirmDialogState: {};
|
|
96
|
+
useStatus: {};
|
|
97
|
+
useToast: {};
|
|
98
|
+
}>>;
|
|
99
|
+
reactErrorImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
100
|
+
formatError: {};
|
|
101
|
+
logAndFormatError: {};
|
|
102
|
+
logError: {};
|
|
103
|
+
}>>;
|
|
104
|
+
}>;
|
|
105
|
+
};
|
|
106
|
+
//# sourceMappingURL=ts-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-callback/generated/ts-templates.ts"],"names":[],"mappings":"AA8BA,eAAO,MAAM,mCAAmC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG/C,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { authHooksImportsProvider, reactComponentsImportsProvider, reactErrorImportsProvider, } from '@baseplate-dev/react-generators';
|
|
3
|
+
const auth0CallbackPage = createTsTemplateFile({
|
|
4
|
+
importMapProviders: {
|
|
5
|
+
authHooksImports: authHooksImportsProvider,
|
|
6
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
7
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
8
|
+
},
|
|
9
|
+
name: 'auth0-callback-page',
|
|
10
|
+
projectExports: {},
|
|
11
|
+
source: { path: 'auth0-callback.page.tsx' },
|
|
12
|
+
variables: {},
|
|
13
|
+
});
|
|
14
|
+
const signupPage = createTsTemplateFile({
|
|
15
|
+
importMapProviders: {
|
|
16
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
17
|
+
reactErrorImports: reactErrorImportsProvider,
|
|
18
|
+
},
|
|
19
|
+
name: 'signup-page',
|
|
20
|
+
projectExports: {},
|
|
21
|
+
source: { path: 'signup.page.tsx' },
|
|
22
|
+
variables: {},
|
|
23
|
+
});
|
|
24
|
+
export const AUTH_0_AUTH_0_CALLBACK_TS_TEMPLATES = {
|
|
25
|
+
auth0CallbackPage,
|
|
26
|
+
signupPage,
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=ts-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-callback/generated/ts-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC9B,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;IAC7C,kBAAkB,EAAE;QAClB,gBAAgB,EAAE,wBAAwB;QAC1C,sBAAsB,EAAE,8BAA8B;QACtD,iBAAiB,EAAE,yBAAyB;KAC7C;IACD,IAAI,EAAE,qBAAqB;IAC3B,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;IAC3C,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,oBAAoB,CAAC;IACtC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,8BAA8B;QACtD,iBAAiB,EAAE,yBAAyB;KAC7C;IACD,IAAI,EAAE,aAAa;IACnB,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACnC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mCAAmC,GAAG;IACjD,iBAAiB;IACjB,UAAU;CACX,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
import { useLogOut } from '%authHooksImports';
|
|
6
|
+
import { Alert, Button, Card, Spinner } from '%reactComponentsImports';
|
|
7
|
+
import { logError } from '%reactErrorImports';
|
|
8
|
+
import { OAuthError, useAuth0 } from '@auth0/auth0-react';
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { useNavigate } from 'react-router-dom';
|
|
11
|
+
|
|
12
|
+
function formatAndReportAuthError(error: unknown): string {
|
|
13
|
+
if (
|
|
14
|
+
error instanceof OAuthError &&
|
|
15
|
+
error.error === 'access_denied' &&
|
|
16
|
+
error.error_description?.includes('INVALID_ROLE')
|
|
17
|
+
) {
|
|
18
|
+
return 'You do not have permission to access this page.';
|
|
19
|
+
}
|
|
20
|
+
logError(error);
|
|
21
|
+
return 'Sorry, we could not log you in. Please try again.';
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function Auth0CallbackPage(): ReactElement {
|
|
25
|
+
const logOut = useLogOut();
|
|
26
|
+
const navigate = useNavigate();
|
|
27
|
+
|
|
28
|
+
const { handleRedirectCallback } = useAuth0();
|
|
29
|
+
const [error, setError] = useState<string | null>(null);
|
|
30
|
+
// https://github.com/auth0/auth0-react/pull/355
|
|
31
|
+
const didHandleRedirect = useRef(false);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (didHandleRedirect.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
didHandleRedirect.current = true;
|
|
38
|
+
handleRedirectCallback()
|
|
39
|
+
.then(({ appState }: { appState?: { returnTo?: string } }) => {
|
|
40
|
+
navigate(appState?.returnTo ?? '/', { replace: true });
|
|
41
|
+
})
|
|
42
|
+
.catch((err: unknown) => {
|
|
43
|
+
setError(formatAndReportAuthError(err));
|
|
44
|
+
});
|
|
45
|
+
}, [handleRedirectCallback, navigate]);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div className="flex h-full items-center justify-center">
|
|
49
|
+
{error ? (
|
|
50
|
+
<Card className="space-y-4 p-4">
|
|
51
|
+
<Alert type="error">{error}</Alert>
|
|
52
|
+
<Button onClick={logOut}>Try Again</Button>
|
|
53
|
+
</Card>
|
|
54
|
+
) : (
|
|
55
|
+
<Spinner size="large" />
|
|
56
|
+
)}
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export default Auth0CallbackPage;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import type { ReactElement } from 'react';
|
|
4
|
+
|
|
5
|
+
import { Alert, Button, Card, Spinner } from '%reactComponentsImports';
|
|
6
|
+
import { logAndFormatError } from '%reactErrorImports';
|
|
7
|
+
import { useAuth0 } from '@auth0/auth0-react';
|
|
8
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
9
|
+
import { Navigate } from 'react-router-dom';
|
|
10
|
+
|
|
11
|
+
function SignupPage(): ReactElement {
|
|
12
|
+
const { loginWithRedirect, isAuthenticated } = useAuth0();
|
|
13
|
+
const [error, setError] = useState<string | null>(null);
|
|
14
|
+
|
|
15
|
+
const redirectToSignup = useCallback((): void => {
|
|
16
|
+
loginWithRedirect({ authorizationParams: { screen_hint: 'signup' } }).catch(
|
|
17
|
+
(err: unknown) => {
|
|
18
|
+
setError(logAndFormatError(err));
|
|
19
|
+
},
|
|
20
|
+
);
|
|
21
|
+
}, [loginWithRedirect]);
|
|
22
|
+
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (!isAuthenticated) {
|
|
25
|
+
redirectToSignup();
|
|
26
|
+
}
|
|
27
|
+
}, [isAuthenticated, redirectToSignup]);
|
|
28
|
+
|
|
29
|
+
// if they are already authenticated, redirect them to home
|
|
30
|
+
if (isAuthenticated) {
|
|
31
|
+
return <Navigate to="/" />;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<div className="flex h-full items-center justify-center">
|
|
36
|
+
{error ? (
|
|
37
|
+
<Card className="space-y-4 p-4">
|
|
38
|
+
<Alert type="error">{error}</Alert>
|
|
39
|
+
<Button onClick={redirectToSignup}>Try Again</Button>
|
|
40
|
+
</Card>
|
|
41
|
+
) : (
|
|
42
|
+
<Spinner size="large" />
|
|
43
|
+
)}
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export default SignupPage;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export declare const auth0ComponentsGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{}, {
|
|
2
|
+
main: import("@baseplate-dev/sync").GeneratorTask<{
|
|
3
|
+
authComponentsImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
4
|
+
RequireAuth: {
|
|
5
|
+
name: string;
|
|
6
|
+
};
|
|
7
|
+
}>>;
|
|
8
|
+
}, {
|
|
9
|
+
reactComponents: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/react-generators").ReactComponentsProvider>;
|
|
10
|
+
reactComponentsImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
11
|
+
Alert: {};
|
|
12
|
+
AlertIcon: {};
|
|
13
|
+
BackButton: {};
|
|
14
|
+
Button: {};
|
|
15
|
+
ButtonGroup: {};
|
|
16
|
+
Card: {};
|
|
17
|
+
CheckedInput: {};
|
|
18
|
+
ConfirmDialog: {};
|
|
19
|
+
ErrorableLoader: {};
|
|
20
|
+
ErrorDisplay: {};
|
|
21
|
+
FormError: {};
|
|
22
|
+
FormLabel: {};
|
|
23
|
+
LinkButton: {};
|
|
24
|
+
ListGroup: {};
|
|
25
|
+
Modal: {};
|
|
26
|
+
NotFoundCard: {};
|
|
27
|
+
ReactDatePickerInput: {};
|
|
28
|
+
ReactSelectInput: {};
|
|
29
|
+
SelectInput: {};
|
|
30
|
+
Sidebar: {};
|
|
31
|
+
Spinner: {};
|
|
32
|
+
Status: {
|
|
33
|
+
isTypeOnly: true;
|
|
34
|
+
};
|
|
35
|
+
StatusType: {
|
|
36
|
+
isTypeOnly: true;
|
|
37
|
+
};
|
|
38
|
+
Table: {};
|
|
39
|
+
TextAreaInput: {};
|
|
40
|
+
TextInput: {};
|
|
41
|
+
Toast: {};
|
|
42
|
+
useConfirmDialog: {};
|
|
43
|
+
UseConfirmDialogRequestOptions: {
|
|
44
|
+
isTypeOnly: true;
|
|
45
|
+
};
|
|
46
|
+
useConfirmDialogState: {};
|
|
47
|
+
useStatus: {};
|
|
48
|
+
useToast: {};
|
|
49
|
+
}>>;
|
|
50
|
+
typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
|
|
51
|
+
}, any>;
|
|
52
|
+
}>;
|
|
53
|
+
//# sourceMappingURL=auth0-components.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-components.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-components/auth0-components.generator.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwCnC,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { projectScope, typescriptFileProvider, } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { authComponentsImportsProvider, reactComponentsImportsProvider, reactComponentsProvider, } from '@baseplate-dev/react-generators';
|
|
3
|
+
import { createGenerator, createGeneratorTask } from '@baseplate-dev/sync';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { z } from 'zod';
|
|
6
|
+
import { createAuth0ComponentsImports } from './generated/ts-import-maps.js';
|
|
7
|
+
import { AUTH_0_AUTH_0_COMPONENTS_TS_TEMPLATES } from './generated/ts-templates.js';
|
|
8
|
+
const descriptorSchema = z.object({});
|
|
9
|
+
export const auth0ComponentsGenerator = createGenerator({
|
|
10
|
+
name: 'auth0/auth0-components',
|
|
11
|
+
generatorFileUrl: import.meta.url,
|
|
12
|
+
descriptorSchema,
|
|
13
|
+
buildTasks: () => ({
|
|
14
|
+
main: createGeneratorTask({
|
|
15
|
+
dependencies: {
|
|
16
|
+
reactComponents: reactComponentsProvider,
|
|
17
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
18
|
+
typescriptFile: typescriptFileProvider,
|
|
19
|
+
},
|
|
20
|
+
exports: {
|
|
21
|
+
authComponentsImports: authComponentsImportsProvider.export(projectScope),
|
|
22
|
+
},
|
|
23
|
+
run({ reactComponents, typescriptFile, reactComponentsImports }) {
|
|
24
|
+
const requireAuthPath = `${reactComponents.getComponentsFolder()}/RequireAuth/index.tsx`;
|
|
25
|
+
reactComponents.registerComponent({ name: 'RequireAuth' });
|
|
26
|
+
return {
|
|
27
|
+
providers: {
|
|
28
|
+
authComponentsImports: createAuth0ComponentsImports(path.dirname(requireAuthPath)),
|
|
29
|
+
},
|
|
30
|
+
build: async (builder) => {
|
|
31
|
+
await builder.apply(typescriptFile.renderTemplateFile({
|
|
32
|
+
template: AUTH_0_AUTH_0_COMPONENTS_TS_TEMPLATES.requireAuth,
|
|
33
|
+
destination: requireAuthPath,
|
|
34
|
+
importMapProviders: {
|
|
35
|
+
reactComponentsImports,
|
|
36
|
+
},
|
|
37
|
+
}));
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
}),
|
|
42
|
+
}),
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=auth0-components.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-components.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-components/auth0-components.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,6BAA6B,EAC7B,8BAA8B,EAC9B,uBAAuB,GACxB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC3E,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,qCAAqC,EAAE,MAAM,6BAA6B,CAAC;AAEpF,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAEtC,MAAM,CAAC,MAAM,wBAAwB,GAAG,eAAe,CAAC;IACtD,IAAI,EAAE,wBAAwB;IAC9B,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACjC,gBAAgB;IAChB,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;YACxB,YAAY,EAAE;gBACZ,eAAe,EAAE,uBAAuB;gBACxC,sBAAsB,EAAE,8BAA8B;gBACtD,cAAc,EAAE,sBAAsB;aACvC;YACD,OAAO,EAAE;gBACP,qBAAqB,EACnB,6BAA6B,CAAC,MAAM,CAAC,YAAY,CAAC;aACrD;YACD,GAAG,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,sBAAsB,EAAE;gBAC7D,MAAM,eAAe,GAAG,GAAG,eAAe,CAAC,mBAAmB,EAAE,wBAAwB,CAAC;gBACzF,eAAe,CAAC,iBAAiB,CAAC,EAAE,IAAI,EAAE,aAAa,EAAE,CAAC,CAAC;gBAE3D,OAAO;oBACL,SAAS,EAAE;wBACT,qBAAqB,EAAE,4BAA4B,CACjD,IAAI,CAAC,OAAO,CAAC,eAAe,CAAC,CAC9B;qBACF;oBACD,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;wBACvB,MAAM,OAAO,CAAC,KAAK,CACjB,cAAc,CAAC,kBAAkB,CAAC;4BAChC,QAAQ,EAAE,qCAAqC,CAAC,WAAW;4BAC3D,WAAW,EAAE,eAAe;4BAC5B,kBAAkB,EAAE;gCAClB,sBAAsB;6BACvB;yBACF,CAAC,CACH,CAAC;oBACJ,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-import-maps.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-components/generated/ts-import-maps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,iCAAiC,CAAC;AAMpF,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,GACjB,4BAA4B,CAQ9B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createTsImportMap } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { authComponentsImportsSchema } from '@baseplate-dev/react-generators';
|
|
3
|
+
import path from 'node:path/posix';
|
|
4
|
+
export function createAuth0ComponentsImports(importBase) {
|
|
5
|
+
if (!importBase.startsWith('@/')) {
|
|
6
|
+
throw new Error('importBase must start with @/');
|
|
7
|
+
}
|
|
8
|
+
return createTsImportMap(authComponentsImportsSchema, {
|
|
9
|
+
RequireAuth: path.join(importBase, 'index.js'),
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=ts-import-maps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-import-maps.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-components/generated/ts-import-maps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,MAAM,UAAU,4BAA4B,CAC1C,UAAkB;IAElB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,iBAAiB,CAAC,2BAA2B,EAAE;QACpD,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,UAAU,CAAC;KAC/C,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare const AUTH_0_AUTH_0_COMPONENTS_TS_TEMPLATES: {
|
|
2
|
+
requireAuth: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
3
|
+
reactComponentsImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
4
|
+
Alert: {};
|
|
5
|
+
AlertIcon: {};
|
|
6
|
+
BackButton: {};
|
|
7
|
+
Button: {};
|
|
8
|
+
ButtonGroup: {};
|
|
9
|
+
Card: {};
|
|
10
|
+
CheckedInput: {};
|
|
11
|
+
ConfirmDialog: {};
|
|
12
|
+
ErrorableLoader: {};
|
|
13
|
+
ErrorDisplay: {};
|
|
14
|
+
FormError: {};
|
|
15
|
+
FormLabel: {};
|
|
16
|
+
LinkButton: {};
|
|
17
|
+
ListGroup: {};
|
|
18
|
+
Modal: {};
|
|
19
|
+
NotFoundCard: {};
|
|
20
|
+
ReactDatePickerInput: {};
|
|
21
|
+
ReactSelectInput: {};
|
|
22
|
+
SelectInput: {};
|
|
23
|
+
Sidebar: {};
|
|
24
|
+
Spinner: {};
|
|
25
|
+
Status: {
|
|
26
|
+
isTypeOnly: true;
|
|
27
|
+
};
|
|
28
|
+
StatusType: {
|
|
29
|
+
isTypeOnly: true;
|
|
30
|
+
};
|
|
31
|
+
Table: {};
|
|
32
|
+
TextAreaInput: {};
|
|
33
|
+
TextInput: {};
|
|
34
|
+
Toast: {};
|
|
35
|
+
useConfirmDialog: {};
|
|
36
|
+
UseConfirmDialogRequestOptions: {
|
|
37
|
+
isTypeOnly: true;
|
|
38
|
+
};
|
|
39
|
+
useConfirmDialogState: {};
|
|
40
|
+
useStatus: {};
|
|
41
|
+
useToast: {};
|
|
42
|
+
}>>;
|
|
43
|
+
}>;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=ts-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-components/generated/ts-templates.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,qCAAqC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAkB,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { reactComponentsImportsProvider } from '@baseplate-dev/react-generators';
|
|
3
|
+
const requireAuth = createTsTemplateFile({
|
|
4
|
+
importMapProviders: {
|
|
5
|
+
reactComponentsImports: reactComponentsImportsProvider,
|
|
6
|
+
},
|
|
7
|
+
name: 'require-auth',
|
|
8
|
+
projectExports: { RequireAuth: { exportName: 'default' } },
|
|
9
|
+
source: { path: 'RequireAuth.tsx' },
|
|
10
|
+
variables: {},
|
|
11
|
+
});
|
|
12
|
+
export const AUTH_0_AUTH_0_COMPONENTS_TS_TEMPLATES = { requireAuth };
|
|
13
|
+
//# sourceMappingURL=ts-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-components/generated/ts-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAC;AAEjF,MAAM,WAAW,GAAG,oBAAoB,CAAC;IACvC,kBAAkB,EAAE;QAClB,sBAAsB,EAAE,8BAA8B;KACvD;IACD,IAAI,EAAE,cAAc;IACpB,cAAc,EAAE,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE;IAC1D,MAAM,EAAE,EAAE,IAAI,EAAE,iBAAiB,EAAE;IACnC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,qCAAqC,GAAG,EAAE,WAAW,EAAE,CAAC"}
|