@learncard/helpers 1.5.1 → 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"),
@@ -192,10 +193,18 @@ var require_types_cjs_development = __commonJS({
192
193
  IdentifierTypeValidator: /* @__PURE__ */ __name(() => IdentifierTypeValidator, "IdentifierTypeValidator"),
193
194
  IdentityObjectValidator: /* @__PURE__ */ __name(() => IdentityObjectValidator, "IdentityObjectValidator"),
194
195
  ImageValidator: /* @__PURE__ */ __name(() => ImageValidator, "ImageValidator"),
196
+ InboxBatchErrorReasonValidator: /* @__PURE__ */ __name(() => InboxBatchErrorReasonValidator, "InboxBatchErrorReasonValidator"),
197
+ InboxBatchReceiptValidator: /* @__PURE__ */ __name(() => InboxBatchReceiptValidator, "InboxBatchReceiptValidator"),
198
+ InboxBatchStatusValidator: /* @__PURE__ */ __name(() => InboxBatchStatusValidator, "InboxBatchStatusValidator"),
195
199
  InboxCredentialQueryValidator: /* @__PURE__ */ __name(() => InboxCredentialQueryValidator, "InboxCredentialQueryValidator"),
200
+ InboxCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => InboxCredentialRefreshReceiptValidator, "InboxCredentialRefreshReceiptValidator"),
196
201
  InboxCredentialValidator: /* @__PURE__ */ __name(() => InboxCredentialValidator, "InboxCredentialValidator"),
197
202
  IncrementCounterEventValidator: /* @__PURE__ */ __name(() => IncrementCounterEventValidator, "IncrementCounterEventValidator"),
198
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"),
199
208
  IssueInboxCredentialResponseValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialResponseValidator, "IssueInboxCredentialResponseValidator"),
200
209
  IssueInboxCredentialValidator: /* @__PURE__ */ __name(() => IssueInboxCredentialValidator, "IssueInboxCredentialValidator"),
201
210
  IssueInboxSigningAuthorityValidator: /* @__PURE__ */ __name(() => IssueInboxSigningAuthorityValidator, "IssueInboxSigningAuthorityValidator"),
@@ -244,7 +253,8 @@ var require_types_cjs_development = __commonJS({
244
253
  LaunchTypeValidator: /* @__PURE__ */ __name(() => LaunchTypeValidator, "LaunchTypeValidator"),
245
254
  LearnCardRefreshAuthorizationValidator: /* @__PURE__ */ __name(() => LearnCardRefreshAuthorizationValidator, "LearnCardRefreshAuthorizationValidator"),
246
255
  LinkProviderFrameworkInputValidator: /* @__PURE__ */ __name(() => LinkProviderFrameworkInputValidator, "LinkProviderFrameworkInputValidator"),
247
- ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator, "ManagedCredentialRefreshServiceValidator"),
256
+ ManagedCredentialRefreshReceiptValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshReceiptValidator, "ManagedCredentialRefreshReceiptValidator"),
257
+ ManagedCredentialRefreshServiceValidator: /* @__PURE__ */ __name(() => ManagedCredentialRefreshServiceValidator2, "ManagedCredentialRefreshServiceValidator"),
248
258
  PaginatedAppStoreListingsValidator: /* @__PURE__ */ __name(() => PaginatedAppStoreListingsValidator, "PaginatedAppStoreListingsValidator"),
249
259
  PaginatedBoostRecipientsValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsValidator, "PaginatedBoostRecipientsValidator"),
250
260
  PaginatedBoostRecipientsWithChildrenValidator: /* @__PURE__ */ __name(() => PaginatedBoostRecipientsWithChildrenValidator, "PaginatedBoostRecipientsWithChildrenValidator"),
