iso-signatures 0.1.9 → 0.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.
@@ -1 +1,2 @@
1
+ export {};
1
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/signers/ecdsa.js"],"names":[],"mappings":"AAoBA;;;;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"}
@@ -1,5 +1,5 @@
1
1
  import type { DIDKey } from 'iso-did/key';
2
- import type { SignatureAlgorithm, KeyType } from 'iso-did/types';
2
+ import type { KeyType, SignatureAlgorithm } from 'iso-did/types';
3
3
  export interface ISigner<Export extends CryptoKeyPair | string> {
4
4
  /**
5
5
  * JWT signing algorithm
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAEhE,MAAM,WAAW,OAAO,CAAC,MAAM,SAAS,aAAa,GAAG,MAAM;IAC5D;;OAEG;IACH,GAAG,EAAE,kBAAkB,CAAA;IACvB;;OAEG;IACH,IAAI,EAAE,OAAO,CAAA;IACb;;OAEG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;IAEb,GAAG,EAAE,MAAM,CAAA;IACX;;OAEG;IACH,IAAI,EAAE,CAAC,OAAO,EAAE,UAAU,KAAK,OAAO,CAAC,UAAU,CAAC,CAAA;IAElD,MAAM,EAAE,MAAM,MAAM,CAAA;CACrB;AAED,MAAM,WAAW,WAAW;IAC1B,SAAS,EAAE,UAAU,CAAA;IACrB,OAAO,EAAE,UAAU,CAAA;IACnB,SAAS,EAAE,UAAU,CAAA;CACtB;AACD,MAAM,MAAM,MAAM,GAAG,CAAC,KAAK,EAAE,WAAW,KAAK,OAAO,CAAC,OAAO,CAAC,CAAA;AAE7D,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,kBAAkB,IAAI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ACpC;AAED,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,MAAM,CAAA;IACX,GAAG,EAAE,MAAM,CAAA;IACX,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,MAAM,WAAW,gBAAiB,SAAQ,eAAe;IACvD,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;IACT,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;IACV,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG;IAAE,CAAC,EAAE,MAAM,CAAA;CAAE,CAAA"}
@@ -1 +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"}
1
+ {"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/ecdsa.js"],"names":[],"mappings":"AA8CA;;;;;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"}
@@ -1 +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"}
1
+ {"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/eddsa.js"],"names":[],"mappings":"AAWuT,gFAAyC;AAJhW,mDAAmD;AACnD,uBADW,OAAO,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAG9C"}
@@ -10,7 +10,7 @@ export class Resolver implements IResolver {
10
10
  * @param {import('../types').ResolverOptions} options
11
11
  */
12
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">>;
13
+ registry: Partial<import("../types").Verifier<"EdDSA" | "ES256" | "ES384" | "ES512" | "ES256K" | "RS256">>;
14
14
  cache: import("../types").Cache;
15
15
  /** @type {IResolver['verify']} */
16
16
  verify(input: import("../types").ResolverVerifyInput): Promise<boolean>;
@@ -1 +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"}
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,2GAAwB;IACxB,gCACmE;IAGrE,kCAAkC;IAClC,wEAAS;CAQV;wBA7DY,OAAO,UAAU,EAAE,SAAS"}
@@ -1 +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"}
1
+ {"version":3,"file":"rsa.d.ts","sourceRoot":"","sources":["../../../src/verifiers/rsa.js"],"names":[],"mappings":"AAyBM,mFAAyC;AAJ/C,sDAAsD;AACtD,uBADW,OAAO,aAAa,EAAE,QAAQ,CAAC,OAAO,CAAC,CAGjD"}
package/package.json CHANGED
@@ -1,14 +1,15 @@
1
1
  {
2
2
  "name": "iso-signatures",
3
- "version": "0.1.9",
3
+ "type": "module",
4
+ "version": "0.2.0",
4
5
  "description": "Signatures tooling.",
5
6
  "author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)",
6
7
  "license": "MIT",
8
+ "homepage": "https://github.com/hugomrdias/iso-repo/tree/main/packages/iso-signatures",
7
9
  "repository": {
8
10
  "url": "hugomrdias/iso-repo",
9
11
  "directory": "packages/iso-signatures"
10
12
  },
11
- "homepage": "https://github.com/hugomrdias/iso-repo/tree/main/packages/iso-signatures",
12
13
  "keywords": [
13
14
  "elliptic",
14
15
  "curve",
@@ -25,49 +26,21 @@
25
26
  "rsa",
26
27
  "signatures"
27
28
  ],
28
- "type": "module",
29
- "main": "src/index.js",
30
- "types": "dist/src/index.d.ts",
31
29
  "exports": {
32
30
  ".": {
33
31
  "types": "./dist/src/index.d.ts",
34
32
  "import": "./src/index.js"
35
33
  },
36
- "./signers/ecdsa": {
37
- "types": "./dist/src/signers/ecdsa.d.ts",
38
- "import": "./src/signers/ecdsa.js"
39
- },
40
- "./signers/eddsa": {
41
- "types": "./dist/src/signers/eddsa.d.ts",
42
- "import": "./src/signers/eddsa.js"
43
- },
44
- "./signers/rsa-old": {
45
- "types": "./dist/src/signers/rsa-old.d.ts",
46
- "import": "./src/signers/rsa-old.js"
34
+ "./types": {
35
+ "types": "./dist/src/types.d.ts"
47
36
  },
48
- "./signers/rsa": {
49
- "types": "./dist/src/signers/rsa.d.ts",
50
- "import": "./src/signers/rsa.js"
37
+ "./signers/*": {
38
+ "types": "./dist/src/signers/*",
39
+ "default": "./src/signers/*"
51
40
  },
52
- "./verifiers/ecdsa": {
53
- "types": "./dist/src/verifiers/ecdsa.d.ts",
54
- "import": "./src/verifiers/ecdsa.js"
55
- },
56
- "./verifiers/eddsa": {
57
- "types": "./dist/src/verifiers/eddsa.d.ts",
58
- "import": "./src/verifiers/eddsa.js"
59
- },
60
- "./verifiers/rsa-old": {
61
- "types": "./dist/src/verifiers/rsa-old.d.ts",
62
- "import": "./src/verifiers/rsa-old.js"
63
- },
64
- "./verifiers/rsa": {
65
- "types": "./dist/src/verifiers/rsa.d.ts",
66
- "import": "./src/verifiers/rsa.js"
67
- },
68
- "./verifiers/resolver": {
69
- "types": "./dist/src/verifiers/resolver.d.ts",
70
- "import": "./src/verifiers/resolver.js"
41
+ "./verifiers/*": {
42
+ "types": "./dist/src/verifiers/*",
43
+ "import": "./src/verifiers/*"
71
44
  },
72
45
  "./asn1": {
73
46
  "types": "./dist/src/asn1.d.ts",
@@ -78,11 +51,16 @@
78
51
  "import": "./src/spki.js"
79
52
  }
80
53
  },
54
+ "main": "src/index.js",
55
+ "types": "dist/src/index.d.ts",
81
56
  "typesVersions": {
82
57
  "*": {
83
58
  ".": [
84
59
  "dist/src/index"
85
60
  ],
61
+ "types": [
62
+ "dist/src/types"
63
+ ],
86
64
  "signers/*": [
87
65
  "dist/src/signers/*"
88
66
  ],
@@ -104,19 +82,18 @@
104
82
  ],
105
83
  "dependencies": {
106
84
  "@noble/ed25519": "^2.0.0",
107
- "iso-base": "^1.1.2",
108
- "iso-did": "^1.3.1"
85
+ "iso-base": "^2.0.1",
86
+ "iso-did": "^1.4.0"
109
87
  },
110
88
  "devDependencies": {
111
- "@types/assert": "^1.5.6",
112
- "@types/mocha": "^10.0.1",
113
- "@types/node": "^20.4.3",
114
- "assert": "^2.0.0",
115
- "hd-scripts": "^7.0.0",
89
+ "@types/assert": "^1.5.10",
90
+ "@types/mocha": "^10.0.6",
91
+ "@types/node": "^20.10.4",
92
+ "assert": "^2.1.0",
116
93
  "mocha": "^10.2.0",
117
- "playwright-test": "^12.1.1",
118
- "type-fest": "^4.0.0",
119
- "typescript": "5.1.6"
94
+ "playwright-test": "^14.0.0",
95
+ "type-fest": "^4.8.3",
96
+ "typescript": "5.3.3"
120
97
  },
121
98
  "publishConfig": {
122
99
  "provenance": true
@@ -125,9 +102,6 @@
125
102
  "extends": [
126
103
  "../../node_modules/hd-scripts/eslint/index.js"
127
104
  ],
128
- "parserOptions": {
129
- "project": "./tsconfig.json"
130
- },
131
105
  "env": {
132
106
  "mocha": true
133
107
  },
@@ -143,13 +117,14 @@
143
117
  "@types/*",
144
118
  "hd-scripts",
145
119
  "assert",
146
- "type-fest"
120
+ "type-fest",
121
+ "mocha"
147
122
  ]
148
123
  },
149
124
  "scripts": {
150
- "lint": "tsc --build && eslint '**/*.{js,ts}' && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
125
+ "lint": "tsc --build && eslint . && prettier --check '**/*.{js,ts,yml,json}' --ignore-path ../../.gitignore",
151
126
  "test": "tsc --build && pnpm run test:node && pnpm run test:browser",
152
- "test:node": "mocha 'test/**/!(*.browser).test.js'",
153
- "test:browser": "playwright-test 'test/**/!(*.node).test.js'"
127
+ "test:node": "pw-test 'test/**/!(*.browser).test.js' --mode node",
128
+ "test:browser": "pw-test 'test/**/!(*.node).test.js'"
154
129
  }
155
130
  }
package/readme.md CHANGED
@@ -13,6 +13,7 @@ pnpm install iso-signatures
13
13
  ```js
14
14
  import { EdDSASigner } from 'iso-signatures/signers/eddsa'
15
15
  import * as EdDSA from 'iso-signatures/verifiers/eddsa'
16
+ import { Resolver } from 'iso-signatures/verifiers/resolver'
16
17
 
17
18
  const message = new TextEncoder().encode('hello world')
18
19
  const resolver = new Resolver({
@@ -32,6 +33,7 @@ import { EdDSASigner } from 'iso-signatures/signers/eddsa'
32
33
  import * as EdDSA from 'iso-signatures/verifiers/eddsa'
33
34
  import * as ECDSA from 'iso-signatures/verifiers/ecdsa'
34
35
  import * as RSA from 'iso-signatures/verifiers/rsa'
36
+ import { Resolver } from 'iso-signatures/verifiers/resolver'
35
37
 
36
38
  const message = new TextEncoder().encode('hello world')
37
39
  const resolver = new Resolver(
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
1
  import { webcrypto } from 'iso-base/crypto'
3
2
  import { u8 } from 'iso-base/utils'
4
3
  import { DIDKey, keyTypeToAlg } from 'iso-did/key'
package/src/types.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { DIDKey } from 'iso-did/key'
2
- import type { SignatureAlgorithm, KeyType } from 'iso-did/types'
2
+ import type { KeyType, SignatureAlgorithm } from 'iso-did/types'
3
3
 
4
4
  export interface ISigner<Export extends CryptoKeyPair | string> {
5
5
  /**
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
1
  import { webcrypto } from 'iso-base/crypto'
3
2
  import { decompress, isCompressed } from 'iso-base/ec-compression'
4
3
  import { createEcdsaParams } from '../utils.js'
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
1
  import { verifyAsync } from '@noble/ed25519'
3
2
 
4
3
  /** @type {import('../types').Verify} */
@@ -1,4 +1,3 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
1
  import { webcrypto } from 'iso-base/crypto'
3
2
  import { spki } from '../spki.js'
4
3
 
@@ -1,53 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,4 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,128 +0,0 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
- import { webcrypto } from 'iso-base/crypto'
3
- import { u8 } from 'iso-base/utils'
4
- import { DIDKey } from 'iso-did/key'
5
-
6
- /**
7
- * @typedef {import('../types.js').ISigner<CryptoKeyPair>} ISigner
8
- */
9
-
10
- /**
11
- * RSA Old fission format signer
12
- *
13
- * @implements {ISigner}
14
- */
15
- export class RSAOldSigner {
16
- /** @type {Extract<import('iso-did/types').SignatureAlgorithm, "RS256_OLD">} */
17
- static alg = 'RS256_OLD'
18
-
19
- /** @type {Extract<import('iso-did/types').KeyType, "RSA_OLD">} */
20
- static type = 'RSA_OLD'
21
-
22
- /**
23
- * @param {Uint8Array} publicKey
24
- * @param {CryptoKeyPair} keypair
25
- */
26
- constructor(publicKey, keypair) {
27
- this.keypair = keypair
28
- this.publicKey = publicKey
29
- this.alg = RSAOldSigner.alg
30
- this.type = RSAOldSigner.type
31
- this.did = DIDKey.fromPublicKey(RSAOldSigner.type, this.publicKey)
32
- }
33
-
34
- /**
35
- * Generate a new signer
36
- */
37
- static async generate() {
38
- const cryptoKeyPair = await webcrypto.subtle.generateKey(
39
- {
40
- name: 'RSASSA-PKCS1-v1_5',
41
- modulusLength: 2048,
42
- publicExponent: new Uint8Array([0x01, 0x00, 0x01]),
43
- hash: { name: 'SHA-256' },
44
- },
45
-
46
- false,
47
- ['sign', 'verify']
48
- )
49
-
50
- const publicKey = await webcrypto.subtle.exportKey(
51
- 'spki',
52
- cryptoKeyPair.publicKey
53
- )
54
-
55
- return new RSAOldSigner(u8(publicKey), cryptoKeyPair)
56
- }
57
-
58
- /**
59
- * Import a signer from a JWK
60
- *
61
- * @param {import('../types.js').PrivateKeyRSAJwk} jwk
62
- */
63
- static async importJwk(jwk) {
64
- const privateKey = await webcrypto.subtle.importKey(
65
- 'jwk',
66
- jwk,
67
- {
68
- name: 'RSASSA-PKCS1-v1_5',
69
- hash: 'SHA-256',
70
- },
71
- false,
72
- ['sign']
73
- )
74
- const publicKeyJWK = await webcrypto.subtle.importKey(
75
- 'jwk',
76
- { ...jwk, d: undefined },
77
- {
78
- name: 'RSASSA-PKCS1-v1_5',
79
- hash: 'SHA-256',
80
- },
81
- true,
82
- ['verify']
83
- )
84
-
85
- const publicKey = await webcrypto.subtle.exportKey('spki', publicKeyJWK)
86
-
87
- return new RSAOldSigner(u8(publicKey), {
88
- privateKey,
89
- publicKey: publicKeyJWK,
90
- })
91
- }
92
-
93
- /**
94
- * Import a signer from a keypair
95
- *
96
- * @param {CryptoKeyPair} keypair
97
- */
98
- static async import(keypair) {
99
- const publicKey = await webcrypto.subtle.exportKey(
100
- 'spki',
101
- keypair.publicKey
102
- )
103
-
104
- return new RSAOldSigner(u8(publicKey), keypair)
105
- }
106
-
107
- /**
108
- * Sign a message
109
- *
110
- * @param {Uint8Array} message
111
- */
112
- async sign(message) {
113
- const buf = await webcrypto.subtle.sign(
114
- { name: 'RSASSA-PKCS1-v1_5', saltLength: 128 },
115
- this.keypair.privateKey,
116
- message
117
- )
118
-
119
- return u8(buf)
120
- }
121
-
122
- /**
123
- * Export the signer as a crypto key pair
124
- */
125
- export() {
126
- return this.keypair
127
- }
128
- }
@@ -1,25 +0,0 @@
1
- /* eslint-disable unicorn/numeric-separators-style */
2
- import { webcrypto } from 'iso-base/crypto'
3
-
4
- /** @type {import('../types.js').Verify} */
5
- export async function verify({ signature, message, publicKey }) {
6
- const key = await webcrypto.subtle.importKey(
7
- 'spki',
8
- publicKey,
9
- { name: 'RSASSA-PKCS1-v1_5', hash: { name: 'SHA-256' } },
10
- true,
11
- ['verify']
12
- )
13
-
14
- return await webcrypto.subtle.verify(
15
- { name: 'RSASSA-PKCS1-v1_5', saltLength: 128 },
16
- key,
17
- signature,
18
- message
19
- )
20
- }
21
-
22
- /** @type {import('../types.js').Verifier<'RS256_OLD'>} */
23
- export const verifier = {
24
- RS256_OLD: verify,
25
- }