@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,73 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const auth0PluginDefinitionSchema: z.ZodObject<{
|
|
3
|
+
modelRefs: z.ZodObject<{
|
|
4
|
+
user: import("@baseplate-dev/project-builder-lib").ZodRef<z.ZodString>;
|
|
5
|
+
}, "strip", z.ZodTypeAny, {
|
|
6
|
+
user: string;
|
|
7
|
+
}, {
|
|
8
|
+
user: string;
|
|
9
|
+
}>;
|
|
10
|
+
authFeatureRef: import("@baseplate-dev/project-builder-lib").ZodRef<z.ZodString>;
|
|
11
|
+
roles: z.ZodEffects<z.ZodEffects<z.ZodArray<import("@baseplate-dev/project-builder-lib").ZodRef<z.ZodObject<{
|
|
12
|
+
name: z.ZodString;
|
|
13
|
+
comment: z.ZodString;
|
|
14
|
+
builtIn: z.ZodDefault<z.ZodBoolean>;
|
|
15
|
+
} & {
|
|
16
|
+
id: z.ZodType<string, z.ZodAnyDef, string>;
|
|
17
|
+
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
id: string;
|
|
19
|
+
name: string;
|
|
20
|
+
comment: string;
|
|
21
|
+
builtIn: boolean;
|
|
22
|
+
}, {
|
|
23
|
+
id: string;
|
|
24
|
+
name: string;
|
|
25
|
+
comment: string;
|
|
26
|
+
builtIn?: boolean | undefined;
|
|
27
|
+
}>>, "many">, {
|
|
28
|
+
id: string;
|
|
29
|
+
name: string;
|
|
30
|
+
comment: string;
|
|
31
|
+
builtIn: boolean;
|
|
32
|
+
}[], {
|
|
33
|
+
id: string;
|
|
34
|
+
name: string;
|
|
35
|
+
comment: string;
|
|
36
|
+
builtIn?: boolean | undefined;
|
|
37
|
+
}[]>, {
|
|
38
|
+
id: string;
|
|
39
|
+
name: string;
|
|
40
|
+
comment: string;
|
|
41
|
+
builtIn: boolean;
|
|
42
|
+
}[], {
|
|
43
|
+
id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
comment: string;
|
|
46
|
+
builtIn?: boolean | undefined;
|
|
47
|
+
}[]>;
|
|
48
|
+
}, "strip", z.ZodTypeAny, {
|
|
49
|
+
modelRefs: {
|
|
50
|
+
user: string;
|
|
51
|
+
};
|
|
52
|
+
authFeatureRef: string;
|
|
53
|
+
roles: {
|
|
54
|
+
id: string;
|
|
55
|
+
name: string;
|
|
56
|
+
comment: string;
|
|
57
|
+
builtIn: boolean;
|
|
58
|
+
}[];
|
|
59
|
+
}, {
|
|
60
|
+
modelRefs: {
|
|
61
|
+
user: string;
|
|
62
|
+
};
|
|
63
|
+
authFeatureRef: string;
|
|
64
|
+
roles: {
|
|
65
|
+
id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
comment: string;
|
|
68
|
+
builtIn?: boolean | undefined;
|
|
69
|
+
}[];
|
|
70
|
+
}>;
|
|
71
|
+
export type Auth0PluginDefinition = z.infer<typeof auth0PluginDefinitionSchema>;
|
|
72
|
+
export type Auth0PluginDefinitionInput = z.input<typeof auth0PluginDefinitionSchema>;
|
|
73
|
+
//# sourceMappingURL=plugin-definition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-definition.d.ts","sourceRoot":"","sources":["../../../../src/auth0/core/schema/plugin-definition.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,eAAO,MAAM,2BAA2B;;;;;;;;;;;;;;YAmBspc,EAAG,OAAO,SAAQ,EAAG,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAP1tc,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,2BAA2B,CAAC,CAAC;AAEhF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,2BAA2B,CACnC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { featureEntityType, modelEntityType, zRef, } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { authRolesSchema } from '#src/roles/index.js';
|
|
4
|
+
export const auth0PluginDefinitionSchema = z.object({
|
|
5
|
+
modelRefs: z.object({
|
|
6
|
+
user: zRef(z.string().min(1), {
|
|
7
|
+
type: modelEntityType,
|
|
8
|
+
onDelete: 'RESTRICT',
|
|
9
|
+
}),
|
|
10
|
+
}),
|
|
11
|
+
authFeatureRef: zRef(z.string().min(1), {
|
|
12
|
+
type: featureEntityType,
|
|
13
|
+
onDelete: 'RESTRICT',
|
|
14
|
+
}),
|
|
15
|
+
roles: authRolesSchema,
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=plugin-definition.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-definition.js","sourceRoot":"","sources":["../../../../src/auth0/core/schema/plugin-definition.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,IAAI,GACL,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,CAAC,MAAM,CAAC;IAClD,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;YAC5B,IAAI,EAAE,eAAe;YACrB,QAAQ,EAAE,UAAU;SACrB,CAAC;KACH,CAAC;IACF,cAAc,EAAE,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE;QACtC,IAAI,EAAE,iBAAiB;QACvB,QAAQ,EAAE,UAAU;KACrB,CAAC;IACF,KAAK,EAAE,eAAe;CACvB,CAAC,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import '../../styles.css';
|
|
2
|
+
declare const _default: import("@baseplate-dev/project-builder-lib").PluginPlatformModule<{
|
|
3
|
+
webConfig: import("@baseplate-dev/project-builder-lib").PluginSpecWithInitializer<import("@baseplate-dev/project-builder-lib").WebConfigSpec>;
|
|
4
|
+
}, {}>;
|
|
5
|
+
export default _default;
|
|
6
|
+
//# sourceMappingURL=web.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.d.ts","sourceRoot":"","sources":["../../../src/auth0/core/web.ts"],"names":[],"mappings":"AAOA,OAAO,kBAAkB,CAAC;;;;AAE1B,wBASG"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { createPlatformPluginExport, webConfigSpec, } from '@baseplate-dev/project-builder-lib';
|
|
2
|
+
import { AuthDefinitionEditor } from './components/auth-definition-editor.js';
|
|
3
|
+
import '../../styles.css';
|
|
4
|
+
export default createPlatformPluginExport({
|
|
5
|
+
dependencies: {
|
|
6
|
+
webConfig: webConfigSpec,
|
|
7
|
+
},
|
|
8
|
+
exports: {},
|
|
9
|
+
initialize: ({ webConfig }, { pluginId }) => {
|
|
10
|
+
webConfig.registerWebConfigComponent(pluginId, AuthDefinitionEditor);
|
|
11
|
+
return {};
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=web.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"web.js","sourceRoot":"","sources":["../../../src/auth0/core/web.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,aAAa,GACd,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,MAAM,wCAAwC,CAAC;AAE9E,OAAO,kBAAkB,CAAC;AAE1B,eAAe,0BAA0B,CAAC;IACxC,YAAY,EAAE;QACZ,SAAS,EAAE,aAAa;KACzB;IACD,OAAO,EAAE,EAAE;IACX,UAAU,EAAE,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;QAC1C,SAAS,CAAC,0BAA0B,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;QACrE,OAAO,EAAE,CAAC;IACZ,CAAC;CACF,CAAC,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
export declare const auth0ModuleGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{
|
|
2
|
+
userModelName: string;
|
|
3
|
+
includeManagement?: boolean | undefined;
|
|
4
|
+
}, {
|
|
5
|
+
nodeManagementPackage: import("@baseplate-dev/sync").AnyGeneratorTask | undefined;
|
|
6
|
+
config: import("@baseplate-dev/sync").GeneratorTask<undefined, {
|
|
7
|
+
provider: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
|
|
8
|
+
configFields: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/fastify-generators").ConfigServiceField>;
|
|
9
|
+
}>, "getValues">>;
|
|
10
|
+
}, undefined>;
|
|
11
|
+
main: import("@baseplate-dev/sync").GeneratorTask<{
|
|
12
|
+
userSessionServiceImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
13
|
+
userSessionService: {};
|
|
14
|
+
}>>;
|
|
15
|
+
}, {
|
|
16
|
+
typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
|
|
17
|
+
authRolesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
18
|
+
AuthRole: {
|
|
19
|
+
isTypeOnly: true;
|
|
20
|
+
};
|
|
21
|
+
DEFAULT_PUBLIC_ROLES: {};
|
|
22
|
+
DEFAULT_USER_ROLES: {};
|
|
23
|
+
RoleConfig: {
|
|
24
|
+
isTypeOnly: true;
|
|
25
|
+
};
|
|
26
|
+
}>>;
|
|
27
|
+
appModule: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/fastify-generators").AppModuleProvider>;
|
|
28
|
+
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
29
|
+
config: {};
|
|
30
|
+
}>>;
|
|
31
|
+
prismaOutput: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/fastify-generators").PrismaOutputProvider>;
|
|
32
|
+
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
33
|
+
UserSessionPayload: {
|
|
34
|
+
isTypeOnly: true;
|
|
35
|
+
};
|
|
36
|
+
UserSessionService: {
|
|
37
|
+
isTypeOnly: true;
|
|
38
|
+
};
|
|
39
|
+
}>>;
|
|
40
|
+
authContextImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
41
|
+
AuthContext: {
|
|
42
|
+
isTypeOnly: true;
|
|
43
|
+
};
|
|
44
|
+
AuthSessionInfo: {
|
|
45
|
+
isTypeOnly: true;
|
|
46
|
+
};
|
|
47
|
+
AuthUserSessionInfo: {
|
|
48
|
+
isTypeOnly: true;
|
|
49
|
+
};
|
|
50
|
+
createAuthContextFromSessionInfo: {};
|
|
51
|
+
InvalidSessionError: {};
|
|
52
|
+
}>>;
|
|
53
|
+
}, any>;
|
|
54
|
+
nodePackages: import("@baseplate-dev/sync").AnyGeneratorTask;
|
|
55
|
+
fastifyAuth0Plugin: import("@baseplate-dev/sync").GeneratorTask<any, {
|
|
56
|
+
fastifyServerConfig: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
|
|
57
|
+
errorHandlerFunction: import("@baseplate-dev/utils").ScalarContainer<import("@baseplate-dev/core-generators").TsCodeFragment | undefined>;
|
|
58
|
+
initializerFragments: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/core-generators").TsCodeFragment>;
|
|
59
|
+
plugins: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/fastify-generators").FastifyServerPlugin>;
|
|
60
|
+
prePluginFragments: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/core-generators").TsCodeFragment>;
|
|
61
|
+
}>, "getValues">>;
|
|
62
|
+
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
63
|
+
config: {};
|
|
64
|
+
}>>;
|
|
65
|
+
}, any>;
|
|
66
|
+
}>;
|
|
67
|
+
//# sourceMappingURL=auth0-module.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-module.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/fastify/auth0-module/auth0-module.generator.ts"],"names":[],"mappings":"AAoCA,eAAO,MAAM,oBAAoB;;;;;;;iCAPM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yCAZ9C,sBACb;yCAMC,sBACH;4BAGgD,sBAAsB;uCAIhD,sBACd;;;;;;EAgJN,CAAC"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { createNodePackagesTask, extractPackageVersions, projectScope, tsCodeFragment, tsImportBuilder, typescriptFileProvider, } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { appModuleProvider, authContextImportsProvider, authRolesImportsProvider, configServiceImportsProvider, configServiceProvider, fastifyServerConfigProvider, prismaOutputProvider, userSessionServiceImportsProvider, userSessionTypesImportsProvider, } from '@baseplate-dev/fastify-generators';
|
|
3
|
+
import { createGenerator, createGeneratorTask, createProviderTask, } from '@baseplate-dev/sync';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
import { AUTH0_PACKAGES } from '#src/auth0/constants/packages.js';
|
|
6
|
+
import { createAuth0ModuleImports } from './generated/ts-import-maps.js';
|
|
7
|
+
import { AUTH_0_AUTH_0_MODULE_TS_TEMPLATES } from './generated/ts-templates.js';
|
|
8
|
+
const descriptorSchema = z.object({
|
|
9
|
+
userModelName: z.string().min(1),
|
|
10
|
+
includeManagement: z.boolean().optional(),
|
|
11
|
+
});
|
|
12
|
+
export const auth0ModuleGenerator = createGenerator({
|
|
13
|
+
name: 'auth0/auth0-module',
|
|
14
|
+
generatorFileUrl: import.meta.url,
|
|
15
|
+
descriptorSchema,
|
|
16
|
+
buildTasks: ({ includeManagement, userModelName }) => ({
|
|
17
|
+
nodeManagementPackage: includeManagement
|
|
18
|
+
? createNodePackagesTask({
|
|
19
|
+
prod: extractPackageVersions(AUTH0_PACKAGES, ['auth0']),
|
|
20
|
+
})
|
|
21
|
+
: undefined,
|
|
22
|
+
config: createProviderTask(configServiceProvider, (configService) => {
|
|
23
|
+
configService.configFields.set('AUTH0_DOMAIN', {
|
|
24
|
+
validator: tsCodeFragment('z.string().min(1)'),
|
|
25
|
+
comment: 'Auth0 domain (can be custom domain)',
|
|
26
|
+
seedValue: 'subdomain.auth0.com',
|
|
27
|
+
exampleValue: '<AUTH0_DOMAIN>',
|
|
28
|
+
});
|
|
29
|
+
configService.configFields.set('AUTH0_AUDIENCE', {
|
|
30
|
+
validator: tsCodeFragment('z.string().min(1)'),
|
|
31
|
+
comment: 'Auth0 audience',
|
|
32
|
+
seedValue: 'https://api.example.com',
|
|
33
|
+
exampleValue: '<AUTH0_AUDIENCE>',
|
|
34
|
+
});
|
|
35
|
+
if (includeManagement) {
|
|
36
|
+
configService.configFields.set('AUTH0_TENANT_DOMAIN', {
|
|
37
|
+
validator: tsCodeFragment('z.string().min(1)'),
|
|
38
|
+
comment: 'Auth0 tenant domain (ends with auth0.com), e.g. domain.auth0.com',
|
|
39
|
+
seedValue: 'domain.auth0.com',
|
|
40
|
+
exampleValue: '<AUTH0_TENANT_DOMAIN>',
|
|
41
|
+
});
|
|
42
|
+
configService.configFields.set('AUTH0_CLIENT_ID', {
|
|
43
|
+
validator: tsCodeFragment('z.string().min(1)'),
|
|
44
|
+
comment: 'Auth0 management client ID (https://auth0.com/docs/get-started/auth0-overview/create-applications/machine-to-machine-apps)',
|
|
45
|
+
seedValue: 'CLIENT_ID',
|
|
46
|
+
exampleValue: '<AUTH0_CLIENT_ID>',
|
|
47
|
+
});
|
|
48
|
+
configService.configFields.set('AUTH0_CLIENT_SECRET', {
|
|
49
|
+
validator: tsCodeFragment('z.string().min(1)'),
|
|
50
|
+
comment: 'Auth0 management client secret',
|
|
51
|
+
seedValue: 'CLIENT_SECRET',
|
|
52
|
+
exampleValue: '<AUTH0_CLIENT_SECRET>',
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}),
|
|
56
|
+
main: createGeneratorTask({
|
|
57
|
+
dependencies: {
|
|
58
|
+
typescriptFile: typescriptFileProvider,
|
|
59
|
+
authRolesImports: authRolesImportsProvider,
|
|
60
|
+
appModule: appModuleProvider,
|
|
61
|
+
configServiceImports: configServiceImportsProvider,
|
|
62
|
+
prismaOutput: prismaOutputProvider,
|
|
63
|
+
userSessionTypesImports: userSessionTypesImportsProvider,
|
|
64
|
+
authContextImports: authContextImportsProvider,
|
|
65
|
+
},
|
|
66
|
+
exports: {
|
|
67
|
+
userSessionServiceImports: userSessionServiceImportsProvider.export(projectScope),
|
|
68
|
+
},
|
|
69
|
+
run({ typescriptFile, authRolesImports, prismaOutput, configServiceImports, appModule, userSessionTypesImports, authContextImports, }) {
|
|
70
|
+
const userSessionServicePath = `${appModule.getModuleFolder()}/services/user-session.service.ts`;
|
|
71
|
+
const managementPath = `${appModule.getModuleFolder()}/services/management.ts`;
|
|
72
|
+
return {
|
|
73
|
+
providers: {
|
|
74
|
+
auth0Module: {},
|
|
75
|
+
userSessionServiceImports: createAuth0ModuleImports(`${appModule.getModuleFolder()}/services`),
|
|
76
|
+
},
|
|
77
|
+
build: async (builder) => {
|
|
78
|
+
await builder.apply(typescriptFile.renderTemplateFile({
|
|
79
|
+
template: AUTH_0_AUTH_0_MODULE_TS_TEMPLATES.userSessionService,
|
|
80
|
+
destination: userSessionServicePath,
|
|
81
|
+
variables: {
|
|
82
|
+
TPL_USER_MODEL: prismaOutput.getPrismaModelFragment(userModelName),
|
|
83
|
+
},
|
|
84
|
+
importMapProviders: {
|
|
85
|
+
authContextImports,
|
|
86
|
+
authRolesImports,
|
|
87
|
+
userSessionTypesImports,
|
|
88
|
+
},
|
|
89
|
+
}));
|
|
90
|
+
if (includeManagement) {
|
|
91
|
+
await builder.apply(typescriptFile.renderTemplateFile({
|
|
92
|
+
template: AUTH_0_AUTH_0_MODULE_TS_TEMPLATES.management,
|
|
93
|
+
destination: managementPath,
|
|
94
|
+
importMapProviders: {
|
|
95
|
+
configServiceImports,
|
|
96
|
+
},
|
|
97
|
+
}));
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
}),
|
|
103
|
+
nodePackages: createNodePackagesTask({
|
|
104
|
+
prod: extractPackageVersions(AUTH0_PACKAGES, ['fastify-auth0-verify']),
|
|
105
|
+
}),
|
|
106
|
+
fastifyAuth0Plugin: createGeneratorTask({
|
|
107
|
+
dependencies: {
|
|
108
|
+
fastifyServerConfig: fastifyServerConfigProvider,
|
|
109
|
+
configServiceImports: configServiceImportsProvider,
|
|
110
|
+
},
|
|
111
|
+
run({ fastifyServerConfig, configServiceImports }) {
|
|
112
|
+
fastifyServerConfig.plugins.set('fastifyAuth0Verify', {
|
|
113
|
+
plugin: tsCodeFragment('fastifyAuth0Verify', tsImportBuilder()
|
|
114
|
+
.default('fastifyAuth0Verify')
|
|
115
|
+
.from('fastify-auth0-verify')),
|
|
116
|
+
options: tsCodeFragment(`{
|
|
117
|
+
domain: config.AUTH0_DOMAIN,
|
|
118
|
+
audience: config.AUTH0_AUDIENCE,
|
|
119
|
+
}`, configServiceImports.config.declaration()),
|
|
120
|
+
});
|
|
121
|
+
},
|
|
122
|
+
}),
|
|
123
|
+
}),
|
|
124
|
+
});
|
|
125
|
+
//# sourceMappingURL=auth0-module.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-module.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/fastify/auth0-module/auth0-module.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACZ,cAAc,EACd,eAAe,EACf,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,qBAAqB,EACrB,2BAA2B,EAC3B,oBAAoB,EACpB,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,mCAAmC,CAAC;A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B,EAAE,oBAAoB,EAAE;gBAC/C,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE;oBACpD,MAAM,EAAE,cAAc,CACpB,oBAAoB,EACpB,eAAe,EAAE;yBACd,OAAO,CAAC,oBAAoB,CAAC;yBAC7B,IAAI,CAAC,sBAAsB,CAAC,CAChC;oBACD,OAAO,EAAE,cAAc,CACrB;;;IAGR,EACQ,oBAAoB,CAAC,MAAM,CAAC,WAAW,EAAE,CAC1C;iBACF,CAAC,CAAC;YACL,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/fastify/auth0-module/generated/ts-import-maps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iCAAiC,EAAE,MAAM,mCAAmC,CAAC;AAM3F,wBAAgB,wBAAwB,CACtC,UAAU,EAAE,MAAM,GACjB,iCAAiC,CAQnC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { createTsImportMap } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { userSessionServiceImportsSchema } from '@baseplate-dev/fastify-generators';
|
|
3
|
+
import path from 'node:path/posix';
|
|
4
|
+
export function createAuth0ModuleImports(importBase) {
|
|
5
|
+
if (!importBase.startsWith('@/')) {
|
|
6
|
+
throw new Error('importBase must start with @/');
|
|
7
|
+
}
|
|
8
|
+
return createTsImportMap(userSessionServiceImportsSchema, {
|
|
9
|
+
userSessionService: path.join(importBase, 'user-session.service.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/fastify/auth0-module/generated/ts-import-maps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AACpF,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,MAAM,UAAU,wBAAwB,CACtC,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,+BAA+B,EAAE;QACxD,kBAAkB,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,yBAAyB,CAAC;KACrE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export declare const AUTH_0_AUTH_0_MODULE_TS_TEMPLATES: {
|
|
2
|
+
management: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
|
|
3
|
+
configServiceImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
4
|
+
config: {};
|
|
5
|
+
}>>;
|
|
6
|
+
}>;
|
|
7
|
+
userSessionService: import("@baseplate-dev/core-generators").TsTemplateFile<{
|
|
8
|
+
TPL_USER_MODEL: {};
|
|
9
|
+
}, {
|
|
10
|
+
authContextImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
11
|
+
AuthContext: {
|
|
12
|
+
isTypeOnly: true;
|
|
13
|
+
};
|
|
14
|
+
AuthSessionInfo: {
|
|
15
|
+
isTypeOnly: true;
|
|
16
|
+
};
|
|
17
|
+
AuthUserSessionInfo: {
|
|
18
|
+
isTypeOnly: true;
|
|
19
|
+
};
|
|
20
|
+
createAuthContextFromSessionInfo: {};
|
|
21
|
+
InvalidSessionError: {};
|
|
22
|
+
}>>;
|
|
23
|
+
authRolesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
24
|
+
AuthRole: {
|
|
25
|
+
isTypeOnly: true;
|
|
26
|
+
};
|
|
27
|
+
DEFAULT_PUBLIC_ROLES: {};
|
|
28
|
+
DEFAULT_USER_ROLES: {};
|
|
29
|
+
RoleConfig: {
|
|
30
|
+
isTypeOnly: true;
|
|
31
|
+
};
|
|
32
|
+
}>>;
|
|
33
|
+
userSessionTypesImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
|
|
34
|
+
UserSessionPayload: {
|
|
35
|
+
isTypeOnly: true;
|
|
36
|
+
};
|
|
37
|
+
UserSessionService: {
|
|
38
|
+
isTypeOnly: true;
|
|
39
|
+
};
|
|
40
|
+
}>>;
|
|
41
|
+
}>;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=ts-templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/fastify/auth0-module/generated/ts-templates.ts"],"names":[],"mappings":"AA4BA,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAG7C,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createTsTemplateFile } from '@baseplate-dev/core-generators';
|
|
2
|
+
import { authContextImportsProvider, authRolesImportsProvider, configServiceImportsProvider, userSessionTypesImportsProvider, } from '@baseplate-dev/fastify-generators';
|
|
3
|
+
const management = createTsTemplateFile({
|
|
4
|
+
importMapProviders: { configServiceImports: configServiceImportsProvider },
|
|
5
|
+
name: 'management',
|
|
6
|
+
projectExports: {},
|
|
7
|
+
source: { path: 'management.ts' },
|
|
8
|
+
variables: {},
|
|
9
|
+
});
|
|
10
|
+
const userSessionService = createTsTemplateFile({
|
|
11
|
+
importMapProviders: {
|
|
12
|
+
authContextImports: authContextImportsProvider,
|
|
13
|
+
authRolesImports: authRolesImportsProvider,
|
|
14
|
+
userSessionTypesImports: userSessionTypesImportsProvider,
|
|
15
|
+
},
|
|
16
|
+
name: 'user-session-service',
|
|
17
|
+
projectExports: { userSessionService: {} },
|
|
18
|
+
source: { path: 'user-session.service.ts' },
|
|
19
|
+
variables: { TPL_USER_MODEL: {} },
|
|
20
|
+
});
|
|
21
|
+
export const AUTH_0_AUTH_0_MODULE_TS_TEMPLATES = {
|
|
22
|
+
management,
|
|
23
|
+
userSessionService,
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=ts-templates.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ts-templates.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/fastify/auth0-module/generated/ts-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACxB,4BAA4B,EAC5B,+BAA+B,GAChC,MAAM,mCAAmC,CAAC;AAE3C,MAAM,UAAU,GAAG,oBAAoB,CAAC;IACtC,kBAAkB,EAAE,EAAE,oBAAoB,EAAE,4BAA4B,EAAE;IAC1E,IAAI,EAAE,YAAY;IAClB,cAAc,EAAE,EAAE;IAClB,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;IACjC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,oBAAoB,CAAC;IAC9C,kBAAkB,EAAE;QAClB,kBAAkB,EAAE,0BAA0B;QAC9C,gBAAgB,EAAE,wBAAwB;QAC1C,uBAAuB,EAAE,+BAA+B;KACzD;IACD,IAAI,EAAE,sBAAsB;IAC5B,cAAc,EAAE,EAAE,kBAAkB,EAAE,EAAE,EAAE;IAC1C,MAAM,EAAE,EAAE,IAAI,EAAE,yBAAyB,EAAE;IAC3C,SAAS,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE;CAClC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,iCAAiC,GAAG;IAC/C,UAAU;IACV,kBAAkB;CACnB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import { config } from '%configServiceImports';
|
|
4
|
+
import { ManagementClient } from 'auth0';
|
|
5
|
+
|
|
6
|
+
let cachedClient: ManagementClient | null = null;
|
|
7
|
+
|
|
8
|
+
export function getAuth0ManagementClient(): ManagementClient {
|
|
9
|
+
if (cachedClient) {
|
|
10
|
+
return cachedClient;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const client = new ManagementClient({
|
|
14
|
+
domain: config.AUTH0_TENANT_DOMAIN,
|
|
15
|
+
clientId: config.AUTH0_CLIENT_ID,
|
|
16
|
+
clientSecret: config.AUTH0_CLIENT_SECRET,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
cachedClient = client;
|
|
20
|
+
|
|
21
|
+
return client;
|
|
22
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
|
|
3
|
+
import type { AuthUserSessionInfo } from '%authContextImports';
|
|
4
|
+
import type { AuthRole } from '%authRolesImports';
|
|
5
|
+
import type { UserSessionService } from '%userSessionTypesImports';
|
|
6
|
+
import type { FastifyRequest } from 'fastify';
|
|
7
|
+
|
|
8
|
+
import { DEFAULT_USER_ROLES } from '%authRolesImports';
|
|
9
|
+
|
|
10
|
+
const USER_ID_CLAIM = 'https://app.com/user_id';
|
|
11
|
+
const EMAIL_CLAIM = 'https://app.com/email';
|
|
12
|
+
const EMAIL_VERIFIED_CLAIM = 'https://app.com/email_verified';
|
|
13
|
+
const ROLES_CLAIM = 'https://app.com/roles';
|
|
14
|
+
|
|
15
|
+
interface Auth0Jwt {
|
|
16
|
+
[USER_ID_CLAIM]?: string;
|
|
17
|
+
[EMAIL_CLAIM]?: string;
|
|
18
|
+
[EMAIL_VERIFIED_CLAIM]?: boolean;
|
|
19
|
+
[ROLES_CLAIM]?: string[];
|
|
20
|
+
sub: string;
|
|
21
|
+
email: string;
|
|
22
|
+
exp: number;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export class Auth0UserSessionService implements UserSessionService {
|
|
26
|
+
/**
|
|
27
|
+
* Retrieves the user session information from the request.
|
|
28
|
+
*
|
|
29
|
+
* @param req - The Fastify request object containing the cookies.
|
|
30
|
+
* @param reply - The Fastify reply object used to set or clear cookies.
|
|
31
|
+
* @param currentDate - The current date used for session validation. Defaults to the current date and time.
|
|
32
|
+
* @returns A promise that resolves to the authenticated user session information or null if the session is invalid.
|
|
33
|
+
* @throws {InvalidSessionError} If the session is invalid or expired.
|
|
34
|
+
*/
|
|
35
|
+
async getSessionInfoFromRequest(
|
|
36
|
+
req: FastifyRequest,
|
|
37
|
+
): Promise<AuthUserSessionInfo | undefined> {
|
|
38
|
+
if (!req.headers.authorization) {
|
|
39
|
+
return undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const verifiedJwt = await req.jwtVerify<Auth0Jwt>();
|
|
43
|
+
const userId = verifiedJwt[USER_ID_CLAIM];
|
|
44
|
+
const roles = verifiedJwt[ROLES_CLAIM] ?? [];
|
|
45
|
+
const email = verifiedJwt[EMAIL_CLAIM];
|
|
46
|
+
|
|
47
|
+
if (!userId) {
|
|
48
|
+
throw new Error(`Missing user id in JWT`);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const user = await TPL_USER_MODEL.findUnique({ where: { id: userId } });
|
|
52
|
+
|
|
53
|
+
// create user if one does not exist already
|
|
54
|
+
if (!user) {
|
|
55
|
+
if (!email) {
|
|
56
|
+
throw new Error(`Missing email claim in JWT`);
|
|
57
|
+
}
|
|
58
|
+
// Use createMany to avoid race-conditions with creating the user
|
|
59
|
+
await TPL_USER_MODEL.createMany({
|
|
60
|
+
data: [
|
|
61
|
+
{
|
|
62
|
+
id: userId,
|
|
63
|
+
auth0Id: verifiedJwt.sub,
|
|
64
|
+
email,
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
skipDuplicates: true,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
id: verifiedJwt.sub,
|
|
73
|
+
type: 'user',
|
|
74
|
+
userId,
|
|
75
|
+
roles: [...DEFAULT_USER_ROLES, ...roles] as AuthRole[],
|
|
76
|
+
expiresAt:
|
|
77
|
+
typeof verifiedJwt.exp === 'number'
|
|
78
|
+
? new Date(verifiedJwt.exp * 1000)
|
|
79
|
+
: undefined,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Retrieves the user session information from the authentication token
|
|
85
|
+
*
|
|
86
|
+
* @param req The request object
|
|
87
|
+
* @returns The session info or undefined if no session is found
|
|
88
|
+
*/
|
|
89
|
+
async getSessionInfoFromToken(
|
|
90
|
+
req: FastifyRequest,
|
|
91
|
+
token?: string | null,
|
|
92
|
+
): Promise<AuthUserSessionInfo | undefined> {
|
|
93
|
+
// We have to manually add the header to the request since we can't
|
|
94
|
+
// use server.jwt.verify due to an error
|
|
95
|
+
req.headers.authorization = token ?? undefined;
|
|
96
|
+
|
|
97
|
+
return this.getSessionInfoFromRequest(req);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export const userSessionService = new Auth0UserSessionService();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth0/generators/fastify/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/auth0/generators/fastify/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth0/generators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/auth0/generators/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const auth0ApolloGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{}, {
|
|
2
|
+
main: import("@baseplate-dev/sync").GeneratorTask<any, {
|
|
3
|
+
reactApolloConfig: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
|
|
4
|
+
createApolloClientArguments: import("@baseplate-dev/utils").NamedArrayFieldContainer<import("@baseplate-dev/react-generators").ApolloCreateArgument>;
|
|
5
|
+
apolloLinks: import("@baseplate-dev/utils").NamedArrayFieldContainer<import("@baseplate-dev/react-generators").ApolloLink>;
|
|
6
|
+
websocketOptions: import("@baseplate-dev/utils").MapContainer<string, string | import("@baseplate-dev/core-generators").TsCodeFragment>;
|
|
7
|
+
}>, "getValues">>;
|
|
8
|
+
}, any>;
|
|
9
|
+
}>;
|
|
10
|
+
//# sourceMappingURL=auth0-apollo.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth0-apollo.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-apollo/auth0-apollo.generator.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,oBAAoB;;;gDA6CsT,sBAAsB;gCAA0E,sBAAsB;qCAAqE,sBAAsB;;;EADtiB,CAAC"}
|