@learncard/core 6.0.0 → 6.1.0

Sign up to get free protection for your applications and to get access to all the features.
package/dist/core.esm.js CHANGED
@@ -36013,7 +36013,7 @@ function getImports() {
36013
36013
  const ret = wasm.memory;
36014
36014
  return addHeapObject(ret);
36015
36015
  };
36016
- imports.wbg.__wbindgen_closure_wrapper10020 = function(arg0, arg1, arg2) {
36016
+ imports.wbg.__wbindgen_closure_wrapper10021 = function(arg0, arg1, arg2) {
36017
36017
  const ret = makeMutClosure(arg0, arg1, 3552, __wbg_adapter_24);
36018
36018
  return addHeapObject(ret);
36019
36019
  };
@@ -36050,7 +36050,7 @@ var didkit_wasm_default = init;
36050
36050
 
36051
36051
  // src/didkit/index.ts
36052
36052
  var initialized = false;
36053
- var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/soErM6xgSNqxVeJZzo7v") => __async(void 0, null, function* () {
36053
+ var init2 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/R0BsvnoVRhezGazRDUy5") => __async(void 0, null, function* () {
36054
36054
  if (initialized)
36055
36055
  return;
36056
36056
  initialized = true;
@@ -36115,6 +36115,90 @@ var ExpirationPlugin = /* @__PURE__ */ __name((wallet) => ({
36115
36115
  }
36116
36116
  }), "ExpirationPlugin");
36117
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
+
36118
36202
  // ../../node_modules/.pnpm/zod@3.17.3/node_modules/zod/lib/index.mjs
36119
36203
  var util;
