@learncard/core 5.1.1 → 6.1.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/README.md +2 -1
- package/dist/core.cjs.development.js +143 -26
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +76 -76
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +627 -362
- package/dist/core.esm.js +143 -26
- package/dist/core.esm.js.map +3 -3
- package/dist/didkit/didkit_wasm.js +1 -1
- package/dist/didkit/didkit_wasm_bg.wasm +0 -0
- package/dist/didkit_wasm.js +1 -1
- package/dist/didkit_wasm_bg.wasm +0 -0
- package/package.json +2 -2
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* () {
|
@@ -35985,7 +36013,7 @@ function getImports() {
|
|
35985
36013
|
const ret = wasm.memory;
|
35986
36014
|
return addHeapObject(ret);
|
35987
36015
|
};
|
35988
|
-
imports.wbg.
|
36016
|
+
imports.wbg.__wbindgen_closure_wrapper10021 = function(arg0, arg1, arg2) {
|
35989
36017
|
const ret = makeMutClosure(arg0, arg1, 3552, __wbg_adapter_24);
|
35990
36018
|
return addHeapObject(ret);
|
35991
36019
|
};
|
@@ -36022,7 +36050,7 @@ var didkit_wasm_default = init;
|
|
36022
36050
|
|
36023
36051
|
// src/didkit/index.ts
|
36024
36052
|
var initialized = false;
|
36025
|
-
var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/
|
36053
|
+
var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/R0BsvnoVRhezGazRDUy5") => __async(void 0, null, function* () {
|
36026
36054
|
if (initialized)
|
36027
36055
|
return;
|
36028
36056
|
initialized = true;
|
@@ -36087,6 +36115,90 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
|
|
36087
36115
|
}
|
36088
36116
|
}), "ExpirationPlugin");
|
36089
36117
|
|
36118
|
+
// src/wallet/helpers/wallet.helpers.ts
|
36119
|
+
var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
|
36120
|
+
|
36121
|
+
// src/wallet/plugins/vc-templates/templates.ts
|
36122
|
+
var VC_TEMPLATES = {
|
36123
|
+
basic: ({
|
36124
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
36125
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
36126
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
36127
|
+
} = {}) => ({
|
36128
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
36129
|
+
id: "http://example.org/credentials/3731",
|
36130
|
+
type: ["VerifiableCredential"],
|
36131
|
+
issuer: did,
|
36132
|
+
issuanceDate,
|
36133
|
+
credentialSubject: { id: subject }
|
36134
|
+
}),
|
36135
|
+
achievement: ({
|
36136
|
+
did = "did:example:d23dd687a7dc6787646f2eb98d0",
|
36137
|
+
subject = "did:example:d23dd687a7dc6787646f2eb98d0",
|
36138
|
+
name: name5 = "Teamwork Badge",
|
36139
|
+
achievementName = "Teamwork",
|
36140
|
+
description = "This badge recognizes the development of the capacity to collaborate within a group environment.",
|
36141
|
+
criteriaNarrative = "Team members are nominated for this badge by their peers and recognized upon review by Example Corp management.",
|
36142
|
+
issuanceDate = "2020-08-19T21:41:50Z"
|
36143
|
+
} = {}) => ({
|
36144
|
+
"@context": [
|
36145
|
+
"https://www.w3.org/2018/credentials/v1",
|
36146
|
+
"https://imsglobal.github.io/openbadges-specification/context.json"
|
36147
|
+
],
|
36148
|
+
id: "http://example.com/credentials/3527",
|
36149
|
+
type: ["VerifiableCredential", "OpenBadgeCredential"],
|
36150
|
+
issuer: did,
|
36151
|
+
issuanceDate,
|
36152
|
+
name: name5,
|
36153
|
+
credentialSubject: {
|
36154
|
+
id: subject,
|
36155
|
+
type: ["AchievementSubject"],
|
36156
|
+
achievement: {
|
36157
|
+
id: "https://example.com/achievements/21st-century-skills/teamwork",
|
36158
|
+
type: ["Achievement"],
|
36159
|
+
criteria: { narrative: criteriaNarrative },
|
36160
|
+
description,
|
36161
|
+
name: achievementName
|
36162
|
+
}
|
36163
|
+
}
|
36164
|
+
})
|
36165
|
+
};
|
36166
|
+
|
36167
|
+
// src/wallet/plugins/vc-templates/vc-templates.ts
|
36168
|
+
var getVCTemplatesPlugin = /* @__PURE__ */ __name((wallet) => {
|
36169
|
+
return {
|
36170
|
+
pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
|
36171
|
+
newCredential: (_wallet, args = { type: "basic" }) => {
|
36172
|
+
var _a, _b;
|
36173
|
+
const did = args.did || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
|
36174
|
+
if (!did)
|
36175
|
+
throw new Error("Could not get issuer did!");
|
36176
|
+
const defaults = {
|
36177
|
+
did,
|
36178
|
+
subject: "did:example:d23dd687a7dc6787646f2eb98d0",
|
36179
|
+
issuanceDate: "2020-08-19T21:41:50Z"
|
36180
|
+
};
|
36181
|
+
const _c = args, { type = "basic" } = _c, functionArgs = __objRest(_c, ["type"]);
|
36182
|
+
if (!(type in VC_TEMPLATES))
|
36183
|
+
throw new Error("Invalid Test VC Type!");
|
36184
|
+
return VC_TEMPLATES[type](__spreadValues(__spreadValues({}, defaults), functionArgs));
|
36185
|
+
},
|
36186
|
+
newPresentation: (_0, _1, ..._2) => __async(void 0, [_0, _1, ..._2], function* (_wallet, credential, args = {}) {
|
36187
|
+
var _a, _b;
|
36188
|
+
const did = (args == null ? void 0 : args.did) || ((_b = (_a = _wallet.pluginMethods).getSubjectDid) == null ? void 0 : _b.call(_a, "key"));
|
36189
|
+
if (!did)
|
36190
|
+
throw new Error("Could not get issuer did!");
|
36191
|
+
return {
|
36192
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
36193
|
+
type: ["VerifiablePresentation"],
|
36194
|
+
holder: did,
|
36195
|
+
verifiableCredential: credential
|
36196
|
+
};
|
36197
|
+
})
|
36198
|
+
})
|
36199
|
+
};
|
36200
|
+
}, "getVCTemplatesPlugin");
|
36201
|
+
|
36090
36202
|
// ../../node_modules/.pnpm/zod@3.17.3/node_modules/zod/lib/index.mjs
|
36091
36203
|
var util;
|
36092
36204
|
(function(util2) {
|
@@ -38831,12 +38943,12 @@ var ImageValidator = mod.string().or(mod.object({
|
|
38831
38943
|
caption: mod.string().optional()
|
38832
38944
|
}));
|
38833
38945
|
var GeoCoordinatesValidator = mod.object({
|
38834
|
-
type: mod.string().array().nonempty(),
|
38946
|
+
type: mod.string().min(1).or(mod.string().array().nonempty()),
|
38835
38947
|
latitude: mod.number(),
|
38836
38948
|
longitude: mod.number()
|
38837
38949
|
});
|
38838
38950
|
var AddressValidator = mod.object({
|
38839
|
-
type: mod.string().array().nonempty(),
|
38951
|
+
type: mod.string().min(1).or(mod.string().array().nonempty()),
|
38840
38952
|
addressCountry: mod.string().optional(),
|
38841
38953
|
addressCountryCode: mod.string().optional(),
|
38842
38954
|
addressRegion: mod.string().optional(),
|
@@ -38867,7 +38979,7 @@ var IdentifierTypeValidator = mod.enum([
|
|
38867
38979
|
"identifier"
|
38868
38980
|
]).or(mod.string());
|
38869
38981
|
var IdentifierEntryValidator = mod.object({
|
38870
|
-
type: mod.string().array().nonempty(),
|
38982
|
+
type: mod.string().min(1).or(mod.string().array().nonempty()),
|
38871
38983
|
identifier: mod.string(),
|
38872
38984
|
identifierType: IdentifierTypeValidator
|
38873
38985
|
});
|
@@ -39087,7 +39199,7 @@ var AchievementSubjectValidator = mod.object({
|
|
39087
39199
|
activityStartDate: mod.string().optional(),
|
39088
39200
|
creditsEarned: mod.number().optional(),
|
39089
39201
|
achievement: AchievementValidator.optional(),
|
39090
|
-
identifier: IdentityObjectValidator.optional(),
|
39202
|
+
identifier: IdentityObjectValidator.array().optional(),
|
39091
39203
|
image: ImageValidator.optional(),
|
39092
39204
|
licenseNumber: mod.string().optional(),
|
39093
39205
|
narrative: mod.string().optional(),
|
@@ -39108,7 +39220,7 @@ var EvidenceValidator = mod.object({
|
|
39108
39220
|
var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
|
39109
39221
|
name: mod.string().optional(),
|
39110
39222
|
description: mod.string().optional(),
|
39111
|
-
image:
|
39223
|
+
image: ImageValidator.optional(),
|
39112
39224
|
credentialSubject: AchievementSubjectValidator.or(AchievementSubjectValidator.array()),
|
39113
39225
|
endorsement: UnsignedVCValidator.array().optional(),
|
39114
39226
|
evidence: EvidenceValidator.array().optional()
|
@@ -40755,9 +40867,12 @@ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
|
|
40755
40867
|
// src/wallet/initializers/emptyWallet.ts
|
40756
40868
|
var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], function* ({ didkit } = {}) {
|
40757
40869
|
const didkitWallet = yield (yield generateWallet()).addPlugin(yield getDidKitPlugin(didkit));
|
40758
|
-
const
|
40870
|
+
const expirationWallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
|
40871
|
+
const wallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin(expirationWallet));
|
40759
40872
|
return {
|
40760
40873
|
_wallet: wallet,
|
40874
|
+
newCredential: wallet.pluginMethods.newCredential,
|
40875
|
+
newPresentation: wallet.pluginMethods.newPresentation,
|
40761
40876
|
verifyCredential: verifyCredential2(wallet),
|
40762
40877
|
verifyPresentation: wallet.pluginMethods.verifyPresentation,
|
40763
40878
|
resolveDid: wallet.pluginMethods.resolveDid
|
@@ -53455,16 +53570,7 @@ var CeramicClient = class {
|
|
53455
53570
|
__name(CeramicClient, "CeramicClient");
|
53456
53571
|
|
53457
53572
|
// 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();
|
53573
|
+
var CredentialsListValidator = mod.object({ credentials: IDXCredentialValidator.array() }).strict();
|
53468
53574
|
|
53469
53575
|
// src/wallet/plugins/idx/idx.ts
|
53470
53576
|
var getCeramicClientFromWalletSuite = /* @__PURE__ */ __name((wallet, ceramicEndpoint) => __async(void 0, null, function* () {
|
@@ -53493,7 +53599,7 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
|
|
53493
53599
|
throw new Error("Invalid credentials list stored in IDX");
|
53494
53600
|
}), "getCredentialsListFromIdx");
|
53495
53601
|
const addCredentialStreamIdToIdx = /* @__PURE__ */ __name((_record, alias) => __async(void 0, null, function* () {
|
53496
|
-
const record =
|
53602
|
+
const record = IDXCredentialValidator.parse(_record);
|
53497
53603
|
if (!record)
|
53498
53604
|
throw new Error("record is required");
|
53499
53605
|
if (!record.id)
|
@@ -53639,9 +53745,6 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, n
|
|
53639
53745
|
};
|
53640
53746
|
}), "getDidKeyPlugin");
|
53641
53747
|
|
53642
|
-
// src/wallet/helpers/wallet.helpers.ts
|
53643
|
-
var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
|
53644
|
-
|
53645
53748
|
// src/wallet/plugins/vc/issueCredential.ts
|
53646
53749
|
var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
|
53647
53750
|
return (wallet, credential) => __async(void 0, null, function* () {
|
@@ -53685,7 +53788,7 @@ var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
|
|
53685
53788
|
}, "verifyPresentation");
|
53686
53789
|
|
53687
53790
|
// src/wallet/plugins/vc/vc.ts
|
53688
|
-
var getVCPlugin = /* @__PURE__ */ __name((wallet) =>
|
53791
|
+
var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
|
53689
53792
|
return {
|
53690
53793
|
pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
|
53691
53794
|
issueCredential: issueCredential2(wallet),
|
@@ -53715,7 +53818,7 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, funct
|
|
53715
53818
|
})
|
53716
53819
|
})
|
53717
53820
|
};
|
53718
|
-
}
|
53821
|
+
}, "getVCPlugin");
|
53719
53822
|
|
53720
53823
|
// src/wallet/plugins/EthereumPlugin/index.ts
|
53721
53824
|
import { ethers as ethers2 } from "ethers";
|
@@ -57066,8 +57169,9 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
|
|
57066
57169
|
} = {}) {
|
57067
57170
|
const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
|
57068
57171
|
const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
|
57069
|
-
const didkeyAndVCWallet = yield didkeyWallet.addPlugin(
|
57070
|
-
const
|
57172
|
+
const didkeyAndVCWallet = yield didkeyWallet.addPlugin(getVCPlugin(didkeyWallet));
|
57173
|
+
const templateWallet = yield didkeyAndVCWallet.addPlugin(getVCTemplatesPlugin(didkeyAndVCWallet));
|
57174
|
+
const idxWallet = yield templateWallet.addPlugin(yield getIDXPlugin(templateWallet, ceramicIdx));
|
57071
57175
|
const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
|
57072
57176
|
const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
|
57073
57177
|
const wallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
|
@@ -57075,6 +57179,8 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
|
|
57075
57179
|
_wallet: wallet,
|
57076
57180
|
did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
|
57077
57181
|
keypair: (type = "ed25519") => wallet.pluginMethods.getSubjectKeypair(type),
|
57182
|
+
newCredential: wallet.pluginMethods.newCredential,
|
57183
|
+
newPresentation: wallet.pluginMethods.newPresentation,
|
57078
57184
|
issueCredential: wallet.pluginMethods.issueCredential,
|
57079
57185
|
verifyCredential: verifyCredential2(wallet),
|
57080
57186
|
issuePresentation: wallet.pluginMethods.issuePresentation,
|
@@ -57119,8 +57225,19 @@ function initLearnCard() {
|
|
57119
57225
|
}
|
57120
57226
|
__name(initLearnCard, "initLearnCard");
|
57121
57227
|
export {
|
57228
|
+
CredentialsListValidator,
|
57229
|
+
ExpirationPlugin,
|
57122
57230
|
emptyWallet,
|
57231
|
+
generateWallet,
|
57232
|
+
getDidKeyPlugin,
|
57233
|
+
getDidKitPlugin,
|
57234
|
+
getEthereumPlugin,
|
57235
|
+
getIDXPlugin,
|
57236
|
+
getVCPlugin,
|
57237
|
+
getVpqrPlugin,
|
57123
57238
|
initLearnCard,
|
57239
|
+
passwordToKey,
|
57240
|
+
seedToId,
|
57124
57241
|
walletFromKey
|
57125
57242
|
};
|
57126
57243
|
/*!
|