@learncard/lca-api-service 1.5.1 → 1.5.2

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/.env.example CHANGED
@@ -111,8 +111,8 @@ ESCROW_HOLD_RESTART_MIN_AGE_MS=
111
111
 
112
112
  # ESCROW_ENCLAVE_MODE=remote: HTTP client to the enclave-host parent (P3.3).
113
113
  # URL must be https:// unless NODE_ENV=test or the host is localhost. Token
114
- # is a bearer credential, minimum 32 characters. Timeout defaults to 10000ms
115
- # (max 30000ms). Missing/invalid config fails escrow closed at request time
114
+ # is a bearer credential, minimum 32 characters. Timeout defaults to 15000ms
115
+ # (max 30000ms). Keep it above the host's 12s, which is above the enclave's 10s. Missing/invalid config fails escrow closed at request time
116
116
  # rather than crashing the whole service at boot.
117
117
  ESCROW_ENCLAVE_REMOTE_URL=
118
118
  ESCROW_ENCLAVE_REMOTE_TOKEN=
package/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # @welibraryos/lca-api-service
2
2
 
3
+ ## 1.5.2
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [[`9018e3173393f2ec9645286edd99bb80aa3b2c6c`](https://github.com/learningeconomy/LearnCard/commit/9018e3173393f2ec9645286edd99bb80aa3b2c6c)]:
8
+ - @learncard/types@5.23.1
9
+ - @learncard/core@9.4.39
10
+ - @learncard/helpers@1.6.3
11
+ - @learncard/init@2.5.4
12
+ - @learncard/did-web-plugin@1.1.39
13
+ - @learncard/didkit-plugin@1.10.4
14
+ - @learncard/didkit-plugin-node@0.3.4
15
+ - @learncard/sss-key-manager@0.2.2
16
+
3
17
  ## 1.5.1
4
18
 
5
19
  ### Patch Changes
@@ -2,7 +2,7 @@
2
2
  "APPLE_OAUTH_CLIENT_IDS": "com.learncard.app,app.learncard.www",
3
3
  "DOMAIN_NAME": "staging.api.learncard.app",
4
4
  "ESCROW_ENCLAVE_ACTIVE_KEY_ID": "escrow-staging-v1",
5
- "ESCROW_ENCLAVE_REMOTE_TIMEOUT_MS": "10000",
5
+ "ESCROW_ENCLAVE_REMOTE_TIMEOUT_MS": "15000",
6
6
  "ESCROW_HOLD_DURATION_MS": "600000",
7
7
  "ESCROW_HOLD_RESTART_MIN_AGE_MS": "300000",
8
8
  "GOOGLE_OAUTH_CLIENT_IDS": "776298253175-74or0s6rg2k2mmdks6d45ro0i4te1bvf.apps.googleusercontent.com,776298253175-kkf562eofl541vu0oedfdvrk40bpkbh7.apps.googleusercontent.com",
package/dist/app.d.ts CHANGED
@@ -1041,6 +1041,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1041
1041
  attemptsRemaining: number;
1042
1042
  salt?: string | undefined;
1043
1043
  };
1044
+ primaryDid: string | null;
1044
1045
  };
1045
1046
  meta: import("trpc-to-openapi").OpenApiMeta;
1046
1047
  }>;
@@ -1126,7 +1127,7 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1126
1127
  attemptsRemaining: number;
1127
1128
  salt?: string | undefined;
1128
1129
  };
1129
- sssActivationState: "provisional" | "active";
1130
+ sssActivationState: "active" | "provisional";
1130
1131
  escrowStale?: "mode-mismatch" | "key-rotated" | undefined;
1131
1132
  } | null;
1132
1133
  meta: import("trpc-to-openapi").OpenApiMeta;
@@ -1344,6 +1345,45 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1344
1345
  };
1345
1346
  meta: import("trpc-to-openapi").OpenApiMeta;
1346
1347
  }>;
