@sharadox/account-web-library 0.1.0-code-request.8 → 0.1.0-delivery-record.23

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 (103) hide show
  1. package/README.md +68 -0
  2. package/distribution/account-database/type.d.ts +24 -0
  3. package/distribution/account-database/type.d.ts.map +1 -1
  4. package/distribution/account-migration/index.d.ts.map +1 -1
  5. package/distribution/account-migration/index.js +24 -0
  6. package/distribution/account-migration/index.js.map +1 -1
  7. package/distribution/account-server/index.d.ts +15 -0
  8. package/distribution/account-server/index.d.ts.map +1 -0
  9. package/distribution/account-server/index.js +23 -0
  10. package/distribution/account-server/index.js.map +1 -0
  11. package/distribution/account-server/type.d.ts +28 -0
  12. package/distribution/account-server/type.d.ts.map +1 -0
  13. package/distribution/account-server/type.js +2 -0
  14. package/distribution/account-server/type.js.map +1 -0
  15. package/distribution/account-session-revocation/index.d.ts +14 -0
  16. package/distribution/account-session-revocation/index.d.ts.map +1 -0
  17. package/distribution/account-session-revocation/index.js +25 -0
  18. package/distribution/account-session-revocation/index.js.map +1 -0
  19. package/distribution/account-sign-in/index.d.ts +15 -0
  20. package/distribution/account-sign-in/index.d.ts.map +1 -0
  21. package/distribution/account-sign-in/index.js +76 -0
  22. package/distribution/account-sign-in/index.js.map +1 -0
  23. package/distribution/account-sign-in/type.d.ts +20 -0
  24. package/distribution/account-sign-in/type.d.ts.map +1 -0
  25. package/distribution/account-sign-in/type.js +2 -0
  26. package/distribution/account-sign-in/type.js.map +1 -0
  27. package/distribution/account-sign-out/index.d.ts +16 -0
  28. package/distribution/account-sign-out/index.d.ts.map +1 -0
  29. package/distribution/account-sign-out/index.js +34 -0
  30. package/distribution/account-sign-out/index.js.map +1 -0
  31. package/distribution/browser-session-read/index.d.ts +17 -0
  32. package/distribution/browser-session-read/index.d.ts.map +1 -0
  33. package/distribution/browser-session-read/index.js +48 -0
  34. package/distribution/browser-session-read/index.js.map +1 -0
  35. package/distribution/browser-session-read/type.d.ts +14 -0
  36. package/distribution/browser-session-read/type.d.ts.map +1 -0
  37. package/distribution/browser-session-read/type.js +2 -0
  38. package/distribution/browser-session-read/type.js.map +1 -0
  39. package/distribution/challenge-issue/index.d.ts +13 -0
  40. package/distribution/challenge-issue/index.d.ts.map +1 -0
  41. package/distribution/challenge-issue/index.js +18 -0
  42. package/distribution/challenge-issue/index.js.map +1 -0
  43. package/distribution/contact-channel/type.d.ts +20 -0
  44. package/distribution/contact-channel/type.d.ts.map +1 -0
  45. package/distribution/contact-channel/type.js +2 -0
  46. package/distribution/contact-channel/type.js.map +1 -0
  47. package/distribution/email-channel/index.d.ts +13 -0
  48. package/distribution/email-channel/index.d.ts.map +1 -0
  49. package/distribution/email-channel/index.js +90 -0
  50. package/distribution/email-channel/index.js.map +1 -0
  51. package/distribution/email-channel/type.d.ts +17 -0
  52. package/distribution/email-channel/type.d.ts.map +1 -0
  53. package/distribution/email-channel/type.js +2 -0
  54. package/distribution/email-channel/type.js.map +1 -0
  55. package/distribution/secret-derivation/index.d.ts +10 -0
  56. package/distribution/secret-derivation/index.d.ts.map +1 -0
  57. package/distribution/secret-derivation/index.js +15 -0
  58. package/distribution/secret-derivation/index.js.map +1 -0
  59. package/distribution/session-prune/index.d.ts +17 -0
  60. package/distribution/session-prune/index.d.ts.map +1 -0
  61. package/distribution/session-prune/index.js +30 -0
  62. package/distribution/session-prune/index.js.map +1 -0
  63. package/distribution/session-token/index.d.ts +19 -0
  64. package/distribution/session-token/index.d.ts.map +1 -0
  65. package/distribution/session-token/index.js +22 -0
  66. package/distribution/session-token/index.js.map +1 -0
  67. package/distribution/sign-in-finish/index.d.ts +12 -0
  68. package/distribution/sign-in-finish/index.d.ts.map +1 -0
  69. package/distribution/sign-in-finish/index.js +47 -0
  70. package/distribution/sign-in-finish/index.js.map +1 -0
  71. package/distribution/sign-in-finish/type.d.ts +34 -0
  72. package/distribution/sign-in-finish/type.d.ts.map +1 -0
  73. package/distribution/sign-in-finish/type.js +2 -0
  74. package/distribution/sign-in-finish/type.js.map +1 -0
  75. package/distribution/sign-in-start/index.d.ts +19 -0
  76. package/distribution/sign-in-start/index.d.ts.map +1 -0
  77. package/distribution/sign-in-start/index.js +93 -0
  78. package/distribution/sign-in-start/index.js.map +1 -0
  79. package/distribution/sign-in-start/type.d.ts +27 -0
  80. package/distribution/sign-in-start/type.d.ts.map +1 -0
  81. package/distribution/sign-in-start/type.js +2 -0
  82. package/distribution/sign-in-start/type.js.map +1 -0
  83. package/distribution/sign-up-finish/index.d.ts +12 -0
  84. package/distribution/sign-up-finish/index.d.ts.map +1 -0
  85. package/distribution/sign-up-finish/index.js +27 -0
  86. package/distribution/sign-up-finish/index.js.map +1 -0
  87. package/distribution/sign-up-finish/type.d.ts +21 -0
  88. package/distribution/sign-up-finish/type.d.ts.map +1 -0
  89. package/distribution/sign-up-finish/type.js +2 -0
  90. package/distribution/sign-up-finish/type.js.map +1 -0
  91. package/distribution/signed-ticket/index.d.ts +19 -0
  92. package/distribution/signed-ticket/index.d.ts.map +1 -0
  93. package/distribution/signed-ticket/index.js +35 -0
  94. package/distribution/signed-ticket/index.js.map +1 -0
  95. package/distribution/signed-ticket/type.d.ts +16 -0
  96. package/distribution/signed-ticket/type.d.ts.map +1 -0
  97. package/distribution/signed-ticket/type.js +2 -0
  98. package/distribution/signed-ticket/type.js.map +1 -0
  99. package/distribution/test-server/index.d.ts +10 -0
  100. package/distribution/test-server/index.d.ts.map +1 -0
  101. package/distribution/test-server/index.js +16 -0
  102. package/distribution/test-server/index.js.map +1 -0
  103. package/package.json +5 -2
