@learncard/network-plugin 2.4.18 → 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.
- package/dist/lcn-plugin.cjs.development.js +74 -0
- package/dist/lcn-plugin.cjs.development.js.map +2 -2
- package/dist/lcn-plugin.cjs.production.min.js +2 -2
- package/dist/lcn-plugin.cjs.production.min.js.map +3 -3
- package/dist/lcn-plugin.esm.js +74 -0
- package/dist/lcn-plugin.esm.js.map +2 -2
- package/dist/plugin.d.ts.map +1 -1
- package/dist/types.d.ts +10 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +7 -7
|
@@ -9809,6 +9809,28 @@ var LCNNotificationValidator = mod.object({
|
|
|
9809
9809
|
data: LCNNotificationDataValidator.optional(),
|
|
9810
9810
|
sent: mod.string().datetime().optional()
|
|
9811
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();
|
|
9812
9834
|
|
|
9813
9835
|
// src/plugin.ts
|
|
9814
9836
|
var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
|
|
@@ -10548,6 +10570,58 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
|
|
|
10548
10570
|
throw new Error("Please make an account first!");
|
|
10549
10571
|
return client.claimHook.deleteClaimHook.mutate({ id });
|
|
10550
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
|
+
},
|
|
10551
10625
|
resolveFromLCN: async (_learnCard, uri) => {
|
|
10552
10626
|
const result = await client.storage.resolve.query({ uri });
|
|
10553
10627
|
return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).or(ConsentFlowContractValidator).or(ConsentFlowTermsValidator).parseAsync(result);
|