@learncard/network-plugin 2.4.17 → 2.4.19

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.
@@ -5365,7 +5365,8 @@ var require_helpers_cjs_development = __commonJS({
5365
5365
  frontDoorBoostUri: mod2.string().optional(),
5366
5366
  createdAt: mod2.string(),
5367
5367
  updatedAt: mod2.string(),
5368
- expiresAt: mod2.string().optional()
5368
+ expiresAt: mod2.string().optional(),
5369
+ autoBoosts: mod2.string().array().optional()
5369
5370
  });
5370
5371
  var PaginatedConsentFlowContractsValidator2 = PaginationResponseValidator2.extend({
5371
5372
  records: ConsentFlowContractDetailsValidator2.omit({ owner: true }).array()
@@ -9646,7 +9647,8 @@ var ConsentFlowContractDetailsValidator = mod.object({
9646
9647
  frontDoorBoostUri: mod.string().optional(),
9647
9648
  createdAt: mod.string(),
9648
9649
  updatedAt: mod.string(),
9649
- expiresAt: mod.string().optional()
9650
+ expiresAt: mod.string().optional(),
9651
+ autoBoosts: mod.string().array().optional()
9650
9652
  });
9651
9653
  var PaginatedConsentFlowContractsValidator = PaginationResponseValidator.extend({
9652
9654
  records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
@@ -9807,6 +9809,28 @@ var LCNNotificationValidator = mod.object({
9807
9809
  data: LCNNotificationDataValidator.optional(),
9808
9810
  sent: mod.string().datetime().optional()
9809
9811
  });
9812
+ var AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX = "auth-grant:";
9813
+ var AuthGrantValidator = mod.object({
9814
+ id: mod.string(),
9815
+ name: mod.string(),
9816
+ description: mod.string().optional(),
9817
+ challenge: mod.string().startsWith(AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX).min(10, { message: "Challenge is too short" }).max(100, { message: "Challenge is too long" }),
9818
+ status: mod.enum(["revoked", "active"], {
9819
+ required_error: "Status is required",
9820
+ invalid_type_error: "Status must be either active or revoked"
9821
+ }),
9822
+ scope: mod.string(),
9823
+ createdAt: mod.string().datetime({ message: "createdAt must be a valid ISO 8601 datetime string" }),
9824
+ expiresAt: mod.string().datetime({ message: "expiresAt must be a valid ISO 8601 datetime string" }).nullish().optional()
9825
+ });
9826
+ var FlatAuthGrantValidator = mod.object({ id: mod.string() }).catchall(mod.any());
9827
+ var AuthGrantStatusValidator = mod.enum(["active", "revoked"]);
9828
+ var AuthGrantQueryValidator = mod.object({
9829
+ id: StringQuery,
9830
+ name: StringQuery,
9831
+ description: StringQuery,
9832
+ status: AuthGrantStatusValidator
9833
+ }).partial();
9810
9834
 
9811
9835
  // src/plugin.ts
9812
9836
  var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
@@ -10546,6 +10570,58 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
10546
10570
  throw new Error("Please make an account first!");
10547
10571
  return client.claimHook.deleteClaimHook.mutate({ id });
10548
10572
  },
10573
+ addAuthGrant: async (_learnCard, authGrant) => {
10574
+ if (!userData)
10575
+ throw new Error("Please make an account first!");
10576
+ return client.authGrants.addAuthGrant.mutate(authGrant);
10577
+ },
10578
+ revokeAuthGrant: async (_learnCard, id) => {
10579
+ if (!userData)
10580
+ throw new Error("Please make an account first!");
10581
+ return client.authGrants.revokeAuthGrant.mutate({ id });
10582
+ },
10583
+ deleteAuthGrant: async (_learnCard, id) => {
10584
+ if (!userData)
10585
+ throw new Error("Please make an account first!");
10586
+ return client.authGrants.deleteAuthGrant.mutate({ id });
10587
+ },
10588
+ updateAuthGrant: async (_learnCard, id, updates) => {
10589
+ if (!userData)
10590
+ throw new Error("Please make an account first!");
10591
+ return client.authGrants.updateAuthGrant.mutate({ id, updates });
10592
+ },
10593
+ getAuthGrant: async (_learnCard, id) => {
10594
+ if (!userData)
10595
+ throw new Error("Please make an account first!");
10596
+ return client.authGrants.getAuthGrant.query({ id });
10597
+ },
10598
+ getAuthGrants: async (_learnCard, options) => {
10599
+ if (!userData)
10600
+ throw new Error("Please make an account first!");
10601
+ return client.authGrants.getAuthGrants.query(options);
10602
+ },
10603
+ getAPITokenForAuthGrant: async (_learnCard, id) => {
10604
+ if (!userData)
10605
+ throw new Error("Please make an account first!");
10606
+ const authGrant = await client.authGrants.getAuthGrant.query({ id });
10607
+ if (!authGrant)
10608
+ throw new Error("Auth grant not found");
10609
+ if (authGrant.status !== "active")
10610
+ throw new Error("Auth grant is not active");
10611
+ if (!authGrant.challenge)
10612
+ throw new Error("Auth grant has no challenge");
10613
+ if (!authGrant.scope)
10614
+ throw new Error("Auth grant has no scope");
10615
+ if (authGrant.expiresAt && new Date(authGrant.expiresAt) < new Date())
10616
+ throw new Error("Auth grant is expired");
10617
+ const apiToken = await _learnCard.invoke.getDidAuthVp({
10618
+ challenge: authGrant.challenge,
10619
+ proofFormat: "jwt"
10620
+ });
10621
+ if (!apiToken)
10622
+ throw new Error("Failed to get API Token for auth grant");
10623
+ return apiToken;
10624
+ },
10549
10625
  resolveFromLCN: async (_learnCard, uri) => {
10550
10626
  const result = await client.storage.resolve.query({ uri });
10551
10627
  return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).or(ConsentFlowContractValidator).or(ConsentFlowTermsValidator).parseAsync(result);