@cogenta/cli 0.3.0 → 0.4.0

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.
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The one place a password reset token becomes an email — shared between
3
+ * `cogenta users reset-password --email` (a terminal, `commands/users.ts`)
4
+ * and `POST /api/auth/forgot-password` (a browser, `commands/serve.ts`'s
5
+ * `createAuthRouter` wiring).
6
+ *
7
+ * Factored out rather than duplicated: both callers already issue the token
8
+ * through the same `PasswordResetStore`, and a second copy of "how the mail
9
+ * is worded" would drift the moment one of them changed it.
10
+ */
11
+ export interface ResetMailSite {
12
+ readonly name: string;
13
+ readonly url: string;
14
+ }
15
+ export interface SendResetMailOptions {
16
+ /** Where the outgoing mail is written. Defaults to `.cogenta/mail` under the project. */
17
+ readonly mailDir: string;
18
+ /**
19
+ * When set, the mail links to this admin screen (with the token appended as
20
+ * `?token=`) instead of naming the `cogenta users reset-password --token`
21
+ * terminal command. `runServe` passes this so a person who asked from the
22
+ * admin's "forgot password" screen gets something they can click; the CLI
23
+ * command itself never sets it, since whoever ran it is already at a
24
+ * terminal.
25
+ */
26
+ readonly resetUrl?: string;
27
+ }
28
+ /**
29
+ * Sends the reset mail through `@cogenta/channels`, not through a second
30
+ * mailer of this command's own — the email adapter and its transport
31
+ * interface already exist and are the project's one way out.
32
+ *
33
+ * The transport is the file one, because it is the only one that exists: a
34
+ * real SMTP transport is a documented, deliberate gap in that package
35
+ * (`providers/email/transport.ts`). So this writes a real message to a real
36
+ * file and says exactly where, rather than pretending mail left the machine.
37
+ */
38
+ export declare function sendResetMail(options: SendResetMailOptions, site: ResetMailSite, address: string, token: string, expiresAt: string): Promise<string>;
39
+ //# sourceMappingURL=reset-mail.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset-mail.d.ts","sourceRoot":"","sources":["../src/reset-mail.ts"],"names":[],"mappings":"AAEA;;;;;;;;;GASG;AAEH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,oBAAoB;IACnC,yFAAyF;IACzF,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;IACxB;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAA;CAC3B;AAED;;;;;;;;;GASG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,oBAAoB,EAC7B,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,MAAM,EACb,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,MAAM,CAAC,CAwCjB"}
@@ -0,0 +1,45 @@
1
+ import { createEmailAdapter, createFileEmailTransport } from '@cogenta/channels';
2
+ /**
3
+ * Sends the reset mail through `@cogenta/channels`, not through a second
4
+ * mailer of this command's own — the email adapter and its transport
5
+ * interface already exist and are the project's one way out.
6
+ *
7
+ * The transport is the file one, because it is the only one that exists: a
8
+ * real SMTP transport is a documented, deliberate gap in that package
9
+ * (`providers/email/transport.ts`). So this writes a real message to a real
10
+ * file and says exactly where, rather than pretending mail left the machine.
11
+ */
12
+ export async function sendResetMail(options, site, address, token, expiresAt) {
13
+ const { mailDir: directory, resetUrl } = options;
14
+ const adapter = createEmailAdapter({
15
+ transport: createFileEmailTransport({ directory }),
16
+ });
17
+ const howToUseIt = resetUrl === undefined
18
+ ? `Run: cogenta users reset-password --token ${token}\n\nThe token works once and expires at ${expiresAt}. If you did not ask for this, ignore this message — the token is useless without it, and asking again replaces it.`
19
+ : `Open this link: ${resetUrl}${resetUrl.includes('?') ? '&' : '?'}token=${token}\n\nThe link works once and expires at ${expiresAt}. If you did not ask for this, ignore this message — the token is useless without it, and asking again replaces it.`;
20
+ // `report` of the three fixed message levels: `notification` is one line
21
+ // with nowhere to put a token, and `alert` would stamp "[WARNING]" on the
22
+ // subject and demand an incident's `expectedAction`/`adminUrl`. None of the
23
+ // three was designed for transactional mail; a fourth level would change a
24
+ // closed union every one of the five adapters renders, for one caller.
25
+ await adapter.send({ id: address }, {
26
+ level: 'report',
27
+ title: `${site.name} — password reset`,
28
+ keyFigures: [
29
+ { label: 'Valid until', value: expiresAt },
30
+ { label: 'Uses left', value: '1' },
31
+ ],
32
+ sections: [
33
+ {
34
+ heading: 'Your one-time token',
35
+ body: token,
36
+ },
37
+ {
38
+ heading: 'How to use it',
39
+ body: howToUseIt,
40
+ },
41
+ ],
42
+ });
43
+ return directory;
44
+ }
45
+ //# sourceMappingURL=reset-mail.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reset-mail.js","sourceRoot":"","sources":["../src/reset-mail.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAA;AAgChF;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAA6B,EAC7B,IAAmB,EACnB,OAAe,EACf,KAAa,EACb,SAAiB;IAEjB,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAEhD,MAAM,OAAO,GAAG,kBAAkB,CAAC;QACjC,SAAS,EAAE,wBAAwB,CAAC,EAAE,SAAS,EAAE,CAAC;KACnD,CAAC,CAAA;IAEF,MAAM,UAAU,GACd,QAAQ,KAAK,SAAS;QACpB,CAAC,CAAC,6CAA6C,KAAK,2CAA2C,SAAS,qHAAqH;QAC7N,CAAC,CAAC,mBAAmB,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,SAAS,KAAK,0CAA0C,SAAS,qHAAqH,CAAA;IAE5P,yEAAyE;IACzE,0EAA0E;IAC1E,4EAA4E;IAC5E,2EAA2E;IAC3E,uEAAuE;IACvE,MAAM,OAAO,CAAC,IAAI,CAChB,EAAE,EAAE,EAAE,OAAO,EAAE,EACf;QACE,KAAK,EAAE,QAAQ;QACf,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,mBAAmB;QACtC,UAAU,EAAE;YACV,EAAE,KAAK,EAAE,aAAa,EAAE,KAAK,EAAE,SAAS,EAAE;YAC1C,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,EAAE,GAAG,EAAE;SACnC;QACD,QAAQ,EAAE;YACR;gBACE,OAAO,EAAE,qBAAqB;gBAC9B,IAAI,EAAE,KAAK;aACZ;YACD;gBACE,OAAO,EAAE,eAAe;gBACxB,IAAI,EAAE,UAAU;aACjB;SACF;KACF,CACF,CAAA;IAED,OAAO,SAAS,CAAA;AAClB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cogenta/cli",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "The Cogenta command line: diagnose an install, run migrations, inspect drivers.",
5
5
  "license": "MPL-2.0",
