@learncard/network-plugin 2.11.5 → 2.12.1
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 +156 -8
- 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 +157 -9
- 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
|
@@ -13205,6 +13205,19 @@ var VC2EvidenceValidator = external_exports.object({
|
|
|
13205
13205
|
genre: external_exports.string().optional(),
|
|
13206
13206
|
audience: external_exports.string().optional()
|
|
13207
13207
|
}).catchall(external_exports.any());
|
|
13208
|
+
var TemplateRenderMethodValidator = external_exports.object({
|
|
13209
|
+
type: external_exports.literal("TemplateRenderMethod"),
|
|
13210
|
+
renderSuite: external_exports.string(),
|
|
13211
|
+
template: external_exports.string(),
|
|
13212
|
+
renderProperty: external_exports.array(external_exports.string()).optional(),
|
|
13213
|
+
outputPreference: external_exports.object({
|
|
13214
|
+
mediaType: external_exports.string()
|
|
13215
|
+
}).optional()
|
|
13216
|
+
});
|
|
13217
|
+
var RenderMethodValidator = external_exports.union([
|
|
13218
|
+
TemplateRenderMethodValidator,
|
|
13219
|
+
external_exports.record(external_exports.string(), external_exports.any())
|
|
13220
|
+
]);
|
|
13208
13221
|
var UnsignedVCValidator = external_exports.object({
|
|
13209
13222
|
"@context": ContextValidator,
|
|
13210
13223
|
id: external_exports.string().optional(),
|
|
@@ -13228,7 +13241,8 @@ var UnsignedVCValidator = external_exports.object({
|
|
|
13228
13241
|
validUntil: external_exports.string().optional(),
|
|
13229
13242
|
status: CredentialStatusValidator.or(CredentialStatusValidator.array()).optional(),
|
|
13230
13243
|
termsOfUse: TermsOfUseValidator.or(TermsOfUseValidator.array()).optional(),
|
|
13231
|
-
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional()
|
|
13244
|
+
evidence: external_exports.union([VC2EvidenceValidator, external_exports.array(VC2EvidenceValidator)]).optional(),
|
|
13245
|
+
renderMethod: external_exports.union([RenderMethodValidator, external_exports.array(RenderMethodValidator)]).optional()
|
|
13232
13246
|
}).catchall(external_exports.any());
|
|
13233
13247
|
var ProofValidator = external_exports.object({
|
|
13234
13248
|
type: external_exports.string(),
|
|
@@ -13536,10 +13550,45 @@ var UnsignedClrCredentialValidator = UnsignedVCValidator.extend({
|
|
|
13536
13550
|
var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
|
|
13537
13551
|
proof: ProofValidator.or(ProofValidator.array())
|
|
13538
13552
|
});
|
|
13553
|
+
var StatusCheckEntryValidator = external_exports.object({
|
|
13554
|
+
/**
|
|
13555
|
+
* The `credentialStatus.type` as it appeared on the credential.
|
|
13556
|
+
* One of `BitstringStatusListEntry`, `StatusList2021Entry`,
|
|
13557
|
+
* `RevocationList2020Status`, or any future custom status type.
|
|
13558
|
+
*/
|
|
13559
|
+
entryType: external_exports.string(),
|
|
13560
|
+
/**
|
|
13561
|
+
* The claimed purpose of the entry. Standard values are
|
|
13562
|
+
* `"revocation"` and `"suspension"`; the spec allows arbitrary
|
|
13563
|
+
* strings.
|
|
13564
|
+
*/
|
|
13565
|
+
statusPurpose: external_exports.string(),
|
|
13566
|
+
/**
|
|
13567
|
+
* Whether the bit at the credential's index in the status list
|
|
13568
|
+
* bitstring was set.
|
|
13569
|
+
*/
|
|
13570
|
+
isSet: external_exports.boolean(),
|
|
13571
|
+
/** URL of the status list credential, when known. */
|
|
13572
|
+
statusListCredential: external_exports.string().optional(),
|
|
13573
|
+
/** Original (string) index within the status list. */
|
|
13574
|
+
statusListIndex: external_exports.string().optional()
|
|
13575
|
+
});
|
|
13539
13576
|
var VerificationCheckValidator = external_exports.object({
|
|
13540
13577
|
checks: external_exports.string().array(),
|
|
13541
13578
|
warnings: external_exports.string().array(),
|
|
13542
|
-
errors: external_exports.string().array()
|
|
13579
|
+
errors: external_exports.string().array(),
|
|
13580
|
+
/**
|
|
13581
|
+
* Per-entry results for the `credentialStatus` check, populated
|
|
13582
|
+
* by `@learncard/didkit-plugin` when the verified credential
|
|
13583
|
+
* carries one or more `credentialStatus` entries. Empty / absent
|
|
13584
|
+
* for credentials without a status entry.
|
|
13585
|
+
*
|
|
13586
|
+
* Marked `.optional()` because the underlying `ssi-ldp`
|
|
13587
|
+
* serializer omits the field when empty (`skip_serializing_if`),
|
|
13588
|
+
* so older WASM builds that pre-date the structured-status
|
|
13589
|
+
* change still validate against this schema.
|
|
13590
|
+
*/
|
|
13591
|
+
status: StatusCheckEntryValidator.array().optional()
|
|
13543
13592
|
});
|
|
13544
13593
|
var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
|
|
13545
13594
|
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
|
@@ -14942,6 +14991,28 @@ var AuthSessionError = (_a2 = class extends Error {
|
|
|
14942
14991
|
this.name = "AuthSessionError";
|
|
14943
14992
|
}
|
|
14944
14993
|
}, __name(_a2, "AuthSessionError"), __name2(_a2, "AuthSessionError"), _a2);
|
|
14994
|
+
var BITSTRING_STATUS_PURPOSES = ["revocation", "suspension"];
|
|
14995
|
+
var BitstringStatusPurposeValidator = external_exports.enum(BITSTRING_STATUS_PURPOSES);
|
|
14996
|
+
var BitstringStatusListEntryValidator = external_exports.object({
|
|
14997
|
+
id: external_exports.string().optional(),
|
|
14998
|
+
type: external_exports.literal("BitstringStatusListEntry"),
|
|
14999
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
15000
|
+
statusListIndex: external_exports.string(),
|
|
15001
|
+
statusListCredential: external_exports.string()
|
|
15002
|
+
});
|
|
15003
|
+
var AllocatedBitstringStatusListEntryValidator = BitstringStatusListEntryValidator.extend({
|
|
15004
|
+
id: external_exports.string()
|
|
15005
|
+
});
|
|
15006
|
+
var BitstringStatusListCredentialSubjectValidator = external_exports.object({
|
|
15007
|
+
id: external_exports.string().optional(),
|
|
15008
|
+
type: external_exports.literal("BitstringStatusList"),
|
|
15009
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
15010
|
+
encodedList: external_exports.string()
|
|
15011
|
+
});
|
|
15012
|
+
var AllocateCredentialStatusInputValidator = external_exports.object({
|
|
15013
|
+
statusPurposes: external_exports.array(BitstringStatusPurposeValidator).optional(),
|
|
15014
|
+
listSize: external_exports.number().int().positive().optional()
|
|
15015
|
+
}).default({});
|
|
14945
15016
|
|
|
14946
15017
|
// src/plugin.ts
|
|
14947
15018
|
var import_helpers = require("@learncard/helpers");
|
|
@@ -15475,6 +15546,27 @@ var appendTemplateEvidence = /* @__PURE__ */ __name((boost, templateData, allowA
|
|
|
15475
15546
|
var hasDid = /* @__PURE__ */ __name((profile) => {
|
|
15476
15547
|
return !!profile && "did" in profile && typeof profile.did === "string" && profile.did.length > 0;
|
|
15477
15548
|
}, "hasDid");
|
|
15549
|
+
var appendNetworkCredentialStatus = /* @__PURE__ */ __name(async (client, credential, statusPurposes = ["revocation"]) => {
|
|
15550
|
+
if (!(0, import_helpers.isVC2Format)(credential)) return credential;
|
|
15551
|
+
const existingStatuses = (0, import_helpers.getCredentialStatusArray)(credential);
|
|
15552
|
+
const missingPurposes = statusPurposes.filter((statusPurpose) => {
|
|
15553
|
+
return !existingStatuses.some(
|
|
15554
|
+
(status) => status.type === "BitstringStatusListEntry" && status.statusPurpose === statusPurpose
|
|
15555
|
+
);
|
|
15556
|
+
});
|
|
15557
|
+
if (missingPurposes.length === 0) return credential;
|
|
15558
|
+
const entries = await client.boost.allocateCredentialStatus.mutate({
|
|
15559
|
+
statusPurposes: missingPurposes
|
|
15560
|
+
});
|
|
15561
|
+
const credentialStatuses = [...existingStatuses, ...entries];
|
|
15562
|
+
credential.credentialStatus = credentialStatuses.length === 1 ? credentialStatuses[0] : credentialStatuses;
|
|
15563
|
+
return credential;
|
|
15564
|
+
}, "appendNetworkCredentialStatus");
|
|
15565
|
+
var issueCredentialWithNetworkStatus = /* @__PURE__ */ __name(async (learnCard, client, credential, statusPurposes) => {
|
|
15566
|
+
return learnCard.invoke.issueCredential(
|
|
15567
|
+
await appendNetworkCredentialStatus(client, credential, statusPurposes)
|
|
15568
|
+
);
|
|
15569
|
+
}, "issueCredentialWithNetworkStatus");
|
|
15478
15570
|
async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, options) {
|
|
15479
15571
|
const apiToken = typeof apiTokenOrOptions === "string" ? apiTokenOrOptions : void 0;
|
|
15480
15572
|
const guardianApprovalGetter = (typeof apiTokenOrOptions === "object" ? apiTokenOrOptions?.guardianApprovalGetter : void 0) ?? options?.guardianApprovalGetter;
|
|
@@ -15854,7 +15946,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
15854
15946
|
const myProfile = await client.profile.getProfile.query();
|
|
15855
15947
|
const issuerDid = myProfile?.did || await client.utilities.getDid.query();
|
|
15856
15948
|
const issuerDisplayName = myProfile?.displayName || "Unknown Issuer";
|
|
15857
|
-
const signedCredential = await
|
|
15949
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
15950
|
+
_learnCard,
|
|
15951
|
+
client,
|
|
15952
|
+
vc
|
|
15953
|
+
);
|
|
15858
15954
|
const didAuthJwt = await _learnCard.invoke.getDidAuthVp({
|
|
15859
15955
|
proofFormat: "jwt",
|
|
15860
15956
|
challenge: `inbox-federation-${crypto.randomUUID()}`
|
|
@@ -16192,10 +16288,28 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16192
16288
|
if (result) await _learnCard.invoke.clearDidWebCache?.();
|
|
16193
16289
|
return result;
|
|
16194
16290
|
}, "removeBoostAdmin"),
|
|
16291
|
+
allocateCredentialStatus: /* @__PURE__ */ __name(async (_learnCard, options2 = {}) => {
|
|
16292
|
+
await ensureUser();
|
|
16293
|
+
return client.boost.allocateCredentialStatus.mutate(options2);
|
|
16294
|
+
}, "allocateCredentialStatus"),
|
|
16195
16295
|
revokeBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16196
16296
|
await ensureUser();
|
|
16197
16297
|
return client.boost.revokeBoostRecipient.mutate({ boostUri, recipientProfileId });
|
|
16198
16298
|
}, "revokeBoostRecipient"),
|
|
16299
|
+
suspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16300
|
+
await ensureUser();
|
|
16301
|
+
return client.boost.suspendBoostRecipient.mutate({
|
|
16302
|
+
boostUri,
|
|
16303
|
+
recipientProfileId
|
|
16304
|
+
});
|
|
16305
|
+
}, "suspendBoostRecipient"),
|
|
16306
|
+
unsuspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16307
|
+
await ensureUser();
|
|
16308
|
+
return client.boost.unsuspendBoostRecipient.mutate({
|
|
16309
|
+
boostUri,
|
|
16310
|
+
recipientProfileId
|
|
16311
|
+
});
|
|
16312
|
+
}, "unsuspendBoostRecipient"),
|
|
16199
16313
|
deleteBoost: /* @__PURE__ */ __name(async (_learnCard, uri) => {
|
|
16200
16314
|
await ensureUser();
|
|
16201
16315
|
return client.boost.deleteBoost.mutate({ uri });
|
|
@@ -16244,7 +16358,13 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16244
16358
|
if (typeof options2 === "object" && options2.overideFn) {
|
|
16245
16359
|
boost = options2.overideFn(boost);
|
|
16246
16360
|
}
|
|
16247
|
-
const
|
|
16361
|
+
const statusPurposes = typeof options2 === "object" ? options2.statusPurposes : void 0;
|
|
16362
|
+
const vc = await issueCredentialWithNetworkStatus(
|
|
16363
|
+
_learnCard,
|
|
16364
|
+
client,
|
|
16365
|
+
boost,
|
|
16366
|
+
statusPurposes
|
|
16367
|
+
);
|
|
16248
16368
|
if (typeof options2 === "object" && !options2.encrypt || !options2) {
|
|
16249
16369
|
return client.boost.sendBoost.mutate({
|
|
16250
16370
|
profileId,
|
|
@@ -16352,7 +16472,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16352
16472
|
if (boost.type?.includes("BoostCredential")) {
|
|
16353
16473
|
boost.boostId = input.templateUri;
|
|
16354
16474
|
}
|
|
16355
|
-
const signedCredential = await
|
|
16475
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16476
|
+
_learnCard,
|
|
16477
|
+
client,
|
|
16478
|
+
boost
|
|
16479
|
+
);
|
|
16356
16480
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16357
16481
|
recipient,
|
|
16358
16482
|
signedCredential,
|
|
@@ -16426,7 +16550,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16426
16550
|
}
|
|
16427
16551
|
if (boost?.type?.includes("BoostCredential"))
|
|
16428
16552
|
boost.boostId = input.templateUri;
|
|
16429
|
-
const signedCredential = await
|
|
16553
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16554
|
+
_learnCard,
|
|
16555
|
+
client,
|
|
16556
|
+
boost
|
|
16557
|
+
);
|
|
16430
16558
|
if (isDid && recipient.startsWith("did:web:")) {
|
|
16431
16559
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16432
16560
|
recipient,
|
|
@@ -16551,6 +16679,12 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16551
16679
|
categories
|
|
16552
16680
|
});
|
|
16553
16681
|
}, "syncCredentialsToContract"),
|
|
16682
|
+
deleteCredentialFromAllContracts: /* @__PURE__ */ __name(async (_learnCard, deletedUris) => {
|
|
16683
|
+
await ensureUser();
|
|
16684
|
+
return client.contracts.deleteCredentialFromAllContracts.mutate({
|
|
16685
|
+
deletedUris
|
|
16686
|
+
});
|
|
16687
|
+
}, "deleteCredentialFromAllContracts"),
|
|
16554
16688
|
sendAiInsightsContractRequest: /* @__PURE__ */ __name(async (_learnCard, contractUri, targetProfileId, shareLink) => {
|
|
16555
16689
|
await ensureUser();
|
|
16556
16690
|
return client.contracts.sendAiInsightsContractRequest.mutate({
|
|
@@ -17152,14 +17286,28 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
|
|
|
17152
17286
|
const verifyBoostCredential = await learnCard.invoke.verifyCredential(
|
|
17153
17287
|
boostCredential
|
|
17154
17288
|
);
|
|
17289
|
+
const boostCredentialErrors = verifyBoostCredential.errors ?? [];
|
|
17290
|
+
if (verifyBoostCredential.status?.length) {
|
|
17291
|
+
verificationCheck.status = [
|
|
17292
|
+
...verificationCheck.status ?? [],
|
|
17293
|
+
...verifyBoostCredential.status
|
|
17294
|
+
];
|
|
17295
|
+
}
|
|
17155
17296
|
if (!boostCredential?.boostId && !credential?.boostId) {
|
|
17156
17297
|
verificationCheck.warnings.push(
|
|
17157
17298
|
"Boost Authenticity could not be verified: Boost ID metadata is missing."
|
|
17158
17299
|
);
|
|
17159
17300
|
}
|
|
17160
|
-
if (
|
|
17301
|
+
if (boostCredentialErrors.length > 0) {
|
|
17302
|
+
if (boostCredentialErrors.some(
|
|
17303
|
+
(error46) => /revoked|suspend|status/i.test(error46)
|
|
17304
|
+
)) {
|
|
17305
|
+
verificationCheck.checks = verificationCheck.checks.filter(
|
|
17306
|
+
(check2) => check2 !== "status"
|
|
17307
|
+
);
|
|
17308
|
+
}
|
|
17161
17309
|
verificationCheck.errors = [
|
|
17162
|
-
...
|
|
17310
|
+
...boostCredentialErrors,
|
|
17163
17311
|
...verificationCheck.errors || [],
|
|
17164
17312
|
"Boost Credential could not be verified."
|
|
17165
17313
|
];
|