@learncard/sss-key-manager 0.1.20 → 0.1.22

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 (39) hide show
  1. package/README.md +157 -16
  2. package/dist/api-client.d.ts +49 -0
  3. package/dist/api-client.d.ts.map +1 -0
  4. package/dist/atomic-operations.d.ts +101 -0
  5. package/dist/atomic-operations.d.ts.map +1 -0
  6. package/dist/auth-coordinator.d.ts +10 -0
  7. package/dist/auth-coordinator.d.ts.map +1 -0
  8. package/dist/crypto.d.ts +31 -0
  9. package/dist/crypto.d.ts.map +1 -0
  10. package/dist/index.d.ts +26 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/key-manager.d.ts +30 -0
  13. package/dist/key-manager.d.ts.map +1 -0
  14. package/dist/passkey.d.ts +23 -0
  15. package/dist/passkey.d.ts.map +1 -0
  16. package/dist/qr-crypto.d.ts +56 -0
  17. package/dist/qr-crypto.d.ts.map +1 -0
  18. package/dist/qr-login.d.ts +122 -0
  19. package/dist/qr-login.d.ts.map +1 -0
  20. package/dist/recovery-phrase.d.ts +14 -0
  21. package/dist/recovery-phrase.d.ts.map +1 -0
  22. package/dist/sss-key-manager.cjs.development.js +230 -6
  23. package/dist/sss-key-manager.cjs.development.js.map +2 -2
  24. package/dist/sss-key-manager.cjs.production.min.js +6 -6
  25. package/dist/sss-key-manager.cjs.production.min.js.map +3 -3
  26. package/dist/sss-key-manager.esm.js +230 -6
  27. package/dist/sss-key-manager.esm.js.map +2 -2
  28. package/dist/sss-strategy.d.ts +82 -0
  29. package/dist/sss-strategy.d.ts.map +1 -0
  30. package/dist/sss.d.ts +15 -0
  31. package/dist/sss.d.ts.map +1 -0
  32. package/dist/storage.d.ts +46 -0
  33. package/dist/storage.d.ts.map +1 -0
  34. package/dist/types.d.ts +155 -0
  35. package/dist/types.d.ts.map +1 -0
  36. package/package.json +5 -6
  37. package/src/crypto.ts +9 -14
  38. package/src/recovery-phrase.ts +7 -4
  39. package/dist/sss-key-manager.d.ts +0 -898
