@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.
Files changed (241) hide show
  1. package/LICENSE +390 -0
  2. package/dist/auth/core/common.d.ts +7 -0
  3. package/dist/auth/core/common.d.ts.map +1 -0
  4. package/dist/auth/core/common.js +26 -0
  5. package/dist/auth/core/common.js.map +1 -0
  6. package/dist/auth/core/components/auth-definition-editor.d.ts +5 -0
  7. package/dist/auth/core/components/auth-definition-editor.d.ts.map +1 -0
  8. package/dist/auth/core/components/auth-definition-editor.js +57 -0
  9. package/dist/auth/core/components/auth-definition-editor.js.map +1 -0
  10. package/dist/auth/core/components/role-editor-form.d.ts +10 -0
  11. package/dist/auth/core/components/role-editor-form.d.ts.map +1 -0
  12. package/dist/auth/core/components/role-editor-form.js +27 -0
  13. package/dist/auth/core/components/role-editor-form.js.map +1 -0
  14. package/dist/auth/core/node.d.ts +5 -0
  15. package/dist/auth/core/node.d.ts.map +1 -0
  16. package/dist/auth/core/node.js +58 -0
  17. package/dist/auth/core/node.js.map +1 -0
  18. package/dist/auth/core/schema/models.d.ts +9 -0
  19. package/dist/auth/core/schema/models.d.ts.map +1 -0
  20. package/dist/auth/core/schema/models.js +187 -0
  21. package/dist/auth/core/schema/models.js.map +1 -0
  22. package/dist/auth/core/schema/plugin-definition.d.ts +88 -0
  23. package/dist/auth/core/schema/plugin-definition.d.ts.map +1 -0
  24. package/dist/auth/core/schema/plugin-definition.js +29 -0
  25. package/dist/auth/core/schema/plugin-definition.js.map +1 -0
  26. package/dist/auth/core/web.d.ts +6 -0
  27. package/dist/auth/core/web.d.ts.map +1 -0
  28. package/dist/auth/core/web.js +14 -0
  29. package/dist/auth/core/web.js.map +1 -0
  30. package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts +65 -0
  31. package/dist/auth/generators/fastify/auth-module/auth-module.generator.d.ts.map +1 -0
  32. package/dist/auth/generators/fastify/auth-module/auth-module.generator.js +62 -0
  33. package/dist/auth/generators/fastify/auth-module/auth-module.generator.js.map +1 -0
  34. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.d.ts +96 -0
  35. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.d.ts.map +1 -0
  36. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js +94 -0
  37. package/dist/auth/generators/fastify/auth-module/generated/ts-templates.js.map +1 -0
  38. package/dist/auth/generators/fastify/auth-module/templates/management.ts +22 -0
  39. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session-payload.object-type.ts +23 -0
  40. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.mutations.ts +22 -0
  41. package/dist/auth/generators/fastify/auth-module/templates/schema/user-session.queries.ts +20 -0
  42. package/dist/auth/generators/fastify/auth-module/templates/services/user-session.service.ts +251 -0
  43. package/dist/auth/generators/fastify/auth-module/templates/user-session.constants.ts +19 -0
  44. package/dist/auth/generators/fastify/auth-module/templates/user-session.service.ts +101 -0
  45. package/dist/auth/generators/fastify/auth-module/templates/utils/cookie-signer.ts +71 -0
  46. package/dist/auth/generators/fastify/auth-module/templates/utils/session-cookie.ts +42 -0
  47. package/dist/auth/generators/fastify/auth-module/templates/utils/verify-request-origin.ts +45 -0
  48. package/dist/auth/generators/fastify/index.d.ts +2 -0
  49. package/dist/auth/generators/fastify/index.d.ts.map +1 -0
  50. package/dist/auth/generators/fastify/index.js +2 -0
  51. package/dist/auth/generators/fastify/index.js.map +1 -0
  52. package/dist/auth/generators/index.d.ts +2 -0
  53. package/dist/auth/generators/index.d.ts.map +1 -0
  54. package/dist/auth/generators/index.js +2 -0
  55. package/dist/auth/generators/index.js.map +1 -0
  56. package/dist/auth/index.d.ts +2 -0
  57. package/dist/auth/index.d.ts.map +1 -0
  58. package/dist/auth/index.js +2 -0
  59. package/dist/auth/index.js.map +1 -0
  60. package/dist/auth/metadata.json +8 -0
  61. package/dist/auth/static/icon.svg +1 -0
  62. package/dist/auth0/constants/packages.d.ts +6 -0
  63. package/dist/auth0/constants/packages.d.ts.map +1 -0
  64. package/dist/auth0/constants/packages.js +6 -0
  65. package/dist/auth0/constants/packages.js.map +1 -0
  66. package/dist/auth0/core/common.d.ts +7 -0
  67. package/dist/auth0/core/common.d.ts.map +1 -0
  68. package/dist/auth0/core/common.js +28 -0
  69. package/dist/auth0/core/common.js.map +1 -0
  70. package/dist/auth0/core/components/auth-definition-editor.d.ts +5 -0
  71. package/dist/auth0/core/components/auth-definition-editor.d.ts.map +1 -0
  72. package/dist/auth0/core/components/auth-definition-editor.js +57 -0
  73. package/dist/auth0/core/components/auth-definition-editor.js.map +1 -0
  74. package/dist/auth0/core/components/role-dialog.d.ts +14 -0
  75. package/dist/auth0/core/components/role-dialog.d.ts.map +1 -0
  76. package/dist/auth0/core/components/role-dialog.js +27 -0
  77. package/dist/auth0/core/components/role-dialog.js.map +1 -0
  78. package/dist/auth0/core/components/role-editor-form.d.ts +10 -0
  79. package/dist/auth0/core/components/role-editor-form.d.ts.map +1 -0
  80. package/dist/auth0/core/components/role-editor-form.js +52 -0
  81. package/dist/auth0/core/components/role-editor-form.js.map +1 -0
  82. package/dist/auth0/core/node.d.ts +5 -0
  83. package/dist/auth0/core/node.d.ts.map +1 -0
  84. package/dist/auth0/core/node.js +86 -0
  85. package/dist/auth0/core/node.js.map +1 -0
  86. package/dist/auth0/core/schema/migrations.d.ts +3 -0
  87. package/dist/auth0/core/schema/migrations.d.ts.map +1 -0
  88. package/dist/auth0/core/schema/migrations.js +17 -0
  89. package/dist/auth0/core/schema/migrations.js.map +1 -0
  90. package/dist/auth0/core/schema/models.d.ts +6 -0
  91. package/dist/auth0/core/schema/models.d.ts.map +1 -0
  92. package/dist/auth0/core/schema/models.js +33 -0
  93. package/dist/auth0/core/schema/models.js.map +1 -0
  94. package/dist/auth0/core/schema/plugin-definition.d.ts +73 -0
  95. package/dist/auth0/core/schema/plugin-definition.d.ts.map +1 -0
  96. package/dist/auth0/core/schema/plugin-definition.js +17 -0
  97. package/dist/auth0/core/schema/plugin-definition.js.map +1 -0
  98. package/dist/auth0/core/web.d.ts +6 -0
  99. package/dist/auth0/core/web.d.ts.map +1 -0
  100. package/dist/auth0/core/web.js +14 -0
  101. package/dist/auth0/core/web.js.map +1 -0
  102. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts +67 -0
  103. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.d.ts.map +1 -0
  104. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js +125 -0
  105. package/dist/auth0/generators/fastify/auth0-module/auth0-module.generator.js.map +1 -0
  106. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts +3 -0
  107. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.d.ts.map +1 -0
  108. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js +12 -0
  109. package/dist/auth0/generators/fastify/auth0-module/generated/ts-import-maps.js.map +1 -0
  110. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.d.ts +43 -0
  111. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.d.ts.map +1 -0
  112. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.js +25 -0
  113. package/dist/auth0/generators/fastify/auth0-module/generated/ts-templates.js.map +1 -0
  114. package/dist/auth0/generators/fastify/auth0-module/templates/management.ts +22 -0
  115. package/dist/auth0/generators/fastify/auth0-module/templates/user-session.service.ts +101 -0
  116. package/dist/auth0/generators/fastify/index.d.ts +2 -0
  117. package/dist/auth0/generators/fastify/index.d.ts.map +1 -0
  118. package/dist/auth0/generators/fastify/index.js +2 -0
  119. package/dist/auth0/generators/fastify/index.js.map +1 -0
  120. package/dist/auth0/generators/index.d.ts +3 -0
  121. package/dist/auth0/generators/index.d.ts.map +1 -0
  122. package/dist/auth0/generators/index.js +3 -0
  123. package/dist/auth0/generators/index.js.map +1 -0
  124. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts +10 -0
  125. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.d.ts.map +1 -0
  126. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js +41 -0
  127. package/dist/auth0/generators/react/auth0-apollo/auth0-apollo.generator.js.map +1 -0
  128. package/dist/auth0/generators/react/auth0-apollo/templates/auth-link.ts +11 -0
  129. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts +61 -0
  130. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.d.ts.map +1 -0
  131. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js +59 -0
  132. package/dist/auth0/generators/react/auth0-callback/auth0-callback.generator.js.map +1 -0
  133. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts +106 -0
  134. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.d.ts.map +1 -0
  135. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.js +28 -0
  136. package/dist/auth0/generators/react/auth0-callback/generated/ts-templates.js.map +1 -0
  137. package/dist/auth0/generators/react/auth0-callback/templates/auth0-callback.page.tsx +61 -0
  138. package/dist/auth0/generators/react/auth0-callback/templates/signup.page.tsx +48 -0
  139. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts +53 -0
  140. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.d.ts.map +1 -0
  141. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js +44 -0
  142. package/dist/auth0/generators/react/auth0-components/auth0-components.generator.js.map +1 -0
  143. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts +3 -0
  144. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.d.ts.map +1 -0
  145. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js +12 -0
  146. package/dist/auth0/generators/react/auth0-components/generated/ts-import-maps.js.map +1 -0
  147. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts +45 -0
  148. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.d.ts.map +1 -0
  149. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js +13 -0
  150. package/dist/auth0/generators/react/auth0-components/generated/ts-templates.js.map +1 -0
  151. package/dist/auth0/generators/react/auth0-components/templates/RequireAuth.tsx +22 -0
  152. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts +28 -0
  153. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.d.ts.map +1 -0
  154. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js +65 -0
  155. package/dist/auth0/generators/react/auth0-hooks/auth0-hooks.generator.js.map +1 -0
  156. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts +8 -0
  157. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.d.ts.map +1 -0
  158. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js +12 -0
  159. package/dist/auth0/generators/react/auth0-hooks/generated/text-templates.js.map +1 -0
  160. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts +3 -0
  161. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.d.ts.map +1 -0
  162. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js +16 -0
  163. package/dist/auth0/generators/react/auth0-hooks/generated/ts-import-maps.js.map +1 -0
  164. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts +33 -0
  165. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.d.ts.map +1 -0
  166. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js +50 -0
  167. package/dist/auth0/generators/react/auth0-hooks/generated/ts-templates.js.map +1 -0
  168. package/dist/auth0/generators/react/auth0-hooks/templates/useCurrentUser.gql +10 -0
  169. package/dist/auth0/generators/react/auth0-hooks/templates/useCurrentUser.ts +29 -0
  170. package/dist/auth0/generators/react/auth0-hooks/templates/useLogOut.ts +14 -0
  171. package/dist/auth0/generators/react/auth0-hooks/templates/useRequiredUserId.ts +11 -0
  172. package/dist/auth0/generators/react/auth0-hooks/templates/useSession.ts +23 -0
  173. package/dist/auth0/generators/react/index.d.ts +6 -0
  174. package/dist/auth0/generators/react/index.d.ts.map +1 -0
  175. package/dist/auth0/generators/react/index.js +6 -0
  176. package/dist/auth0/generators/react/index.js.map +1 -0
  177. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts +23 -0
  178. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.d.ts.map +1 -0
  179. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js +64 -0
  180. package/dist/auth0/generators/react/react-auth0/react-auth0.generator.js.map +1 -0
  181. package/dist/auth0/metadata.json +8 -0
  182. package/dist/auth0/static/icon.svg +7 -0
  183. package/dist/index.d.ts +2 -0
  184. package/dist/index.js +2 -0
  185. package/dist/index.js.map +1 -0
  186. package/dist/roles/constants.d.ts +4 -0
  187. package/dist/roles/constants.d.ts.map +1 -0
  188. package/dist/roles/constants.js +25 -0
  189. package/dist/roles/constants.js.map +1 -0
  190. package/dist/roles/index.d.ts +3 -0
  191. package/dist/roles/index.d.ts.map +1 -0
  192. package/dist/roles/index.js +3 -0
  193. package/dist/roles/index.js.map +1 -0
  194. package/dist/roles/schema.d.ts +65 -0
  195. package/dist/roles/schema.d.ts.map +1 -0
  196. package/dist/roles/schema.js +43 -0
  197. package/dist/roles/schema.js.map +1 -0
  198. package/dist/utils/cn.d.ts +2 -0
  199. package/dist/utils/cn.d.ts.map +1 -0
  200. package/dist/utils/cn.js +2 -0
  201. package/dist/utils/cn.js.map +1 -0
  202. package/dist/web/assets/__federation_expose_auth0CoreCommon--n6esVYP.js +54 -0
  203. package/dist/web/assets/__federation_expose_auth0CoreCommon--n6esVYP.js.map +1 -0
  204. package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js +377 -0
  205. package/dist/web/assets/__federation_expose_auth0CoreWeb-Ql6gpX5q.js.map +1 -0
  206. package/dist/web/assets/__federation_fn_import-BiwmVFwy.js +421 -0
  207. package/dist/web/assets/__federation_fn_import-BiwmVFwy.js.map +1 -0
  208. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js +330 -0
  209. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib/web-CY8oz43s.js.map +1 -0
  210. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js +10559 -0
  211. package/dist/web/assets/__federation_shared_@baseplate-dev/project-builder-lib-B62IPizQ.js.map +1 -0
  212. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js +12718 -0
  213. package/dist/web/assets/__federation_shared_@baseplate-dev/ui-components-BU2QTWNs.js.map +1 -0
  214. package/dist/web/assets/__federation_shared_react-dom-Bwq4pLax.js +250 -0
  215. package/dist/web/assets/__federation_shared_react-dom-Bwq4pLax.js.map +1 -0
  216. package/dist/web/assets/__federation_shared_react-uocnGSER.js +7 -0
  217. package/dist/web/assets/__federation_shared_react-uocnGSER.js.map +1 -0
  218. package/dist/web/assets/__federation_shared_zod-BK7IELHt.js +4380 -0
  219. package/dist/web/assets/__federation_shared_zod-BK7IELHt.js.map +1 -0
  220. package/dist/web/assets/index-B1hOKVPw.js +574 -0
  221. package/dist/web/assets/index-B1hOKVPw.js.map +1 -0
  222. package/dist/web/assets/index-CgJx-krK.js +95 -0
  223. package/dist/web/assets/index-CgJx-krK.js.map +1 -0
  224. package/dist/web/assets/index-l0sNRNKZ.js.map +1 -0
  225. package/dist/web/assets/index.esm-BcxPd7Ha.js +2584 -0
  226. package/dist/web/assets/index.esm-BcxPd7Ha.js.map +1 -0
  227. package/dist/web/assets/model-utils-CbQJy1wE.js +1263 -0
  228. package/dist/web/assets/model-utils-CbQJy1wE.js.map +1 -0
  229. package/dist/web/assets/plugin-definition-BQRupXoQ.js +78 -0
  230. package/dist/web/assets/plugin-definition-BQRupXoQ.js.map +1 -0
  231. package/dist/web/assets/react-2jQE8aG0.js +47 -0
  232. package/dist/web/assets/react-2jQE8aG0.js.map +1 -0
  233. package/dist/web/assets/remoteEntry.js +54 -0
  234. package/dist/web/assets/remoteEntry.js.map +1 -0
  235. package/dist/web/assets/style-BdgwWjAf.css +95 -0
  236. package/dist/web/index.html +24 -0
  237. package/dist/web-export.d.ts +2 -0
  238. package/dist/web-export.js +2 -0
  239. package/dist/web-export.js.map +1 -0
  240. package/manifest.json +4 -0
  241. package/package.json +80 -0