@@ -270,6 +280,8 @@ var require_types_cjs_development = __commonJS({
270
280
  PaginatedVisibleLCNProfilesValidator: /* @__PURE__ */ __name(() => PaginatedVisibleLCNProfilesValidator, "PaginatedVisibleLCNProfilesValidator"),
271
281
  PaginationOptionsValidator: /* @__PURE__ */ __name(() => PaginationOptionsValidator, "PaginationOptionsValidator"),
272
282
  PaginationResponseValidator: /* @__PURE__ */ __name(() => PaginationResponseValidator, "PaginationResponseValidator"),
283
+ PrepareRefreshableSendInputValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendInputValidator, "PrepareRefreshableSendInputValidator"),
284
+ PrepareRefreshableSendResultValidator: /* @__PURE__ */ __name(() => PrepareRefreshableSendResultValidator, "PrepareRefreshableSendResultValidator"),
273
285
  ProfileValidator: /* @__PURE__ */ __name(() => ProfileValidator, "ProfileValidator"),
274
286
  ProfileVisibilityEnum: /* @__PURE__ */ __name(() => ProfileVisibilityEnum, "ProfileVisibilityEnum"),
275
287
  PromotionLevelValidator: /* @__PURE__ */ __name(() => PromotionLevelValidator, "PromotionLevelValidator"),
@@ -295,6 +307,7 @@ var require_types_cjs_development = __commonJS({
295
307
  SendAiSessionCredentialEventValidator: /* @__PURE__ */ __name(() => SendAiSessionCredentialEventValidator, "SendAiSessionCredentialEventValidator"),
296
308
  SendBoostInputValidator: /* @__PURE__ */ __name(() => SendBoostInputValidator, "SendBoostInputValidator"),
297
309
  SendBoostResponseValidator: /* @__PURE__ */ __name(() => SendBoostResponseValidator, "SendBoostResponseValidator"),
310
+ SendBoostTemplateValidator: /* @__PURE__ */ __name(() => SendBoostTemplateValidator, "SendBoostTemplateValidator"),
298
311
  SendBrandingOptionsValidator: /* @__PURE__ */ __name(() => SendBrandingOptionsValidator, "SendBrandingOptionsValidator"),
299
312
  SendCredentialEventValidator: /* @__PURE__ */ __name(() => SendCredentialEventValidator, "SendCredentialEventValidator"),
300
313
  SendInboxResponseValidator: /* @__PURE__ */ __name(() => SendInboxResponseValidator, "SendInboxResponseValidator"),
@@ -1024,7 +1037,7 @@ var require_types_cjs_development = __commonJS({
1024
1037
  getSizableOrigin: /* @__PURE__ */ __name(() => getSizableOrigin, "getSizableOrigin"),
1025
1038
  hexToUint8Array: /* @__PURE__ */ __name(() => hexToUint8Array, "hexToUint8Array"),
1026
1039
  isObject: /* @__PURE__ */ __name(() => isObject, "isObject"),
1027
- isPlainObject: /* @__PURE__ */ __name(() => isPlainObject, "isPlainObject"),
1040
+ isPlainObject: /* @__PURE__ */ __name(() => isPlainObject2, "isPlainObject"),
1028
1041
  issue: /* @__PURE__ */ __name(() => issue, "issue"),
1029
1042
  joinValues: /* @__PURE__ */ __name(() => joinValues, "joinValues"),
1030
1043
  jsonStringifyReplacer: /* @__PURE__ */ __name(() => jsonStringifyReplacer, "jsonStringifyReplacer"),
@@ -1250,7 +1263,7 @@ var require_types_cjs_development = __commonJS({
1250
1263
  return false;
1251
1264
  }
1252
1265
  });
1253
- function isPlainObject(o) {
1266
+ function isPlainObject2(o) {
1254
1267
  if (isObject(o) === false)
1255
1268
  return false;
1256
1269
  const ctor = o.constructor;
@@ -1266,10 +1279,10 @@ var require_types_cjs_development = __commonJS({
1266
1279
  }
1267
1280
  return true;
1268
1281
  }
1269
- __name(isPlainObject, "isPlainObject");
1270
- __name2(isPlainObject, "isPlainObject");
1282
+ __name(isPlainObject2, "isPlainObject");
1283
+ __name2(isPlainObject2, "isPlainObject");
1271
1284
  function shallowClone(o) {
1272
- if (isPlainObject(o))
1285
+ if (isPlainObject2(o))
1273
1286
  return { ...o };
1274
1287
  if (Array.isArray(o))
1275
1288
  return [...o];
@@ -1493,7 +1506,7 @@ var require_types_cjs_development = __commonJS({
1493
1506
  __name(omit, "omit");
1494
1507
  __name2(omit, "omit");
1495
1508
  function extend(schema, shape) {
1496
- if (!isPlainObject(shape)) {
1509
+ if (!isPlainObject2(shape)) {
1497
1510
  throw new Error("Invalid input to extend: expected a plain object");
1498
1511
  }
1499
1512
  const checks = schema._zod.def.checks;
@@ -1518,7 +1531,7 @@ var require_types_cjs_development = __commonJS({
1518
1531
  __name(extend, "extend");
1519
1532
  __name2(extend, "extend");
1520
1533
  function safeExtend(schema, shape) {
1521
- if (!isPlainObject(shape)) {
1534
+ if (!isPlainObject2(shape)) {
1522
1535
  throw new Error("Invalid input to safeExtend: expected a plain object");
1523
1536
  }
1524
1537
  const def = mergeDefs(schema._zod.def, {
@@ -3945,7 +3958,7 @@ var require_types_cjs_development = __commonJS({
3945
3958
  if (a instanceof Date && b instanceof Date && +a === +b) {
3946
3959
  return { valid: true, data: a };
3947
3960
  }
3948
- if (isPlainObject(a) && isPlainObject(b)) {
3961
+ if (isPlainObject2(a) && isPlainObject2(b)) {
3949
3962
  const bKeys = Object.keys(b);
3950
3963
  const sharedKeys = Object.keys(a).filter((key) => bKeys.indexOf(key) !== -1);
3951
3964
  const newObj = { ...a, ...b };
@@ -4141,7 +4154,7 @@ var require_types_cjs_development = __commonJS({
4141
4154
  $ZodType.init(inst, def);
4142
4155
  inst._zod.parse = (payload, ctx) => {
4143
4156
  const input = payload.value;
4144
- if (!isPlainObject(input)) {
4157
+ if (!isPlainObject2(input)) {
4145
4158
  payload.issues.push({
4146
4159
  expected: "record",
4147
4160
  code: "invalid_type",
@@ -16219,6 +16232,204 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16219
16232
  $or: BaseStringQuery.array()
16220
16233
  })
16221
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
+ ]);
16222
16433
  var LCNProfileDisplayValidator = external_exports.object({
16223
16434
  backgroundColor: external_exports.string().optional(),
16224
16435
  backgroundImage: external_exports.string().optional(),
@@ -16554,7 +16765,13 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16554
16765
  "Options for email/phone recipients (Universal Inbox)"
16555
16766
  ),
16556
16767
  templateData: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
16557
- 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
+ )
16558
16775
  }).refine((data) => data.templateUri || data.template || data.signedCredential, {
16559
16776
  message: "Either templateUri, template, or signedCredential must be provided.",
16560
16777
  path: ["templateUri"]
@@ -16569,8 +16786,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16569
16786
  message: "guardianEmail must differ from recipient (self-approval not allowed)",
16570
16787
  path: ["options", "guardianEmail"]
16571
16788
  }
16572
- );
16789
+ ).refine((data) => !data.idempotencyKey || data.refresh === true, {
16790
+ message: "idempotencyKey is only supported with refresh: true.",
16791
+ path: ["idempotencyKey"]
16792
+ });
16573
16793
  var SendInboxResponseValidator = external_exports.object({
16794
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
16574
16795
  issuanceId: external_exports.string(),
16575
16796
  status: external_exports.enum(["PENDING", "ISSUED", "EXPIRED", "DELIVERED", "CLAIMED"]),
16576
16797
  claimUrl: external_exports.string().url().optional().describe("Present when suppressDelivery=true"),
@@ -16585,8 +16806,34 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16585
16806
  activityId: external_exports.string().describe("Links to the activity lifecycle for this issuance"),
16586
16807
  inbox: SendInboxResponseValidator.optional().describe(
16587
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"
16588
16812
  )
16589
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
+ });
16590
16837
  var SendInputValidator = external_exports.discriminatedUnion("type", [SendBoostInputValidator]);
16591
16838
  var SendResponseValidator = external_exports.discriminatedUnion("type", [SendBoostResponseValidator]);
16592
16839
  var ConsentFlowTermsStatusValidator = external_exports.enum(["live", "stale", "withdrawn"]);
@@ -16905,6 +17152,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16905
17152
  webhookUrl: external_exports.string().optional()
16906
17153
  });
16907
17154
  var AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX = "auth-grant:";
17155
+ var ACT_AS_HEADER = "X-LearnCard-Act-As";
16908
17156
  var AuthGrantValidator = external_exports.object({
16909
17157
  id: external_exports.string(),
16910
17158
  name: external_exports.string(),
@@ -16917,6 +17165,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16917
17165
  }, "error")
16918
17166
  }),
16919
17167
  scope: external_exports.string(),
17168
+ actAs: external_exports.string().optional(),
16920
17169
  createdAt: external_exports.iso.datetime({ error: "createdAt must be a valid ISO 8601 datetime string" }),
16921
17170
  expiresAt: external_exports.iso.datetime({ error: "expiresAt must be a valid ISO 8601 datetime string" }).nullish().optional()
16922
17171
  });
@@ -16988,6 +17237,8 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
16988
17237
  sessionJwt: external_exports.string()
16989
17238
  });
16990
17239
  var InboxCredentialValidator = external_exports.object({
17240
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
17241
+ refreshId: external_exports.string().optional(),
16991
17242
  id: external_exports.string(),
16992
17243
  credential: external_exports.string().optional(),
16993
17244
  isSigned: external_exports.boolean(),
@@ -17042,12 +17293,19 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17042
17293
  templateUri: external_exports.string().optional().describe(
17043
17294
  "URI of a boost template to use for issuance. The boost credential will be resolved and used. Mutually exclusive with credential field."
17044
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(),
17045
17300
  // === OPTIONAL FEATURES ===
17046
17301
  // Add major, distinct features at the top level.
17047
17302
  //consentRequest: ConsentRequestValidator.optional(),
17048
17303
  // === PROCESS CONFIGURATION (Optional) ===
17049
17304
  // HOW should this issuance be handled?
17050
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
+ ),
17051
17309
  signingAuthority: IssueInboxSigningAuthorityValidator.optional().describe(
17052
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."
17053
17311
  ),
@@ -17101,17 +17359,130 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17101
17359
  }).optional().describe(
17102
17360
  "Configuration for the credential issuance. If not provided, the default configuration will be used."
17103
17361
  )
17362
+ }).refine((data) => !data.idempotencyKey || data.refresh === true, {
17363
+ message: "idempotencyKey requires refresh: true."
17104
17364
  }).refine((data) => data.credential || data.templateUri, {
17105
17365
  message: "Either credential or templateUri must be provided.",
17106
17366
  path: ["credential"]
17107
- });
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
+ );
17108
17374
  var IssueInboxCredentialResponseValidator = external_exports.object({
17375
+ refresh: InboxCredentialRefreshReceiptValidator.optional(),
17109
17376
  issuanceId: external_exports.string(),
17110
17377
  status: LCNInboxStatusEnumValidator,
17111
17378
  recipient: ContactMethodQueryValidator,
17112
17379
  claimUrl: external_exports.string().url().optional(),
17113
17380
  recipientDid: external_exports.string().optional()
17114
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
+ });
17115
17486
  var CredentialNameRefValidator = external_exports.object({ name: external_exports.string() }).passthrough();
17116
17487
  var ClaimInboxCredentialValidator = external_exports.object({
17117
17488
  credential: VCValidator.or(VPValidator).or(UnsignedVCValidator).or(CredentialNameRefValidator).describe("The credential to issue, or a { name } reference to resolve a boost template."),
@@ -17597,6 +17968,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17597
17968
  eventType: CredentialActivityEventTypeValidator,
17598
17969
  timestamp: external_exports.string(),
17599
17970
  actorProfileId: external_exports.string().optional(),
17971
+ onBehalfOf: external_exports.string().optional(),
17600
17972
  recipientType: CredentialActivityRecipientTypeValidator,
17601
17973
  recipientIdentifier: external_exports.string(),
17602
17974
  boostUri: external_exports.string().optional(),
@@ -17757,191 +18129,6 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
17757
18129
  const result = inAppMessagesFlagValidator.safeParse(raw);
17758
18130
  return result.success ? result.data : EMPTY_IN_APP_MESSAGES_FLAG;
17759
18131
  }, "parseInAppMessagesFlag");
17760
- var LearnCardRefreshAuthorizationValidator = external_exports.object({ type: external_exports.literal("LearnCardDIDAuth") }).catchall(external_exports.any());
17761
- var ManagedCredentialRefreshServiceValidator = external_exports.object({
17762
- id: external_exports.string().min(1),
17763
- type: external_exports.literal("LearnCardCredentialRefresh2026"),
17764
- authorization: LearnCardRefreshAuthorizationValidator.optional()
17765
- }).catchall(external_exports.any());
17766
- var StandardCredentialRefreshServiceValidator = external_exports.object({
17767
- id: external_exports.string().min(1),
17768
- type: external_exports.literal("1EdTechCredentialRefresh")
17769
- }).catchall(external_exports.any());
17770
- var SupportedCredentialRefreshServiceValidator2 = external_exports.union([
17771
- ManagedCredentialRefreshServiceValidator,
17772
- StandardCredentialRefreshServiceValidator
17773
- ]);
17774
- var AllocateCredentialRefreshInputValidator = external_exports.object({
17775
- holder: external_exports.object({
17776
- profileId: external_exports.string().optional(),
17777
- did: external_exports.string().min(1)
17778
- }),
17779
- credentialId: external_exports.string().min(1)
17780
- });
17781
- var AllocateCredentialRefreshResultValidator = external_exports.object({
17782
- refreshId: external_exports.string().min(1),
17783
- refreshService: ManagedCredentialRefreshServiceValidator.extend({
17784
- authorization: LearnCardRefreshAuthorizationValidator
17785
- })
17786
- });
17787
- var CredentialRefreshSigningModeValidator = external_exports.enum(["issuer-signed", "signing-authority"]);
17788
- var PublishCredentialRefreshBaseFields = {
17789
- refreshId: external_exports.string().min(1),
17790
- notifyHolder: external_exports.boolean().optional(),
17791
- updateSummary: external_exports.string().optional(),
17792
- idempotencyKey: external_exports.string().optional()
17793
- };
17794
- var PublishIssuerSignedRefreshValidator = external_exports.object({
17795
- ...PublishCredentialRefreshBaseFields,
17796
- mode: external_exports.literal("issuer-signed"),
17797
- signedCredential: VCValidator
17798
- });
17799
- var PublishSigningAuthorityRefreshValidator = external_exports.object({
17800
- ...PublishCredentialRefreshBaseFields,
17801
- mode: external_exports.literal("signing-authority"),
17802
- credential: UnsignedVCValidator,
17803
- signingAuthority: external_exports.object({
17804
- type: external_exports.string().min(1)
17805
- }).catchall(external_exports.any())
17806
- });
17807
- var PublishCredentialRefreshInputValidator = external_exports.object({
17808
- ...PublishCredentialRefreshBaseFields,
17809
- mode: CredentialRefreshSigningModeValidator,
17810
- signedCredential: VCValidator.optional(),
17811
- credential: UnsignedVCValidator.optional(),
17812
- signingAuthority: external_exports.object({
17813
- type: external_exports.string().min(1)
17814
- }).catchall(external_exports.any()).optional()
17815
- }).superRefine((input, ctx) => {
17816
- if (input.mode === "issuer-signed" && !input.signedCredential) {
17817
- ctx.addIssue({
17818
- code: "custom",
17819
- path: ["signedCredential"],
17820
- message: "signedCredential is required for issuer-signed publication"
17821
- });
17822
- }
17823
- if (input.mode === "issuer-signed" && (input.credential !== void 0 || input.signingAuthority !== void 0)) {
17824
- ctx.addIssue({
17825
- code: "custom",
17826
- path: ["mode"],
17827
- message: "issuer-signed publication cannot include signing-authority fields"
17828
- });
17829
- }
17830
- if (input.mode === "signing-authority") {
17831
- if (input.signedCredential !== void 0) {
17832
- ctx.addIssue({
17833
- code: "custom",
17834
- path: ["signedCredential"],
17835
- message: "signing-authority publication cannot include signedCredential"
17836
- });
17837
- }
17838
- if (!input.credential) {
17839
- ctx.addIssue({
17840
- code: "custom",
17841
- path: ["credential"],
17842
- message: "credential is required for signing-authority publication"
17843
- });
17844
- }
17845
- if (!input.signingAuthority) {
17846
- ctx.addIssue({
17847
- code: "custom",
17848
- path: ["signingAuthority"],
17849
- message: "signingAuthority is required for signing-authority publication"
17850
- });
17851
- }
17852
- }
17853
- });
17854
- var PublishCredentialRefreshNotificationValidator = external_exports.enum([
17855
- "queued",
17856
- "suppressed",
17857
- "not-applicable",
17858
- /** Publication succeeded, but the post-commit notification enqueue must be retried. */
17859
- "delivery-failed"
17860
- ]);
17861
- var PublishCredentialRefreshResultValidator = external_exports.object({
17862
- refreshId: external_exports.string().min(1),
17863
- version: external_exports.number().int().positive(),
17864
- publishedAt: external_exports.string().min(1),
17865
- notification: PublishCredentialRefreshNotificationValidator
17866
- });
17867
- var CredentialRefreshVersionMetadataValidator = external_exports.object({
17868
- version: external_exports.number().int().positive(),
17869
- publishedAt: external_exports.string().min(1),
17870
- effectiveAt: external_exports.string().optional(),
17871
- etag: external_exports.string().optional(),
17872
- signingMode: CredentialRefreshSigningModeValidator.optional(),
17873
- updateSummary: external_exports.string().optional()
17874
- });
17875
- var GetCredentialRefreshHistoryInputValidator = external_exports.object({
17876
- refreshId: external_exports.string().min(1),
17877
- cursor: external_exports.string().optional(),
17878
- limit: external_exports.number().int().positive().optional()
17879
- });
17880
- var GetCredentialRefreshHistoryResultValidator = external_exports.object({
17881
- records: CredentialRefreshVersionMetadataValidator.array(),
17882
- hasMore: external_exports.boolean(),
17883
- cursor: external_exports.string().optional()
17884
- });
17885
- var CredentialRefreshChallengeValidator = external_exports.object({
17886
- challenge: external_exports.string().min(1),
17887
- expiresAt: external_exports.string().min(1),
17888
- domain: external_exports.string().optional(),
17889
- scheme: external_exports.literal("LearnCardDIDAuth").optional()
17890
- });
17891
- var PublicCredentialRefreshEnvelopeValidator = external_exports.object({
17892
- format: external_exports.literal("vc"),
17893
- credential: VCValidator,
17894
- etag: external_exports.string().optional()
17895
- });
17896
- var JweCredentialRefreshEnvelopeValidator = external_exports.object({
17897
- format: external_exports.literal("jwe"),
17898
- jwe: JWEValidator2,
17899
- etag: external_exports.string().optional(),
17900
- /** Present on LearnCard-managed endpoints; optional for interoperable JWE services. */
17901
- version: external_exports.number().int().positive().optional()
17902
- });
17903
- var CredentialRefreshResponseEnvelopeValidator = external_exports.discriminatedUnion("format", [
17904
- PublicCredentialRefreshEnvelopeValidator,
17905
- JweCredentialRefreshEnvelopeValidator
17906
- ]);
17907
- var CredentialRefreshFailureCodeValidator = external_exports.enum([
17908
- "UNAVAILABLE",
17909
- "TIMEOUT",
17910
- "UNSUPPORTED_SERVICE",
17911
- "UNAUTHORIZED",
17912
- "MALFORMED_RESPONSE",
17913
- "INVALID_PROOF",
17914
- "ISSUER_MISMATCH",
17915
- "ID_MISMATCH",
17916
- "ROLLBACK",
17917
- "REVOKED",
17918
- "UNSAFE_ENDPOINT"
17919
- ]);
17920
- var CredentialRefreshUpdatedResultValidator = external_exports.object({
17921
- status: external_exports.literal("updated"),
17922
- credential: VCValidator,
17923
- etag: external_exports.string().optional(),
17924
- managedVersion: external_exports.number().int().positive().optional()
17925
- });
17926
- var CredentialRefreshUnchangedResultValidator = external_exports.object({
17927
- status: external_exports.literal("unchanged"),
17928
- checkedAt: external_exports.string().min(1),
17929
- etag: external_exports.string().optional()
17930
- });
17931
- var CredentialRefreshUnsupportedResultValidator = external_exports.object({
17932
- status: external_exports.literal("unsupported")
17933
- });
17934
- var CredentialRefreshFailedResultValidator = external_exports.object({
17935
- status: external_exports.literal("failed"),
17936
- code: CredentialRefreshFailureCodeValidator,
17937
- retryable: external_exports.boolean()
17938
- });
17939
- var CredentialRefreshResultValidator = external_exports.discriminatedUnion("status", [
17940
- CredentialRefreshUpdatedResultValidator,
17941
- CredentialRefreshUnchangedResultValidator,
17942
- CredentialRefreshUnsupportedResultValidator,
17943
- CredentialRefreshFailedResultValidator
17944
- ]);
17945
18132
  }
17946
18133
  });
17947
18134
 
@@ -18843,6 +19030,134 @@ var canonicalizeCredentialContent = /* @__PURE__ */ __name((value) => {
18843
19030
  return value;
18844
19031
  }, "canonicalizeCredentialContent");
18845
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");
18846
19161
  var credentialContentsEqual = /* @__PURE__ */ __name((first, second) => {
18847
19162
  const stripProof = /* @__PURE__ */ __name((vc) => {
18848
19163
  const { proof: _proof, ...rest } = vc ?? {};
@@ -18965,6 +19280,10 @@ export {
18965
19280
  ImageResizingValidator,
18966
19281
  ImageUploadingValidator,
18967
19282
  ImageWithLoadingStateValdator,
19283
+ MANAGED_REFRESH_AUTHORIZATION_IRI,
19284
+ MANAGED_REFRESH_DID_AUTH_IRI,
19285
+ MANAGED_REFRESH_SERVICE_CONTEXT,
19286
+ MANAGED_REFRESH_TYPE_IRI,
18968
19287
  RegExpTransformer,
18969
19288
  calculateAgeFromDob,
18970
19289
  canonicalizeCredentialContent,
@@ -18997,10 +19316,12 @@ export {
18997
19316
  getCredentialIssuerId,
18998
19317
  getCredentialStatusArray,
18999
19318
  getDidWeb,
19319
+ getManagedRefreshServices,
19000
19320
  getProvider,
19001
19321
  getSupportedRefreshService,
19002
19322
  getUrlsFromSrcSet,
19003
19323
  immerArraySlice,
19324
+ injectManagedRefreshService,
19004
19325
  innerImmerOuterImmer,
19005
19326
  innerImmerOuterReact,
19006
19327
  innerReactOuterImmer,
@@ -19017,6 +19338,7 @@ export {
19017
19338
  optionalEnvironmentString,
19018
19339
  optionalEnvironmentUrl,
19019
19340
  parseEnvironment,
19341
+ prepareManagedRefreshContext,
19020
19342
  projectEnvelopeToDisplayVc,
19021
19343
  quantizeValue,
19022
19344
  requiredEnvironmentString,