@nxgt/janus 0.25.0 → 0.27.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.
Files changed (33) hide show
  1. package/README.md +22 -5
  2. package/dist/auth/config/reserved.d.ts +1 -1
  3. package/dist/auth/config/reserved.d.ts.map +1 -1
  4. package/dist/auth/email-flows/any-type-change-email.d.ts +18 -0
  5. package/dist/auth/email-flows/any-type-change-email.d.ts.map +1 -0
  6. package/dist/auth/email-flows/change-email-token.d.ts +6 -1
  7. package/dist/auth/email-flows/change-email-token.d.ts.map +1 -1
  8. package/dist/auth/email-flows/change-email.d.ts +6 -0
  9. package/dist/auth/email-flows/change-email.d.ts.map +1 -1
  10. package/dist/auth/index.d.ts +1 -1
  11. package/dist/auth/index.d.ts.map +1 -1
  12. package/dist/auth/janus.d.ts.map +1 -1
  13. package/dist/auth/sign-in-attempts.d.ts +5 -0
  14. package/dist/auth/sign-in-attempts.d.ts.map +1 -1
  15. package/dist/auth/types/change-email.d.ts +31 -0
  16. package/dist/auth/types/change-email.d.ts.map +1 -1
  17. package/dist/auth/types/index.d.ts +1 -1
  18. package/dist/auth/types/index.d.ts.map +1 -1
  19. package/dist/auth/types/janus.d.ts +9 -2
  20. package/dist/auth/types/janus.d.ts.map +1 -1
  21. package/dist/auth/types/password.d.ts +8 -2
  22. package/dist/auth/types/password.d.ts.map +1 -1
  23. package/dist/auth/users/change-password.d.ts +13 -0
  24. package/dist/auth/users/change-password.d.ts.map +1 -1
  25. package/dist/index.js +470 -450
  26. package/dist/index.js.map +20 -19
  27. package/docs/README.md +1 -1
  28. package/docs/guide/email-flows.md +14 -0
  29. package/docs/guide/passwords.md +8 -2
  30. package/docs/guide/users.md +3 -3
  31. package/docs/roadmap.md +11 -27
  32. package/docs/troubleshooting.md +15 -12
  33. package/package.json +1 -1
