@learncard/didkey-plugin 1.1.20 → 1.1.21

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.
@@ -116,4 +116,4 @@ var getDidKeyPlugin = /* @__PURE__ */ __name(async (learnCard, key, defaultDidMe
116
116
  }
117
117
  };
118
118
  }, "getDidKeyPlugin");
119
- //# sourceMappingURL=didkey-plugin.cjs.development.js.map
119
+ //# sourceMappingURL=didkey-plugin.cjs.development.cjs.map
@@ -1,2 +1,2 @@
1
1
  "use strict";var d=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var D=Object.prototype.hasOwnProperty;var t=(e,r)=>d(e,"name",{value:r,configurable:!0});var w=(e,r)=>{for(var o in r)d(e,o,{get:r[o],enumerable:!0})},b=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let s of k(r))!D.call(e,s)&&s!==o&&d(e,s,{get:()=>r[s],enumerable:!(a=m(r,s))||a.enumerable});return e};var K=e=>b(d({},"__esModule",{value:!0}),e);var P={};w(P,{getDidKeyPlugin:()=>x});module.exports=K(P);function y(e){var r=0,o=e.length,a=[];if(o%2)throw new Error("invalid hex:"+e);for(;r<o;r+=2)a.push(parseInt(e.substr(r,2),16));return new Uint8Array(a)}t(y,"toUint8Array");var f=require("@learncard/helpers");var E=["key","tz","pkh:tz","pkh:tezos","pkh:sol","pkh:solana"],A=["key","tz","ethr","pkh:tz","pkh:tezos","pkh:eth","pkh:celo","pkh:poly","pkh:btc","pkh:doge","pkh:eip155","pkh:bip122"],g=t(e=>{if(E.includes(e))return"ed25519";if(A.includes(e)||e.startsWith("pkh:eip155:")||e.startsWith("pkh:bip122:"))return"secp256k1";throw new Error("Unspported Did Method")},"getAlgorithmForDidMethod");var u=!1,x=t(async(e,r,o)=>{if(r.length===0)throw new Error("Please don't use an empty string for a key!");if(!(0,f.isHex)(r))throw new Error("Key must be a hexadecimal string!");if(r.length>64)throw new Error("Key must be less than 64 characters");r.length<64&&!u&&(u=!0,console.warn("Warning: A LearnCard has been initialized with a seed that is less than 32 bytes, and will be padded with zeroes"),console.warn("Please instantiate LearnCards using 32 bytes that have been randomly generated in a cryptographically secure fashion!"),console.warn("See https://app.gitbook.com/o/6uDv1QDlxaaZC7i8EaGb/s/FXvEJ9j3Vf3FW5Nc557n/learn-card-packages/learncard-core/instantiation#key-generation for details"));let a=r.padStart(64,"0"),s=y(a),h={},p={ed25519:e.invoke.generateEd25519KeyFromBytes(s),secp256k1:e.invoke.generateSecp256k1KeyFromBytes(s)},c=t((n=o)=>{if(!h[n]){let i=g(n);h[n]=e.invoke.keyToDid(n,p[i])}return h[n]},"did"),l=t((n="ed25519")=>{if(!p[n])throw new Error("Unsupported algorithm");return p[n]},"keypair");return{name:"DID Key",displayName:"DID Key",description:"Generates dids and JWKs using 32 Secure Random Bytes of Entropy",id:{did:t((n,i)=>c(i),"did"),keypair:t((n,i)=>l(i),"keypair")},methods:{getSubjectDid:t((n,i=o)=>c(i),"getSubjectDid"),getSubjectKeypair:t((n,i="ed25519")=>l(i),"getSubjectKeypair"),getKey:t(()=>a,"getKey")}}},"getDidKeyPlugin");
2
- //# sourceMappingURL=didkey-plugin.cjs.production.min.js.map
2
+ //# sourceMappingURL=didkey-plugin.cjs.production.min.cjs.map
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  if (process.env.NODE_ENV === 'production') {
4
- module.exports = require('./didkey-plugin.cjs.production.min.js');
4
+ module.exports = require('./didkey-plugin.cjs.production.min.cjs');
5
5
  } else {
6
- module.exports = require('./didkey-plugin.cjs.development.js');
6
+ module.exports = require('./didkey-plugin.cjs.development.cjs');
7
7
  }
@@ -0,0 +1,9 @@
1
+ import { LearnCard } from '@learncard/core';
2
+ import { DidKeyPlugin, DependentMethods } from './types';
3
+ export * from './types';
4
+ /**
5
+ *
6
+ * @group Plugins
7
+ */
8
+ export declare const getDidKeyPlugin: <DidMethod extends string>(learnCard: LearnCard<any, any, DependentMethods<DidMethod>>, key: string, defaultDidMethod: DidMethod) => Promise<DidKeyPlugin<DidMethod>>;
9
+ //# sourceMappingURL=index.d.ts.map
package/package.json CHANGED
@@ -1,9 +1,22 @@
1
1
  {
2
2
  "name": "@learncard/didkey-plugin",
3
- "version": "1.1.20",
3
+ "version": "1.1.21",
4
4
  "description": "",
5
- "main": "./dist/index.js",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
6
7
  "module": "./dist/didkey-plugin.esm.js",
8
+ "exports": {
9
+ ".": {
10
+ "import": {
11
+ "types": "./dist/index.d.ts",
12
+ "default": "./dist/didkey-plugin.esm.js"
13
+ },
14
+ "require": {
15
+ "types": "./dist/index.d.cts",
16
+ "default": "./dist/index.cjs"
17
+ }
18
+ }
19
+ },
7
20
  "files": [
8
21
  "dist"
9
22
  ],
@@ -27,17 +40,17 @@
27
40
  "jest": "^29.3.0",
28
41
  "shx": "^0.3.4",
29
42
  "ts-jest": "^29.0.3",
30
- "@learncard/types": "5.17.0"
43
+ "@learncard/types": "5.17.1"
31
44
  },
32
45
  "types": "./dist/index.d.ts",
33
46
  "dependencies": {
34
47
  "hex-lite": "^1.5.0",
35
- "@learncard/core": "9.4.20",
36
- "@learncard/helpers": "^1.3.2"
48
+ "@learncard/core": "9.4.21",
49
+ "@learncard/helpers": "^1.3.3"
37
50
  },
38
51
  "sideEffects": false,
39
52
  "scripts": {
40
- "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.js && tsc --p tsconfig.json",
53
+ "build": "node ./scripts/build.mjs && shx cp ./scripts/mixedEntypoint.js ./dist/index.cjs && tsc --p tsconfig.json && shx cp ./dist/index.d.ts ./dist/index.d.cts",
41
54
  "test": "jest --passWithNoTests",
42
55
  "test:watch": "jest --watch",
43
56
  "test:coverage": "jest --silent --ci --coverage --coverageReporters=\"text\" --coverageReporters=\"text-summary\""