@learncard/core 8.2.0 → 8.3.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/core.cjs.development.js +66 -7
- package/dist/core.cjs.development.js.map +4 -4
- package/dist/core.cjs.production.min.js +31 -31
- package/dist/core.cjs.production.min.js.map +4 -4
- package/dist/core.d.ts +2 -0
- package/dist/core.esm.js +66 -7
- package/dist/core.esm.js.map +4 -4
- package/package.json +5 -5
@@ -7128,10 +7128,10 @@ var require_lodash = __commonJS({
|
|
7128
7128
|
return array && array.length ? baseUniq(array) : [];
|
7129
7129
|
}
|
7130
7130
|
__name(uniq, "uniq");
|
7131
|
-
function
|
7131
|
+
function uniqBy2(array, iteratee2) {
|
7132
7132
|
return array && array.length ? baseUniq(array, getIteratee(iteratee2, 2)) : [];
|
7133
7133
|
}
|
7134
|
-
__name(
|
7134
|
+
__name(uniqBy2, "uniqBy");
|
7135
7135
|
function uniqWith(array, comparator) {
|
7136
7136
|
comparator = typeof comparator == "function" ? comparator : undefined2;
|
7137
7137
|
return array && array.length ? baseUniq(array, undefined2, comparator) : [];
|
@@ -8971,7 +8971,7 @@ var require_lodash = __commonJS({
|
|
8971
8971
|
lodash.unionBy = unionBy;
|
8972
8972
|
lodash.unionWith = unionWith;
|
8973
8973
|
lodash.uniq = uniq;
|
8974
|
-
lodash.uniqBy =
|
8974
|
+
lodash.uniqBy = uniqBy2;
|
8975
8975
|
lodash.uniqWith = uniqWith;
|
8976
8976
|
lodash.unset = unset;
|
8977
8977
|
lodash.unzip = unzip;
|
@@ -46186,6 +46186,7 @@ __export(src_exports2, {
|
|
46186
46186
|
getEthereumPlugin: () => getEthereumPlugin,
|
46187
46187
|
getIDXPlugin: () => getIDXPlugin,
|
46188
46188
|
getTestCache: () => getTestCache,
|
46189
|
+
getTestStorage: () => getTestStorage,
|
46189
46190
|
getVCAPIPlugin: () => getVCAPIPlugin,
|
46190
46191
|
getVCPlugin: () => getVCPlugin,
|
46191
46192
|
getVCTemplatesPlugin: () => getVCTemplatesPlugin,
|
@@ -46238,6 +46239,12 @@ var mapObject = /* @__PURE__ */ __name((obj, callback) => {
|
|
46238
46239
|
Object.entries(obj).map(([key2, value], index) => [key2, callback(value, index)])
|
46239
46240
|
);
|
46240
46241
|
}, "mapObject");
|
46242
|
+
var isFulfilledAndNotEmpty = /* @__PURE__ */ __name((input) => input.status === "fulfilled" && !!input.value, "isFulfilledAndNotEmpty");
|
46243
|
+
var uniqBy = /* @__PURE__ */ __name((array, key2) => {
|
46244
|
+
return [
|
46245
|
+
...new Map(array.map((obj) => [key2 instanceof Function ? key2(obj) : obj[key2], obj])).values()
|
46246
|
+
];
|
46247
|
+
}, "uniqBy");
|
46241
46248
|
|
46242
46249
|
// src/wallet/base/wallet.ts
|
46243
46250
|
var getPlaneProviders = /* @__PURE__ */ __name((plugins, plane) => {
|
@@ -46278,7 +46285,7 @@ var generateReadPlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46278
46285
|
return cachedResponse;
|
46279
46286
|
}
|
46280
46287
|
}
|
46281
|
-
const
|
46288
|
+
const results = await Promise.allSettled(
|
46282
46289
|
learnCard.plugins.map(async (plugin) => {
|
46283
46290
|
if (!pluginImplementsPlane(plugin, "read")) {
|
46284
46291
|
throw new Error("Plugin is not a Read Plugin");
|
@@ -46286,6 +46293,7 @@ var generateReadPlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46286
46293
|
return plugin.read.get(learnCard, uri);
|
46287
46294
|
})
|
46288
46295
|
);
|
46296
|
+
const vc = results.find(isFulfilledAndNotEmpty)?.value;
|
46289
46297
|
if (vc && learnCardImplementsPlane(learnCard, "cache") && cache !== "skip-cache") {
|
46290
46298
|
await learnCard.cache.setVc(uri, vc);
|
46291
46299
|
}
|
@@ -46415,7 +46423,7 @@ var generateIndexPlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46415
46423
|
return plugin.index.get(learnCard, query);
|
46416
46424
|
})
|
46417
46425
|
)).flat();
|
46418
|
-
const results =
|
46426
|
+
const results = uniqBy(resultsWithDuplicates, "id");
|
46419
46427
|
if (results && learnCardImplementsPlane(learnCard, "cache") && cache !== "skip-cache") {
|
46420
46428
|
await learnCard.cache.setIndex("all", query ?? {}, results);
|
46421
46429
|
}
|
@@ -46429,7 +46437,7 @@ var generateCachePlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46429
46437
|
getIndex: async (name5, query) => {
|
46430
46438
|
learnCard.debug?.("learnCard.cache.getIndex");
|
46431
46439
|
try {
|
46432
|
-
const
|
46440
|
+
const results = await Promise.allSettled(
|
46433
46441
|
learnCard.plugins.map(async (plugin) => {
|
46434
46442
|
if (!pluginImplementsPlane(plugin, "cache")) {
|
46435
46443
|
throw new Error("Plugin is not a Cache Plugin");
|
@@ -46437,6 +46445,7 @@ var generateCachePlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46437
46445
|
return plugin.cache.getIndex(learnCard, name5, query);
|
46438
46446
|
})
|
46439
46447
|
);
|
46448
|
+
const index = results.find(isFulfilledAndNotEmpty)?.value;
|
46440
46449
|
return index;
|
46441
46450
|
} catch (error) {
|
46442
46451
|
return void 0;
|
@@ -46469,7 +46478,7 @@ var generateCachePlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46469
46478
|
getVc: async (uri) => {
|
46470
46479
|
learnCard.debug?.("learnCard.cache.getVc");
|
46471
46480
|
try {
|
46472
|
-
const
|
46481
|
+
const results = await Promise.allSettled(
|
46473
46482
|
learnCard.plugins.map(async (plugin) => {
|
46474
46483
|
if (!pluginImplementsPlane(plugin, "cache")) {
|
46475
46484
|
throw new Error("Plugin is not a Cache Plugin");
|
@@ -46477,6 +46486,7 @@ var generateCachePlane = /* @__PURE__ */ __name((learnCard) => {
|
|
46477
46486
|
return plugin.cache.getVc(learnCard, uri);
|
46478
46487
|
})
|
46479
46488
|
);
|
46489
|
+
const vc = results.find(isFulfilledAndNotEmpty)?.value;
|
46480
46490
|
return vc;
|
46481
46491
|
} catch (error) {
|
46482
46492
|
return void 0;
|
@@ -71421,6 +71431,55 @@ var getTestCache = /* @__PURE__ */ __name(() => {
|
|
71421
71431
|
methods: {}
|
71422
71432
|
};
|
71423
71433
|
}, "getTestCache");
|
71434
|
+
|
71435
|
+
// src/wallet/plugins/test-storage/index.ts
|
71436
|
+
var getTestStorage = /* @__PURE__ */ __name(() => {
|
71437
|
+
let index = [];
|
71438
|
+
let vcs = [];
|
71439
|
+
return {
|
71440
|
+
name: "Test Storage",
|
71441
|
+
displayName: "Test Storage",
|
71442
|
+
description: "[Testing] Tests Storage Implementations",
|
71443
|
+
read: {
|
71444
|
+
get: async (_learnCard, uri) => {
|
71445
|
+
_learnCard.debug?.("Test Storage, read, get", { uri });
|
71446
|
+
if (!uri)
|
71447
|
+
return void 0;
|
71448
|
+
const [_lc, method, vcIndex] = uri.split(":");
|
71449
|
+
if (method !== "test")
|
71450
|
+
return void 0;
|
71451
|
+
return vcs[Number.parseInt(vcIndex)];
|
71452
|
+
}
|
71453
|
+
},
|
71454
|
+
store: {
|
71455
|
+
upload: async (_learnCard, vc) => {
|
71456
|
+
_learnCard.debug?.("Test Storage, store, upload", { vc });
|
71457
|
+
const vcIndex = vcs.length;
|
71458
|
+
vcs.push(vc);
|
71459
|
+
return `lc:test:${vcIndex}`;
|
71460
|
+
}
|
71461
|
+
},
|
71462
|
+
index: {
|
71463
|
+
get: async (_learnCard, query) => {
|
71464
|
+
_learnCard.debug?.("Test Storage, index, get", { query });
|
71465
|
+
return index;
|
71466
|
+
},
|
71467
|
+
add: async (_learnCard, record) => {
|
71468
|
+
_learnCard.debug?.("Test Storage, index, add", { record });
|
71469
|
+
index.push(record);
|
71470
|
+
return true;
|
71471
|
+
},
|
71472
|
+
update: async () => false,
|
71473
|
+
remove: async (_learnCard, id) => {
|
71474
|
+
_learnCard.debug?.("Test Storage, index, remove", { id });
|
71475
|
+
let recordIndex = index.findIndex((record) => record.id === id);
|
71476
|
+
index.splice(recordIndex, 1);
|
71477
|
+
return true;
|
71478
|
+
}
|
71479
|
+
},
|
71480
|
+
methods: {}
|
71481
|
+
};
|
71482
|
+
}, "getTestStorage");
|
71424
71483
|
/*!
|
71425
71484
|
* A CredentialHandlerRegistration provides a CredentialManager to enable Web
|
71426
71485
|
* apps to register Profiles that can be presented to websites.
|