36120
36204
  (function(util2) {
@@ -38859,12 +38943,12 @@ var ImageValidator = mod.string().or(mod.object({
38859
38943
  caption: mod.string().optional()
38860
38944
  }));
38861
38945
  var GeoCoordinatesValidator = mod.object({
38862
- type: mod.string().array().nonempty(),
38946
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38863
38947
  latitude: mod.number(),
38864
38948
  longitude: mod.number()
38865
38949
  });
38866
38950
  var AddressValidator = mod.object({
38867
- type: mod.string().array().nonempty(),
38951
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38868
38952
  addressCountry: mod.string().optional(),
38869
38953
  addressCountryCode: mod.string().optional(),
38870
38954
  addressRegion: mod.string().optional(),
@@ -38895,7 +38979,7 @@ var IdentifierTypeValidator = mod.enum([
38895
38979
  "identifier"
38896
38980
  ]).or(mod.string());
38897
38981
  var IdentifierEntryValidator = mod.object({
38898
- type: mod.string().array().nonempty(),
38982
+ type: mod.string().min(1).or(mod.string().array().nonempty()),
38899
38983
  identifier: mod.string(),
38900
38984
  identifierType: IdentifierTypeValidator
38901
38985
  });
@@ -39115,7 +39199,7 @@ var AchievementSubjectValidator = mod.object({
39115
39199
  activityStartDate: mod.string().optional(),
39116
39200
  creditsEarned: mod.number().optional(),
39117
39201
  achievement: AchievementValidator.optional(),
39118
- identifier: IdentityObjectValidator.optional(),
39202
+ identifier: IdentityObjectValidator.array().optional(),
39119
39203
  image: ImageValidator.optional(),
39120
39204
  licenseNumber: mod.string().optional(),
39121
39205
  narrative: mod.string().optional(),
@@ -39136,7 +39220,7 @@ var EvidenceValidator = mod.object({
39136
39220
  var UnsignedAchievementCredentialValidator = UnsignedVCValidator.extend({
39137
39221
  name: mod.string().optional(),
39138
39222
  description: mod.string().optional(),
39139
- image: mod.string().optional(),
39223
+ image: ImageValidator.optional(),
39140
39224
  credentialSubject: AchievementSubjectValidator.or(AchievementSubjectValidator.array()),
39141
39225
  endorsement: UnsignedVCValidator.array().optional(),
39142
39226
  evidence: EvidenceValidator.array().optional()
@@ -40783,9 +40867,12 @@ var verifyCredential2 = /* @__PURE__ */ __name((wallet) => {
40783
40867
  // src/wallet/initializers/emptyWallet.ts
40784
40868
  var emptyWallet = /* @__PURE__ */ __name((..._0) => __async(void 0, [..._0], function* ({ didkit } = {}) {
40785
40869
  const didkitWallet = yield (yield generateWallet()).addPlugin(yield getDidKitPlugin(didkit));
40786
- const wallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
40870
+ const expirationWallet = yield didkitWallet.addPlugin(ExpirationPlugin(didkitWallet));
40871
+ const wallet = yield expirationWallet.addPlugin(getVCTemplatesPlugin(expirationWallet));
40787
40872
  return {
40788
40873
  _wallet: wallet,
40874
+ newCredential: wallet.pluginMethods.newCredential,
40875
+ newPresentation: wallet.pluginMethods.newPresentation,
40789
40876
  verifyCredential: verifyCredential2(wallet),
40790
40877
  verifyPresentation: wallet.pluginMethods.verifyPresentation,
40791
40878
  resolveDid: wallet.pluginMethods.resolveDid
@@ -53658,9 +53745,6 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async(void 0, n
53658
53745
  };
53659
53746
  }), "getDidKeyPlugin");
53660
53747
 
53661
- // src/wallet/helpers/wallet.helpers.ts
53662
- var recycleDependents = /* @__PURE__ */ __name((_methods) => ({}), "recycleDependents");
53663
-
53664
53748
  // src/wallet/plugins/vc/issueCredential.ts
53665
53749
  var issueCredential2 = /* @__PURE__ */ __name((initWallet) => {
53666
53750
  return (wallet, credential) => __async(void 0, null, function* () {
@@ -53704,7 +53788,7 @@ var verifyPresentation2 = /* @__PURE__ */ __name((initWallet) => {
53704
53788
  }, "verifyPresentation");
53705
53789
 
53706
53790
  // src/wallet/plugins/vc/vc.ts
53707
- var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, function* () {
53791
+ var getVCPlugin = /* @__PURE__ */ __name((wallet) => {
53708
53792
  return {
53709
53793
  pluginMethods: __spreadProps(__spreadValues({}, recycleDependents(wallet.pluginMethods)), {
53710
53794
  issueCredential: issueCredential2(wallet),
@@ -53734,7 +53818,7 @@ var getVCPlugin = /* @__PURE__ */ __name((wallet) => __async(void 0, null, funct
53734
53818
  })
53735
53819
  })
53736
53820
  };
53737
- }), "getVCPlugin");
53821
+ }, "getVCPlugin");
53738
53822
 
53739
53823
  // src/wallet/plugins/EthereumPlugin/index.ts
53740
53824
  import { ethers as ethers2 } from "ethers";
@@ -57085,8 +57169,9 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57085
57169
  } = {}) {
57086
57170
  const didkitWallet = yield (yield generateWallet(defaultContents)).addPlugin(yield getDidKitPlugin(didkit));
57087
57171
  const didkeyWallet = yield didkitWallet.addPlugin(yield getDidKeyPlugin(didkitWallet, key2));
57088
- const didkeyAndVCWallet = yield didkeyWallet.addPlugin(yield getVCPlugin(didkeyWallet));
57089
- const idxWallet = yield didkeyAndVCWallet.addPlugin(yield getIDXPlugin(didkeyAndVCWallet, ceramicIdx));
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));
57090
57175
  const expirationWallet = yield idxWallet.addPlugin(ExpirationPlugin(idxWallet));
57091
57176
  const ethWallet = yield expirationWallet.addPlugin(getEthereumPlugin(expirationWallet, ethereumConfig));
57092
57177
  const wallet = yield ethWallet.addPlugin(getVpqrPlugin(ethWallet));
@@ -57094,6 +57179,8 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async(void 0, [_0, .
57094
57179
  _wallet: wallet,
57095
57180
  did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
57096
57181
  keypair: (type = "ed25519") => wallet.pluginMethods.getSubjectKeypair(type),
57182
+ newCredential: wallet.pluginMethods.newCredential,
57183
+ newPresentation: wallet.pluginMethods.newPresentation,
57097
57184
  issueCredential: wallet.pluginMethods.issueCredential,
57098
57185
  verifyCredential: verifyCredential2(wallet),
57099
57186
  issuePresentation: wallet.pluginMethods.issuePresentation,