@learncard/learn-cloud-plugin 2.3.25 → 2.3.27
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/{index.js → index.cjs} +2 -2
- package/dist/index.d.cts +3 -0
- package/dist/{learn-cloud-plugin.cjs.development.js → learn-cloud-plugin.cjs.development.cjs} +47 -14
- package/dist/{learn-cloud-plugin.cjs.development.js.map → learn-cloud-plugin.cjs.development.cjs.map} +3 -3
- package/dist/learn-cloud-plugin.cjs.production.min.cjs +56 -0
- package/dist/{learn-cloud-plugin.cjs.production.min.js.map → learn-cloud-plugin.cjs.production.min.cjs.map} +3 -3
- package/dist/learn-cloud-plugin.esm.js +47 -14
- package/dist/learn-cloud-plugin.esm.js.map +3 -3
- package/dist/plugin.d.ts.map +1 -1
- package/package.json +22 -9
- package/dist/learn-cloud-plugin.cjs.production.min.js +0 -56
|
@@ -6107,9 +6107,9 @@ var require_lib = __commonJS({
|
|
|
6107
6107
|
});
|
|
6108
6108
|
|
|
6109
6109
|
// src/plugin.ts
|
|
6110
|
-
var import_lodash = __toESM(require_lodash());
|
|
6110
|
+
var import_lodash = __toESM(require_lodash(), 1);
|
|
6111
6111
|
import { getClient } from "@learncard/learn-cloud-client";
|
|
6112
|
-
import { isEncrypted } from "@learncard/helpers";
|
|
6112
|
+
import { isEncrypted, resolveStorageReadResult } from "@learncard/helpers";
|
|
6113
6113
|
|
|
6114
6114
|
// ../../../node_modules/.pnpm/zod@4.1.13/node_modules/zod/v4/classic/external.js
|
|
6115
6115
|
var external_exports = {};
|
|
@@ -19640,6 +19640,17 @@ var CredentialFormatValidator = external_exports.enum([
|
|
|
19640
19640
|
"vc+sd-jwt",
|
|
19641
19641
|
"mso_mdoc"
|
|
19642
19642
|
]);
|
|
19643
|
+
var StoredCredentialEnvelopeValidator = external_exports.object({
|
|
19644
|
+
format: CredentialFormatValidator,
|
|
19645
|
+
data: external_exports.string()
|
|
19646
|
+
}).passthrough();
|
|
19647
|
+
var isStoredCredentialEnvelope = /* @__PURE__ */ __name2((value) => {
|
|
19648
|
+
if (!value || typeof value !== "object") return false;
|
|
19649
|
+
const candidate = value;
|
|
19650
|
+
if (typeof candidate.format !== "string") return false;
|
|
19651
|
+
if (!CredentialFormatValidator.safeParse(candidate.format).success) return false;
|
|
19652
|
+
return typeof candidate.data === "string" || candidate.data instanceof Uint8Array;
|
|
19653
|
+
}, "isStoredCredentialEnvelope");
|
|
19643
19654
|
var StatusCheckEntryValidator = external_exports.object({
|
|
19644
19655
|
/**
|
|
19645
19656
|
* The `credentialStatus.type` as it appeared on the credential.
|
|
@@ -19971,7 +19982,8 @@ var BoostRecipientValidator = external_exports.object({
|
|
|
19971
19982
|
to: LCNVisibleProfileValidator,
|
|
19972
19983
|
from: external_exports.string(),
|
|
19973
19984
|
received: external_exports.string().optional(),
|
|
19974
|
-
uri: external_exports.string().optional()
|
|
19985
|
+
uri: external_exports.string().optional(),
|
|
19986
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
19975
19987
|
});
|
|
19976
19988
|
var PaginatedBoostRecipientsValidator = PaginationResponseValidator.extend({
|
|
19977
19989
|
records: BoostRecipientValidator.array()
|
|
@@ -19981,7 +19993,8 @@ var BoostRecipientWithChildrenValidator = external_exports.object({
|
|
|
19981
19993
|
from: external_exports.string(),
|
|
19982
19994
|
received: external_exports.string().optional(),
|
|
19983
19995
|
boostUris: external_exports.array(external_exports.string()),
|
|
19984
|
-
credentialUris: external_exports.array(external_exports.string()).optional()
|
|
19996
|
+
credentialUris: external_exports.array(external_exports.string()).optional(),
|
|
19997
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
19985
19998
|
});
|
|
19986
19999
|
var PaginatedBoostRecipientsWithChildrenValidator = PaginationResponseValidator.extend({
|
|
19987
20000
|
records: BoostRecipientWithChildrenValidator.array()
|
|
@@ -21067,7 +21080,8 @@ var CredentialActivityValidator = external_exports.object({
|
|
|
21067
21080
|
inboxCredentialId: external_exports.string().optional(),
|
|
21068
21081
|
integrationId: external_exports.string().optional(),
|
|
21069
21082
|
source: CredentialActivitySourceTypeValidator,
|
|
21070
|
-
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
21083
|
+
metadata: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
21084
|
+
status: external_exports.enum(["active", "revoked", "suspended"]).optional()
|
|
21071
21085
|
});
|
|
21072
21086
|
var CredentialActivityWithDetailsValidator = CredentialActivityValidator.extend({
|
|
21073
21087
|
boost: external_exports.object({
|
|
@@ -21124,7 +21138,7 @@ var AllocateCredentialStatusInputValidator = external_exports.object({
|
|
|
21124
21138
|
}).default({});
|
|
21125
21139
|
|
|
21126
21140
|
// src/helpers.ts
|
|
21127
|
-
var import_json_stringify_deterministic = __toESM(require_lib());
|
|
21141
|
+
var import_json_stringify_deterministic = __toESM(require_lib(), 1);
|
|
21128
21142
|
|
|
21129
21143
|
// ../../../node_modules/.pnpm/pbkdf2-hmac@1.2.1/node_modules/pbkdf2-hmac/dist/index.browser.esm.js
|
|
21130
21144
|
var e = { "SHA-1": { outputLength: 20, blockSize: 64 }, "SHA-256": { outputLength: 32, blockSize: 64 }, "SHA-384": { outputLength: 48, blockSize: 128 }, "SHA-512": { outputLength: 64, blockSize: 128 } };
|
|
@@ -21225,6 +21239,19 @@ var generateEncryptedRecord = /* @__PURE__ */ __name(async (learnCard, record2,
|
|
|
21225
21239
|
}, "generateEncryptedRecord");
|
|
21226
21240
|
|
|
21227
21241
|
// src/plugin.ts
|
|
21242
|
+
var uint8ArrayToBase64Url = /* @__PURE__ */ __name((bytes) => {
|
|
21243
|
+
let binary = "";
|
|
21244
|
+
for (let i = 0; i < bytes.length; i += 1) binary += String.fromCharCode(bytes[i]);
|
|
21245
|
+
const base643 = typeof btoa === "function" ? btoa(binary) : Buffer.from(binary, "binary").toString("base64");
|
|
21246
|
+
return base643.replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
21247
|
+
}, "uint8ArrayToBase64Url");
|
|
21248
|
+
var normalizeEnvelopeForTransport = /* @__PURE__ */ __name((value) => {
|
|
21249
|
+
if (!isStoredCredentialEnvelope(value)) {
|
|
21250
|
+
return value;
|
|
21251
|
+
}
|
|
21252
|
+
if (typeof value.data === "string") return value;
|
|
21253
|
+
return { ...value, data: uint8ArrayToBase64Url(value.data) };
|
|
21254
|
+
}, "normalizeEnvelopeForTransport");
|
|
21228
21255
|
var getLearnCloudClient = /* @__PURE__ */ __name(async (url2, learnCard) => {
|
|
21229
21256
|
return getClient(url2, async (challenge) => {
|
|
21230
21257
|
const jwt2 = await learnCard.invoke.getDidAuthVp({ proofFormat: "jwt", challenge });
|
|
@@ -21428,7 +21455,9 @@ var getLearnCloudPlugin = /* @__PURE__ */ __name(async (initialLearnCard, url2,
|
|
|
21428
21455
|
if (!result) return null;
|
|
21429
21456
|
try {
|
|
21430
21457
|
const decryptedResult = await _learnCard.invoke.decryptDagJwe(result);
|
|
21431
|
-
|
|
21458
|
+
const parsed = await VCValidator.or(VPValidator).or(StoredCredentialEnvelopeValidator).parseAsync(decryptedResult);
|
|
21459
|
+
const resolved = resolveStorageReadResult(parsed);
|
|
21460
|
+
return resolved === void 0 || isStoredCredentialEnvelope(resolved) ? null : resolved;
|
|
21432
21461
|
} catch (error46) {
|
|
21433
21462
|
_learnCard.debug?.(error46);
|
|
21434
21463
|
return null;
|
|
@@ -21466,7 +21495,8 @@ var getLearnCloudPlugin = /* @__PURE__ */ __name(async (initialLearnCard, url2,
|
|
|
21466
21495
|
learnCard.debug?.("LearnCloud read.get result", result);
|
|
21467
21496
|
const decryptedResult = await _learnCard.invoke.decryptDagJwe(result);
|
|
21468
21497
|
learnCard.debug?.("LearnCloud read.get decryptedResult", decryptedResult);
|
|
21469
|
-
|
|
21498
|
+
const parsed = await VCValidator.or(VPValidator).or(StoredCredentialEnvelopeValidator).parseAsync(decryptedResult);
|
|
21499
|
+
return resolveStorageReadResult(parsed);
|
|
21470
21500
|
} catch (error46) {
|
|
21471
21501
|
_learnCard.debug?.(error46);
|
|
21472
21502
|
return void 0;
|
|
@@ -21477,7 +21507,8 @@ var getLearnCloudPlugin = /* @__PURE__ */ __name(async (initialLearnCard, url2,
|
|
|
21477
21507
|
learnCard.debug?.("LearnCloud read.get result", result);
|
|
21478
21508
|
const decryptedResult = await _learnCard.invoke.decryptDagJwe(result);
|
|
21479
21509
|
learnCard.debug?.("LearnCloud read.get decryptedResult", decryptedResult);
|
|
21480
|
-
|
|
21510
|
+
const parsed = await VCValidator.or(VPValidator).or(StoredCredentialEnvelopeValidator).parseAsync(decryptedResult);
|
|
21511
|
+
return resolveStorageReadResult(parsed);
|
|
21481
21512
|
} catch (error46) {
|
|
21482
21513
|
_learnCard.debug?.(error46);
|
|
21483
21514
|
return void 0;
|
|
@@ -21487,14 +21518,16 @@ var getLearnCloudPlugin = /* @__PURE__ */ __name(async (initialLearnCard, url2,
|
|
|
21487
21518
|
store: {
|
|
21488
21519
|
upload: /* @__PURE__ */ __name(async (_learnCard, credential) => {
|
|
21489
21520
|
_learnCard.debug?.("learnCard.store['LearnCard Network'].upload");
|
|
21490
|
-
return client.storage.store.mutate({
|
|
21521
|
+
return client.storage.store.mutate({
|
|
21522
|
+
item: normalizeEnvelopeForTransport(credential)
|
|
21523
|
+
});
|
|
21491
21524
|
}, "upload"),
|
|
21492
21525
|
uploadEncrypted: /* @__PURE__ */ __name(async (_learnCard, credential, { recipients = [] } = { recipients: [] }) => {
|
|
21493
21526
|
_learnCard.debug?.("learnCard.store['LearnCard Network'].upload");
|
|
21494
|
-
const jwe = await _learnCard.invoke.createDagJwe(
|
|
21495
|
-
|
|
21496
|
-
...recipients
|
|
21497
|
-
|
|
21527
|
+
const jwe = await _learnCard.invoke.createDagJwe(
|
|
21528
|
+
normalizeEnvelopeForTransport(credential),
|
|
21529
|
+
[_learnCard.id.did(), ...recipients]
|
|
21530
|
+
);
|
|
21498
21531
|
return client.storage.store.mutate({ item: jwe });
|
|
21499
21532
|
}, "uploadEncrypted"),
|
|
21500
21533
|
delete: /* @__PURE__ */ __name(async (_learnCard, uri) => {
|