6
6
  "type": "module",
@@ -30,17 +30,20 @@
30
30
  },
31
31
  "dependencies": {
32
32
  "graphql": "^17.0.2",
33
- "@cogenta/agents": "0.2.0",
34
- "@cogenta/blocks": "0.1.3",
35
- "@cogenta/channels": "0.2.0",
36
- "@cogenta/api": "1.0.0",
37
- "@cogenta/auth": "0.2.0",
38
- "@cogenta/core": "0.3.0",
39
- "@cogenta/import": "0.1.3",
40
- "@cogenta/schema": "0.2.0",
41
- "@cogenta/seo": "0.2.0",
42
- "@cogenta/render": "0.1.3",
43
- "@cogenta/theme-canonical": "0.2.0"
33
+ "@cogenta/agents": "0.2.1",
34
+ "@cogenta/analytics": "0.2.0",
35
+ "@cogenta/auth": "0.3.0",
36
+ "@cogenta/blocks": "0.1.4",
37
+ "@cogenta/api": "1.1.0",
38
+ "@cogenta/channels": "0.2.1",
39
+ "@cogenta/commerce": "0.2.0",
40
+ "@cogenta/import": "0.1.4",
41
+ "@cogenta/plugins": "0.2.0",
42
+ "@cogenta/core": "0.4.0",
43
+ "@cogenta/theme-canonical": "0.2.1",
44
+ "@cogenta/schema": "0.3.0",
45
+ "@cogenta/render": "0.1.4",
46
+ "@cogenta/seo": "0.2.1"
44
47
  },
45
48
  "devDependencies": {
46
49
  "typescript": "^7.0.2",