@learncard/helpers 1.5.0 → 1.6.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.
@@ -53,6 +53,7 @@ var require_types_cjs_development = __commonJS({
53
53
  var __toCommonJS = /* @__PURE__ */ __name((mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod), "__toCommonJS");
54
54
  var index_exports = {};
55
55
  __export2(index_exports, {
56
+ ACT_AS_HEADER: /* @__PURE__ */ __name(() => ACT_AS_HEADER, "ACT_AS_HEADER"),
56
57
  AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX: /* @__PURE__ */ __name(() => AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX, "AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX"),
57
58
  AchievementCredentialValidator: /* @__PURE__ */ __name(() => AchievementCredentialValidator, "AchievementCredentialValidator"),
58
59
  AchievementCriteriaValidator: /* @__PURE__ */ __name(() => AchievementCriteriaValidator, "AchievementCriteriaValidator"),
@@ -115,6 +116,7 @@ var require_types_cjs_development = __commonJS({
115
116
  ConsentFlowContractValidator: /* @__PURE__ */ __name(() => ConsentFlowContractValidator, "ConsentFlowContractValidator"),
116
117
  ConsentFlowDataForDidQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataForDidQueryValidator, "ConsentFlowDataForDidQueryValidator"),
117
118
  ConsentFlowDataQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowDataQueryValidator, "ConsentFlowDataQueryValidator"),
119
+ ConsentFlowGuardianApprovalValidator: /* @__PURE__ */ __name(() => ConsentFlowGuardianApprovalValidator, "ConsentFlowGuardianApprovalValidator"),
118
120
  ConsentFlowTermValidator: /* @__PURE__ */ __name(() => ConsentFlowTermValidator, "ConsentFlowTermValidator"),
119
121
  ConsentFlowTermsQueryValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsQueryValidator, "ConsentFlowTermsQueryValidator"),
120
122
  ConsentFlowTermsStatusValidator: /* @__PURE__ */ __name(() => ConsentFlowTermsStatusValidator, "ConsentFlowTermsStatusValidator"),
@@ -191,10 +193,18 @@ var require_types_cjs_development = __commonJS({
191
193
  IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
192
194
  IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
193
195
  ImageValidator: /* @__PURE__ */ __name(() => ImageValidator, "ImageValidator"),
196
+ InboxBatchErrorReasonValidator: /* @__PURE__ */ __name(() => InboxBatchErrorReasonValidator, "InboxBatchErrorReasonValidator"),
197
+ InboxBatchReceiptValidator: /* @__PURE__ */ __name(() => InboxBatchReceiptValidator, "InboxBatchReceiptValidator"),
198
+ InboxBatchStatusValidator: /* @__PURE__ */ __name(() => InboxBatchStatusValidator, "InboxBatchStatusValidator"),
194
199
  InboxCredentialQueryValidator: /* @__PURE__ */ __name(() => InboxCredentialQueryValidator, "InboxCredentialQueryValidator"),
200
+ InboxCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => InboxCredentialRefreshReceiptValidator, "InboxCredentialRefreshReceiptValidator"),
195
201
  InboxCredentialValidator: /* @__PURE__ */ __name(() => InboxCredentialValidator, "InboxCredentialValidator"),
196
202
  IncrementCounterEventValidator: /* @__PURE__ */ __name(() => IncrementCounterEventValidator, "IncrementCounterEventValidator"),
197
203
  InstalledAppValidator: /* @__PURE__ */ __name(() => InstalledAppValidator, "InstalledAppValidator"),
204
+ IssueInboxCredentialBatchItemResultValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemResultValidator, "IssueInboxCredentialBatchItemResultValidator"),
205
+ IssueInboxCredentialBatchItemValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchItemValidator, "IssueInboxCredentialBatchItemValidator"),
206
+ IssueInboxCredentialBatchResponseValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchResponseValidator, "IssueInboxCredentialBatchResponseValidator"),
207
+ IssueInboxCredentialBatchValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialBatchValidator, "IssueInboxCredentialBatchValidator"),
198
208
  IssueInboxCredentialResponseValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialResponseValidator, "IssueInboxCredentialResponseValidator"),
199
209
  IssueInboxCredentialValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialValidator, "IssueInboxCredentialValidator"),
200
210
  IssueInboxSigningAuthorityValidator: /* @__PURE__ */ __name(() => IssueInboxSigningAuthorityValidator, "IssueInboxSigningAuthorityValidator"),
@@ -243,7 +253,8 @@ var require_types_cjs_development = __commonJS({
243
253
  LaunchTypeValidator: /* @__PURE__ */ __name(() => LaunchTypeValidator, "LaunchTypeValidator"),
244
254
  LearnCardRefreshAuthorizationValidator: /* @__PURE__ */ __name(() => LearnCardRefreshAuthorizationValidator, "LearnCardRefreshAuthorizationValidator"),
245
255
  LinkProviderFrameworkInputValidator: /* @__PURE__ */ __name(() => LinkProviderFrameworkInputValidator, "LinkProviderFrameworkInputValidator"),
246
- ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator, "ManagedCredentialRefreshServiceValidator"),
256
+ ManagedCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshReceiptValidator, "ManagedCredentialRefreshReceiptValidator"),
257
+ ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator2, "ManagedCredentialRefreshServiceValidator"),
247
258
  PaginatedAppStoreListingsValidator: /* @__PURE__ */ __name(() => PaginatedAppStoreListingsValidator, "PaginatedAppStoreListingsValidator"),
248
259
  PaginatedBoostRecipientsValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsValidator, "PaginatedBoostRecipientsValidator"),
249
260
  PaginatedBoostRecipientsWithChildrenValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsWithChildrenValidator, "PaginatedBoostRecipientsWithChildrenValidator"),
@@ -269,6 +280,8 @@ var require_types_cjs_development = __commonJS({
269
280
  PaginatedVisibleLCNProfilesValidator: /* @__PURE__ */ __name(() => PaginatedVisibleLCNProfilesValidator, "PaginatedVisibleLCNProfilesValidator"),
270
281
  PaginationOptionsValidator: /* @__PURE__ */ __name(() => PaginationOptionsValidator, "PaginationOptionsValidator"),
271
282
  PaginationResponseValidator: /* @__PURE__ */ __name(() => PaginationResponseValidator, "PaginationResponseValidator"),
283
+ PrepareRefreshableSendInputValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendInputValidator, "PrepareRefreshableSendInputValidator"),
284
+ PrepareRefreshableSendResultValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendResultValidator, "PrepareRefreshableSendResultValidator"),
272
285
  ProfileValidator: /* @__PURE__ */ __name(() => ProfileValidator, "ProfileValidator"),
273
286
  ProfileVisibilityEnum: /* @__PURE__ */ __name(() => ProfileVisibilityEnum, "ProfileVisibilityEnum"),
274
287
  PromotionLevelValidator: /* @__PURE__ */ __name(() => PromotionLevelValidator, "PromotionLevelValidator"),
