@learncard/sss-key-manager 0.2.5 → 0.2.7

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/src/types.ts CHANGED
@@ -16,6 +16,7 @@ export {
16
16
  type AuthProvider,
17
17
  type RecoveryMethodInfo,
18
18
  type RecoveryResult,
19
+ type RevokeOtherDevicesResult,
19
20
  type IdentityRecoverySession,
20
21
  type ServerKeyStatus,
21
22
  type SssActivationState,
@@ -124,6 +125,29 @@ export class EscrowPinUnavailableError extends Error {
124
125
  }
125
126
  }
126
127
 
128
+ /**
129
+ * What this client saw during one PIN sign-in flow (own-typos rule, E). A flow starts
130
+ * with the first PIN status read before the first attempt and ends when the sign-in
131
+ * completes; a new modal or app start begins a new flow.
132
+ */
133
+ export interface EscrowPinAttemptContext {
134
+ /**
135
+ * Verified wrong entries recorded against the PIN when the flow started, before
136
+ * any attempt here. Undefined when the server could not say (legacy record, failed
137
+ * read): treated as "wrong entries recorded".
138
+ */
139
+ priorWrongAttempts?: number;
140
+ /** Wrong entries this client itself submitted in this flow (mismatch responses). */
141
+ ownWrongAttempts: number;
142
+ /**
143
+ * Salt of the PIN generation the counts belong to (from the flow's first status).
144
+ * A status read during the release that shows another salt (a new PIN, or a
145
+ * same-PIN re-set elsewhere) means the counts describe a different PIN, so they
146
+ * are ignored and the stricter #1905 rule applies.
147
+ */
148
+ pinSalt?: string;
149
+ }
150
+
127
151
  /** A failed PIN attempt consumes its hold; another attempt must start a fresh hold. */
128
152
  export class EscrowPinMismatchError extends Error {
129
153
  constructor(public readonly attemptsRemaining: number) {
@@ -156,6 +180,18 @@ export class EscrowPinLockedError extends Error {
156
180
  }
157
181
  }
158
182
 
183
+ /**
184
+ * A PIN sign-in released the key, but the released share version is no longer on the
185
+ * server (another device secured the account or recovered meanwhile). Nothing was
186
+ * stored; a revoke is never silently undone.
187
+ */
188
+ export class PinSignInStaleError extends Error {
189
+ constructor() {
190
+ super('Your account changed while signing in. Try again.');
191
+ this.name = 'PinSignInStaleError';
192
+ }
193
+ }
194
+
159
195
  export interface PasskeyRecoveryMethod {
160
196
  type: 'passkey';
161
197
  credentialId?: string;
@@ -180,7 +216,19 @@ export type RecoveryMethod =
180
216
  * SSS-specific recovery input — what the user provides to recover their key.
181
217
  */
182
218
  export type RecoveryInput =
183
- | { method: 'escrow-pin'; pin: string; expectedDid?: string }
219
+ | {
220
+ method: 'escrow-pin';
221
+ pin: string;
222
+ expectedDid?: string;
223
+ /** Verified recovery-email session; set only when no login is bound yet. */
224
+ recoverySessionToken?: string;
225
+ /**
226
+ * Own-typos rule (E): wrong entries this client observed in the current PIN
227
+ * sign-in flow. Omitted by older callers, which keeps the stricter rule (any
228
+ * recorded wrong entry blocks the same-PIN re-set).
229
+ */
230
+ pinAttempts?: EscrowPinAttemptContext;
231
+ }
184
232
  | {
185
233
  method: 'escrow';
186
234
  holdId: string;