@learncard/network-plugin 2.11.5 → 2.12.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.
- package/dist/lcn-plugin.cjs.development.js +114 -7
- package/dist/lcn-plugin.cjs.development.js.map +3 -3
- package/dist/lcn-plugin.cjs.production.min.js +7 -7
- package/dist/lcn-plugin.cjs.production.min.js.map +3 -3
- package/dist/lcn-plugin.esm.js +115 -8
- package/dist/lcn-plugin.esm.js.map +3 -3
- package/dist/plugin.d.ts.map +1 -1
- package/dist/types.d.ts +14 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -13536,10 +13536,18 @@ var UnsignedClrCredentialValidator = UnsignedVCValidator.extend({
|
|
|
13536
13536
|
var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
|
|
13537
13537
|
proof: ProofValidator.or(ProofValidator.array())
|
|
13538
13538
|
});
|
|
13539
|
+
var StatusCheckEntryValidator = external_exports.object({
|
|
13540
|
+
entryType: external_exports.string(),
|
|
13541
|
+
statusPurpose: external_exports.string(),
|
|
13542
|
+
isSet: external_exports.boolean(),
|
|
13543
|
+
statusListCredential: external_exports.string().optional(),
|
|
13544
|
+
statusListIndex: external_exports.string().optional()
|
|
13545
|
+
});
|
|
13539
13546
|
var VerificationCheckValidator = external_exports.object({
|
|
13540
13547
|
checks: external_exports.string().array(),
|
|
13541
13548
|
warnings: external_exports.string().array(),
|
|
13542
|
-
errors: external_exports.string().array()
|
|
13549
|
+
errors: external_exports.string().array(),
|
|
13550
|
+
status: StatusCheckEntryValidator.array().optional()
|
|
13543
13551
|
});
|
|
13544
13552
|
var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
|
|
13545
13553
|
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
|
@@ -14942,6 +14950,28 @@ var AuthSessionError = (_a2 = class extends Error {
|
|
|
14942
14950
|
this.name = "AuthSessionError";
|
|
14943
14951
|
}
|
|
14944
14952
|
}, __name(_a2, "AuthSessionError"), __name2(_a2, "AuthSessionError"), _a2);
|
|
14953
|
+
var BITSTRING_STATUS_PURPOSES = ["revocation", "suspension"];
|
|
14954
|
+
var BitstringStatusPurposeValidator = external_exports.enum(BITSTRING_STATUS_PURPOSES);
|
|
14955
|
+
var BitstringStatusListEntryValidator = external_exports.object({
|
|
14956
|
+
id: external_exports.string().optional(),
|
|
14957
|
+
type: external_exports.literal("BitstringStatusListEntry"),
|
|
14958
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
14959
|
+
statusListIndex: external_exports.string(),
|
|
14960
|
+
statusListCredential: external_exports.string()
|
|
14961
|
+
});
|
|
14962
|
+
var AllocatedBitstringStatusListEntryValidator = BitstringStatusListEntryValidator.extend({
|
|
14963
|
+
id: external_exports.string()
|
|
14964
|
+
});
|
|
14965
|
+
var BitstringStatusListCredentialSubjectValidator = external_exports.object({
|
|
14966
|
+
id: external_exports.string().optional(),
|
|
14967
|
+
type: external_exports.literal("BitstringStatusList"),
|
|
14968
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
14969
|
+
encodedList: external_exports.string()
|
|
14970
|
+
});
|
|
14971
|
+
var AllocateCredentialStatusInputValidator = external_exports.object({
|
|
14972
|
+
statusPurposes: external_exports.array(BitstringStatusPurposeValidator).optional(),
|
|
14973
|
+
listSize: external_exports.number().int().positive().optional()
|
|
14974
|
+
}).default({});
|
|
14945
14975
|
|
|
14946
14976
|
// src/plugin.ts
|
|
14947
14977
|
var import_helpers = require("@learncard/helpers");
|
|
@@ -15475,6 +15505,27 @@ var appendTemplateEvidence = /* @__PURE__ */ __name((boost, templateData, allowA
|
|
|
15475
15505
|
var hasDid = /* @__PURE__ */ __name((profile) => {
|
|
15476
15506
|
return !!profile && "did" in profile && typeof profile.did === "string" && profile.did.length > 0;
|
|
15477
15507
|
}, "hasDid");
|
|
15508
|
+
var appendNetworkCredentialStatus = /* @__PURE__ */ __name(async (client, credential, statusPurposes = ["revocation"]) => {
|
|
15509
|
+
if (!(0, import_helpers.isVC2Format)(credential)) return credential;
|
|
15510
|
+
const existingStatuses = (0, import_helpers.getCredentialStatusArray)(credential);
|
|
15511
|
+
const missingPurposes = statusPurposes.filter((statusPurpose) => {
|
|
15512
|
+
return !existingStatuses.some(
|
|
15513
|
+
(status) => status.type === "BitstringStatusListEntry" && status.statusPurpose === statusPurpose
|
|
15514
|
+
);
|
|
15515
|
+
});
|
|
15516
|
+
if (missingPurposes.length === 0) return credential;
|
|
15517
|
+
const entries = await client.boost.allocateCredentialStatus.mutate({
|
|
15518
|
+
statusPurposes: missingPurposes
|
|
15519
|
+
});
|
|
15520
|
+
const credentialStatuses = [...existingStatuses, ...entries];
|
|
15521
|
+
credential.credentialStatus = credentialStatuses.length === 1 ? credentialStatuses[0] : credentialStatuses;
|
|
15522
|
+
return credential;
|
|
15523
|
+
}, "appendNetworkCredentialStatus");
|
|
15524
|
+
var issueCredentialWithNetworkStatus = /* @__PURE__ */ __name(async (learnCard, client, credential, statusPurposes) => {
|
|
15525
|
+
return learnCard.invoke.issueCredential(
|
|
15526
|
+
await appendNetworkCredentialStatus(client, credential, statusPurposes)
|
|
15527
|
+
);
|
|
15528
|
+
}, "issueCredentialWithNetworkStatus");
|
|
15478
15529
|
async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, options) {
|
|
15479
15530
|
const apiToken = typeof apiTokenOrOptions === "string" ? apiTokenOrOptions : void 0;
|
|
15480
15531
|
const guardianApprovalGetter = (typeof apiTokenOrOptions === "object" ? apiTokenOrOptions?.guardianApprovalGetter : void 0) ?? options?.guardianApprovalGetter;
|
|
@@ -15854,7 +15905,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
15854
15905
|
const myProfile = await client.profile.getProfile.query();
|
|
15855
15906
|
const issuerDid = myProfile?.did || await client.utilities.getDid.query();
|
|
15856
15907
|
const issuerDisplayName = myProfile?.displayName || "Unknown Issuer";
|
|
15857
|
-
const signedCredential = await
|
|
15908
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
15909
|
+
_learnCard,
|
|
15910
|
+
client,
|
|
15911
|
+
vc
|
|
15912
|
+
);
|
|
15858
15913
|
const didAuthJwt = await _learnCard.invoke.getDidAuthVp({
|
|
15859
15914
|
proofFormat: "jwt",
|
|
15860
15915
|
challenge: `inbox-federation-${crypto.randomUUID()}`
|
|
@@ -16192,10 +16247,28 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16192
16247
|
if (result) await _learnCard.invoke.clearDidWebCache?.();
|
|
16193
16248
|
return result;
|
|
16194
16249
|
}, "removeBoostAdmin"),
|
|
16250
|
+
allocateCredentialStatus: /* @__PURE__ */ __name(async (_learnCard, options2 = {}) => {
|
|
16251
|
+
await ensureUser();
|
|
16252
|
+
return client.boost.allocateCredentialStatus.mutate(options2);
|
|
16253
|
+
}, "allocateCredentialStatus"),
|
|
16195
16254
|
revokeBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16196
16255
|
await ensureUser();
|
|
16197
16256
|
return client.boost.revokeBoostRecipient.mutate({ boostUri, recipientProfileId });
|
|
16198
16257
|
}, "revokeBoostRecipient"),
|
|
16258
|
+
suspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16259
|
+
await ensureUser();
|
|
16260
|
+
return client.boost.suspendBoostRecipient.mutate({
|
|
16261
|
+
boostUri,
|
|
16262
|
+
recipientProfileId
|
|
16263
|
+
});
|
|
16264
|
+
}, "suspendBoostRecipient"),
|
|
16265
|
+
unsuspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16266
|
+
await ensureUser();
|
|
16267
|
+
return client.boost.unsuspendBoostRecipient.mutate({
|
|
16268
|
+
boostUri,
|
|
16269
|
+
recipientProfileId
|
|
16270
|
+
});
|
|
16271
|
+
}, "unsuspendBoostRecipient"),
|
|
16199
16272
|
deleteBoost: /* @__PURE__ */ __name(async (_learnCard, uri) => {
|
|
16200
16273
|
await ensureUser();
|
|
16201
16274
|
return client.boost.deleteBoost.mutate({ uri });
|
|
@@ -16244,7 +16317,13 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16244
16317
|
if (typeof options2 === "object" && options2.overideFn) {
|
|
16245
16318
|
boost = options2.overideFn(boost);
|
|
16246
16319
|
}
|
|
16247
|
-
const
|
|
16320
|
+
const statusPurposes = typeof options2 === "object" ? options2.statusPurposes : void 0;
|
|
16321
|
+
const vc = await issueCredentialWithNetworkStatus(
|
|
16322
|
+
_learnCard,
|
|
16323
|
+
client,
|
|
16324
|
+
boost,
|
|
16325
|
+
statusPurposes
|
|
16326
|
+
);
|
|
16248
16327
|
if (typeof options2 === "object" && !options2.encrypt || !options2) {
|
|
16249
16328
|
return client.boost.sendBoost.mutate({
|
|
16250
16329
|
profileId,
|
|
@@ -16352,7 +16431,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16352
16431
|
if (boost.type?.includes("BoostCredential")) {
|
|
16353
16432
|
boost.boostId = input.templateUri;
|
|
16354
16433
|
}
|
|
16355
|
-
const signedCredential = await
|
|
16434
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16435
|
+
_learnCard,
|
|
16436
|
+
client,
|
|
16437
|
+
boost
|
|
16438
|
+
);
|
|
16356
16439
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16357
16440
|
recipient,
|
|
16358
16441
|
signedCredential,
|
|
@@ -16426,7 +16509,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16426
16509
|
}
|
|
16427
16510
|
if (boost?.type?.includes("BoostCredential"))
|
|
16428
16511
|
boost.boostId = input.templateUri;
|
|
16429
|
-
const signedCredential = await
|
|
16512
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16513
|
+
_learnCard,
|
|
16514
|
+
client,
|
|
16515
|
+
boost
|
|
16516
|
+
);
|
|
16430
16517
|
if (isDid && recipient.startsWith("did:web:")) {
|
|
16431
16518
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16432
16519
|
recipient,
|
|
@@ -16551,6 +16638,12 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16551
16638
|
categories
|
|
16552
16639
|
});
|
|
16553
16640
|
}, "syncCredentialsToContract"),
|
|
16641
|
+
deleteCredentialFromAllContracts: /* @__PURE__ */ __name(async (_learnCard, deletedUris) => {
|
|
16642
|
+
await ensureUser();
|
|
16643
|
+
return client.contracts.deleteCredentialFromAllContracts.mutate({
|
|
16644
|
+
deletedUris
|
|
16645
|
+
});
|
|
16646
|
+
}, "deleteCredentialFromAllContracts"),
|
|
16554
16647
|
sendAiInsightsContractRequest: /* @__PURE__ */ __name(async (_learnCard, contractUri, targetProfileId, shareLink) => {
|
|
16555
16648
|
await ensureUser();
|
|
16556
16649
|
return client.contracts.sendAiInsightsContractRequest.mutate({
|
|
@@ -17152,14 +17245,28 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
|
|
|
17152
17245
|
const verifyBoostCredential = await learnCard.invoke.verifyCredential(
|
|
17153
17246
|
boostCredential
|
|
17154
17247
|
);
|
|
17248
|
+
const boostCredentialErrors = verifyBoostCredential.errors ?? [];
|
|
17249
|
+
if (verifyBoostCredential.status?.length) {
|
|
17250
|
+
verificationCheck.status = [
|
|
17251
|
+
...verificationCheck.status ?? [],
|
|
17252
|
+
...verifyBoostCredential.status
|
|
17253
|
+
];
|
|
17254
|
+
}
|
|
17155
17255
|
if (!boostCredential?.boostId && !credential?.boostId) {
|
|
17156
17256
|
verificationCheck.warnings.push(
|
|
17157
17257
|
"Boost Authenticity could not be verified: Boost ID metadata is missing."
|
|
17158
17258
|
);
|
|
17159
17259
|
}
|
|
17160
|
-
if (
|
|
17260
|
+
if (boostCredentialErrors.length > 0) {
|
|
17261
|
+
if (boostCredentialErrors.some(
|
|
17262
|
+
(error46) => /revoked|suspend|status/i.test(error46)
|
|
17263
|
+
)) {
|
|
17264
|
+
verificationCheck.checks = verificationCheck.checks.filter(
|
|
17265
|
+
(check2) => check2 !== "status"
|
|
17266
|
+
);
|
|
17267
|
+
}
|
|
17161
17268
|
verificationCheck.errors = [
|
|
17162
|
-
...
|
|
17269
|
+
...boostCredentialErrors,
|
|
17163
17270
|
...verificationCheck.errors || [],
|
|
17164
17271
|
"Boost Credential could not be verified."
|
|
17165
17272
|
];
|