iso-signatures 0.1.5 → 0.1.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.
@@ -0,0 +1,57 @@
1
+ /**
2
+ * ECDSA signer
3
+ *
4
+ * @implements {ISigner}
5
+ */
6
+ export class ECDSASigner implements ISigner {
7
+ /**
8
+ * Generate a new signer
9
+ *
10
+ * @param {ECDSAAlg} alg
11
+ */
12
+ static generate(alg: ECDSAAlg): Promise<ECDSASigner>;
13
+ /**
14
+ * Import a signer from a JWK
15
+ *
16
+ * @param {import('../types.js').PrivateKeyJwk} jwk
17
+ */
18
+ static importJwk(jwk: import('../types.js').PrivateKeyJwk): Promise<ECDSASigner>;
19
+ /**
20
+ * Import a signer from a CryptoKeyPair
21
+ *
22
+ * @param {CryptoKeyPair} key
23
+ */
24
+ static import(key: CryptoKeyPair): Promise<ECDSASigner>;
25
+ /**
26
+ * @param {ECDSAAlg} alg
27
+ * @param {Uint8Array} publicKey
28
+ * @param {CryptoKeyPair} keypair
29
+ */
30
+ constructor(alg: ECDSAAlg, publicKey: Uint8Array, keypair: CryptoKeyPair);
31
+ params: {
32
+ name: "ECDSA";
33
+ namedCurve: "P-256" | "P-384" | "P-521";
34
+ hash: "SHA-256" | "SHA-384" | "SHA-512";
35
+ };
36
+ keypair: CryptoKeyPair;
37
+ publicKey: Uint8Array;
38
+ alg: "ES256" | "ES384" | "ES512";
39
+ type: "P-256" | "P-384" | "P-521";
40
+ did: DIDKey;
41
+ /**
42
+ * Sign a message
43
+ *
44
+ * @param {Uint8Array} message
45
+ */
46
+ sign(message: Uint8Array): Promise<Uint8Array>;
47
+ /**
48
+ * Export the signer as a CryptoKeyPair
49
+ *
50
+ * @returns {CryptoKeyPair}
51
+ */
52
+ export(): CryptoKeyPair;
53
+ }
54
+ export type ISigner = import('../types.js').ISigner<CryptoKeyPair>;
55
+ export type ECDSAAlg = Extract<import('iso-did/types').SignatureAlgorithm, 'ES256' | 'ES384' | 'ES512'>;
56
+ import { DIDKey } from 'iso-did/key';
57
+ //# sourceMappingURL=ecdsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/signers/ecdsa.js"],"names":[],"mappings":"AAqBA;;;;GAIG;AACH;IAeE;;;;OAIG;IACH,qBAFW,QAAQ,wBAelB;IAED;;;;OAIG;IACH,sBAFW,OAAO,aAAa,EAAE,aAAa,wBA0B7C;IAED;;;;OAIG;IACH,mBAFW,aAAa,wBA0BvB;IA9FD;;;;OAIG;IACH,iBAJW,QAAQ,aACR,UAAU,WACV,aAAa,EASvB;IANC;;;;MAAoC;IACpC,uBAAsB;IACtB,sBAA0B;IAC1B,iCAAc;IACd,kCAAkC;IAClC,YAA0D;IAqF5D;;;;OAIG;IACH,cAFW,UAAU,uBAUpB;IAED;;;;OAIG;IACH,UAFa,aAAa,CAIzB;CACF;sBA3IY,OAAO,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;uBAC5C,QAAQ,OAAO,eAAe,EAAE,kBAAkB,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;uBALxD,aAAa"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * @typedef {import('../types.js').ISigner<string>} ISigner
3
+ */
4
+ /**
5
+ * EdDSA signer
6
+ *
7
+ * @implements {ISigner}
8
+ */
9
+ export class EdDSASigner implements ISigner {
10
+ /** @type {Extract<import('iso-did/types').SignatureAlgorithm, "EdDSA">} */
11
+ static alg: Extract<import('iso-did/types').SignatureAlgorithm, "EdDSA">;
12
+ /** @type {Extract<import('iso-did/types').KeyType, "Ed25519">} */
13
+ static type: Extract<import('iso-did/types').KeyType, "Ed25519">;
14
+ static code: number;
15
+ /**
16
+ * Generate a new signer
17
+ *
18
+ * @param {Uint8Array} [bytes]
19
+ */
20
+ static generate(bytes?: Uint8Array | undefined): Promise<EdDSASigner>;
21
+ /**
22
+ * Import a signer from a encoded string
23
+ *
24
+ * @param {string} encoded
25
+ */
26
+ static import(encoded: string): Promise<EdDSASigner>;
27
+ /**
28
+ * @param {Uint8Array} publicKey
29
+ * @param {Uint8Array} privateKey
30
+ */
31
+ constructor(publicKey: Uint8Array, privateKey: Uint8Array);
32
+ privateKey: Uint8Array;
33
+ publicKey: Uint8Array;
34
+ alg: "EdDSA";
35
+ type: "Ed25519";
36
+ code: number;
37
+ did: DIDKey;
38
+ /**
39
+ * Sign a message
40
+ *
41
+ * @param {Uint8Array} message
42
+ */
43
+ sign(message: Uint8Array): Promise<Uint8Array>;
44
+ /**
45
+ * Export the signer as a encoded string
46
+ */
47
+ export(): string;
48
+ }
49
+ export type ISigner = import('../types.js').ISigner<string>;
50
+ import { DIDKey } from 'iso-did/key';
51
+ //# sourceMappingURL=eddsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/signers/eddsa.js"],"names":[],"mappings":"AAUA;;GAEG;AAEH;;;;GAIG;AACH;IACE,2EAA2E;IAC3E,YADW,QAAQ,OAAO,eAAe,EAAE,kBAAkB,EAAE,OAAO,CAAC,CACnD;IAEpB,kEAAkE;IAClE,aADW,QAAQ,OAAO,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CACvC;IAEvB,oBAAoB;IAepB;;;;OAIG;IACH,sEAIC;IAED;;;;OAIG;IACH,uBAFW,MAAM,wBAOhB;IAlCD;;;OAGG;IACH,uBAHW,UAAU,cACV,UAAU,EASpB;IANC,uBAA4B;IAC5B,sBAA0B;IAC1B,aAA0B;IAC1B,gBAA4B;IAC5B,aAA4B;IAC5B,YAAiE;IA0BnE;;;;OAIG;IACH,cAFW,UAAU,uBAIpB;IAED;;OAEG;IACH,iBAEC;CACF;sBApEY,OAAO,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;uBAN3B,aAAa"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * @typedef {import('../types.js').ISigner<CryptoKeyPair>} ISigner
3
+ */
4
+ /**
5
+ * RSA Old fission format signer
6
+ *
7
+ * @implements {ISigner}
8
+ */
9
+ export class RSAOldSigner implements ISigner {
10
+ /** @type {Extract<import('iso-did/types').SignatureAlgorithm, "RS256_OLD">} */
11
+ static alg: Extract<import('iso-did/types').SignatureAlgorithm, "RS256_OLD">;
12
+ /** @type {Extract<import('iso-did/types').KeyType, "RSA_OLD">} */
13
+ static type: Extract<import('iso-did/types').KeyType, "RSA_OLD">;
14
+ /**
15
+ * Generate a new signer
16
+ */
17
+ static generate(): Promise<RSAOldSigner>;
18
+ /**
19
+ * Import a signer from a JWK
20
+ *
21
+ * @param {import('../types.js').PrivateKeyRSAJwk} jwk
22
+ */
23
+ static importJwk(jwk: import('../types.js').PrivateKeyRSAJwk): Promise<RSAOldSigner>;
24
+ /**
25
+ * Import a signer from a keypair
26
+ *
27
+ * @param {CryptoKeyPair} keypair
28
+ */
29
+ static import(keypair: CryptoKeyPair): Promise<RSAOldSigner>;
30
+ /**
31
+ * @param {Uint8Array} publicKey
32
+ * @param {CryptoKeyPair} keypair
33
+ */
34
+ constructor(publicKey: Uint8Array, keypair: CryptoKeyPair);
35
+ keypair: CryptoKeyPair;
36
+ publicKey: Uint8Array;
37
+ alg: "RS256_OLD";
38
+ type: "RSA_OLD";
39
+ did: DIDKey;
40
+ /**
41
+ * Sign a message
42
+ *
43
+ * @param {Uint8Array} message
44
+ */
45
+ sign(message: Uint8Array): Promise<Uint8Array>;
46
+ /**
47
+ * Export the signer as a crypto key pair
48
+ */
49
+ export(): CryptoKeyPair;
50
+ }
51
+ export type ISigner = import('../types.js').ISigner<CryptoKeyPair>;
52
+ import { DIDKey } from 'iso-did/key';
53
+ //# sourceMappingURL=rsa-old.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa-old.d.ts","sourceRoot":"","sources":["../../../src/signers/rsa-old.js"],"names":[],"mappings":"AAKA;;GAEG;AAEH;;;;GAIG;AACH;IACE,+EAA+E;IAC/E,YADW,QAAQ,OAAO,eAAe,EAAE,kBAAkB,EAAE,WAAW,CAAC,CACnD;IAExB,kEAAkE;IAClE,aADW,QAAQ,OAAO,eAAe,EAAE,OAAO,EAAE,SAAS,CAAC,CACvC;IAcvB;;OAEG;IACH,yCAmBC;IAED;;;;OAIG;IACH,sBAFW,OAAO,aAAa,EAAE,gBAAgB,yBA8BhD;IAED;;;;OAIG;IACH,uBAFW,aAAa,yBASvB;IAnFD;;;OAGG;IACH,uBAHW,UAAU,WACV,aAAa,EAQvB;IALC,uBAAsB;IACtB,sBAA0B;IAC1B,iBAA2B;IAC3B,gBAA6B;IAC7B,YAAkE;IA4EpE;;;;OAIG;IACH,cAFW,UAAU,uBAUpB;IAED;;OAEG;IACH,wBAEC;CACF;sBAzHY,OAAO,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;uBAHlC,aAAa"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * @typedef {import('../types.js').ISigner<CryptoKeyPair>} ISigner
3
+ */
4
+ /**
5
+ * RSA signer
6
+ *
7
+ * @implements {ISigner}
8
+ */
9
+ export class RSASigner implements ISigner {
10
+ /** @type {Extract<import('iso-did/types').SignatureAlgorithm, "RS256">} */
11
+ static alg: Extract<import('iso-did/types').SignatureAlgorithm, "RS256">;
12
+ /** @type {Extract<import('iso-did/types').KeyType, "RSA">} */
13
+ static type: Extract<import('iso-did/types').KeyType, "RSA">;
14
+ static code: number;
15
+ /**
16
+ * Generate a new signer
17
+ */
18
+ static generate(): Promise<RSASigner>;
19
+ /**
20
+ * Import a signer from a JWK
21
+ *
22
+ * @param {import('../types.js').PrivateKeyRSAJwk} jwk
23
+ */
24
+ static importJwk(jwk: import('../types.js').PrivateKeyRSAJwk): Promise<RSASigner>;
25
+ /**
26
+ * Import a signer from a keypair
27
+ *
28
+ * @param {CryptoKeyPair} keypair
29
+ */
30
+ static import(keypair: CryptoKeyPair): Promise<RSASigner>;
31
+ /**
32
+ * @param {Uint8Array} publicKey
33
+ * @param {CryptoKeyPair} keypair
34
+ */
35
+ constructor(publicKey: Uint8Array, keypair: CryptoKeyPair);
36
+ keypair: CryptoKeyPair;
37
+ publicKey: Uint8Array;
38
+ alg: "RS256";
39
+ type: "RSA";
40
+ code: number;
41
+ did: DIDKey;
42
+ /**
43
+ * Sign a message
44
+ *
45
+ * @param {Uint8Array} message
46
+ */
47
+ sign(message: Uint8Array): Promise<Uint8Array>;
48
+ /**
49
+ * Export the signer as a crypto key pair
50
+ */
51
+ export(): CryptoKeyPair;
52
+ }
53
+ export type ISigner = import('../types.js').ISigner<CryptoKeyPair>;
54
+ import { DIDKey } from 'iso-did/key';
55
+ //# sourceMappingURL=rsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa.d.ts","sourceRoot":"","sources":["../../../src/signers/rsa.js"],"names":[],"mappings":"AAMA;;GAEG;AAEH;;;;GAIG;AACH;IACE,2EAA2E;IAC3E,YADW,QAAQ,OAAO,eAAe,EAAE,kBAAkB,EAAE,OAAO,CAAC,CACnD;IAEpB,8DAA8D;IAC9D,aADW,QAAQ,OAAO,eAAe,EAAE,OAAO,EAAE,KAAK,CAAC,CACvC;IAGnB,oBAAoB;IAepB;;OAEG;IACH,sCAmBC;IAED;;;;OAIG;IACH,sBAFW,OAAO,aAAa,EAAE,gBAAgB,sBA8BhD;IAED;;;;OAIG;IACH,uBAFW,aAAa,sBASvB;IApFD;;;OAGG;IACH,uBAHW,UAAU,WACV,aAAa,EASvB;IANC,uBAAsB;IACtB,sBAA0B;IAC1B,aAAwB;IACxB,YAA0B;IAC1B,aAA0B;IAC1B,YAA+D;IA4EjE;;;;OAIG;IACH,cAFW,UAAU,uBAUpB;IAED;;OAEG;IACH,wBAEC;CACF;sBA7HY,OAAO,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;uBAJlC,aAAa"}
@@ -0,0 +1,10 @@
1
+ /**
2
+ *
3
+ * @param {'ES256' | 'ES384' | 'ES512'} type
4
+ * @param {import('../types.js').VerifyInput} param1
5
+ * @returns
6
+ */
7
+ export function verify(type: 'ES256' | 'ES384' | 'ES512', { signature, message, publicKey }: import('../types.js').VerifyInput): Promise<boolean>;
8
+ /** @type {import('../types.js').Verifier<'ES256' | 'ES384' | 'ES512'>} */
9
+ export const verifier: import('../types.js').Verifier<'ES256' | 'ES384' | 'ES512'>;
10
+ //# sourceMappingURL=ecdsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/ecdsa.js"],"names":[],"mappings":"AA+CA;;;;;GAKG;AACH,6BAJW,OAAO,GAAG,OAAO,GAAG,OAAO,qCAC3B,OAAO,aAAa,EAAE,WAAW,oBAK3C;AAfD,0EAA0E;AAC1E,uBADW,OAAO,aAAa,EAAE,QAAQ,CAAC,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC,CAKrE"}
@@ -0,0 +1,4 @@
1
+ export function verify(input: import("../types").VerifyInput): Promise<boolean>;
2
+ /** @type {import('../types').Verifier<'EdDSA'>} */
3
+ export const verifier: import('../types').Verifier<'EdDSA'>;
4
+ //# sourceMappingURL=eddsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/eddsa.js"],"names":[],"mappings":"AAYiQ,gFAAyC;AAJ1S,mDAAmD;AACnD,uBADW,OAAO,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAG9C"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Verifier resolver
3
+ *
4
+ * @implements {IResolver}
5
+ */
6
+ export class Resolver implements IResolver {
7
+ /**
8
+ *
9
+ * @param {import('../types').VerifierRegistry<import('iso-did/types').SignatureAlgorithm>} registry
10
+ * @param {import('../types').ResolverOptions} options
11
+ */
12
+ constructor(registry?: import('../types').VerifierRegistry<import('iso-did/types').SignatureAlgorithm>, options?: import('../types').ResolverOptions);
13
+ registry: Partial<import("../types").Verifier<"EdDSA" | "ES256" | "ES384" | "ES512" | "ES256K" | "RS256" | "RS256_OLD">>;
14
+ cache: import("../types").Cache;
15
+ /** @type {IResolver['verify']} */
16
+ verify(input: import("../types").ResolverVerifyInput): Promise<boolean>;
17
+ }
18
+ export type IResolver = import('../types').IResolver;
19
+ //# sourceMappingURL=resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../../src/verifiers/resolver.js"],"names":[],"mappings":"AAoCA;;;;GAIG;AACH;IACE;;;;OAIG;IACH,uBAHW,OAAO,UAAU,EAAE,gBAAgB,CAAC,OAAO,eAAe,EAAE,kBAAkB,CAAC,YAC/E,OAAO,UAAU,EAAE,eAAe,EAM5C;IAHC,yHAAwB;IACxB,gCACmE;IAGrE,kCAAkC;IAClC,wEAAS;CAQV;wBA7DY,OAAO,UAAU,EAAE,SAAS"}
@@ -0,0 +1,4 @@
1
+ export function verify(input: import("../types.js").VerifyInput): Promise<boolean>;
2
+ /** @type {import('../types.js').Verifier<'RS256_OLD'>} */
3
+ export const verifier: import('../types.js').Verifier<'RS256_OLD'>;
4
+ //# sourceMappingURL=rsa-old.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa-old.d.ts","sourceRoot":"","sources":["../../../src/verifiers/rsa-old.js"],"names":[],"mappings":"AAuBc,mFAEkB;AAJhC,0DAA0D;AAC1D,uBADW,OAAO,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,CAGrD"}
@@ -0,0 +1,4 @@
1
+ export function verify(input: import("../types.js").VerifyInput): Promise<boolean>;
2
+ /** @type {import('../types.js').Verifier<'RS256'>} */
3
+ export const verifier: import('../types.js').Verifier<'RS256'>;
4
+ //# sourceMappingURL=rsa.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/rsa.js"],"names":[],"mappings":"AAsBoD,mFAExC;AAFZ,sDAAsD;AACtD,uBADW,OAAO,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAGjD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iso-signatures",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "description": "Signatures tooling.",
5
5
  "author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)",
