@noy-db/on-password 0.7.0 → 0.8.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/LICENSE CHANGED
@@ -1,21 +1,202 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 vLannaAi
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 vLannaAi
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1 @@
1
+ noy-db — Copyright 2026 vLannaAi
package/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # @noy-db/on-password
2
+
3
+ [![npm](https://img.shields.io/npm/v/%40noy-db/on-password.svg)](https://www.npmjs.com/package/@noy-db/on-password)
4
+
5
+ > Tier-2 password authenticator slot for noy-db
6
+
7
+ Part of [**`@noy-db/hub`**](https://www.npmjs.com/package/@noy-db/hub) — the zero-knowledge, offline-first, encrypted document store.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @noy-db/hub @noy-db/on-password
13
+ ```
14
+
15
+ ## What it is
16
+
17
+ A password is enrolled as its own keyring slot: PBKDF2-SHA256 at 600,000 iterations derives a wrapping key from the password, and that key wraps the vault's DEK set into the slot — so unlocking is a slot unwrap, never a re-derivation of the tier-1 phrase. It sits at tier 2 deliberately, beside the rarely-typed tier-1 secret rather than replacing it; pair it with [`@noy-db/on-email-otp`](https://www.npmjs.com/package/@noy-db/on-email-otp) or [`@noy-db/on-totp`](https://www.npmjs.com/package/@noy-db/on-totp) for the familiar SaaS second factor.
18
+
19
+ ## Status
20
+
21
+ **Pre-release.** API may change before `1.0`.
22
+
23
+ ## Documentation
24
+
25
+ See the [main repository](https://github.com/noy-db/on#readme) for setup and the full unlock-primitive catalog.
26
+
27
+ - Source — [`on-password`](https://github.com/noy-db/on/tree/main/on-password)
28
+ - Issues — [github.com/noy-db/on/issues](https://github.com/noy-db/on/issues)
29
+
30
+ ## License
31
+
32
+ [Apache-2.0](./LICENSE) © vLannaAi
package/dist/index.d.ts CHANGED
@@ -33,7 +33,7 @@ import { UnlockedKeyring, EnrollAuthenticatorOptions, SlotRewrapCeremony, Keyrin
33
33
  * `rotateSecret`) require a tier-1 unlock anyway — re-enter the
34
34
  * master phrase.
35
35
  *
36
- * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → Tier 2 — `on-password`
36
+ * @see https://github.com/noy-db/docs/blob/main/content/docs/services/session-tiers.md → Tier 2 — `on-password`
37
37
  *
38
38
  * @packageDocumentation
39
39
  */
@@ -104,6 +104,15 @@ declare function enrollPasswordAuthenticator(keyring: UnlockedKeyring, options:
104
104
  * @throws {@link PasswordInvalidError} when the password is wrong or
105
105
  * the slot is not a wrap-DEKs slot (e.g. a legacy wrap-KEK password
106
106
  * legacy wrap-KEK slots — those need re-enrollment).
107
+ *
108
+ * ⛔ **A slot blob is a BEARER CREDENTIAL.** This function needs no store,
109
+ * no keyring and no network — the blob authenticates itself under the
110
+ * password. **Removing the slot from the keyring does not invalidate a
111
+ * copy of the blob**, because removal rotates no DEKs. Anyone holding a
112
+ * captured blob and the password keeps the full live DEK set until the
113
+ * vault's keys are rotated. Treat slot removal as *hiding the slot from
114
+ * future lookups*, not as revocation, and rotate if a blob may have
115
+ * leaked. See noy-db/on#6.
107
116
  */
108
117
  declare function unwrapDeksWithPassword(slot: KeyringAuthenticator, password: string): Promise<Map<string, CryptoKey>>;
109
118
  /**
@@ -129,7 +138,7 @@ declare function unwrapDeksWithPassword(slot: KeyringAuthenticator, password: st
129
138
  * - **Cold-start** (`createNoydb({ getKeyring: ... })`) — consumer
130
139
  * does NOT have a keyring yet; the verifier loads identity from
131
140
  * disk before returning the unlocked keyring. This is the
132
- * primary cold-start tier-2 path (Niwat tier-2b uses this).
141
+ * primary cold-start tier-2 path (Pilot1 tier-2b uses this).
133
142
  *
134
143
  * Identity fields (userId, displayName, role, permissions,
135
144
  * authenticators, salt, capability bits, per-keyring policy) are read
@@ -137,8 +146,15 @@ declare function unwrapDeksWithPassword(slot: KeyringAuthenticator, password: st
137
146
  * those fields are not encrypted because the sync engine + grant flow
138
147
  * need them without a key.
139
148
  *
140
- * @throws {@link PasswordInvalidError} when the password is wrong or
141
- * the keyring file is missing.
149
+ * Refuses a slot that is no longer enrolled in the keyring it loads
150
+ * but see the revocation caveat on {@link unwrapDeksWithPassword}: that
151
+ * refusal is hardening, not revocation, and a holder of the raw blob
152
+ * bypasses it by calling the primitive directly. Rotation is the only
153
+ * thing that revokes.
154
+ *
155
+ * @throws {@link PasswordInvalidError} when the password is wrong, the
156
+ * keyring file is missing or carries no body, or the slot is not enrolled
157
+ * in it.
142
158
  */
143
159
  declare function verifyPasswordSlot(slot: KeyringAuthenticator, password: string, options: VerifyPasswordSlotOptions): Promise<UnlockedKeyring>;
144
160
  /** Adapter shape required by {@link verifyPasswordSlot}. */
@@ -175,10 +191,41 @@ interface VerifyPasswordSlotOptions {
175
191
  *
176
192
  * The password itself is unaffected by phrase rotation — what needs to
177
193
  * change is the **wrapped DEK set**: the encrypted blob the slot's
178
- * `wrapped_deks` field holds. After rotation, the old blob still has
179
- * the old DEKs (now stale because rotateSecret rewrapped them
180
- * under a fresh KEK); the new blob must hold the freshly rewrapped
181
- * `ctx.newDeks`.
194
+ * `wrapped_deks` field holds. After rotation the old blob is wrapped
195
+ * under the OLD KEK; the new blob must hold `ctx.newDeks`.
196
+ *
197
+ * ⚠️ **The old blob's DEK VALUES are not stale — only its wrapping is.**
198
+ * `rotateSecret` rewraps the SAME DEKs under a freshly-derived KEK;
199
+ * only `rotateKeys` re-mints DEK values. Records are encrypted with
200
+ * DEKs, so a captured blob keeps decrypting everything across any
201
+ * number of phrase rotations — see the bearer-credential warning on
202
+ * {@link unwrapDeksWithPassword} and #6. An earlier revision of this
203
+ * comment said "now stale because rotateSecret rewrapped them under a
204
+ * fresh KEK", which reads as though rotation invalidated the captured
205
+ * blob. It does not.
206
+ *
207
+ * ## Revoking a credential — this ceremony is a REQUIRED INPUT to it
208
+ *
209
+ * Hub's `revokeAuthenticator` is the real revocation, and it is three steps:
210
+ * `removeAuthenticator` (hides the slot), `rotateKeys` (mints fresh DEKs —
211
+ * the step that actually revokes), then `rotateSecret` with a
212
+ * `slotCeremonies` entry for every slot that STAYS.
213
+ *
214
+ * ⛔ **A remaining slot handed no ceremony is DROPPED, not preserved.** After
215
+ * the `rotateKeys` step its blob wraps DEKs that no longer exist, so keeping
216
+ * it would leave a credential that silently fails. Its holder must re-enrol.
217
+ *
218
+ * So revoking ONE credential means supplying `passwordSlotRewrapCeremony(password)` for
219
+ * EVERY password slot you intend to keep — and each requires that
220
+ * credential to be present (the password itself for a password slot, a live authenticator assertion for a WebAuthn slot). Re-wrapping a credential
221
+ * is the credential's own operation; there is no way to do it on the
222
+ * holder's behalf.
223
+ *
224
+ * ⚠️ **Not in any published hub at the time of writing.**
225
+ * `revokeAuthenticator` landed on noy-db `main` in `0612b4ac`, AFTER
226
+ * `@noy-db/hub@0.7.1-pre.0` was cut and published — so it is in neither
227
+ * `@latest` (0.7.0) nor `@next` (0.7.1-pre.0). Ask npm before promising it to
228
+ * a consumer; do not infer its version from hub's `main`.
182
229
  *
183
230
  * Single ceremony, one operation:
184
231
  * 1. Validate `oldSlot.method === 'password'` and `oldSlot.wrapKind === 'deks'`.
package/dist/index.js CHANGED
@@ -80,8 +80,19 @@ async function verifyPasswordSlot(slot, password, options) {
80
80
  `verifyPasswordSlot: no keyring found at "${options.vault}/_keyring/${options.userId}". Verify the vault and userId are correct.`
81
81
  );
82
82
  }
83
+ if (!env._data) {
84
+ throw new PasswordInvalidError(
85
+ `verifyPasswordSlot: the keyring at "${options.vault}/_keyring/${options.userId}" carries no body. The record exists but is empty \u2014 it was not written by a keyring writer.`
86
+ );
87
+ }
83
88
  const file = JSON.parse(env._data);
84
89
  const salt = new Uint8Array(base64ToBuffer(file.salt));
90
+ const stillEnrolled = (file.authenticators ?? []).some((a) => a.id === slot.id);
91
+ if (!stillEnrolled) {
92
+ throw new PasswordInvalidError(
93
+ `verifyPasswordSlot: slot "${slot.id}" is not enrolled in "${options.vault}/_keyring/${options.userId}". It may have been removed.`
94
+ );
95
+ }
85
96
  await assertRosterAuthenticated(file, deks, options.userId);
86
97
  return {
87
98
  userId: file.user_id,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * **@noy-db/on-password** — tier-2 password authenticator slot.\n *\n * The user's tier-1 *phrase* is the rarely-typed master that derives\n * the KEK. This package adds a SEPARATE secret — a password the user\n * types at each unlock — as a tier-2 slot in the multi-slot keyring.\n * The two credentials have:\n *\n * - **Different lifecycles** — the phrase rotates yearly; the password\n * rotates per the developer's policy.\n * - **Different strength rules** — the phrase is validated against the\n * phrase format; the password is validated against a\n * length / regex rule the developer chooses.\n * - **Different storage** — the phrase derives the KEK; the password\n * derives a wrapping key that wraps the SAME DEK SET in its own\n * keyring slot (LUKS-like multi-slot, wrap-DEKs variant).\n *\n * ## Wrap-DEKs format (Path C)\n *\n * Slots produced by this package use the wrap-DEKs variant of\n * `KeyringAuthenticator` — they encrypt the serialized DEK set under\n * a password-derived AES-GCM key, NOT the KEK. This unifies tier-2\n * password slots with the tier-0 (paper recovery, `mintPaperRecoveryEntry`)\n * and tier-3 (`@noy-db/on-pin`'s `wrappedKeyring`) primitives — all\n * three sidestep the non-extractable-KEK constraint by wrapping the\n * DEK set rather than the KEK itself.\n *\n * Trade-off: an `UnlockedKeyring` produced via password-slot unlock\n * has `kek: null`. Sensitive operations (`enrollAuthenticator`,\n * `rotateSecret`) require a tier-1 unlock anyway — re-enter the\n * master phrase.\n *\n * @see https://github.com/vLannaAi/noy-db-docs/blob/main/content/docs/services/session-tiers.md → Tier 2 — `on-password`\n *\n * @packageDocumentation\n */\nimport { assertRosterAuthenticated, base64ToBuffer, mintWrappedDeksBlob, unwrapDeksFromBlob, ValidationError, type KeyringFile, type NoydbStore } from '@noy-db/hub'\nimport type { EnrollAuthenticatorOptions, KeyringAuthenticator, SlotRewrapCeremony, SlotRewrapContext, UnlockedKeyring } from '@noy-db/hub/on'\n\n/**\n * PBKDF2 iteration count — matches the tier-1 phrase derivation.\n * Exported as a documented invariant; the actual derivation lives\n * in hub's canonical wrap-DEKs primitive.\n */\nexport const PASSWORD_PBKDF2_ITERATIONS = 600_000\n\n/** Default minimum password length. Override per-app via `enrollPasswordAuthenticator`. */\nexport const PASSWORD_DEFAULT_MIN_LENGTH = 12\n\n// ─── Errors ────────────────────────────────────────────────────────────\n\nexport class PasswordTooWeakError extends Error {\n readonly code = 'PASSWORD_TOO_WEAK' as const\n readonly minLength: number\n constructor(minLength: number, message?: string) {\n super(\n message ??\n `Password must be at least ${String(minLength)} characters. ` +\n 'For accounts with a separate tier-1 phrase, prefer a longer password ' +\n 'or pair with TOTP/email-OTP via @noy-db/on-totp or @noy-db/on-email-otp.',\n )\n this.name = 'PasswordTooWeakError'\n this.minLength = minLength\n }\n}\n\nexport class PasswordInvalidError extends Error {\n readonly code = 'PASSWORD_INVALID' as const\n constructor(message = 'Password does not unlock this slot.') {\n super(message)\n this.name = 'PasswordInvalidError'\n }\n}\n\n// ─── Public API ────────────────────────────────────────────────────────\n\n/** Options for {@link enrollPasswordAuthenticator}. */\nexport interface EnrollPasswordOptions {\n /** Slot id. Default: `'password'`. */\n readonly id?: string\n /** Password the user will type at unlock. Distinct from the tier-1 phrase. */\n readonly password: string\n /** Minimum length. Default 12. */\n readonly minLength?: number\n /** Optional regex the password must satisfy in addition to length. */\n readonly pattern?: RegExp\n /** Tier the active session held when enrolling. Default 1. */\n readonly enrolledViaTier?: 1 | 2\n}\n\n/**\n * Build the keyring slot for a tier-2 password authenticator. Returns\n * an `EnrollAuthenticatorOptions` value the caller hands to\n * `db.team.enrollAuthenticator(vault, slot)` — separating the cryptographic\n * step (this function) from the persistence step (the hub) keeps the\n * package small and lets the hub's policy gate run between the two.\n *\n * The slot uses the **wrap-DEKs** variant of `KeyringAuthenticator`:\n * the DEK set is serialized to JSON and encrypted with AES-GCM under\n * a PBKDF2-derived key. No requirement on `keyring.kek` — works with\n * tier-1 unlocked keyrings; throws if `keyring.deks` is empty.\n *\n * Usage:\n *\n * ```ts\n * import { enrollPasswordAuthenticator } from '@noy-db/on-password'\n *\n * const keyring = await db.team.getKeyring('acme')\n * const slot = await enrollPasswordAuthenticator(keyring, {\n * password: 'strong-password-2026',\n * minLength: 14,\n * })\n * await db.team.enrollAuthenticator('acme', slot, {\n * factors: [{ kind: 'totp' }],\n * })\n * ```\n */\nexport async function enrollPasswordAuthenticator(\n keyring: UnlockedKeyring,\n options: EnrollPasswordOptions,\n): Promise<EnrollAuthenticatorOptions> {\n const minLength = options.minLength ?? PASSWORD_DEFAULT_MIN_LENGTH\n if (options.password.length < minLength) {\n throw new PasswordTooWeakError(minLength)\n }\n if (options.pattern && !options.pattern.test(options.password)) {\n throw new PasswordTooWeakError(\n minLength,\n `Password does not match the configured pattern: ${options.pattern.toString()}.`,\n )\n }\n\n if (keyring.deks.size === 0) {\n throw new Error(\n 'enrollPasswordAuthenticator: the supplied keyring has no DEKs in memory. ' +\n 'Re-authenticate at tier 1 first.',\n )\n }\n\n // Delegate the wrap-DEKs crypto to the canonical hub primitive.\n // The slot envelope still stores `salt` inside `meta` for backward\n // compatibility with the legacy slot format; moving it to top-level\n // for parity with PaperRecoveryEntry is deferred.\n const blob = await mintWrappedDeksBlob(keyring.deks, options.password)\n\n return {\n id: options.id ?? 'password',\n method: 'password',\n wrapKind: 'deks',\n wrapped_deks: blob.wrappedDeks,\n iv: blob.iv,\n meta: {\n salt: blob.salt,\n minLength,\n ...(options.pattern !== undefined ? { pattern: options.pattern.source } : {}),\n },\n enrolled_via_tier: options.enrolledViaTier ?? 1,\n }\n}\n\n/**\n * Recover the DEK set from a wrap-DEKs password slot. Returns the raw\n * DEK map; the hub-friendly verifier {@link verifyPasswordSlot} wraps\n * this and produces a full `UnlockedKeyring`.\n *\n * @throws {@link PasswordInvalidError} when the password is wrong or\n * the slot is not a wrap-DEKs slot (e.g. a legacy wrap-KEK password\n * legacy wrap-KEK slots — those need re-enrollment).\n */\nexport async function unwrapDeksWithPassword(\n slot: KeyringAuthenticator,\n password: string,\n): Promise<Map<string, CryptoKey>> {\n if (slot.wrapKind !== 'deks') {\n throw new PasswordInvalidError(\n 'Password slot is not a wrap-DEKs slot. Pre-pre.8 wrap-KEK password ' +\n 'slots are no longer supported — re-enrol via enrollPasswordAuthenticator.',\n )\n }\n\n const meta = slot.meta as { salt?: unknown }\n if (typeof meta.salt !== 'string') {\n throw new PasswordInvalidError(\n 'Password slot is missing the per-slot salt — keyring may be corrupted.',\n )\n }\n\n // Delegate to the canonical wrap-DEKs primitive. The blob's\n // three fields (salt / iv / wrappedDeks) are reconstructed from\n // the slot's split layout: salt lives in meta, iv + wrappedDeks\n // at top level. Previously, this code re-implemented the same crypto\n // inline.\n try {\n return await unwrapDeksFromBlob(\n { salt: meta.salt, iv: slot.iv, wrappedDeks: slot.wrapped_deks },\n password,\n )\n } catch {\n throw new PasswordInvalidError()\n }\n}\n\n/**\n * Hub-friendly verify callback. Pass to `db.unlockViaAuthenticator`:\n *\n * ```ts\n * import { verifyPasswordSlot } from '@noy-db/on-password'\n *\n * const unlocked = await db.team.unlockViaAuthenticator('acme', 'password',\n * (slot) => verifyPasswordSlot(slot, 'strong-password-2026',\n * { store, vault: 'acme', userId: 'alice' }),\n * )\n * ```\n *\n * Unwraps the DEK set with the supplied password and returns an\n * `UnlockedKeyring` the hub installs in its keyring cache. The\n * returned keyring has `kek: null` — sensitive operations (enrol new\n * slot, rotate phrase) require a tier-1 unlock from the master phrase.\n *\n * The `{ store, vault, userId }` shape works in both contexts:\n * - **Warm re-unlock** — db is alive; consumer already has identity\n * in memory but pays one cheap `_keyring/<userId>` read.\n * - **Cold-start** (`createNoydb({ getKeyring: ... })`) — consumer\n * does NOT have a keyring yet; the verifier loads identity from\n * disk before returning the unlocked keyring. This is the\n * primary cold-start tier-2 path (Niwat tier-2b uses this).\n *\n * Identity fields (userId, displayName, role, permissions,\n * authenticators, salt, capability bits, per-keyring policy) are read\n * directly from the `_keyring/<userId>` envelope's plaintext header —\n * those fields are not encrypted because the sync engine + grant flow\n * need them without a key.\n *\n * @throws {@link PasswordInvalidError} when the password is wrong or\n * the keyring file is missing.\n */\nexport async function verifyPasswordSlot(\n slot: KeyringAuthenticator,\n password: string,\n options: VerifyPasswordSlotOptions,\n): Promise<UnlockedKeyring> {\n const deks = await unwrapDeksWithPassword(slot, password)\n\n const env = await options.store.get(options.vault, '_keyring', options.userId)\n if (!env) {\n throw new PasswordInvalidError(\n `verifyPasswordSlot: no keyring found at \"${options.vault}/_keyring/${options.userId}\". ` +\n 'Verify the vault and userId are correct.',\n )\n }\n const file = JSON.parse(env._data) as KeyringFile\n const salt = new Uint8Array(base64ToBuffer(file.salt))\n\n // #1096 — the identity fields below are read from the PLAINTEXT header, so\n // without this the store could promote a viewer to admin by editing one word\n // and have it refused at tier-1 open but accepted here. A vault is only as\n // strong as its weakest unlock path.\n //\n // Verifiable at tier 2 because `deks` above already carries the vault roster\n // key — it rides the slot's wrapped-DEK blob like any other DEK, and that\n // blob is authenticated by its own AES-GCM tag under the password. The\n // canary is deliberately NOT checked: it proves the KEK, and this path has\n // no KEK by design.\n await assertRosterAuthenticated(file, deks, options.userId)\n\n return {\n userId: file.user_id,\n displayName: file.display_name,\n role: file.role,\n permissions: file.permissions,\n authenticators: file.authenticators ?? [],\n salt,\n ...(file.export_capability !== undefined && { exportCapability: file.export_capability }),\n ...(file.import_capability !== undefined && { importCapability: file.import_capability }),\n ...(file.policy !== undefined && { policy: file.policy }),\n deks,\n // Wrap-DEKs unlock cannot recover the KEK. Sensitive ops route\n // through tier-1 via re-entry of the master phrase. Matches the\n // existing tier-3 (`@noy-db/on-pin`) pattern.\n kek: null,\n }\n}\n\n/** Adapter shape required by {@link verifyPasswordSlot}. */\nexport interface VerifyPasswordSlotOptions {\n /** The vault's NoydbStore — used to load `_keyring/<userId>`. */\n readonly store: NoydbStore\n /** Vault name — same value passed to `db.openVault(name)`. */\n readonly vault: string\n /** User id — same value passed to `createNoydb({ user })`. */\n readonly userId: string\n}\n\n/**\n * `SlotRewrapCeremony` factory for password slots — the password parallel\n * to `webAuthnSlotRewrapCeremony`. Used by hub's\n * `rotateSecret({ slotCeremonies: { [slotId]: passwordSlotRewrapCeremony(pwd) } })`\n * to preserve a tier-2 password enrollment across a tier-1 phrase\n * rotation without forcing the user to re-enroll the password.\n *\n * Returns a closure capturing the password so the result matches\n * hub's `SlotRewrapCeremony` signature `(ctx) => Promise<EnrollAuthenticatorOptions>`\n * directly. Pass into `slotCeremonies` keyed by the existing slot id:\n *\n * ```ts\n * import { passwordSlotRewrapCeremony } from '@noy-db/on-password'\n *\n * await db.team.rotateSecret('acme', {\n * oldSecret: oldPhrase,\n * newSecret: newPhrase,\n * slotCeremonies: {\n * 'password': passwordSlotRewrapCeremony('strong-password-2026'),\n * },\n * })\n * ```\n *\n * The password itself is unaffected by phrase rotation — what needs to\n * change is the **wrapped DEK set**: the encrypted blob the slot's\n * `wrapped_deks` field holds. After rotation, the old blob still has\n * the old DEKs (now stale because rotateSecret rewrapped them\n * under a fresh KEK); the new blob must hold the freshly rewrapped\n * `ctx.newDeks`.\n *\n * Single ceremony, one operation:\n * 1. Validate `oldSlot.method === 'password'` and `oldSlot.wrapKind === 'deks'`.\n * 2. Re-mint the wrap-DEKs blob via {@link enrollPasswordAuthenticator}\n * using the supplied password against `ctx.newDeks`.\n * 3. Return `EnrollAuthenticatorOptions` preserving `oldSlot.id`,\n * `method: 'password'`, and the strength config (`minLength`,\n * `pattern`) carried in the old slot's `meta`. Hub validates\n * `id` + `method` + `wrapKind` to prevent slot-type swap mid-\n * rotation.\n *\n * Legacy wrap-KEK password slots cannot be rewrapped via\n * this ceremony — they must be re-enrolled fresh via\n * {@link enrollPasswordAuthenticator}. The validation throws\n * {@link ValidationError} for those.\n *\n * @throws {ValidationError} when `oldSlot.method !== 'password'` or\n * `oldSlot.wrapKind !== 'deks'`.\n * @throws {PasswordTooWeakError} when the supplied password fails the\n * strength rules carried in `oldSlot.meta` (minLength, pattern).\n *\n * @see webAuthnSlotRewrapCeremony — the WebAuthn parallel.\n */\nexport function passwordSlotRewrapCeremony(password: string): SlotRewrapCeremony {\n return async (ctx: SlotRewrapContext): Promise<EnrollAuthenticatorOptions> => {\n if (ctx.oldSlot.method !== 'password') {\n throw new ValidationError(\n `passwordSlotRewrapCeremony: oldSlot.method is \"${ctx.oldSlot.method}\"; expected \"password\". ` +\n 'This ceremony only handles password slots — pair other methods with their own helpers.',\n )\n }\n if (ctx.oldSlot.wrapKind !== 'deks') {\n throw new ValidationError(\n 'passwordSlotRewrapCeremony: oldSlot is a wrap-KEK slot; expected wrap-DEKs. ' +\n 'Password slots use the wrap-DEKs variant since #26 Path C; legacy wrap-KEK ' +\n 'password slots are not supported here — re-enrol via enrollPasswordAuthenticator.',\n )\n }\n\n // Preserve the strength config the slot was originally enrolled with —\n // a rotation should not silently downgrade minLength or drop a pattern.\n const oldMeta = ctx.oldSlot.meta as { minLength?: unknown; pattern?: unknown }\n const minLength = typeof oldMeta.minLength === 'number' ? oldMeta.minLength : undefined\n const pattern = typeof oldMeta.pattern === 'string' ? new RegExp(oldMeta.pattern) : undefined\n\n return enrollPasswordAuthenticator(\n // enrollPasswordAuthenticator only reads `keyring.deks`, so a\n // synthetic minimal keyring is enough. The freshly-rewrapped DEKs\n // come from hub via `ctx.newDeks`.\n { deks: ctx.newDeks } as UnlockedKeyring,\n {\n id: ctx.oldSlot.id,\n password,\n ...(minLength !== undefined && { minLength }),\n ...(pattern !== undefined && { pattern }),\n // Carry the original tier so hub's anti-slot-swap guard plus\n // the rotate-recover preservation rule keep the slot's\n // provenance honest.\n enrolledViaTier: ctx.oldSlot.enrolled_via_tier,\n },\n )\n }\n}\n\n// All wrap-DEKs crypto helpers (PBKDF2 derivation, base64\n// codecs) live in hub's `team/wrapped-deks.ts` — both this\n// package and `mintPaperRecoveryEntry` share one implementation.\n"],"mappings":";AAoCA,SAAS,2BAA2B,gBAAgB,qBAAqB,oBAAoB,uBAA0D;AAQhJ,IAAM,6BAA6B;AAGnC,IAAM,8BAA8B;AAIpC,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC,OAAO;AAAA,EACP;AAAA,EACT,YAAY,WAAmB,SAAkB;AAC/C;AAAA,MACE,WACE,6BAA6B,OAAO,SAAS,CAAC;AAAA,IAGlD;AACA,SAAK,OAAO;AACZ,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC,OAAO;AAAA,EAChB,YAAY,UAAU,uCAAuC;AAC3D,UAAM,OAAO;AACb,SAAK,OAAO;AAAA,EACd;AACF;AA6CA,eAAsB,4BACpB,SACA,SACqC;AACrC,QAAM,YAAY,QAAQ,aAAa;AACvC,MAAI,QAAQ,SAAS,SAAS,WAAW;AACvC,UAAM,IAAI,qBAAqB,SAAS;AAAA,EAC1C;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Ac,UAAa,EAAE,UAAU;AAAA,QAC3C,GAAI,YAAY,UAAa,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA,QAIvC,iBAAiB,IAAI,QAAQ;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * **@noy-db/on-password** — tier-2 password authenticator slot.\n *\n * The user's tier-1 *phrase* is the rarely-typed master that derives\n * the KEK. This package adds a SEPARATE secret — a password the user\n * types at each unlock — as a tier-2 slot in the multi-slot keyring.\n * The two credentials have:\n *\n * - **Different lifecycles** — the phrase rotates yearly; the password\n * rotates per the developer's policy.\n * - **Different strength rules** — the phrase is validated against the\n * phrase format; the password is validated against a\n * length / regex rule the developer chooses.\n * - **Different storage** — the phrase derives the KEK; the password\n * derives a wrapping key that wraps the SAME DEK SET in its own\n * keyring slot (LUKS-like multi-slot, wrap-DEKs variant).\n *\n * ## Wrap-DEKs format (Path C)\n *\n * Slots produced by this package use the wrap-DEKs variant of\n * `KeyringAuthenticator` — they encrypt the serialized DEK set under\n * a password-derived AES-GCM key, NOT the KEK. This unifies tier-2\n * password slots with the tier-0 (paper recovery, `mintPaperRecoveryEntry`)\n * and tier-3 (`@noy-db/on-pin`'s `wrappedKeyring`) primitives — all\n * three sidestep the non-extractable-KEK constraint by wrapping the\n * DEK set rather than the KEK itself.\n *\n * Trade-off: an `UnlockedKeyring` produced via password-slot unlock\n * has `kek: null`. Sensitive operations (`enrollAuthenticator`,\n * `rotateSecret`) require a tier-1 unlock anyway — re-enter the\n * master phrase.\n *\n * @see https://github.com/noy-db/docs/blob/main/content/docs/services/session-tiers.md → Tier 2 — `on-password`\n *\n * @packageDocumentation\n */\nimport { assertRosterAuthenticated, base64ToBuffer, mintWrappedDeksBlob, unwrapDeksFromBlob, ValidationError, type KeyringFile, type NoydbStore } from '@noy-db/hub'\nimport type { EnrollAuthenticatorOptions, KeyringAuthenticator, SlotRewrapCeremony, SlotRewrapContext, UnlockedKeyring } from '@noy-db/hub/on'\n\n/**\n * PBKDF2 iteration count — matches the tier-1 phrase derivation.\n * Exported as a documented invariant; the actual derivation lives\n * in hub's canonical wrap-DEKs primitive.\n */\nexport const PASSWORD_PBKDF2_ITERATIONS = 600_000\n\n/** Default minimum password length. Override per-app via `enrollPasswordAuthenticator`. */\nexport const PASSWORD_DEFAULT_MIN_LENGTH = 12\n\n// ─── Errors ────────────────────────────────────────────────────────────\n\nexport class PasswordTooWeakError extends Error {\n readonly code = 'PASSWORD_TOO_WEAK' as const\n readonly minLength: number\n constructor(minLength: number, message?: string) {\n super(\n message ??\n `Password must be at least ${String(minLength)} characters. ` +\n 'For accounts with a separate tier-1 phrase, prefer a longer password ' +\n 'or pair with TOTP/email-OTP via @noy-db/on-totp or @noy-db/on-email-otp.',\n )\n this.name = 'PasswordTooWeakError'\n this.minLength = minLength\n }\n}\n\nexport class PasswordInvalidError extends Error {\n readonly code = 'PASSWORD_INVALID' as const\n constructor(message = 'Password does not unlock this slot.') {\n super(message)\n this.name = 'PasswordInvalidError'\n }\n}\n\n// ─── Public API ────────────────────────────────────────────────────────\n\n/** Options for {@link enrollPasswordAuthenticator}. */\nexport interface EnrollPasswordOptions {\n /** Slot id. Default: `'password'`. */\n readonly id?: string\n /** Password the user will type at unlock. Distinct from the tier-1 phrase. */\n readonly password: string\n /** Minimum length. Default 12. */\n readonly minLength?: number\n /** Optional regex the password must satisfy in addition to length. */\n readonly pattern?: RegExp\n /** Tier the active session held when enrolling. Default 1. */\n readonly enrolledViaTier?: 1 | 2\n}\n\n/**\n * Build the keyring slot for a tier-2 password authenticator. Returns\n * an `EnrollAuthenticatorOptions` value the caller hands to\n * `db.team.enrollAuthenticator(vault, slot)` — separating the cryptographic\n * step (this function) from the persistence step (the hub) keeps the\n * package small and lets the hub's policy gate run between the two.\n *\n * The slot uses the **wrap-DEKs** variant of `KeyringAuthenticator`:\n * the DEK set is serialized to JSON and encrypted with AES-GCM under\n * a PBKDF2-derived key. No requirement on `keyring.kek` — works with\n * tier-1 unlocked keyrings; throws if `keyring.deks` is empty.\n *\n * Usage:\n *\n * ```ts\n * import { enrollPasswordAuthenticator } from '@noy-db/on-password'\n *\n * const keyring = await db.team.getKeyring('acme')\n * const slot = await enrollPasswordAuthenticator(keyring, {\n * password: 'strong-password-2026',\n * minLength: 14,\n * })\n * await db.team.enrollAuthenticator('acme', slot, {\n * factors: [{ kind: 'totp' }],\n * })\n * ```\n */\nexport async function enrollPasswordAuthenticator(\n keyring: UnlockedKeyring,\n options: EnrollPasswordOptions,\n): Promise<EnrollAuthenticatorOptions> {\n const minLength = options.minLength ?? PASSWORD_DEFAULT_MIN_LENGTH\n if (options.password.length < minLength) {\n throw new PasswordTooWeakError(minLength)\n }\n if (options.pattern && !options.pattern.test(options.password)) {\n throw new PasswordTooWeakError(\n minLength,\n `Password does not match the configured pattern: ${options.pattern.toString()}.`,\n )\n }\n\n if (keyring.deks.size === 0) {\n throw new Error(\n 'enrollPasswordAuthenticator: the supplied keyring has no DEKs in memory. ' +\n 'Re-authenticate at tier 1 first.',\n )\n }\n\n // Delegate the wrap-DEKs crypto to the canonical hub primitive.\n // The slot envelope still stores `salt` inside `meta` for backward\n // compatibility with the legacy slot format; moving it to top-level\n // for parity with PaperRecoveryEntry is deferred.\n const blob = await mintWrappedDeksBlob(keyring.deks, options.password)\n\n return {\n id: options.id ?? 'password',\n method: 'password',\n wrapKind: 'deks',\n wrapped_deks: blob.wrappedDeks,\n iv: blob.iv,\n meta: {\n salt: blob.salt,\n minLength,\n ...(options.pattern !== undefined ? { pattern: options.pattern.source } : {}),\n },\n enrolled_via_tier: options.enrolledViaTier ?? 1,\n }\n}\n\n/**\n * Recover the DEK set from a wrap-DEKs password slot. Returns the raw\n * DEK map; the hub-friendly verifier {@link verifyPasswordSlot} wraps\n * this and produces a full `UnlockedKeyring`.\n *\n * @throws {@link PasswordInvalidError} when the password is wrong or\n * the slot is not a wrap-DEKs slot (e.g. a legacy wrap-KEK password\n * legacy wrap-KEK slots — those need re-enrollment).\n *\n * ⛔ **A slot blob is a BEARER CREDENTIAL.** This function needs no store,\n * no keyring and no network — the blob authenticates itself under the\n * password. **Removing the slot from the keyring does not invalidate a\n * copy of the blob**, because removal rotates no DEKs. Anyone holding a\n * captured blob and the password keeps the full live DEK set until the\n * vault's keys are rotated. Treat slot removal as *hiding the slot from\n * future lookups*, not as revocation, and rotate if a blob may have\n * leaked. See noy-db/on#6.\n */\nexport async function unwrapDeksWithPassword(\n slot: KeyringAuthenticator,\n password: string,\n): Promise<Map<string, CryptoKey>> {\n if (slot.wrapKind !== 'deks') {\n throw new PasswordInvalidError(\n 'Password slot is not a wrap-DEKs slot. Pre-pre.8 wrap-KEK password ' +\n 'slots are no longer supported — re-enrol via enrollPasswordAuthenticator.',\n )\n }\n\n const meta = slot.meta as { salt?: unknown }\n if (typeof meta.salt !== 'string') {\n throw new PasswordInvalidError(\n 'Password slot is missing the per-slot salt — keyring may be corrupted.',\n )\n }\n\n // Delegate to the canonical wrap-DEKs primitive. The blob's\n // three fields (salt / iv / wrappedDeks) are reconstructed from\n // the slot's split layout: salt lives in meta, iv + wrappedDeks\n // at top level. Previously, this code re-implemented the same crypto\n // inline.\n try {\n return await unwrapDeksFromBlob(\n { salt: meta.salt, iv: slot.iv, wrappedDeks: slot.wrapped_deks },\n password,\n )\n } catch {\n throw new PasswordInvalidError()\n }\n}\n\n/**\n * Hub-friendly verify callback. Pass to `db.unlockViaAuthenticator`:\n *\n * ```ts\n * import { verifyPasswordSlot } from '@noy-db/on-password'\n *\n * const unlocked = await db.team.unlockViaAuthenticator('acme', 'password',\n * (slot) => verifyPasswordSlot(slot, 'strong-password-2026',\n * { store, vault: 'acme', userId: 'alice' }),\n * )\n * ```\n *\n * Unwraps the DEK set with the supplied password and returns an\n * `UnlockedKeyring` the hub installs in its keyring cache. The\n * returned keyring has `kek: null` — sensitive operations (enrol new\n * slot, rotate phrase) require a tier-1 unlock from the master phrase.\n *\n * The `{ store, vault, userId }` shape works in both contexts:\n * - **Warm re-unlock** — db is alive; consumer already has identity\n * in memory but pays one cheap `_keyring/<userId>` read.\n * - **Cold-start** (`createNoydb({ getKeyring: ... })`) — consumer\n * does NOT have a keyring yet; the verifier loads identity from\n * disk before returning the unlocked keyring. This is the\n * primary cold-start tier-2 path (Pilot1 tier-2b uses this).\n *\n * Identity fields (userId, displayName, role, permissions,\n * authenticators, salt, capability bits, per-keyring policy) are read\n * directly from the `_keyring/<userId>` envelope's plaintext header —\n * those fields are not encrypted because the sync engine + grant flow\n * need them without a key.\n *\n * Refuses a slot that is no longer enrolled in the keyring it loads —\n * but see the revocation caveat on {@link unwrapDeksWithPassword}: that\n * refusal is hardening, not revocation, and a holder of the raw blob\n * bypasses it by calling the primitive directly. Rotation is the only\n * thing that revokes.\n *\n * @throws {@link PasswordInvalidError} when the password is wrong, the\n * keyring file is missing or carries no body, or the slot is not enrolled\n * in it.\n */\nexport async function verifyPasswordSlot(\n slot: KeyringAuthenticator,\n password: string,\n options: VerifyPasswordSlotOptions,\n): Promise<UnlockedKeyring> {\n const deks = await unwrapDeksWithPassword(slot, password)\n\n const env = await options.store.get(options.vault, '_keyring', options.userId)\n if (!env) {\n throw new PasswordInvalidError(\n `verifyPasswordSlot: no keyring found at \"${options.vault}/_keyring/${options.userId}\". ` +\n 'Verify the vault and userId are correct.',\n )\n }\n // ⚠️ `_data` is OPTIONAL since hub 0.8.0's capsule seam, and hub documents\n // absence and `''` as the SAME thing: no sealed body. A `_keyring` record\n // with no body is unreadable, so it fails the same way a missing one does —\n // kept a separate branch from `!env` only so the message names which it was.\n if (!env._data) {\n throw new PasswordInvalidError(\n `verifyPasswordSlot: the keyring at \"${options.vault}/_keyring/${options.userId}\" ` +\n 'carries no body. The record exists but is empty — it was not written by a keyring writer.',\n )\n }\n const file = JSON.parse(env._data) as KeyringFile\n const salt = new Uint8Array(base64ToBuffer(file.salt))\n\n // #6 — refuse a slot that is no longer in the keyring. Hub's own tier-2\n // dispatch reaches the verifier through `findAuthenticator`, so it never\n // presents a removed slot; this guards the DIRECT-primitive path, where a\n // caller hands us a blob it captured earlier.\n //\n // ⛔ THIS IS NOT REVOCATION, and must not be read as closing #6. Two\n // measured reasons, both of which survive this check:\n // 1. `unwrapDeksWithPassword` above is EXPORTED. A holder of the blob\n // calls it directly, gets the live DEK set, and never reaches this\n // line. The assertion is not on that path and cannot be.\n // 2. Removal rotates nothing, so every DEK the blob unwrapped stays\n // valid forever. Declining to hand back a keyring object does not\n // un-extract keys that are already in the caller's hands.\n // Real revocation is rotate-on-removal, which lives in hub\n // (`removeAuthenticator`), not here. Do not \"complete\" this by hardening\n // the message or widening the check — neither moves the guarantee.\n const stillEnrolled = (file.authenticators ?? []).some((a) => a.id === slot.id)\n if (!stillEnrolled) {\n throw new PasswordInvalidError(\n `verifyPasswordSlot: slot \"${slot.id}\" is not enrolled in ` +\n `\"${options.vault}/_keyring/${options.userId}\". It may have been removed.`,\n )\n }\n\n // #1096 — the identity fields below are read from the PLAINTEXT header, so\n // without this the store could promote a viewer to admin by editing one word\n // and have it refused at tier-1 open but accepted here. A vault is only as\n // strong as its weakest unlock path.\n //\n // Verifiable at tier 2 because `deks` above already carries the vault roster\n // key — it rides the slot's wrapped-DEK blob like any other DEK, and that\n // blob is authenticated by its own AES-GCM tag under the password. The\n // canary is deliberately NOT checked: it proves the KEK, and this path has\n // no KEK by design.\n await assertRosterAuthenticated(file, deks, options.userId)\n\n return {\n userId: file.user_id,\n displayName: file.display_name,\n role: file.role,\n permissions: file.permissions,\n authenticators: file.authenticators ?? [],\n salt,\n ...(file.export_capability !== undefined && { exportCapability: file.export_capability }),\n ...(file.import_capability !== undefined && { importCapability: file.import_capability }),\n ...(file.policy !== undefined && { policy: file.policy }),\n deks,\n // Wrap-DEKs unlock cannot recover the KEK. Sensitive ops route\n // through tier-1 via re-entry of the master phrase. Matches the\n // existing tier-3 (`@noy-db/on-pin`) pattern.\n kek: null,\n }\n}\n\n/** Adapter shape required by {@link verifyPasswordSlot}. */\nexport interface VerifyPasswordSlotOptions {\n /** The vault's NoydbStore — used to load `_keyring/<userId>`. */\n readonly store: NoydbStore\n /** Vault name — same value passed to `db.openVault(name)`. */\n readonly vault: string\n /** User id — same value passed to `createNoydb({ user })`. */\n readonly userId: string\n}\n\n/**\n * `SlotRewrapCeremony` factory for password slots — the password parallel\n * to `webAuthnSlotRewrapCeremony`. Used by hub's\n * `rotateSecret({ slotCeremonies: { [slotId]: passwordSlotRewrapCeremony(pwd) } })`\n * to preserve a tier-2 password enrollment across a tier-1 phrase\n * rotation without forcing the user to re-enroll the password.\n *\n * Returns a closure capturing the password so the result matches\n * hub's `SlotRewrapCeremony` signature `(ctx) => Promise<EnrollAuthenticatorOptions>`\n * directly. Pass into `slotCeremonies` keyed by the existing slot id:\n *\n * ```ts\n * import { passwordSlotRewrapCeremony } from '@noy-db/on-password'\n *\n * await db.team.rotateSecret('acme', {\n * oldSecret: oldPhrase,\n * newSecret: newPhrase,\n * slotCeremonies: {\n * 'password': passwordSlotRewrapCeremony('strong-password-2026'),\n * },\n * })\n * ```\n *\n * The password itself is unaffected by phrase rotation — what needs to\n * change is the **wrapped DEK set**: the encrypted blob the slot's\n * `wrapped_deks` field holds. After rotation the old blob is wrapped\n * under the OLD KEK; the new blob must hold `ctx.newDeks`.\n *\n * ⚠️ **The old blob's DEK VALUES are not stale — only its wrapping is.**\n * `rotateSecret` rewraps the SAME DEKs under a freshly-derived KEK;\n * only `rotateKeys` re-mints DEK values. Records are encrypted with\n * DEKs, so a captured blob keeps decrypting everything across any\n * number of phrase rotations — see the bearer-credential warning on\n * {@link unwrapDeksWithPassword} and #6. An earlier revision of this\n * comment said \"now stale because rotateSecret rewrapped them under a\n * fresh KEK\", which reads as though rotation invalidated the captured\n * blob. It does not.\n *\n * ## Revoking a credential — this ceremony is a REQUIRED INPUT to it\n *\n * Hub's `revokeAuthenticator` is the real revocation, and it is three steps:\n * `removeAuthenticator` (hides the slot), `rotateKeys` (mints fresh DEKs —\n * the step that actually revokes), then `rotateSecret` with a\n * `slotCeremonies` entry for every slot that STAYS.\n *\n * ⛔ **A remaining slot handed no ceremony is DROPPED, not preserved.** After\n * the `rotateKeys` step its blob wraps DEKs that no longer exist, so keeping\n * it would leave a credential that silently fails. Its holder must re-enrol.\n *\n * So revoking ONE credential means supplying `passwordSlotRewrapCeremony(password)` for\n * EVERY password slot you intend to keep — and each requires that\n * credential to be present (the password itself for a password slot, a live authenticator assertion for a WebAuthn slot). Re-wrapping a credential\n * is the credential's own operation; there is no way to do it on the\n * holder's behalf.\n *\n * ⚠️ **Not in any published hub at the time of writing.**\n * `revokeAuthenticator` landed on noy-db `main` in `0612b4ac`, AFTER\n * `@noy-db/hub@0.7.1-pre.0` was cut and published — so it is in neither\n * `@latest` (0.7.0) nor `@next` (0.7.1-pre.0). Ask npm before promising it to\n * a consumer; do not infer its version from hub's `main`.\n *\n * Single ceremony, one operation:\n * 1. Validate `oldSlot.method === 'password'` and `oldSlot.wrapKind === 'deks'`.\n * 2. Re-mint the wrap-DEKs blob via {@link enrollPasswordAuthenticator}\n * using the supplied password against `ctx.newDeks`.\n * 3. Return `EnrollAuthenticatorOptions` preserving `oldSlot.id`,\n * `method: 'password'`, and the strength config (`minLength`,\n * `pattern`) carried in the old slot's `meta`. Hub validates\n * `id` + `method` + `wrapKind` to prevent slot-type swap mid-\n * rotation.\n *\n * Legacy wrap-KEK password slots cannot be rewrapped via\n * this ceremony — they must be re-enrolled fresh via\n * {@link enrollPasswordAuthenticator}. The validation throws\n * {@link ValidationError} for those.\n *\n * @throws {ValidationError} when `oldSlot.method !== 'password'` or\n * `oldSlot.wrapKind !== 'deks'`.\n * @throws {PasswordTooWeakError} when the supplied password fails the\n * strength rules carried in `oldSlot.meta` (minLength, pattern).\n *\n * @see webAuthnSlotRewrapCeremony — the WebAuthn parallel.\n */\nexport function passwordSlotRewrapCeremony(password: string): SlotRewrapCeremony {\n return async (ctx: SlotRewrapContext): Promise<EnrollAuthenticatorOptions> => {\n if (ctx.oldSlot.method !== 'password') {\n throw new ValidationError(\n `passwordSlotRewrapCeremony: oldSlot.method is \"${ctx.oldSlot.method}\"; expected \"password\". ` +\n 'This ceremony only handles password slots — pair other methods with their own helpers.',\n )\n }\n if (ctx.oldSlot.wrapKind !== 'deks') {\n throw new ValidationError(\n 'passwordSlotRewrapCeremony: oldSlot is a wrap-KEK slot; expected wrap-DEKs. ' +\n 'Password slots use the wrap-DEKs variant since #26 Path C; legacy wrap-KEK ' +\n 'password slots are not supported here — re-enrol via enrollPasswordAuthenticator.',\n )\n }\n\n // Preserve the strength config the slot was originally enrolled with —\n // a rotation should not silently downgrade minLength or drop a pattern.\n const oldMeta = ctx.oldSlot.meta as { minLength?: unknown; pattern?: unknown }\n const minLength = typeof oldMeta.minLength === 'number' ? oldMeta.minLength : undefined\n const pattern = typeof oldMeta.pattern === 'string' ? new RegExp(oldMeta.pattern) : undefined\n\n return enrollPasswordAuthenticator(\n // enrollPasswordAuthenticator only reads `keyring.deks`, so a\n // synthetic minimal keyring is enough. The freshly-rewrapped DEKs\n // come from hub via `ctx.newDeks`.\n { deks: ctx.newDeks } as UnlockedKeyring,\n {\n id: ctx.oldSlot.id,\n password,\n ...(minLength !== undefined && { minLength }),\n ...(pattern !== undefined && { pattern }),\n // Carry the original tier so hub's anti-slot-swap guard plus\n // the rotate-recover preservation rule keep the slot's\n // provenance honest.\n enrolledViaTier: ctx.oldSlot.enrolled_via_tier,\n },\n )\n }\n}\n\n// All wrap-DEKs crypto helpers (PBKDF2 derivation, base64\n// codecs) live in hub's `team/wrapped-deks.ts` — both this\n// package and `mintPaperRecoveryEntry` share one implementation.\n"],"mappings":";AAoCA,SAAS,2BAA2B,gBAAgB,qBAAqB,oBAAoB,uBAA0D;AAQhJ,IAAM,6BAA6B;AAGnC,IAAM,8BAA8B;AAIpC,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC,OAAO;AAAA,EACP;AAAA,EACT,YAAY,WAAmB,SAAkB;AAC/C;AAAA,M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sB,UAAa,EAAE,kBAAkB,KAAK,kBAAkB;AAAA,IACvF,GAAI,KAAK,WAAW,UAAa,EAAE,QAAQ,KAAK,OAAO;AAAA,IACvD;AAAA;AAAA;AAAA;AAAA,IAIA,KAAK;AAAA,EACP;AACF;AA+FO,SAAS,2BAA2B,UAAsC;AAC/E,SAAO,OAAO,QAAgE;AAC5E,QAAI,IAAI,QAAQ,WAAW,YAAY;AACrC,YAAM,IAAI;AAAA,QACR,kDAAkD,IAAI,QAAQ,MAAM;AAAA,MAEtE;AAAA,IACF;AACA,QAAI,IAAI,QAAQ,aAAa,QAAQ;AACnC,YAAM,IAAI;AAAA,QACR;AAAA,MAGF;AAAA,IACF;AAIA,UAAM,UAAU,IAAI,QAAQ;AAC5B,UAAM,YAAY,OAAO,QAAQ,cAAc,WAAW,QAAQ,YAAY;AAC9E,UAAM,UAAU,OAAO,QAAQ,YAAY,WAAW,IAAI,OAAO,QAAQ,OAAO,IAAI;AAEpF,WAAO;AAAA;AAAA;AAAA;AAAA,MAIL,EAAE,MAAM,IAAI,QAAQ;AAAA,MACpB;AAAA,QACE,IAAI,IAAI,QAAQ;AAAA,QAChB;AAAA,QACA,GAAI,cAAc,UAAa,EAAE,UAAU;AAAA,QAC3C,GAAI,YAAY,UAAa,EAAE,QAAQ;AAAA;AAAA;AAAA;AAAA,QAIvC,iBAAiB,IAAI,QAAQ;AAAA,MAC/B;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
package/package.json CHANGED
@@ -1,17 +1,17 @@
1
1
  {
2
2
  "name": "@noy-db/on-password",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "Tier-2 password authenticator slot for noy-db. PBKDF2-SHA256 600K wraps the DEK set in its own keyring slot, distinct from the rarely-typed tier-1 phrase. Pair with @noy-db/on-email-otp or @noy-db/on-totp for the SaaS UX.",
5
- "license": "MIT",
5
+ "license": "Apache-2.0",
6
6
  "author": "vLannaAi <vicio@lanna.ai>",
7
- "homepage": "https://github.com/vLannaAi/noy-db/tree/main/packages/on-password#readme",
7
+ "homepage": "https://github.com/noy-db/on/tree/main/on-password#readme",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/vLannaAi/noy-db.git",
11
- "directory": "packages/on-password"
10
+ "url": "git+https://github.com/noy-db/on.git",
11
+ "directory": "on-password"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/vLannaAi/noy-db/issues"
14
+ "url": "https://github.com/noy-db/on/issues"
15
15
  },
16
16
  "type": "module",
17
17
  "sideEffects": false,
@@ -26,18 +26,19 @@
26
26
  "files": [
27
27
  "dist",
28
28
  "README.md",
29
- "LICENSE"
29
+ "LICENSE",
30
+ "NOTICE"
30
31
  ],
31
32
  "engines": {
32
33
  "node": ">=22.0.0"
33
34
  },
34
35
  "peerDependencies": {
35
- "@noy-db/hub": "^0.7.0"
36
+ "@noy-db/hub": "^0.7.0 || ^0.7.1-pre.0 || ^0.8.0-pre.0"
36
37
  },
37
38
  "devDependencies": {
38
- "happy-dom": "^18.0.0",
39
- "@noy-db/hub": "0.7.0",
40
- "@noy-db/test-ceremony-conformance": "0.7.0"
39
+ "@noy-db/hub": "0.8.0",
40
+ "@noy-db/test-ceremony-conformance": "0.8.0",
41
+ "happy-dom": "^18.0.0"
41
42
  },
42
43
  "keywords": [
43
44
  "noy-db",