@cedarjs/auth-dbauth-setup 5.0.7-next.338 → 5.0.7

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/dist/index.js CHANGED
@@ -1 +1,22 @@
1
- export * from "./setup.js";
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
+ var index_exports = {};
17
+ module.exports = __toCommonJS(index_exports);
18
+ __reExport(index_exports, require("./setup.js"), module.exports);
19
+ // Annotate the CommonJS export names for ESM import in node:
20
+ 0 && (module.exports = {
21
+ ...require("./setup.js")
22
+ });
package/dist/setup.js CHANGED
@@ -1,4 +1,40 @@
1
- import { terminalLink } from "termi-link";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var setup_exports = {};
30
+ __export(setup_exports, {
31
+ builder: () => builder,
32
+ command: () => command,
33
+ description: () => description,
34
+ handler: () => handler
35
+ });
36
+ module.exports = __toCommonJS(setup_exports);
37
+ var import_termi_link = require("termi-link");
2
38
  const command = "dbAuth";
3
39
  const description = "Set up auth for for dbAuth";
4
40
  function builder(yargs) {
@@ -23,7 +59,7 @@ function builder(yargs) {
23
59
  description: "Generate auth pages (login, signup, etc.)",
24
60
  type: "boolean"
25
61
  }).epilogue(
26
- `Also see the ${terminalLink(
62
+ `Also see the ${(0, import_termi_link.terminalLink)(
27
63
  "CedarJS CLI Reference",
28
64
  "https://cedarjs.com/docs/cli-commands#setup-auth"
29
65
  )}`
@@ -33,9 +69,10 @@ const handler = async (options) => {
33
69
  const { handler: handler2 } = await import("./setupHandler.js");
34
70
  return handler2(options);
35
71
  };
36
- export {
72
+ // Annotate the CommonJS export names for ESM import in node:
73
+ 0 && (module.exports = {
37
74
  builder,
38
75
  command,
39
76
  description,
40
77
  handler
41
- };
78
+ });
@@ -10,5 +10,4 @@ export declare const createUserModelTask: {
10
10
  export declare const notes: string[];
11
11
  export declare const notesCreatedUserModel: string[];
12
12
  export declare const noteGenerate: string[];
13
- export declare const notePrivateSet: string[];
14
13
  //# sourceMappingURL=setupData.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"setupData.d.ts","sourceRoot":"","sources":["../src/setupData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM5D,eAAO,MAAM,SAAS;;;CAKrB,CAAA;AAED,eAAO,MAAM,mBAAmB;;gBAEZ,gBAAgB;CAoBnC,CAAA;AAGD,eAAO,MAAM,KAAK,UAsDjB,CAAA;AAED,eAAO,MAAM,qBAAqB,UAwBjC,CAAA;AAED,eAAO,MAAM,YAAY,UAMxB,CAAA;AAED,eAAO,MAAM,cAAc,UAO1B,CAAA"}
1
+ {"version":3,"file":"setupData.d.ts","sourceRoot":"","sources":["../src/setupData.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM5D,eAAO,MAAM,SAAS;;;CAKrB,CAAA;AAED,eAAO,MAAM,mBAAmB;;gBAEZ,gBAAgB;CAoBnC,CAAA;AAGD,eAAO,MAAM,KAAK,UAsDjB,CAAA;AAED,eAAO,MAAM,qBAAqB,UAwBjC,CAAA;AAED,eAAO,MAAM,YAAY,UAMxB,CAAA"}
package/dist/setupData.js CHANGED
@@ -1,9 +1,46 @@
1
- import crypto from "node:crypto";
2
- import path from "node:path";
3
- import { getPaths, colors, addEnvVarTask } from "@cedarjs/cli-helpers";
4
- import { addModels, functionsPath, hasModel, libPath } from "./shared.js";
5
- const secret = crypto.randomBytes(32).toString("base64");
6
- const extraTask = addEnvVarTask(
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var setupData_exports = {};
30
+ __export(setupData_exports, {
31
+ createUserModelTask: () => createUserModelTask,
32
+ extraTask: () => extraTask,
33
+ noteGenerate: () => noteGenerate,
34
+ notes: () => notes,
35
+ notesCreatedUserModel: () => notesCreatedUserModel
36
+ });
37
+ module.exports = __toCommonJS(setupData_exports);
38
+ var import_node_crypto = __toESM(require("node:crypto"));
39
+ var import_node_path = __toESM(require("node:path"));
40
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
41
+ var import_shared = require("./shared.js");
42
+ const secret = import_node_crypto.default.randomBytes(32).toString("base64");
43
+ const extraTask = (0, import_cli_helpers.addEnvVarTask)(
7
44
  "SESSION_SECRET",
8
45
  secret,
9
46
  "Used to encrypt/decrypt session cookies. Change this value and re-deploy to log out all users of your app at once."
@@ -11,11 +48,11 @@ const extraTask = addEnvVarTask(
11
48
  const createUserModelTask = {
12
49
  title: "Creating model `User`...",
13
50
  task: async (ctx) => {
14
- const hasUserModel = await hasModel("User");
51
+ const hasUserModel = await (0, import_shared.hasModel)("User");
15
52
  if (hasUserModel && !ctx.force) {
16
53
  throw new Error("User model already exists");
17
54
  }
18
- addModels(`
55
+ (0, import_shared.addModels)(`
19
56
  model User {
20
57
  id String @id @default(uuid())
21
58
  email String @unique
@@ -30,7 +67,7 @@ model User {
30
67
  }
31
68
  };
32
69
  const notes = [
33
- `${colors.warning("Done! But you have a little more work to do:")}
70
+ `${import_cli_helpers.colors.warning("Done! But you have a little more work to do:")}
34
71
  `,
35
72
  "You will need to add a couple of fields to your User table in order",
36
73
  "to store a hashed password and salt:",
@@ -58,7 +95,7 @@ const notes = [
58
95
  "You'll need to let Cedar know what fields you're using for your users'",
59
96
  "`id` and `username` fields. In this case we're using `id` and `email`,",
60
97
  "so update those in the `authFields` config in",
61
- `\`${functionsPath}/auth.js\`. This is also the place to tell Cedar if`,
98
+ `\`${import_shared.functionsPath}/auth.js\`. This is also the place to tell Cedar if`,
62
99
  "you used a different name for the `hashedPassword`, `salt`,",
63
100
  "`resetToken` or `resetTokenExpiresAt`, fields:`",
64
101
  "",
@@ -72,12 +109,12 @@ const notes = [
72
109
  " },",
73
110
  "",
74
111
  "To get the actual user that's logged in, take a look at `getCurrentUser()`",
75
- `in \`${libPath}/auth.js\`. We default it to something simple, but you may`,
112
+ `in \`${import_shared.libPath}/auth.js\`. We default it to something simple, but you may`,
76
113
  "use different names for your model or unique ID fields, in which case you",
77
114
  "need to update those calls (instructions are in the comment above the code).",
78
115
  "",
79
116
  "Finally, we created a SESSION_SECRET environment variable for you in",
80
- `${path.join(getPaths().base, ".env")}. This value should NOT be checked`,
117
+ `${import_node_path.default.join((0, import_cli_helpers.getPaths)().base, ".env")}. This value should NOT be checked`,
81
118
  "into version control and should be unique for each environment you",
82
119
  "deploy to. If you ever need to log everyone out of your app at once",
83
120
  "change this secret to a new value and deploy. To create a new secret, run:",
@@ -86,19 +123,19 @@ const notes = [
86
123
  ""
87
124
  ];
88
125
  const notesCreatedUserModel = [
89
- `${colors.warning("Done! But you have a little more work to do:")}
126
+ `${import_cli_helpers.colors.warning("Done! But you have a little more work to do:")}
90
127
  `,
91
128
  "If you expose any of your user data via GraphQL be sure to exclude",
92
129
  "`hashedPassword` and `salt` (or whatever you named them) from the",
93
130
  "SDL file that defines the fields for your user.",
94
131
  "",
95
132
  "To get the actual user that's logged in, take a look at `getCurrentUser()`",
96
- `in \`${libPath}/auth.js\`. We default it to something simple, but you may`,
133
+ `in \`${import_shared.libPath}/auth.js\`. We default it to something simple, but you may`,
97
134
  "use different names for your model or unique ID fields, in which case you",
98
135
  "need to update those calls (instructions are in the comment above the code).",
99
136
  "",
100
137
  "Finally, we created a SESSION_SECRET environment variable for you in",
101
- `${path.join(getPaths().base, ".env")}. This value should NOT be checked`,
138
+ `${import_node_path.default.join((0, import_cli_helpers.getPaths)().base, ".env")}. This value should NOT be checked`,
102
139
  "into version control and should be unique for each environment you",
103
140
  "deploy to. If you ever need to log everyone out of your app at once",
104
141
  "change this secret to a new value and deploy. To create a new secret, run:",
@@ -118,19 +155,11 @@ const noteGenerate = [
118
155
  "",
119
156
  " yarn cedar generate dbAuth"
120
157
  ];
121
- const notePrivateSet = [
122
- "",
123
- "Ready to protect a route? Wrap it in `<PrivateSet>` in Routes.tsx:",
124
- "",
125
- ' <PrivateSet unauthenticated="login">',
126
- ' <Route path="/admin" page={AdminPage} name="admin" />',
127
- " </PrivateSet>"
128
- ];
129
- export {
158
+ // Annotate the CommonJS export names for ESM import in node:
159
+ 0 && (module.exports = {
130
160
  createUserModelTask,
131
161
  extraTask,
132
162
  noteGenerate,
133
- notePrivateSet,
134
163
  notes,
135
164
  notesCreatedUserModel
136
- };
165
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"setupHandler.d.ts","sourceRoot":"","sources":["../src/setupHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAwBtC,wBAAsB,OAAO,CAAC,EAC5B,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,KAAK,EAAE,QAAQ,GAChB,EAAE,IAAI,iBAyEN;AAsED,eAAO,MAAM,yBAAyB;;;CAuCrC,CAAA"}
1
+ {"version":3,"file":"setupHandler.d.ts","sourceRoot":"","sources":["../src/setupHandler.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAuBtC,wBAAsB,OAAO,CAAC,EAC5B,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,KAAK,EAAE,QAAQ,GAChB,EAAE,IAAI,iBAoEN;AAsED,eAAO,MAAM,yBAAyB;;;CAuCrC,CAAA"}
@@ -1,29 +1,44 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import prompts from "prompts";
4
- import { getGraphqlPath, standardAuthHandler } from "@cedarjs/cli-helpers";
5
- import {
6
- notes,
7
- noteGenerate,
8
- notesCreatedUserModel,
9
- notePrivateSet,
10
- extraTask,
11
- createUserModelTask
12
- } from "./setupData.js";
13
- import {
14
- generateAuthPagesTask,
15
- getModelNames,
16
- hasAuthPages,
17
- hasModel
18
- } from "./shared.js";
19
- import {
20
- notes as webAuthnNotes,
21
- noteGenerate as webAuthnNoteGenerate,
22
- extraTask as webAuthnExtraTask,
23
- webPackages as webAuthnWebPackages,
24
- apiPackages as webAuthnApiPackages,
25
- createUserModelTask as webAuthnCreateUserModelTask
26
- } from "./webAuthn.setupData.js";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var setupHandler_exports = {};
30
+ __export(setupHandler_exports, {
31
+ createAuthDecoderFunction: () => createAuthDecoderFunction,
32
+ handler: () => handler
33
+ });
34
+ module.exports = __toCommonJS(setupHandler_exports);
35
+ var import_node_fs = __toESM(require("node:fs"));
36
+ var import_node_path = __toESM(require("node:path"));
37
+ var import_prompts = __toESM(require("prompts"));
38
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
39
+ var import_setupData = require("./setupData.js");
40
+ var import_shared = require("./shared.js");
41
+ var import_webAuthn_setupData = require("./webAuthn.setupData.js");
27
42
  async function handler({
28
43
  webauthn,
29
44
  createUserModel,
@@ -31,10 +46,7 @@ async function handler({
31
46
  force: forceArg
32
47
  }) {
33
48
  const { version } = JSON.parse(
34
- fs.readFileSync(
35
- path.resolve(import.meta.dirname, "../package.json"),
36
- "utf-8"
37
- )
49
+ import_node_fs.default.readFileSync(import_node_path.default.resolve(__dirname, "../package.json"), "utf-8")
38
50
  );
39
51
  const webAuthn = await shouldIncludeWebAuthn(webauthn);
40
52
  const createDbUserModel = await shouldCreateUserModel(createUserModel);
@@ -42,58 +54,57 @@ async function handler({
42
54
  const oneMoreThing = [];
43
55
  if (webAuthn) {
44
56
  if (createDbUserModel) {
45
- oneMoreThing.push(...notesCreatedUserModel);
57
+ oneMoreThing.push(...import_setupData.notesCreatedUserModel);
46
58
  } else {
47
- oneMoreThing.push(...webAuthnNotes);
59
+ oneMoreThing.push(...import_webAuthn_setupData.notes);
48
60
  }
49
61
  if (!generateDbAuthPages) {
50
- oneMoreThing.push(...webAuthnNoteGenerate);
62
+ oneMoreThing.push(...import_webAuthn_setupData.noteGenerate);
51
63
  }
52
64
  } else {
53
65
  if (createDbUserModel) {
54
- oneMoreThing.push(...notesCreatedUserModel);
66
+ oneMoreThing.push(...import_setupData.notesCreatedUserModel);
55
67
  } else {
56
- oneMoreThing.push(...notes);
68
+ oneMoreThing.push(...import_setupData.notes);
57
69
  }
58
70
  if (!generateDbAuthPages) {
59
- oneMoreThing.push(...noteGenerate);
71
+ oneMoreThing.push(...import_setupData.noteGenerate);
60
72
  }
61
73
  }
62
- oneMoreThing.push(...notePrivateSet);
63
74
  let createDbUserModelTask = void 0;
64
75
  if (createDbUserModel) {
65
76
  if (webAuthn) {
66
- createDbUserModelTask = webAuthnCreateUserModelTask;
77
+ createDbUserModelTask = import_webAuthn_setupData.createUserModelTask;
67
78
  } else {
68
- createDbUserModelTask = createUserModelTask;
79
+ createDbUserModelTask = import_setupData.createUserModelTask;
69
80
  }
70
81
  }
71
- await standardAuthHandler({
72
- basedir: import.meta.dirname,
82
+ await (0, import_cli_helpers.standardAuthHandler)({
83
+ basedir: __dirname,
73
84
  forceArg,
74
85
  provider: "dbAuth",
75
86
  authDecoderImport: "import { createAuthDecoder } from '@cedarjs/auth-dbauth-api'",
76
87
  webAuthn,
77
88
  webPackages: [
78
89
  `@cedarjs/auth-dbauth-web@${version}`,
79
- ...webAuthn ? webAuthnWebPackages : []
90
+ ...webAuthn ? import_webAuthn_setupData.webPackages : []
80
91
  ],
81
92
  apiPackages: [
82
93
  `@cedarjs/auth-dbauth-api@${version}`,
83
- ...webAuthn ? webAuthnApiPackages : []
94
+ ...webAuthn ? import_webAuthn_setupData.apiPackages : []
84
95
  ],
85
96
  extraTasks: [
86
- webAuthn ? webAuthnExtraTask : extraTask,
97
+ webAuthn ? import_webAuthn_setupData.extraTask : import_setupData.extraTask,
87
98
  createDbUserModelTask,
88
99
  createAuthDecoderFunction,
89
- generateDbAuthPages ? generateAuthPagesTask(createDbUserModel) : void 0
100
+ generateDbAuthPages ? (0, import_shared.generateAuthPagesTask)(createDbUserModel) : void 0
90
101
  ],
91
102
  notes: oneMoreThing
92
103
  });
93
104
  }
94
105
  async function shouldIncludeWebAuthn(webauthn) {
95
106
  if (webauthn === null) {
96
- const webAuthnResponse = await prompts({
107
+ const webAuthnResponse = await (0, import_prompts.default)({
97
108
  type: "confirm",
98
109
  name: "answer",
99
110
  message: `Enable WebAuthn support (TouchID/FaceID)? See https://cedarjs.com/docs/auth/dbAuth#webAuthn`,
@@ -104,14 +115,14 @@ async function shouldIncludeWebAuthn(webauthn) {
104
115
  return webauthn;
105
116
  }
106
117
  async function shouldCreateUserModel(createUserModel) {
107
- const hasUserModel = await hasModel("User");
108
- const modelNames = await getModelNames();
118
+ const hasUserModel = await (0, import_shared.hasModel)("User");
119
+ const modelNames = await (0, import_shared.getModelNames)();
109
120
  const isNewProject = modelNames.length === 1 && modelNames[0] === "UserExample";
110
121
  if (isNewProject) {
111
122
  return true;
112
123
  }
113
124
  if (createUserModel === null && !hasUserModel) {
114
- const createModelResponse = await prompts({
125
+ const createModelResponse = await (0, import_prompts.default)({
115
126
  type: "confirm",
116
127
  name: "answer",
117
128
  message: "Create User model?",
@@ -122,8 +133,8 @@ async function shouldCreateUserModel(createUserModel) {
122
133
  return createUserModel;
123
134
  }
124
135
  async function shouldGenerateDbAuthPages(generateAuthPages) {
125
- if (generateAuthPages === null && !hasAuthPages()) {
126
- const generateAuthPagesResponse = await prompts({
136
+ if (generateAuthPages === null && !(0, import_shared.hasAuthPages)()) {
137
+ const generateAuthPagesResponse = await (0, import_prompts.default)({
127
138
  type: "confirm",
128
139
  name: "answer",
129
140
  message: "Generate auth pages (login, signup, forgotten password, etc)?",
@@ -136,12 +147,12 @@ async function shouldGenerateDbAuthPages(generateAuthPages) {
136
147
  const createAuthDecoderFunction = {
137
148
  title: "Create auth decoder function",
138
149
  task: () => {
139
- const graphqlPath = getGraphqlPath();
150
+ const graphqlPath = (0, import_cli_helpers.getGraphqlPath)();
140
151
  if (!graphqlPath) {
141
152
  throw new Error("Could not find your graphql file path");
142
153
  }
143
154
  const authDecoderCreation = "const authDecoder = createAuthDecoder(cookieName)";
144
- const content = fs.readFileSync(graphqlPath, "utf-8");
155
+ const content = import_node_fs.default.readFileSync(graphqlPath, "utf-8");
145
156
  let newContent = content.replace(
146
157
  "import { getCurrentUser } from",
147
158
  "import { cookieName, getCurrentUser } from"
@@ -159,13 +170,14 @@ const createAuthDecoderFunction = {
159
170
  if (!newContent.includes("import { cookieName")) {
160
171
  throw new Error("Failed to import cookieName");
161
172
  }
162
- fs.writeFileSync(graphqlPath, newContent);
173
+ import_node_fs.default.writeFileSync(graphqlPath, newContent);
163
174
  }
164
175
  };
165
176
  function escapeRegExp(str) {
166
177
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
167
178
  }
168
- export {
179
+ // Annotate the CommonJS export names for ESM import in node:
180
+ 0 && (module.exports = {
169
181
  createAuthDecoderFunction,
170
182
  handler
171
- };
183
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,QAAkD,CAAA;AACtE,eAAO,MAAM,aAAa,QAGzB,CAAA;AAED,eAAO,MAAM,aAAa,yBAOzB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,qBAe1C,CAAA;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,iBAS7C;AAED,wBAAgB,YAAY,YAuB3B;AAED,wBAAgB,qBAAqB,CAAC,mBAAmB,EAAE,OAAO;;;EAuBjE"}
1
+ {"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../src/shared.ts"],"names":[],"mappings":"AAaA,eAAO,MAAM,OAAO,QAAkD,CAAA;AACtE,eAAO,MAAM,aAAa,QAGzB,CAAA;AAED,eAAO,MAAM,aAAa,yBAMzB,CAAA;AAED,eAAO,MAAM,QAAQ,GAAU,MAAM,MAAM,qBAe1C,CAAA;AAED,wBAAsB,SAAS,CAAC,MAAM,EAAE,MAAM,iBAS7C;AAED,wBAAgB,YAAY,YAuB3B;AAED,wBAAgB,qBAAqB,CAAC,mBAAmB,EAAE,OAAO;;;EAuBjE"}
package/dist/shared.js CHANGED
@@ -1,23 +1,57 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
- import prismaInternals from "@prisma/internals";
4
- import { getPaths } from "@cedarjs/cli-helpers";
5
- import { runBin } from "@cedarjs/cli-helpers/packageManager/exec";
6
- import {
7
- processPagesDir,
8
- getSchemaPath,
9
- getPrismaSchemas
10
- } from "@cedarjs/project-config";
11
- const libPath = getPaths().api.lib.replace(getPaths().base, "");
12
- const functionsPath = getPaths().api.functions.replace(
13
- getPaths().base,
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var shared_exports = {};
30
+ __export(shared_exports, {
31
+ addModels: () => addModels,
32
+ functionsPath: () => functionsPath,
33
+ generateAuthPagesTask: () => generateAuthPagesTask,
34
+ getModelNames: () => getModelNames,
35
+ hasAuthPages: () => hasAuthPages,
36
+ hasModel: () => hasModel,
37
+ libPath: () => libPath
38
+ });
39
+ module.exports = __toCommonJS(shared_exports);
40
+ var import_node_fs = __toESM(require("node:fs"));
41
+ var import_node_path = __toESM(require("node:path"));
42
+ var import_internals = require("@prisma/internals");
43
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
44
+ var import_exec = require("@cedarjs/cli-helpers/packageManager/exec");
45
+ var import_project_config = require("@cedarjs/project-config");
46
+ const libPath = (0, import_cli_helpers.getPaths)().api.lib.replace((0, import_cli_helpers.getPaths)().base, "");
47
+ const functionsPath = (0, import_cli_helpers.getPaths)().api.functions.replace(
48
+ (0, import_cli_helpers.getPaths)().base,
14
49
  ""
15
50
  );
16
51
  const getModelNames = async () => {
17
- const { getDMMF } = prismaInternals;
18
- const result = await getPrismaSchemas();
52
+ const result = await (0, import_project_config.getPrismaSchemas)();
19
53
  const datamodel = result.schemas;
20
- const schema = await getDMMF({ datamodel });
54
+ const schema = await (0, import_internals.getDMMF)({ datamodel });
21
55
  return schema.datamodel.models.map((model) => model.name);
22
56
  };
23
57
  const hasModel = async (name) => {
@@ -32,20 +66,20 @@ const hasModel = async (name) => {
32
66
  return false;
33
67
  };
34
68
  async function addModels(models) {
35
- const schemaPath = await getSchemaPath(getPaths().api.prismaConfig);
36
- const isDirectory = fs.statSync(schemaPath).isDirectory();
69
+ const schemaPath = await (0, import_project_config.getSchemaPath)((0, import_cli_helpers.getPaths)().api.prismaConfig);
70
+ const isDirectory = import_node_fs.default.statSync(schemaPath).isDirectory();
37
71
  if (isDirectory) {
38
- fs.writeFileSync(path.join(schemaPath, "user.prisma"), models);
72
+ import_node_fs.default.writeFileSync(import_node_path.default.join(schemaPath, "user.prisma"), models);
39
73
  } else {
40
- fs.appendFileSync(schemaPath, models);
74
+ import_node_fs.default.appendFileSync(schemaPath, models);
41
75
  }
42
76
  }
43
77
  function hasAuthPages() {
44
- const routes = fs.readFileSync(getPaths().web.routes, "utf-8");
78
+ const routes = import_node_fs.default.readFileSync((0, import_cli_helpers.getPaths)().web.routes, "utf-8");
45
79
  if (/path={?['"]\/(login|signin|signup)['"]}? /i.test(routes)) {
46
80
  return true;
47
81
  }
48
- return processPagesDir().some((page) => {
82
+ return (0, import_project_config.processPagesDir)().some((page) => {
49
83
  if (page.importName === "LoginPage" || page.importName === "LogInPage" || page.importName === "SigninPage" || page.importName === "SignInPage" || page.importName === "SignupPage" || page.importName === "SignUpPage") {
50
84
  return true;
51
85
  }
@@ -56,7 +90,7 @@ function generateAuthPagesTask(generatingUserModel) {
56
90
  return {
57
91
  title: "Adding dbAuth pages...",
58
92
  task: async () => {
59
- const rwjsPaths = getPaths();
93
+ const rwjsPaths = (0, import_cli_helpers.getPaths)();
60
94
  const args = ["g", "dbAuth"];
61
95
  if (generatingUserModel) {
62
96
  args.push(
@@ -66,14 +100,15 @@ function generateAuthPagesTask(generatingUserModel) {
66
100
  "password"
67
101
  );
68
102
  }
69
- await runBin("cedar", args, {
103
+ await (0, import_exec.runBin)("cedar", args, {
70
104
  stdio: "inherit",
71
105
  cwd: rwjsPaths.base
72
106
  });
73
107
  }
74
108
  };
75
109
  }
76
- export {
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
77
112
  addModels,
78
113
  functionsPath,
79
114
  generateAuthPagesTask,
@@ -81,4 +116,4 @@ export {
81
116
  hasAuthPages,
82
117
  hasModel,
83
118
  libPath
84
- };
119
+ });
@@ -1,17 +1,55 @@
1
- import path from "node:path";
2
- import { getPaths, colors } from "@cedarjs/cli-helpers";
3
- import { addModels, functionsPath, hasModel, libPath } from "./shared.js";
4
- import { extraTask } from "./setupData.js";
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+ var webAuthn_setupData_exports = {};
30
+ __export(webAuthn_setupData_exports, {
31
+ apiPackages: () => apiPackages,
32
+ createUserModelTask: () => createUserModelTask,
33
+ extraTask: () => import_setupData.extraTask,
34
+ noteGenerate: () => noteGenerate,
35
+ notes: () => notes,
36
+ webPackages: () => webPackages
37
+ });
38
+ module.exports = __toCommonJS(webAuthn_setupData_exports);
39
+ var import_node_path = __toESM(require("node:path"));
40
+ var import_cli_helpers = require("@cedarjs/cli-helpers");
41
+ var import_shared = require("./shared.js");
42
+ var import_setupData = require("./setupData.js");
5
43
  const webPackages = ["@simplewebauthn/browser@^10"];
6
44
  const apiPackages = ["@simplewebauthn/server@^10"];
7
45
  const createUserModelTask = {
8
46
  title: "Creating model `User`...",
9
47
  task: async (ctx) => {
10
- const hasUserModel = await hasModel("User");
48
+ const hasUserModel = await (0, import_shared.hasModel)("User");
11
49
  if (hasUserModel && !ctx.force) {
12
50
  throw new Error("User model already exists");
13
51
  }
14
- addModels(`
52
+ (0, import_shared.addModels)(`
15
53
  model User {
16
54
  id String @id @default(uuid())
17
55
  email String @unique
@@ -37,7 +75,7 @@ model UserCredential {
37
75
  }
38
76
  };
39
77
  const notes = [
40
- `${colors.warning("Done! But you have a little more work to do:")}
78
+ `${import_cli_helpers.colors.warning("Done! But you have a little more work to do:")}
41
79
  `,
42
80
  "You will need to add a couple of fields to your User table in order",
43
81
  "to store a hashed password, salt, reset token, and to connect it to",
@@ -78,7 +116,7 @@ const notes = [
78
116
  "You'll need to let Cedar know what fields you're using for your users'",
79
117
  "`id` and `username` fields. In this case we're using `id` and `email`,",
80
118
  "so update those in the `authFields` config in",
81
- `\`${functionsPath}/auth.js\`. This is also the place to tell Cedar if`,
119
+ `\`${import_shared.functionsPath}/auth.js\`. This is also the place to tell Cedar if`,
82
120
  "you used a different name for the `hashedPassword`, `salt`,",
83
121
  "`resetToken` or `resetTokenExpiresAt`, fields:`",
84
122
  "",
@@ -93,12 +131,12 @@ const notes = [
93
131
  " },",
94
132
  "",
95
133
  "To get the actual user that's logged in, take a look at `getCurrentUser()`",
96
- `in \`${libPath}/auth.js\`. We default it to something simple, but you may`,
134
+ `in \`${import_shared.libPath}/auth.js\`. We default it to something simple, but you may`,
97
135
  "use different names for your model or unique ID fields, in which case you",
98
136
  "need to update those calls (instructions are in the comment above the code).",
99
137
  "",
100
138
  "Finally, we created a SESSION_SECRET environment variable for you in",
101
- `${path.join(getPaths().base, ".env")}. This value should NOT be checked`,
139
+ `${import_node_path.default.join((0, import_cli_helpers.getPaths)().base, ".env")}. This value should NOT be checked`,
102
140
  "into version control and should be unique for each environment you",
103
141
  "deploy to. If you ever need to log everyone out of your app at once",
104
142
  "change this secret to a new value and deploy. To create a new secret, run:",
@@ -113,11 +151,12 @@ const noteGenerate = [
113
151
  "",
114
152
  " yarn cedar generate dbAuth"
115
153
  ];
116
- export {
154
+ // Annotate the CommonJS export names for ESM import in node:
155
+ 0 && (module.exports = {
117
156
  apiPackages,
118
157
  createUserModelTask,
119
158
  extraTask,
120
159
  noteGenerate,
121
160
  notes,
122
161
  webPackages
123
- };
162
+ });
package/package.json CHANGED
@@ -1,42 +1,42 @@
1
1
  {
2
2
  "name": "@cedarjs/auth-dbauth-setup",
3
- "version": "5.0.7-next.338",
3
+ "version": "5.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
7
7
  "directory": "packages/auth-providers/dbAuth/setup"
8
8
  },
9
9
  "license": "MIT",
10
- "type": "module",
10
+ "type": "commonjs",
11
11
  "main": "./dist/index.js",
12
12
  "types": "./dist/index.d.ts",
13
13
  "files": [
14
14
  "dist"
15
15
  ],
16
16
  "scripts": {
17
- "build": "node ./build.mts",
17
+ "build": "node ./build.mts && yarn build:types",
18
18
  "build:pack": "yarn pack -o cedarjs-auth-dbauth-setup.tgz",
19
- "build:types": "tsc --build --verbose ./tsconfig.build.json",
19
+ "build:types": "tsc --build --verbose",
20
20
  "build:watch": "nodemon --watch src --ext \"js,jsx,ts,tsx,template\" --ignore dist --exec \"yarn build\"",
21
21
  "prepublishOnly": "NODE_ENV=production yarn build",
22
22
  "test": "yarn vitest run src",
23
23
  "test:watch": "yarn test --watch"
24
24
  },
25
25
  "dependencies": {
26
- "@cedarjs/cli-helpers": "5.0.7-next.338",
27
- "@cedarjs/project-config": "5.0.7-next.338",
26
+ "@cedarjs/cli-helpers": "5.0.7",
28
27
  "@prisma/internals": "7.8.0",
28
+ "@simplewebauthn/browser": "10.0.0",
29
29
  "prompts": "2.4.2",
30
30
  "termi-link": "1.1.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@cedarjs/framework-tools": "5.0.7-next.338",
33
+ "@cedarjs/framework-tools": "5.0.7",
34
+ "@simplewebauthn/types": "10.0.0",
34
35
  "@types/yargs": "17.0.35",
35
- "memfs": "4.68.1",
36
36
  "nodemon": "3.1.14",
37
37
  "ts-dedent": "2.3.0",
38
38
  "typescript": "5.9.3",
39
- "vitest": "4.1.10"
39
+ "vitest": "3.2.6"
40
40
  },
41
41
  "engines": {
42
42
  "node": ">=24"