@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.
- package/dist/lcn-plugin.cjs.development.js +78 -2
- 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 +78 -2
- 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
package/dist/lcn-plugin.esm.js
CHANGED
|
@@ -5340,7 +5340,8 @@ var require_helpers_cjs_development = __commonJS({
|
|
|
5340
5340
|
frontDoorBoostUri: mod2.string().optional(),
|
|
5341
5341
|
createdAt: mod2.string(),
|
|
5342
5342
|
updatedAt: mod2.string(),
|
|
5343
|
-
expiresAt: mod2.string().optional()
|
|
5343
|
+
expiresAt: mod2.string().optional(),
|
|
5344
|
+
autoBoosts: mod2.string().array().optional()
|
|
5344
5345
|
});
|
|
5345
5346
|
var PaginatedConsentFlowContractsValidator2 = PaginationResponseValidator2.extend({
|
|
5346
5347
|
records: ConsentFlowContractDetailsValidator2.omit({ owner: true }).array()
|
|
@@ -9621,7 +9622,8 @@ var ConsentFlowContractDetailsValidator = mod.object({
|
|
|
9621
9622
|
frontDoorBoostUri: mod.string().optional(),
|
|
9622
9623
|
createdAt: mod.string(),
|
|
9623
9624
|
updatedAt: mod.string(),
|
|
9624
|
-
expiresAt: mod.string().optional()
|
|
9625
|
+
expiresAt: mod.string().optional(),
|
|
9626
|
+
autoBoosts: mod.string().array().optional()
|
|
9625
9627
|
});
|
|
9626
9628
|
var PaginatedConsentFlowContractsValidator = PaginationResponseValidator.extend({
|
|
9627
9629
|
records: ConsentFlowContractDetailsValidator.omit({ owner: true }).array()
|
|
@@ -9782,6 +9784,28 @@ var LCNNotificationValidator = mod.object({
|
|
|
9782
9784
|
data: LCNNotificationDataValidator.optional(),
|
|
9783
9785
|
sent: mod.string().datetime().optional()
|
|
9784
9786
|
});
|
|
9787
|
+
var AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX = "auth-grant:";
|
|
9788
|
+
var AuthGrantValidator = mod.object({
|
|
9789
|
+
id: mod.string(),
|
|
9790
|
+
name: mod.string(),
|
|
9791
|
+
description: mod.string().optional(),
|
|
9792
|
+
challenge: mod.string().startsWith(AUTH_GRANT_AUDIENCE_DOMAIN_PREFIX).min(10, { message: "Challenge is too short" }).max(100, { message: "Challenge is too long" }),
|
|
9793
|
+
status: mod.enum(["revoked", "active"], {
|
|
9794
|
+
required_error: "Status is required",
|
|
9795
|
+
invalid_type_error: "Status must be either active or revoked"
|
|
9796
|
+
}),
|
|
9797
|
+
scope: mod.string(),
|
|
9798
|
+
createdAt: mod.string().datetime({ message: "createdAt must be a valid ISO 8601 datetime string" }),
|
|
9799
|
+
expiresAt: mod.string().datetime({ message: "expiresAt must be a valid ISO 8601 datetime string" }).nullish().optional()
|
|
9800
|
+
});
|
|
9801
|
+
var FlatAuthGrantValidator = mod.object({ id: mod.string() }).catchall(mod.any());
|
|
9802
|
+
var AuthGrantStatusValidator = mod.enum(["active", "revoked"]);
|
|
9803
|
+
var AuthGrantQueryValidator = mod.object({
|
|
9804
|
+
id: StringQuery,
|
|
9805
|
+
name: StringQuery,
|
|
9806
|
+
description: StringQuery,
|
|
9807
|
+
status: AuthGrantStatusValidator
|
|
9808
|
+
}).partial();
|
|
9785
9809
|
|
|
9786
9810
|
// src/plugin.ts
|
|
9787
9811
|
var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) => {
|
|
@@ -10521,6 +10545,58 @@ var getLearnCardNetworkPlugin = /* @__PURE__ */ __name(async (learnCard, url) =>
|
|
|
10521
10545
|
throw new Error("Please make an account first!");
|
|
10522
10546
|
return client.claimHook.deleteClaimHook.mutate({ id });
|
|
10523
10547
|
},
|
|
10548
|
+
addAuthGrant: async (_learnCard, authGrant) => {
|
|
10549
|
+
if (!userData)
|
|
10550
|
+
throw new Error("Please make an account first!");
|
|
10551
|
+
return client.authGrants.addAuthGrant.mutate(authGrant);
|
|
10552
|
+
},
|
|
10553
|
+
revokeAuthGrant: async (_learnCard, id) => {
|
|
10554
|
+
if (!userData)
|
|
10555
|
+
throw new Error("Please make an account first!");
|
|
10556
|
+
return client.authGrants.revokeAuthGrant.mutate({ id });
|
|
10557
|
+
},
|
|
10558
|
+
deleteAuthGrant: async (_learnCard, id) => {
|
|
10559
|
+
if (!userData)
|
|
10560
|
+
throw new Error("Please make an account first!");
|
|
10561
|
+
return client.authGrants.deleteAuthGrant.mutate({ id });
|
|
10562
|
+
},
|
|
10563
|
+
updateAuthGrant: async (_learnCard, id, updates) => {
|
|
10564
|
+
if (!userData)
|
|
10565
|
+
throw new Error("Please make an account first!");
|
|
10566
|
+
return client.authGrants.updateAuthGrant.mutate({ id, updates });
|
|
10567
|
+
},
|
|
10568
|
+
getAuthGrant: async (_learnCard, id) => {
|
|
10569
|
+
if (!userData)
|
|
10570
|
+
throw new Error("Please make an account first!");
|
|
10571
|
+
return client.authGrants.getAuthGrant.query({ id });
|
|
10572
|
+
},
|
|
10573
|
+
getAuthGrants: async (_learnCard, options) => {
|
|
10574
|
+
if (!userData)
|
|
10575
|
+
throw new Error("Please make an account first!");
|
|
10576
|
+
return client.authGrants.getAuthGrants.query(options);
|
|
10577
|
+
},
|
|
10578
|
+
getAPITokenForAuthGrant: async (_learnCard, id) => {
|
|
10579
|
+
if (!userData)
|
|
10580
|
+
throw new Error("Please make an account first!");
|
|
10581
|
+
const authGrant = await client.authGrants.getAuthGrant.query({ id });
|
|
10582
|
+
if (!authGrant)
|
|
10583
|
+
throw new Error("Auth grant not found");
|
|
10584
|
+
if (authGrant.status !== "active")
|
|
10585
|
+
throw new Error("Auth grant is not active");
|
|
10586
|
+
if (!authGrant.challenge)
|
|
10587
|
+
throw new Error("Auth grant has no challenge");
|
|
10588
|
+
if (!authGrant.scope)
|
|
10589
|
+
throw new Error("Auth grant has no scope");
|
|
10590
|
+
if (authGrant.expiresAt && new Date(authGrant.expiresAt) < new Date())
|
|
10591
|
+
throw new Error("Auth grant is expired");
|
|
10592
|
+
const apiToken = await _learnCard.invoke.getDidAuthVp({
|
|
10593
|
+
challenge: authGrant.challenge,
|
|
10594
|
+
proofFormat: "jwt"
|
|
10595
|
+
});
|
|
10596
|
+
if (!apiToken)
|
|
10597
|
+
throw new Error("Failed to get API Token for auth grant");
|
|
10598
|
+
return apiToken;
|
|
10599
|
+
},
|
|
10524
10600
|
resolveFromLCN: async (_learnCard, uri) => {
|
|
10525
10601
|
const result = await client.storage.resolve.query({ uri });
|
|
10526
10602
|
return UnsignedVCValidator.or(VCValidator).or(VPValidator).or(JWEValidator).or(ConsentFlowContractValidator).or(ConsentFlowTermsValidator).parseAsync(result);
|