@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
package/dist/lcn-plugin.esm.js
CHANGED
|
@@ -13515,10 +13515,18 @@ var UnsignedClrCredentialValidator = UnsignedVCValidator.extend({
|
|
|
13515
13515
|
var ClrCredentialValidator = UnsignedClrCredentialValidator.extend({
|
|
13516
13516
|
proof: ProofValidator.or(ProofValidator.array())
|
|
13517
13517
|
});
|
|
13518
|
+
var StatusCheckEntryValidator = external_exports.object({
|
|
13519
|
+
entryType: external_exports.string(),
|
|
13520
|
+
statusPurpose: external_exports.string(),
|
|
13521
|
+
isSet: external_exports.boolean(),
|
|
13522
|
+
statusListCredential: external_exports.string().optional(),
|
|
13523
|
+
statusListIndex: external_exports.string().optional()
|
|
13524
|
+
});
|
|
13518
13525
|
var VerificationCheckValidator = external_exports.object({
|
|
13519
13526
|
checks: external_exports.string().array(),
|
|
13520
13527
|
warnings: external_exports.string().array(),
|
|
13521
|
-
errors: external_exports.string().array()
|
|
13528
|
+
errors: external_exports.string().array(),
|
|
13529
|
+
status: StatusCheckEntryValidator.array().optional()
|
|
13522
13530
|
});
|
|
13523
13531
|
var VerificationStatusValidator = external_exports.enum(["Success", "Failed", "Error"]);
|
|
13524
13532
|
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
|
@@ -14921,9 +14929,31 @@ var AuthSessionError = (_a2 = class extends Error {
|
|
|
14921
14929
|
this.name = "AuthSessionError";
|
|
14922
14930
|
}
|
|
14923
14931
|
}, __name(_a2, "AuthSessionError"), __name2(_a2, "AuthSessionError"), _a2);
|
|
14932
|
+
var BITSTRING_STATUS_PURPOSES = ["revocation", "suspension"];
|
|
14933
|
+
var BitstringStatusPurposeValidator = external_exports.enum(BITSTRING_STATUS_PURPOSES);
|
|
14934
|
+
var BitstringStatusListEntryValidator = external_exports.object({
|
|
14935
|
+
id: external_exports.string().optional(),
|
|
14936
|
+
type: external_exports.literal("BitstringStatusListEntry"),
|
|
14937
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
14938
|
+
statusListIndex: external_exports.string(),
|
|
14939
|
+
statusListCredential: external_exports.string()
|
|
14940
|
+
});
|
|
14941
|
+
var AllocatedBitstringStatusListEntryValidator = BitstringStatusListEntryValidator.extend({
|
|
14942
|
+
id: external_exports.string()
|
|
14943
|
+
});
|
|
14944
|
+
var BitstringStatusListCredentialSubjectValidator = external_exports.object({
|
|
14945
|
+
id: external_exports.string().optional(),
|
|
14946
|
+
type: external_exports.literal("BitstringStatusList"),
|
|
14947
|
+
statusPurpose: BitstringStatusPurposeValidator,
|
|
14948
|
+
encodedList: external_exports.string()
|
|
14949
|
+
});
|
|
14950
|
+
var AllocateCredentialStatusInputValidator = external_exports.object({
|
|
14951
|
+
statusPurposes: external_exports.array(BitstringStatusPurposeValidator).optional(),
|
|
14952
|
+
listSize: external_exports.number().int().positive().optional()
|
|
14953
|
+
}).default({});
|
|
14924
14954
|
|
|
14925
14955
|
// src/plugin.ts
|
|
14926
|
-
import { isVC2Format } from "@learncard/helpers";
|
|
14956
|
+
import { getCredentialStatusArray, isVC2Format } from "@learncard/helpers";
|
|
14927
14957
|
|
|
14928
14958
|
// ../../../node_modules/.pnpm/mustache@4.2.0/node_modules/mustache/mustache.mjs
|
|
14929
14959
|
var objectToString = Object.prototype.toString;
|
|
@@ -15454,6 +15484,27 @@ var appendTemplateEvidence = /* @__PURE__ */ __name((boost, templateData, allowA
|
|
|
15454
15484
|
var hasDid = /* @__PURE__ */ __name((profile) => {
|
|
15455
15485
|
return !!profile && "did" in profile && typeof profile.did === "string" && profile.did.length > 0;
|
|
15456
15486
|
}, "hasDid");
|
|
15487
|
+
var appendNetworkCredentialStatus = /* @__PURE__ */ __name(async (client, credential, statusPurposes = ["revocation"]) => {
|
|
15488
|
+
if (!isVC2Format(credential)) return credential;
|
|
15489
|
+
const existingStatuses = getCredentialStatusArray(credential);
|
|
15490
|
+
const missingPurposes = statusPurposes.filter((statusPurpose) => {
|
|
15491
|
+
return !existingStatuses.some(
|
|
15492
|
+
(status) => status.type === "BitstringStatusListEntry" && status.statusPurpose === statusPurpose
|
|
15493
|
+
);
|
|
15494
|
+
});
|
|
15495
|
+
if (missingPurposes.length === 0) return credential;
|
|
15496
|
+
const entries = await client.boost.allocateCredentialStatus.mutate({
|
|
15497
|
+
statusPurposes: missingPurposes
|
|
15498
|
+
});
|
|
15499
|
+
const credentialStatuses = [...existingStatuses, ...entries];
|
|
15500
|
+
credential.credentialStatus = credentialStatuses.length === 1 ? credentialStatuses[0] : credentialStatuses;
|
|
15501
|
+
return credential;
|
|
15502
|
+
}, "appendNetworkCredentialStatus");
|
|
15503
|
+
var issueCredentialWithNetworkStatus = /* @__PURE__ */ __name(async (learnCard, client, credential, statusPurposes) => {
|
|
15504
|
+
return learnCard.invoke.issueCredential(
|
|
15505
|
+
await appendNetworkCredentialStatus(client, credential, statusPurposes)
|
|
15506
|
+
);
|
|
15507
|
+
}, "issueCredentialWithNetworkStatus");
|
|
15457
15508
|
async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, options) {
|
|
15458
15509
|
const apiToken = typeof apiTokenOrOptions === "string" ? apiTokenOrOptions : void 0;
|
|
15459
15510
|
const guardianApprovalGetter = (typeof apiTokenOrOptions === "object" ? apiTokenOrOptions?.guardianApprovalGetter : void 0) ?? options?.guardianApprovalGetter;
|
|
@@ -15833,7 +15884,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
15833
15884
|
const myProfile = await client.profile.getProfile.query();
|
|
15834
15885
|
const issuerDid = myProfile?.did || await client.utilities.getDid.query();
|
|
15835
15886
|
const issuerDisplayName = myProfile?.displayName || "Unknown Issuer";
|
|
15836
|
-
const signedCredential = await
|
|
15887
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
15888
|
+
_learnCard,
|
|
15889
|
+
client,
|
|
15890
|
+
vc
|
|
15891
|
+
);
|
|
15837
15892
|
const didAuthJwt = await _learnCard.invoke.getDidAuthVp({
|
|
15838
15893
|
proofFormat: "jwt",
|
|
15839
15894
|
challenge: `inbox-federation-${crypto.randomUUID()}`
|
|
@@ -16171,10 +16226,28 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16171
16226
|
if (result) await _learnCard.invoke.clearDidWebCache?.();
|
|
16172
16227
|
return result;
|
|
16173
16228
|
}, "removeBoostAdmin"),
|
|
16229
|
+
allocateCredentialStatus: /* @__PURE__ */ __name(async (_learnCard, options2 = {}) => {
|
|
16230
|
+
await ensureUser();
|
|
16231
|
+
return client.boost.allocateCredentialStatus.mutate(options2);
|
|
16232
|
+
}, "allocateCredentialStatus"),
|
|
16174
16233
|
revokeBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16175
16234
|
await ensureUser();
|
|
16176
16235
|
return client.boost.revokeBoostRecipient.mutate({ boostUri, recipientProfileId });
|
|
16177
16236
|
}, "revokeBoostRecipient"),
|
|
16237
|
+
suspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16238
|
+
await ensureUser();
|
|
16239
|
+
return client.boost.suspendBoostRecipient.mutate({
|
|
16240
|
+
boostUri,
|
|
16241
|
+
recipientProfileId
|
|
16242
|
+
});
|
|
16243
|
+
}, "suspendBoostRecipient"),
|
|
16244
|
+
unsuspendBoostRecipient: /* @__PURE__ */ __name(async (_learnCard, boostUri, recipientProfileId) => {
|
|
16245
|
+
await ensureUser();
|
|
16246
|
+
return client.boost.unsuspendBoostRecipient.mutate({
|
|
16247
|
+
boostUri,
|
|
16248
|
+
recipientProfileId
|
|
16249
|
+
});
|
|
16250
|
+
}, "unsuspendBoostRecipient"),
|
|
16178
16251
|
deleteBoost: /* @__PURE__ */ __name(async (_learnCard, uri) => {
|
|
16179
16252
|
await ensureUser();
|
|
16180
16253
|
return client.boost.deleteBoost.mutate({ uri });
|
|
@@ -16223,7 +16296,13 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16223
16296
|
if (typeof options2 === "object" && options2.overideFn) {
|
|
16224
16297
|
boost = options2.overideFn(boost);
|
|
16225
16298
|
}
|
|
16226
|
-
const
|
|
16299
|
+
const statusPurposes = typeof options2 === "object" ? options2.statusPurposes : void 0;
|
|
16300
|
+
const vc = await issueCredentialWithNetworkStatus(
|
|
16301
|
+
_learnCard,
|
|
16302
|
+
client,
|
|
16303
|
+
boost,
|
|
16304
|
+
statusPurposes
|
|
16305
|
+
);
|
|
16227
16306
|
if (typeof options2 === "object" && !options2.encrypt || !options2) {
|
|
16228
16307
|
return client.boost.sendBoost.mutate({
|
|
16229
16308
|
profileId,
|
|
@@ -16331,7 +16410,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16331
16410
|
if (boost.type?.includes("BoostCredential")) {
|
|
16332
16411
|
boost.boostId = input.templateUri;
|
|
16333
16412
|
}
|
|
16334
|
-
const signedCredential = await
|
|
16413
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16414
|
+
_learnCard,
|
|
16415
|
+
client,
|
|
16416
|
+
boost
|
|
16417
|
+
);
|
|
16335
16418
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16336
16419
|
recipient,
|
|
16337
16420
|
signedCredential,
|
|
@@ -16405,7 +16488,11 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16405
16488
|
}
|
|
16406
16489
|
if (boost?.type?.includes("BoostCredential"))
|
|
16407
16490
|
boost.boostId = input.templateUri;
|
|
16408
|
-
const signedCredential = await
|
|
16491
|
+
const signedCredential = await issueCredentialWithNetworkStatus(
|
|
16492
|
+
_learnCard,
|
|
16493
|
+
client,
|
|
16494
|
+
boost
|
|
16495
|
+
);
|
|
16409
16496
|
if (isDid && recipient.startsWith("did:web:")) {
|
|
16410
16497
|
const credentialUri = await _learnCard.invoke.sendCredential(
|
|
16411
16498
|
recipient,
|
|
@@ -16530,6 +16617,12 @@ async function getLearnCardNetworkPlugin(learnCard, url2, apiTokenOrOptions, opt
|
|
|
16530
16617
|
categories
|
|
16531
16618
|
});
|
|
16532
16619
|
}, "syncCredentialsToContract"),
|
|
16620
|
+
deleteCredentialFromAllContracts: /* @__PURE__ */ __name(async (_learnCard, deletedUris) => {
|
|
16621
|
+
await ensureUser();
|
|
16622
|
+
return client.contracts.deleteCredentialFromAllContracts.mutate({
|
|
16623
|
+
deletedUris
|
|
16624
|
+
});
|
|
16625
|
+
}, "deleteCredentialFromAllContracts"),
|
|
16533
16626
|
sendAiInsightsContractRequest: /* @__PURE__ */ __name(async (_learnCard, contractUri, targetProfileId, shareLink) => {
|
|
16534
16627
|
await ensureUser();
|
|
16535
16628
|
return client.contracts.sendAiInsightsContractRequest.mutate({
|
|
@@ -17131,14 +17224,28 @@ var getVerifyBoostPlugin = /* @__PURE__ */ __name(async (learnCard, trustedBoost
|
|
|
17131
17224
|
const verifyBoostCredential = await learnCard.invoke.verifyCredential(
|
|
17132
17225
|
boostCredential
|
|
17133
17226
|
);
|
|
17227
|
+
const boostCredentialErrors = verifyBoostCredential.errors ?? [];
|
|
17228
|
+
if (verifyBoostCredential.status?.length) {
|
|
17229
|
+
verificationCheck.status = [
|
|
17230
|
+
...verificationCheck.status ?? [],
|
|
17231
|
+
...verifyBoostCredential.status
|
|
17232
|
+
];
|
|
17233
|
+
}
|
|
17134
17234
|
if (!boostCredential?.boostId && !credential?.boostId) {
|
|
17135
17235
|
verificationCheck.warnings.push(
|
|
17136
17236
|
"Boost Authenticity could not be verified: Boost ID metadata is missing."
|
|
17137
17237
|
);
|
|
17138
17238
|
}
|
|
17139
|
-
if (
|
|
17239
|
+
if (boostCredentialErrors.length > 0) {
|
|
17240
|
+
if (boostCredentialErrors.some(
|
|
17241
|
+
(error46) => /revoked|suspend|status/i.test(error46)
|
|
17242
|
+
)) {
|
|
17243
|
+
verificationCheck.checks = verificationCheck.checks.filter(
|
|
17244
|
+
(check2) => check2 !== "status"
|
|
17245
|
+
);
|
|
17246
|
+
}
|
|
17140
17247
|
verificationCheck.errors = [
|
|
17141
|
-
...
|
|
17248
|
+
...boostCredentialErrors,
|
|
17142
17249
|
...verificationCheck.errors || [],
|
|
17143
17250
|
"Boost Credential could not be verified."
|
|
17144
17251
|
];
|