1348
+ getAuthorityState: import("@trpc/server").TRPCMutationProcedure<{
1349
+ input: {
1350
+ authToken: string;
1351
+ providerType: "firebase" | "supertokens" | "keycloak" | "oidc";
1352
+ nonce: string;
1353
+ };
1354
+ output: {
1355
+ state: {
1356
+ tenant: string;
1357
+ authorityGeneration: string;
1358
+ did: string;
1359
+ enrollmentVersion: number;
1360
+ enrollmentEpoch: number;
1361
+ status: "empty" | "active" | "disabled";
1362
+ envelope: {
1363
+ version: 1;
1364
+ algorithm: "P-256-HKDF-SHA256-AES-256-GCM";
1365
+ keyId: string;
1366
+ ephemeralPublicKey: string;
1367
+ salt: string;
1368
+ iv: string;
1369
+ ciphertext: string;
1370
+ } | null;
1371
+ shareVersion: number | null;
1372
+ hasPin: boolean;
1373
+ pinGeneration: number;
1374
+ attemptsUsed: number;
1375
+ };
1376
+ proof: {
1377
+ version: 1;
1378
+ keyId: string;
1379
+ measurement: number[];
1380
+ payload: string;
1381
+ signature: string;
1382
+ kind: "snapshot";
1383
+ };
1384
+ };
1385
+ meta: import("trpc-to-openapi").OpenApiMeta;
1386
+ }>;
1347
1387
  enroll: import("@trpc/server").TRPCMutationProcedure<{
1348
1388
  input: {
1349
1389
  authToken: string;
@@ -1361,10 +1401,56 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1361
1401
  enclaveKeyId: string;
1362
1402
  pinSalt?: string | undefined;
1363
1403
  clearPin?: boolean | undefined;
1404
+ signedIntent?: {
1405
+ intent: {
1406
+ version: 2;
1407
+ tenant: string;
1408
+ did: string;
1409
+ authorityGeneration: string;
1410
+ expectedEnrollmentVersion: number;
1411
+ action: "enroll" | "replace" | "disable" | "carry";
1412
+ sourceBlobIdentity: string | null;
1413
+ targetBlobIdentity: string | null;
1414
+ pinAction: "set" | "change" | "clear" | "keep";
1415
+ shareVersion: number;
1416
+ enrollmentEpoch: number;
1417
+ requestId: string;
1418
+ allowRewrap: boolean;
1419
+ recoveryEmail: string | null;
1420
+ recoveryLanguage: string | null;
1421
+ };
1422
+ signature: string;
1423
+ } | undefined;
1424
+ sourceEnvelope?: {
1425
+ version: 1;
1426
+ algorithm: "P-256-HKDF-SHA256-AES-256-GCM";
1427
+ keyId: string;
1428
+ ephemeralPublicKey: string;
1429
+ salt: string;
1430
+ iv: string;
1431
+ ciphertext: string;
1432
+ } | null | undefined;
1364
1433
  };
1365
1434
  output: {
1366
1435
  success: true;
1367
1436
  shareVersion: number;
1437
+ envelope?: {
1438
+ version: 1;
1439
+ algorithm: "P-256-HKDF-SHA256-AES-256-GCM";
1440
+ keyId: string;
1441
+ ephemeralPublicKey: string;
1442
+ salt: string;
1443
+ iv: string;
1444
+ ciphertext: string;
1445
+ } | undefined;
1446
+ receipt?: {
1447
+ version: 1;
1448
+ keyId: string;
1449
+ measurement: number[];
1450
+ signature: string;
1451
+ kind: "commit";
1452
+ payload: string;
1453
+ } | undefined;
1368
1454
  };
1369
1455
  meta: import("trpc-to-openapi").OpenApiMeta;
1370
1456
  }>;
@@ -1376,6 +1462,62 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1376
1462
  };
