@learncard/react 2.3.6 → 2.3.7

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/cjs/index.js CHANGED
@@ -12,7 +12,7 @@ var MiniVCThumbnail = require('./MiniVCThumbnail-ea29644e.js');
12
12
  var Notification = require('./Notification-cf0cdc81.js');
13
13
  var QRCodeCard = require('./QRCodeCard-9f777402.js');
14
14
  var RoundedSquare = require('./RoundedSquare-a577d49f.js');
15
- var VCCard = require('./VCCard-37198c86.js');
15
+ var VCCard = require('./VCCard-5e260b6b.js');
16
16
  var VCDisplayBackFace = require('./VCDisplayBackFace-d0d79b7a.js');
17
17
  var VCDisplayCard = require('./VCDisplayCard-36a39706.js');
18
18
  var VCThumbnail = require('./VCThumbnail-b45b8244.js');
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var VCCard = require('./VCCard-37198c86.js');
5
+ var VCCard = require('./VCCard-5e260b6b.js');
6
6
  require('react');
7
7
  require('stream');
8
8
  require('http');
@@ -12,7 +12,7 @@ var MiniVCThumbnail = require('./MiniVCThumbnail-ea29644e.js');
12
12
  var Notification = require('./Notification-cf0cdc81.js');
13
13
  var QRCodeCard = require('./QRCodeCard-9f777402.js');
14
14
  var RoundedSquare = require('./RoundedSquare-a577d49f.js');
15
- var VCCard = require('./VCCard-37198c86.js');
15
+ var VCCard = require('./VCCard-5e260b6b.js');
16
16
  var VCDisplayBackFace = require('./VCDisplayBackFace-d0d79b7a.js');
17
17
  var VCDisplayCard = require('./VCDisplayCard-36a39706.js');
18
18
  var VCThumbnail = require('./VCThumbnail-b45b8244.js');
@@ -131885,7 +131885,30 @@ var getIDXPlugin = /* @__PURE__ */ __name((_0, _1) => __async$1(void 0, [_0, _1]
131885
131885
  }
131886
131886
  };
131887
131887
  }), "getIDXPlugin");
131888
+ var ED25519_METHODS = ["key", "tz", "pkh:tz", "pkh:tezos", "pkh:sol", "pkh:solana"];
131889
+ var SECP256K1_METHODS = [
131890
+ "key",
131891
+ "tz",
131892
+ "ethr",
131893
+ "pkh:tz",
131894
+ "pkh:tezos",
131895
+ "pkh:eth",
131896
+ "pkh:celo",
131897
+ "pkh:poly",
131898
+ "pkh:btc",
131899
+ "pkh:doge",
131900
+ "pkh:eip155",
131901
+ "pkh:bip122"
131902
+ ];
131888
131903
  var isHex = /* @__PURE__ */ __name((str) => /^[0-9a-f]+$/i.test(str), "isHex");
