iso-signatures 0.5.1 → 0.5.2
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/signers/eddsa.d.ts +1 -1
- package/dist/src/signers/eddsa.d.ts.map +1 -1
- package/dist/src/signers/eip191.d.ts +104 -5
- package/dist/src/signers/eip191.d.ts.map +1 -1
- package/dist/src/signers/es256k.d.ts +1 -1
- package/dist/src/signers/es256k.d.ts.map +1 -1
- package/dist/src/verifiers/eip191.d.ts +1 -1
- package/dist/src/verifiers/eip191.d.ts.map +1 -1
- package/license +9 -0
- package/package.json +14 -12
- package/src/signers/eip191.js +1 -1
- package/src/verifiers/eip191.js +20 -10
|
@@ -42,7 +42,7 @@ export class EdDSASigner extends DID implements ISigner {
|
|
|
42
42
|
*
|
|
43
43
|
* @param {Uint8Array} message
|
|
44
44
|
*/
|
|
45
|
-
sign(message: Uint8Array): Promise<import("@noble/ed25519").Bytes
|
|
45
|
+
sign(message: Uint8Array): Promise<import("@noble/ed25519").Bytes & Uint8Array<ArrayBuffer>>;
|
|
46
46
|
/**
|
|
47
47
|
* Export the signer as a encoded string
|
|
48
48
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/signers/eddsa.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,gDAFgB,OAAO;IAGrB;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAmBpB;;;;OAIG;IACH,wBAFW,UAAU,wBAiBpB;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;IA/DD;;;OAGG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,cACrC,UAAU,EAOpB;IAZD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAmEb;;;;OAIG;IACH,cAFW,UAAU,
|
|
1
|
+
{"version":3,"file":"eddsa.d.ts","sourceRoot":"","sources":["../../../src/signers/eddsa.js"],"names":[],"mappings":"AAyBA;;;;GAIG;AACH,gDAFgB,OAAO;IAGrB;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAmBpB;;;;OAIG;IACH,wBAFW,UAAU,wBAiBpB;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;IA/DD;;;OAGG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,cACrC,UAAU,EAOpB;IAZD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAmEb;;;;OAIG;IACH,cAFW,UAAU,qEAIpB;IAED;;OAEG;IACH,iBAEC;;CAKF;sBApHY,OAAO,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;oBAP9B,SAAS"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @typedef {import('../types.js').ISigner<string>} ISigner
|
|
3
3
|
* @typedef {import('ox').Provider.Provider} Provider
|
|
4
|
+
* @typedef {import('eventemitter3').EventEmitter} EventEmitter
|
|
4
5
|
*/
|
|
5
6
|
/**
|
|
6
7
|
* EIP191 signer
|
|
@@ -44,7 +45,7 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
44
45
|
/** @type {import('../types.js').SignatureType} */
|
|
45
46
|
signatureType: import("../types.js").SignatureType;
|
|
46
47
|
provider: {
|
|
47
|
-
request: Provider.RequestFn<{
|
|
48
|
+
request: import("ox/Provider").RequestFn<{
|
|
48
49
|
Request: {
|
|
49
50
|
method: "eth_accounts";
|
|
50
51
|
params?: undefined;
|
|
@@ -248,6 +249,12 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
248
249
|
params: [serializedTransaction: import("ox/Hex").Hex];
|
|
249
250
|
};
|
|
250
251
|
ReturnType: import("ox/Hex").Hex;
|
|
252
|
+
} | {
|
|
253
|
+
Request: {
|
|
254
|
+
method: "eth_sendRawTransactionSync";
|
|
255
|
+
params: [serializedTransaction: import("ox/Hex").Hex] | [serializedTransaction: import("ox/Hex").Hex, timeout: number];
|
|
256
|
+
};
|
|
257
|
+
ReturnType: import("ox/TransactionReceipt").Rpc;
|
|
251
258
|
} | {
|
|
252
259
|
Request: {
|
|
253
260
|
method: "eth_sendTransaction";
|
|
@@ -259,7 +266,7 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
259
266
|
method: "eth_simulateV1";
|
|
260
267
|
params: [{
|
|
261
268
|
blockStateCalls: readonly {
|
|
262
|
-
blockOverrides?: import("
|
|
269
|
+
blockOverrides?: import("viem").RpcBlockOverrides | undefined;
|
|
263
270
|
calls?: readonly import("ox/TransactionRequest").Rpc[] | undefined;
|
|
264
271
|
stateOverrides?: import("ox/StateOverrides").Rpc | undefined;
|
|
265
272
|
}[];
|
|
@@ -311,6 +318,12 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
311
318
|
params: [serializedTransaction: import("ox/Hex").Hex];
|
|
312
319
|
};
|
|
313
320
|
ReturnType: import("ox/Hex").Hex;
|
|
321
|
+
} | {
|
|
322
|
+
Request: {
|
|
323
|
+
method: "eth_sendRawTransactionSync";
|
|
324
|
+
params: [serializedTransaction: import("ox/Hex").Hex] | [serializedTransaction: import("ox/Hex").Hex, timeout: number];
|
|
325
|
+
};
|
|
326
|
+
ReturnType: import("ox/TransactionReceipt").Rpc;
|
|
314
327
|
} | {
|
|
315
328
|
Request: {
|
|
316
329
|
method: "eth_sendTransaction";
|
|
@@ -525,8 +538,94 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
525
538
|
};
|
|
526
539
|
ReturnType: boolean;
|
|
527
540
|
}>;
|
|
528
|
-
|
|
529
|
-
|
|
541
|
+
eventNames?: (() => ("accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message")[]) | undefined;
|
|
542
|
+
listeners?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T) => ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
543
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
544
|
+
chainChanged: (chainId: string) => void;
|
|
545
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
546
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
547
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
548
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void)[]) | undefined;
|
|
549
|
+
listenerCount?: ((event: "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message") => number) | undefined;
|
|
550
|
+
emit?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, ...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
551
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
552
|
+
chainChanged: (chainId: string) => void;
|
|
553
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
554
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
555
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
556
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => boolean) | undefined;
|
|
557
|
+
on?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
558
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
559
|
+
chainChanged: (chainId: string) => void;
|
|
560
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
561
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
562
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
563
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
564
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
565
|
+
chainChanged: (chainId: string) => void;
|
|
566
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
567
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
568
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
569
|
+
}, any>) | undefined;
|
|
570
|
+
addListener?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
571
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
572
|
+
chainChanged: (chainId: string) => void;
|
|
573
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
574
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
575
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
576
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
577
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
578
|
+
chainChanged: (chainId: string) => void;
|
|
579
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
580
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
581
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
582
|
+
}, any>) | undefined;
|
|
583
|
+
once?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
584
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
585
|
+
chainChanged: (chainId: string) => void;
|
|
586
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
587
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
588
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
589
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
590
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
591
|
+
chainChanged: (chainId: string) => void;
|
|
592
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
593
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
594
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
595
|
+
}, any>) | undefined;
|
|
596
|
+
removeListener?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
597
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
598
|
+
chainChanged: (chainId: string) => void;
|
|
599
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
600
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
601
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
602
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void) | undefined, context?: any, once?: boolean) => import("eventemitter3").EventEmitter<{
|
|
603
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
604
|
+
chainChanged: (chainId: string) => void;
|
|
605
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
606
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
607
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
608
|
+
}, any>) | undefined;
|
|
609
|
+
off?: (<T extends "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
610
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
611
|
+
chainChanged: (chainId: string) => void;
|
|
612
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
613
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
614
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
615
|
+
}>[Extract<T, "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message">]) => void) | undefined, context?: any, once?: boolean) => import("eventemitter3").EventEmitter<{
|
|
616
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
617
|
+
chainChanged: (chainId: string) => void;
|
|
618
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
619
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
620
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
621
|
+
}, any>) | undefined;
|
|
622
|
+
removeAllListeners?: ((event?: "accountsChanged" | "chainChanged" | "connect" | "disconnect" | "message" | undefined) => import("eventemitter3").EventEmitter<{
|
|
623
|
+
accountsChanged: (accounts: readonly import("ox/Address").Address[]) => void;
|
|
624
|
+
chainChanged: (chainId: string) => void;
|
|
625
|
+
connect: (connectInfo: import("ox/Provider").ConnectInfo) => void;
|
|
626
|
+
disconnect: (error: import("ox/Provider").ProviderRpcError) => void;
|
|
627
|
+
message: (message: import("ox/Provider").Message) => void;
|
|
628
|
+
}, any>) | undefined;
|
|
530
629
|
};
|
|
531
630
|
address: `0x${string}`;
|
|
532
631
|
chainId: number | `0x${string}`;
|
|
@@ -544,6 +643,6 @@ export class EIP191Signer extends DID implements ISigner {
|
|
|
544
643
|
}
|
|
545
644
|
export type ISigner = import("../types.js").ISigner<string>;
|
|
546
645
|
export type Provider = import("ox").Provider.Provider;
|
|
646
|
+
export type EventEmitter = import("eventemitter3").EventEmitter;
|
|
547
647
|
import { DID } from 'iso-did';
|
|
548
|
-
import { Provider } from 'ox';
|
|
549
648
|
//# sourceMappingURL=eip191.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip191.d.ts","sourceRoot":"","sources":["../../../src/signers/eip191.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eip191.d.ts","sourceRoot":"","sources":["../../../src/signers/eip191.js"],"names":[],"mappings":"AAIA;;;;GAIG;AAEH;;;;GAIG;AACH,iDAFgB,OAAO;IAuBrB;;;;;;;;;;;;;;;;;OAiBG;IACH,qBAdG;QAA0B,QAAQ,EAA1B,QAAQ;QACgB,OAAO;QACE,OAAO;QACvB,SAAS;KAElC,yBAwBF;IAlDD;;;;;;;OAOG;IACH,sBALW,QAAQ,WACR,KAAK,MAAM,EAAE,YACb,MAAM,GAAG,KAAK,MAAM,EAAE,cACtB,MAAM,EAShB;IAlBD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAaX;;;;sBAW0B,CAAC;;;;;;sBAOJ,CAAC;;;;;;sBAUpB,CAAL;;;;;;;;;;;;sBAqCwQ,CAAC;;;;;;sBAAmP,CAAC;;;;;;;;;;;;;;;;;;sBAA6jE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAAqxP,CAAC;;;;;;sBAAkT,CAAC;;;;;;;;;;;;sBAAovB,CAAC;;;;;;sBAAuQ,CAAC;;;;;;sBAAwW,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;sCAAs0C,CAAC;6BAA2D,CAAC;sCAAmF,CAAC;;0CAA6F,CAAC;kCAAqD,CAAC;8BAAiD,CAAC;;;;qBAAkM,CAAC;yBAA8B,CAAC;4BAAwB,CAAC;;;;wBAAiI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAnE9+b,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAmE4gD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;sBAA0Q,CAAC;;;;;;;;;;sBAA+Z,CAAC;;;;;;;;;;;;;;;sBAAmQ,CAAC;;;4BAAguI,CAAC;;;;;;;;gCAA4M,CAAC;;;;;;;;;;;;;;;;4BAA2f,CAAC;;;;;iCAA8H,CAAC;mCAAoD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oCAA+R,CAAC;;;0BAAgD,CAAC;4BAA+C,CAAC;6BAAwC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAA68B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAjEh5R;IACxB,uBAAsB;IACtB,gCAAsB;IACtB,kBAA0B;IAsC5B;;;;OAIG;IACH,cAFW,UAAU,wCAQpB;IAED;;OAEG;IACH,iBAEC;CAKF;sBAzFY,OAAO,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;uBACrC,OAAO,IAAI,EAAE,QAAQ,CAAC,QAAQ;2BAC9B,OAAO,eAAe,EAAE,YAAY;oBAN7B,SAAS"}
|
|
@@ -43,7 +43,7 @@ export class ES256KSigner extends DID implements ISigner {
|
|
|
43
43
|
*
|
|
44
44
|
* @param {Uint8Array} message
|
|
45
45
|
*/
|
|
46
|
-
sign(message: Uint8Array): Promise<import("@noble/secp256k1").Bytes
|
|
46
|
+
sign(message: Uint8Array): Promise<import("@noble/secp256k1").Bytes & Uint8Array<ArrayBuffer>>;
|
|
47
47
|
/**
|
|
48
48
|
* Export the signer as a encoded string
|
|
49
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"es256k.d.ts","sourceRoot":"","sources":["../../../src/signers/es256k.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,iDAFgB,OAAO;IAGrB;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAoBpB;;;;OAIG;IACH,wBAFW,UAAU,gBAUpB;IAED;;;;;OAKG;IACH,sBAHW,OAAO,eAAe,EAAE,YAAY,QACpC,OAAO,eAAe,EAAE,aAAa,gBAU/C;IAED;;;;;OAKG;IACH,uBAHW,MAAM,QACN,OAAO,eAAe,EAAE,aAAa,gBAU/C;IAzDD;;;;OAIG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,cACrC,UAAU,EAOpB;IAhBD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAgEb;;;;OAIG;IACH,cAFW,UAAU,
|
|
1
|
+
{"version":3,"file":"es256k.d.ts","sourceRoot":"","sources":["../../../src/signers/es256k.js"],"names":[],"mappings":"AAoBA;;;;GAIG;AACH,iDAFgB,OAAO;IAGrB;;;;OAIG;IACH,aAFU,MAAM,CAEI;IAoBpB;;;;OAIG;IACH,wBAFW,UAAU,gBAUpB;IAED;;;;;OAKG;IACH,sBAHW,OAAO,eAAe,EAAE,YAAY,QACpC,OAAO,eAAe,EAAE,aAAa,gBAU/C;IAED;;;;;OAKG;IACH,uBAHW,MAAM,QACN,OAAO,eAAe,EAAE,aAAa,gBAU/C;IAzDD;;;;OAIG;IACH,iBAHW,OAAO,eAAe,EAAE,aAAa,cACrC,UAAU,EAOpB;IAhBD,kDAAkD;IAClD,eADW,OAAO,aAAa,EAAE,aAAa,CACjC;IAgEb;;;;OAIG;IACH,cAFW,UAAU,uEAKpB;IAED;;OAEG;IACH,iBAEC;;CAKF;sBA9GY,OAAO,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC;oBAL9B,SAAS"}
|
|
@@ -7,7 +7,7 @@ export function hexToBytes(signature: `0x${string}`): Uint8Array<ArrayBufferLike
|
|
|
7
7
|
/**
|
|
8
8
|
* @param {Uint8Array} data
|
|
9
9
|
*/
|
|
10
|
-
export function getSignPayload(data: Uint8Array): Uint8Array<ArrayBufferLike>;
|
|
10
|
+
export function getSignPayload(data: Uint8Array): Uint8Array<ArrayBufferLike> & Uint8Array<ArrayBuffer>;
|
|
11
11
|
export function verify(input: import("../types.js").VerifyInput): Promise<boolean>;
|
|
12
12
|
/** @type {import('../types').Verifier<'EIP191'>} */
|
|
13
13
|
export const verifier: import("../types").Verifier<"EIP191">;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eip191.d.ts","sourceRoot":"","sources":["../../../src/verifiers/eip191.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"eip191.d.ts","sourceRoot":"","sources":["../../../src/verifiers/eip191.js"],"names":[],"mappings":"AAYA;;;;GAIG;AACH,sCAFW,KAAK,MAAM,EAAE,+BAIvB;AAED;;GAEG;AACH,qCAFW,UAAU,yDAKpB;;AAyBD,oDAAoD;AACpD,uBADW,OAAO,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAG/C"}
|
package/license
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) Hugo Dias <hugomrdias@gmail.com> (hugodias.me)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iso-signatures",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.5.
|
|
4
|
+
"version": "0.5.2",
|
|
5
5
|
"description": "Signatures tooling.",
|
|
6
6
|
"author": "Hugo Dias <hugomrdias@gmail.com> (hugodias.me)",
|
|
7
7
|
"license": "MIT",
|
|
@@ -81,23 +81,24 @@
|
|
|
81
81
|
"dist/src/**/*.d.ts.map"
|
|
82
82
|
],
|
|
83
83
|
"dependencies": {
|
|
84
|
-
"@noble/ed25519": "^3.0.
|
|
84
|
+
"@noble/ed25519": "^3.0.1",
|
|
85
85
|
"@noble/hashes": "^2.0.0",
|
|
86
86
|
"@noble/secp256k1": "^3.0.0",
|
|
87
|
-
"
|
|
88
|
-
"iso-base": "^4.
|
|
89
|
-
"iso-did": "^2.1.1"
|
|
87
|
+
"eventemitter3": "5.0.1",
|
|
88
|
+
"iso-base": "^4.4.0",
|
|
89
|
+
"iso-did": "^2.1.1",
|
|
90
|
+
"ox": "^0.14.30"
|
|
90
91
|
},
|
|
91
92
|
"devDependencies": {
|
|
92
93
|
"@types/assert": "^1.5.11",
|
|
93
94
|
"@types/mocha": "^10.0.10",
|
|
94
|
-
"@types/node": "^
|
|
95
|
+
"@types/node": "^26.1.1",
|
|
95
96
|
"assert": "^2.1.0",
|
|
96
|
-
"mocha": "^11.7.
|
|
97
|
-
"playwright-test": "^14.1.
|
|
98
|
-
"type-fest": "^5.0
|
|
99
|
-
"typescript": "
|
|
100
|
-
"viem": "^2.
|
|
97
|
+
"mocha": "^11.7.5",
|
|
98
|
+
"playwright-test": "^14.1.13",
|
|
99
|
+
"type-fest": "^5.8.0",
|
|
100
|
+
"typescript": "^6.0.3",
|
|
101
|
+
"viem": "^2.54.6"
|
|
101
102
|
},
|
|
102
103
|
"publishConfig": {
|
|
103
104
|
"provenance": true
|
|
@@ -110,7 +111,8 @@
|
|
|
110
111
|
"@types/*",
|
|
111
112
|
"assert",
|
|
112
113
|
"type-fest",
|
|
113
|
-
"mocha"
|
|
114
|
+
"mocha",
|
|
115
|
+
"eventemitter3"
|
|
114
116
|
]
|
|
115
117
|
},
|
|
116
118
|
"scripts": {
|
package/src/signers/eip191.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { hex } from 'iso-base/rfc4648'
|
|
2
2
|
import { DID } from 'iso-did'
|
|
3
3
|
import { DIDPkh } from 'iso-did/pkh'
|
|
4
|
-
import { Provider } from 'ox'
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
6
|
* @typedef {import('../types.js').ISigner<string>} ISigner
|
|
8
7
|
* @typedef {import('ox').Provider.Provider} Provider
|
|
8
|
+
* @typedef {import('eventemitter3').EventEmitter} EventEmitter
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
/**
|
package/src/verifiers/eip191.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import { keccak_256 } from '@noble/hashes/sha3.js'
|
|
2
|
-
import { recoverPublicKeyAsync, Signature
|
|
2
|
+
import { Point, recoverPublicKeyAsync, Signature } from '@noble/secp256k1'
|
|
3
3
|
import { hex } from 'iso-base/rfc4648'
|
|
4
4
|
import { utf8 } from 'iso-base/utf8'
|
|
5
5
|
import { concat } from 'iso-base/utils'
|
|
6
|
+
import { DIDPkh } from 'iso-did/pkh'
|
|
7
|
+
import * as Address from 'ox/Address'
|
|
8
|
+
import * as PublicKey from 'ox/PublicKey'
|
|
6
9
|
import * as SignatureOx from 'ox/Signature'
|
|
7
10
|
|
|
8
11
|
const PREFIX = '\x19Ethereum Signed Message:\n'
|
|
@@ -25,19 +28,26 @@ export function getSignPayload(data) {
|
|
|
25
28
|
}
|
|
26
29
|
|
|
27
30
|
/** @type {import('../types.js').Verify} */
|
|
28
|
-
export async function verify({ signature, message }) {
|
|
29
|
-
|
|
31
|
+
export async function verify({ signature, message, did }) {
|
|
32
|
+
if (signature.length !== 65) {
|
|
33
|
+
throw new Error('Invalid signature length')
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const didPkh = DIDPkh.fromString(did.did)
|
|
30
37
|
const sigRecovered = Signature.fromBytes(signature.slice(0, 64))
|
|
31
38
|
.addRecoveryBit(SignatureOx.vToYParity(signature[64]))
|
|
32
39
|
.toBytes('recovered')
|
|
33
|
-
const pubKey = await recoverPublicKeyAsync(
|
|
34
|
-
|
|
35
|
-
|
|
40
|
+
const pubKey = await recoverPublicKeyAsync(
|
|
41
|
+
sigRecovered,
|
|
42
|
+
getSignPayload(message),
|
|
43
|
+
{ prehash: false }
|
|
44
|
+
)
|
|
45
|
+
// noble returns a compressed key, address derivation needs it uncompressed
|
|
46
|
+
const address = Address.fromPublicKey(
|
|
47
|
+
PublicKey.fromBytes(Point.fromBytes(pubKey).toBytes(false))
|
|
48
|
+
)
|
|
36
49
|
|
|
37
|
-
return
|
|
38
|
-
prehash: false,
|
|
39
|
-
format: 'recovered',
|
|
40
|
-
})
|
|
50
|
+
return Address.isEqual(address, didPkh.address)
|
|
41
51
|
}
|
|
42
52
|
|
|
43
53
|
/** @type {import('../types').Verifier<'EIP191'>} */
|