1377
1463
  output: {
1378
1464
  success: true;
1465
+ receipt?: {
1466
+ version: 1;
1467
+ keyId: string;
1468
+ measurement: number[];
1469
+ signature: string;
1470
+ kind: "commit";
1471
+ payload: string;
1472
+ } | undefined;
1473
+ };
1474
+ meta: import("trpc-to-openapi").OpenApiMeta;
1475
+ }>;
1476
+ disable: import("@trpc/server").TRPCMutationProcedure<{
1477
+ input: {
1478
+ authToken: string;
1479
+ providerType: "firebase" | "supertokens" | "keycloak" | "oidc";
1480
+ optOut: boolean;
1481
+ signedIntent: {
1482
+ intent: {
1483
+ version: 2;
1484
+ tenant: string;
1485
+ did: string;
1486
+ authorityGeneration: string;
1487
+ expectedEnrollmentVersion: number;
1488
+ action: "enroll" | "replace" | "disable" | "carry";
1489
+ sourceBlobIdentity: string | null;
1490
+ targetBlobIdentity: string | null;
1491
+ pinAction: "set" | "change" | "clear" | "keep";
1492
+ shareVersion: number;
1493
+ enrollmentEpoch: number;
1494
+ requestId: string;
1495
+ allowRewrap: boolean;
1496
+ recoveryEmail: string | null;
1497
+ recoveryLanguage: string | null;
1498
+ };
1499
+ signature: string;
1500
+ };
1501
+ sourceEnvelope?: {
1502
+ version: 1;
1503
+ algorithm: "P-256-HKDF-SHA256-AES-256-GCM";
1504
+ keyId: string;
1505
+ ephemeralPublicKey: string;
1506
+ salt: string;
1507
+ iv: string;
1508
+ ciphertext: string;
1509
+ } | undefined;
1510
+ };
1511
+ output: {
1512
+ success: true;
1513
+ receipt?: {
1514
+ version: 1;
1515
+ keyId: string;
1516
+ measurement: number[];
1517
+ signature: string;
1518
+ kind: "commit";
1519
+ payload: string;
1520
+ } | undefined;
1379
1521
  };
1380
1522
  meta: import("trpc-to-openapi").OpenApiMeta;
1381
1523
  }>;
@@ -1405,10 +1547,66 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1405
1547
  releaseAfter: string;
1406
1548
  status: "pending";
1407
1549
  resumeToken: string | null;
1550
+ holdRecord?: {
1551
+ [x: string]: unknown;
1552
+ hold: {
1553
+ [x: string]: unknown;
1554
+ holdId: string;
1555
+ did: string;
1556
+ shareVersion: number;
1557
+ blobHash: string;
1558
+ enrollmentEpoch: number;
1559
+ releasePolicy: "pin" | "hold";
1560
+ clientEphemeralPublicKey: string;
1561
+ createdLo: number;
1562
+ createdHi: number;
1563
+ policyVersion: number;
1564
+ signature: string;
1565
+ };
1566
+ holdDurationMs: number;
1567
+ ledgerSeq: number;
1568
+ } | undefined;
1569
+ requiresConfirmation?: boolean | undefined;
1408
1570
  pinSalt?: string | undefined;
1409
1571
  };
1410
1572
  meta: import("trpc-to-openapi").OpenApiMeta;
1411
1573
  }>;