@@ -0,0 +1,122 @@
1
+ /**
2
+ * QR Login Client
3
+ *
4
+ * High-level orchestrator for cross-device login via QR code or short code.
5
+ * Coordinates between the relay API and the ECDH crypto layer.
6
+ *
7
+ * Two roles:
8
+ * - **Requester** (Device B, new device): creates session, renders QR, polls
9
+ * - **Approver** (Device A, logged-in device): reads QR/code, encrypts share, approves
10
+ */
11
+ import type { EphemeralKeypair } from './qr-crypto';
12
+ export interface QrLoginSession {
13
+ sessionId: string;
14
+ shortCode: string;
15
+ expiresInSeconds: number;
16
+ }
17
+ export interface QrLoginSessionInfo {
18
+ sessionId: string;
19
+ publicKey: string;
20
+ status: 'pending' | 'approved';
21
+ encryptedPayload?: string;
22
+ approverDid?: string;
23
+ }
24
+ export interface QrLoginClientConfig {
25
+ serverUrl: string;
26
+ }
27
+ export interface QrPayload {
28
+ /** Session ID for the relay */
29
+ sessionId: string;
30
+ /** Base64-encoded ephemeral X25519 public key */
31
+ publicKey: string;
32
+ /** Server URL for the relay */
33
+ serverUrl: string;
34
+ }
35
+ /** Result of polling — either still waiting or the device share is ready */
36
+ export type PollResult = {
37
+ status: 'pending';
38
+ } | {
39
+ status: 'approved';
40
+ deviceShare: string;
41
+ approverDid: string;
42
+ accountHint?: string;
43
+ shareVersion?: number;
44
+ };
45
+ /**
46
+ * Create a QR login session and generate the ephemeral keypair.
47
+ *
48
+ * Returns everything Device B needs to display a QR and start polling.
49
+ * The ephemeral private key is kept in memory — never serialized.
50
+ */
51
+ export declare const createQrLoginSession: (config: QrLoginClientConfig) => Promise<{
52
+ session: QrLoginSession;
53
+ ephemeralKeypair: EphemeralKeypair;
54
+ qrPayload: QrPayload;
55
+ }>;
56
+ /**
57
+ * Poll a QR login session for approval.
58
+ *
59
+ * When Device A approves, this returns the decrypted device share.
60
+ *
61
+ * @param config - Server config
62
+ * @param sessionId - The session to poll
63
+ * @param ephemeralPrivateKey - Device B's ephemeral private key (for decryption)
64
+ */
65
+ export declare const pollQrLoginSession: (config: QrLoginClientConfig, sessionId: string, ephemeralPrivateKey: CryptoKey) => Promise<PollResult>;
66
+ /**
67
+ * Convenience: poll in a loop until approved or timeout.
68
+ *
69
+ * @param config - Server config
70
+ * @param sessionId - The session to poll
71
+ * @param ephemeralPrivateKey - Device B's ephemeral private key
72
+ * @param intervalMs - Polling interval (default 2000ms)
73
+ * @param timeoutMs - Total timeout (default 120000ms)
74
+ * @param onPoll - Optional callback on each poll (for UI updates)
75
+ */
76
+ export declare const pollUntilApproved: (config: QrLoginClientConfig, sessionId: string, ephemeralPrivateKey: CryptoKey, options?: {
77
+ intervalMs?: number;
78
+ timeoutMs?: number;
79
+ onPoll?: (attempt: number) => void;
80
+ signal?: AbortSignal;
81
+ }) => Promise<{
82
+ deviceShare: string;
83
+ approverDid: string;
84
+ accountHint?: string;
85
+ shareVersion?: number;
86
+ }>;
87
+ /**
88
+ * Fetch a QR login session's public key (for Device A to encrypt against).
89
+ *
90
+ * @param config - Server config
91
+ * @param lookup - Session ID or 6-digit short code
92
+ */
93
+ export declare const getQrLoginSessionInfo: (config: QrLoginClientConfig, lookup: string) => Promise<QrLoginSessionInfo>;
94
+ /**
95
+ * Approve a QR login session by encrypting and pushing the device share.
96
+ *
97
+ * Called by Device A (the logged-in device).
98
+ *
99
+ * @param config - Server config
100
+ * @param sessionId - The session to approve
101
+ * @param deviceShare - Plaintext device share from Device A's local storage
102
+ * @param approverDid - DID of the approving device
103
+ * @param recipientPublicKey - Base64 X25519 public key from the session
104
+ * @param accountHint - Optional email or phone of the approver's account (sent to Device B as a login hint)
105
+ * @param shareVersion - Optional share version so Device B can fetch the matching auth share
106
+ */
107
+ export declare const approveQrLoginSession: (config: QrLoginClientConfig, sessionId: string, deviceShare: string, approverDid: string, recipientPublicKey: string, accountHint?: string, shareVersion?: number) => Promise<void>;
108
+ export interface NotifyDevicesResult {
109
+ sent: boolean;
110
+ deviceCount: number;
111
+ }
112
+ /**
113
+ * Send a push notification to the authenticated user's other devices,
114
+ * prompting them to open the approver flow for the given QR session.
115
+ *
116
+ * Called by Device B (in needs_recovery) after creating a session.
117
+ * Requires the user's Firebase (or other auth provider) token.
118
+ *
119
+ * This is fire-and-forget — failure does not block the QR login flow.
120
+ */
121
+ export declare const notifyDevicesForQrSession: (config: QrLoginClientConfig, sessionId: string, shortCode: string, authToken: string, providerType?: string) => Promise<NotifyDevicesResult>;
122
+ //# sourceMappingURL=qr-login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"qr-login.d.ts","sourceRoot":"","sources":["../src/qr-login.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAUH,OAAO,KAAK,EAAE,gBAAgB,EAAyB,MAAM,aAAa,CAAC;AAM3E,MAAM,WAAW,cAAc;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,gBAAgB,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,kBAAkB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,SAAS,GAAG,UAAU,CAAC;IAC/B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAChC,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,SAAS;IACtB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;IAElB,iDAAiD;IACjD,SAAS,EAAE,MAAM,CAAC;IAElB,+BAA+B;IAC/B,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,4EAA4E;AAC5E,MAAM,MAAM,UAAU,GAChB;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE,GACrB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAoBpH;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,GAC7B,QAAQ,mBAAmB,KAC5B,OAAO,CAAC;IACP,OAAO,EAAE,cAAc,CAAC;IACxB,gBAAgB,EAAE,gBAAgB,CAAC;IACnC,SAAS,EAAE,SAAS,CAAC;CACxB,CAsBA,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,kBAAkB,GAC3B,QAAQ,mBAAmB,EAC3B,WAAW,MAAM,EACjB,qBAAqB,SAAS,KAC/B,OAAO,CAAC,UAAU,CAkCpB,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,GAC1B,QAAQ,mBAAmB,EAC3B,WAAW,MAAM,EACjB,qBAAqB,SAAS,EAC9B,UAAU;IACN,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,MAAM,CAAC,EAAE,WAAW,CAAC;CACxB,KACF,OAAO,CAAC;IAAE,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,MAAM,CAAA;CAAE,CAwCnG,CAAC;AAMF;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,GAC9B,QAAQ,mBAAmB,EAC3B,QAAQ,MAAM,KACf,OAAO,CAAC,kBAAkB,CAW5B,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,qBAAqB,GAC9B,QAAQ,mBAAmB,EAC3B,WAAW,MAAM,EACjB,aAAa,MAAM,EACnB,aAAa,MAAM,EACnB,oBAAoB,MAAM,EAC1B,cAAc,MAAM,EACpB,eAAe,MAAM,KACtB,OAAO,CAAC,IAAI,CAoBd,CAAC;AAMF,MAAM,WAAW,mBAAmB;IAChC,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,eAAO,MAAM,yBAAyB,GAClC,QAAQ,mBAAmB,EAC3B,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,WAAW,MAAM,EACjB,eAAc,MAAmB,KAClC,OAAO,CAAC,mBAAmB,CAqB7B,CAAC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * BIP39 Recovery Phrase utilities for SSS recovery
3
+ * The recovery phrase directly encodes a share (not encryption)
4
+ */
5
+ export interface RecoveryPhraseData {
6
+ phrase: string;
7
+ shareHex: string;
8
+ }
9
+ export declare function shareToRecoveryPhrase(shareHex: string): Promise<string>;
10
+ export declare function recoveryPhraseToShare(phrase: string): Promise<string>;
11
+ export declare function generateRecoveryPhrase(shareHex: string): Promise<RecoveryPhraseData>;
12
+ export declare function validateRecoveryPhrase(phrase: string): Promise<boolean>;
13
+ export declare function countWords(phrase: string): number;
14
+ //# sourceMappingURL=recovery-phrase.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recovery-phrase.d.ts","sourceRoot":"","sources":["../src/recovery-phrase.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH,MAAM,WAAW,kBAAkB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CACpB;AAkCD,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAc7E;AAED,wBAAsB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoD3E;AAED,wBAAsB,sBAAsB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAG1F;AAED,wBAAsB,sBAAsB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAO7E;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAKjD"}
@@ -66,6 +66,8 @@ var require_types_cjs_development = __commonJS({
66
66
  AgeRatingValidator: /* @__PURE__ */ __name(() => AgeRatingValidator, "AgeRatingValidator"),
67
67
  AlignmentTargetTypeValidator: /* @__PURE__ */ __name(() => AlignmentTargetTypeValidator, "AlignmentTargetTypeValidator"),
68
68
  AlignmentValidator: /* @__PURE__ */ __name(() => AlignmentValidator, "AlignmentValidator"),
69
+ AllocateCredentialRefreshInputValidator: /* @__PURE__ */ __name(() => AllocateCredentialRefreshInputValidator, "AllocateCredentialRefreshInputValidator"),
70
+ AllocateCredentialRefreshResultValidator: /* @__PURE__ */ __name(() => AllocateCredentialRefreshResultValidator, "AllocateCredentialRefreshResultValidator"),
69
71
  AllocateCredentialStatusInputValidator: /* @__PURE__ */ __name(() => AllocateCredentialStatusInputValidator, "AllocateCredentialStatusInputValidator"),
70
72
  AllocatedBitstringStatusListEntryValidator: /* @__PURE__ */ __name(() => AllocatedBitstringStatusListEntryValidator, "AllocatedBitstringStatusListEntryValidator"),
71
73
  AllowConnectionRequestsEnum: /* @__PURE__ */ __name(() => AllowConnectionRequestsEnum, "AllowConnectionRequestsEnum"),
@@ -147,6 +149,16 @@ var require_types_cjs_development = __commonJS({
147
149
  CredentialInfoValidator: /* @__PURE__ */ __name(() => CredentialInfoValidator, "CredentialInfoValidator"),
148
150
  CredentialNameRefValidator: /* @__PURE__ */ __name(() => CredentialNameRefValidator, "CredentialNameRefValidator"),
149
151
  CredentialRecordValidator: /* @__PURE__ */ __name(() => CredentialRecordValidator, "CredentialRecordValidator"),
152
+ CredentialRefreshChallengeValidator: /* @__PURE__ */ __name(() => CredentialRefreshChallengeValidator, "CredentialRefreshChallengeValidator"),
153
+ CredentialRefreshFailedResultValidator: /* @__PURE__ */ __name(() => CredentialRefreshFailedResultValidator, "CredentialRefreshFailedResultValidator"),
154
+ CredentialRefreshFailureCodeValidator: /* @__PURE__ */ __name(() => CredentialRefreshFailureCodeValidator, "CredentialRefreshFailureCodeValidator"),
155
+ CredentialRefreshResponseEnvelopeValidator: /* @__PURE__ */ __name(() => CredentialRefreshResponseEnvelopeValidator, "CredentialRefreshResponseEnvelopeValidator"),
156
+ CredentialRefreshResultValidator: /* @__PURE__ */ __name(() => CredentialRefreshResultValidator, "CredentialRefreshResultValidator"),
157
+ CredentialRefreshSigningModeValidator: /* @__PURE__ */ __name(() => CredentialRefreshSigningModeValidator, "CredentialRefreshSigningModeValidator"),
158
+ CredentialRefreshUnchangedResultValidator: /* @__PURE__ */ __name(() => CredentialRefreshUnchangedResultValidator, "CredentialRefreshUnchangedResultValidator"),
159
+ CredentialRefreshUnsupportedResultValidator: /* @__PURE__ */ __name(() => CredentialRefreshUnsupportedResultValidator, "CredentialRefreshUnsupportedResultValidator"),
160
+ CredentialRefreshUpdatedResultValidator: /* @__PURE__ */ __name(() => CredentialRefreshUpdatedResultValidator, "CredentialRefreshUpdatedResultValidator"),
161
+ CredentialRefreshVersionMetadataValidator: /* @__PURE__ */ __name(() => CredentialRefreshVersionMetadataValidator, "CredentialRefreshVersionMetadataValidator"),
150
162
  CredentialSchemaValidator: /* @__PURE__ */ __name(() => CredentialSchemaValidator, "CredentialSchemaValidator"),
151
163
  CredentialStatusValidator: /* @__PURE__ */ __name(() => CredentialStatusValidator, "CredentialStatusValidator"),
152
164
  CredentialSubjectValidator: /* @__PURE__ */ __name(() => CredentialSubjectValidator, "CredentialSubjectValidator"),
@@ -167,6 +179,8 @@ var require_types_cjs_development = __commonJS({
167
179
  GeoCoordinatesValidator: /* @__PURE__ */ __name(() => GeoCoordinatesValidator, "GeoCoordinatesValidator"),
168
180
  GetCounterEventValidator: /* @__PURE__ */ __name(() => GetCounterEventValidator, "GetCounterEventValidator"),
169
181
  GetCountersEventValidator: /* @__PURE__ */ __name(() => GetCountersEventValidator, "GetCountersEventValidator"),
182
+ GetCredentialRefreshHistoryInputValidator: /* @__PURE__ */ __name(() => GetCredentialRefreshHistoryInputValidator, "GetCredentialRefreshHistoryInputValidator"),
183
+ GetCredentialRefreshHistoryResultValidator: /* @__PURE__ */ __name(() => GetCredentialRefreshHistoryResultValidator, "GetCredentialRefreshHistoryResultValidator"),
170
184
  GetFullSkillTreeInputValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeInputValidator, "GetFullSkillTreeInputValidator"),
171
185
  GetFullSkillTreeResultValidator: /* @__PURE__ */ __name(() => GetFullSkillTreeResultValidator, "GetFullSkillTreeResultValidator"),
172
186
  GetSkillPathInputValidator: /* @__PURE__ */ __name(() => GetSkillPathInputValidator, "GetSkillPathInputValidator"),
@@ -191,6 +205,7 @@ var require_types_cjs_development = __commonJS({
191
205
  JWEValidator: /* @__PURE__ */ __name(() => JWEValidator, "JWEValidator"),
192
206
  JWKValidator: /* @__PURE__ */ __name(() => JWKValidator, "JWKValidator"),
193
207
  JWKWithPrivateKeyValidator: /* @__PURE__ */ __name(() => JWKWithPrivateKeyValidator, "JWKWithPrivateKeyValidator"),
208
+ JweCredentialRefreshEnvelopeValidator: /* @__PURE__ */ __name(() => JweCredentialRefreshEnvelopeValidator, "JweCredentialRefreshEnvelopeValidator"),
194
209
  KnownAchievementTypeValidator: /* @__PURE__ */ __name(() => KnownAchievementTypeValidator, "KnownAchievementTypeValidator"),
195
210
  LCNAuthedProfileValidator: /* @__PURE__ */ __name(() => LCNAuthedProfileValidator, "LCNAuthedProfileValidator"),
196
211
  LCNBoostClaimLinkOptionsValidator: /* @__PURE__ */ __name(() => LCNBoostClaimLinkOptionsValidator, "LCNBoostClaimLinkOptionsValidator"),
@@ -228,7 +243,9 @@ var require_types_cjs_development = __commonJS({
228
243
  LCNSigningAuthorityValidator: /* @__PURE__ */ __name(() => LCNSigningAuthorityValidator, "LCNSigningAuthorityValidator"),
229
244
  LCNVisibleProfileValidator: /* @__PURE__ */ __name(() => LCNVisibleProfileValidator, "LCNVisibleProfileValidator"),
230
245
  LaunchTypeValidator: /* @__PURE__ */ __name(() => LaunchTypeValidator, "LaunchTypeValidator"),
246
+ LearnCardRefreshAuthorizationValidator: /* @__PURE__ */ __name(() => LearnCardRefreshAuthorizationValidator, "LearnCardRefreshAuthorizationValidator"),
231
247
  LinkProviderFrameworkInputValidator: /* @__PURE__ */ __name(() => LinkProviderFrameworkInputValidator, "LinkProviderFrameworkInputValidator"),
248
+ ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator, "ManagedCredentialRefreshServiceValidator"),
232
249
  PaginatedAppStoreListingsValidator: /* @__PURE__ */ __name(() => PaginatedAppStoreListingsValidator, "PaginatedAppStoreListingsValidator"),
233
250
  PaginatedBoostRecipientsValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsValidator, "PaginatedBoostRecipientsValidator"),
234
251
  PaginatedBoostRecipientsWithChildrenValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsWithChildrenValidator, "PaginatedBoostRecipientsWithChildrenValidator"),
@@ -258,6 +275,12 @@ var require_types_cjs_development = __commonJS({
258
275
  ProfileVisibilityEnum: /* @__PURE__ */ __name(() => ProfileVisibilityEnum, "ProfileVisibilityEnum"),
259
276
  PromotionLevelValidator: /* @__PURE__ */ __name(() => PromotionLevelValidator, "PromotionLevelValidator"),
260
277
  ProofValidator: /* @__PURE__ */ __name(() => ProofValidator, "ProofValidator"),
278
+ PublicCredentialRefreshEnvelopeValidator: /* @__PURE__ */ __name(() => PublicCredentialRefreshEnvelopeValidator, "PublicCredentialRefreshEnvelopeValidator"),
279
+ PublishCredentialRefreshInputValidator: /* @__PURE__ */ __name(() => PublishCredentialRefreshInputValidator, "PublishCredentialRefreshInputValidator"),
280
+ PublishCredentialRefreshNotificationValidator: /* @__PURE__ */ __name(() => PublishCredentialRefreshNotificationValidator, "PublishCredentialRefreshNotificationValidator"),
281
+ PublishCredentialRefreshResultValidator: /* @__PURE__ */ __name(() => PublishCredentialRefreshResultValidator, "PublishCredentialRefreshResultValidator"),
282
+ PublishIssuerSignedRefreshValidator: /* @__PURE__ */ __name(() => PublishIssuerSignedRefreshValidator, "PublishIssuerSignedRefreshValidator"),
283
+ PublishSigningAuthorityRefreshValidator: /* @__PURE__ */ __name(() => PublishSigningAuthorityRefreshValidator, "PublishSigningAuthorityRefreshValidator"),
261
284
  RefreshServiceValidator: /* @__PURE__ */ __name(() => RefreshServiceValidator, "RefreshServiceValidator"),
262
285
  RegExpValidator: /* @__PURE__ */ __name(() => RegExpValidator, "RegExpValidator"),
263
286
  RelatedValidator: /* @__PURE__ */ __name(() => RelatedValidator, "RelatedValidator"),
@@ -298,11 +321,13 @@ var require_types_cjs_development = __commonJS({
298
321
  SkillTreeNodeInputValidator: /* @__PURE__ */ __name(() => SkillTreeNodeInputValidator, "SkillTreeNodeInputValidator"),
299
322
  SkillTreeNodeValidator: /* @__PURE__ */ __name(() => SkillTreeNodeValidator, "SkillTreeNodeValidator"),
300
323
  SkillValidator: /* @__PURE__ */ __name(() => SkillValidator, "SkillValidator"),
324
+ StandardCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => StandardCredentialRefreshServiceValidator, "StandardCredentialRefreshServiceValidator"),
301
325
  StatusCheckEntryValidator: /* @__PURE__ */ __name(() => StatusCheckEntryValidator, "StatusCheckEntryValidator"),
302
326
  StoredCredentialEnvelopeValidator: /* @__PURE__ */ __name(() => StoredCredentialEnvelopeValidator, "StoredCredentialEnvelopeValidator"),
303
327
  StringQuery: /* @__PURE__ */ __name(() => StringQuery, "StringQuery"),
304
328
  SummaryCredentialDataValidator: /* @__PURE__ */ __name(() => SummaryCredentialDataValidator, "SummaryCredentialDataValidator"),
305
329
  SummaryCredentialKeywordValidator: /* @__PURE__ */ __name(() => SummaryCredentialKeywordValidator, "SummaryCredentialKeywordValidator"),
330
+ SupportedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => SupportedCredentialRefreshServiceValidator, "SupportedCredentialRefreshServiceValidator"),
306
331
  SyncFrameworkInputValidator: /* @__PURE__ */ __name(() => SyncFrameworkInputValidator, "SyncFrameworkInputValidator"),
307
332
  TagValidator: /* @__PURE__ */ __name(() => TagValidator, "TagValidator"),
308
333
  TemplateRenderMethodValidator: /* @__PURE__ */ __name(() => TemplateRenderMethodValidator, "TemplateRenderMethodValidator"),
@@ -16272,7 +16297,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16272
16297
  did: LCNProfileValidator.shape.did
16273
16298
  });
16274
16299
  var LCNConnectionProfileValidator = LCNAuthedProfileValidator.extend({
16275
- email: LCNProfileValidator.shape.email
16300
+ email: LCNProfileValidator.shape.email,
16301
+ connectedAt: external_exports.iso.datetime().optional().describe("When the viewer and this profile became connected.")
16276
16302
  });
16277
16303
  var LCNVisibleProfileValidator = external_exports.union([
16278
16304
  LCNConnectionProfileValidator.strict(),
@@ -16505,7 +16531,10 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16505
16531
  webhookUrl: external_exports.string().url().optional().describe("Webhook URL to receive claim notifications"),
16506
16532
  suppressDelivery: external_exports.boolean().optional().describe("If true, returns claimUrl without sending email/SMS"),
16507
16533
  branding: SendBrandingOptionsValidator.optional().describe("Branding for email/SMS delivery"),
16508
- guardianEmail: external_exports.string().email().optional().describe("Guardian email that must approve before student can claim")
16534
+ guardianEmail: external_exports.string().email().optional().describe("Guardian email that must approve before student can claim"),
16535
+ expiresInDays: external_exports.number().int().min(1).max(720).optional().describe(
16536
+ "How many days the credential stays claimable in the Universal Inbox (default 30). Does not change the credential validity period."
16537
+ )
16509
16538
  });
16510
16539
  var SendBoostInputValidator = external_exports.object({
16511
16540
  type: external_exports.literal("boost"),
@@ -16800,7 +16829,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16800
16829
  "APP_NOTIFICATION",
16801
16830
  "CREDENTIAL_REVOKED",
16802
16831
  "CREDENTIAL_SUSPENDED",
16803
- "CREDENTIAL_UNSUSPENDED"
16832
+ "CREDENTIAL_UNSUSPENDED",
16833
+ "CREDENTIAL_REFRESHED"
16804
16834
  ]);
16805
16835
  var LCNNotificationMessageValidator = external_exports.object({
16806
16836
  title: external_exports.string().optional(),
@@ -16932,12 +16962,16 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16932
16962
  });
16933
16963
  var InboxCredentialValidator = external_exports.object({
16934
16964
  id: external_exports.string(),
16935
- credential: external_exports.string(),
16965
+ credential: external_exports.string().optional(),
16936
16966
  isSigned: external_exports.boolean(),
16937
16967
  currentStatus: LCNInboxStatusEnumValidator,
16938
16968
  isAccepted: external_exports.boolean().optional(),
16939
16969
  expiresAt: external_exports.string(),
16940
16970
  createdAt: external_exports.string(),
16971
+ finalizedAt: external_exports.string().optional(),
16972
+ expiredAt: external_exports.string().optional(),
16973
+ credentialName: external_exports.string().optional(),
16974
+ achievementType: external_exports.string().optional(),
16941
16975
  issuerDid: external_exports.string(),
16942
16976
  webhookUrl: external_exports.string().optional(),
16943
16977
  boostUri: external_exports.string().optional(),
@@ -16991,7 +17025,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16991
17025
  "The signing authority to use for the credential. If not provided, the users default signing authority will be used if the credential is not signed."
16992
17026
  ),
16993
17027
  webhookUrl: external_exports.string().url().optional().describe("The webhook URL to receive credential issuance events."),
16994
- expiresInDays: external_exports.number().min(1).max(365).optional().describe("The number of days the credential will be valid for."),
17028
+ expiresInDays: external_exports.number().int().min(1).max(720).optional().describe(
17029
+ "How many days the encrypted inbox payload remains claimable. This does not change the credential validity period."
17030
+ ),
16995
17031
  templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional().describe(
16996
17032
  "Template data to render into the boost credential template using Mustache syntax. Only used when boostUri is provided."
16997
17033
  ),
@@ -17054,6 +17090,9 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17054
17090
  credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
17055
17091
  configuration: external_exports.object({
17056
17092
  publishableKey: external_exports.string(),
17093
+ expiresInDays: external_exports.number().int().min(1).max(720).optional().describe(
17094
+ "Inbox claim window in days. Defaults to 720; use a shorter window for sensitive records."
17095
+ ),
17057
17096
  signingAuthorityName: external_exports.string().optional(),
17058
17097
  listingId: external_exports.string().optional(),
17059
17098
  listingSlug: external_exports.string().optional()
@@ -17691,6 +17730,191 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17691
17730
  const result = inAppMessagesFlagValidator.safeParse(raw);
17692
17731
  return result.success ? result.data : EMPTY_IN_APP_MESSAGES_FLAG;
17693
17732
  }, "parseInAppMessagesFlag");
17733
+ var LearnCardRefreshAuthorizationValidator = external_exports.object({ type: external_exports.literal("LearnCardDIDAuth") }).catchall(external_exports.any());
17734
+ var ManagedCredentialRefreshServiceValidator = external_exports.object({
17735
+ id: external_exports.string().min(1),
17736
+ type: external_exports.literal("LearnCardCredentialRefresh2026"),
17737
+ authorization: LearnCardRefreshAuthorizationValidator.optional()
17738
+ }).catchall(external_exports.any());
17739
+ var StandardCredentialRefreshServiceValidator = external_exports.object({
17740
+ id: external_exports.string().min(1),
17741
+ type: external_exports.literal("1EdTechCredentialRefresh")
17742
+ }).catchall(external_exports.any());
17743
+ var SupportedCredentialRefreshServiceValidator = external_exports.union([
17744
+ ManagedCredentialRefreshServiceValidator,
17745
+ StandardCredentialRefreshServiceValidator
17746
+ ]);
17747
+ var AllocateCredentialRefreshInputValidator = external_exports.object({
17748
+ holder: external_exports.object({
17749
+ profileId: external_exports.string().optional(),
17750
+ did: external_exports.string().min(1)
17751
+ }),
17752
+ credentialId: external_exports.string().min(1)
17753
+ });
17754
+ var AllocateCredentialRefreshResultValidator = external_exports.object({
17755
+ refreshId: external_exports.string().min(1),
17756
+ refreshService: ManagedCredentialRefreshServiceValidator.extend({
17757
+ authorization: LearnCardRefreshAuthorizationValidator
17758
+ })
17759
+ });
17760
+ var CredentialRefreshSigningModeValidator = external_exports.enum(["issuer-signed", "signing-authority"]);
17761
+ var PublishCredentialRefreshBaseFields = {
17762
+ refreshId: external_exports.string().min(1),
17763
+ notifyHolder: external_exports.boolean().optional(),
17764
+ updateSummary: external_exports.string().optional(),
17765
+ idempotencyKey: external_exports.string().optional()
17766
+ };
17767
+ var PublishIssuerSignedRefreshValidator = external_exports.object({
17768
+ ...PublishCredentialRefreshBaseFields,
17769
+ mode: external_exports.literal("issuer-signed"),
17770
+ signedCredential: VCValidator
17771
+ });
17772
+ var PublishSigningAuthorityRefreshValidator = external_exports.object({
17773
+ ...PublishCredentialRefreshBaseFields,
17774
+ mode: external_exports.literal("signing-authority"),
17775
+ credential: UnsignedVCValidator,
17776
+ signingAuthority: external_exports.object({
17777
+ type: external_exports.string().min(1)
17778
+ }).catchall(external_exports.any())
17779
+ });
17780
+ var PublishCredentialRefreshInputValidator = external_exports.object({
17781
+ ...PublishCredentialRefreshBaseFields,
17782
+ mode: CredentialRefreshSigningModeValidator,
17783
+ signedCredential: VCValidator.optional(),
17784
+ credential: UnsignedVCValidator.optional(),
17785
+ signingAuthority: external_exports.object({
17786
+ type: external_exports.string().min(1)
17787
+ }).catchall(external_exports.any()).optional()
17788
+ }).superRefine((input, ctx) => {
17789
+ if (input.mode === "issuer-signed" && !input.signedCredential) {
17790
+ ctx.addIssue({
17791
+ code: "custom",
17792
+ path: ["signedCredential"],
17793
+ message: "signedCredential is required for issuer-signed publication"
17794
+ });
17795
+ }
17796
+ if (input.mode === "issuer-signed" && (input.credential !== void 0 || input.signingAuthority !== void 0)) {
17797
+ ctx.addIssue({
17798
+ code: "custom",
17799
+ path: ["mode"],
17800
+ message: "issuer-signed publication cannot include signing-authority fields"
17801
+ });
17802
+ }
17803
+ if (input.mode === "signing-authority") {
17804
+ if (input.signedCredential !== void 0) {
17805
+ ctx.addIssue({
17806
+ code: "custom",
17807
+ path: ["signedCredential"],
17808
+ message: "signing-authority publication cannot include signedCredential"
17809
+ });
17810
+ }
17811
+ if (!input.credential) {
17812
+ ctx.addIssue({
17813
+ code: "custom",
17814
+ path: ["credential"],
17815
+ message: "credential is required for signing-authority publication"
17816
+ });
17817
+ }
17818
+ if (!input.signingAuthority) {
17819
+ ctx.addIssue({
17820
+ code: "custom",
17821
+ path: ["signingAuthority"],
17822
+ message: "signingAuthority is required for signing-authority publication"
17823
+ });
17824
+ }
17825
+ }
17826
+ });
17827
+ var PublishCredentialRefreshNotificationValidator = external_exports.enum([
17828
+ "queued",
17829
+ "suppressed",
17830
+ "not-applicable",
17831
+ /** Publication succeeded, but the post-commit notification enqueue must be retried. */
17832
+ "delivery-failed"
17833
+ ]);
17834
+ var PublishCredentialRefreshResultValidator = external_exports.object({
17835
+ refreshId: external_exports.string().min(1),
17836
+ version: external_exports.number().int().positive(),
17837
+ publishedAt: external_exports.string().min(1),
17838
+ notification: PublishCredentialRefreshNotificationValidator
17839
+ });
17840
+ var CredentialRefreshVersionMetadataValidator = external_exports.object({
17841
+ version: external_exports.number().int().positive(),
17842
+ publishedAt: external_exports.string().min(1),
17843
+ effectiveAt: external_exports.string().optional(),
17844
+ etag: external_exports.string().optional(),
17845
+ signingMode: CredentialRefreshSigningModeValidator.optional(),
17846
+ updateSummary: external_exports.string().optional()
17847
+ });
17848
+ var GetCredentialRefreshHistoryInputValidator = external_exports.object({
17849
+ refreshId: external_exports.string().min(1),
17850
+ cursor: external_exports.string().optional(),
17851
+ limit: external_exports.number().int().positive().optional()
17852
+ });
17853
+ var GetCredentialRefreshHistoryResultValidator = external_exports.object({
17854
+ records: CredentialRefreshVersionMetadataValidator.array(),
17855
+ hasMore: external_exports.boolean(),
17856
+ cursor: external_exports.string().optional()
17857
+ });
17858
+ var CredentialRefreshChallengeValidator = external_exports.object({
17859
+ challenge: external_exports.string().min(1),
17860
+ expiresAt: external_exports.string().min(1),
17861
+ domain: external_exports.string().optional(),
17862
+ scheme: external_exports.literal("LearnCardDIDAuth").optional()
17863
+ });
17864
+ var PublicCredentialRefreshEnvelopeValidator = external_exports.object({
17865
+ format: external_exports.literal("vc"),
17866
+ credential: VCValidator,
17867
+ etag: external_exports.string().optional()
17868
+ });
17869
+ var JweCredentialRefreshEnvelopeValidator = external_exports.object({
17870
+ format: external_exports.literal("jwe"),
17871
+ jwe: JWEValidator,
17872
+ etag: external_exports.string().optional(),
17873
+ /** Present on LearnCard-managed endpoints; optional for interoperable JWE services. */
17874
+ version: external_exports.number().int().positive().optional()
17875
+ });
17876
+ var CredentialRefreshResponseEnvelopeValidator = external_exports.discriminatedUnion("format", [
17877
+ PublicCredentialRefreshEnvelopeValidator,
17878
+ JweCredentialRefreshEnvelopeValidator
17879
+ ]);
17880
+ var CredentialRefreshFailureCodeValidator = external_exports.enum([
17881
+ "UNAVAILABLE",
17882
+ "TIMEOUT",
17883
+ "UNSUPPORTED_SERVICE",
17884
+ "UNAUTHORIZED",
17885
+ "MALFORMED_RESPONSE",
17886
+ "INVALID_PROOF",
17887
+ "ISSUER_MISMATCH",
17888
+ "ID_MISMATCH",
17889
+ "ROLLBACK",
17890
+ "REVOKED",
17891
+ "UNSAFE_ENDPOINT"
17892
+ ]);
17893
+ var CredentialRefreshUpdatedResultValidator = external_exports.object({
17894
+ status: external_exports.literal("updated"),
17895
+ credential: VCValidator,
17896
+ etag: external_exports.string().optional(),
17897
+ managedVersion: external_exports.number().int().positive().optional()
17898
+ });
17899
+ var CredentialRefreshUnchangedResultValidator = external_exports.object({
17900
+ status: external_exports.literal("unchanged"),
17901
+ checkedAt: external_exports.string().min(1),
17902
+ etag: external_exports.string().optional()
17903
+ });
17904
+ var CredentialRefreshUnsupportedResultValidator = external_exports.object({
17905
+ status: external_exports.literal("unsupported")
17906
+ });
17907
+ var CredentialRefreshFailedResultValidator = external_exports.object({
17908
+ status: external_exports.literal("failed"),
17909
+ code: CredentialRefreshFailureCodeValidator,
17910
+ retryable: external_exports.boolean()
17911
+ });
17912
+ var CredentialRefreshResultValidator = external_exports.discriminatedUnion("status", [
17913
+ CredentialRefreshUpdatedResultValidator,
17914
+ CredentialRefreshUnchangedResultValidator,
17915
+ CredentialRefreshUnsupportedResultValidator,
17916
+ CredentialRefreshFailedResultValidator
17917
+ ]);
17694
17918
  }
17695
17919
  });
17696
17920
 
@@ -17999,7 +18223,7 @@ async function deriveKeyFromPassword(password, salt, params = DEFAULT_KDF_PARAMS
17999
18223
  hashLength: ARGON2_HASH_LENGTH,
18000
18224
  outputType: "binary"
18001
18225
  });
18002
- return new Uint8Array(hash);
18226
+ return Uint8Array.from(hash);
18003
18227
  }
18004
18228
  __name(deriveKeyFromPassword, "deriveKeyFromPassword");
18005
18229
  async function encryptWithPassword(plaintext, password) {