iso-signatures 0.3.2 → 0.4.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.
- package/dist/src/asn1.d.ts +6 -6
- package/dist/src/asn1.d.ts.map +1 -1
- package/dist/src/signers/ecdsa.d.ts +26 -18
- package/dist/src/signers/ecdsa.d.ts.map +1 -1
- package/dist/src/signers/eddsa.d.ts +21 -18
- package/dist/src/signers/eddsa.d.ts.map +1 -1
- package/dist/src/signers/eip191.d.ts +549 -0
- package/dist/src/signers/eip191.d.ts.map +1 -0
- package/dist/src/signers/es256k.d.ts +55 -0
- package/dist/src/signers/es256k.d.ts.map +1 -0
- package/dist/src/signers/rsa.d.ts +9 -18
- package/dist/src/signers/rsa.d.ts.map +1 -1
- package/dist/src/spki.d.ts +2 -2
- package/dist/src/spki.d.ts.map +1 -1
- package/dist/src/types.d.ts +11 -7
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils.d.ts +1 -12
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/verifiers/ecdsa.d.ts +4 -4
- package/dist/src/verifiers/ecdsa.d.ts.map +1 -1
- package/dist/src/verifiers/eddsa.d.ts +2 -2
- package/dist/src/verifiers/eddsa.d.ts.map +1 -1
- package/dist/src/verifiers/eip191.d.ts +15 -0
- package/dist/src/verifiers/eip191.d.ts.map +1 -0
- package/dist/src/verifiers/resolver.d.ts +4 -4
- package/dist/src/verifiers/resolver.d.ts.map +1 -1
- package/dist/src/verifiers/rsa.d.ts +1 -1
- package/dist/src/verifiers/rsa.d.ts.map +1 -1
- package/package.json +16 -24
- package/src/signers/ecdsa.js +86 -34
- package/src/signers/eddsa.js +33 -22
- package/src/signers/eip191.js +95 -0
- package/src/signers/es256k.js +121 -0
- package/src/signers/rsa.js +10 -20
- package/src/types.ts +19 -9
- package/src/utils.js +6 -42
- package/src/verifiers/ecdsa.js +26 -12
- package/src/verifiers/eddsa.js +4 -4
- package/src/verifiers/eip191.js +47 -0
- package/src/verifiers/resolver.js +7 -5
- package/src/verifiers/rsa.js +2 -2
package/dist/src/asn1.d.ts
CHANGED
|
@@ -15,17 +15,17 @@ export function into(input: Uint8Array, expectedTag: number, offset: number): {
|
|
|
15
15
|
position: number;
|
|
16
16
|
length: number;
|
|
17
17
|
};
|
|
18
|
-
export function encodeBitString(input: Uint8Array): Uint8Array
|
|
19
|
-
export function encodeOctetString(input: Uint8Array): Uint8Array
|
|
20
|
-
export function encodeSequence(sequence: Uint8Array[]): Uint8Array
|
|
21
|
-
export function readSequence(bytes: Uint8Array, offset?: number): Uint8Array
|
|
22
|
-
export function encodeInt(input: Uint8Array): Uint8Array
|
|
18
|
+
export function encodeBitString(input: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
19
|
+
export function encodeOctetString(input: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
20
|
+
export function encodeSequence(sequence: Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
21
|
+
export function readSequence(bytes: Uint8Array, offset?: number): Uint8Array<ArrayBufferLike>;
|
|
22
|
+
export function encodeInt(input: Uint8Array): Uint8Array<ArrayBuffer>;
|
|
23
23
|
export function enterSequence(bytes: Uint8Array, offset?: number): number;
|
|
24
24
|
export function skipSequence(bytes: Uint8Array, offset?: number): number;
|
|
25
25
|
export function skipInt(bytes: Uint8Array, offset?: number): number;
|
|
26
26
|
export function readBitString(bytes: Uint8Array, offset?: number): Uint8Array;
|
|
27
27
|
export function readInt(bytes: Uint8Array, byteOffset?: number): Uint8Array;
|
|
28
28
|
export function readOctetString(bytes: Uint8Array, offset?: number): Uint8Array;
|
|
29
|
-
export function readSequenceWith(readers: [Reader, ...Reader[]], source: Uint8Array, byteOffset?: number): Uint8Array[];
|
|
29
|
+
export function readSequenceWith(readers: [Reader, ...Reader[]], source: Uint8Array, byteOffset?: number): Uint8Array<ArrayBufferLike>[];
|
|
30
30
|
export type Reader = (bytes: Uint8Array, offset: number) => Uint8Array;
|
|
31
31
|
//# sourceMappingURL=asn1.d.ts.map
|
package/dist/src/asn1.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"asn1.d.ts","sourceRoot":"","sources":["../../src/asn1.js"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"asn1.d.ts","sourceRoot":"","sources":["../../src/asn1.js"],"names":[],"mappings":"AAIA,sBAAuB,CAAI,CAAA;AAC3B,4BAA6B,CAAI,CAAA;AACjC,+BAAgC,CAAI,CAAA;AACpC,uBAAwB,CAAI,CAAA;AAC5B,yBAA0B,CAAI,CAAA;AAC9B,2BAA4B,EAAI,CAAA;AAEhC,6BAA8B,CAAI,CAAA;AAM3B,wCAHI,MAAM,GACJ,UAAU,CAetB;AAOM,qCAJI,UAAU,WACV,MAAM,GACJ;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAC,CAsB9C;AAQM,4BALI,UAAU,eACV,MAAM,YACN,MAAM,GACJ,MAAM,CAKlB;AAQM,4BALI,UAAU,eACV,MAAM,UACN,MAAM,GACJ;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAmBhD;AAKM,uCAFI,UAAU,2BA8BpB;AAKM,yCAFI,UAAU,2BAqBpB;AAKM,yCAFI,UAAU,EAAE,2BAgCtB;AAMM,oCAHI,UAAU,WACV,MAAM,+BAMhB;AAKM,iCAFI,UAAU,2BAkCpB;AAQM,qCALI,UAAU,WACV,MAAM,GACJ,MAAM,CAIyB;AAOrC,oCAJI,UAAU,WACV,MAAM,GACJ,MAAM,CAGgB;AAO5B,+BAJI,UAAU,WACV,MAAM,GACJ,MAAM,CAEuD;AAOnE,qCAJI,UAAU,WACV,MAAM,GACJ,UAAU,CAiBtB;AAOM,+BAJI,UAAU,eACV,MAAM,GACJ,UAAU,CAgBtB;AAOM,uCAJI,UAAU,WACV,MAAM,GACJ,UAAU,CAMtB;AAQM,0CAJI,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,UACrB,UAAU,eACV,MAAM,iCAYhB;qBAfY,CAAC,KAAK,EAAC,UAAU,EAAE,MAAM,EAAC,MAAM,KAAK,UAAU"}
|
|
@@ -1,56 +1,64 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ECDSA
|
|
2
|
+
* Create web crypto params for ECDSA.
|
|
3
|
+
*
|
|
4
|
+
* @param {Curves} curve
|
|
5
|
+
* @returns {{name: 'ECDSA', namedCurve: 'P-256' | 'P-384' | 'P-521', hash: 'SHA-256' | 'SHA-384' | 'SHA-512'}}
|
|
6
|
+
*/
|
|
7
|
+
export function createEcdsaParams(curve: Curves): {
|
|
8
|
+
name: "ECDSA";
|
|
9
|
+
namedCurve: "P-256" | "P-384" | "P-521";
|
|
10
|
+
hash: "SHA-256" | "SHA-384" | "SHA-512";
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* ECDSA signer for ES256, ES384, and ES512 using WebCrypto
|
|
3
14
|
*
|
|
4
15
|
* @implements {ISigner}
|
|
5
16
|
*/
|
|
6
|
-
export class ECDSASigner implements ISigner {
|
|
17
|
+
export class ECDSASigner extends DID implements ISigner {
|
|
7
18
|
/**
|
|
8
19
|
* Generate a new signer
|
|
9
20
|
*
|
|
10
|
-
* @param {
|
|
21
|
+
* @param {Curves} curve
|
|
11
22
|
*/
|
|
12
|
-
static generate(
|
|
23
|
+
static generate(curve: Curves): Promise<ECDSASigner>;
|
|
13
24
|
/**
|
|
14
25
|
* Import a signer from a JWK
|
|
15
26
|
*
|
|
16
27
|
* @param {import('iso-did/types').ECJWKPrivate} jwk
|
|
17
28
|
* @param {import('iso-did/types').VerifiableDID} [did]
|
|
18
29
|
*/
|
|
19
|
-
static importJwk(jwk: import(
|
|
30
|
+
static importJwk(jwk: import("iso-did/types").ECJWKPrivate, did?: import("iso-did/types").VerifiableDID): Promise<ECDSASigner>;
|
|
20
31
|
/**
|
|
21
32
|
* Import a signer from a CryptoKeyPair
|
|
22
33
|
*
|
|
23
34
|
* @param {CryptoKeyPair} key
|
|
24
35
|
* @param {import('iso-did/types').VerifiableDID} [did]
|
|
25
36
|
*/
|
|
26
|
-
static import(key: CryptoKeyPair, did?: import("iso-did/types").VerifiableDID
|
|
37
|
+
static import(key: CryptoKeyPair, did?: import("iso-did/types").VerifiableDID): Promise<ECDSASigner>;
|
|
27
38
|
/**
|
|
28
39
|
* @param {import('iso-did/types').VerifiableDID} did
|
|
29
40
|
* @param {CryptoKeyPair} keypair
|
|
30
41
|
*/
|
|
31
|
-
constructor(did: import(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
publicKey: Uint8Array;
|
|
36
|
-
alg: "ES256" | "ES384" | "ES512";
|
|
37
|
-
document: import("iso-did/types").DIDDocument;
|
|
38
|
-
didKey: `did:${string}:${string}`;
|
|
42
|
+
constructor(did: import("iso-did/types").VerifiableDID, keypair: CryptoKeyPair);
|
|
43
|
+
/** @type {import('../types.js').SignatureType} */
|
|
44
|
+
signatureType: import("../types.js").SignatureType;
|
|
45
|
+
curve: "P-256" | "P-384" | "P-521";
|
|
39
46
|
/**
|
|
40
47
|
* Sign a message
|
|
41
48
|
*
|
|
42
49
|
* @param {Uint8Array} message
|
|
43
50
|
*/
|
|
44
|
-
sign(message: Uint8Array): Promise<Uint8Array
|
|
51
|
+
sign(message: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>;
|
|
45
52
|
/**
|
|
46
53
|
* Export the signer as a CryptoKeyPair
|
|
47
54
|
*
|
|
48
55
|
* @returns {CryptoKeyPair}
|
|
49
56
|
*/
|
|
50
57
|
export(): CryptoKeyPair;
|
|
51
|
-
toString(): string;
|
|
52
58
|
#private;
|
|
53
59
|
}
|
|
54
|
-
export type ISigner = import(
|
|
55
|
-
export type
|
|
60
|
+
export type ISigner = import("../types.js").ISigner<CryptoKeyPair>;
|
|
61
|
+
export type Curves = Extract<import("iso-did/types").KeyType, "P-256" | "P-384" | "P-521">;
|
|
62
|
+
export type SignatureTypes = Extract<import("../types.js").SignatureType, "ES256" | "ES384" | "ES512">;
|
|
63
|
+
import { DID } from 'iso-did';
|
|
56
64
|
//# sourceMappingURL=ecdsa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/signers/ecdsa.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ecdsa.d.ts","sourceRoot":"","sources":["../../../src/signers/ecdsa.js"],"names":[],"mappings":"AAwCA;;;;;GAKG;AACH,yCAHW,MAAM,GACJ;IAAC,IAAI,EAAE,OAAO,CAAC;IAAC,UAAU,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;IAAC,IAAI,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,CAAA;CAAC,CA8B7G;AAED;;;;GAIG;AACH,gDAFgB,OAAO;IAuBrB;;;;OAIG;IACH,uBAFW,MAAM,wBAkBhB;IAED;;;;;OAKG;IACH,sBAHW,OAAO,eAAe,EAAE,YAAY,QACpC,OAAO,eAAe,EAAE,aAAa,wBA2B/C;IAED;;;;;OAKG;IACH,mBAHW,aAAa,QACb,OAAO,eAAe,EAAE,aAAa,wBA2B/C;IAnGD;;;OAGG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,WACrC,aAAa,EAQvB;IAZD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAOX,mCAA+C;IA+FjD;;;;OAIG;IACH,cAFW,UAAU,wCAUpB;IAED;;;;OAIG;IACH,UAFa,aAAa,CAIzB;;CAKF;sBAnNY,OAAO,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC;qBAC5C,OAAO,CAAC,OAAO,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;6BACrE,OAAO,CAAC,OAAO,aAAa,EAAE,aAAa,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,CAAC;oBAPlE,SAAS"}
|
|
@@ -3,49 +3,52 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @implements {ISigner}
|
|
5
5
|
*/
|
|
6
|
-
export class EdDSASigner implements ISigner {
|
|
7
|
-
/**
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
6
|
+
export class EdDSASigner extends DID implements ISigner {
|
|
7
|
+
/**
|
|
8
|
+
* Multibase code for ed25519 private key
|
|
9
|
+
* @see https://github.com/multiformats/multicodec/blob/3bc7f4c20afe28e10d9d539e2a565578de6dd71c/table.csv#L181
|
|
10
|
+
* @type {number}
|
|
11
|
+
*/
|
|
11
12
|
static code: number;
|
|
12
13
|
/**
|
|
13
14
|
* Generate a new signer
|
|
14
15
|
*
|
|
15
16
|
* @param {Uint8Array} [bytes]
|
|
16
17
|
*/
|
|
17
|
-
static generate(bytes?: Uint8Array
|
|
18
|
+
static generate(bytes?: Uint8Array): Promise<EdDSASigner>;
|
|
18
19
|
/**
|
|
19
20
|
* Import a signer from a encoded string
|
|
20
21
|
*
|
|
21
22
|
* @param {string} encoded
|
|
22
23
|
* @param {import('iso-did/types').VerifiableDID} [did]
|
|
23
24
|
*/
|
|
24
|
-
static import(encoded: string, did?: import("iso-did/types").VerifiableDID
|
|
25
|
+
static import(encoded: string, did?: import("iso-did/types").VerifiableDID): Promise<EdDSASigner>;
|
|
26
|
+
/**
|
|
27
|
+
* Import a signer from a JWK
|
|
28
|
+
*
|
|
29
|
+
* @param {import('iso-did/types').OKPJWKPrivate} jwk
|
|
30
|
+
* @param {import('iso-did/types').VerifiableDID} [did] - Optional DID to verify the JWK
|
|
31
|
+
*/
|
|
32
|
+
static importJwk(jwk: import("iso-did/types").OKPJWKPrivate, did?: import("iso-did/types").VerifiableDID): EdDSASigner;
|
|
25
33
|
/**
|
|
26
34
|
* @param {import('iso-did/types').VerifiableDID} did
|
|
27
35
|
* @param {Uint8Array} privateKey
|
|
28
36
|
*/
|
|
29
|
-
constructor(did: import(
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
type: "P-256" | "P-384" | "P-521" | "Ed25519" | "secp256k1" | "RSA";
|
|
33
|
-
publicKey: Uint8Array;
|
|
34
|
-
alg: "EdDSA" | "ES256" | "ES384" | "ES512" | "ES256K" | "RS256";
|
|
35
|
-
document: import("iso-did/types").DIDDocument;
|
|
36
|
-
didKey: `did:${string}:${string}`;
|
|
37
|
+
constructor(did: import("iso-did/types").VerifiableDID, privateKey: Uint8Array);
|
|
38
|
+
/** @type {import('../types.js').SignatureType} */
|
|
39
|
+
signatureType: import("../types.js").SignatureType;
|
|
37
40
|
/**
|
|
38
41
|
* Sign a message
|
|
39
42
|
*
|
|
40
43
|
* @param {Uint8Array} message
|
|
41
44
|
*/
|
|
42
|
-
sign(message: Uint8Array): Promise<
|
|
45
|
+
sign(message: Uint8Array): Promise<import("@noble/ed25519").Bytes>;
|
|
43
46
|
/**
|
|
44
47
|
* Export the signer as a encoded string
|
|
45
48
|
*/
|
|
46
49
|
export(): string;
|
|
47
|
-
toString(): string;
|
|
48
50
|
#private;
|
|
49
51
|
}
|
|
50
|
-
export type ISigner = import(
|
|
52
|
+
export type ISigner = import("../types.js").ISigner<string>;
|
|
53
|
+
import { DID } from 'iso-did';
|
|
51
54
|
//# sourceMappingURL=eddsa.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/signers/eddsa.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/signers/eddsa.js"],"names":[],"mappings":"AA0BA;;;;GAIG;AACH,gDAFgB,OAAO;IAGrB;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAmBpB;;;;OAIG;IACH,wBAFW,UAAU,wBASpB;IAED;;;;;OAKG;IACH,uBAHW,MAAM,QACN,OAAO,eAAe,EAAE,aAAa,wBAU/C;IAED;;;;;OAKG;IACH,sBAHW,OAAO,eAAe,EAAE,aAAa,QACrC,OAAO,eAAe,EAAE,aAAa,eAU/C;IAvDD;;;OAGG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,cACrC,UAAU,EAOpB;IAZD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IA2Db;;;;OAIG;IACH,cAFW,UAAU,2CAIpB;IAED;;OAEG;IACH,iBAEC;;CAKF;sBA5GY,OAAO,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;oBAR9B,SAAS"}
|