@softistx/janus 0.73.1 → 0.74.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.
- package/README.md +1 -0
- package/dist/auth/port/memory/social-links.d.ts.map +1 -1
- package/dist/auth/port/types/social-links.d.ts +8 -0
- package/dist/auth/port/types/social-links.d.ts.map +1 -1
- package/dist/auth/shared-api.d.ts +3 -0
- package/dist/auth/shared-api.d.ts.map +1 -1
- package/dist/auth/social/index.d.ts.map +1 -1
- package/dist/auth/social/unlink.d.ts +7 -0
- package/dist/auth/social/unlink.d.ts.map +1 -1
- package/dist/auth/types/social.d.ts +8 -0
- package/dist/auth/types/social.d.ts.map +1 -1
- package/dist/chunks/{index-k6y18nx9.js → index-7h34nqrm.js} +10 -2
- package/dist/chunks/{index-k6y18nx9.js.map → index-7h34nqrm.js.map} +3 -3
- package/dist/conformance/cases/social-links/reads.d.ts.map +1 -1
- package/dist/conformance/index.js +33 -2
- package/dist/conformance/index.js.map +3 -3
- package/dist/index.js +17 -2
- package/dist/index.js.map +5 -5
- package/docs/guide/adapters.md +6 -3
- package/docs/guide/errors.md +1 -1
- package/docs/guide/social.md +9 -0
- package/docs/roadmap.md +1 -0
- package/docs/troubleshooting.md +13 -0
- package/package.json +1 -1
package/docs/guide/adapters.md
CHANGED
|
@@ -31,7 +31,7 @@ describeJanusStores({
|
|
|
31
31
|
|
|
32
32
|
| Port | Taken by | Methods |
|
|
33
33
|
| --- | --- | --- |
|
|
34
|
-
| `JanusStores` — `{ users: UserStore, sessions: SessionStore, tokens: TokenStore, socialLinks?: SocialLinkStore, passkeys?: PasskeyStore }` | `janus({ store })` | 6 (+ 1 optional) + 7 (+ 1 optional) + 5 (+ 1 optional) + 5 (the optional `socialLinks` slot) + 7 (the optional `passkeys` slot) |
|
|
34
|
+
| `JanusStores` — `{ users: UserStore, sessions: SessionStore, tokens: TokenStore, socialLinks?: SocialLinkStore, passkeys?: PasskeyStore }` | `janus({ store })` | 6 (+ 1 optional) + 7 (+ 1 optional) + 5 (+ 1 optional) + 5 (+ 1 optional) (the optional `socialLinks` slot) + 7 (the optional `passkeys` slot) |
|
|
35
35
|
| `RelationStore` | `permissions({ store })`, `janus({ relations })` | 6 (+ 1 optional) |
|
|
36
36
|
|
|
37
37
|
They are separate on purpose: an application that only authenticates
|
|
@@ -516,7 +516,10 @@ pair**: its own when it wrote, the holder's when the pair was already linked
|
|
|
516
516
|
(then nothing is written; the core reads `userId` to learn it lost). Never a
|
|
517
517
|
read followed by a write: twenty concurrent inserts leave one record.
|
|
518
518
|
`findSocialLink` answers the record or `null`; `listUserSocialLinks` a list,
|
|
519
|
-
`[]` for none; `
|
|
519
|
+
`[]` for none; the **optional** `countSocialLinks(provider)` answers how many
|
|
520
|
+
links go through one provider in the store's partition (`0` for none; what
|
|
521
|
+
`auth.social.countLinks` calls, and a store without it makes that call throw `UNSUPPORTED`);
|
|
522
|
+
`deleteSocialLink(userId, provider, accountId)` is conditional on
|
|
520
523
|
the owner and answers whether it deleted; `deleteUserSocialLinks` answers a
|
|
521
524
|
count, and is what deleting a user calls. The suite's `socialLinks` cases and
|
|
522
525
|
five outage cases run when the harness opens stores with the slot.
|
|
@@ -711,7 +714,7 @@ compile error naming the missing method.
|
|
|
711
714
|
|
|
712
715
|
| Suite | Cases | Harness opens |
|
|
713
716
|
| --- | --- | --- |
|
|
714
|
-
| `describeJanusStores({ name, harness, runner?, faults?, skip? })` |
|
|
717
|
+
| `describeJanusStores({ name, harness, runner?, faults?, skip? })` | 100: users, sessions, tokens, the optional `socialLinks` and `passkeys` slots, and one outage per method whose honest answer can be "nothing" — twenty-nine of them | `{ stores, faults?, close? }` |
|
|
715
718
|
| `describeRelationStores({ name, harness, runner?, faults?, skip? })` | 16: the relation store, ids of edge characters, and one outage per method | `{ store, faults?, close? }` |
|
|
716
719
|
| `describeApiKeyStores({ name, harness, runner?, faults?, skip? })` | the optional `ApiKeyStore`: insert, list, the conditional touch, revoke, delete, and one outage per method; the `bound`, `userBound` and `expiryNotice` cases are skipped, with their reason, for a store without that capability | `{ store, faults?, close? }` |
|
|
717
720
|
| `describeInvitationStores({ name, harness, runner?, faults?, skip? })` | the optional `InvitationStore`: insert and the pending constraint, find by id and by code hash, list, count, the conditional update, delete, and one outage per method | `{ store, faults?, close? }` |
|
package/docs/guide/errors.md
CHANGED
|
@@ -70,7 +70,7 @@ that wired the library, so no handler needs to tell it apart.
|
|
|
70
70
|
| `SECOND_FACTOR_ACTIVE` | `SecondFactorError` | 409 | `enroll` or `activate` on a factor already active: `disable` it first | `userId` |
|
|
71
71
|
| `INVALID_CURSOR` | `InvalidCursorError` | 400 | A cursor this store did not mint. Never a silent first page | |
|
|
72
72
|
| `CURSOR_FILTER_MISMATCH` | `CursorFilterMismatchError` | 400 | `invitations.list({ after })` with a `nextCursor` issued for another scope, status, role, ref, lapsed or order. Never a page of the other list | |
|
|
73
|
-
| `UNSUPPORTED` | `UnsupportedError` | 501 | The wired store lacks an optional capability — `collectExpired` with neither `deleteExpiredSessions` nor `deleteExpiredTokens`,
|
|
73
|
+
| `UNSUPPORTED` | `UnsupportedError` | 501 | The wired store lacks an optional capability — `collectExpired` with neither `deleteExpiredSessions` nor `deleteExpiredTokens`, `sessions.list` / `sessions.revoke` without `listUserSessions`, or `social.countLinks` without `countSocialLinks` | `slot`, `operation` |
|
|
74
74
|
| `PERMISSION_DEPTH` | `PermissionDepthError` | 500 | A check or list walked past `maxDepth`. **Not a denial** | `permission`, `maxDepth` |
|
|
75
75
|
| `API_KEY_LIMIT` | `ApiKeyLimitError` | 409 | `apiKeys.create` for a user who already holds `maxActive` standing keys (refused before anything is written); the key a race inserted is revoked again. Revoke one, then create — see [API keys](api-keys.md#creating-a-key) | `maxActive`, `userId` |
|
|
76
76
|
| `API_KEY_INVALID` | `ApiKeyInvalidError` | 400 | `apiKeys.create` with a name empty, over 100 characters once trimmed, or holding a NUL or a lone surrogate, or a lifetime not among `apiKeys.lifetimes`, or `scopes` that are not 1 to 32 scope tokens, or a `bound` that is not `{ type, id }`. Nothing was written | `field`: `'name'`, `'lifetime'`, `'scopes'` or `'bound'` |
|
package/docs/guide/social.md
CHANGED
|
@@ -438,8 +438,17 @@ export async function link(request: Request): Promise<Response> {
|
|
|
438
438
|
```ts
|
|
439
439
|
await auth.social.list(user); // readonly SocialLink[], oldest first; [] for nobody
|
|
440
440
|
await auth.social.unlink(user, { provider: 'github', accountId }); // true if this call deleted it, false for one not theirs or not there
|
|
441
|
+
await auth.social.countLinks({ provider: 'github' }); // how many accounts are linked through it; 0 for none
|
|
441
442
|
```
|
|
442
443
|
|
|
444
|
+
`countLinks` is what an admin screen calls before deleting a provider: refuse
|
|
445
|
+
while it answers more than `0`. It counts in the partition the instance's
|
|
446
|
+
store is bound to (`createMongoStores(db, { partition })`), so one tenant never
|
|
447
|
+
sees another's links. It needs a store that implements the optional
|
|
448
|
+
`countSocialLinks(provider)`: `createMemoryStores()`, `janus-mongo` and
|
|
449
|
+
`janus-drizzle` do; a store without it makes the call throw `UNSUPPORTED`
|
|
450
|
+
(`UnsupportedError`, `slot` and `operation` set).
|
|
451
|
+
|
|
443
452
|
`unlink` refuses with `LAST_SIGN_IN_METHOD` (409) when the link is the user's
|
|
444
453
|
only way to sign in. It counts **a password, the user's other links and, on a
|
|
445
454
|
type with no password, a verified e-mail** (the e-mail signs in by link or code).
|
package/docs/roadmap.md
CHANGED
|
@@ -84,6 +84,7 @@ Nothing yet.
|
|
|
84
84
|
The last ten, newest first, each with the version it came in. Everything
|
|
85
85
|
before is in the [CHANGELOG](../CHANGELOG.md).
|
|
86
86
|
|
|
87
|
+
- **Counting a provider's links** — `auth.social.countLinks({ provider })`, backed by the optional `SocialLinkStore.countSocialLinks(provider)` of the memory, MongoDB (per partition) and Drizzle stores, so an app can refuse deleting a provider users are still linked through. [#930](https://github.com/softistx/nxgt-janus/issues/930)
|
|
87
88
|
- **Public on npmjs** — every `@softistx/janus*` package is public on registry.npmjs.org and installs without a token or a scope mapping.
|
|
88
89
|
- **Sealing TOTP secrets again** — `secondFactor.reseal({ batch, after })` seals the secrets of users who do not sign in under the first key, in resumable, idempotent batches, so the old key can be retired. [#915](https://github.com/softistx/nxgt-janus/issues/915)
|
|
89
90
|
- **The methods a session proved** — 0.71.0. `session.amr`, the RFC 8176 methods of the sign-in extended by each step-up, with `authenticatedAt` as the time of the last proof, on `authenticate` and every `SignedIn`; `AMR` and `isMultiFactor` exported. The Mongo, Drizzle (a nullable `amr` column) and Redis stores keep it. [#889](https://github.com/softistx/nxgt-janus/issues/889)
|
package/docs/troubleshooting.md
CHANGED
|
@@ -211,6 +211,7 @@ How the messages are shaped:
|
|
|
211
211
|
- [`LAST_SIGN_IN_METHOD` — `social.unlink: this is the user's only way to sign in …`](#last_sign_in_method--socialunlink-this-is-the-users-only-way-to-sign-in--set-a-password-or-link-another-account-first)
|
|
212
212
|
- [`EMAIL_UNVERIFIED` — `social.complete: the provider does not vouch for an e-mail, so no account is created`](#email_unverified--socialcomplete-the-provider-does-not-vouch-for-an-e-mail-so-no-account-is-created)
|
|
213
213
|
- [`janus: the user type "<name>" configures social and store.socialLinks is missing …`](#janus-the-user-type-name-configures-social-and-storesociallinks-is-missing-)
|
|
214
|
+
- [`social.countLinks: store.socialLinks does not implement countSocialLinks …`](#socialcountlinks-storesociallinks-does-not-implement-countsociallinks-)
|
|
214
215
|
- [`janus: social.signUp needs a type whose login is its e-mail …`](#janus-socialsignup-needs-a-type-whose-login-is-its-e-mail-)
|
|
215
216
|
|
|
216
217
|
**Passkeys**
|
|
@@ -2781,6 +2782,18 @@ A `TypeError` at wiring: `<where>: the user type "<name>" configures social and
|
|
|
2781
2782
|
const store = { ...createMemoryStores(), ...adapterStores, socialLinks: adapterSocialLinks };
|
|
2782
2783
|
```
|
|
2783
2784
|
|
|
2785
|
+
### `social.countLinks: store.socialLinks does not implement countSocialLinks …`
|
|
2786
|
+
|
|
2787
|
+
An `UnsupportedError` (`UNSUPPORTED`, 501) when `auth.social.countLinks(...)` is called: `social.countLinks: store.socialLinks does not implement countSocialLinks — use a store that does, or implement the method`.
|
|
2788
|
+
|
|
2789
|
+
**When:** `countLinks` on a store whose `socialLinks` slot does not implement the optional `countSocialLinks(provider)`.
|
|
2790
|
+
**Why:** the method is optional on the port, so a store written before it compiles and signs in; only the count needs it.
|
|
2791
|
+
**Fix:** upgrade `@softistx/janus-mongo` or `@softistx/janus-drizzle`, use `createMemoryStores()`, or add the method to your store:
|
|
2792
|
+
|
|
2793
|
+
```ts
|
|
2794
|
+
const socialLinks = { ...mine, countSocialLinks: (provider) => countRows({ provider }) };
|
|
2795
|
+
```
|
|
2796
|
+
|
|
2784
2797
|
### `janus: social.signUp needs a type whose login is its e-mail …`
|
|
2785
2798
|
|
|
2786
2799
|
A `TypeError` at wiring, and a compile error: `<at>: social.signUp needs a type whose login is its e-mail — password.login is "<field>", not "<email field>"`.
|