@learncard/core 5.1.1 → 6.0.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.esm.js CHANGED
@@ -35278,6 +35278,34 @@ import "abort-controller/polyfill";
35278
35278
  import crypto2 from "isomorphic-webcrypto";
35279
35279
  if (typeof window === "undefined" && !globalThis.crypto)
35280
35280
  globalThis.crypto = crypto2;
35281
+ var crypto_default = crypto2;
35282
+
35283
+ // src/wallet/base/functions/passwordToKey.ts
35284
+ var passwordToKey = /* @__PURE__ */ __name((password, salt = "salt", iterations = 1e5, digest2 = "SHA-256") => __async(void 0, null, function* () {
35285
+ var saltBuffer = Buffer.from(salt);
35286
+ var passphraseKey = Buffer.from(password);
35287
+ return crypto_default.subtle.importKey("raw", passphraseKey, { name: "PBKDF2" }, false, [
35288
+ "deriveBits",
35289
+ "deriveKey"
35290
+ ]).then(function(key2) {
35291
+ return crypto_default.subtle.deriveKey({
35292
+ name: "PBKDF2",
35293
+ salt: saltBuffer,
35294
+ iterations,
35295
+ hash: digest2
35296
+ }, key2, { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"]);
35297
+ }).then((webKey) => {
35298
+ return crypto_default.subtle.exportKey("raw", webKey);
35299
+ }).then((buffer2) => {
35300
+ return new Uint8Array(buffer2);
35301
+ });
35302
+ }), "passwordToKey");
35303
+
35304
+ // src/wallet/base/functions/seedToId.ts
35305
+ var seedToId = /* @__PURE__ */ __name((seed) => __async(void 0, null, function* () {
35306
+ const buffer2 = yield crypto_default.subtle.digest("SHA-256", seed);
35307
+ return `urn:digest:${Buffer.from(new Int8Array(buffer2)).toString("hex")}`;
35308
+ }), "seedToId");
35281
35309
 
35282
35310
  // src/wallet/base/wallet.ts
35283
35311
  var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async(void 0, null, function* () {
@@ -53455,16 +53483,7 @@ var CeramicClient = class {
53455
53483
  __name(CeramicClient, "CeramicClient");
53456
53484
 
53457
53485
  // 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();
53486
+ var CredentialsListValidator = mod.object({ credentials: IDXCredentialValidator.array() }).strict();
53468
53487
 
53469
53488
  // src/wallet/plugins/idx/idx.ts
53470
53489
  var getCeramicClientFromWalletSuite = /* @__PURE__ */ __name((wallet, ceramicEndpoint) => __async(void 0, null, function* () {
@@ -53493,7 +53512,7 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
53493
53512
  throw new Error("Invalid credentials list stored in IDX");
53494
53513
  }), "getCredentialsListFromIdx");
53495
53514
  const addCredentialStreamIdToIdx = /* @__PURE__ */ __name((_record, alias) => __async(void 0, null, function* () {
53496
- const record = IDXCredentialValidator2.parse(_record);
53515
+ const record = IDXCredentialValidator.parse(_record);
53497
53516
  if (!record)
53498
53517
  throw new Error("record is required");
53499
53518
  if (!record.id)
@@ -57119,8 +57138,19 @@ function initLearnCard() {
57119
57138
  }
57120
57139
  __name(initLearnCard, "initLearnCard");
57121
57140
  export {
57141
+ CredentialsListValidator,
57142
+ ExpirationPlugin,
57122
57143
  emptyWallet,
57144
+ generateWallet,
57145
+ getDidKeyPlugin,
57146
+ getDidKitPlugin,
57147
+ getEthereumPlugin,
57148
+ getIDXPlugin,
57149
+ getVCPlugin,
57150
+ getVpqrPlugin,
57123
57151
  initLearnCard,
57152
+ passwordToKey,
57153
+ seedToId,
57124
57154
  walletFromKey
57125
57155
  };
57126
57156
  /*!