@learncard/core 5.1.0 → 5.1.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/README.md CHANGED
@@ -9,7 +9,7 @@ The LearnCard Core is a pluggable, open-source, universal digital wallet to enab
9
9
 
10
10
  ## Documentation
11
11
  All LearnCard documentation can be found at:
12
- https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/
12
+ https://docs.learncard.com
13
13
 
14
14
  ## Install
15
15
 
@@ -2881,9 +2881,9 @@ var require_package = __commonJS({
2881
2881
  }
2882
2882
  });
2883
2883
 
2884
- // (disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js
2884
+ // (disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js
2885
2885
  var require_buffer = __commonJS({
2886
- "(disabled):../../node_modules/.pnpm/buffer@5.7.1/node_modules/buffer/index.js"() {
2886
+ "(disabled):../../node_modules/.pnpm/buffer@5.2.1/node_modules/buffer/index.js"() {
2887
2887
  }
2888
2888
  });
2889
2889
 
@@ -35276,7 +35276,7 @@ var import_polyfill = require("abort-controller/polyfill");
35276
35276
 
35277
35277
  // src/wallet/base/crypto.ts
35278
35278
  var import_isomorphic_webcrypto = __toESM(require("isomorphic-webcrypto"));
35279
- if (typeof window === "undefined")
35279
+ if (typeof window === "undefined" && !globalThis.crypto)
35280
35280
  globalThis.crypto = import_isomorphic_webcrypto.default;
35281
35281
 
35282
35282
  // src/wallet/base/wallet.ts
@@ -35501,6 +35501,15 @@ function __wbg_adapter_24(arg0, arg1, arg2) {
35501
35501
  wasm._dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h47a829c6210a1ab1(arg0, arg1, addHeapObject(arg2));
35502
35502
  }
35503
35503
  __name(__wbg_adapter_24, "__wbg_adapter_24");
35504
+ function resolveDID(did, input_metadata) {
35505
+ const ptr0 = passStringToWasm0(did, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
35506
+ const len0 = WASM_VECTOR_LEN;
35507
+ const ptr1 = passStringToWasm0(input_metadata, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
35508
+ const len1 = WASM_VECTOR_LEN;
35509
+ const ret = wasm.resolveDID(ptr0, len0, ptr1, len1);
35510
+ return takeObject(ret);
35511
+ }
35512
+ __name(resolveDID, "resolveDID");
35504
35513
  function passArray8ToWasm0(arg, malloc) {
35505
35514
  const ptr = malloc(arg.length * 1);
35506
35515
  getUint8Memory0().set(arg, ptr / 1);
@@ -36055,6 +36064,9 @@ var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async(void 0, null, fu
36055
36064
  }),
36056
36065
  contextLoader: (_wallet, url) => __async(void 0, null, function* () {
36057
36066
  return JSON.parse(yield contextLoader(url));
36067
+ }),
36068
+ resolveDid: (_wallet, did) => __async(void 0, null, function* () {
36069
+ return JSON.parse(yield resolveDID(did, "{}"));
36058
36070
  })
36059
36071
  }
36060
36072
  };
@@ -39124,6 +39136,13 @@ var CredentialInfoValidator = mod.object({
39124
39136
  issuee: ProfileValidator.optional(),
39125
39137
  credentialSubject: CredentialSubjectValidator.optional()
39126
39138
  });
39139
+ var StorageTypeValidator = mod.enum(["ceramic"]);
39140
+ var StorageTypeEnum = StorageTypeValidator.enum;
39141
+ var IDXCredentialValidator = mod.object({
39142
+ id: mod.string(),
39143
+ title: mod.string(),
39144
+ storageType: StorageTypeValidator.optional()
39145
+ });
39127
39146
 
39128
39147
  // ../../node_modules/.pnpm/date-fns@2.28.0/node_modules/date-fns/esm/_lib/toInteger/index.js
39129
39148
  function toInteger(dirtyNumber) {
@@ -40740,7 +40759,8 @@ var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], fun
40740
40759
  return {
40741
40760
  _wallet: wallet,
40742
40761
  verifyCredential: verifyCredential2(wallet),
40743
- verifyPresentation: wallet.pluginMethods.verifyPresentation
40762
+ verifyPresentation: wallet.pluginMethods.verifyPresentation,
40763
+ resolveDid: wallet.pluginMethods.resolveDid
40744
40764
  };
40745
40765
  }), "emptyWallet");
40746
40766
 
@@ -53434,6 +53454,18 @@ var CeramicClient = class {
53434
53454
  };
53435
53455
  __name(CeramicClient, "CeramicClient");
