@learncard/core 5.1.1 → 6.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +2 -1
- package/dist/core.cjs.development.js +41 -11
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +46 -46
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +362 -199
- package/dist/core.esm.js +41 -11
- package/dist/core.esm.js.map +3 -3
- package/package.json +2 -2
package/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
[<img src="https://user-images.githubusercontent.com/2185016/
|
1
|
+
[<img src="https://user-images.githubusercontent.com/2185016/190510561-294db809-09fd-4771-9749-6c0e0f4144fd.png" width="215"/>](https://learncard.com)
|
2
|
+
|
2
3
|
# @learncard/core
|
3
4
|
|
4
5
|
[![npm version](https://img.shields.io/npm/v/@learncard/core)](https://www.npmjs.com/package/@learncard/core)
|
@@ -35266,8 +35266,19 @@ var require_base32_decode = __commonJS({
|
|
35266
35266
|
// src/index.ts
|
35267
35267
|
var src_exports2 = {};
|
35268
35268
|
__export(src_exports2, {
|
35269
|
+
CredentialsListValidator: () => CredentialsListValidator,
|
35270
|
+
ExpirationPlugin: () => ExpirationPlugin,
|
35269
35271
|
emptyWallet: () => emptyWallet,
|
35272
|
+
generateWallet: () => generateWallet,
|
35273
|
+
getDidKeyPlugin: () => getDidKeyPlugin,
|
35274
|
+
getDidKitPlugin: () => getDidKitPlugin,
|
35275
|
+
getEthereumPlugin: () => getEthereumPlugin,
|
35276
|
+
getIDXPlugin: () => getIDXPlugin,
|
35277
|
+
getVCPlugin: () => getVCPlugin,
|
35278
|
+
getVpqrPlugin: () => getVpqrPlugin,
|
35270
35279
|
initLearnCard: () => initLearnCard,
|
35280
|
+
passwordToKey: () => passwordToKey,
|
35281
|
+
seedToId: () => seedToId,
|
35271
35282
|
walletFromKey: () => walletFromKey
|
35272
35283
|
});
|
35273
35284
|
module.exports = __toCommonJS(src_exports2);
|
@@ -35278,6 +35289,34 @@ var import_polyfill = require("abort-controller/polyfill");
|
|
35278
35289
|
var import_isomorphic_webcrypto = __toESM(require("isomorphic-webcrypto"));
|
35279
35290
|
if (typeof window === "undefined" && !globalThis.crypto)
|
35280
35291
|
globalThis.crypto = import_isomorphic_webcrypto.default;
|
35292
|
+
var crypto_default = import_isomorphic_webcrypto.default;
|
35293
|
+
|
35294
|
+
// src/wallet/base/functions/passwordToKey.ts
|
35295
|
+
var passwordToKey = /* @__PURE__ */ __name((password, salt = "salt", iterations = 1e5, digest2 = "SHA-256") => __async(void 0, null, function* () {
|
35296
|
+
var saltBuffer = Buffer.from(salt);
|
35297
|
+
var passphraseKey = Buffer.from(password);
|
35298
|
+
return crypto_default.subtle.importKey("raw", passphraseKey, { name: "PBKDF2" }, false, [
|
35299
|
+
"deriveBits",
|
35300
|
+
"deriveKey"
|
35301
|
+
]).then(function(key2) {
|
35302
|
+
return crypto_default.subtle.deriveKey({
|
35303
|
+
name: "PBKDF2",
|
35304
|
+
salt: saltBuffer,
|
35305
|
+
iterations,
|
35306
|
+
hash: digest2
|
35307
|
+
}, key2, { name: "AES-CBC", length: 256 }, true, ["encrypt", "decrypt"]);
|
35308
|
+
}).then((webKey) => {
|
35309
|
+
return crypto_default.subtle.exportKey("raw", webKey);
|
35310
|
+
}).then((buffer2) => {
|
35311
|
+
return new Uint8Array(buffer2);
|
35312
|
+
});
|
35313
|
+
}), "passwordToKey");
|
35314
|
+
|
35315
|
+
// src/wallet/base/functions/seedToId.ts
|
35316
|
+
var seedToId = /* @__PURE__ */ __name((seed) => __async(void 0, null, function* () {
|
35317
|
+
const buffer2 = yield crypto_default.subtle.digest("SHA-256", seed);
|
35318
|
+
return `urn:digest:${Buffer.from(new Int8Array(buffer2)).toString("hex")}`;
|
35319
|
+
}), "seedToId");
|
35281
35320
|
|
35282
35321
|
// src/wallet/base/wallet.ts
|
35283
35322
|
var addPluginToWallet = /* @__PURE__ */ __name((wallet, plugin) => __async(void 0, null, function* () {
|
@@ -53455,16 +53494,7 @@ var CeramicClient = class {
|
|
53455
53494
|
__name(CeramicClient, "CeramicClient");
|
53456
53495
|
|
53457
53496
|
// src/wallet/plugins/idx/types.ts
|
53458
|
-
var
|
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();
|
53497
|
+
var CredentialsListValidator = mod.object({ credentials: IDXCredentialValidator.array() }).strict();
|
53468
53498
|
|
53469
53499
|
// src/wallet/plugins/idx/idx.ts
|
53470
53500
|
var getCeramicClientFromWalletSuite = /* @__PURE__ */ __name((wallet, ceramicEndpoint) => __async(void 0, null, function* () {
|
@@ -53493,7 +53523,7 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
|
|
53493
53523
|
throw new Error("Invalid credentials list stored in IDX");
|
53494
53524
|
}), "getCredentialsListFromIdx");
|
53495
53525
|
const addCredentialStreamIdToIdx = /* @__PURE__ */ __name((_record, alias) => __async(void 0, null, function* () {
|
53496
|
-
const record =
|
53526
|
+
const record = IDXCredentialValidator.parse(_record);
|
53497
53527
|
if (!record)
|
53498
53528
|
throw new Error("record is required");
|
53499
53529
|
if (!record.id)
|