131904
+ var getAlgorithmForDidMethod = /* @__PURE__ */ __name((didMethod) => {
131905
+ if (ED25519_METHODS.includes(didMethod))
131906
+ return "ed25519";
131907
+ if (SECP256K1_METHODS.includes(didMethod) || didMethod.startsWith("pkh:eip155:") || didMethod.startsWith("pkh:bip122:")) {
131908
+ return "secp256k1";
131909
+ }
131910
+ throw new Error("Unspported Did Method");
131911
+ }, "getAlgorithmForDidMethod");
131889
131912
  var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async$1(void 0, null, function* () {
131890
131913
  if (key2.length === 0)
131891
131914
  throw new Error("Please don't use an empty string for a key!");
@@ -131893,12 +131916,28 @@ var getDidKeyPlugin = /* @__PURE__ */ __name((wallet, key2) => __async$1(void 0,
131893
131916
  throw new Error("Key must be a hexadecimal string!");
131894
131917
  if (key2.length > 64)
131895
131918
  throw new Error("Key must be less than 64 characters");
131896
- const keypair = wallet.pluginMethods.generateEd25519KeyFromBytes(toUint8Array(key2.padStart(64, "0")));
131919
+ const seed = key2.padStart(64, "0");
131920
+ const seedBytes = toUint8Array(seed);
131921
+ const memoizedDids = {};
131922
+ const keyPairs = {
131923
+ ed25519: wallet.pluginMethods.generateEd25519KeyFromBytes(seedBytes),
131924
+ secp256k1: wallet.pluginMethods.generateSecp256k1KeyFromBytes(seedBytes)
131925
+ };
131897
131926
  return {
131898
131927
  pluginMethods: {
131899
- getSubjectDid: (_wallet, type) => wallet.pluginMethods.keyToDid(type, keypair),
131900
- getSubjectKeypair: () => keypair,
131901
- getKey: () => key2.padStart(64, "0")
131928
+ getSubjectDid: (_wallet, type) => {
131929
+ if (!memoizedDids[type]) {
131930
+ const algorithm = getAlgorithmForDidMethod(type);
131931
+ memoizedDids[type] = wallet.pluginMethods.keyToDid(type, keyPairs[algorithm]);
131932
+ }
131933
+ return memoizedDids[type];
131934
+ },
131935
+ getSubjectKeypair: (_wallet, type = "ed25519") => {
131936
+ if (!keyPairs[type])
131937
+ throw new Error("Unsupported algorithm");
131938
+ return keyPairs[type];
131939
+ },
131940
+ getKey: () => seed
131902
131941
  }
131903
131942
  };
131904
131943
  }), "getDidKeyPlugin");
@@ -136793,6 +136832,30 @@ function generateEd25519KeyFromBytes(bytes) {
136793
136832
  }
136794
136833
  }
136795
136834
  __name(generateEd25519KeyFromBytes, "generateEd25519KeyFromBytes");