53436
53456
 
53457
+ // src/wallet/plugins/idx/types.ts
53458
+ var StorageTypeValidator2 = mod.enum(["ceramic"]);
53459
+ var StorageTypeEnum2 = StorageTypeValidator2.enum;
53460
+ var CredentialMetadataValidator = mod.object({ name: mod.string().optional(), image: mod.string().optional() }).catchall(mod.any());
53461
+ var IDXCredentialValidator2 = mod.object({
53462
+ id: mod.string(),
53463
+ title: mod.string(),
53464
+ storageType: StorageTypeValidator2.optional(),
53465
+ metadata: CredentialMetadataValidator.optional()
53466
+ }).strict();
53467
+ var CredentialsListValidator = mod.object({ credentials: IDXCredentialValidator2.array() }).strict();
53468
+
53437
53469
  // src/wallet/plugins/idx/idx.ts
53438
53470
  var getCeramicClientFromWalletSuite = /* @__PURE__ */ __name((wallet, ceramicEndpoint) => __async(void 0, null, function* () {
53439
53471
  const client = new CeramicClient(ceramicEndpoint);
@@ -53451,9 +53483,17 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53451
53483
  const loader = new TileLoader({ ceramic });
53452
53484
  const dataStore = new DIDDataStore({ ceramic, model: modelData });
53453
53485
  const getCredentialsListFromIdx = /* @__PURE__ */ __name((..._02) => __async(void 0, [..._02], function* (alias = credentialAlias) {
53454
- return (yield dataStore.get(alias)) || { credentials: [] };
53486
+ const list = yield dataStore.get(alias);
53487
+ if (!list)
53488
+ return { credentials: [] };
53489
+ const validationResult = yield CredentialsListValidator.spa(list);
53490
+ if (validationResult.success)
53491
+ return validationResult.data;
53492
+ console.error(validationResult.error);
53493
+ throw new Error("Invalid credentials list stored in IDX");
53455
53494
  }), "getCredentialsListFromIdx");
53456
- const addCredentialStreamIdToIdx = /* @__PURE__ */ __name((record, alias) => __async(void 0, null, function* () {
53495
+ const addCredentialStreamIdToIdx = /* @__PURE__ */ __name((_record, alias) => __async(void 0, null, function* () {
53496
+ const record = IDXCredentialValidator2.parse(_record);
53457
53497
  if (!record)
53458
53498
  throw new Error("record is required");
53459
53499
  if (!record.id)
@@ -53468,10 +53508,10 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53468
53508
  });
53469
53509
  if (indexOfExistingCredential > -1) {
53470
53510
  existing.credentials[indexOfExistingCredential] = __spreadValues({
53471
- storageType: "ceramic" /* ceramic */
53511
+ storageType: StorageTypeEnum.ceramic
53472
53512
  }, record);
53473
53513
  } else
53474
- existing.credentials.push(__spreadValues({ storageType: "ceramic" /* ceramic */ }, record));
53514
+ existing.credentials.push(__spreadValues({ storageType: StorageTypeEnum.ceramic }, record));
53475
53515
  return dataStore.set(alias, existing);
53476
53516
  }), "addCredentialStreamIdToIdx");
53477
53517
  const removeCredentialFromIdx = /* @__PURE__ */ __name((title, alias) => __async(void 0, null, function* () {
@@ -53524,8 +53564,8 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53524
53564
  return readContentFromCeramic(streamId);
53525
53565
  })));
53526
53566
  }),
53527
- addVerifiableCredentialInIdx: (_02, _12) => __async(void 0, [_02, _12], function* (_wallet, { title, id }) {
53528
- return addCredentialStreamIdToIdx({ title, id });
53567
+ addVerifiableCredentialInIdx: (_wallet, idxCredential) => __async(void 0, null, function* () {
53568
+ return addCredentialStreamIdToIdx(idxCredential);
53529
53569
  }),
53530
53570
  removeVerifiableCredentialInIdx: (_wallet, title) => __async(void 0, null, function* () {
53531
53571
  return removeCredentialFromIdx(title);
@@ -57051,6 +57091,7 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57051
57091
  removeCredential: (title) => __async(void 0, null, function* () {
57052
57092
  yield wallet.pluginMethods.removeVerifiableCredentialInIdx(title);
57053
57093
  }),
57094
+ resolveDid: wallet.pluginMethods.resolveDid,
57054
57095
  readFromCeramic: wallet.pluginMethods.readContentFromCeramic,
57055
57096
  getTestVc: wallet.pluginMethods.getTestVc,
57056
57097
  getTestVp: wallet.pluginMethods.getTestVp,