6
6
  "license": "MIT",
@@ -68,6 +68,14 @@
68
68
  "./verifiers/resolver": {
69
69
  "types": "./dist/src/verifiers/resolver.d.ts",
70
70
  "import": "./src/verifiers/resolver.js"
71
+ },
72
+ "./asn1": {
73
+ "types": "./dist/src/asn1.d.ts",
74
+ "import": "./src/asn1.js"
75
+ },
76
+ "./spki": {
77
+ "types": "./dist/src/spki.d.ts",
78
+ "import": "./src/spki.js"
71
79
  }
72
80
  },
73
81
  "typesVersions": {
@@ -80,13 +88,19 @@
80
88
  ],
81
89
  "verifiers/*": [
82
90
  "dist/src/verifiers/*"
91
+ ],
92
+ "./asn1": [
93
+ "./dist/src/asn1"
94
+ ],
95
+ "./spki": [
96
+ "./dist/src/spki"
83
97
  ]
84
98
  }
85
99
  },
86
100
  "files": [
87
101
  "src",
88
- "dist/src/*.d.ts",
89
- "dist/src/*.d.ts.map"
102
+ "dist/src/**/*.d.ts",
103
+ "dist/src/**/*.d.ts.map"
90
104
  ],
91
105
  "dependencies": {
92
106
  "@noble/ed25519": "^2.0.0",
@@ -96,13 +110,13 @@
96
110
  "devDependencies": {
97
111
  "@types/assert": "^1.5.6",
98
112
  "@types/mocha": "^10.0.1",
99
- "@types/node": "^20.3.1",
113
+ "@types/node": "^20.4.0",
100
114
  "assert": "^2.0.0",
101
115
  "hd-scripts": "^7.0.0",
102
116
  "mocha": "^10.2.0",
103
- "playwright-test": "^9.2.0",
117
+ "playwright-test": "^11.0.3",
104
118
  "type-fest": "^3.12.0",
105
- "typescript": "5.1.3"
119
+ "typescript": "5.1.6"
106
120
  },
107
121
  "eslintConfig": {
108
122
  "extends": [