package/README.md CHANGED
@@ -418,7 +418,9 @@ else reaches the store and is asynchronous.
418
418
  'throttled'` and `retryAfter`, the seconds until the next window. Nothing
419
419
  locks, a login nobody holds is counted alike, and a password sign-in that
420
420
  opens a session — after its second factor, when one is active — starts
421
- the count again. `signIn: { throttle: { attempts, window } }`
421
+ the count again. `changePassword` counts in the same budget: a wrong
422
+ `current` is one more password tried at the login, and past the limit it
423
+ is refused alike, with `retryAfter`. `signIn: { throttle: { attempts, window } }`
422
424
  changes it, `signIn: { throttle: false }` turns it off; a store that
423
425
  cannot count throws `STORE_FAILED`
424
426
  ([passwords](docs/guide/passwords.md#password-guessing-is-throttled)).
@@ -798,6 +800,19 @@ there. Without janus-mail, send it with your own mailer.
798
800
  - **Events**: `user.emailChanged`, carrying `formerEmail`, then
799
801
  `user.emailVerified`. An `update` that moves the e-mail spends the
800
802
  user's pending links, so a move back to the old address revives none.
803
+ - **With several user types**, `auth.admin.changeEmail.confirm(token)` answers
804
+ `TOKEN_UNKNOWN` for a token issued to a user of another type — and the token
805
+ is spent. A confirmation page that does not know the type calls the root's
806
+ instead, which reads the user the token was issued to, whatever their type,
807
+ and confirms exactly as their type does (`send` stays on each type):
808
+
809
+ ```ts
810
+ await auth.admin.changeEmail.send(admin, newEmail);
811
+ const changed = await auth.changeEmail.confirm(token); // changed.type === 'admin'
812
+ ```
813
+
814
+ It exists when at least one type has an e-mail, so a type cannot be named
815
+ `changeEmail`. Its type is `AnyTypeChangeEmailApi`.
801
816
 
802
817
  [The e-mail flows guide](docs/guide/email-flows.md#changeemail) has a Hono
803
818
  route for each step, with the notice to the former address.
@@ -1660,7 +1675,9 @@ minutes.
1660
1675
  per 15 minutes, then `CREDENTIALS_INVALID` with `retryAfter` until the window
1661
1676
  ends — the right password too, so tell the visitor to wait `retryAfter`
1662
1677
  seconds rather than that the password is wrong. `CredentialRefusal` gained
1663
- `'throttled'`: an exhaustive `switch` over `error.reason` must handle it. A
1678
+ `'throttled'`: an exhaustive `switch` over `error.reason` must handle it.
1679
+ `changePassword` counts in the same budget, so wrong current passwords can
1680
+ make `signIn` answer throttled, and the other way round. A
1664
1681
  test that tries more than ten wrong passwords at one login over a
1665
1682
  `fixedClock` is throttled too: advance the clock past `retryAfter`, or wire
1666
1683
  `signIn: { throttle: false }`. **Somebody who knows a login can keep its
@@ -1796,7 +1813,7 @@ that sends one, since it is awaited: queue the event and return.
1796
1813
 
1797
1814
  ## Type safety, counted
1798
1815
 
1799
- **One hundred and eighty-one plausible mistakes, one hundred and eighty-one refused at compile time — and
1816
+ **One hundred and eighty-five plausible mistakes, one hundred and eighty-five refused at compile time — and
1800
1817
  two gaps, named.**
1801
1818
 
1802
1819
  The lists are typechecked and never run, with one `@ts-expect-error` per
@@ -1804,10 +1821,10 @@ mistake beside the shapes that must keep compiling. One is a single file:
1804
1821
  `test/types/refusals.ts` (fifteen, on the shared vocabulary). The other three
1805
1822
  are folders with one file per behaviour: `test/types/port/` (twenty-six, on
1806
1823
  the identity stores' port, from the point of view of the person implementing
1807
- it), `test/types/auth/` (eighty-eight, on `janus()`, from the point of view of
1824
+ it), `test/types/auth/` (ninety-two, on `janus()`, from the point of view of
1808
1825
  the application — twelve of them on the second factor, three on sign-in codes,
1809
1826
  five on user events, four on step-ups, six on the sign-in throttle, five on the mail throttle, four on
1810
- sign-in links, six on devices, two on `findMany`, five on requests in two steps, three on signing in on the application's proof, three on finding a user by e-mail, three on proving an e-mail on the application's proof, three on changing an e-mail, four on `findOrCreate`) and `test/types/permissions/` (fifty-two, on the
1827
+ sign-in links, six on devices, two on `findMany`, five on requests in two steps, three on signing in on the application's proof, three on finding a user by e-mail, three on proving an e-mail on the application's proof, six on changing an e-mail, four on `findOrCreate`) and `test/types/permissions/` (fifty-two, on the
1811
1828
  permission model and the questions asked of it). The rule comes from
1812
1829
  `nxgt-data`, and so does the reason to distrust the claim without the files:
1813
1830
  when it was last measured on `@nxgt/mongo`, *seven of twelve plausible
@@ -10,5 +10,5 @@ export declare const SINGLE_TYPE = "user";
10
10
  */
11
11
  export declare const RESERVED_FIELDS: readonly ["id", "type", "emailVerified", "active", "hasPassword", "hasSecondFactor", "version", "createdAt", "updatedAt", "password"];
12
12
  /** Names on `janus()`'s answer, so a user type may not take one. */
13
- export declare const RESERVED_TYPES: readonly ["authenticate", "signOut", "signOutEverywhere", "findUser", "getUser", "cookie", "collectExpired", "types"];
13
+ export declare const RESERVED_TYPES: readonly ["authenticate", "signOut", "signOutEverywhere", "findUser", "getUser", "cookie", "collectExpired", "types", "changeEmail"];
14
14
  //# sourceMappingURL=reserved.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../../src/auth/config/reserved.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,eAAe,uIAWlB,CAAC;AAEX,oEAAoE;AACpE,eAAO,MAAM,cAAc,uHASjB,CAAC"}
1
+ {"version":3,"file":"reserved.d.ts","sourceRoot":"","sources":["../../../src/auth/config/reserved.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,0DAA0D;AAC1D,eAAO,MAAM,WAAW,SAAS,CAAC;AAElC;;;GAGG;AACH,eAAO,MAAM,eAAe,uIAWlB,CAAC;AAEX,oEAAoE;AACpE,eAAO,MAAM,cAAc,sIAUjB,CAAC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The confirmation of a change of e-mail at the root of an instance with
3
+ * several user types: for the page that follows the link and does not know
4
+ * the user's type.
5
+ */
6
+ import type { AnyUser, Context } from '../context';
7
+ /**
8
+ * `{ changeEmail: { confirm } }`. Built whatever the types, as each type's
9
+ * flows are; the types show it only when one has an e-mail, and a user of a
10
+ * type without one is `TOKEN_UNKNOWN`. `send` stays on each type: it needs the
11
+ * user's type to validate the address.
12
+ */
13
+ export declare function anyTypeChangeEmail(context: Context): {
14
+ readonly changeEmail: {
15
+ confirm(token: string): Promise<AnyUser>;
16
+ };
17
+ };
18
+ //# sourceMappingURL=any-type-change-email.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"any-type-change-email.d.ts","sourceRoot":"","sources":["../../../src/auth/email-flows/any-type-change-email.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAGnD;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,GAAG;IACrD,QAAQ,CAAC,WAAW,EAAE;QAAE,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAA;KAAE,CAAC;CACnE,CAOA"}
@@ -34,9 +34,14 @@ export declare function refuseMoved(type: ResolvedType, user: UserRecord, token:
34
34
  * Spends a change's token and says why it cannot be used, when it cannot. A
35
35
  * user gone since, or of another type, is as good as no token; a user who
36
36
  * moved since the link was asked is stale.
37
+ *
38
+ * With `type` null the user's own type answers — whichever it is, provided it
39
+ * has an e-mail: a page that does not know the type confirms the link, and
40
+ * `type` in the answer is the one the user has.
37
41
  */
38
- export declare function redeemChangeEmailToken(context: Context, type: ResolvedType, secret: string, where: string): Promise<{
42
+ export declare function redeemChangeEmailToken(context: Context, type: ResolvedType | null, secret: string, where: string): Promise<{
39
43
  token: TokenRecord;
40
44
  user: UserRecord;
45
+ type: ResolvedType;
41
46
  }>;
42
47
  //# sourceMappingURL=change-email-token.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-email-token.d.ts","sourceRoot":"","sources":["../../../src/auth/email-flows/change-email-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAuC,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI,KAAG,MAGjE,CAAC;AAEH;;;;;GAKG;AACH,wBAAsB,YAAY,CACjC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,IAAI,CAQN;AAED;;;;GAIG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC,CAanD"}
1
+ {"version":3,"file":"change-email-token.d.ts","sourceRoot":"","sources":["../../../src/auth/email-flows/change-email-token.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,EAAkB,KAAK,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,KAAK,OAAO,EAAuC,MAAM,YAAY,CAAC;AAE/E,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAE7D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,qDAAqD;AACrD,eAAO,MAAM,UAAU,GAAI,QAAQ,MAAM,EAAE,QAAQ,MAAM,GAAG,IAAI,KAAG,MAGjE,CAAC;AAEH;;;;;GAKG;AACH,wBAAsB,YAAY,CACjC,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,MAAM,CAAC,CA0BjB;AAED;;;GAGG;AACH,wBAAsB,qBAAqB,CAC1C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,GACb,OAAO,CAAC,WAAW,CAAC,CAmBtB;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,UAAU,EAChB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,IAAI,CAQN;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC3C,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,GAAG,IAAI,EACzB,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAAC;IAAE,KAAK,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,UAAU,CAAC;IAAC,IAAI,EAAE,YAAY,CAAA;CAAE,CAAC,CAmBvE"}
@@ -8,4 +8,10 @@ import { type AnyUser, type Context } from '../context';
8
8
  import type { ChangeEmailApi } from '../types';
9
9
  /** `changeEmail` of one user type: `send` to the new address, then `confirm`. */
10
10
  export declare function changeEmailFlows(context: Context, type: ResolvedType, at: At): ChangeEmailApi<AnyUser>['changeEmail'];
11
+ /**
12
+ * Redeems a change's token: the write, then the events it earned. `asked` is
13
+ * the type whose `confirm` was called, or null for the root's, where the
14
+ * user's own type answers.
15
+ */
16
+ export declare function confirmChange(context: Context, asked: ResolvedType | null, secret: string, where: string): Promise<AnyUser>;
11
17
  //# sourceMappingURL=change-email.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"change-email.d.ts","sourceRoot":"","sources":["../../../src/auth/email-flows/change-email.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,OAAO,EAMZ,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAe/C,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,EAAE,EAAE,EAAE,GACJ,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CA4BxC"}
1
+ {"version":3,"file":"change-email.d.ts","sourceRoot":"","sources":["../../../src/auth/email-flows/change-email.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,KAAK,OAAO,EACZ,KAAK,OAAO,EAMZ,MAAM,YAAY,CAAC;AAIpB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAe/C,iFAAiF;AACjF,wBAAgB,gBAAgB,CAC/B,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,EAAE,EAAE,EAAE,GACJ,cAAc,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,CA4BxC;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAClC,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE,YAAY,GAAG,IAAI,EAC1B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,OAAO,CAAC,CAiDlB"}
@@ -8,5 +8,5 @@ export type { JanusStores, Json, JsonObject, PasswordRecord, SecondFactorRecord,
8
8
  export type { SealingKey } from './sealing';
9
9
  export { assertFresh } from './sessions/fresh';
10
10
  export type { StandardSchemaV1 } from './standard-schema';
11
- export type { Authenticated, ChangeEmailApi, Checked, EmailOf, FindByEmailApi, FindOrCreateApi, FirstProof, HeaderRecord, IssuedCode, IssuedToken, Janus, LoginOf, MagicLinkApi, PasswordApi, PreparedCode, PreparedRequest, ProvenSignInApi, RecoveredSignIn, RecoveryCodesIssued, RequestLike, RequiredStringKeys, ResetPasswordApi, SecondFactorApi, SecondFactorEnrolment, SecondFactorRequired, Session, SharedApi, SignedIn, SignInCodeApi, SignInOptions, SignInResult, StepUpApi, StepUpByApp, StepUpByEmail, TypeApi, TypesOf, User, UserBase, UserOf, UserRef, UserTypeApi, VerifyEmailApi, WriteOptions, } from './types';
11
+ export type { AnyTypeChangeEmailApi, Authenticated, ChangeEmailApi, Checked, EmailOf, FindByEmailApi, FindOrCreateApi, FirstProof, HeaderRecord, IssuedCode, IssuedToken, Janus, LoginOf, MagicLinkApi, PasswordApi, PreparedCode, PreparedRequest, ProvenSignInApi, RecoveredSignIn, RecoveryCodesIssued, RequestLike, RequiredStringKeys, ResetPasswordApi, SecondFactorApi, SecondFactorEnrolment, SecondFactorRequired, Session, SharedApi, SignedIn, SignInCodeApi, SignInOptions, SignInResult, StepUpApi, StepUpByApp, StepUpByEmail, TypeApi, TypesOf, User, UserBase, UserOf, UserRef, UserTypeApi, VerifyEmailApi, WriteOptions, } from './types';
12
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,SAAS,EACT,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,gBAAgB,EAChB,UAAU,EACV,cAAc,GACd,MAAM,U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BAAoB,EACpB,OAAO,EACP,SAAS,EACT,QAAQ,EACR,aAAa,EACb,aAAa,EACb,YAAY,EACZ,SAAS,EACT,WAAW,EACX,aAAa,EACb,OAAO,EACP,OAAO,EACP,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,OAAO,EACP,WAAW,EACX,cAAc,EACd,YAAY,GACZ,MAAM,SAAS,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"janus.d.ts","sourceRoot":"","sources":["../../src/auth/janus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,UAAU,CAAC;AAO3D,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAChD,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACpB,KAAK,CAAC,CAAC,CAAC,CA2DV"}
1
+ {"version":3,"file":"janus.d.ts","sourceRoot":"","sources":["../../src/auth/janus.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAiB,MAAM,UAAU,CAAC;AAQ3D,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,wBAAgB,KAAK,CAAC,KAAK,CAAC,CAAC,SAAS,WAAW,EAChD,MAAM,EAAE,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GACpB,KAAK,CAAC,CAAC,CAAC,CA+DV"}
@@ -7,6 +7,11 @@
7
7
  * password sign-in shut, window after window: a per-client limit is the
8
8
  * application's, and a sign-in code still opens the account.
9
9
  *
10
+ * `changePassword` counts in the same budget: each call is one more
11
+ * password tried at the user's login, counted before `current` is compared
12
+ * (a user with no password too) and refused past the limit alike, and a
13
+ * change that is written restarts the count. Wrong guesses of both add up.
14
+ *
10
15
  * Counted per login, **known or not**: an unknown login is counted as a
11
16
  * registered one is, so the throttle does not tell them apart. Counted
12
17
  * before anything is looked up or compared, so of twenty guesses at once,
@@ -1 +1 @@
1
- {"version":3,"file":"sign-in-attempts.d.ts","sourceRoot":"","sources":["../../src/auth/sign-in-attempts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgC/C;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAWf"}
1
+ {"version":3,"file":"sign-in-attempts.d.ts","sourceRoot":"","sources":["../../src/auth/sign-in-attempts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAGH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAGzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAgC/C;;;GAGG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAgBf;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CACvC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,IAAI,CAAC,CAWf"}
@@ -44,6 +44,37 @@ export interface ChangeEmailApi<U> {
44
44
  * holds is `LOGIN_TAKEN` — the token already spent; an inactive user
45
45
  * is `USER_INACTIVE`. A user written in between is `VERSION_CONFLICT`,
46
46
  * also after the token is spent.
47
+ *
48
+ * **With several user types**, a token issued to a user of another type
49
+ * is `TOKEN_UNKNOWN` here, and it is spent. A page that does not know
50
+ * the type — an anonymous confirmation page — calls the root's
51
+ * `janus.changeEmail.confirm` instead.
52
+ */
53
+ confirm(token: string): Promise<U>;
54
+ };
55
+ }
56
+ /**
57
+ * What an instance with several user types answers at its root when at least
58
+ * one has an e-mail: the confirmation of a change, whatever the user's type.
59
+ */
60
+ export interface AnyTypeChangeEmailApi<U> {
61
+ readonly changeEmail: {
62
+ /**
63
+ * Confirms a change of e-mail for a page that does not know the user's
64
+ * type: spends the link's token, reads the user it was issued to,
65
+ * whatever their type, and then does what that type's `confirm` does —
66
+ * the same move, events and refusals. The answer's `type` says which
67
+ * type it was.
68
+ *
69
+ * **Call it from a `POST`**, never from the `GET` of the link. An
70
+ * unknown, spent or lapsed token is `TOKEN_UNKNOWN`, `TOKEN_SPENT` or
71
+ * `TOKEN_EXPIRED`; a user gone since, or of a type with no e-mail, is
72
+ * `TOKEN_UNKNOWN`; a user whose e-mail is no longer the one the link
73
+ * was asked from is `TOKEN_STALE`; an address another user of the type
74
+ * holds is `LOGIN_TAKEN` — the token already spent; an inactive user
75
+ * is `USER_INACTIVE`. A user written in between is `VERSION_CONFLICT`.
76
+ *
77
+ * `send` stays on each type: `janus.admin.changeEmail.send(...)`.
47
78
  */
48
79
  confirm(token: string): Promise<U>;
49
80
  };
@@ -1 +1 @@
1
- {"version":3,"file":"change-email.d.ts","sourceRoot":"","sources":["../../../src/auth/types/change-email.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE;QACrB;;;;;;;;;;;;;;;;;WAiBG;QACH,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD;;;;;;;;;;;;;WAaG;QACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACnC,CAAC;CACF"}
1
+ {"version":3,"file":"change-email.d.ts","sourceRoot":"","sources":["../../../src/auth/types/change-email.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAEtC;;;GAGG;AACH,MAAM,WAAW,cAAc,CAAC,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE;QACrB;;;;;;;;;;;;;;;;;WAiBG;QACH,IAAI,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;QACzD;;;;;;;;;;;;;;;;;;WAkBG;QACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACnC,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB,CAAC,CAAC;IACvC,QAAQ,CAAC,WAAW,EAAE;QACrB;;;;;;;;;;;;;;;;WAgBG;QACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;KACnC,CAAC;CACF"}
@@ -7,7 +7,7 @@
7
7
  * keeps each schema's type travelling through every public method without
8
8
  * dragging a type parameter through every internal function.
9
9
  */
10
- export type { ChangeEmailApi } from './change-email';
10
+ export type { AnyTypeChangeEmailApi, ChangeEmailApi } from './change-email';
11
11
  export type { Checked } from './checks';
12
12
  export type { FirstProof, IssuedCode, IssuedToken, ResetPasswordApi, SignInCodeApi, VerifyEmailApi, } from './email-flows';
13
13
  export type { FindByEmailApi } from './find-by-email';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/types/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,YAAY,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,YAAY,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EACX,UAAU,EACV,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,aAAa,EACb,cAAc,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,YAAY,EACX,OAAO,EACP,OAAO,EACP,kBAAkB,EAClB,OAAO,EACP,MAAM,GACN,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzD,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAChE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,YAAY,EACX,eAAe,EACf,mBAAmB,EACnB,eAAe,EACf,qBAAqB,GACrB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACX,aAAa,EACb,YAAY,EACZ,WAAW,EACX,OAAO,GACP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EACX,OAAO,GACP,MAAM,WAAW,CAAC;AACnB,YAAY,EACX,oBAAoB,EACpB,QAAQ,EACR,aAAa,EACb,YAAY,GACZ,MAAM,WAAW,CAAC;AACnB,YAAY,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvE,YAAY,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACpE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -5,7 +5,7 @@
5
5
  * Part of what `janus()` hands back; `./index` gathers it.
6
6
  */
7
7
  import type { JanusConfig, MultiTypeConfig, SingleTypeConfig } from '../config';
8
- import type { ChangeEmailApi } from './change-email';
8
+ import type { AnyTypeChangeEmailApi, ChangeEmailApi } from './change-email';
9
9
  import type { ResetPasswordApi, SignInCodeApi, VerifyEmailApi } from './email-flows';
10
10
  import type { FindByEmailApi } from './find-by-email';
11
11
  import type { FindOrCreateApi } from './find-or-create';
@@ -83,9 +83,16 @@ export interface SharedApi<U extends {
83
83
  * environment may be on at run time, and `signIn` must be typed for it.
84
84
  */
85
85
  type TwoFactorOf<C> = 'secondFactor' extends keyof C ? true : false;
86
+ /**
87
+ * The users of the types that have an e-mail, which `changeEmail.confirm` at
88
+ * the root of several types answers; nothing when no type has one.
89
+ */
90
+ type ChangeEmailUsers<C extends MultiTypeConfig> = {
91
+ [K in keyof C['users'] & string]: [EmailOf<C['users'][K]>] extends [never] ? never : UserOfType<K, C['users'][K]>;
92
+ }[keyof C['users'] & string];
86
93
  /** What `janus(config)` answers. */
87
94
  export type Janus<C extends JanusConfig> = SharedApi<UserOf<C>> & (C extends MultiTypeConfig ? {
88
95
  readonly [K in keyof C['users'] & string]: TypeApi<K, C['users'][K], TwoFactorOf<C>>;
89
- } : C extends SingleTypeConfig ? TypeApi<'user', SingleAsType<C>, TwoFactorOf<C>> : never);
96
+ } & ([ChangeEmailUsers<C>] extends [never] ? unknown : AnyTypeChangeEmailApi<ChangeEmailUsers<C>>) : C extends SingleTypeConfig ? TypeApi<'user', SingleAsType<C>, TwoFactorOf<C>> : never);
90
97
  export {};
91
98
  //# sourceMappingURL=janus.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"janus.d.ts","sourceRoot":"","sources":["../../../src/auth/types/janus.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAChF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AACrD,OAAO,KAAK,EACX,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EACX,OAAO,EACP,WAAW,EACX,OAAO,EACP,YAAY,EACZ,MAAM,EACN,UAAU,EACV,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC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,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;CAC/B,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,CAAC,CAAC;AAE7B,oCAAoC;AACpC,MAAM,MAAM,KAAK,CAAC,CAAC,SAAS,WAAW,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAC9D,CAAC,CAAC,SAAS,eAAe,GACvB;IACA,QAAQ,EAAE,CAAC,IAAI,MAAM,CAAC,CAAC,OAAO,CAAC,GAAG,MAAM,GAAG,OAAO,CACjD,CAAC,EACD,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EACb,WAAW,CAAC,CAAC,CAAC,CACd;CACD,GAAG,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,GACvC,OAAO,GACP,qBAAqB,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC,GAC7C,CAAC,SAAS,gBAAgB,GACzB,OAAO,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,GAChD,KAAK,CAAC,CAAC"}
@@ -63,8 +63,14 @@ export interface PasswordApi<U, In, Login extends string, Answer = SignedIn<U>>
63
63
  setPassword(user: UserRef, password: string, options?: WriteOptions): Promise<U>;
64
64
  /**
65
65
  * Replaces the password after checking the current one — the user's call.
66
- * `CREDENTIALS_INVALID` when `current` is wrong. Other sessions stay open:
67
- * call `signOutEverywhere(user, { except })` for that.
66
+ * `CREDENTIALS_INVALID` when `current` is wrong. Each call is counted in
67
+ * the sign-in throttle of the user's login, whose budget `signIn` shares:
68
+ * past the limit it is `CREDENTIALS_INVALID` with `reason: 'throttled'` and
69
+ * `retryAfter`, the right `current` included, and a change that is written
70
+ * restarts the count; that restart runs after the write, so a `STORE_FAILED`
71
+ * from it leaves the password changed: check with `signIn` using `next`
72
+ * before retrying. Other sessions stay open: call
73
+ * `signOutEverywhere(user, { except })` for that.
68
74
  */
69
75
  changePassword(user: UserRef, change: {
70
76
  readonly current: string;
@@ -1 +1 @@
1
- {"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../../src/auth/types/password.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAgB,MAAM,WAAW,CAAC;AACvE,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,WAAW,WAAW,CAC3B,CAAC,EACD,EAAE,EACF,KAAK,SAAS,MAAM,EACpB,MAAM,GAAG,QAAQ,CAAC,CAAC,CAAC;IAEpB;;;;;;;;OAQG;IACH,MAAM,CACL,KAAK,EAAE,EAAE,GAAG;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EACzC,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;IAExB;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;IACH,MAAM,CACL,KAAK,EAAE;QAAE,QAAQ,EAAE,CAAC,IAAI,KAAK,GAAG,MAAM;KAAE,GAAG;QAAE,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,EACxE,OAAO,CAAC,EAAE,aAAa,GACrB,OAAO,CAAC,MAAM,CAAC,CAAC;IAEnB,mFAAmF;IACnF,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAE9C,8FAA8F;IAC9F,WAAW,CACV,IAAI,EAAE,OAAO,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,CAAC,CAAC,CAAC;IAEd;;;;OAIG;IACH,cAAc,CACb,IAAI,EAAE,OAAO,EACb,MAAM,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QA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M,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,EAC3D,OAAO,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,CAAC,CAAC,CAAC;CACd"}
@@ -5,6 +5,19 @@ import type { UserRef, WriteOptions } from '../types';
5
5
  /**
6
6
  * Replaces the password after checking the current one, in the write that
7
7
  * replaces it — so the check is made on the very record the write replaces.
8
+ *
9
+ * Each call counts one attempt in the sign-in throttle of the user's login,
10
+ * the one `signIn` counts in, so a caller holding a session cannot try
11
+ * current passwords without limit, and the wrong guesses of both add up. The
12
+ * attempt is counted on the record the write reads, before the password is
13
+ * compared (a user with no password included, so the answer does not tell
14
+ * the two apart); past the limit the call is refused with `retryAfter`, the
15
+ * right password included, and nothing is compared or written. The write
16
+ * runs its callback once, so a call counts exactly once. A user with no login
17
+ * string, or the throttle off, counts nothing. A change that is written
18
+ * restarts the count, as a sign-in that opens a session does — after
19
+ * {@link passwordChanged}, so an outage restarting it cannot skip what the
20
+ * old password opened.
8
21
  */
9
22
  export declare function changePassword(context: Context, type: ResolvedType, user: UserRef, change: {
10
23
  readonly current: string;
@@ -1 +1 @@
1
- {"version":3,"file":"change-password.d.ts","sourceRoot":"","sources":["../../../src/auth/users/change-password.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,KAAK,OAAO,EAMZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD;;;GAGG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC3D,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,CAAC,CAoCrB"}
1
+ {"version":3,"file":"change-password.d.ts","sourceRoot":"","sources":["../../../src/auth/users/change-password.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EACN,KAAK,OAAO,EAMZ,MAAM,YAAY,CAAC;AAEpB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAEtD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,cAAc,CACnC,OAAO,EAAE,OAAO,EAChB,IAAI,EAAE,YAAY,EAClB,IAAI,EAAE,OAAO,EACb,MAAM,EAAE;IAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAC3D,OAAO,EAAE,YAAY,GAAG,SAAS,EACjC,KAAK,EAAE,MAAM,GACX,OAAO,CAAC,UAAU,CAAC,CA0CrB"}