@taquito/signer 23.0.3 → 24.0.0-beta.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,4 +1,4 @@
1
- import { ExtendedPrivateKey } from './index';
1
+ import { ExtendedPrivateKey } from './types';
2
2
  export declare class PrivateKey implements ExtendedPrivateKey {
3
3
  readonly priv: Uint8Array;
4
4
  readonly chainCode: Uint8Array;
@@ -1,15 +1,6 @@
1
1
  export * as ECDSA from './ecdsa';
2
2
  export * as Ed25519 from './ed25519';
3
- export declare const Hard = 2147483648;
4
- export interface ExtendedKey {
5
- readonly chainCode: Uint8Array;
6
- derive(index: number): ExtendedKey;
7
- derivePath(path: Iterable<number>): ExtendedKey;
8
- }
9
- export interface ExtendedPrivateKey extends ExtendedKey {
10
- derive(index: number): ExtendedPrivateKey;
11
- derivePath(path: number[]): ExtendedPrivateKey;
12
- }
3
+ export * from './types';
13
4
  export declare class Path extends Array<number> {
14
5
  static from(iterable: Iterable<number> | ArrayLike<number>): Path;
15
6
  /**
@@ -0,0 +1,10 @@
1
+ export declare const Hard = 2147483648;
2
+ export interface ExtendedKey {
3
+ readonly chainCode: Uint8Array;
4
+ derive(index: number): ExtendedKey;
5
+ derivePath(path: Iterable<number>): ExtendedKey;
6
+ }
7
+ export interface ExtendedPrivateKey extends ExtendedKey {
8
+ derive(index: number): ExtendedPrivateKey;
9
+ derivePath(path: number[]): ExtendedPrivateKey;
10
+ }
@@ -1,16 +1,11 @@
1
- import elliptic from 'elliptic';
2
1
  import { SigningKey, PublicKey } from './key-interface';
3
2
  import { RawSignResult } from '@taquito/core';
4
3
  type Curve = 'p256' | 'secp256k1';
5
- declare class ECKeyBase {
6
- readonly keyPair: elliptic.ec.KeyPair;
7
- constructor(keyPair: elliptic.ec.KeyPair);
8
- curve(): Curve;
9
- }
10
4
  /**
11
5
  * @description Provide signing logic for elliptic curve based key (tz2, tz3)
12
6
  */
13
- export declare class ECKey extends ECKeyBase implements SigningKey {
7
+ export declare class ECKey implements SigningKey {
8
+ #private;
14
9
  /**
15
10
  *
16
11
  * @param key Encoded private key
@@ -33,9 +28,10 @@ export declare class ECKey extends ECKeyBase implements SigningKey {
33
28
  */
34
29
  secretKey(): string;
35
30
  }
36
- export declare class ECPublicKey extends ECKeyBase implements PublicKey {
31
+ export declare class ECPublicKey implements PublicKey {
32
+ #private;
33
+ readonly curve: Curve;
37
34
  constructor(src: string);
38
- constructor(src: elliptic.ec.KeyPair);
39
35
  constructor(src: Uint8Array, curve: Curve);
40
36
  compare(other: PublicKey): number;
41
37
  hash(): string;
@@ -0,0 +1,60 @@
1
+ import { Curves } from './helpers';
2
+ import { SignResult, RawSignResult, Signer } from '@taquito/core';
3
+ import { PublicKey } from './key-interface';
4
+ export interface FromMnemonicParams {
5
+ mnemonic: string;
6
+ password?: string;
7
+ derivationPath?: string;
8
+ curve?: Curves;
9
+ }
10
+ /**
11
+ * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
12
+ *
13
+ * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
14
+ * @throws {@link InvalidMnemonicError}
15
+ */
16
+ export declare class InMemorySigner implements Signer {
17
+ #private;
18
+ static fromFundraiser(email: string, password: string, mnemonic: string): InMemorySigner;
19
+ static fromSecretKey(key: string, passphrase?: string): Promise<InMemorySigner>;
20
+ /**
21
+ *
22
+ * @description Instantiation of an InMemorySigner instance from a mnemonic
23
+ * @param mnemonic 12-24 word mnemonic
24
+ * @param password password used to encrypt the mnemonic to seed value
25
+ * @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
26
+ * @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
27
+ * @returns InMemorySigner
28
+ * @throws {@link InvalidMnemonicError}
29
+ */
30
+ static fromMnemonic({ mnemonic, password, derivationPath, curve, }: FromMnemonicParams): InMemorySigner;
31
+ /**
32
+ *
33
+ * @param key Encoded private key
34
+ * @param passphrase Passphrase to decrypt the private key if it is encrypted
35
+ * @throws {@link InvalidKeyError}
36
+ *
37
+ */
38
+ constructor(key: string, passphrase?: string);
39
+ /**
40
+ *
41
+ * @param bytes Bytes to sign
42
+ * @param watermark Watermark to append to the bytes
43
+ */
44
+ sign(message: string | Uint8Array, watermark?: Uint8Array): Promise<SignResult>;
45
+ provePossession(): Promise<RawSignResult>;
46
+ get canProvePossession(): boolean;
47
+ /**
48
+ * @returns Encoded public key
49
+ */
50
+ publicKey(): Promise<string>;
51
+ /**
52
+ * @returns Encoded public key hash
53
+ */
54
+ publicKeyHash(): Promise<string>;
55
+ /**
56
+ * @returns Encoded private key
57
+ */
58
+ secretKey(): Promise<string>;
59
+ }
60
+ export declare function publicKeyFromString(src: string): PublicKey;
@@ -10,8 +10,28 @@ export interface SigningKeyWithProofOfPossession extends SigningKey {
10
10
  }
11
11
  export declare function isPOP(k: SigningKey): k is SigningKeyWithProofOfPossession;
12
12
  export interface PublicKey {
13
+ /**
14
+ * @description Compare two public keys of the same elliptic curve
15
+ * @param PublicKey the other PublicKey class to compare to
16
+ * @returns -1 if this public key is less than the other, 0 if they are equal, 1 if this public key is greater than the other
17
+ * @throws {@link InvalidPublicKeyError}
18
+ */
13
19
  compare(other: PublicKey): number;
20
+ /**
21
+ * @description Hash of the public key (tz1, tz2, tz3, tz4 addresses)
22
+ * @returns the hash of the public key
23
+ */
14
24
  hash(): string;
25
+ /**
26
+ * @description Get the bytes of the public key without prefix
27
+ * @param compress: Whether to get the compressed format of the public key
28
+ * @default true
29
+ * @returns the bytes of the public key
30
+ */
15
31
  bytes(compress?: boolean): Uint8Array;
32
+ /**
33
+ * @description Get the bytes of the public key with prefix
34
+ * @returns the bytes of the public key
35
+ */
16
36
  toProtocol(): Uint8Array;
17
37
  }
@@ -1,66 +1,10 @@
1
- import { Curves } from './helpers';
2
- import { SignResult, RawSignResult, Signer } from '@taquito/core';
3
- import { PublicKey } from './key-interface';
4
- export * from './import-key';
1
+ /**
2
+ * @packageDocumentation
3
+ * @module @taquito/signer
4
+ */
5
+ export * from './in-memory-signer';
5
6
  export { VERSION } from './version';
6
7
  export * from './derivation-tools';
7
8
  export * from './helpers';
8
9
  export { InvalidPassphraseError } from './errors';
9
10
  export { PublicKey } from './key-interface';
10
- export interface FromMnemonicParams {
11
- mnemonic: string;
12
- password?: string;
13
- derivationPath?: string;
14
- curve?: Curves;
15
- }
16
- /**
17
- * @description A local implementation of the signer. Will represent a Tezos account and be able to produce signature in its behalf
18
- *
19
- * @warn If running in production and dealing with tokens that have real value, it is strongly recommended to use a HSM backed signer so that private key material is not stored in memory or on disk
20
- * @throws {@link InvalidMnemonicError}
21
- */
22
- export declare class InMemorySigner implements Signer {
23
- #private;
24
- static fromFundraiser(email: string, password: string, mnemonic: string): InMemorySigner;
25
- static fromSecretKey(key: string, passphrase?: string): Promise<InMemorySigner>;
26
- /**
27
- *
28
- * @description Instantiation of an InMemorySigner instance from a mnemonic
29
- * @param mnemonic 12-24 word mnemonic
30
- * @param password password used to encrypt the mnemonic to seed value
31
- * @param derivationPath default 44'/1729'/0'/0' (44'/1729' mandatory)
32
- * @param curve currently only supported for tz1, tz2, tz3 addresses. soon bip25519
33
- * @returns InMemorySigner
34
- * @throws {@link InvalidMnemonicError}
35
- */
36
- static fromMnemonic({ mnemonic, password, derivationPath, curve, }: FromMnemonicParams): InMemorySigner;
37
- /**
38
- *
39
- * @param key Encoded private key
40
- * @param passphrase Passphrase to decrypt the private key if it is encrypted
41
- * @throws {@link InvalidKeyError}
42
- *
43
- */
44
- constructor(key: string, passphrase?: string);
45
- /**
46
- *
47
- * @param bytes Bytes to sign
48
- * @param watermark Watermark to append to the bytes
49
- */
50
- sign(message: string | Uint8Array, watermark?: Uint8Array): Promise<SignResult>;
51
- provePossession(): Promise<RawSignResult>;
52
- get canProvePossession(): boolean;
53
- /**
54
- * @returns Encoded public key
55
- */
56
- publicKey(): Promise<string>;
57
- /**
58
- * @returns Encoded public key hash
59
- */
60
- publicKeyHash(): Promise<string>;
61
- /**
62
- * @returns Encoded private key
63
- */
64
- secretKey(): Promise<string>;
65
- }
66
- export declare function publicKeyFromString(src: string): PublicKey;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/signer",
3
- "version": "23.0.3",
3
+ "version": "24.0.0-beta.0",
4
4
  "description": "Provide signing functionality to be with taquito",
5
5
  "keywords": [
6
6
  "tezos",
@@ -24,7 +24,7 @@
24
24
  },
25
25
  "license": "Apache-2.0",
26
26
  "engines": {
27
- "node": ">=18"
27
+ "node": ">=20"
28
28
  },
29
29
  "scripts": {
30
30
  "test": "jest --coverage",
@@ -66,27 +66,24 @@
66
66
  ]
67
67
  },
68
68
  "dependencies": {
69
- "@noble/curves": "^1.9.6",
69
+ "@noble/curves": "^1.9.7",
70
70
  "@stablelib/blake2b": "^1.0.1",
71
71
  "@stablelib/ed25519": "^1.0.3",
72
72
  "@stablelib/hmac": "^1.0.1",
73
73
  "@stablelib/nacl": "^1.0.4",
74
74
  "@stablelib/pbkdf2": "^1.0.1",
75
75
  "@stablelib/sha512": "^1.0.1",
76
- "@taquito/core": "^23.0.3",
77
- "@taquito/taquito": "^23.0.3",
78
- "@taquito/utils": "^23.0.3",
76
+ "@taquito/core": "^24.0.0-beta.0",
77
+ "@taquito/utils": "^24.0.0-beta.0",
79
78
  "@types/bn.js": "^5.1.5",
80
79
  "bip39": "3.1.0",
81
- "elliptic": "^6.6.1",
82
80
  "pbkdf2": "^3.1.2",
83
81
  "typedarray-to-buffer": "^4.0.0"
84
82
  },
85
83
  "devDependencies": {
86
84
  "@types/bluebird": "^3.5.42",
87
- "@types/elliptic": "^6.4.18",
88
85
  "@types/jest": "^29.5.12",
89
- "@types/node": "^18",
86
+ "@types/node": "^20",
90
87
  "@types/pbkdf2": "^3.1.2",
91
88
  "@typescript-eslint/eslint-plugin": "^6.21.0",
92
89
  "@typescript-eslint/parser": "^6.21.0",
@@ -104,6 +101,7 @@
104
101
  "rimraf": "^6.0.1",
105
102
  "rollup": "^4.22.4",
106
103
  "rollup-plugin-json": "^4.0.0",
104
+ "rollup-plugin-polyfill-node": "^0.13.0",
107
105
  "rollup-plugin-typescript2": "^0.36.0",
108
106
  "shelljs": "^0.8.5",
109
107
  "ts-jest": "^29.2.3",
@@ -112,5 +110,5 @@
112
110
  "typedoc": "^0.26.5",
113
111
  "typescript": "~5.5.4"
114
112
  },
115
- "gitHead": "2abf349e97af45f11210b3121078b9d96699d5da"
113
+ "gitHead": "f212ea3edaf1fac34d738b5d00a9892ab7a3b721"
116
114
  }
@@ -1,51 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.importKey = importKey;
13
- const taquito_signer_1 = require("./taquito-signer");
14
- /**
15
- *
16
- * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider
17
- *
18
- * @warn The JSON faucets are no longer available on https://teztnets.com/
19
- * @param toolkit The toolkit instance to attach a signer
20
- * @param privateKeyOrEmail Key to load in memory
21
- * @param passphrase If the key is encrypted passphrase to decrypt it
22
- * @param mnemonic Faucet mnemonic
23
- * @param secret Faucet secret
24
- */
25
- function importKey(toolkit, privateKeyOrEmail, passphrase, mnemonic, secret) {
26
- return __awaiter(this, void 0, void 0, function* () {
27
- if (privateKeyOrEmail && passphrase && mnemonic && secret) {
28
- const signer = taquito_signer_1.InMemorySigner.fromFundraiser(privateKeyOrEmail, passphrase, mnemonic);
29
- toolkit.setProvider({ signer });
30
- const pkh = yield signer.publicKeyHash();
31
- let op;
32
- try {
33
- op = yield toolkit.tz.activate(pkh, secret);
34
- }
35
- catch (ex) {
36
- const isInvalidActivationError = ex && ex.body && /Invalid activation/.test(ex.body);
37
- if (!isInvalidActivationError) {
38
- throw ex;
39
- }
40
- }
41
- if (op) {
42
- yield op.confirmation();
43
- }
44
- }
45
- else {
46
- // Fallback to regular import
47
- const signer = yield taquito_signer_1.InMemorySigner.fromSecretKey(privateKeyOrEmail, passphrase);
48
- toolkit.setProvider({ signer });
49
- }
50
- });
51
- }
@@ -1,13 +0,0 @@
1
- import { TezosToolkit } from '@taquito/taquito';
2
- /**
3
- *
4
- * @description Import a key to sign operation with the side-effect of setting the Tezos instance to use the InMemorySigner provider
5
- *
6
- * @warn The JSON faucets are no longer available on https://teztnets.com/
7
- * @param toolkit The toolkit instance to attach a signer
8
- * @param privateKeyOrEmail Key to load in memory
9
- * @param passphrase If the key is encrypted passphrase to decrypt it
10
- * @param mnemonic Faucet mnemonic
11
- * @param secret Faucet secret
12
- */
13
- export declare function importKey(toolkit: TezosToolkit, privateKeyOrEmail: string, passphrase?: string, mnemonic?: string, secret?: string): Promise<void>;