@taquito/remote-signer 12.0.3 → 12.1.1
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/lib/errors.js +28 -1
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/taquito-remote-signer.js +25 -13
- package/dist/lib/taquito-remote-signer.js.map +1 -1
- package/dist/lib/version.js +2 -2
- package/dist/taquito-remote-signer.es6.js +53 -16
- package/dist/taquito-remote-signer.es6.js.map +1 -1
- package/dist/taquito-remote-signer.umd.js +52 -14
- package/dist/taquito-remote-signer.umd.js.map +1 -1
- package/dist/types/errors.d.ts +21 -0
- package/dist/types/taquito-remote-signer.d.ts +10 -0
- package/package.json +5 -5
package/dist/lib/errors.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.BadSigningDataError = exports.OperationNotAuthorizedError = exports.KeyNotFoundError = void 0;
|
|
3
|
+
exports.PublicKeyMismatch = exports.BadSigningDataError = exports.OperationNotAuthorizedError = exports.KeyNotFoundError = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @category Error
|
|
6
|
+
* @description Error that indicates a failure in grabbing the public key
|
|
7
|
+
*/
|
|
4
8
|
class KeyNotFoundError extends Error {
|
|
5
9
|
constructor(message, innerException) {
|
|
6
10
|
super(message);
|
|
@@ -10,6 +14,10 @@ class KeyNotFoundError extends Error {
|
|
|
10
14
|
}
|
|
11
15
|
}
|
|
12
16
|
exports.KeyNotFoundError = KeyNotFoundError;
|
|
17
|
+
/**
|
|
18
|
+
* @category Error
|
|
19
|
+
* @description Error that indicates an unauthorized operation being attempted
|
|
20
|
+
*/
|
|
13
21
|
class OperationNotAuthorizedError extends Error {
|
|
14
22
|
constructor(message, innerException) {
|
|
15
23
|
super(message);
|
|
@@ -19,6 +27,10 @@ class OperationNotAuthorizedError extends Error {
|
|
|
19
27
|
}
|
|
20
28
|
}
|
|
21
29
|
exports.OperationNotAuthorizedError = OperationNotAuthorizedError;
|
|
30
|
+
/**
|
|
31
|
+
* @category Error
|
|
32
|
+
* @description Error that indicates bad signing data
|
|
33
|
+
*/
|
|
22
34
|
class BadSigningDataError extends Error {
|
|
23
35
|
constructor(message, innerException, data) {
|
|
24
36
|
super(message);
|
|
@@ -29,4 +41,19 @@ class BadSigningDataError extends Error {
|
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
exports.BadSigningDataError = BadSigningDataError;
|
|
44
|
+
/**
|
|
45
|
+
* @category Error
|
|
46
|
+
* @description Error that indicates a mismatch between the initialized and the requested public key
|
|
47
|
+
*/
|
|
48
|
+
class PublicKeyMismatch extends Error {
|
|
49
|
+
constructor(requested, initialized) {
|
|
50
|
+
super(`Requested public key hash does not match the initialized public key hash: {
|
|
51
|
+
requested: ${requested},
|
|
52
|
+
initialized: ${initialized}
|
|
53
|
+
}`);
|
|
54
|
+
this.requested = requested;
|
|
55
|
+
this.name = 'PublicKeyMismatch';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.PublicKeyMismatch = PublicKeyMismatch;
|
|
32
59
|
//# sourceMappingURL=errors.js.map
|
package/dist/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":";;;AAAA,MAAa,gBAAiB,SAAQ,KAAK;IAEzC,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QADvD,SAAI,GAAG,kBAAkB,CAAC;IAGjC,CAAC;CACF;AALD,4CAKC;AAED,MAAa,2BAA4B,SAAQ,KAAK;IAEpD,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS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AAkB,SAAQ,KAAK;IAE1C,YAAmB,SAAiB,EAAE,WAAmB;QACvD,KAAK,CACH;qBACe,SAAS;uBACP,WAAW;QAC1B,CACH,CAAC;QANe,cAAS,GAAT,SAAS,CAAQ;QAD7B,SAAI,GAAG,mBAAmB,CAAC;IAQlC,CAAC;CACF;AAVD,8CAUC"}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.RemoteSigner = exports.VERSION = void 0;
|
|
12
|
+
exports.RemoteSigner = exports.VERSION = exports.SignatureVerificationFailedError = void 0;
|
|
13
13
|
/**
|
|
14
14
|
* @packageDocumentation
|
|
15
15
|
* @module @taquito/remote-signer
|
|
@@ -19,6 +19,25 @@ const utils_1 = require("@taquito/utils");
|
|
|
19
19
|
const blake2b_1 = require("@stablelib/blake2b");
|
|
20
20
|
const typedarray_to_buffer_1 = require("typedarray-to-buffer");
|
|
21
21
|
const errors_1 = require("./errors");
|
|
22
|
+
/**
|
|
23
|
+
* @category Error
|
|
24
|
+
* @description Error
|
|
25
|
+
*/
|
|
26
|
+
class SignatureVerificationFailedError extends Error {
|
|
27
|
+
constructor(bytes, signature) {
|
|
28
|
+
super(`
|
|
29
|
+
Signature failed verification against public key:
|
|
30
|
+
{
|
|
31
|
+
bytes: ${bytes},
|
|
32
|
+
signature: ${signature}
|
|
33
|
+
}
|
|
34
|
+
`);
|
|
35
|
+
this.bytes = bytes;
|
|
36
|
+
this.signature = signature;
|
|
37
|
+
this.name = 'SignatureVerificationFailedError';
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.SignatureVerificationFailedError = SignatureVerificationFailedError;
|
|
22
41
|
var version_1 = require("./version");
|
|
23
42
|
Object.defineProperty(exports, "VERSION", { enumerable: true, get: function () { return version_1.VERSION; } });
|
|
24
43
|
const pref = {
|
|
@@ -48,7 +67,7 @@ class RemoteSigner {
|
|
|
48
67
|
this.options = options;
|
|
49
68
|
this.http = http;
|
|
50
69
|
if (utils_1.validateKeyHash(this.pkh) !== utils_1.ValidationResult.VALID) {
|
|
51
|
-
throw new utils_1.InvalidKeyHashError(
|
|
70
|
+
throw new utils_1.InvalidKeyHashError(this.pkh);
|
|
52
71
|
}
|
|
53
72
|
}
|
|
54
73
|
publicKeyHash() {
|
|
@@ -82,7 +101,7 @@ class RemoteSigner {
|
|
|
82
101
|
}
|
|
83
102
|
secretKey() {
|
|
84
103
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
|
-
throw new
|
|
104
|
+
throw new utils_1.ProhibitedActionError('Secret key cannot be exposed');
|
|
86
105
|
});
|
|
87
106
|
}
|
|
88
107
|
sign(bytes, watermark) {
|
|
@@ -102,18 +121,14 @@ class RemoteSigner {
|
|
|
102
121
|
? signature.substring(0, 3)
|
|
103
122
|
: signature.substring(0, 5);
|
|
104
123
|
if (!utils_1.isValidPrefix(pref)) {
|
|
105
|
-
throw new
|
|
124
|
+
throw new utils_1.InvalidSignatureError(signature, 'Unsupported signature given by remote signer');
|
|
106
125
|
}
|
|
107
126
|
const decoded = utils_1.b58cdecode(signature, utils_1.prefix[pref]);
|
|
108
127
|
const pk = yield this.publicKey();
|
|
109
128
|
yield this.verifyPublicKey(pk);
|
|
110
129
|
const signatureVerified = utils_1.verifySignature(watermarkedBytes, pk, signature);
|
|
111
130
|
if (!signatureVerified) {
|
|
112
|
-
throw new
|
|
113
|
-
{
|
|
114
|
-
bytes: ${watermarkedBytes},
|
|
115
|
-
signature: ${signature}
|
|
116
|
-
}`);
|
|
131
|
+
throw new SignatureVerificationFailedError(watermarkedBytes, signature);
|
|
117
132
|
}
|
|
118
133
|
return {
|
|
119
134
|
bytes,
|
|
@@ -147,10 +162,7 @@ class RemoteSigner {
|
|
|
147
162
|
const _publicKey = utils_1.b58cdecode(publicKey, pref[curve].pk);
|
|
148
163
|
const publicKeyHash = utils_1.b58cencode(blake2b_1.hash(_publicKey, 20), pref[curve].pkh);
|
|
149
164
|
if (publicKeyHash !== this.pkh) {
|
|
150
|
-
throw new
|
|
151
|
-
publicKey: ${publicKey},
|
|
152
|
-
publicKeyHash: ${this.pkh}
|
|
153
|
-
}`);
|
|
165
|
+
throw new errors_1.PublicKeyMismatch(publicKeyHash, this.pkh);
|
|
154
166
|
}
|
|
155
167
|
});
|
|
156
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-remote-signer.js","sourceRoot":"","sources":["../../src/taquito-remote-signer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;GAGG;AACH,oDAAkF;AAClF,
|
|
1
|
+
{"version":3,"file":"taquito-remote-signer.js","sourceRoot":"","sources":["../../src/taquito-remote-signer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA;;;GAGG;AACH,oDAAkF;AAClF,0CAcwB;AACxB,gDAA0C;AAC1C,+DAA4C;AAC5C,qCAKkB;AAGlB;;;GAGG;AACH,MAAa,gCAAiC,SAAQ,KAAK;IAEzD,YAAmB,KAAa,EAAS,SAAiB;QACxD,KAAK,CACH;;;mBAGa,KAAK;uBACD,SAAS;;OAEzB,CACF,CAAC;QATe,UAAK,GAAL,KAAK,CAAQ;QAAS,cAAS,GAAT,SAAS,CAAQ;QADnD,SAAI,GAAG,kCAAkC,CAAC;IAWjD,CAAC;CACF;AAbD,4EAaC;AAgBD,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAEhB,MAAM,IAAI,GAAG;IACX,EAAE,EAAE;QACF,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,GAAG,EAAE,cAAM,CAAC,GAAG;QACf,GAAG,EAAE,cAAM,CAAC,KAAK;KAClB;IACD,EAAE,EAAE;QACF,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC;QAClB,EAAE,EAAE,cAAM,CAAC,MAAM,CAAC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,CAAC,EAAE,CAAC,CAAW,CAAC;YAClD,MAAM,UAAU,GAAG,kBAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YAEzD,MAAM,aAAa,GAAG,kBAAU,CAAC,cAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;YACxE,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;gBAC9B,MAAM,IAAI,0BAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;aACtD;QACH,CAAC;KAAA;CACF;AA3GD,oCA2GC"}
|
package/dist/lib/version.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.VERSION = void 0;
|
|
4
4
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
5
5
|
exports.VERSION = {
|
|
6
|
-
"commitHash": "
|
|
7
|
-
"version": "12.
|
|
6
|
+
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25",
|
|
7
|
+
"version": "12.1.1"
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=version.js.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpBackend, HttpResponseError, STATUS_CODE } from '@taquito/http-utils';
|
|
2
|
-
import { prefix, validateKeyHash, ValidationResult, InvalidKeyHashError, hex2buf, mergebuf, buf2hex, isValidPrefix, b58cdecode, verifySignature, b58cencode } from '@taquito/utils';
|
|
2
|
+
import { prefix, validateKeyHash, ValidationResult, InvalidKeyHashError, ProhibitedActionError, hex2buf, mergebuf, buf2hex, isValidPrefix, InvalidSignatureError, b58cdecode, verifySignature, b58cencode } from '@taquito/utils';
|
|
3
3
|
import { hash } from '@stablelib/blake2b';
|
|
4
4
|
import toBuffer from 'typedarray-to-buffer';
|
|
5
5
|
|
|
@@ -28,6 +28,10 @@ function __awaiter(thisArg, _arguments, P, generator) {
|
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
/**
|
|
32
|
+
* @category Error
|
|
33
|
+
* @description Error that indicates a failure in grabbing the public key
|
|
34
|
+
*/
|
|
31
35
|
class KeyNotFoundError extends Error {
|
|
32
36
|
constructor(message, innerException) {
|
|
33
37
|
super(message);
|
|
@@ -36,6 +40,10 @@ class KeyNotFoundError extends Error {
|
|
|
36
40
|
this.name = 'KeyNotFoundError';
|
|
37
41
|
}
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* @category Error
|
|
45
|
+
* @description Error that indicates an unauthorized operation being attempted
|
|
46
|
+
*/
|
|
39
47
|
class OperationNotAuthorizedError extends Error {
|
|
40
48
|
constructor(message, innerException) {
|
|
41
49
|
super(message);
|
|
@@ -44,6 +52,10 @@ class OperationNotAuthorizedError extends Error {
|
|
|
44
52
|
this.name = 'OperationNotAuthorized';
|
|
45
53
|
}
|
|
46
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* @category Error
|
|
57
|
+
* @description Error that indicates bad signing data
|
|
58
|
+
*/
|
|
47
59
|
class BadSigningDataError extends Error {
|
|
48
60
|
constructor(message, innerException, data) {
|
|
49
61
|
super(message);
|
|
@@ -52,14 +64,46 @@ class BadSigningDataError extends Error {
|
|
|
52
64
|
this.data = data;
|
|
53
65
|
this.name = 'BadSigningData';
|
|
54
66
|
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* @category Error
|
|
70
|
+
* @description Error that indicates a mismatch between the initialized and the requested public key
|
|
71
|
+
*/
|
|
72
|
+
class PublicKeyMismatch extends Error {
|
|
73
|
+
constructor(requested, initialized) {
|
|
74
|
+
super(`Requested public key hash does not match the initialized public key hash: {
|
|
75
|
+
requested: ${requested},
|
|
76
|
+
initialized: ${initialized}
|
|
77
|
+
}`);
|
|
78
|
+
this.requested = requested;
|
|
79
|
+
this.name = 'PublicKeyMismatch';
|
|
80
|
+
}
|
|
55
81
|
}
|
|
56
82
|
|
|
57
83
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
58
84
|
const VERSION = {
|
|
59
|
-
"commitHash": "
|
|
60
|
-
"version": "12.
|
|
85
|
+
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25",
|
|
86
|
+
"version": "12.1.1"
|
|
61
87
|
};
|
|
62
88
|
|
|
89
|
+
/**
|
|
90
|
+
* @category Error
|
|
91
|
+
* @description Error
|
|
92
|
+
*/
|
|
93
|
+
class SignatureVerificationFailedError extends Error {
|
|
94
|
+
constructor(bytes, signature) {
|
|
95
|
+
super(`
|
|
96
|
+
Signature failed verification against public key:
|
|
97
|
+
{
|
|
98
|
+
bytes: ${bytes},
|
|
99
|
+
signature: ${signature}
|
|
100
|
+
}
|
|
101
|
+
`);
|
|
102
|
+
this.bytes = bytes;
|
|
103
|
+
this.signature = signature;
|
|
104
|
+
this.name = 'SignatureVerificationFailedError';
|
|
105
|
+
}
|
|
106
|
+
}
|
|
63
107
|
const pref = {
|
|
64
108
|
ed: {
|
|
65
109
|
pk: prefix['edpk'],
|
|
@@ -87,7 +131,7 @@ class RemoteSigner {
|
|
|
87
131
|
this.options = options;
|
|
88
132
|
this.http = http;
|
|
89
133
|
if (validateKeyHash(this.pkh) !== ValidationResult.VALID) {
|
|
90
|
-
throw new InvalidKeyHashError(
|
|
134
|
+
throw new InvalidKeyHashError(this.pkh);
|
|
91
135
|
}
|
|
92
136
|
}
|
|
93
137
|
publicKeyHash() {
|
|
@@ -121,7 +165,7 @@ class RemoteSigner {
|
|
|
121
165
|
}
|
|
122
166
|
secretKey() {
|
|
123
167
|
return __awaiter(this, void 0, void 0, function* () {
|
|
124
|
-
throw new
|
|
168
|
+
throw new ProhibitedActionError('Secret key cannot be exposed');
|
|
125
169
|
});
|
|
126
170
|
}
|
|
127
171
|
sign(bytes, watermark) {
|
|
@@ -141,18 +185,14 @@ class RemoteSigner {
|
|
|
141
185
|
? signature.substring(0, 3)
|
|
142
186
|
: signature.substring(0, 5);
|
|
143
187
|
if (!isValidPrefix(pref)) {
|
|
144
|
-
throw new
|
|
188
|
+
throw new InvalidSignatureError(signature, 'Unsupported signature given by remote signer');
|
|
145
189
|
}
|
|
146
190
|
const decoded = b58cdecode(signature, prefix[pref]);
|
|
147
191
|
const pk = yield this.publicKey();
|
|
148
192
|
yield this.verifyPublicKey(pk);
|
|
149
193
|
const signatureVerified = verifySignature(watermarkedBytes, pk, signature);
|
|
150
194
|
if (!signatureVerified) {
|
|
151
|
-
throw new
|
|
152
|
-
{
|
|
153
|
-
bytes: ${watermarkedBytes},
|
|
154
|
-
signature: ${signature}
|
|
155
|
-
}`);
|
|
195
|
+
throw new SignatureVerificationFailedError(watermarkedBytes, signature);
|
|
156
196
|
}
|
|
157
197
|
return {
|
|
158
198
|
bytes,
|
|
@@ -186,14 +226,11 @@ class RemoteSigner {
|
|
|
186
226
|
const _publicKey = b58cdecode(publicKey, pref[curve].pk);
|
|
187
227
|
const publicKeyHash = b58cencode(hash(_publicKey, 20), pref[curve].pkh);
|
|
188
228
|
if (publicKeyHash !== this.pkh) {
|
|
189
|
-
throw new
|
|
190
|
-
publicKey: ${publicKey},
|
|
191
|
-
publicKeyHash: ${this.pkh}
|
|
192
|
-
}`);
|
|
229
|
+
throw new PublicKeyMismatch(publicKeyHash, this.pkh);
|
|
193
230
|
}
|
|
194
231
|
});
|
|
195
232
|
}
|
|
196
233
|
}
|
|
197
234
|
|
|
198
|
-
export { RemoteSigner, VERSION };
|
|
235
|
+
export { RemoteSigner, SignatureVerificationFailedError, VERSION };
|
|
199
236
|
//# sourceMappingURL=taquito-remote-signer.es6.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-remote-signer.es6.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["export class KeyNotFoundError extends Error {\n public name = 'KeyNotFoundError';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\nexport class OperationNotAuthorizedError extends Error {\n public name = 'OperationNotAuthorized';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\nexport class BadSigningDataError extends Error {\n public name = 'BadSigningData';\n constructor(public message: string, public innerException: any, public readonly data: any) {\n super(message);\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256\",\n \"version\": \"12.0.3\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/remote-signer\n */\nimport { HttpBackend, HttpResponseError, STATUS_CODE } from '@taquito/http-utils';\nimport {\n b58cdecode,\n b58cencode,\n buf2hex,\n hex2buf,\n isValidPrefix,\n mergebuf,\n prefix,\n verifySignature,\n validateKeyHash,\n ValidationResult,\n InvalidKeyHashError\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport { BadSigningDataError, KeyNotFoundError, OperationNotAuthorizedError } from './errors';\nimport { Signer } from '@taquito/taquito';\n\ninterface PublicKeyResponse {\n public_key: string;\n}\n\ninterface SignResponse {\n signature: string;\n}\n\ntype curves = 'ed' | 'p2' | 'sp';\n\nexport interface RemoteSignerOptions {\n headers?: { [key: string]: string };\n}\n\nexport { VERSION } from './version';\n\nconst pref = {\n ed: {\n pk: prefix['edpk'],\n sk: prefix['edsk'],\n pkh: prefix.tz1,\n sig: prefix.edsig,\n },\n p2: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n sp: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\nexport class RemoteSigner implements Signer {\n constructor(\n private pkh: string,\n private rootUrl: string,\n private options: RemoteSignerOptions = {},\n private http = new HttpBackend()\n ) {\n if (validateKeyHash(this.pkh) !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(`Invalid Public Key Hash: ${this.pkh}`);\n }\n }\n\n async publicKeyHash(): Promise<string> {\n return this.pkh;\n }\n\n private createURL(path: string) {\n // Trim trailing slashes because it is assumed to be included in path\n return `${this.rootUrl.replace(/\\/+$/g, '')}${path}`;\n }\n\n async publicKey(): Promise<string> {\n try {\n const { public_key } = await this.http.createRequest<PublicKeyResponse>({\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'GET',\n headers: this.options.headers,\n });\n return public_key;\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n }\n }\n throw ex;\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n try {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n const watermarkedBytes = buf2hex(toBuffer(bb));\n const { signature } = await this.http.createRequest<SignResponse>(\n {\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'POST',\n headers: this.options.headers,\n },\n watermarkedBytes\n );\n const pref = signature.startsWith('sig')\n ? signature.substring(0, 3)\n : signature.substring(0, 5);\n\n if (!isValidPrefix(pref)) {\n throw new Error(`Unsupported signature given by remote signer: ${signature}`);\n }\n\n const decoded = b58cdecode(signature, prefix[pref]);\n\n const pk = await this.publicKey();\n await this.verifyPublicKey(pk);\n const signatureVerified = verifySignature(watermarkedBytes, pk, signature);\n if (!signatureVerified) {\n throw new Error(\n `Signature failed verification against public key:\n {\n bytes: ${watermarkedBytes},\n signature: ${signature}\n }`\n );\n }\n\n return {\n bytes,\n sig: b58cencode(decoded, prefix.sig),\n prefixSig: signature,\n sbytes: bytes + buf2hex(toBuffer(decoded)),\n };\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n } else if (ex.status === STATUS_CODE.FORBIDDEN) {\n throw new OperationNotAuthorizedError('Signing Operation not authorized', ex);\n } else if (ex.status === STATUS_CODE.BAD_REQUEST) {\n throw new BadSigningDataError('Invalid data', ex, {\n bytes,\n watermark,\n });\n }\n }\n throw ex;\n }\n }\n\n async verifyPublicKey(publicKey: string) {\n const curve = publicKey.substring(0, 2) as curves;\n const _publicKey = b58cdecode(publicKey, pref[curve].pk);\n\n const publicKeyHash = b58cencode(hash(_publicKey, 20), pref[curve].pkh);\n if (publicKeyHash !== this.pkh) {\n throw new Error(\n `Requested public key does not match the initialized public key hash: {\n publicKey: ${publicKey},\n publicKeyHash: ${this.pkh}\n }`\n );\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAAa,gBAAiB,SAAQ,KAAK;IAEzC,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QADvD,SAAI,GAAG,kBAAkB,CAAC;KAGhC;CACF;MAEY,2BAA4B,SAAQ,KAAK;IAEpD,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QADvD,SAAI,GAAG,wBAAwB,CAAC;KAGtC;CACF;MAEY,mBAAoB,SAAQ,KAAK;IAE5C,YAAmB,OAAe,EAAS,cAAmB,EAAkB,IAAS;QACvF,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QAAkB,SAAI,GAAJ,IAAI,CAAK;QADlF,SAAI,GAAG,gBAAgB,CAAC;KAG9B;;;AC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AC;qBAC/E;yBAAM,IAAI,EAAE,CAAC,MAAM,KAAK,WAAW,CAAC,WAAW,EAAE;wBAChD,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,EAAE,EAAE;4BAChD,KAAK;4BACL,SAAS;yBACV,CAAC,CAAC;qBACJ;iBACF;gBACD,MAAM,EAAE,CAAC;aACV;SACF;KAAA;IAEK,eAAe,CAAC,SAAiB;;YACrC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAW,CAAC;YAClD,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;YAEzD,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;YACxE,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;gBAC9B,MAAM,IAAI,KAAK,CACb;uBACe,SAAS;2BACL,IAAI,CAAC,GAAG;UACzB,CACH,CAAC;aACH;SACF;KAAA;;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-remote-signer.es6.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["/**\n * @category Error\n * @description Error that indicates a failure in grabbing the public key\n */\nexport class KeyNotFoundError extends Error {\n public name = 'KeyNotFoundError';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends Error {\n public name = 'OperationNotAuthorized';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates bad signing data\n */\nexport class BadSigningDataError extends Error {\n public name = 'BadSigningData';\n constructor(public message: string, public innerException: any, public readonly data: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a mismatch between the initialized and the requested public key\n */\nexport class PublicKeyMismatch extends Error {\n public name = 'PublicKeyMismatch';\n constructor(public requested: string, initialized: string) {\n super(\n `Requested public key hash does not match the initialized public key hash: {\n requested: ${requested},\n initialized: ${initialized}\n }`\n );\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25\",\n \"version\": \"12.1.1\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/remote-signer\n */\nimport { HttpBackend, HttpResponseError, STATUS_CODE } from '@taquito/http-utils';\nimport {\n b58cdecode,\n b58cencode,\n buf2hex,\n hex2buf,\n isValidPrefix,\n mergebuf,\n prefix,\n verifySignature,\n validateKeyHash,\n ValidationResult,\n InvalidKeyHashError,\n ProhibitedActionError,\n InvalidSignatureError,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n KeyNotFoundError,\n OperationNotAuthorizedError,\n PublicKeyMismatch,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationFailedError extends Error {\n public name = 'SignatureVerificationFailedError';\n constructor(public bytes: string, public signature: string) {\n super(\n `\n Signature failed verification against public key: \n {\n bytes: ${bytes},\n signature: ${signature}\n }\n `\n );\n }\n}\n\ninterface PublicKeyResponse {\n public_key: string;\n}\n\ninterface SignResponse {\n signature: string;\n}\n\ntype curves = 'ed' | 'p2' | 'sp';\n\nexport interface RemoteSignerOptions {\n headers?: { [key: string]: string };\n}\n\nexport { VERSION } from './version';\n\nconst pref = {\n ed: {\n pk: prefix['edpk'],\n sk: prefix['edsk'],\n pkh: prefix.tz1,\n sig: prefix.edsig,\n },\n p2: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n sp: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\nexport class RemoteSigner implements Signer {\n constructor(\n private pkh: string,\n private rootUrl: string,\n private options: RemoteSignerOptions = {},\n private http = new HttpBackend()\n ) {\n if (validateKeyHash(this.pkh) !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh);\n }\n }\n\n async publicKeyHash(): Promise<string> {\n return this.pkh;\n }\n\n private createURL(path: string) {\n // Trim trailing slashes because it is assumed to be included in path\n return `${this.rootUrl.replace(/\\/+$/g, '')}${path}`;\n }\n\n async publicKey(): Promise<string> {\n try {\n const { public_key } = await this.http.createRequest<PublicKeyResponse>({\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'GET',\n headers: this.options.headers,\n });\n return public_key;\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n }\n }\n throw ex;\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n try {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n const watermarkedBytes = buf2hex(toBuffer(bb));\n const { signature } = await this.http.createRequest<SignResponse>(\n {\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'POST',\n headers: this.options.headers,\n },\n watermarkedBytes\n );\n const pref = signature.startsWith('sig')\n ? signature.substring(0, 3)\n : signature.substring(0, 5);\n\n if (!isValidPrefix(pref)) {\n throw new InvalidSignatureError(signature, 'Unsupported signature given by remote signer');\n }\n\n const decoded = b58cdecode(signature, prefix[pref]);\n\n const pk = await this.publicKey();\n await this.verifyPublicKey(pk);\n const signatureVerified = verifySignature(watermarkedBytes, pk, signature);\n if (!signatureVerified) {\n throw new SignatureVerificationFailedError(watermarkedBytes, signature);\n }\n\n return {\n bytes,\n sig: b58cencode(decoded, prefix.sig),\n prefixSig: signature,\n sbytes: bytes + buf2hex(toBuffer(decoded)),\n };\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n } else if (ex.status === STATUS_CODE.FORBIDDEN) {\n throw new OperationNotAuthorizedError('Signing Operation not authorized', ex);\n } else if (ex.status === STATUS_CODE.BAD_REQUEST) {\n throw new BadSigningDataError('Invalid data', ex, {\n bytes,\n watermark,\n });\n }\n }\n throw ex;\n }\n }\n\n async verifyPublicKey(publicKey: string) {\n const curve = publicKey.substring(0, 2) as curves;\n const _publicKey = b58cdecode(publicKey, pref[curve].pk);\n\n const publicKeyHash = b58cencode(hash(_publicKey, 20), pref[curve].pkh);\n if (publicKeyHash !== this.pkh) {\n throw new PublicKeyMismatch(publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;MAIa,gBAAiB,SAAQ,KAAK;IAEzC,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QADvD,SAAI,GAAG,kBAAkB,CAAC;KAGhC;CACF;AAED;;;;MAIa,2BAA4B,SAAQ,KAAK;IAEpD,YAAmB,OAAe,EAAS,cAAmB;QAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cAAc,CAAK;QADvD,SAAI,GAAG,wBAAwB,CAAC;KAGtC;CACF;AAED;;;;MAIa,mBAAoB,SAAQ,KAAK;IAE5C,YAAmB,OAAe,EAAS,cAAmB,EAAkB,IAAS;QACvF,KAAK,CAAC,OAAO,CAAC,CAAC;QADE,YAAO,GAAP,OAAO,CAAQ;QAAS,mBAAc,GAAd,cA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,6 +33,10 @@
|
|
|
33
33
|
});
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/**
|
|
37
|
+
* @category Error
|
|
38
|
+
* @description Error that indicates a failure in grabbing the public key
|
|
39
|
+
*/
|
|
36
40
|
class KeyNotFoundError extends Error {
|
|
37
41
|
constructor(message, innerException) {
|
|
38
42
|
super(message);
|
|
@@ -41,6 +45,10 @@
|
|
|
41
45
|
this.name = 'KeyNotFoundError';
|
|
42
46
|
}
|
|
43
47
|
}
|
|
48
|
+
/**
|
|
49
|
+
* @category Error
|
|
50
|
+
* @description Error that indicates an unauthorized operation being attempted
|
|
51
|
+
*/
|
|
44
52
|
class OperationNotAuthorizedError extends Error {
|
|
45
53
|
constructor(message, innerException) {
|
|
46
54
|
super(message);
|
|
@@ -49,6 +57,10 @@
|
|
|
49
57
|
this.name = 'OperationNotAuthorized';
|
|
50
58
|
}
|
|
51
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* @category Error
|
|
62
|
+
* @description Error that indicates bad signing data
|
|
63
|
+
*/
|
|
52
64
|
class BadSigningDataError extends Error {
|
|
53
65
|
constructor(message, innerException, data) {
|
|
54
66
|
super(message);
|
|
@@ -57,14 +69,46 @@
|
|
|
57
69
|
this.data = data;
|
|
58
70
|
this.name = 'BadSigningData';
|
|
59
71
|
}
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* @category Error
|
|
75
|
+
* @description Error that indicates a mismatch between the initialized and the requested public key
|
|
76
|
+
*/
|
|
77
|
+
class PublicKeyMismatch extends Error {
|
|
78
|
+
constructor(requested, initialized) {
|
|
79
|
+
super(`Requested public key hash does not match the initialized public key hash: {
|
|
80
|
+
requested: ${requested},
|
|
81
|
+
initialized: ${initialized}
|
|
82
|
+
}`);
|
|
83
|
+
this.requested = requested;
|
|
84
|
+
this.name = 'PublicKeyMismatch';
|
|
85
|
+
}
|
|
60
86
|
}
|
|
61
87
|
|
|
62
88
|
// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
|
|
63
89
|
const VERSION = {
|
|
64
|
-
"commitHash": "
|
|
65
|
-
"version": "12.
|
|
90
|
+
"commitHash": "38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25",
|
|
91
|
+
"version": "12.1.1"
|
|
66
92
|
};
|
|
67
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @category Error
|
|
96
|
+
* @description Error
|
|
97
|
+
*/
|
|
98
|
+
class SignatureVerificationFailedError extends Error {
|
|
99
|
+
constructor(bytes, signature) {
|
|
100
|
+
super(`
|
|
101
|
+
Signature failed verification against public key:
|
|
102
|
+
{
|
|
103
|
+
bytes: ${bytes},
|
|
104
|
+
signature: ${signature}
|
|
105
|
+
}
|
|
106
|
+
`);
|
|
107
|
+
this.bytes = bytes;
|
|
108
|
+
this.signature = signature;
|
|
109
|
+
this.name = 'SignatureVerificationFailedError';
|
|
110
|
+
}
|
|
111
|
+
}
|
|
68
112
|
const pref = {
|
|
69
113
|
ed: {
|
|
70
114
|
pk: utils.prefix['edpk'],
|
|
@@ -92,7 +136,7 @@
|
|
|
92
136
|
this.options = options;
|
|
93
137
|
this.http = http;
|
|
94
138
|
if (utils.validateKeyHash(this.pkh) !== utils.ValidationResult.VALID) {
|
|
95
|
-
throw new utils.InvalidKeyHashError(
|
|
139
|
+
throw new utils.InvalidKeyHashError(this.pkh);
|
|
96
140
|
}
|
|
97
141
|
}
|
|
98
142
|
publicKeyHash() {
|
|
@@ -126,7 +170,7 @@
|
|
|
126
170
|
}
|
|
127
171
|
secretKey() {
|
|
128
172
|
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
-
throw new
|
|
173
|
+
throw new utils.ProhibitedActionError('Secret key cannot be exposed');
|
|
130
174
|
});
|
|
131
175
|
}
|
|
132
176
|
sign(bytes, watermark) {
|
|
@@ -146,18 +190,14 @@
|
|
|
146
190
|
? signature.substring(0, 3)
|
|
147
191
|
: signature.substring(0, 5);
|
|
148
192
|
if (!utils.isValidPrefix(pref)) {
|
|
149
|
-
throw new
|
|
193
|
+
throw new utils.InvalidSignatureError(signature, 'Unsupported signature given by remote signer');
|
|
150
194
|
}
|
|
151
195
|
const decoded = utils.b58cdecode(signature, utils.prefix[pref]);
|
|
152
196
|
const pk = yield this.publicKey();
|
|
153
197
|
yield this.verifyPublicKey(pk);
|
|
154
198
|
const signatureVerified = utils.verifySignature(watermarkedBytes, pk, signature);
|
|
155
199
|
if (!signatureVerified) {
|
|
156
|
-
throw new
|
|
157
|
-
{
|
|
158
|
-
bytes: ${watermarkedBytes},
|
|
159
|
-
signature: ${signature}
|
|
160
|
-
}`);
|
|
200
|
+
throw new SignatureVerificationFailedError(watermarkedBytes, signature);
|
|
161
201
|
}
|
|
162
202
|
return {
|
|
163
203
|
bytes,
|
|
@@ -191,16 +231,14 @@
|
|
|
191
231
|
const _publicKey = utils.b58cdecode(publicKey, pref[curve].pk);
|
|
192
232
|
const publicKeyHash = utils.b58cencode(blake2b.hash(_publicKey, 20), pref[curve].pkh);
|
|
193
233
|
if (publicKeyHash !== this.pkh) {
|
|
194
|
-
throw new
|
|
195
|
-
publicKey: ${publicKey},
|
|
196
|
-
publicKeyHash: ${this.pkh}
|
|
197
|
-
}`);
|
|
234
|
+
throw new PublicKeyMismatch(publicKeyHash, this.pkh);
|
|
198
235
|
}
|
|
199
236
|
});
|
|
200
237
|
}
|
|
201
238
|
}
|
|
202
239
|
|
|
203
240
|
exports.RemoteSigner = RemoteSigner;
|
|
241
|
+
exports.SignatureVerificationFailedError = SignatureVerificationFailedError;
|
|
204
242
|
exports.VERSION = VERSION;
|
|
205
243
|
|
|
206
244
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"taquito-remote-signer.umd.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["export class KeyNotFoundError extends Error {\n public name = 'KeyNotFoundError';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\nexport class OperationNotAuthorizedError extends Error {\n public name = 'OperationNotAuthorized';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\nexport class BadSigningDataError extends Error {\n public name = 'BadSigningData';\n constructor(public message: string, public innerException: any, public readonly data: any) {\n super(message);\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"02ebaa8ef1920e8b6a81f0d0978f28cff0a2d256\",\n \"version\": \"12.0.3\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/remote-signer\n */\nimport { HttpBackend, HttpResponseError, STATUS_CODE } from '@taquito/http-utils';\nimport {\n b58cdecode,\n b58cencode,\n buf2hex,\n hex2buf,\n isValidPrefix,\n mergebuf,\n prefix,\n verifySignature,\n validateKeyHash,\n ValidationResult,\n InvalidKeyHashError\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport { BadSigningDataError, KeyNotFoundError, OperationNotAuthorizedError } from './errors';\nimport { Signer } from '@taquito/taquito';\n\ninterface PublicKeyResponse {\n public_key: string;\n}\n\ninterface SignResponse {\n signature: string;\n}\n\ntype curves = 'ed' | 'p2' | 'sp';\n\nexport interface RemoteSignerOptions {\n headers?: { [key: string]: string };\n}\n\nexport { VERSION } from './version';\n\nconst pref = {\n ed: {\n pk: prefix['edpk'],\n sk: prefix['edsk'],\n pkh: prefix.tz1,\n sig: prefix.edsig,\n },\n p2: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n sp: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\nexport class RemoteSigner implements Signer {\n constructor(\n private pkh: string,\n private rootUrl: string,\n private options: RemoteSignerOptions = {},\n private http = new HttpBackend()\n ) {\n if (validateKeyHash(this.pkh) !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(`Invalid Public Key Hash: ${this.pkh}`);\n }\n }\n\n async publicKeyHash(): Promise<string> {\n return this.pkh;\n }\n\n private createURL(path: string) {\n // Trim trailing slashes because it is assumed to be included in path\n return `${this.rootUrl.replace(/\\/+$/g, '')}${path}`;\n }\n\n async publicKey(): Promise<string> {\n try {\n const { public_key } = await this.http.createRequest<PublicKeyResponse>({\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'GET',\n headers: this.options.headers,\n });\n return public_key;\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n }\n }\n throw ex;\n }\n }\n\n async secretKey(): Promise<string> {\n throw new Error('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n try {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n const watermarkedBytes = buf2hex(toBuffer(bb));\n const { signature } = await this.http.createRequest<SignResponse>(\n {\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'POST',\n headers: this.options.headers,\n },\n watermarkedBytes\n );\n const pref = signature.startsWith('sig')\n ? signature.substring(0, 3)\n : signature.substring(0, 5);\n\n if (!isValidPrefix(pref)) {\n throw new Error(`Unsupported signature given by remote signer: ${signature}`);\n }\n\n const decoded = b58cdecode(signature, prefix[pref]);\n\n const pk = await this.publicKey();\n await this.verifyPublicKey(pk);\n const signatureVerified = verifySignature(watermarkedBytes, pk, signature);\n if (!signatureVerified) {\n throw new Error(\n `Signature failed verification against public key:\n {\n bytes: ${watermarkedBytes},\n signature: ${signature}\n }`\n );\n }\n\n return {\n bytes,\n sig: b58cencode(decoded, prefix.sig),\n prefixSig: signature,\n sbytes: bytes + buf2hex(toBuffer(decoded)),\n };\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n } else if (ex.status === STATUS_CODE.FORBIDDEN) {\n throw new OperationNotAuthorizedError('Signing Operation not authorized', ex);\n } else if (ex.status === STATUS_CODE.BAD_REQUEST) {\n throw new BadSigningDataError('Invalid data', ex, {\n bytes,\n watermark,\n });\n }\n }\n throw ex;\n }\n }\n\n async verifyPublicKey(publicKey: string) {\n const curve = publicKey.substring(0, 2) as curves;\n const _publicKey = b58cdecode(publicKey, pref[curve].pk);\n\n const publicKeyHash = b58cencode(hash(_publicKey, 20), pref[curve].pkh);\n if (publicKeyHash !== this.pkh) {\n throw new Error(\n `Requested public key does not match the initialized public key hash: {\n publicKey: ${publicKey},\n publicKeyHash: ${this.pkh}\n }`\n );\n }\n }\n}\n"],"names":["prefix","HttpBackend","validateKeyHash","ValidationResult","InvalidKeyHashError","HttpResponseError","STATUS_CODE","hex2buf","mergebuf","buf2hex","toBuffer","isValidPrefix","b58cdecode","verifySignature","b58cencode","hash"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAAa,gBAAiB,SAAQ,KAAK;QAEzC,YAAmB,OAAe,EAAS,cAAmB;YAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;YADE,YAAO,GAAP,OAAO,CAAQ;YAAS,mBAAc,GAAd,cAAc,CAAK;YADvD,SAAI,GAAG,kBAAkB,CAAC;SAGhC;KACF;UAEY,2BAA4B,SAAQ,KAAK;QAEpD,YAAmB,OAAe,EAAS,cAAmB;YAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;YADE,YAAO,GAAP,OAAO,CAAQ;YAAS,mBAAc,GAAd,cAAc,CAAK;YADvD,SAAI,GAAG,wBAAwB,CAAC;SAGtC;KACF;UAEY,mBAAoB,SAAQ,KAAK;QAE5C,YAAmB,OAAe,EAAS,cAAmB,EAAkB,IAAS;YACvF,KAAK,CAAC,OAAO,CAAC,CAAC;YADE,YAAO,GAAP,OAAO,CAAQ;YAAS,mBAAc,GAAd,cAAc,CAA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CAAC;yBAC9D;6BAAM,IAAI,EAAE,CAAC,MAAM,KAAKA,qBAAW,CAAC,SAAS,EAAE;4BAC9C,MAAM,IAAI,2BAA2B,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;yBAC/E;6BAAM,IAAI,EAAE,CAAC,MAAM,KAAKA,qBAAW,CAAC,WAAW,EAAE;4BAChD,MAAM,IAAI,mBAAmB,CAAC,cAAc,EAAE,EAAE,EAAE;gCAChD,KAAK;gCACL,SAAS;6BACV,CAAC,CAAC;yBACJ;qBACF;oBACD,MAAM,EAAE,CAAC;iBACV;aACF;SAAA;QAEK,eAAe,CAAC,SAAiB;;gBACrC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAW,CAAC;gBAClD,MAAM,UAAU,GAAGM,gBAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBAEzD,MAAM,aAAa,GAAGE,gBAAU,CAACC,YAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACxE,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;oBAC9B,MAAM,IAAI,KAAK,CACb;uBACe,SAAS;2BACL,IAAI,CAAC,GAAG;UACzB,CACH,CAAC;iBACH;aACF;SAAA;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"taquito-remote-signer.umd.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["/**\n * @category Error\n * @description Error that indicates a failure in grabbing the public key\n */\nexport class KeyNotFoundError extends Error {\n public name = 'KeyNotFoundError';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends Error {\n public name = 'OperationNotAuthorized';\n constructor(public message: string, public innerException: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates bad signing data\n */\nexport class BadSigningDataError extends Error {\n public name = 'BadSigningData';\n constructor(public message: string, public innerException: any, public readonly data: any) {\n super(message);\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates a mismatch between the initialized and the requested public key\n */\nexport class PublicKeyMismatch extends Error {\n public name = 'PublicKeyMismatch';\n constructor(public requested: string, initialized: string) {\n super(\n `Requested public key hash does not match the initialized public key hash: {\n requested: ${requested},\n initialized: ${initialized}\n }`\n );\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"38da814ec2bb4e81c7ad5a45b6b183a4d0b8dc25\",\n \"version\": \"12.1.1\"\n};\n","/**\n * @packageDocumentation\n * @module @taquito/remote-signer\n */\nimport { HttpBackend, HttpResponseError, STATUS_CODE } from '@taquito/http-utils';\nimport {\n b58cdecode,\n b58cencode,\n buf2hex,\n hex2buf,\n isValidPrefix,\n mergebuf,\n prefix,\n verifySignature,\n validateKeyHash,\n ValidationResult,\n InvalidKeyHashError,\n ProhibitedActionError,\n InvalidSignatureError,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n KeyNotFoundError,\n OperationNotAuthorizedError,\n PublicKeyMismatch,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationFailedError extends Error {\n public name = 'SignatureVerificationFailedError';\n constructor(public bytes: string, public signature: string) {\n super(\n `\n Signature failed verification against public key: \n {\n bytes: ${bytes},\n signature: ${signature}\n }\n `\n );\n }\n}\n\ninterface PublicKeyResponse {\n public_key: string;\n}\n\ninterface SignResponse {\n signature: string;\n}\n\ntype curves = 'ed' | 'p2' | 'sp';\n\nexport interface RemoteSignerOptions {\n headers?: { [key: string]: string };\n}\n\nexport { VERSION } from './version';\n\nconst pref = {\n ed: {\n pk: prefix['edpk'],\n sk: prefix['edsk'],\n pkh: prefix.tz1,\n sig: prefix.edsig,\n },\n p2: {\n pk: prefix['p2pk'],\n sk: prefix['p2sk'],\n pkh: prefix.tz3,\n sig: prefix.p2sig,\n },\n sp: {\n pk: prefix['sppk'],\n sk: prefix['spsk'],\n pkh: prefix.tz2,\n sig: prefix.spsig,\n },\n};\n\nexport class RemoteSigner implements Signer {\n constructor(\n private pkh: string,\n private rootUrl: string,\n private options: RemoteSignerOptions = {},\n private http = new HttpBackend()\n ) {\n if (validateKeyHash(this.pkh) !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh);\n }\n }\n\n async publicKeyHash(): Promise<string> {\n return this.pkh;\n }\n\n private createURL(path: string) {\n // Trim trailing slashes because it is assumed to be included in path\n return `${this.rootUrl.replace(/\\/+$/g, '')}${path}`;\n }\n\n async publicKey(): Promise<string> {\n try {\n const { public_key } = await this.http.createRequest<PublicKeyResponse>({\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'GET',\n headers: this.options.headers,\n });\n return public_key;\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n }\n }\n throw ex;\n }\n }\n\n async secretKey(): Promise<string> {\n throw new ProhibitedActionError('Secret key cannot be exposed');\n }\n\n async sign(bytes: string, watermark?: Uint8Array) {\n try {\n let bb = hex2buf(bytes);\n if (typeof watermark !== 'undefined') {\n bb = mergebuf(watermark, bb);\n }\n const watermarkedBytes = buf2hex(toBuffer(bb));\n const { signature } = await this.http.createRequest<SignResponse>(\n {\n url: this.createURL(`/keys/${this.pkh}`),\n method: 'POST',\n headers: this.options.headers,\n },\n watermarkedBytes\n );\n const pref = signature.startsWith('sig')\n ? signature.substring(0, 3)\n : signature.substring(0, 5);\n\n if (!isValidPrefix(pref)) {\n throw new InvalidSignatureError(signature, 'Unsupported signature given by remote signer');\n }\n\n const decoded = b58cdecode(signature, prefix[pref]);\n\n const pk = await this.publicKey();\n await this.verifyPublicKey(pk);\n const signatureVerified = verifySignature(watermarkedBytes, pk, signature);\n if (!signatureVerified) {\n throw new SignatureVerificationFailedError(watermarkedBytes, signature);\n }\n\n return {\n bytes,\n sig: b58cencode(decoded, prefix.sig),\n prefixSig: signature,\n sbytes: bytes + buf2hex(toBuffer(decoded)),\n };\n } catch (ex) {\n if (ex instanceof HttpResponseError) {\n if (ex.status === STATUS_CODE.NOT_FOUND) {\n throw new KeyNotFoundError(`Key not found: ${this.pkh}`, ex);\n } else if (ex.status === STATUS_CODE.FORBIDDEN) {\n throw new OperationNotAuthorizedError('Signing Operation not authorized', ex);\n } else if (ex.status === STATUS_CODE.BAD_REQUEST) {\n throw new BadSigningDataError('Invalid data', ex, {\n bytes,\n watermark,\n });\n }\n }\n throw ex;\n }\n }\n\n async verifyPublicKey(publicKey: string) {\n const curve = publicKey.substring(0, 2) as curves;\n const _publicKey = b58cdecode(publicKey, pref[curve].pk);\n\n const publicKeyHash = b58cencode(hash(_publicKey, 20), pref[curve].pkh);\n if (publicKeyHash !== this.pkh) {\n throw new PublicKeyMismatch(publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":["prefix","HttpBackend","validateKeyHash","ValidationResult","InvalidKeyHashError","HttpResponseError","STATUS_CODE","ProhibitedActionError","hex2buf","mergebuf","buf2hex","toBuffer","isValidPrefix","InvalidSignatureError","b58cdecode","verifySignature","b58cencode","hash"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAAA;;;;UAIa,gBAAiB,SAAQ,KAAK;QAEzC,YAAmB,OAAe,EAAS,cAAmB;YAC5D,KAAK,CAAC,OAAO,CAAC,CAAC;YADE,YAAO,GAAP,OAAO,CAAQ;YAAS,mBAAc,GAAd,cAAc,CAAK;YADvD,SAAI,GAAG,kBAAkB,CAAC;SAGhC;KACF;IAED;;;;UAIa,2BAA4B,SAAQ,KAAK;QAEpD,YAAmB,OAAe,EA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AW,CAAC;gBAClD,MAAM,UAAU,GAAGQ,gBAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;gBAEzD,MAAM,aAAa,GAAGE,gBAAU,CAACC,YAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;gBACxE,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;oBAC9B,MAAM,IAAI,iBAAiB,CAAC,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;iBACtD;aACF;SAAA;;;;;;;;;;;;;"}
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @category Error
|
|
3
|
+
* @description Error that indicates a failure in grabbing the public key
|
|
4
|
+
*/
|
|
1
5
|
export declare class KeyNotFoundError extends Error {
|
|
2
6
|
message: string;
|
|
3
7
|
innerException: any;
|
|
4
8
|
name: string;
|
|
5
9
|
constructor(message: string, innerException: any);
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* @category Error
|
|
13
|
+
* @description Error that indicates an unauthorized operation being attempted
|
|
14
|
+
*/
|
|
7
15
|
export declare class OperationNotAuthorizedError extends Error {
|
|
8
16
|
message: string;
|
|
9
17
|
innerException: any;
|
|
10
18
|
name: string;
|
|
11
19
|
constructor(message: string, innerException: any);
|
|
12
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* @category Error
|
|
23
|
+
* @description Error that indicates bad signing data
|
|
24
|
+
*/
|
|
13
25
|
export declare class BadSigningDataError extends Error {
|
|
14
26
|
message: string;
|
|
15
27
|
innerException: any;
|
|
@@ -17,3 +29,12 @@ export declare class BadSigningDataError extends Error {
|
|
|
17
29
|
name: string;
|
|
18
30
|
constructor(message: string, innerException: any, data: any);
|
|
19
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* @category Error
|
|
34
|
+
* @description Error that indicates a mismatch between the initialized and the requested public key
|
|
35
|
+
*/
|
|
36
|
+
export declare class PublicKeyMismatch extends Error {
|
|
37
|
+
requested: string;
|
|
38
|
+
name: string;
|
|
39
|
+
constructor(requested: string, initialized: string);
|
|
40
|
+
}
|
|
@@ -4,6 +4,16 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { HttpBackend } from '@taquito/http-utils';
|
|
6
6
|
import { Signer } from '@taquito/taquito';
|
|
7
|
+
/**
|
|
8
|
+
* @category Error
|
|
9
|
+
* @description Error
|
|
10
|
+
*/
|
|
11
|
+
export declare class SignatureVerificationFailedError extends Error {
|
|
12
|
+
bytes: string;
|
|
13
|
+
signature: string;
|
|
14
|
+
name: string;
|
|
15
|
+
constructor(bytes: string, signature: string);
|
|
16
|
+
}
|
|
7
17
|
export interface RemoteSignerOptions {
|
|
8
18
|
headers?: {
|
|
9
19
|
[key: string]: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@taquito/remote-signer",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.1",
|
|
4
4
|
"description": "Remote signer provider",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"tezos",
|
|
@@ -63,9 +63,9 @@
|
|
|
63
63
|
"dependencies": {
|
|
64
64
|
"@stablelib/blake2b": "^1.0.1",
|
|
65
65
|
"@stablelib/ed25519": "^1.0.2",
|
|
66
|
-
"@taquito/http-utils": "^12.
|
|
67
|
-
"@taquito/taquito": "^12.
|
|
68
|
-
"@taquito/utils": "^12.
|
|
66
|
+
"@taquito/http-utils": "^12.1.1",
|
|
67
|
+
"@taquito/taquito": "^12.1.1",
|
|
68
|
+
"@taquito/utils": "^12.1.1",
|
|
69
69
|
"typedarray-to-buffer": "^4.0.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
@@ -97,5 +97,5 @@
|
|
|
97
97
|
"ts-toolbelt": "^9.6.0",
|
|
98
98
|
"typescript": "~4.1.5"
|
|
99
99
|
},
|
|
100
|
-
"gitHead": "
|
|
100
|
+
"gitHead": "e97d6f77d990f91b4e407f4e7b7f8f3785edb2ba"
|
|
101
101
|
}
|