@@ -0,0 +1,22 @@
1
+ // @ts-nocheck
2
+
3
+ import type { ReactElement } from 'react';
4
+
5
+ import { Spinner } from '%reactComponentsImports';
6
+ import { withAuthenticationRequired } from '@auth0/auth0-react';
7
+
8
+ interface Props {
9
+ children: ReactElement;
10
+ }
11
+
12
+ function RequireAuth({ children }: Props): ReactElement {
13
+ return children;
14
+ }
15
+
16
+ export default withAuthenticationRequired(RequireAuth, {
17
+ onRedirecting: () => (
18
+ <div className="flex h-full items-center justify-center">
19
+ <Spinner size="large" />
20
+ </div>
21
+ ),
22
+ });
@@ -0,0 +1,28 @@
1
+ export declare const auth0HooksGenerator: import("@baseplate-dev/sync").GeneratorBundleCreator<{
2
+ userQueryName?: string | undefined;
3
+ }, {
4
+ authHooksImports: import("@baseplate-dev/sync").GeneratorTask<{
5
+ authHooksImports: import("@baseplate-dev/sync").ProviderExport<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
6
+ SessionData: {
7
+ isTypeOnly: true;
8
+ };
9
+ useCurrentUser: {};
10
+ useLogOut: {};
11
+ useRequiredUserId: {};
12
+ useSession: {};
13
+ }>>;
14
+ }, any, any>;
15
+ main: import("@baseplate-dev/sync").GeneratorTask<any, {
16
+ typescriptFile: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").TypescriptFileProvider>;
17
+ reactApollo: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/react-generators").ReactApolloProvider>;
18
+ reactErrorImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
19
+ formatError: {};
20
+ logAndFormatError: {};
21
+ logError: {};
22
+ }>>;
23
+ generatedGraphqlImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
24
+ '*': {};
25
+ }>>;
26
+ }, any>;
27
+ }>;
28
+ //# sourceMappingURL=auth0-hooks.generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth0-hooks.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-hooks/auth0-hooks.generator.ts"],"names":[],"mappings":"AAyBA,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;EAgE9B,CAAC"}
@@ -0,0 +1,65 @@
1
+ import { projectScope, typescriptFileProvider, } from '@baseplate-dev/core-generators';
2
+ import { authHooksImportsProvider, generatedGraphqlImportsProvider, reactApolloProvider, reactErrorImportsProvider, } from '@baseplate-dev/react-generators';
3
+ import { createGenerator, createGeneratorTask, renderTextTemplateFileAction, } from '@baseplate-dev/sync';
4
+ import { z } from 'zod';
5
+ import { AUTH_0_AUTH_0_HOOKS_TEXT_TEMPLATES } from './generated/text-templates.js';
6
+ import { createAuth0HooksImports } from './generated/ts-import-maps.js';
7
+ import { AUTH_0_AUTH_0_HOOKS_TS_TEMPLATES } from './generated/ts-templates.js';
8
+ const descriptorSchema = z.object({
9
+ userQueryName: z.string().default('user'),
10
+ });
11
+ export const auth0HooksGenerator = createGenerator({
12
+ name: 'auth0/auth0-hooks',
13
+ generatorFileUrl: import.meta.url,
14
+ descriptorSchema,
15
+ buildTasks: ({ userQueryName }) => ({
16
+ authHooksImports: createGeneratorTask({
17
+ exports: {
18
+ authHooksImports: authHooksImportsProvider.export(projectScope),
19
+ },
20
+ run() {
21
+ return {
22
+ providers: {
23
+ authHooksImports: createAuth0HooksImports('@/src/hooks'),
24
+ },
25
+ };
26
+ },
27
+ }),
28
+ main: createGeneratorTask({
29
+ dependencies: {
30
+ typescriptFile: typescriptFileProvider,
31
+ reactApollo: reactApolloProvider,
32
+ reactErrorImports: reactErrorImportsProvider,
33
+ generatedGraphqlImports: generatedGraphqlImportsProvider,
34
+ },
35
+ run({ typescriptFile, reactErrorImports, generatedGraphqlImports, reactApollo, }) {
36
+ return {
37
+ build: async (builder) => {
38
+ await builder.apply(typescriptFile.renderTemplateGroup({
39
+ group: AUTH_0_AUTH_0_HOOKS_TS_TEMPLATES.hooksGroup,
40
+ baseDirectory: '@/src/hooks',
41
+ variables: {
42
+ useCurrentUser: {
43
+ TPL_USER: userQueryName,
44
+ },
45
+ },
46
+ importMapProviders: {
47
+ generatedGraphqlImports,
48
+ reactErrorImports,
49
+ },
50
+ }));
51
+ await builder.apply(renderTextTemplateFileAction({
52
+ template: AUTH_0_AUTH_0_HOOKS_TEXT_TEMPLATES.useCurrentUserGql,
53
+ destination: '@/src/hooks/useCurrentUser.gql',
54
+ variables: {
55
+ TPL_USER_QUERY_NAME: userQueryName,
56
+ },
57
+ }));
58
+ reactApollo.registerGqlFile(`@/src/hooks/useCurrentUser.gql`);
59
+ },
60
+ };
61
+ },
62
+ }),
63
+ }),
64
+ });
65
+ //# sourceMappingURL=auth0-hooks.generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth0-hooks.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/auth0-hooks/auth0-hooks.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,sBAAsB,GACvB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,wBAAwB,EACxB,+BAA+B,EAC/B,mBAAmB,EACnB,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,4BAA4B,GAC7B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,kCAAkC,EAAE,MAAM,+BAA+B,CAAC;AACnF,OAAO,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AACxE,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA6B,CAAC;AAE/E,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;IACjD,IAAI,EAAE,mBAAmB;IACzB,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACjC,gBAAgB;IAChB,UAAU,EAAE,CAAC,EAAE,aAAa,EAAE,EAAE,EAAE,CAAC,CAAC;QAClC,gBAAgB,EAAE,mBAAmB,CAAC;YACpC,OAAO,EAAE;gBACP,gBAAgB,EAAE,wBAAwB,CAAC,MAAM,CAAC,YAAY,CAAC;aAChE;YACD,GAAG;gBACD,OAAO;oBACL,SAAS,EAAE;wBACT,gBAAgB,EAAE,uBAAuB,CAAC,aAAa,CAAC;qBACzD;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;QACF,IAAI,EAAE,mBAAmB,CAAC;YACxB,YAAY,EAAE;gBACZ,cAAc,EAAE,sBAAsB;gBACtC,WAAW,EAAE,mBAAmB;gBAChC,iBAAiB,EAAE,yBAAyB;gBAC5C,uBAAuB,EAAE,+BAA+B;aACzD;YACD,GAAG,CAAC,EACF,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,WAAW,GACZ;gBACC,OAAO;oBACL,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE;wBACvB,MAAM,OAAO,CAAC,KAAK,CACjB,cAAc,CAAC,mBAAmB,CAAC;4BACjC,KAAK,EAAE,gCAAgC,CAAC,UAAU;4BAClD,aAAa,EAAE,aAAa;4BAC5B,SAAS,EAAE;gCACT,cAAc,EAAE;oCACd,QAAQ,EAAE,aAAa;iCACxB;6BACF;4BACD,kBAAkB,EAAE;gCAClB,uBAAuB;gCACvB,iBAAiB;6BAClB;yBACF,CAAC,CACH,CAAC;wBAEF,MAAM,OAAO,CAAC,KAAK,CACjB,4BAA4B,CAAC;4BAC3B,QAAQ,EAAE,kCAAkC,CAAC,iBAAiB;4BAC9D,WAAW,EAAE,gCAAgC;4BAC7C,SAAS,EAAE;gCACT,mBAAmB,EAAE,aAAa;6BACnC;yBACF,CAAC,CACH,CAAC;wBAEF,WAAW,CAAC,eAAe,CAAC,gCAAgC,CAAC,CAAC;oBAChE,CAAC;iBACF,CAAC;YACJ,CAAC;SACF,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ export declare const AUTH_0_AUTH_0_HOOKS_TEXT_TEMPLATES: {
2
+ useCurrentUserGql: import("@baseplate-dev/sync").TextTemplateFile<{
3
+ TPL_USER_QUERY_NAME: {
4
+ description: string;
5
+ };
6
+ }>;
7
+ };
8
+ //# sourceMappingURL=text-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-templates.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/text-templates.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,kCAAkC;;;;;;CAE9C,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { createTextTemplateFile } from '@baseplate-dev/sync';
2
+ const useCurrentUserGql = createTextTemplateFile({
3
+ name: 'use-current-user-gql',
4
+ source: { path: 'useCurrentUser.gql' },
5
+ variables: {
6
+ TPL_USER_QUERY_NAME: { description: 'The name of the user query' },
7
+ },
8
+ });
9
+ export const AUTH_0_AUTH_0_HOOKS_TEXT_TEMPLATES = {
10
+ useCurrentUserGql,
11
+ };
12
+ //# sourceMappingURL=text-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"text-templates.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/text-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;IAC/C,IAAI,EAAE,sBAAsB;IAC5B,MAAM,EAAE,EAAE,IAAI,EAAE,oBAAoB,EAAE;IACtC,SAAS,EAAE;QACT,mBAAmB,EAAE,EAAE,WAAW,EAAE,4BAA4B,EAAE;KACnE;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,kCAAkC,GAAG;IAChD,iBAAiB;CAClB,CAAC"}
@@ -0,0 +1,3 @@
1
+ import type { AuthHooksImportsProvider } from '@baseplate-dev/react-generators';
2
+ export declare function createAuth0HooksImports(importBase: string): AuthHooksImportsProvider;
3
+ //# sourceMappingURL=ts-import-maps.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-import-maps.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/ts-import-maps.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAMhF,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,MAAM,GACjB,wBAAwB,CAY1B"}
@@ -0,0 +1,16 @@
1
+ import { createTsImportMap } from '@baseplate-dev/core-generators';
2
+ import { authHooksImportsSchema } from '@baseplate-dev/react-generators';
3
+ import path from 'node:path/posix';
4
+ export function createAuth0HooksImports(importBase) {
5
+ if (!importBase.startsWith('@/')) {
6
+ throw new Error('importBase must start with @/');
7
+ }
8
+ return createTsImportMap(authHooksImportsSchema, {
9
+ SessionData: path.join(importBase, 'useSession.js'),
10
+ useCurrentUser: path.join(importBase, 'useCurrentUser.js'),
11
+ useLogOut: path.join(importBase, 'useLogOut.js'),
12
+ useRequiredUserId: path.join(importBase, 'useRequiredUserId.js'),
13
+ useSession: path.join(importBase, 'useSession.js'),
14
+ });
15
+ }
16
+ //# sourceMappingURL=ts-import-maps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-import-maps.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/ts-import-maps.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,gCAAgC,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAEnC,MAAM,UAAU,uBAAuB,CACrC,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,sBAAsB,EAAE;QAC/C,WAAW,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC;QACnD,cAAc,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,mBAAmB,CAAC;QAC1D,SAAS,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,cAAc,CAAC;QAChD,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,sBAAsB,CAAC;QAChE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC;KACnD,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,33 @@
1
+ export declare const AUTH_0_AUTH_0_HOOKS_TS_TEMPLATES: {
2
+ hooksGroup: import("@baseplate-dev/core-generators").TsTemplateGroup<{
3
+ useCurrentUser: {
4
+ destination: string;
5
+ template: import("@baseplate-dev/core-generators").TsTemplateFile<{
6
+ TPL_USER: {};
7
+ }, {
8
+ generatedGraphqlImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
9
+ '*': {};
10
+ }>>;
11
+ }>;
12
+ };
13
+ useLogOut: {
14
+ destination: string;
15
+ template: import("@baseplate-dev/core-generators").TsTemplateFile<{}, {
16
+ reactErrorImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
17
+ formatError: {};
18
+ logAndFormatError: {};
19
+ logError: {};
20
+ }>>;
21
+ }>;
22
+ };
23
+ useRequiredUserId: {
24
+ destination: string;
25
+ template: import("@baseplate-dev/core-generators").TsTemplateFile<{}, Record<never, import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/sync").Provider>>>;
26
+ };
27
+ useSession: {
28
+ destination: string;
29
+ template: import("@baseplate-dev/core-generators").TsTemplateFile<{}, Record<never, import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/sync").Provider>>>;
30
+ };
31
+ }>;
32
+ };
33
+ //# sourceMappingURL=ts-templates.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-templates.d.ts","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/ts-templates.ts"],"names":[],"mappings":"AA4DA,eAAO,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAAiB,CAAC"}
@@ -0,0 +1,50 @@
1
+ import { createTsTemplateFile, createTsTemplateGroup, } from '@baseplate-dev/core-generators';
2
+ import { generatedGraphqlImportsProvider, reactErrorImportsProvider, } from '@baseplate-dev/react-generators';
3
+ const useCurrentUser = createTsTemplateFile({
4
+ group: 'hooks',
5
+ importMapProviders: {
6
+ generatedGraphqlImports: generatedGraphqlImportsProvider,
7
+ },
8
+ name: 'use-current-user',
9
+ projectExports: { useCurrentUser: {} },
10
+ source: { path: 'useCurrentUser.ts' },
11
+ variables: { TPL_USER: {} },
12
+ });
13
+ const useLogOut = createTsTemplateFile({
14
+ group: 'hooks',
15
+ importMapProviders: { reactErrorImports: reactErrorImportsProvider },
16
+ name: 'use-log-out',
17
+ projectExports: { useLogOut: {} },
18
+ source: { path: 'useLogOut.ts' },
19
+ variables: {},
20
+ });
21
+ const useRequiredUserId = createTsTemplateFile({
22
+ group: 'hooks',
23
+ name: 'use-required-user-id',
24
+ projectExports: { useRequiredUserId: {} },
25
+ source: { path: 'useRequiredUserId.ts' },
26
+ variables: {},
27
+ });
28
+ const useSession = createTsTemplateFile({
29
+ group: 'hooks',
30
+ name: 'use-session',
31
+ projectExports: { SessionData: { isTypeOnly: true }, useSession: {} },
32
+ source: { path: 'useSession.ts' },
33
+ variables: {},
34
+ });
35
+ const hooksGroup = createTsTemplateGroup({
36
+ templates: {
37
+ useCurrentUser: {
38
+ destination: 'useCurrentUser.ts',
39
+ template: useCurrentUser,
40
+ },
41
+ useLogOut: { destination: 'useLogOut.ts', template: useLogOut },
42
+ useRequiredUserId: {
43
+ destination: 'useRequiredUserId.ts',
44
+ template: useRequiredUserId,
45
+ },
46
+ useSession: { destination: 'useSession.ts', template: useSession },
47
+ },
48
+ });
49
+ export const AUTH_0_AUTH_0_HOOKS_TS_TEMPLATES = { hooksGroup };
50
+ //# sourceMappingURL=ts-templates.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ts-templates.js","sourceRoot":"","sources":["../../../../../../src/auth0/generators/react/auth0-hooks/generated/ts-templates.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,+BAA+B,EAC/B,yBAAyB,GAC1B,MAAM,iCAAiC,CAAC;AAEzC,MAAM,cAAc,GAAG,oBAAoB,CAAC;IAC1C,KAAK,EAAE,OAAO;IACd,kBAAkB,EAAE;QAClB,uBAAuB,EAAE,+BAA+B;KACzD;IACD,IAAI,EAAE,kBAAkB;IACxB,cAAc,EAAE,EAAE,cAAc,EAAE,EAAE,EAAE;IACtC,MAAM,EAAE,EAAE,IAAI,EAAE,mBAAmB,EAAE;IACrC,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE;CAC5B,CAAC,CAAC;AAEH,MAAM,SAAS,GAAG,oBAAoB,CAAC;IACrC,KAAK,EAAE,OAAO;IACd,kBAAkB,EAAE,EAAE,iBAAiB,EAAE,yBAAyB,EAAE;IACpE,IAAI,EAAE,aAAa;IACnB,cAAc,EAAE,EAAE,SAAS,EAAE,EAAE,EAAE;IACjC,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;IAChC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;IAC7C,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,sBAAsB;IAC5B,cAAc,EAAE,EAAE,iBAAiB,EAAE,EAAE,EAAE;IACzC,MAAM,EAAE,EAAE,IAAI,EAAE,sBAAsB,EAAE;IACxC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,oBAAoB,CAAC;IACtC,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,aAAa;IACnB,cAAc,EAAE,EAAE,WAAW,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,EAAE,EAAE;IACrE,MAAM,EAAE,EAAE,IAAI,EAAE,eAAe,EAAE;IACjC,SAAS,EAAE,EAAE;CACd,CAAC,CAAC;AAEH,MAAM,UAAU,GAAG,qBAAqB,CAAC;IACvC,SAAS,EAAE;QACT,cAAc,EAAE;YACd,WAAW,EAAE,mBAAmB;YAChC,QAAQ,EAAE,cAAc;SACzB;QACD,SAAS,EAAE,EAAE,WAAW,EAAE,cAAc,EAAE,QAAQ,EAAE,SAAS,EAAE;QAC/D,iBAAiB,EAAE;YACjB,WAAW,EAAE,sBAAsB;YACnC,QAAQ,EAAE,iBAAiB;SAC5B;QACD,UAAU,EAAE,EAAE,WAAW,EAAE,eAAe,EAAE,QAAQ,EAAE,UAAU,EAAE;KACnE;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,gCAAgC,GAAG,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,10 @@
1
+ fragment CurrentUser on User {
2
+ id
3
+ email
4
+ }
5
+
6
+ query getUserById($id: Uuid!) {
7
+ TPL_USER_QUERY_NAME(id: $id) {
8
+ ...CurrentUser
9
+ }
10
+ }
@@ -0,0 +1,29 @@
1
+ // @ts-nocheck
2
+
3
+ import type { CurrentUserFragment } from '%generatedGraphqlImports';
4
+
5
+ import { useGetUserByIdQuery } from '%generatedGraphqlImports';
6
+
7
+ import { useSession } from './useSession.js';
8
+
9
+ interface UseCurrentUserResult {
10
+ user?: CurrentUserFragment;
11
+ loading: boolean;
12
+ error?: Error | null;
13
+ }
14
+
15
+ export function useCurrentUser(): UseCurrentUserResult {
16
+ const { userId } = useSession();
17
+ const { data, loading, error } = useGetUserByIdQuery({
18
+ variables: { id: userId ?? '' },
19
+ skip: !userId,
20
+ });
21
+
22
+ const noUserError = !userId ? new Error('No user logged in') : null;
23
+
24
+ return {
25
+ user: data?.TPL_USER,
26
+ loading,
27
+ error: error ?? noUserError,
28
+ };
29
+ }
@@ -0,0 +1,14 @@
1
+ // @ts-nocheck
2
+
3
+ import { logError } from '%reactErrorImports';
4
+ import { useAuth0 } from '@auth0/auth0-react';
5
+
6
+ export function useLogOut(): () => void {
7
+ const { logout } = useAuth0();
8
+
9
+ return () => {
10
+ logout({ logoutParams: { returnTo: globalThis.location.origin } }).catch(
11
+ (err: unknown) => logError(err),
12
+ );
13
+ };
14
+ }
@@ -0,0 +1,11 @@
1
+ // @ts-nocheck
2
+
3
+ import { useSession } from './useSession.js';
4
+
5
+ export function useRequiredUserId(): string {
6
+ const { userId } = useSession();
7
+ if (!userId) {
8
+ throw new Error('User is not authenticated');
9
+ }
10
+ return userId;
11
+ }
@@ -0,0 +1,23 @@
1
+ // @ts-nocheck
2
+
3
+ import { useAuth0 } from '@auth0/auth0-react';
4
+ import { useMemo } from 'react';
5
+
6
+ export interface SessionData {
7
+ userId: string | null;
8
+ isAuthenticated: boolean;
9
+ }
10
+ const USER_ID_CLAIM = 'https://app.com/user_id';
11
+
12
+ export function useSession(): SessionData {
13
+ const { user, isAuthenticated } = useAuth0();
14
+
15
+ const sessionData: SessionData = useMemo(
16
+ () => ({
17
+ userId: (user?.[USER_ID_CLAIM] ?? null) as string | null,
18
+ isAuthenticated,
19
+ }),
20
+ [user, isAuthenticated],
21
+ );
22
+ return sessionData;
23
+ }
@@ -0,0 +1,6 @@
1
+ export * from './auth0-apollo/auth0-apollo.generator.js';
2
+ export * from './auth0-callback/auth0-callback.generator.js';
3
+ export * from './auth0-components/auth0-components.generator.js';
4
+ export * from './auth0-hooks/auth0-hooks.generator.js';
5
+ export * from './react-auth0/react-auth0.generator.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/auth0/generators/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './auth0-apollo/auth0-apollo.generator.js';
2
+ export * from './auth0-callback/auth0-callback.generator.js';
3
+ export * from './auth0-components/auth0-components.generator.js';
4
+ export * from './auth0-hooks/auth0-hooks.generator.js';
5
+ export * from './react-auth0/react-auth0.generator.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/auth0/generators/react/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,kDAAkD,CAAC;AACjE,cAAc,wCAAwC,CAAC;AACvD,cAAc,wCAAwC,CAAC"}
@@ -0,0 +1,23 @@
1
+ export declare const reactAuth0Generator: import("@baseplate-dev/sync").GeneratorBundleCreator<{
2
+ callbackPath?: string | undefined;
3
+ }, {
4
+ nodePackages: import("@baseplate-dev/sync").AnyGeneratorTask;
5
+ reactConfig: import("@baseplate-dev/sync").GeneratorTask<undefined, {
6
+ provider: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
7
+ configEntries: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/react-generators").ReactConfigEntry>;
8
+ additionalDevEnvVars: import("@baseplate-dev/utils").MapContainer<string, string>;
9
+ }>, "getValues">>;
10
+ }, undefined>;
11
+ reactAppConfig: import("@baseplate-dev/sync").GeneratorTask<any, {
12
+ reactConfigImports: import("@baseplate-dev/sync").ProviderType<import("@baseplate-dev/core-generators").InferTsImportMapFromSchema<{
13
+ config: {};
14
+ }>>;
15
+ reactAppConfig: import("@baseplate-dev/sync").ProviderType<Omit<import("@baseplate-dev/utils").FieldMap<{
16
+ errorBoundary: import("@baseplate-dev/utils").ScalarContainer<((contents: import("@baseplate-dev/core-generators").TsCodeFragment) => import("@baseplate-dev/core-generators").TsCodeFragment) | undefined>;
17
+ renderWrappers: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/react-generators").RenderWrapper>;
18
+ renderSiblings: import("@baseplate-dev/utils").MapContainer<string, import("@baseplate-dev/core-generators").TsCodeFragment>;
19
+ renderRoot: import("@baseplate-dev/utils").ScalarContainer<import("@baseplate-dev/core-generators").TsCodeFragment | undefined>;
20
+ }>, "getValues">>;
21
+ }, any>;
22
+ }>;
23
+ //# sourceMappingURL=react-auth0.generator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-auth0.generator.d.ts","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/react-auth0/react-auth0.generator.ts"],"names":[],"mappings":"AAwBA,eAAO,MAAM,mBAAmB;;;;;;kCAEhB,sBACf;yCAEiB,sBAAqB;;;;;;;;kCAJ7B,sBACP;mCAEsB,sBACjB;mCACuB,sBAAsB;+BAErB,sBAAsB;;;EA+CpD,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { createNodePackagesTask, extractPackageVersions, TsCodeUtils, tsImportBuilder, } from '@baseplate-dev/core-generators';
2
+ import { reactAppConfigProvider, reactConfigImportsProvider, reactConfigProvider, } from '@baseplate-dev/react-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
+ const descriptorSchema = z.object({
7
+ callbackPath: z.string().optional(),
8
+ });
9
+ export const reactAuth0Generator = createGenerator({
10
+ name: 'auth0/react-auth0',
11
+ generatorFileUrl: import.meta.url,
12
+ descriptorSchema,
13
+ buildTasks: ({ callbackPath }) => ({
14
+ nodePackages: createNodePackagesTask({
15
+ prod: extractPackageVersions(AUTH0_PACKAGES, ['@auth0/auth0-react']),
16
+ }),
17
+ reactConfig: createProviderTask(reactConfigProvider, (reactConfig) => {
18
+ reactConfig.configEntries.mergeObj({
19
+ VITE_AUTH0_DOMAIN: {
20
+ comment: 'Auth0 Domain',
21
+ validator: 'z.string().min(1)',
22
+ devDefaultValue: 'domain.auth0.com',
23
+ },
24
+ VITE_AUTH0_CLIENT_ID: {
25
+ comment: 'Auth0 Client ID',
26
+ validator: 'z.string().min(1)',
27
+ devDefaultValue: 'AUTH0_CLIENT_ID',
28
+ },
29
+ VITE_AUTH0_AUDIENCE: {
30
+ comment: 'Auth0 Audience',
31
+ validator: 'z.string().min(1)',
32
+ devDefaultValue: 'AUTH0_AUDIENCE',
33
+ },
34
+ });
35
+ }),
36
+ reactAppConfig: createGeneratorTask({
37
+ dependencies: {
38
+ reactConfigImports: reactConfigImportsProvider,
39
+ reactAppConfig: reactAppConfigProvider,
40
+ },
41
+ run({ reactConfigImports, reactAppConfig }) {
42
+ const redirectUri = callbackPath
43
+ ? `\`\${globalThis.location.origin}/${callbackPath}\``
44
+ : 'globalThis.location.origin';
45
+ reactAppConfig.renderWrappers.set('react-auth0', {
46
+ wrap: (contents) => TsCodeUtils.templateWithImports([
47
+ tsImportBuilder(['Auth0Provider']).from('@auth0/auth0-react'),
48
+ reactConfigImports.config.declaration(),
49
+ ]) `<Auth0Provider
50
+ domain={config.VITE_AUTH0_DOMAIN}
51
+ clientId={config.VITE_AUTH0_CLIENT_ID}
52
+ authorizationParams={{
53
+ redirect_uri: ${redirectUri},
54
+ audience: config.VITE_AUTH0_AUDIENCE,
55
+ }}
56
+ skipRedirectCallback
57
+ >${contents}</Auth0Provider>`,
58
+ type: 'auth',
59
+ });
60
+ },
61
+ }),
62
+ }),
63
+ });
64
+ //# sourceMappingURL=react-auth0.generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"react-auth0.generator.js","sourceRoot":"","sources":["../../../../../src/auth0/generators/react/react-auth0/react-auth0.generator.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,WAAW,EACX,eAAe,GAChB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,sBAAsB,EACtB,0BAA0B,EAC1B,mBAAmB,GACpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAElE,MAAM,gBAAgB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;IACjD,IAAI,EAAE,mBAAmB;IACzB,gBAAgB,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG;IACjC,gBAAgB;IAChB,UAAU,EAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,CAAC,CAAC;QACjC,YAAY,EAAE,sBAAsB,CAAC;YACnC,IAAI,EAAE,sBAAsB,CAAC,cAAc,EAAE,CAAC,oBAAoB,CAAC,CAAC;SACrE,CAAC;QACF,WAAW,EAAE,kBAAkB,CAAC,mBAAmB,EAAE,CAAC,WAAW,EAAE,EAAE;YACnE,WAAW,CAAC,aAAa,CAAC,QAAQ,CAAC;gBACjC,iBAAiB,EAAE;oBACjB,OAAO,EAAE,cAAc;oBACvB,SAAS,EAAE,mBAAmB;oBAC9B,eAAe,EAAE,kBAAkB;iBACpC;gBACD,oBAAoB,EAAE;oBACpB,OAAO,EAAE,iBAAiB;oBAC1B,SAAS,EAAE,mBAAmB;oBAC9B,eAAe,EAAE,iBAAiB;iBACnC;gBACD,mBAAmB,EAAE;oBACnB,OAAO,EAAE,gBAAgB;oBACzB,SAAS,EAAE,mBAAmB;oBAC9B,eAAe,EAAE,gBAAgB;iBAClC;aACF,CAAC,CAAC;QACL,CAAC,CAAC;QACF,cAAc,EAAE,mBAAmB,CAAC;YAClC,YAAY,EAAE;gBACZ,kBAAkB,EAAE,0BAA0B;gBAC9C,cAAc,EAAE,sBAAsB;aACvC;YACD,GAAG,CAAC,EAAE,kBAAkB,EAAE,cAAc,EAAE;gBACxC,MAAM,WAAW,GAAG,YAAY;oBAC9B,CAAC,CAAC,oCAAoC,YAAY,IAAI;oBACtD,CAAC,CAAC,4BAA4B,CAAC;gBAEjC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,EAAE;oBAC/C,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,mBAAmB,CAAC;wBAClD,eAAe,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC;wBAC7D,kBAAkB,CAAC,MAAM,CAAC,WAAW,EAAE;qBACxC,CAAC,CAAA;;;;0BAIc,WAAW;;;;SAI5B,QAAQ,kBAAkB;oBACzB,IAAI,EAAE,MAAM;iBACb,CAAC,CAAC;YACL,CAAC;SACF,CAAC;KACH,CAAC;CACH,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "auth0",
3
+ "displayName": "Auth0",
4
+ "icon": "icon.svg",
5
+ "description": "This plugin allows users to authenticate and authorize access to the application using Auth0.",
6
+ "version": "0.1.0",
7
+ "moduleDirectories": ["core"]
8
+ }
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="utf-8"?><!-- Uploaded to: SVG Repo, www.svgrepo.com, Generator: SVG Repo Mixer Tools -->
2
+ <svg xmlns="http://www.w3.org/2000/svg"
3
+ aria-label="Auth0" role="img"
4
+ viewBox="0 0 512 512"><rect
5
+ width="512" height="512"
6
+ rx="15%"
7
+ fill="#ffffff"/><path d="M358.1 378.8L319.6 260L420.5 186.9H295.7l-38.6-118.7l-.01-.03h124.8l38.6 118.7v-.003l0.03-.02c22.4 68.8-.7 147 -62.4 192zm-201.9 0l-.036 .03L257.13 452.2L358.09 378.84L257.17 305.51ZM93.85 186.85c-23.57 72.57 3.79 149.46 62.36 192l0.01-.036L194.77 260.17L93.89 186.87H218.6L257.15 68.2L257.2 68.2H132.4Z" fill="#eb5424"/></svg>
@@ -0,0 +1,2 @@
1
+ export * from './auth/index.js';
2
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './auth/index.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,4 @@
1
+ import type { AuthRoleDefinition } from './schema.js';
2
+ export declare const AUTH_DEFAULT_ROLES: Omit<AuthRoleDefinition, 'id'>[];
3
+ export declare function createDefaultAuthRoles(): AuthRoleDefinition[];
4
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/roles/constants.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,eAAO,MAAM,kBAAkB,EAAE,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,EAgB9D,CAAC;AAEF,wBAAgB,sBAAsB,IAAI,kBAAkB,EAAE,CAK7D"}
@@ -0,0 +1,25 @@
1
+ import { authRoleEntityType } from '@baseplate-dev/project-builder-lib';
2
+ export const AUTH_DEFAULT_ROLES = [
3
+ {
4
+ name: 'public',
5
+ comment: 'All users (including unauthenticated and authenticated users)',
6
+ builtIn: true,
7
+ },
8
+ {
9
+ name: 'user',
10
+ comment: 'All authenticated users',
11
+ builtIn: true,
12
+ },
13
+ {
14
+ name: 'system',
15
+ comment: 'System processes without a user context, e.g. background jobs',
16
+ builtIn: true,
17
+ },
18
+ ];
19
+ export function createDefaultAuthRoles() {
20
+ return AUTH_DEFAULT_ROLES.map((role) => ({
21
+ ...role,
22
+ id: authRoleEntityType.generateNewId(),
23
+ }));
24
+ }
25
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/roles/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,oCAAoC,CAAC;AAIxE,MAAM,CAAC,MAAM,kBAAkB,GAAqC;IAClE;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,+DAA+D;QACxE,OAAO,EAAE,IAAI;KACd;IACD;QACE,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,yBAAyB;QAClC,OAAO,EAAE,IAAI;KACd;IACD;QACE,IAAI,EAAE,QAAQ;QACd,OAAO,EAAE,+DAA+D;QACxE,OAAO,EAAE,IAAI;KACd;CACF,CAAC;AAEF,MAAM,UAAU,sBAAsB;IACpC,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QACvC,GAAG,IAAI;QACP,EAAE,EAAE,kBAAkB,CAAC,aAAa,EAAE;KACvC,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './schema.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './constants.js';
2
+ export * from './schema.js';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/roles/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,aAAa,CAAC"}