1574
+ confirmRecovery: import("@trpc/server").TRPCMutationProcedure<{
1575
+ input: {
1576
+ holdId: string;
1577
+ resumeToken: string;
1578
+ code: string;
1579
+ };
1580
+ output: {
1581
+ success: true;
1582
+ receipt?: {
1583
+ version: 1;
1584
+ keyId: string;
1585
+ measurement: number[];
1586
+ signature: string;
1587
+ kind: "commit";
1588
+ payload: string;
1589
+ } | {
1590
+ version: 1;
1591
+ keyId: string;
1592
+ measurement: number[];
1593
+ payload: string;
1594
+ signature: string;
1595
+ kind: "snapshot";
1596
+ } | undefined;
1597
+ };
1598
+ meta: import("trpc-to-openapi").OpenApiMeta;
1599
+ }>;
1600
+ resendRecoveryCode: import("@trpc/server").TRPCMutationProcedure<{
1601
+ input: {
1602
+ holdId: string;
1603
+ resumeToken: string;
1604
+ };
1605
+ output: {
1606
+ success: true;
1607
+ };
1608
+ meta: import("trpc-to-openapi").OpenApiMeta;
1609
+ }>;
1412
1610
  getStatus: import("@trpc/server").TRPCQueryProcedure<{
1413
1611
  input: {
1414
1612
  holdId?: string | undefined;
@@ -1425,6 +1623,27 @@ export declare const appRouter: import("@trpc/server").TRPCBuiltRouter<{
1425
1623
  releasePolicy: "pin" | "hold";
1426
1624
  cancelledAt?: string | undefined;
1427
1625
  completedAt?: string | undefined;
1626
+ requiresConfirmation?: boolean | undefined;
1627
+ confirmed?: boolean | undefined;
1628
+ holdRecord?: {
1629
+ [x: string]: unknown;
1630
+ hold: {
1631
+ [x: string]: unknown;
1632
+ holdId: string;
1633
+ did: string;
1634
+ shareVersion: number;
1635
+ blobHash: string;
1636
+ enrollmentEpoch: number;
1637
+ releasePolicy: "pin" | "hold";
1638
+ clientEphemeralPublicKey: string;
1639
+ createdLo: number;
1640
+ createdHi: number;
1641
+ policyVersion: number;
1642
+ signature: string;
1643
+ };
1644
+ holdDurationMs: number;
1645
+ ledgerSeq: number;
1646
+ } | undefined;
1428
1647
  } | null;
1429
1648
  };
1430
1649
  meta: import("trpc-to-openapi").OpenApiMeta;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/index.js
3
- size: 137933050 bytes
4
- sha256: 8cda805bc82451b7427da412c28532f9ac6d5acb3700d2e4b73e60efa9711622
3
+ size: 138248277 bytes
4
+ sha256: 35649149351a54bc7898af2974a1ad44edaafc82a95d3e8e650a3e5e13ceb012
@@ -1,10 +1,18 @@
1
1
  import { z } from 'zod';
2
+ import { type AuthorityRecord } from '../services/escrow-enclave/authorityContract';
2
3
  import type { Collection } from 'mongodb';
3
4
  import { type AuthProviderMapping } from './UserKey';
4
5
  export declare const ESCROW_HOLDS_COLLECTION = "escrowholds";
5
6
  export declare const ESCROW_HOLD_STALE_WINDOW_MS: number;
6
7
  export declare const ESCROW_HOLD_RESTART_MIN_AGE_MS: number;
7
8
  export declare const ESCROW_HOLD_REMINDER_WINDOW_MS: number;
9
+ export declare const ESCROW_RELEASE_TIME_MARGIN_MS = 60000;
10
+ export declare const ESCROW_RELEASE_WARNING_GAP_MS: number;
11
+ export declare const computeEffectiveReleaseAfter: (params: {
12
+ confirmedAtMs: number;
13
+ holdDurationMs: number;
14
+ releaseWarningSentAtMs?: number;
15
+ }) => Date;
8
16
  export declare const EscrowHoldRecordValidator: z.ZodObject<{
9
17
  hold: z.ZodObject<{
10
18
  holdId: z.ZodString;
@@ -82,6 +90,22 @@ export declare const EscrowHoldValidator: z.ZodObject<{
82
90
  }>>;
83
91
  cancelledAt: z.ZodOptional<z.ZodDate>;
84
92
  enclaveCancelPendingAt: z.ZodOptional<z.ZodDate>;
93
+ enclaveCancelReceipt: z.ZodOptional<z.ZodObject<{
94
+ version: z.ZodLiteral<1>;
95
+ keyId: z.ZodString;
96
+ measurement: z.ZodArray<z.ZodNumber>;
97
+ signature: z.ZodString;
98
+ kind: z.ZodLiteral<"commit">;
99
+ payload: z.ZodString;
100
+ }, z.core.$strict>>;
101
+ enclaveReleaseReceipt: z.ZodOptional<z.ZodObject<{
102
+ version: z.ZodLiteral<1>;
103
+ keyId: z.ZodString;
104
+ measurement: z.ZodArray<z.ZodNumber>;
105
+ signature: z.ZodString;
106
+ kind: z.ZodLiteral<"commit">;
107
+ payload: z.ZodString;
108
+ }, z.core.$strict>>;
85
109
  enclaveCancelConfirmedAt: z.ZodOptional<z.ZodDate>;
86
110
  enclaveCancelAttempts: z.ZodOptional<z.ZodNumber>;
87
111
  enclaveEnvelope: z.ZodOptional<z.ZodObject<{
@@ -105,6 +129,8 @@ export declare const EscrowHoldValidator: z.ZodObject<{
105
129
  cancelTokenUsedAt: z.ZodOptional<z.ZodDate>;
106
130
  cancelTokenHashes: z.ZodOptional<z.ZodArray<z.ZodString>>;
107
131
  startedNotificationPending: z.ZodOptional<z.ZodBoolean>;
132
+ requiresConfirmation: z.ZodOptional<z.ZodBoolean>;
133
+ confirmedAt: z.ZodOptional<z.ZodDate>;
108
134
  reminderClaimedUntil: z.ZodOptional<z.ZodDate>;
109
135
  startedNotificationAttemptedAt: z.ZodOptional<z.ZodDate>;
110
136
  reminderAttemptedAt: z.ZodOptional<z.ZodDate>;
@@ -134,9 +160,11 @@ export declare const hasUnconfirmedEscrowCancellation: (primaryDid: string) => P
134
160
  export declare const findEscrowHoldsPendingEnclaveCancellation: (limit: number) => Promise<EscrowHold[]>;
135
161
  export declare const countEscrowCancellationsNearRelease: (now: Date) => Promise<number>;
136
162
  export declare const recordEscrowEnclaveCancelAttempt: (id: string) => Promise<boolean>;
137
- export declare const confirmEscrowEnclaveCancellation: (id: string) => Promise<void>;
163
+ export declare const confirmEscrowEnclaveCancellation: (id: string, receipt?: AuthorityRecord) => Promise<void>;
164
+ export declare const recordEscrowReleaseReceipt: (id: string, receipt: AuthorityRecord) => Promise<void>;
138
165
  export declare const cancelEscrowHold: (id: string, cancelledBy: "did" | "system", cancelReason?: EscrowHold["cancelReason"]) => Promise<EscrowHold | null>;
139
166
  export declare const cancelEscrowHoldByCancelToken: (id: string, cancelTokenHash: string) => Promise<EscrowHold | null>;
167
+ export declare const recordEscrowHoldConfirmation: (id: string, confirmedAt: Date, releaseAfter: Date) => Promise<EscrowHold | null>;
140
168
  export declare const completeEscrowHold: (id: string) => Promise<EscrowHold | null>;
141
169
  export declare const hasCompletedEscrowHoldForVersion: (authProvider: AuthProviderMapping, shareVersion: number) => Promise<boolean>;
142
170
  export declare const expireStaleEscrowHolds: (now: Date) => Promise<number>;
@@ -149,5 +177,5 @@ export declare const claimEscrowHoldForReminder: (id: string, now: Date) => Prom
149
177
  export declare const releaseEscrowReminderClaim: (hold: EscrowHold) => Promise<void>;
150
178
  export declare const hashEscrowResumeToken: (token: string) => string;
151
179
  export declare const generateEscrowResumeToken: () => string;
152
- export declare const recordEscrowHoldNotification: (holdId: string, kind: EscrowHold["notifications"][number]["kind"]) => Promise<void>;
180
+ export declare const recordEscrowHoldNotification: (holdId: string, kind: EscrowHold["notifications"][number]["kind"], releaseAfter?: Date) => Promise<void>;
153
181
  export declare const rotateEscrowCancelToken: (holdId: string) => Promise<string | null>;
@@ -1,4 +1,5 @@
1
1
  import { z } from 'zod';
2
+ import { type AuthorityMutationResult, type AuthorityRecord } from '../services/escrow-enclave/authorityContract';
2
3
  import { pruneOrphanedRecoveryMethods } from './pruneOrphanedRecoveryMethods';
3
4
  export declare const USER_KEYS_COLLECTION = "userkeys";
4
5
  export declare const ContactMethodValidator: z.ZodObject<{
@@ -72,6 +73,24 @@ export declare const EscrowEnvelopeValidator: z.ZodObject<{
72
73
  ciphertext: z.ZodString;
73
74
  }, z.core.$strict>;
74
75
  export declare const EscrowBlobValidator: z.ZodObject<{
76
+ authorityGeneration: z.ZodOptional<z.ZodString>;
77
+ enrollmentVersion: z.ZodOptional<z.ZodNumber>;
78
+ commitReceipt: z.ZodOptional<z.ZodObject<{
79
+ version: z.ZodLiteral<1>;
80
+ keyId: z.ZodString;
81
+ measurement: z.ZodArray<z.ZodNumber>;
82
+ signature: z.ZodString;
83
+ kind: z.ZodLiteral<"commit">;
84
+ payload: z.ZodString;
85
+ }, z.core.$strict>>;
86
+ authorityStateProof: z.ZodOptional<z.ZodObject<{
87
+ version: z.ZodLiteral<1>;
88
+ keyId: z.ZodString;
89
+ measurement: z.ZodArray<z.ZodNumber>;
90
+ payload: z.ZodString;
91
+ signature: z.ZodString;
92
+ kind: z.ZodLiteral<"snapshot">;
93
+ }, z.core.$strict>>;
75
94
  enrollmentEpoch: z.ZodNumber;
76
95
  blobHash: z.ZodString;
77
96
  envelope: z.ZodObject<{
@@ -121,6 +140,24 @@ export declare const EscrowPinStatusValidator: z.ZodObject<{
121
140
  export declare const getEscrowPinStatus: (userKey: MongoUserKeyType) => z.infer<typeof EscrowPinStatusValidator>;
122
141
  declare const MongoUserKeyBaseValidator: z.ZodObject<{
123
142
  escrowBlob: z.ZodOptional<z.ZodObject<{
143
+ authorityGeneration: z.ZodOptional<z.ZodString>;
144
+ enrollmentVersion: z.ZodOptional<z.ZodNumber>;
145
+ commitReceipt: z.ZodOptional<z.ZodObject<{
146
+ version: z.ZodLiteral<1>;
147
+ keyId: z.ZodString;
148
+ measurement: z.ZodArray<z.ZodNumber>;
149
+ signature: z.ZodString;
150
+ kind: z.ZodLiteral<"commit">;
151
+ payload: z.ZodString;
152
+ }, z.core.$strict>>;
153
+ authorityStateProof: z.ZodOptional<z.ZodObject<{
154
+ version: z.ZodLiteral<1>;
155
+ keyId: z.ZodString;
156
+ measurement: z.ZodArray<z.ZodNumber>;
157
+ payload: z.ZodString;
158
+ signature: z.ZodString;
159
+ kind: z.ZodLiteral<"snapshot">;
160
+ }, z.core.$strict>>;
124
161
  enrollmentEpoch: z.ZodNumber;
125
162
  blobHash: z.ZodString;
126
163
  envelope: z.ZodObject<{
@@ -230,8 +267,8 @@ declare const MongoUserKeyBaseValidator: z.ZodObject<{
230
267
  migratedFromWeb3Auth: z.ZodDefault<z.ZodBoolean>;
231
268
  migratedAt: z.ZodOptional<z.ZodDate>;
232
269
  sssActivationState: z.ZodOptional<z.ZodEnum<{
233
- provisional: "provisional";
234
270
  active: "active";
271
+ provisional: "provisional";
235
272
  }>>;
236
273
  provisionalCreatedAt: z.ZodOptional<z.ZodDate>;
237
274
  createdAt: z.ZodDate;
@@ -239,6 +276,24 @@ declare const MongoUserKeyBaseValidator: z.ZodObject<{
239
276
  }, z.core.$strip>;
240
277
  export declare const MongoUserKeyValidator: z.ZodObject<{
241
278
  escrowBlob: z.ZodOptional<z.ZodObject<{
279
+ authorityGeneration: z.ZodOptional<z.ZodString>;
280
+ enrollmentVersion: z.ZodOptional<z.ZodNumber>;
281
+ commitReceipt: z.ZodOptional<z.ZodObject<{
282
+ version: z.ZodLiteral<1>;
283
+ keyId: z.ZodString;
284
+ measurement: z.ZodArray<z.ZodNumber>;
285
+ signature: z.ZodString;
286
+ kind: z.ZodLiteral<"commit">;
287
+ payload: z.ZodString;
288
+ }, z.core.$strict>>;
289
+ authorityStateProof: z.ZodOptional<z.ZodObject<{
290
+ version: z.ZodLiteral<1>;
291
+ keyId: z.ZodString;
292
+ measurement: z.ZodArray<z.ZodNumber>;
293
+ payload: z.ZodString;
294
+ signature: z.ZodString;
295
+ kind: z.ZodLiteral<"snapshot">;
296
+ }, z.core.$strict>>;
242
297
  enrollmentEpoch: z.ZodNumber;
243
298
  blobHash: z.ZodString;
244
299
  envelope: z.ZodObject<{
@@ -348,8 +403,8 @@ export declare const MongoUserKeyValidator: z.ZodObject<{
348
403
  migratedFromWeb3Auth: z.ZodDefault<z.ZodBoolean>;
349
404
  migratedAt: z.ZodOptional<z.ZodDate>;
350
405
  sssActivationState: z.ZodOptional<z.ZodEnum<{
351
- provisional: "provisional";
352
406
  active: "active";
407
+ provisional: "provisional";
353
408
  }>>;
354
409
  provisionalCreatedAt: z.ZodOptional<z.ZodDate>;
355
410
  createdAt: z.ZodDate;
@@ -436,6 +491,24 @@ export declare const getUserKeysCollection: () => import("mongodb").Collection<{
436
491
  };
437
492
  shareVersion: number;
438
493
  createdAt: Date;
494
+ authorityGeneration?: string | undefined;
495
+ enrollmentVersion?: number | undefined;
496
+ commitReceipt?: {
497
+ version: 1;
498
+ keyId: string;
499
+ measurement: number[];
500
+ signature: string;
501
+ kind: "commit";
502
+ payload: string;
503
+ } | undefined;
504
+ authorityStateProof?: {
505
+ version: 1;
506
+ keyId: string;
507
+ measurement: number[];
508
+ payload: string;
509
+ signature: string;
510
+ kind: "snapshot";
511
+ } | undefined;
439
512
  } | undefined;
440
513
  escrowPin?: {
441
514
  salt: string;
@@ -456,7 +529,7 @@ export declare const getUserKeysCollection: () => import("mongodb").Collection<{
456
529
  recoveryEmail?: string | undefined;
457
530
  recoveryEmailVerifiedAt?: Date | undefined;
458
531
  migratedAt?: Date | undefined;
459
- sssActivationState?: "provisional" | "active" | undefined;
532
+ sssActivationState?: "active" | "provisional" | undefined;
460
533
  provisionalCreatedAt?: Date | undefined;
461
534
  }>;
462
535
  export declare const createUserKeysIndexes: () => Promise<void>;
@@ -475,11 +548,22 @@ export declare const setEscrowBlobByAuthProvider: (authProvider: AuthProviderMap
475
548
  }, carryFrom?: {
476
549
  blob: EscrowBlob;
477
550
  pin: NonNullable<MongoUserKeyType["escrowPin"]>;
551
+ }, authority?: {
552
+ enrollmentEpoch: number;
553
+ expectedBlob?: EscrowBlob;
554
+ expectedPin?: MongoUserKeyType["escrowPin"];
555
+ }) => Promise<MongoUserKeyType | null>;
556
+ export declare const rewrapEscrowBlobByAuthProvider: (authProvider: AuthProviderMapping, oldBlob: EscrowBlob, oldPin: MongoUserKeyType["escrowPin"], newEnvelope: EscrowBlob["envelope"], identity: Pick<EscrowBlob, "enclaveKeyId" | "enclaveMode" | "measurements">, authority?: Pick<AuthorityMutationResult, "authorityGeneration" | "enrollmentVersion"> & {
557
+ receipt?: AuthorityRecord;
558
+ stateProof?: AuthorityRecord;
478
559
  }) => Promise<MongoUserKeyType | null>;
479
- export declare const rewrapEscrowBlobByAuthProvider: (authProvider: AuthProviderMapping, oldBlob: EscrowBlob, oldPin: MongoUserKeyType["escrowPin"], newEnvelope: EscrowBlob["envelope"], identity: Pick<EscrowBlob, "enclaveKeyId" | "enclaveMode" | "measurements">) => Promise<MongoUserKeyType | null>;
480
560
  export declare const findUserKeysWithEscrowBlobKeyId: (keyIds: string[], limit: number) => Promise<MongoUserKeyType[]>;
481
- export declare const clearEscrowByAuthProvider: (authProvider: AuthProviderMapping, { optOut }: {
561
+ export declare const clearEscrowByAuthProvider: (authProvider: AuthProviderMapping, { optOut, expected, }: {
482
562
  optOut: boolean;
563
+ expected?: {
564
+ blob?: EscrowBlob;
565
+ pin?: MongoUserKeyType["escrowPin"];
566
+ };
483
567
  }) => Promise<MongoUserKeyType | null>;
484
568
  export declare const setEscrowOptInByAuthProvider: (authProvider: AuthProviderMapping) => Promise<MongoUserKeyType | null>;
485
569
  export declare const reserveEscrowPinAttempt: (authProvider: AuthProviderMapping, shareVersion: number, expectedCiphertext?: string) => Promise<MongoUserKeyType | null>;