@@ -0,0 +1,27 @@
1
+ import type { Solution } from "@sharadox/protection-web-library/proof-of-work/type";
2
+ import type { Contact } from "@sharadox/account-web-library/contact-kind/type";
3
+ export interface SignInStart {
4
+ contact: Contact;
5
+ /** The browser's answer to `issueChallenge`. */
6
+ solution: Solution;
7
+ /** The client's IP address (web-library's `clientAddress`). */
8
+ address: string;
9
+ /** For the code's message. */
10
+ language: string;
11
+ /** Milliseconds since 1970 (now by default). */
12
+ now?: number;
13
+ }
14
+ export type SignInStartResult = {
15
+ status: "sent";
16
+ requestId: string;
17
+ /** Sends the code: call it after answering (Next.js `after()`), so the answer's timing reveals nothing. */
18
+ deliver: () => Promise<void>;
19
+ } | {
20
+ status: "refused";
21
+ reason: "proof" | "contact" | "unavailable";
22
+ } | {
23
+ status: "refused";
24
+ reason: "rate-limit";
25
+ retryAfterSeconds: number;
26
+ };
27
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/sign-in-start/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qDAAqD,CAAC;AACpF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,iDAAiD,CAAC;AAE/E,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,OAAO,CAAC;IACjB,gDAAgD;IAChD,QAAQ,EAAE,QAAQ,CAAC;IACnB,+DAA+D;IAC/D,OAAO,EAAE,MAAM,CAAC;IAChB,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,iBAAiB,GACzB;IACE,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,2GAA2G;IAC3G,OAAO,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B,GACD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,aAAa,CAAA;CAAE,GAClE;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,YAAY,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/sign-in-start/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import type { AccountServer } from "@sharadox/account-web-library/account-server/type";
2
+ import type { SignUpFinish, SignUpFinishResult } from "@sharadox/account-web-library/sign-up-finish/type";
3
+ /**
4
+ * The last step for a new person: the username they chose, with the ticket proving their contact. Creates the
5
+ * account with that contact verified and signs it in. A taken or invalid username can be tried again with the same
6
+ * ticket while it lasts; a ticket can't make two accounts (the contact is then taken).
7
+ *
8
+ * @example
9
+ * const result = await finishSignUp(server, { ticket, username, token: cookie });
10
+ */
11
+ export declare function finishSignUp(server: AccountServer, { ticket, username, token, now }: SignUpFinish): Promise<SignUpFinishResult>;
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/sign-up-finish/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mDAAmD,CAAC;AAKvF,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,mDAAmD,CAAC;AAE1G;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAChC,MAAM,EAAE,aAAa,EACrB,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAgB,EAAE,EAAE,YAAY,GAC1D,OAAO,CAAC,kBAAkB,CAAC,CAW7B"}
@@ -0,0 +1,27 @@
1
+ import { signIn } from "@sharadox/account-web-library/account-sign-in";
2
+ import { createPersonAccount } from "@sharadox/account-web-library/person-account";
3
+ import { deriveSecret } from "@sharadox/account-web-library/secret-derivation";
4
+ import { readTicket } from "@sharadox/account-web-library/signed-ticket";
5
+ /**
6
+ * The last step for a new person: the username they chose, with the ticket proving their contact. Creates the
7
+ * account with that contact verified and signs it in. A taken or invalid username can be tried again with the same
8
+ * ticket while it lasts; a ticket can't make two accounts (the contact is then taken).
9
+ *
10
+ * @example
11
+ * const result = await finishSignUp(server, { ticket, username, token: cookie });
12
+ */
13
+ export async function finishSignUp(server, { ticket, username, token, now = Date.now() }) {
14
+ const reading = readTicket(ticket, {
15
+ secret: deriveSecret(server.secret, "sign-up-ticket"),
16
+ purpose: "sign-up",
17
+ now,
18
+ });
19
+ if (!reading.valid)
20
+ return { status: "refused", reason: "ticket" };
21
+ const created = await createPersonAccount(server.database, { username, contact: reading.data.contact, now });
22
+ if (!created.created)
23
+ return { status: "refused", reason: created.reason };
24
+ const session = await signIn(server.database, { accountId: created.accountId, token, now });
25
+ return { status: "signed-in", accountId: created.accountId, token: session.token };
26
+ }
27
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/sign-up-finish/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,+CAA+C,CAAC;AAGvE,OAAO,EAAE,mBAAmB,EAAE,MAAM,8CAA8C,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAC;AAC/E,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAC;AAGzE;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,MAAqB,EACrB,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAgB;IAE3D,MAAM,OAAO,GAAG,UAAU,CAAuB,MAAM,EAAE;QACvD,MAAM,EAAE,YAAY,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC;QACrD,OAAO,EAAE,SAAS;QAClB,GAAG;KACJ,CAAC,CAAC;IACH,IAAI,CAAC,OAAO,CAAC,KAAK;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IACnE,MAAM,OAAO,GAAG,MAAM,mBAAmB,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7G,IAAI,CAAC,OAAO,CAAC,OAAO;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC;IAC3E,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5F,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC;AACrF,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { PersonAccountResult } from "@sharadox/account-web-library/person-account/type";
2
+ export interface SignUpFinish {
3
+ /** From `finishSignIn`'s `sign-up` answer. */
4
+ ticket: string;
5
+ username: string;
6
+ /** The browser's current session cookie, if any. */
7
+ token: string | undefined;
8
+ /** Milliseconds since 1970 (now by default). */
9
+ now?: number;
10
+ }
11
+ export type SignUpFinishResult = {
12
+ status: "signed-in";
13
+ accountId: string;
14
+ token: string;
15
+ } | {
16
+ status: "refused";
17
+ reason: "ticket" | Extract<PersonAccountResult, {
18
+ created: false;
19
+ }>["reason"];
20
+ };
21
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/sign-up-finish/type.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mDAAmD,CAAC;AAE7F,MAAM,WAAW,YAAY;IAC3B,8CAA8C;IAC9C,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,oDAAoD;IACpD,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;IAC1B,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,kBAAkB,GAC1B;IAAE,MAAM,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,GACzD;IAAE,MAAM,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,mBAAmB,EAAE;QAAE,OAAO,EAAE,KAAK,CAAA;KAAE,CAAC,CAAC,QAAQ,CAAC,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/sign-up-finish/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,19 @@
1
+ import type { TicketOptions, TicketReading } from "@sharadox/account-web-library/signed-ticket/type";
2
+ /**
3
+ * A short-lived, signed ticket carrying data between two steps (a proved contact from the code step to the
4
+ * username step) without storing anything: the data can be read, but not changed or used for another purpose.
5
+ *
6
+ * @example
7
+ * const ticket = createTicket({ contact }, { secret, purpose: "sign-up", lifetimeSeconds: 900 });
8
+ */
9
+ export declare function createTicket(data: unknown, { secret, purpose, lifetimeSeconds, now }: TicketOptions & {
10
+ lifetimeSeconds: number;
11
+ }): string;
12
+ /**
13
+ * The data of a ticket made by `createTicket`, if it is intact, for this purpose, and not expired.
14
+ *
15
+ * @example
16
+ * const reading = readTicket<{ contact: Contact }>(ticket, { secret, purpose: "sign-up" });
17
+ */
18
+ export declare function readTicket<Data>(ticket: string, { secret, purpose, now }: TicketOptions): TicketReading<Data>;
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/signed-ticket/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,kDAAkD,CAAC;AAIrG;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,OAAO,EACb,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAgB,EAAE,EAAE,aAAa,GAAG;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAClG,MAAM,CAKR;AAED;;;;;GAKG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAC7B,MAAM,EAAE,MAAM,EACd,EAAE,MAAM,EAAE,OAAO,EAAE,GAAgB,EAAE,EAAE,aAAa,GACnD,aAAa,CAAC,IAAI,CAAC,CAerB"}
@@ -0,0 +1,35 @@
1
+ import { createHmac, timingSafeEqual } from "node:crypto";
2
+ const sign = (secret, body) => createHmac("sha256", secret).update(body).digest("base64url");
3
+ /**
4
+ * A short-lived, signed ticket carrying data between two steps (a proved contact from the code step to the
5
+ * username step) without storing anything: the data can be read, but not changed or used for another purpose.
6
+ *
7
+ * @example
8
+ * const ticket = createTicket({ contact }, { secret, purpose: "sign-up", lifetimeSeconds: 900 });
9
+ */
10
+ export function createTicket(data, { secret, purpose, lifetimeSeconds, now = Date.now() }) {
11
+ const body = Buffer.from(JSON.stringify({ data, purpose, expiresAt: now + lifetimeSeconds * 1000 })).toString("base64url");
12
+ return `${body}.${sign(secret, body)}`;
13
+ }
14
+ /**
15
+ * The data of a ticket made by `createTicket`, if it is intact, for this purpose, and not expired.
16
+ *
17
+ * @example
18
+ * const reading = readTicket<{ contact: Contact }>(ticket, { secret, purpose: "sign-up" });
19
+ */
20
+ export function readTicket(ticket, { secret, purpose, now = Date.now() }) {
21
+ const [body, signature, ...rest] = ticket.split(".");
22
+ if (!body || !signature || rest.length > 0)
23
+ return { valid: false, reason: "signature" };
24
+ const expected = Buffer.from(sign(secret, body));
25
+ const given = Buffer.from(signature);
26
+ if (expected.length !== given.length || !timingSafeEqual(expected, given))
27
+ return { valid: false, reason: "signature" };
28
+ const content = JSON.parse(Buffer.from(body, "base64url").toString());
29
+ if (content.purpose !== purpose)
30
+ return { valid: false, reason: "signature" };
31
+ if (content.expiresAt <= now)
32
+ return { valid: false, reason: "expired" };
33
+ return { valid: true, data: content.data };
34
+ }
35
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/signed-ticket/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,IAAI,GAAG,CAAC,MAAc,EAAE,IAAY,EAAE,EAAE,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAE7G;;;;;;GAMG;AACH,MAAM,UAAU,YAAY,CAC1B,IAAa,EACb,EAAE,MAAM,EAAE,OAAO,EAAE,eAAe,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAA+C;IAEnG,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,GAAG,eAAe,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAC3G,WAAW,CACZ,CAAC;IACF,OAAO,GAAG,IAAI,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC;AACzC,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,UAAU,CACxB,MAAc,EACd,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,EAAiB;IAEpD,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,GAAG,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACrD,IAAI,CAAC,IAAI,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACzF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IACjD,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACrC,IAAI,QAAQ,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,CAAC,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC;QACvE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAC,QAAQ,EAAE,CAInE,CAAC;IACF,IAAI,OAAO,CAAC,OAAO,KAAK,OAAO;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IAC9E,IAAI,OAAO,CAAC,SAAS,IAAI,GAAG;QAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IACzE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;AAC7C,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface TicketOptions {
2
+ /** At least 32 characters, server only. */
3
+ secret: string;
4
+ /** What the ticket is for: a ticket for one purpose is refused for any other. */
5
+ purpose: string;
6
+ /** Milliseconds since 1970 (now by default). */
7
+ now?: number;
8
+ }
9
+ export type TicketReading<Data> = {
10
+ valid: true;
11
+ data: Data;
12
+ } | {
13
+ valid: false;
14
+ reason: "signature" | "expired";
15
+ };
16
+ //# sourceMappingURL=type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.d.ts","sourceRoot":"","sources":["../../source/signed-ticket/type.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,aAAa;IAC5B,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,iFAAiF;IACjF,OAAO,EAAE,MAAM,CAAC;IAChB,gDAAgD;IAChD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,aAAa,CAAC,IAAI,IAAI;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,WAAW,GAAG,SAAS,CAAA;CAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type.js","sourceRoot":"","sources":["../../source/signed-ticket/type.ts"],"names":[],"mappings":""}
@@ -0,0 +1,10 @@
1
+ import type { MemoryDatabase } from "@sharadox/database-web-library/memory-database/type";
2
+ import type { AccountServerDatabase } from "@sharadox/account-web-library/account-database/type";
3
+ /**
4
+ * A migrated account server database (account and protection tables) in memory, for tests of the sign-in flow.
5
+ *
6
+ * @example
7
+ * const memory = await createTestServerDatabase();
8
+ */
9
+ export declare function createTestServerDatabase(): Promise<MemoryDatabase<AccountServerDatabase>>;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../source/test-server/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qDAAqD,CAAC;AAE1F,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAGjG;;;;;GAKG;AACH,wBAAsB,wBAAwB,IAAI,OAAO,CAAC,cAAc,CAAC,qBAAqB,CAAC,CAAC,CAK/F"}
@@ -0,0 +1,16 @@
1
+ import { createMemoryDatabase } from "@sharadox/database-web-library/memory-database";
2
+ import { migrateProtection } from "@sharadox/protection-web-library/protection-migration";
3
+ import { migrateAccount } from "@sharadox/account-web-library/account-migration";
4
+ /**
5
+ * A migrated account server database (account and protection tables) in memory, for tests of the sign-in flow.
6
+ *
7
+ * @example
8
+ * const memory = await createTestServerDatabase();
9
+ */
10
+ export async function createTestServerDatabase() {
11
+ const memory = await createMemoryDatabase();
12
+ await migrateProtection(memory.database);
13
+ await migrateAccount(memory.database);
14
+ return memory;
15
+ }
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/test-server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,gDAAgD,CAAC;AAEtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,uDAAuD,CAAC;AAE1F,OAAO,EAAE,cAAc,EAAE,MAAM,iDAAiD,CAAC;AAEjF;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB;IAC5C,MAAM,MAAM,GAAG,MAAM,oBAAoB,EAAyB,CAAC;IACnE,MAAM,iBAAiB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzC,MAAM,cAAc,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC;AAChB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sharadox/account-web-library",
3
- "version": "0.1.0-code-request.8",
3
+ "version": "0.1.0-delivery-record.23",
4
4
  "description": "Passwordless accounts for web applications: one-time codes, two-factor, roles, bans and OpenID Connect for people and agents.",
5
5
  "private": false,
6
6
  "license": "SEE LICENSE IN LICENCA.md",
@@ -41,8 +41,11 @@
41
41
  },
42
42
  "dependencies": {
43
43
  "@sharadox/database-web-library": "0.1.0-development.6",
44
+ "@sharadox/email-web-library": "^0.7.1",
45
+ "@sharadox/protection-web-library": "0.1.0-development.9",
44
46
  "@sharadox/web-library": "^0.11.1",
45
- "kysely": "^0.28.20"
47
+ "kysely": "^0.28.20",
48
+ "zod": "^4.6.7"
46
49
  },
47
50
  "devDependencies": {
48
51
  "@electric-sql/pglite": "0.5.16",