136835
+ function generateSecp256k1KeyFromBytes(bytes) {
136836
+ try {
136837
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
136838
+ const ptr0 = passArray8ToWasm0(bytes, wasm.__wbindgen_malloc);
136839
+ const len0 = WASM_VECTOR_LEN;
136840
+ wasm.generateSecp256k1KeyFromBytes(retptr, ptr0, len0);
136841
+ var r0 = getInt32Memory0()[retptr / 4 + 0];
136842
+ var r1 = getInt32Memory0()[retptr / 4 + 1];
136843
+ var r2 = getInt32Memory0()[retptr / 4 + 2];
136844
+ var r3 = getInt32Memory0()[retptr / 4 + 3];
136845
+ var ptr1 = r0;
136846
+ var len1 = r1;
136847
+ if (r3) {
136848
+ ptr1 = 0;
136849
+ len1 = 0;
136850
+ throw takeObject(r2);
136851
+ }
136852
+ return getStringFromWasm0(ptr1, len1);
136853
+ } finally {
136854
+ wasm.__wbindgen_add_to_stack_pointer(16);
136855
+ wasm.__wbindgen_free(ptr1, len1);
136856
+ }
136857
+ }
136858
+ __name(generateSecp256k1KeyFromBytes, "generateSecp256k1KeyFromBytes");
136796
136859
  function keyToDID(method_pattern, jwk) {
136797
136860
  try {
136798
136861
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -136880,10 +136943,10 @@ function getArrayU8FromWasm0(ptr, len) {
136880
136943
  return getUint8Memory0().subarray(ptr / 1, ptr / 1 + len);
136881
136944
  }
136882
136945
  __name(getArrayU8FromWasm0, "getArrayU8FromWasm0");
136883
- function __wbg_adapter_108(arg0, arg1, arg2, arg3) {
136946
+ function __wbg_adapter_110(arg0, arg1, arg2, arg3) {
136884
136947
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h3ecfeb7a01c1be81(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
136885
136948
  }
136886
- __name(__wbg_adapter_108, "__wbg_adapter_108");
136949
+ __name(__wbg_adapter_110, "__wbg_adapter_110");
136887
136950
  function load(module, imports) {
136888
136951
  return __async$1(this, null, function* () {
136889
136952
  if (typeof Response === "function" && module instanceof Response) {
@@ -137101,7 +137164,7 @@ function init2(input) {
137101
137164
  const a = state0.a;
137102
137165
  state0.a = 0;
137103
137166
  try {
137104
- return __wbg_adapter_108(a, state0.b, arg02, arg12);
137167
+ return __wbg_adapter_110(a, state0.b, arg02, arg12);
137105
137168
  } finally {
137106
137169
  state0.a = a;
137107
137170
  }
@@ -137207,8 +137270,8 @@ function init2(input) {
137207
137270
  const ret = wasm.memory;
137208
137271
  return addHeapObject(ret);
137209
137272
  };
137210
- imports.wbg.__wbindgen_closure_wrapper10902 = function(arg0, arg1, arg2) {
137211
- const ret = makeMutClosure(arg0, arg1, 3717, __wbg_adapter_24);
137273
+ imports.wbg.__wbindgen_closure_wrapper10913 = function(arg0, arg1, arg2) {
137274
+ const ret = makeMutClosure(arg0, arg1, 3725, __wbg_adapter_24);
137212
137275
  return addHeapObject(ret);
137213
137276
  };
137214
137277
  if (typeof input === "string" || typeof Request === "function" && input instanceof Request || typeof URL === "function" && input instanceof URL) {
@@ -137223,7 +137286,7 @@ function init2(input) {
137223
137286
  __name(init2, "init");
137224
137287
  var didkit_wasm_default = init2;
137225
137288
  var initialized = false;
137226
- var init3 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/jXExSjNXSerFVDMIYOgy") => __async$1(void 0, null, function* () {
137289
+ var init3 = /* @__PURE__ */ __name((arg = "https://cdn.filestackcontent.com/dlXanMvQCGDR76JXcBkA") => __async$1(void 0, null, function* () {
137227
137290
  if (initialized)
137228
137291
  return;
137229
137292
  initialized = true;
@@ -137236,6 +137299,7 @@ var getDidKitPlugin = /* @__PURE__ */ __name((input) => __async$1(void 0, null,
137236
137299
  return {
137237
137300
  pluginMethods: {
137238
137301
  generateEd25519KeyFromBytes: (_wallet, bytes) => JSON.parse(generateEd25519KeyFromBytes(bytes)),
137302
+ generateSecp256k1KeyFromBytes: (_wallet, bytes) => JSON.parse(generateSecp256k1KeyFromBytes(bytes)),
137239
137303
  keyToDid: (_wallet, type, keypair) => {
137240
137304
  const memoizedDid = memoizedDids[type];
137241
137305
  if (!memoizedDid) {
@@ -137276,9 +137340,7 @@ var walletFromKey = /* @__PURE__ */ __name((_0, ..._1) => __async$1(void 0, [_0,
137276
137340
  return {
137277
137341
  _wallet: wallet,
137278
137342
  did: (type = "key") => wallet.pluginMethods.getSubjectDid(type),
137279
- get keypair() {
137280
- return wallet.pluginMethods.getSubjectKeypair();
137281
- },
137343
+ keypair: (type = "ed25519") => wallet.pluginMethods.getSubjectKeypair(type),
137282
137344
  issueCredential: wallet.pluginMethods.issueCredential,
137283
137345
  verifyCredential: verifyCredential2(wallet),
137284
137346
  issuePresentation: wallet.pluginMethods.issuePresentation,
@@ -137354,4 +137416,4 @@ const VCCard = ({ credential, issueeOverride, className = "" }) => {
137354
137416
  };
137355
137417
 
137356
137418
  export { VCCard as V };
137357
- //# sourceMappingURL=VCCard-27020ddd.js.map
137419
+ //# sourceMappingURL=VCCard-d5bd0a82.js.map