@@ -294,6 +307,7 @@ var require_types_cjs_development = __commonJS({
294
307
  SendAiSessionCredentialEventValidator: /* @__PURE__ */ __name(() => SendAiSessionCredentialEventValidator, "SendAiSessionCredentialEventValidator"),
295
308
  SendBoostInputValidator: /* @__PURE__ */ __name(() => SendBoostInputValidator, "SendBoostInputValidator"),
296
309
  SendBoostResponseValidator: /* @__PURE__ */ __name(() => SendBoostResponseValidator, "SendBoostResponseValidator"),
310
+ SendBoostTemplateValidator: /* @__PURE__ */ __name(() => SendBoostTemplateValidator, "SendBoostTemplateValidator"),
297
311
  SendBrandingOptionsValidator: /* @__PURE__ */ __name(() => SendBrandingOptionsValidator, "SendBrandingOptionsValidator"),
298
312
  SendCredentialEventValidator: /* @__PURE__ */ __name(() => SendCredentialEventValidator, "SendCredentialEventValidator"),
299
313
  SendInboxResponseValidator: /* @__PURE__ */ __name(() => SendInboxResponseValidator, "SendInboxResponseValidator"),
@@ -1023,7 +1037,7 @@ var require_types_cjs_development = __commonJS({
1023
1037
  getSizableOrigin: /* @__PURE__ */ __name(() => getSizableOrigin, "getSizableOrigin"),
1024
1038
  hexToUint8Array: /* @__PURE__ */ __name(() => hexToUint8Array, "hexToUint8Array"),
1025
1039
  isObject: /* @__PURE__ */ __name(() => isObject, "isObject"),
1026
- isPlainObject: /* @__PURE__ */ __name(() => isPlainObject, "isPlainObject"),
1040
+ isPlainObject: /* @__PURE__ */ __name(() => isPlainObject2, "isPlainObject"),
1027
1041
  issue: /* @__PURE__ */ __name(() => issue, "issue"),
1028
1042
  joinValues: /* @__PURE__ */ __name(() => joinValues, "joinValues"),
1029
1043
  jsonStringifyReplacer: /* @__PURE__ */ __name(() => jsonStringifyReplacer, "jsonStringifyReplacer"),
@@ -1249,7 +1263,7 @@ var require_types_cjs_development = __commonJS({
1249
1263
  return false;
1250
1264
  }
1251
1265
  });
1252
- function isPlainObject(o) {
1266
+ function isPlainObject2(o) {
1253
1267
  if (isObject(o) === false)
1254
1268
  return false;
1255
1269
  const ctor = o.constructor;
@@ -1265,10 +1279,10 @@ var require_types_cjs_development = __commonJS({
1265
1279
  }
1266
1280
  return true;
1267
1281
  }
1268
- __name(isPlainObject, "isPlainObject");
1269
- __name2(isPlainObject, "isPlainObject");
1282
+ __name(isPlainObject2, "isPlainObject");
1283
+ __name2(isPlainObject2, "isPlainObject");
1270
1284
  function shallowClone(o) {
1271
- if (isPlainObject(o))
1285
+ if (isPlainObject2(o))
1272
1286
  return { ...o };
1273
1287
  if (Array.isArray(o))
1274
1288
  return [...o];
@@ -1492,7 +1506,7 @@ var require_types_cjs_development = __commonJS({
1492
1506
  __name(omit, "omit");
1493
1507
  __name2(omit, "omit");
1494
1508
  function extend(schema, shape) {
1495
- if (!isPlainObject(shape)) {
1509
+ if (!isPlainObject2(shape)) {
1496
1510
  throw new Error("Invalid input to extend: expected a plain object");
1497
1511
  }
1498
1512
  const checks = schema._zod.def.checks;
@@ -1517,7 +1531,7 @@ var require_types_cjs_development = __commonJS({
1517
1531
  __name(extend, "extend");
1518
1532
  __name2(extend, "extend");
1519
1533
  function safeExtend(schema, shape) {
1520
- if (!isPlainObject(shape)) {
1534
+ if (!isPlainObject2(shape)) {
1521
1535
  throw new Error("Invalid input to safeExtend: expected a plain object");
1522
1536
  }
1523
1537
  const def = mergeDefs(schema._zod.def, {
@@ -3944,7 +3958,7 @@ var require_types_cjs_development = __commonJS({
3944
3958
  if (a instanceof Date && b instanceof Date && +a === +b) {
3945
3959
  return { valid: true, data: a };
3946
3960
  }
3947
- if (isPlainObject(a) && isPlainObject(b)) {
3961
+ if (isPlainObject2(a) && isPlainObject2(b)) {
3948
3962
  const bKeys = Object.keys(b);
3949
3963
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
3950
3964
  const newObj = { ...a, ...b };
@@ -4140,7 +4154,7 @@ var require_types_cjs_development = __commonJS({
4140
4154
  $ZodType.init(inst, def);
4141
4155
  inst._zod.parse = (payload, ctx) => {
4142
4156
  const input = payload.value;
4143
- if (!isPlainObject(input)) {
4157
+ if (!isPlainObject2(input)) {
4144
4158
  payload.issues.push({
4145
4159
  expected: "record",
4146
4160
  code: "invalid_type",
@@ -15761,14 +15775,22 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
15761
15775
  }).catchall(external_exports.any());
15762
15776
  var ProofValidator = external_exports.object({
15763
15777
  type: external_exports.string(),
15764
- created: external_exports.string(),
15778
+ created: external_exports.string().optional(),
15765
15779
  challenge: external_exports.string().optional(),
15766
15780
  domain: external_exports.string().optional(),
15767
15781
  nonce: external_exports.string().optional(),
15768
15782
  proofPurpose: external_exports.string(),
15769
15783
  verificationMethod: external_exports.string(),
15770
15784
  jws: external_exports.string().optional()
15771
- }).catchall(external_exports.any());
15785
+ }).catchall(external_exports.any()).superRefine((proof, ctx) => {
15786
+ if (proof.created === void 0 && (proof.type !== "DataIntegrityProof" || proof.cryptosuite !== "ecdsa-rdfc-2019")) {
15787
+ ctx.addIssue({
15788
+ code: "custom",
15789
+ path: ["created"],
15790
+ message: "created is required for this proof suite"
15791
+ });
15792
+ }
15793
+ });
15772
15794
  var VCValidator = UnsignedVCValidator.extend({
15773
15795
  proof: ProofValidator.or(ProofValidator.array())
15774
15796
  });
@@ -16210,6 +16232,204 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16210
16232
  $or: BaseStringQuery.array()
16211
16233
  })
16212
16234
  ]);
16235
+ var LearnCardRefreshAuthorizationValidator = external_exports.object({ type: external_exports.literal("LearnCardDIDAuth") }).catchall(external_exports.any());
16236
+ var ManagedCredentialRefreshServiceValidator2 = external_exports.object({
16237
+ id: external_exports.string().min(1),
16238
+ type: external_exports.literal("LearnCardCredentialRefresh2026"),
16239
+ authorization: LearnCardRefreshAuthorizationValidator.optional()
16240
+ }).catchall(external_exports.any());
16241
+ var StandardCredentialRefreshServiceValidator = external_exports.object({
16242
+ id: external_exports.string().min(1),
16243
+ type: external_exports.literal("1EdTechCredentialRefresh")
16244
+ }).catchall(external_exports.any());
16245
+ var SupportedCredentialRefreshServiceValidator2 = external_exports.union([
16246
+ ManagedCredentialRefreshServiceValidator2,
16247
+ StandardCredentialRefreshServiceValidator
16248
+ ]);
16249
+ var AllocateCredentialRefreshInputValidator = external_exports.object({
16250
+ holder: external_exports.object({
16251
+ profileId: external_exports.string().optional(),
16252
+ did: external_exports.string().min(1)
16253
+ }),
16254
+ credentialId: external_exports.string().min(1)
16255
+ });
16256
+ var AllocateCredentialRefreshResultValidator = external_exports.object({
16257
+ refreshId: external_exports.string().min(1),
16258
+ refreshService: ManagedCredentialRefreshServiceValidator2.extend({
16259
+ authorization: LearnCardRefreshAuthorizationValidator
16260
+ })
16261
+ });
16262
+ var ManagedCredentialRefreshReceiptValidator = external_exports.object({
16263
+ refreshId: external_exports.string().min(1),
16264
+ refreshService: ManagedCredentialRefreshServiceValidator2,
16265
+ credentialId: external_exports.string().min(1),
16266
+ issuerDid: external_exports.string().min(1),
16267
+ holderDid: external_exports.string().min(1),
16268
+ credentialStatus: CredentialStatusValidator.or(
16269
+ CredentialStatusValidator.array()
16270
+ ).optional()
16271
+ }).strip();
16272
+ var InboxCredentialRefreshReceiptValidator = ManagedCredentialRefreshReceiptValidator.omit(
16273
+ { holderDid: true }
16274
+ ).extend({ holderDid: external_exports.string().min(1).optional() });
16275
+ var CredentialRefreshSigningModeValidator = external_exports.enum(["issuer-signed", "signing-authority"]);
16276
+ var PublishCredentialRefreshBaseFields = {
16277
+ refreshId: external_exports.string().min(1),
16278
+ notifyHolder: external_exports.boolean().optional(),
16279
+ updateSummary: external_exports.string().optional(),
16280
+ idempotencyKey: external_exports.string().optional()
16281
+ };
16282
+ var PublishIssuerSignedRefreshValidator = external_exports.object({
16283
+ ...PublishCredentialRefreshBaseFields,
16284
+ mode: external_exports.literal("issuer-signed"),
16285
+ signedCredential: VCValidator
16286
+ });
16287
+ var PublishSigningAuthorityRefreshValidator = external_exports.object({
16288
+ ...PublishCredentialRefreshBaseFields,
16289
+ mode: external_exports.literal("signing-authority"),
16290
+ credential: UnsignedVCValidator,
16291
+ signingAuthority: external_exports.object({
16292
+ type: external_exports.string().min(1)
16293
+ }).catchall(external_exports.any())
16294
+ });
16295
+ var PublishCredentialRefreshInputValidator = external_exports.object({
16296
+ ...PublishCredentialRefreshBaseFields,
16297
+ mode: CredentialRefreshSigningModeValidator,
16298
+ signedCredential: VCValidator.optional(),
16299
+ credential: UnsignedVCValidator.optional(),
16300
+ signingAuthority: external_exports.object({
16301
+ type: external_exports.string().min(1)
16302
+ }).catchall(external_exports.any()).optional()
16303
+ }).superRefine((input, ctx) => {
16304
+ if (input.mode === "issuer-signed" && !input.signedCredential) {
16305
+ ctx.addIssue({
16306
+ code: "custom",
16307
+ path: ["signedCredential"],
16308
+ message: "signedCredential is required for issuer-signed publication"
16309
+ });
16310
+ }
16311
+ if (input.mode === "issuer-signed" && (input.credential !== void 0 || input.signingAuthority !== void 0)) {
16312
+ ctx.addIssue({
16313
+ code: "custom",
16314
+ path: ["mode"],
16315
+ message: "issuer-signed publication cannot include signing-authority fields"
16316
+ });
16317
+ }
16318
+ if (input.mode === "signing-authority") {
16319
+ if (input.signedCredential !== void 0) {
16320
+ ctx.addIssue({
16321
+ code: "custom",
16322
+ path: ["signedCredential"],
16323
+ message: "signing-authority publication cannot include signedCredential"
16324
+ });
16325
+ }
16326
+ if (!input.credential) {
16327
+ ctx.addIssue({
16328
+ code: "custom",
16329
+ path: ["credential"],
16330
+ message: "credential is required for signing-authority publication"
16331
+ });
16332
+ }
16333
+ if (!input.signingAuthority) {
16334
+ ctx.addIssue({
16335
+ code: "custom",
16336
+ path: ["signingAuthority"],
16337
+ message: "signingAuthority is required for signing-authority publication"
16338
+ });
16339
+ }
16340
+ }
16341
+ });
16342
+ var PublishCredentialRefreshNotificationValidator = external_exports.enum([
16343
+ "queued",
16344
+ "suppressed",
16345
+ "not-applicable",
16346
+ /** Publication succeeded, but the post-commit notification enqueue must be retried. */
16347
+ "delivery-failed"
16348
+ ]);
16349
+ var PublishCredentialRefreshResultValidator = external_exports.object({
16350
+ refreshId: external_exports.string().min(1),
16351
+ version: external_exports.number().int().positive(),
16352
+ publishedAt: external_exports.string().min(1),
16353
+ notification: PublishCredentialRefreshNotificationValidator
16354
+ });
16355
+ var CredentialRefreshVersionMetadataValidator = external_exports.object({
16356
+ version: external_exports.number().int().positive(),
16357
+ publishedAt: external_exports.string().min(1),
16358
+ effectiveAt: external_exports.string().optional(),
16359
+ etag: external_exports.string().optional(),
16360
+ signingMode: CredentialRefreshSigningModeValidator.optional(),
16361
+ updateSummary: external_exports.string().optional()
16362
+ });
16363
+ var GetCredentialRefreshHistoryInputValidator = external_exports.object({
16364
+ refreshId: external_exports.string().min(1),
16365
+ cursor: external_exports.string().optional(),
16366
+ limit: external_exports.number().int().positive().optional()
16367
+ });
16368
+ var GetCredentialRefreshHistoryResultValidator = external_exports.object({
16369
+ records: CredentialRefreshVersionMetadataValidator.array(),
16370
+ hasMore: external_exports.boolean(),
16371
+ cursor: external_exports.string().optional()
16372
+ });
16373
+ var CredentialRefreshChallengeValidator = external_exports.object({
16374
+ challenge: external_exports.string().min(1),
16375
+ expiresAt: external_exports.string().min(1),
16376
+ domain: external_exports.string().optional(),
16377
+ scheme: external_exports.literal("LearnCardDIDAuth").optional()
16378
+ });
16379
+ var PublicCredentialRefreshEnvelopeValidator = external_exports.object({
16380
+ format: external_exports.literal("vc"),
16381
+ credential: VCValidator,
16382
+ etag: external_exports.string().optional()
16383
+ });
16384
+ var JweCredentialRefreshEnvelopeValidator = external_exports.object({
16385
+ format: external_exports.literal("jwe"),
16386
+ jwe: JWEValidator2,
16387
+ etag: external_exports.string().optional(),
16388
+ /** Present on LearnCard-managed endpoints; optional for interoperable JWE services. */
16389
+ version: external_exports.number().int().positive().optional()
16390
+ });
16391
+ var CredentialRefreshResponseEnvelopeValidator = external_exports.discriminatedUnion("format", [
16392
+ PublicCredentialRefreshEnvelopeValidator,
16393
+ JweCredentialRefreshEnvelopeValidator
16394
+ ]);
16395
+ var CredentialRefreshFailureCodeValidator = external_exports.enum([
16396
+ "UNAVAILABLE",
16397
+ "TIMEOUT",
16398
+ "UNSUPPORTED_SERVICE",
16399
+ "UNAUTHORIZED",
16400
+ "MALFORMED_RESPONSE",
16401
+ "INVALID_PROOF",
16402
+ "ISSUER_MISMATCH",
16403
+ "ID_MISMATCH",
16404
+ "ROLLBACK",
16405
+ "REVOKED",
16406
+ "UNSAFE_ENDPOINT"
16407
+ ]);
16408
+ var CredentialRefreshUpdatedResultValidator = external_exports.object({
16409
+ status: external_exports.literal("updated"),
16410
+ credential: VCValidator,
16411
+ etag: external_exports.string().optional(),
16412
+ managedVersion: external_exports.number().int().positive().optional()
16413
+ });
16414
+ var CredentialRefreshUnchangedResultValidator = external_exports.object({
16415
+ status: external_exports.literal("unchanged"),
16416
+ checkedAt: external_exports.string().min(1),
16417
+ etag: external_exports.string().optional()
16418
+ });
16419
+ var CredentialRefreshUnsupportedResultValidator = external_exports.object({
16420
+ status: external_exports.literal("unsupported")
16421
+ });
16422
+ var CredentialRefreshFailedResultValidator = external_exports.object({
16423
+ status: external_exports.literal("failed"),
16424
+ code: CredentialRefreshFailureCodeValidator,
16425
+ retryable: external_exports.boolean()
16426
+ });
16427
+ var CredentialRefreshResultValidator = external_exports.discriminatedUnion("status", [
16428
+ CredentialRefreshUpdatedResultValidator,
16429
+ CredentialRefreshUnchangedResultValidator,
16430
+ CredentialRefreshUnsupportedResultValidator,
16431
+ CredentialRefreshFailedResultValidator
16432
+ ]);
16213
16433
  var LCNProfileDisplayValidator = external_exports.object({
16214
16434
  backgroundColor: external_exports.string().optional(),
16215
16435
  backgroundImage: external_exports.string().optional(),
@@ -16545,7 +16765,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16545
16765
  "Options for email/phone recipients (Universal Inbox)"
16546
16766
  ),
16547
16767
  templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
16548
- integrationId: external_exports.string().optional().describe("Integration ID for activity tracking")
16768
+ integrationId: external_exports.string().optional().describe("Integration ID for activity tracking"),
16769
+ refresh: external_exports.boolean().optional().describe(
16770
+ "Request managed credential refresh for this send. Profile/DID recipients use immediate issuance; email/phone recipients use deferred Universal Inbox signing and bind the holder at claim."
16771
+ ),
16772
+ idempotencyKey: external_exports.string().min(1).max(200).optional().describe(
16773
+ "Caller-chosen key that makes a managed refresh send (refresh: true) safe to retry as a whole: retries with the same key reuse the same boost, refresh allocation and result. Reusing a key for a different request is rejected. With signedCredential, requires prior tRPC prepareRefreshableSend; direct REST callers omit the key and retry the exact signed credential and templateUri."
16774
+ )
16549
16775
  }).refine((data) => data.templateUri || data.template || data.signedCredential, {
16550
16776
  message: "Either templateUri, template, or signedCredential must be provided.",
16551
16777
  path: ["templateUri"]
@@ -16560,8 +16786,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16560
16786
  message: "guardianEmail must differ from recipient (self-approval not allowed)",
16561
16787
  path: ["options", "guardianEmail"]
16562
16788
  }
16563
- );
16789
+ ).refine((data) => !data.idempotencyKey || data.refresh === true, {
16790
+ message: "idempotencyKey is only supported with refresh: true.",
16791
+ path: ["idempotencyKey"]
16792
+ });
16564
16793
  var SendInboxResponseValidator = external_exports.object({
16794
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
16565
16795
  issuanceId: external_exports.string(),
16566
16796
  status: external_exports.enum(["PENDING", "ISSUED", "EXPIRED", "DELIVERED", "CLAIMED"]),
16567
16797
  claimUrl: external_exports.string().url().optional().describe("Present when suppressDelivery=true"),
@@ -16576,8 +16806,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16576
16806
  activityId: external_exports.string().describe("Links to the activity lifecycle for this issuance"),
16577
16807
  inbox: SendInboxResponseValidator.optional().describe(
16578
16808
  "Present when sent via email/phone (Universal Inbox)"
16809
+ ),
16810
+ refresh: ManagedCredentialRefreshReceiptValidator.optional().describe(
16811
+ "Present when managed refresh was requested: issuance metadata the issuer keeps to publish future updates"
16579
16812
  )
16580
16813
  });
16814
+ var PrepareRefreshableSendInputValidator = external_exports.object({
16815
+ recipient: external_exports.string(),
16816
+ templateUri: external_exports.string().optional(),
16817
+ template: SendBoostTemplateValidator.optional(),
16818
+ contractUri: external_exports.string().optional(),
16819
+ templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
16820
+ integrationId: external_exports.string().optional(),
16821
+ /** Credential ID to allocate for; generated server-side when omitted. */
16822
+ credentialId: external_exports.string().min(1).optional(),
16823
+ idempotencyKey: external_exports.string().min(1).max(200).optional()
16824
+ }).refine((data) => Boolean(data.templateUri) !== Boolean(data.template), {
16825
+ message: "Provide exactly one of templateUri or template."
16826
+ });
16827
+ var PrepareRefreshableSendResultValidator = external_exports.object({
16828
+ boostUri: external_exports.string(),
16829
+ credentialId: external_exports.string(),
16830
+ refreshId: external_exports.string(),
16831
+ refreshService: ManagedCredentialRefreshServiceValidator2,
16832
+ /** The DID to use as credentialSubject.id (recipient DID, or the profile's did:web). */
16833
+ holderDid: external_exports.string(),
16834
+ /** Present when this idempotencyKey already completed: return it without signing. */
16835
+ completed: SendBoostResponseValidator.optional()
16836
+ });
16581
16837
  var SendInputValidator = external_exports.discriminatedUnion("type", [SendBoostInputValidator]);
16582
16838
  var SendResponseValidator = external_exports.discriminatedUnion("type", [SendBoostResponseValidator]);
16583
16839
  var ConsentFlowTermsStatusValidator = external_exports.enum(["live", "stale", "withdrawn"]);
@@ -16653,15 +16909,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16653
16909
  var PaginatedConsentFlowDataValidator = PaginationResponseValidator.extend({
16654
16910
  records: ConsentFlowContractDataValidator.array()
16655
16911
  });
16656
- var ConsentFlowContractDataForDidValidator = external_exports.object({
16657
- credentials: external_exports.object({ category: external_exports.string(), uri: external_exports.string() }).array(),
16658
- personal: external_exports.record(external_exports.string(), external_exports.string()).default({}),
16659
- date: external_exports.string(),
16660
- contractUri: external_exports.string()
16661
- });
16662
- var PaginatedConsentFlowDataForDidValidator = PaginationResponseValidator.extend({
16663
- records: ConsentFlowContractDataForDidValidator.array()
16664
- });
16665
16912
  var ConsentFlowTermValidator = external_exports.object({
16666
16913
  sharing: external_exports.boolean().optional(),
16667
16914
  shared: external_exports.string().array().optional(),
@@ -16695,6 +16942,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16695
16942
  status: ConsentFlowTermsStatusValidator
16696
16943
  }).array()
16697
16944
  });
16945
+ var ConsentFlowGuardianApprovalValidator = external_exports.object({
16946
+ guardianProfileId: external_exports.string(),
16947
+ guardianDid: external_exports.string(),
16948
+ approvedAt: external_exports.string().datetime(),
16949
+ contractUpdatedAt: external_exports.string()
16950
+ });
16951
+ var ConsentFlowContractDataForDidValidator = external_exports.object({
16952
+ credentials: external_exports.object({ category: external_exports.string(), uri: external_exports.string() }).array(),
16953
+ personal: external_exports.record(external_exports.string(), external_exports.string()).default({}),
16954
+ date: external_exports.string(),
16955
+ createdAt: external_exports.string().optional(),
16956
+ contractUpdatedAt: external_exports.string(),
16957
+ contractExpiresAt: external_exports.string().optional(),
16958
+ reasonForAccessing: external_exports.string().optional(),
16959
+ guardian: external_exports.object({
16960
+ required: external_exports.boolean(),
16961
+ approved: external_exports.boolean(),
16962
+ approval: ConsentFlowGuardianApprovalValidator.optional()
16963
+ }),
16964
+ contractUri: external_exports.string(),
16965
+ termsUri: external_exports.string(),
16966
+ status: ConsentFlowTermsStatusValidator,
16967
+ expiresAt: external_exports.string().optional(),
16968
+ terms: ConsentFlowTermsValidator
16969
+ });
16970
+ var PaginatedConsentFlowDataForDidValidator = PaginationResponseValidator.extend({
16971
+ records: ConsentFlowContractDataForDidValidator.array()
16972
+ });
16698
16973
  var ConsentFlowContractQueryValidator = external_exports.object({
16699
16974
  read: external_exports.object({
16700
16975
  anonymize: external_exports.boolean().optional(),
@@ -16755,6 +17030,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16755
17030
  expiresAt: external_exports.string().optional(),
16756
17031
  oneTime: external_exports.boolean().optional(),
16757
17032
  terms: ConsentFlowTermsValidator.optional(),
17033
+ guardianApproval: ConsentFlowGuardianApprovalValidator.optional(),
16758
17034
  id: external_exports.string(),
16759
17035
  action: ConsentFlowTransactionActionValidator,
16760
17036
  date: external_exports.string(),
@@ -16876,6 +17152,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16876
17152
  webhookUrl: external_exports.string().optional()
16877
17153
  });
16878
17154
  var AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX = "auth-grant:";
17155
+ var ACT_AS_HEADER = "X-LearnCard-Act-As";
16879
17156
  var AuthGrantValidator = external_exports.object({
16880
17157
  id: external_exports.string(),
16881
17158
  name: external_exports.string(),
@@ -16888,6 +17165,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16888
17165
  }, "error")
16889
17166
  }),
16890
17167
  scope: external_exports.string(),
17168
+ actAs: external_exports.string().optional(),
16891
17169
  createdAt: external_exports.iso.datetime({ error: "createdAt must be a valid ISO 8601 datetime string" }),
16892
17170
  expiresAt: external_exports.iso.datetime({ error: "expiresAt must be a valid ISO 8601 datetime string" }).nullish().optional()
16893
17171
  });
@@ -16959,6 +17237,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16959
17237
  sessionJwt: external_exports.string()
16960
17238
  });
16961
17239
  var InboxCredentialValidator = external_exports.object({
17240
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
17241
+ refreshId: external_exports.string().optional(),
16962
17242
  id: external_exports.string(),
16963
17243
  credential: external_exports.string().optional(),
16964
17244
  isSigned: external_exports.boolean(),
@@ -17013,12 +17293,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17013
17293
  templateUri: external_exports.string().optional().describe(
17014
17294
  "URI of a boost template to use for issuance. The boost credential will be resolved and used. Mutually exclusive with credential field."
17015
17295
  ),
17296
+ refresh: external_exports.boolean().optional().describe(
17297
+ "Allocate managed refresh before signing. Requires unsigned content and a registered signing authority; binds the holder on claim."
17298
+ ),
17299
+ idempotencyKey: external_exports.string().min(1).max(200).optional(),
17016
17300
  // === OPTIONAL FEATURES ===
17017
17301
  // Add major, distinct features at the top level.
17018
17302
  //consentRequest: ConsentRequestValidator.optional(),
17019
17303
  // === PROCESS CONFIGURATION (Optional) ===
17020
17304
  // HOW should this issuance be handled?
17021
17305
  configuration: external_exports.object({
17306
+ guardianEmail: external_exports.string().email().optional().describe(
17307
+ "Require approval from this guardian before the recipient can claim. Must differ from the recipient email."
17308
+ ),
17022
17309
  signingAuthority: IssueInboxSigningAuthorityValidator.optional().describe(
17023
17310
  "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."
17024
17311
  ),
@@ -17072,17 +17359,130 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17072
17359
  }).optional().describe(
17073
17360
  "Configuration for the credential issuance. If not provided, the default configuration will be used."
17074
17361
  )
17362
+ }).refine((data) => !data.idempotencyKey || data.refresh === true, {
17363
+ message: "idempotencyKey requires refresh: true."
17075
17364
  }).refine((data) => data.credential || data.templateUri, {
17076
17365
  message: "Either credential or templateUri must be provided.",
17077
17366
  path: ["credential"]
17078
- });
17367
+ }).refine(
17368
+ (data) => !data.configuration?.guardianEmail || data.recipient.type !== "email" || data.configuration.guardianEmail.toLowerCase() !== data.recipient.value.toLowerCase(),
17369
+ {
17370
+ message: "guardianEmail must differ from recipient (self-approval not allowed)",
17371
+ path: ["configuration", "guardianEmail"]
17372
+ }
17373
+ );
17079
17374
  var IssueInboxCredentialResponseValidator = external_exports.object({
17375
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
17080
17376
  issuanceId: external_exports.string(),
17081
17377
  status: LCNInboxStatusEnumValidator,
17082
17378
  recipient: ContactMethodQueryValidator,
17083
17379
  claimUrl: external_exports.string().url().optional(),
17084
17380
  recipientDid: external_exports.string().optional()
17085
17381
  });
17382
+ var InboxBatchConfigurationValidator = IssueInboxCredentialValidator.shape.configuration.unwrap().extend({
17383
+ refresh: IssueInboxCredentialValidator.shape.refresh.describe(
17384
+ "Enable managed refresh by default. An item configuration.refresh overrides this value, including false."
17385
+ ),
17386
+ delivery: IssueInboxCredentialValidator.shape.configuration.unwrap().shape.delivery.unwrap().extend({ suppress: external_exports.boolean().optional() }).optional()
17387
+ });
17388
+ var InboxBatchItemConfigurationValidator = InboxBatchConfigurationValidator.extend({
17389
+ guardianEmail: InboxBatchConfigurationValidator.shape.guardianEmail.nullable().describe(
17390
+ "Require guardian approval, or set null to clear a batch-level guardianEmail for this item."
17391
+ )
17392
+ });
17393
+ var IssueInboxCredentialBatchItemValidator = external_exports.object({
17394
+ ...IssueInboxCredentialValidator.shape,
17395
+ configuration: InboxBatchItemConfigurationValidator.optional(),
17396
+ idempotencyKey: external_exports.string().max(256).optional()
17397
+ }).refine((data) => data.credential || data.templateUri, {
17398
+ message: "Either credential or templateUri must be provided.",
17399
+ path: ["credential"]
17400
+ }).describe(
17401
+ "One issuance: provide credential or templateUri. Invalid input is rejected at submission with its item index."
17402
+ );
17403
+ var IssueInboxCredentialBatchValidator = external_exports.object({
17404
+ requestId: external_exports.string().min(1).max(256).optional(),
17405
+ items: external_exports.array(IssueInboxCredentialBatchItemValidator).min(1).max(100),
17406
+ configuration: InboxBatchConfigurationValidator.optional()
17407
+ }).superRefine((batch, ctx) => {
17408
+ batch.items.forEach((item, index) => {
17409
+ const itemGuardian = item.configuration?.guardianEmail;
17410
+ const guardian = itemGuardian === null ? void 0 : itemGuardian ?? batch.configuration?.guardianEmail;
17411
+ if (guardian && item.recipient.type === "email" && guardian.toLowerCase() === item.recipient.value.toLowerCase()) {
17412
+ ctx.addIssue({
17413
+ code: "custom",
17414
+ path: ["items", index, "configuration", "guardianEmail"],
17415
+ message: "guardianEmail must differ from recipient (self-approval not allowed)"
17416
+ });
17417
+ }
17418
+ });
17419
+ });
17420
+ var InboxBatchErrorReasonValidator = external_exports.enum([
17421
+ "DUPLICATE_KEY",
17422
+ "IDEMPOTENCY_MISMATCH",
17423
+ "IN_PROGRESS",
17424
+ "UNCONFIRMED"
17425
+ ]);
17426
+ var IssueInboxCredentialBatchItemResultValidator = external_exports.discriminatedUnion("success", [
17427
+ IssueInboxCredentialResponseValidator.extend({
17428
+ success: external_exports.literal(true),
17429
+ index: external_exports.number().int().nonnegative(),
17430
+ deduplicated: external_exports.boolean().optional(),
17431
+ guardianStatus: GuardianStatusValidator.optional(),
17432
+ idempotencyKey: external_exports.string().optional()
17433
+ }),
17434
+ external_exports.object({
17435
+ success: external_exports.literal(false),
17436
+ index: external_exports.number().int().nonnegative(),
17437
+ idempotencyKey: external_exports.string().optional(),
17438
+ recipient: ContactMethodQueryValidator.optional(),
17439
+ error: external_exports.object({
17440
+ code: external_exports.string(),
17441
+ message: external_exports.string(),
17442
+ reason: InboxBatchErrorReasonValidator.optional()
17443
+ }),
17444
+ issuanceId: external_exports.string().optional().describe(
17445
+ "Present when issuance completed but replay storage could not be confirmed. Reconcile this issuance; do not issue again with a new key."
17446
+ ),
17447
+ claimUrl: external_exports.string().url().optional().describe(
17448
+ "Claim URL of the completed issuance, if available, when replay storage could not be confirmed."
17449
+ )
17450
+ })
17451
+ ]);
17452
+ var IssueInboxCredentialBatchResponseValidator = external_exports.object({
17453
+ results: external_exports.array(IssueInboxCredentialBatchItemResultValidator),
17454
+ summary: external_exports.object({
17455
+ total: external_exports.number(),
17456
+ succeeded: external_exports.number(),
17457
+ failed: external_exports.number(),
17458
+ deduplicated: external_exports.number()
17459
+ })
17460
+ });
17461
+ var InboxBatchReceiptValidator = external_exports.object({
17462
+ batchId: external_exports.string(),
17463
+ status: external_exports.enum(["QUEUED", "PROCESSING", "COMPLETED", "NEEDS_RECONCILIATION"]),
17464
+ createdAt: external_exports.string()
17465
+ });
17466
+ var InboxBatchStatusValidator = external_exports.object({
17467
+ batchId: external_exports.string(),
17468
+ createdAt: external_exports.string(),
17469
+ done: external_exports.boolean().describe(
17470
+ "True when no queued or processing items remain, including unconfirmed outcomes."
17471
+ ),
17472
+ status: external_exports.enum(["QUEUED", "PROCESSING", "COMPLETED", "NEEDS_RECONCILIATION"]),
17473
+ items: external_exports.array(
17474
+ external_exports.object({
17475
+ index: external_exports.number().int().nonnegative(),
17476
+ state: external_exports.enum(["QUEUED", "PROCESSING", "COMPLETED", "NEEDS_RECONCILIATION"]),
17477
+ result: IssueInboxCredentialBatchItemResultValidator.optional()
17478
+ })
17479
+ ),
17480
+ summary: IssueInboxCredentialBatchResponseValidator.shape.summary.extend({
17481
+ completed: external_exports.number(),
17482
+ pending: external_exports.number(),
17483
+ unconfirmed: external_exports.number()
17484
+ })
17485
+ });
17086
17486
  var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
17087
17487
  var ClaimInboxCredentialValidator = external_exports.object({
17088
17488
  credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
@@ -17568,6 +17968,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17568
17968
  eventType: CredentialActivityEventTypeValidator,
17569
17969
  timestamp: external_exports.string(),
17570
17970
  actorProfileId: external_exports.string().optional(),
17971
+ onBehalfOf: external_exports.string().optional(),
17571
17972
  recipientType: CredentialActivityRecipientTypeValidator,
17572
17973
  recipientIdentifier: external_exports.string(),
17573
17974
  boostUri: external_exports.string().optional(),
@@ -17728,191 +18129,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17728
18129
  const result = inAppMessagesFlagValidator.safeParse(raw);
17729
18130
  return result.success ? result.data : EMPTY_IN_APP_MESSAGES_FLAG;
17730
18131
  }, "parseInAppMessagesFlag");
17731
- var LearnCardRefreshAuthorizationValidator = external_exports.object({ type: external_exports.literal("LearnCardDIDAuth") }).catchall(external_exports.any());
17732
- var ManagedCredentialRefreshServiceValidator = external_exports.object({
17733
- id: external_exports.string().min(1),
17734
- type: external_exports.literal("LearnCardCredentialRefresh2026"),
17735
- authorization: LearnCardRefreshAuthorizationValidator.optional()
17736
- }).catchall(external_exports.any());
17737
- var StandardCredentialRefreshServiceValidator = external_exports.object({
17738
- id: external_exports.string().min(1),
17739
- type: external_exports.literal("1EdTechCredentialRefresh")
17740
- }).catchall(external_exports.any());
17741
- var SupportedCredentialRefreshServiceValidator2 = external_exports.union([
17742
- ManagedCredentialRefreshServiceValidator,
17743
- StandardCredentialRefreshServiceValidator
17744
- ]);
17745
- var AllocateCredentialRefreshInputValidator = external_exports.object({
17746
- holder: external_exports.object({
17747
- profileId: external_exports.string().optional(),
17748
- did: external_exports.string().min(1)
17749
- }),
17750
- credentialId: external_exports.string().min(1)
17751
- });
17752
- var AllocateCredentialRefreshResultValidator = external_exports.object({
17753
- refreshId: external_exports.string().min(1),
17754
- refreshService: ManagedCredentialRefreshServiceValidator.extend({
17755
- authorization: LearnCardRefreshAuthorizationValidator
17756
- })
17757
- });
17758
- var CredentialRefreshSigningModeValidator = external_exports.enum(["issuer-signed", "signing-authority"]);
17759
- var PublishCredentialRefreshBaseFields = {
17760
- refreshId: external_exports.string().min(1),
17761
- notifyHolder: external_exports.boolean().optional(),
17762
- updateSummary: external_exports.string().optional(),
17763
- idempotencyKey: external_exports.string().optional()
17764
- };
17765
- var PublishIssuerSignedRefreshValidator = external_exports.object({
17766
- ...PublishCredentialRefreshBaseFields,
17767
- mode: external_exports.literal("issuer-signed"),
17768
- signedCredential: VCValidator
17769
- });
17770
- var PublishSigningAuthorityRefreshValidator = external_exports.object({
17771
- ...PublishCredentialRefreshBaseFields,
17772
- mode: external_exports.literal("signing-authority"),
17773
- credential: UnsignedVCValidator,
17774
- signingAuthority: external_exports.object({
17775
- type: external_exports.string().min(1)
17776
- }).catchall(external_exports.any())
17777
- });
17778
- var PublishCredentialRefreshInputValidator = external_exports.object({
17779
- ...PublishCredentialRefreshBaseFields,
17780
- mode: CredentialRefreshSigningModeValidator,
17781
- signedCredential: VCValidator.optional(),
17782
- credential: UnsignedVCValidator.optional(),
17783
- signingAuthority: external_exports.object({
17784
- type: external_exports.string().min(1)
17785
- }).catchall(external_exports.any()).optional()
17786
- }).superRefine((input, ctx) => {
17787
- if (input.mode === "issuer-signed" && !input.signedCredential) {
17788
- ctx.addIssue({
17789
- code: "custom",
17790
- path: ["signedCredential"],
17791
- message: "signedCredential is required for issuer-signed publication"
17792
- });
17793
- }
17794
- if (input.mode === "issuer-signed" && (input.credential !== void 0 || input.signingAuthority !== void 0)) {
17795
- ctx.addIssue({
17796
- code: "custom",
17797
- path: ["mode"],
17798
- message: "issuer-signed publication cannot include signing-authority fields"
17799
- });
17800
- }
17801
- if (input.mode === "signing-authority") {
17802
- if (input.signedCredential !== void 0) {
17803
- ctx.addIssue({
17804
- code: "custom",
17805
- path: ["signedCredential"],
17806
- message: "signing-authority publication cannot include signedCredential"
17807
- });
17808
- }
17809
- if (!input.credential) {
17810
- ctx.addIssue({
17811
- code: "custom",
17812
- path: ["credential"],
17813
- message: "credential is required for signing-authority publication"
17814
- });
17815
- }
17816
- if (!input.signingAuthority) {
17817
- ctx.addIssue({
17818
- code: "custom",
17819
- path: ["signingAuthority"],
17820
- message: "signingAuthority is required for signing-authority publication"
17821
- });
17822
- }
17823
- }
17824
- });
17825
- var PublishCredentialRefreshNotificationValidator = external_exports.enum([
17826
- "queued",
17827
- "suppressed",
17828
- "not-applicable",
17829
- /** Publication succeeded, but the post-commit notification enqueue must be retried. */
17830
- "delivery-failed"
17831
- ]);
17832
- var PublishCredentialRefreshResultValidator = external_exports.object({
17833
- refreshId: external_exports.string().min(1),
17834
- version: external_exports.number().int().positive(),
17835
- publishedAt: external_exports.string().min(1),
17836
- notification: PublishCredentialRefreshNotificationValidator
17837
- });
17838
- var CredentialRefreshVersionMetadataValidator = external_exports.object({
17839
- version: external_exports.number().int().positive(),
17840
- publishedAt: external_exports.string().min(1),
17841
- effectiveAt: external_exports.string().optional(),
17842
- etag: external_exports.string().optional(),
17843
- signingMode: CredentialRefreshSigningModeValidator.optional(),
17844
- updateSummary: external_exports.string().optional()
17845
- });
17846
- var GetCredentialRefreshHistoryInputValidator = external_exports.object({
17847
- refreshId: external_exports.string().min(1),
17848
- cursor: external_exports.string().optional(),
17849
- limit: external_exports.number().int().positive().optional()
17850
- });
17851
- var GetCredentialRefreshHistoryResultValidator = external_exports.object({
17852
- records: CredentialRefreshVersionMetadataValidator.array(),
17853
- hasMore: external_exports.boolean(),
17854
- cursor: external_exports.string().optional()
17855
- });
17856
- var CredentialRefreshChallengeValidator = external_exports.object({
17857
- challenge: external_exports.string().min(1),
17858
- expiresAt: external_exports.string().min(1),
17859
- domain: external_exports.string().optional(),
17860
- scheme: external_exports.literal("LearnCardDIDAuth").optional()
17861
- });
17862
- var PublicCredentialRefreshEnvelopeValidator = external_exports.object({
17863
- format: external_exports.literal("vc"),
17864
- credential: VCValidator,
17865
- etag: external_exports.string().optional()
17866
- });
17867
- var JweCredentialRefreshEnvelopeValidator = external_exports.object({
17868
- format: external_exports.literal("jwe"),
17869
- jwe: JWEValidator2,
17870
- etag: external_exports.string().optional(),
17871
- /** Present on LearnCard-managed endpoints; optional for interoperable JWE services. */
17872
- version: external_exports.number().int().positive().optional()
17873
- });
17874
- var CredentialRefreshResponseEnvelopeValidator = external_exports.discriminatedUnion("format", [
17875
- PublicCredentialRefreshEnvelopeValidator,
17876
- JweCredentialRefreshEnvelopeValidator
17877
- ]);
17878
- var CredentialRefreshFailureCodeValidator = external_exports.enum([
17879
- "UNAVAILABLE",
17880
- "TIMEOUT",
17881
- "UNSUPPORTED_SERVICE",
17882
- "UNAUTHORIZED",
17883
- "MALFORMED_RESPONSE",
17884
- "INVALID_PROOF",
17885
- "ISSUER_MISMATCH",
17886
- "ID_MISMATCH",
17887
- "ROLLBACK",
17888
- "REVOKED",
17889
- "UNSAFE_ENDPOINT"
17890
- ]);
17891
- var CredentialRefreshUpdatedResultValidator = external_exports.object({
17892
- status: external_exports.literal("updated"),
17893
- credential: VCValidator,
17894
- etag: external_exports.string().optional(),
17895
- managedVersion: external_exports.number().int().positive().optional()
17896
- });
17897
- var CredentialRefreshUnchangedResultValidator = external_exports.object({
17898
- status: external_exports.literal("unchanged"),
17899
- checkedAt: external_exports.string().min(1),
17900
- etag: external_exports.string().optional()
17901
- });
17902
- var CredentialRefreshUnsupportedResultValidator = external_exports.object({
17903
- status: external_exports.literal("unsupported")
17904
- });
17905
- var CredentialRefreshFailedResultValidator = external_exports.object({
17906
- status: external_exports.literal("failed"),
17907
- code: CredentialRefreshFailureCodeValidator,
17908
- retryable: external_exports.boolean()
17909
- });
17910
- var CredentialRefreshResultValidator = external_exports.discriminatedUnion("status", [
17911
- CredentialRefreshUpdatedResultValidator,
17912
- CredentialRefreshUnchangedResultValidator,
17913
- CredentialRefreshUnsupportedResultValidator,
17914
- CredentialRefreshFailedResultValidator
17915
- ]);
17916
18132
  }
17917
18133
  });
17918
18134
 
@@ -18814,6 +19030,134 @@ var canonicalizeCredentialContent = /* @__PURE__ */ __name((value) => {
18814
19030
  return value;
18815
19031
  }, "canonicalizeCredentialContent");
18816
19032
  var canonicalizeCredentialJson = /* @__PURE__ */ __name((value) => JSON.stringify(canonicalizeCredentialContent(value)), "canonicalizeCredentialJson");
19033
+ var MANAGED_REFRESH_TYPE_TERM = "LearnCardCredentialRefresh2026";
19034
+ var MANAGED_REFRESH_DID_AUTH_TERM = "LearnCardDIDAuth";
19035
+ var MANAGED_REFRESH_TYPE_IRI = "https://learncard.com/refresh#LearnCardCredentialRefresh2026";
19036
+ var MANAGED_REFRESH_AUTHORIZATION_IRI = "https://purl.imsglobal.org/spec/ob/v3p0#authorization";
19037
+ var MANAGED_REFRESH_DID_AUTH_IRI = "https://docs.learncard.com/definitions#LearnCardDIDAuth";
19038
+ var MANAGED_REFRESH_SERVICE_CONTEXT = {
19039
+ [MANAGED_REFRESH_TYPE_TERM]: MANAGED_REFRESH_TYPE_IRI,
19040
+ authorization: {
19041
+ "@id": MANAGED_REFRESH_AUTHORIZATION_IRI,
19042
+ "@context": { [MANAGED_REFRESH_DID_AUTH_TERM]: MANAGED_REFRESH_DID_AUTH_IRI }
19043
+ }
19044
+ };
19045
+ var isPlainObject = /* @__PURE__ */ __name((value) => !!value && typeof value === "object" && !Array.isArray(value), "isPlainObject");
19046
+ var toIdForm = /* @__PURE__ */ __name((definition) => typeof definition === "string" ? { "@id": definition } : definition, "toIdForm");
19047
+ var definitionId = /* @__PURE__ */ __name((definition) => {
19048
+ const idForm = toIdForm(definition);
19049
+ return isPlainObject(idForm) ? idForm["@id"] : void 0;
19050
+ }, "definitionId");
19051
+ var findTopLevelDefinition = /* @__PURE__ */ __name((contextObjects, term) => {
19052
+ let found;
19053
+ for (const contextObject of contextObjects) {
19054
+ if (term in contextObject) found = contextObject[term];
19055
+ }
19056
+ return found;
19057
+ }, "findTopLevelDefinition");
19058
+ var assertDefinitionMatchesIri = /* @__PURE__ */ __name((term, definition, expectedIri) => {
19059
+ const actualIri = definitionId(definition);
19060
+ if (actualIri !== expectedIri) {
19061
+ throw new Error(
19062
+ `Conflicting JSON-LD definition for term "${term}": expected "${expectedIri}" but the credential already defines it as ${JSON.stringify(
19063
+ definition
19064
+ )}. Remove or correct the existing definition before signing.`
19065
+ );
19066
+ }
19067
+ }, "assertDefinitionMatchesIri");
19068
+ var getManagedRefreshServices = /* @__PURE__ */ __name((vc) => {
19069
+ const refreshService = vc?.refreshService;
19070
+ if (!refreshService) return [];
19071
+ const services = Array.isArray(refreshService) ? refreshService : [refreshService];
19072
+ return services.flatMap((service) => {
19073
+ const parsed = import_types2.ManagedCredentialRefreshServiceValidator.safeParse(service);
19074
+ return parsed.success ? [parsed.data] : [];
19075
+ });
19076
+ }, "getManagedRefreshServices");
19077
+ var prepareManagedRefreshContext = /* @__PURE__ */ __name((credential) => {
19078
+ const source = credential;
19079
+ if (getManagedRefreshServices(source).length === 0) return credential;
19080
+ const existingContext = credential["@context"];
19081
+ const contextList = existingContext === void 0 || existingContext === null ? [] : Array.isArray(existingContext) ? [...existingContext] : [existingContext];
19082
+ const inlineObjects = contextList.filter(isPlainObject);
19083
+ const fragment = {};
19084
+ const typeDefinition = findTopLevelDefinition(inlineObjects, MANAGED_REFRESH_TYPE_TERM);
19085
+ if (typeDefinition === void 0) {
19086
+ fragment[MANAGED_REFRESH_TYPE_TERM] = MANAGED_REFRESH_TYPE_IRI;
19087
+ } else {
19088
+ assertDefinitionMatchesIri(
19089
+ MANAGED_REFRESH_TYPE_TERM,
19090
+ typeDefinition,
19091
+ MANAGED_REFRESH_TYPE_IRI
19092
+ );
19093
+ }
19094
+ const authorizationDefinition = findTopLevelDefinition(inlineObjects, "authorization");
19095
+ let didAuthCovered = false;
19096
+ if (authorizationDefinition === void 0) {
19097
+ fragment["authorization"] = MANAGED_REFRESH_SERVICE_CONTEXT.authorization;
19098
+ didAuthCovered = true;
19099
+ } else {
19100
+ assertDefinitionMatchesIri(
19101
+ "authorization",
19102
+ authorizationDefinition,
19103
+ MANAGED_REFRESH_AUTHORIZATION_IRI
19104
+ );
19105
+ if (isPlainObject(authorizationDefinition) && isPlainObject(authorizationDefinition["@context"])) {
19106
+ const scopedContext = authorizationDefinition["@context"];
19107
+ if (MANAGED_REFRESH_DID_AUTH_TERM in scopedContext) {
19108
+ assertDefinitionMatchesIri(
19109
+ MANAGED_REFRESH_DID_AUTH_TERM,
19110
+ scopedContext[MANAGED_REFRESH_DID_AUTH_TERM],
19111
+ MANAGED_REFRESH_DID_AUTH_IRI
19112
+ );
19113
+ didAuthCovered = true;
19114
+ }
19115
+ }
19116
+ }
19117
+ if (!didAuthCovered) {
19118
+ const didAuthDefinition = findTopLevelDefinition(
19119
+ inlineObjects,
19120
+ MANAGED_REFRESH_DID_AUTH_TERM
19121
+ );
19122
+ if (didAuthDefinition === void 0) {
19123
+ fragment[MANAGED_REFRESH_DID_AUTH_TERM] = MANAGED_REFRESH_DID_AUTH_IRI;
19124
+ } else {
19125
+ assertDefinitionMatchesIri(
19126
+ MANAGED_REFRESH_DID_AUTH_TERM,
19127
+ didAuthDefinition,
19128
+ MANAGED_REFRESH_DID_AUTH_IRI
19129
+ );
19130
+ }
19131
+ }
19132
+ if (Object.keys(fragment).length === 0) return credential;
19133
+ return {
19134
+ ...credential,
19135
+ "@context": [...contextList, fragment]
19136
+ };
19137
+ }, "prepareManagedRefreshContext");
19138
+ var injectManagedRefreshService = /* @__PURE__ */ __name((credential, refreshService) => {
19139
+ const service = import_types2.ManagedCredentialRefreshServiceValidator.parse(refreshService);
19140
+ const source = credential;
19141
+ const existing = source["refreshService"];
19142
+ const existingServices = existing === void 0 || existing === null ? [] : Array.isArray(existing) ? [...existing] : [existing];
19143
+ const existingManaged = getManagedRefreshServices({ refreshService: existingServices });
19144
+ if (existingManaged.some((entry) => entry.id !== service.id)) {
19145
+ throw new Error(
19146
+ "Credential already carries a different managed refresh service; a credential can only reference one managed refresh service."
19147
+ );
19148
+ }
19149
+ const nonManagedEntries = existingServices.filter(
19150
+ (entry) => !import_types2.ManagedCredentialRefreshServiceValidator.safeParse(entry).success
19151
+ );
19152
+ const mergedRefreshService = existingServices.length === 0 ? service : !Array.isArray(existing) && existingManaged.length > 0 ? (
19153
+ // Re-injecting the same managed service: keep object form (idempotent)
19154
+ service
19155
+ ) : [service, ...nonManagedEntries];
19156
+ return prepareManagedRefreshContext({
19157
+ ...credential,
19158
+ refreshService: mergedRefreshService
19159
+ });
19160
+ }, "injectManagedRefreshService");
18817
19161
  var credentialContentsEqual = /* @__PURE__ */ __name((first, second) => {
18818
19162
  const stripProof = /* @__PURE__ */ __name((vc) => {
18819
19163
  const { proof: _proof, ...rest } = vc ?? {};
@@ -18936,6 +19280,10 @@ export {
18936
19280
  ImageResizingValidator,
18937
19281
  ImageUploadingValidator,
18938
19282
  ImageWithLoadingStateValdator,
19283
+ MANAGED_REFRESH_AUTHORIZATION_IRI,
19284
+ MANAGED_REFRESH_DID_AUTH_IRI,
19285
+ MANAGED_REFRESH_SERVICE_CONTEXT,
19286
+ MANAGED_REFRESH_TYPE_IRI,
18939
19287
  RegExpTransformer,
18940
19288
  calculateAgeFromDob,
18941
19289
  canonicalizeCredentialContent,
@@ -18968,10 +19316,12 @@ export {
18968
19316
  getCredentialIssuerId,
18969
19317
  getCredentialStatusArray,
18970
19318
  getDidWeb,
19319
+ getManagedRefreshServices,
18971
19320
  getProvider,
18972
19321
  getSupportedRefreshService,
18973
19322
  getUrlsFromSrcSet,
18974
19323
  immerArraySlice,
19324
+ injectManagedRefreshService,
18975
19325
  innerImmerOuterImmer,
18976
19326
  innerImmerOuterReact,
18977
19327
  innerReactOuterImmer,
@@ -18988,6 +19338,7 @@ export {
18988
19338
  optionalEnvironmentString,
18989
19339
  optionalEnvironmentUrl,
18990
19340
  parseEnvironment,
19341
+ prepareManagedRefreshContext,
18991
19342
  projectEnvelopeToDisplayVc,
18992
19343
  quantizeValue,
18993
19344
  requiredEnvironmentString,