@learncard/core 1.1.5 → 1.2.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 +82 -48
- package/dist/core.cjs.development.js.map +3 -3
- package/dist/core.cjs.production.min.js +109 -109
- package/dist/core.cjs.production.min.js.map +3 -3
- package/dist/core.d.ts +22 -7
- package/dist/core.esm.js +82 -48
- package/dist/core.esm.js.map +3 -3
- package/package.json +2 -2
@@ -43224,15 +43224,15 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async(void 0, [_0, _1],
|
|
43224
43224
|
|
43225
43225
|
// src/wallet/plugins/didkey/index.ts
|
43226
43226
|
var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
|
43227
|
-
var getDidKeyPlugin = /* @__PURE__ */ __name((key2) => __async(void 0, null, function* () {
|
43227
|
+
var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, null, function* () {
|
43228
43228
|
if (key2.length === 0)
|
43229
43229
|
throw new Error("Please don't use an empty string for a key!");
|
43230
43230
|
if (!isHex(key2))
|
43231
43231
|
throw new Error("Key must be a hexadecimal string!");
|
43232
43232
|
if (key2.length > 64)
|
43233
43233
|
throw new Error("Key must be less than 64 characters");
|
43234
|
-
const keypair =
|
43235
|
-
const did =
|
43234
|
+
const keypair = wallet.pluginMethods.generateEd25519KeyFromBytes(toUint8Array(key2.padStart(64, "0")));
|
43235
|
+
const did = wallet.pluginMethods.keyToDid("key", keypair);
|
43236
43236
|
return {
|
43237
43237
|
pluginMethods: {
|
43238
43238
|
getSubjectDid: () => did,
|
@@ -43258,63 +43258,65 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
|
|
43258
43258
|
}), "ExpirationPlugin");
|
43259
43259
|
|
43260
43260
|
// src/wallet/plugins/vc/issueCredential.ts
|
43261
|
-
var issueCredential2 = /* @__PURE__ */ __name((
|
43262
|
-
|
43263
|
-
|
43264
|
-
|
43265
|
-
|
43266
|
-
|
43267
|
-
|
43268
|
-
|
43261
|
+
var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
|
43262
|
+
return (wallet, credential) => __async(void 0, null, function* () {
|
43263
|
+
const kp = wallet.pluginMethods.getSubjectKeypair();
|
43264
|
+
if (!kp)
|
43265
|
+
throw new Error("Cannot issue credential: Could not get subject keypair");
|
43266
|
+
const options = {
|
43267
|
+
verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
|
43268
|
+
proofPurpose: "assertionMethod"
|
43269
|
+
};
|
43270
|
+
return initWallet.pluginMethods.issueCredential(credential, options, kp);
|
43269
43271
|
});
|
43270
|
-
|
43271
|
-
}), "issueCredential");
|
43272
|
+
}, "issueCredential");
|
43272
43273
|
|
43273
43274
|
// src/wallet/plugins/vc/verifyCredential.ts
|
43274
|
-
var verifyCredential2 = /* @__PURE__ */ __name((
|
43275
|
-
return
|
43276
|
-
|
43275
|
+
var verifyCredential2 = /* @__PURE__ */ __name((initWallet) => {
|
43276
|
+
return (_wallet, credential) => __async(void 0, null, function* () {
|
43277
|
+
return initWallet.pluginMethods.verifyCredential(credential);
|
43278
|
+
});
|
43279
|
+
}, "verifyCredential");
|
43277
43280
|
|
43278
43281
|
// src/wallet/plugins/vc/issuePresentation.ts
|
43279
|
-
var issuePresentation2 = /* @__PURE__ */ __name((
|
43280
|
-
|
43281
|
-
|
43282
|
-
|
43283
|
-
|
43284
|
-
|
43285
|
-
|
43286
|
-
|
43287
|
-
|
43288
|
-
|
43289
|
-
|
43290
|
-
|
43291
|
-
|
43292
|
-
|
43293
|
-
|
43294
|
-
|
43295
|
-
|
43296
|
-
|
43282
|
+
var issuePresentation2 = /* @__PURE__ */ __name((initWallet) => {
|
43283
|
+
return (wallet, credential) => __async(void 0, null, function* () {
|
43284
|
+
const did = wallet.pluginMethods.getSubjectDid();
|
43285
|
+
if (!did)
|
43286
|
+
throw new Error("Cannot create presentation: No holder key found");
|
43287
|
+
const holder = did;
|
43288
|
+
const kp = wallet.pluginMethods.getSubjectKeypair();
|
43289
|
+
if (!kp)
|
43290
|
+
throw new Error("Cannot issue credential: Could not get subject keypair");
|
43291
|
+
const options = {
|
43292
|
+
verificationMethod: yield initWallet.pluginMethods.keyToVerificationMethod("key", kp),
|
43293
|
+
proofPurpose: "assertionMethod"
|
43294
|
+
};
|
43295
|
+
const presentation = {
|
43296
|
+
"@context": ["https://www.w3.org/2018/credentials/v1"],
|
43297
|
+
type: ["VerifiablePresentation"],
|
43298
|
+
holder,
|
43299
|
+
verifiableCredential: credential
|
43300
|
+
};
|
43301
|
+
return initWallet.pluginMethods.issuePresentation(presentation, options, kp);
|
43297
43302
|
});
|
43298
|
-
|
43299
|
-
}), "issuePresentation");
|
43303
|
+
}, "issuePresentation");
|
43300
43304
|
|
43301
43305
|
// src/wallet/plugins/vc/verifyPresentation.ts
|
43302
|
-
var verifyPresentation2 = /* @__PURE__ */ __name((
|
43303
|
-
return
|
43304
|
-
|
43306
|
+
var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
|
43307
|
+
return (_wallet, presentation) => __async(void 0, null, function* () {
|
43308
|
+
return initWallet.pluginMethods.verifyPresentation(presentation);
|
43309
|
+
});
|
43310
|
+
}, "verifyPresentation");
|
43305
43311
|
|
43306
43312
|
// src/wallet/plugins/vc/vc.ts
|
43307
43313
|
var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, function* () {
|
43308
43314
|
return {
|
43309
43315
|
pluginMethods: __spreadProps(__spreadValues({}, wallet.pluginMethods), {
|
43310
|
-
issueCredential: issueCredential2,
|
43311
|
-
verifyCredential: (
|
43312
|
-
|
43313
|
-
|
43314
|
-
issuePresentation: issuePresentation2,
|
43315
|
-
verifyPresentation: (_wallet, presentation) => __async(void 0, null, function* () {
|
43316
|
-
return verifyPresentation2(presentation);
|
43317
|
-
}),
|
43316
|
+
issueCredential: issueCredential2(wallet),
|
43317
|
+
verifyCredential: verifyCredential2(wallet),
|
43318
|
+
issuePresentation: issuePresentation2(wallet),
|
43319
|
+
verifyPresentation: verifyPresentation2(wallet),
|
43318
43320
|
getTestVc: (_wallet, subject = "did:example:d23dd687a7dc6787646f2eb98d0") => {
|
43319
43321
|
const did = _wallet.pluginMethods.getSubjectDid();
|
43320
43322
|
return {
|
@@ -46359,6 +46361,11 @@ var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
|
|
46359
46361
|
var AchievementCredentialValidator = UnsignedAchievementCredentialValidator.extend({
|
46360
46362
|
proof: ProofValidator.or(ProofValidator.array())
|
46361
46363
|
});
|
46364
|
+
var VerificationCheckValidator = mod.object({
|
46365
|
+
checks: mod.string().array(),
|
46366
|
+
warnings: mod.string().array(),
|
46367
|
+
errors: mod.string().array()
|
46368
|
+
});
|
46362
46369
|
var VerificationStatusValidator = mod.enum(["Success", "Failed", "Error"]);
|
46363
46370
|
var VerificationStatusEnum = VerificationStatusValidator.enum;
|
46364
46371
|
var VerificationItemValidator = mod.object({
|
@@ -48000,6 +48007,32 @@ var defaultCeramicIDXArgs = {
|
|
48000
48007
|
defaultContentFamily: "SuperSkills"
|
48001
48008
|
};
|
48002
48009
|
|
48010
|
+
// src/wallet/plugins/didkit/index.ts
|
48011
|
+
var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async(void 0, null, function* () {
|
48012
|
+
yield didkit_default(input);
|
48013
|
+
return {
|
48014
|
+
pluginMethods: {
|
48015
|
+
generateEd25519KeyFromBytes: (_wallet, bytes) => JSON.parse(generateEd25519KeyFromBytes(bytes)),
|
48016
|
+
keyToDid: (_wallet, type, keypair) => keyToDID(type, JSON.stringify(keypair)),
|
48017
|
+
keyToVerificationMethod: (_wallet, type, keypair) => __async(void 0, null, function* () {
|
48018
|
+
return keyToVerificationMethod(type, JSON.stringify(keypair));
|
48019
|
+
}),
|
48020
|
+
issueCredential: (_wallet, credential, options, keypair) => __async(void 0, null, function* () {
|
48021
|
+
return JSON.parse(yield issueCredential(JSON.stringify(credential), JSON.stringify(options), JSON.stringify(keypair)));
|
48022
|
+
}),
|
48023
|
+
verifyCredential: (_wallet, credential) => __async(void 0, null, function* () {
|
48024
|
+
return JSON.parse(yield verifyCredential(JSON.stringify(credential), "{}"));
|
48025
|
+
}),
|
48026
|
+
issuePresentation: (presentation, options, keypair) => __async(void 0, null, function* () {
|
48027
|
+
return issuePresentation(JSON.stringify(presentation), JSON.stringify(options), JSON.stringify(keypair));
|
48028
|
+
}),
|
48029
|
+
verifyPresentation: (_wallet, presentation) => __async(void 0, null, function* () {
|
48030
|
+
return JSON.parse(yield verifyPresentation(JSON.stringify(presentation), "{}"));
|
48031
|
+
})
|
48032
|
+
}
|
48033
|
+
};
|
48034
|
+
}), "getDidKitPlugin");
|
48035
|
+
|
48003
48036
|
// src/wallet/init.ts
|
48004
48037
|
var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, ..._1], function* (key2, {
|
48005
48038
|
ceramicIdx = defaultCeramicIDXArgs,
|
@@ -48007,7 +48040,8 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
|
|
48007
48040
|
defaultContents = []
|
48008
48041
|
} = {}) {
|
48009
48042
|
yield didkit_default(didkit);
|
48010
|
-
const
|
48043
|
+
const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
|
48044
|
+
const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
|
48011
48045
|
const didkeyAndVCWallet = yield didkeyWallet.addPlugin(yield getVCPlugin(didkeyWallet));
|
48012
48046
|
const idxWallet = yield didkeyAndVCWallet.addPlugin(yield getIDXPlugin(didkeyAndVCWallet, ceramicIdx));
|
48013
48047
|
const wallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
|