@taquito/remote-signer 17.1.1 → 17.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ exports.SignatureVerificationError = exports.PublicKeyVerificationError = export
4
4
  const core_1 = require("@taquito/core");
5
5
  /**
6
6
  * @category Error
7
- * @description Error indicates an unauthorized operation being attempted
7
+ * @description Error that indicates an unauthorized operation being attempted
8
8
  */
9
9
  class OperationNotAuthorizedError extends core_1.PermissionDeniedError {
10
10
  constructor(message, cause) {
@@ -17,7 +17,7 @@ class OperationNotAuthorizedError extends core_1.PermissionDeniedError {
17
17
  exports.OperationNotAuthorizedError = OperationNotAuthorizedError;
18
18
  /**
19
19
  * @category Error
20
- * @description Error indicates bad signing data
20
+ * @description Error that indicates bad signing data
21
21
  */
22
22
  class BadSigningDataError extends core_1.TaquitoError {
23
23
  constructor(cause, bytes, watermark) {
@@ -34,7 +34,7 @@ class BadSigningDataError extends core_1.TaquitoError {
34
34
  exports.BadSigningDataError = BadSigningDataError;
35
35
  /**
36
36
  * @category Error
37
- * @description Error indicates a mismatch between the initialized and the requested public key
37
+ * @description Error that indicates a mismatch between the initialized and the requested public key
38
38
  */
39
39
  class PublicKeyVerificationError extends core_1.TaquitoError {
40
40
  constructor(requestedPk, requestedPkh, initializedPkh) {
@@ -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": "15732f9b7d575aa46427c94501fb8677a754b733",
7
- "version": "17.1.1"
6
+ "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
7
+ "version": "17.2.0"
8
8
  };
9
9
  //# sourceMappingURL=version.js.map
@@ -36,7 +36,7 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
36
36
 
37
37
  /**
38
38
  * @category Error
39
- * @description Error indicates an unauthorized operation being attempted
39
+ * @description Error that indicates an unauthorized operation being attempted
40
40
  */
41
41
  class OperationNotAuthorizedError extends PermissionDeniedError {
42
42
  constructor(message, cause) {
@@ -48,7 +48,7 @@ class OperationNotAuthorizedError extends PermissionDeniedError {
48
48
  }
49
49
  /**
50
50
  * @category Error
51
- * @description Error indicates bad signing data
51
+ * @description Error that indicates bad signing data
52
52
  */
53
53
  class BadSigningDataError extends TaquitoError {
54
54
  constructor(cause, bytes, watermark) {
@@ -64,7 +64,7 @@ class BadSigningDataError extends TaquitoError {
64
64
  }
65
65
  /**
66
66
  * @category Error
67
- * @description Error indicates a mismatch between the initialized and the requested public key
67
+ * @description Error that indicates a mismatch between the initialized and the requested public key
68
68
  */
69
69
  class PublicKeyVerificationError extends TaquitoError {
70
70
  constructor(requestedPk, requestedPkh, initializedPkh) {
@@ -93,8 +93,8 @@ class SignatureVerificationError extends TaquitoError {
93
93
 
94
94
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
95
95
  const VERSION = {
96
- "commitHash": "15732f9b7d575aa46427c94501fb8677a754b733",
97
- "version": "17.1.1"
96
+ "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
97
+ "version": "17.2.0"
98
98
  };
99
99
 
100
100
  const pref = {
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-remote-signer.es6.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["import { PermissionDeniedError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends PermissionDeniedError {\n constructor(public readonly message: string, public readonly cause: any) {\n super();\n this.name = 'OperationNotAuthorized';\n }\n}\n\n/**\n * @category Error\n * @description Error indicates bad signing data\n */\nexport class BadSigningDataError extends TaquitoError {\n constructor(\n public readonly cause: any,\n public readonly bytes: string,\n readonly watermark?: Uint8Array\n ) {\n super();\n this.name = 'BadSigningData';\n this.message = watermark\n ? `Invalid signing data with watermark`\n : `Invalid signing data: \"${bytes}\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error indicates a mismatch between the initialized and the requested public key\n */\nexport class PublicKeyVerificationError extends TaquitoError {\n constructor(\n public readonly requestedPk: string,\n public readonly requestedPkh: string,\n public readonly initializedPkh: string\n ) {\n super();\n this.name = 'PublicKeyVerificationFailedError';\n this.message = `Requested pk \"${requestedPk}\" has pkh \"${requestedPkh}\" deesn't match initialized pkh \"${initializedPkh}.\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationError extends TaquitoError {\n public name = 'SignatureVerificationFailedError';\n constructor(public readonly bytes: string, public readonly signature: string) {\n super();\n this.name = 'SignatureVerificationFailedError';\n this.message = `Invalid signature of bytes failed verification agaisnt public key.`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"15732f9b7d575aa46427c94501fb8677a754b733\",\n \"version\": \"17.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 invalidDetail,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n OperationNotAuthorizedError,\n PublicKeyVerificationError,\n SignatureVerificationError,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\nimport {\n InvalidSignatureError,\n InvalidKeyHashError,\n ProhibitedActionError,\n PublicKeyNotFoundError,\n} from '@taquito/core';\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 const pkhValidation = validateKeyHash(this.pkh);\n if (pkhValidation !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh, invalidDetail(pkhValidation));\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 PublicKeyNotFoundError(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(\n signature,\n invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` from a remote signer.`\n );\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 SignatureVerificationError(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 PublicKeyNotFoundError(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(ex, bytes, watermark);\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 PublicKeyVerificationError(publicKey, publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAGG;AACG,MAAO,2BAA4B,SAAQ,qBAAqB,CAAA;IACpE,WAA4B,CAAA,OAAe,EAAkB,KAAU,EAAA;AACrE,QAAA,KAAK,EAAE,CAAC;QADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;QAAkB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;AAErE,QAAA,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;KACtC;AACF,CAAA;AAED;;;AAGG;AACG,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AC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AACxE,YAAA,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;gBAC9B,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1E,aAAA;SACF,CAAA,CAAA;AAAA,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"taquito-remote-signer.es6.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["import { PermissionDeniedError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends PermissionDeniedError {\n constructor(public readonly message: string, public readonly cause: any) {\n super();\n this.name = 'OperationNotAuthorized';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates bad signing data\n */\nexport class BadSigningDataError extends TaquitoError {\n constructor(\n public readonly cause: any,\n public readonly bytes: string,\n readonly watermark?: Uint8Array\n ) {\n super();\n this.name = 'BadSigningData';\n this.message = watermark\n ? `Invalid signing data with watermark`\n : `Invalid signing data: \"${bytes}\"`;\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 PublicKeyVerificationError extends TaquitoError {\n constructor(\n public readonly requestedPk: string,\n public readonly requestedPkh: string,\n public readonly initializedPkh: string\n ) {\n super();\n this.name = 'PublicKeyVerificationFailedError';\n this.message = `Requested pk \"${requestedPk}\" has pkh \"${requestedPkh}\" deesn't match initialized pkh \"${initializedPkh}.\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationError extends TaquitoError {\n public name = 'SignatureVerificationFailedError';\n constructor(public readonly bytes: string, public readonly signature: string) {\n super();\n this.name = 'SignatureVerificationFailedError';\n this.message = `Invalid signature of bytes failed verification agaisnt public key.`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"b85fc404e34545a518215e449b3f1253f4520eec\",\n \"version\": \"17.2.0\"\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 invalidDetail,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n OperationNotAuthorizedError,\n PublicKeyVerificationError,\n SignatureVerificationError,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\nimport {\n InvalidSignatureError,\n InvalidKeyHashError,\n ProhibitedActionError,\n PublicKeyNotFoundError,\n} from '@taquito/core';\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 const pkhValidation = validateKeyHash(this.pkh);\n if (pkhValidation !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh, invalidDetail(pkhValidation));\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 PublicKeyNotFoundError(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(\n signature,\n invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` from a remote signer.`\n );\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 SignatureVerificationError(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 PublicKeyNotFoundError(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(ex, bytes, watermark);\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 PublicKeyVerificationError(publicKey, publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;;;AAGG;AACG,MAAO,2BAA4B,SAAQ,qBAAqB,CAAA;IACpE,WAA4B,CAAA,OAAe,EAAkB,KAAU,EAAA;AACrE,QAAA,KAAK,EAAE,CAAC;QADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;QAAkB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;AAErE,QAAA,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;KACtC;AACF,CAAA;AAED;;;AAGG;AACG,MAAO,mBAAoB,SAAQ,YAAY,CAAA;AACnD,IAAA,WAAA,CACkB,KAAU,EACV,KAAa,EACpB,SAAsB,EAAA;AAE/B,QAAA,KAAK,EAAE,CAAC;QAJQ,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;QACV,IAAK,CAAA,KAAA,GAAL,KAAK,CAAQ;QACpB,IAAS,CAAA,SAAA,GAAT,SAAS,CAAa;AAG/B,QAAA,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,OAAO,GAAG,SAAS;AACtB,cAAE,CAAqC,mCAAA,CAAA;AACvC,cAAE,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAA,CAAG,CAAC;KACxC;AACF,CAAA;AAED;;;AAGG;AACG,MAAO,0BAA2B,SAAQ,YAAY,CAAA;AAC1D,IAAA,WAAA,CACkB,WAAmB,EACnB,YAAoB,EACpB,cAAsB,EAAA;AAEtC,QAAA,KAAK,E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E;AAC9C,wBAAA,MAAM,IAAI,2BAA2B,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;AAC/E,qBAAA;AAAM,yBAAA,IAAI,EAAE,CAAC,MAAM,KAAK,WAAW,CAAC,WAAW,EAAE;wBAChD,MAAM,IAAI,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AACrD,qBAAA;AACF,iBAAA;AACD,gBAAA,MAAM,EAAE,CAAC;AACV,aAAA;SACF,CAAA,CAAA;AAAA,KAAA;AAEK,IAAA,eAAe,CAAC,SAAiB,EAAA;;YACrC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAW,CAAC;AAClD,YAAA,MAAM,UAAU,GAAG,UAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;AAEzD,YAAA,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AACxE,YAAA,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;gBAC9B,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;AAC1E,aAAA;SACF,CAAA,CAAA;AAAA,KAAA;AACF;;;;"}
@@ -40,7 +40,7 @@
40
40
 
41
41
  /**
42
42
  * @category Error
43
- * @description Error indicates an unauthorized operation being attempted
43
+ * @description Error that indicates an unauthorized operation being attempted
44
44
  */
45
45
  class OperationNotAuthorizedError extends core.PermissionDeniedError {
46
46
  constructor(message, cause) {
@@ -52,7 +52,7 @@
52
52
  }
53
53
  /**
54
54
  * @category Error
55
- * @description Error indicates bad signing data
55
+ * @description Error that indicates bad signing data
56
56
  */
57
57
  class BadSigningDataError extends core.TaquitoError {
58
58
  constructor(cause, bytes, watermark) {
@@ -68,7 +68,7 @@
68
68
  }
69
69
  /**
70
70
  * @category Error
71
- * @description Error indicates a mismatch between the initialized and the requested public key
71
+ * @description Error that indicates a mismatch between the initialized and the requested public key
72
72
  */
73
73
  class PublicKeyVerificationError extends core.TaquitoError {
74
74
  constructor(requestedPk, requestedPkh, initializedPkh) {
@@ -97,8 +97,8 @@
97
97
 
98
98
  // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
99
99
  const VERSION = {
100
- "commitHash": "15732f9b7d575aa46427c94501fb8677a754b733",
101
- "version": "17.1.1"
100
+ "commitHash": "b85fc404e34545a518215e449b3f1253f4520eec",
101
+ "version": "17.2.0"
102
102
  };
103
103
 
104
104
  const pref = {
@@ -1 +1 @@
1
- {"version":3,"file":"taquito-remote-signer.umd.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["import { PermissionDeniedError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends PermissionDeniedError {\n constructor(public readonly message: string, public readonly cause: any) {\n super();\n this.name = 'OperationNotAuthorized';\n }\n}\n\n/**\n * @category Error\n * @description Error indicates bad signing data\n */\nexport class BadSigningDataError extends TaquitoError {\n constructor(\n public readonly cause: any,\n public readonly bytes: string,\n readonly watermark?: Uint8Array\n ) {\n super();\n this.name = 'BadSigningData';\n this.message = watermark\n ? `Invalid signing data with watermark`\n : `Invalid signing data: \"${bytes}\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error indicates a mismatch between the initialized and the requested public key\n */\nexport class PublicKeyVerificationError extends TaquitoError {\n constructor(\n public readonly requestedPk: string,\n public readonly requestedPkh: string,\n public readonly initializedPkh: string\n ) {\n super();\n this.name = 'PublicKeyVerificationFailedError';\n this.message = `Requested pk \"${requestedPk}\" has pkh \"${requestedPkh}\" deesn't match initialized pkh \"${initializedPkh}.\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationError extends TaquitoError {\n public name = 'SignatureVerificationFailedError';\n constructor(public readonly bytes: string, public readonly signature: string) {\n super();\n this.name = 'SignatureVerificationFailedError';\n this.message = `Invalid signature of bytes failed verification agaisnt public key.`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"15732f9b7d575aa46427c94501fb8677a754b733\",\n \"version\": \"17.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 invalidDetail,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n OperationNotAuthorizedError,\n PublicKeyVerificationError,\n SignatureVerificationError,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\nimport {\n InvalidSignatureError,\n InvalidKeyHashError,\n ProhibitedActionError,\n PublicKeyNotFoundError,\n} from '@taquito/core';\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 const pkhValidation = validateKeyHash(this.pkh);\n if (pkhValidation !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh, invalidDetail(pkhValidation));\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 PublicKeyNotFoundError(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(\n signature,\n invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` from a remote signer.`\n );\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 SignatureVerificationError(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 PublicKeyNotFoundError(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(ex, bytes, watermark);\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 PublicKeyVerificationError(publicKey, publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":["PermissionDeniedError","TaquitoError","prefix","HttpBackend","validateKeyHash","ValidationResult","InvalidKeyHashError","invalidDetail","HttpResponseError","STATUS_CODE","PublicKeyNotFoundError","ProhibitedActionError","hex2buf","mergebuf","buf2hex","toBuffer","isValidPrefix","InvalidSignatureError","b58cdecode","verifySignature","b58cencode","hash"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEA;;;IAGG;IACG,MAAO,2BAA4B,SAAQA,0BAAqB,CAAA;QACpE,WAA4B,CAAA,OAAe,EAAkB,KAAU,EAAA;IACrE,QAAA,KAAK,EAAE,CAAC;YADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;YAAkB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;IAErE,QAAA,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;SACtC;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,mBAAoB,SAAQC,iBAAY,CAAA;IACnD,IAAA,WAAA,CACkB,KAAU,EACV,KAAa,EACpB,SAAsB,EAAA;IAE/B,QAAA,KAAK,EAAE,CAAC;YAJQ,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;Y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oBAC9B,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1E,aAAA;aACF,CAAA,CAAA;IAAA,KAAA;IACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"taquito-remote-signer.umd.js","sources":["../src/errors.ts","../src/version.ts","../src/taquito-remote-signer.ts"],"sourcesContent":["import { PermissionDeniedError, TaquitoError } from '@taquito/core';\n\n/**\n * @category Error\n * @description Error that indicates an unauthorized operation being attempted\n */\nexport class OperationNotAuthorizedError extends PermissionDeniedError {\n constructor(public readonly message: string, public readonly cause: any) {\n super();\n this.name = 'OperationNotAuthorized';\n }\n}\n\n/**\n * @category Error\n * @description Error that indicates bad signing data\n */\nexport class BadSigningDataError extends TaquitoError {\n constructor(\n public readonly cause: any,\n public readonly bytes: string,\n readonly watermark?: Uint8Array\n ) {\n super();\n this.name = 'BadSigningData';\n this.message = watermark\n ? `Invalid signing data with watermark`\n : `Invalid signing data: \"${bytes}\"`;\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 PublicKeyVerificationError extends TaquitoError {\n constructor(\n public readonly requestedPk: string,\n public readonly requestedPkh: string,\n public readonly initializedPkh: string\n ) {\n super();\n this.name = 'PublicKeyVerificationFailedError';\n this.message = `Requested pk \"${requestedPk}\" has pkh \"${requestedPkh}\" deesn't match initialized pkh \"${initializedPkh}.\"`;\n }\n}\n\n/**\n * @category Error\n * @description Error\n */\nexport class SignatureVerificationError extends TaquitoError {\n public name = 'SignatureVerificationFailedError';\n constructor(public readonly bytes: string, public readonly signature: string) {\n super();\n this.name = 'SignatureVerificationFailedError';\n this.message = `Invalid signature of bytes failed verification agaisnt public key.`;\n }\n}\n","\n// IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!\nexport const VERSION = {\n \"commitHash\": \"b85fc404e34545a518215e449b3f1253f4520eec\",\n \"version\": \"17.2.0\"\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 invalidDetail,\n} from '@taquito/utils';\nimport { hash } from '@stablelib/blake2b';\nimport toBuffer from 'typedarray-to-buffer';\nimport {\n BadSigningDataError,\n OperationNotAuthorizedError,\n PublicKeyVerificationError,\n SignatureVerificationError,\n} from './errors';\nimport { Signer } from '@taquito/taquito';\nimport {\n InvalidSignatureError,\n InvalidKeyHashError,\n ProhibitedActionError,\n PublicKeyNotFoundError,\n} from '@taquito/core';\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 const pkhValidation = validateKeyHash(this.pkh);\n if (pkhValidation !== ValidationResult.VALID) {\n throw new InvalidKeyHashError(this.pkh, invalidDetail(pkhValidation));\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 PublicKeyNotFoundError(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(\n signature,\n invalidDetail(ValidationResult.NO_PREFIX_MATCHED) + ` from a remote signer.`\n );\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 SignatureVerificationError(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 PublicKeyNotFoundError(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(ex, bytes, watermark);\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 PublicKeyVerificationError(publicKey, publicKeyHash, this.pkh);\n }\n }\n}\n"],"names":["PermissionDeniedError","TaquitoError","prefix","HttpBackend","validateKeyHash","ValidationResult","InvalidKeyHashError","invalidDetail","HttpResponseError","STATUS_CODE","PublicKeyNotFoundError","ProhibitedActionError","hex2buf","mergebuf","buf2hex","toBuffer","isValidPrefix","InvalidSignatureError","b58cdecode","verifySignature","b58cencode","hash"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAEA;;;IAGG;IACG,MAAO,2BAA4B,SAAQA,0BAAqB,CAAA;QACpE,WAA4B,CAAA,OAAe,EAAkB,KAAU,EAAA;IACrE,QAAA,KAAK,EAAE,CAAC;YADkB,IAAO,CAAA,OAAA,GAAP,OAAO,CAAQ;YAAkB,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;IAErE,QAAA,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;SACtC;IACF,CAAA;IAED;;;IAGG;IACG,MAAO,mBAAoB,SAAQC,iBAAY,CAAA;IACnD,IAAA,WAAA,CACkB,KAAU,EACV,KAAa,EACpB,SAAsB,EAAA;IAE/B,QAAA,KAAK,EAAE,CAAC;YAJQ,IAAK,CAAA,KAAA,GAAL,KAAK,CAAK;YACV,IAAK,CAAA,KAAA,GAAL,KAAK,CAAQ;YACpB,IAAS,CAAA,SAAA,GAAT,SAAS,CAAa;IAG/B,QAAA,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;YAC7B,IAAI,CAAC,OAAO,GAAG,SAAS;IACtB,cAAE,CAAqC,mCAAA,CAAA;IACvC,cAAE,CAAA,uBAAA,EAA0B,KAAK,CAAA,CAAA,CAAG,CAAC;SACxC;IACF,CAAA;IAED;;;IAGG;IACG,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KC,qBAAW,CAAC,SAAS,EAAE;4BACvC,MAAM,IAAIC,2BAAsB,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IAChD,qBAAA;IAAM,yBAAA,IAAI,EAAE,CAAC,MAAM,KAAKD,qBAAW,CAAC,SAAS,EAAE;IAC9C,wBAAA,MAAM,IAAI,2BAA2B,CAAC,kCAAkC,EAAE,EAAE,CAAC,CAAC;IAC/E,qBAAA;IAAM,yBAAA,IAAI,EAAE,CAAC,MAAM,KAAKA,qBAAW,CAAC,WAAW,EAAE;4BAChD,MAAM,IAAI,mBAAmB,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;IACrD,qBAAA;IACF,iBAAA;IACD,gBAAA,MAAM,EAAE,CAAC;IACV,aAAA;aACF,CAAA,CAAA;IAAA,KAAA;IAEK,IAAA,eAAe,CAAC,SAAiB,EAAA;;gBACrC,MAAM,KAAK,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,CAAW,CAAC;IAClD,YAAA,MAAM,UAAU,GAAGS,gBAAU,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC;IAEzD,YAAA,MAAM,aAAa,GAAGE,gBAAU,CAACC,YAAI,CAAC,UAAU,EAAE,EAAE,CAAC,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;IACxE,YAAA,IAAI,aAAa,KAAK,IAAI,CAAC,GAAG,EAAE;oBAC9B,MAAM,IAAI,0BAA0B,CAAC,SAAS,EAAE,aAAa,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IAC1E,aAAA;aACF,CAAA,CAAA;IAAA,KAAA;IACF;;;;;;;;;;;"}
@@ -1,7 +1,7 @@
1
1
  import { PermissionDeniedError, TaquitoError } from '@taquito/core';
2
2
  /**
3
3
  * @category Error
4
- * @description Error indicates an unauthorized operation being attempted
4
+ * @description Error that indicates an unauthorized operation being attempted
5
5
  */
6
6
  export declare class OperationNotAuthorizedError extends PermissionDeniedError {
7
7
  readonly message: string;
@@ -10,7 +10,7 @@ export declare class OperationNotAuthorizedError extends PermissionDeniedError {
10
10
  }
11
11
  /**
12
12
  * @category Error
13
- * @description Error indicates bad signing data
13
+ * @description Error that indicates bad signing data
14
14
  */
15
15
  export declare class BadSigningDataError extends TaquitoError {
16
16
  readonly cause: any;
@@ -20,7 +20,7 @@ export declare class BadSigningDataError extends TaquitoError {
20
20
  }
21
21
  /**
22
22
  * @category Error
23
- * @description Error indicates a mismatch between the initialized and the requested public key
23
+ * @description Error that indicates a mismatch between the initialized and the requested public key
24
24
  */
25
25
  export declare class PublicKeyVerificationError extends TaquitoError {
26
26
  readonly requestedPk: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taquito/remote-signer",
3
- "version": "17.1.1",
3
+ "version": "17.2.0",
4
4
  "description": "Remote signer provider",
5
5
  "keywords": [
6
6
  "tezos",
@@ -63,10 +63,10 @@
63
63
  "dependencies": {
64
64
  "@stablelib/blake2b": "^1.0.1",
65
65
  "@stablelib/ed25519": "^1.0.3",
66
- "@taquito/core": "^17.1.1",
67
- "@taquito/http-utils": "^17.1.1",
68
- "@taquito/taquito": "^17.1.1",
69
- "@taquito/utils": "^17.1.1",
66
+ "@taquito/core": "^17.2.0",
67
+ "@taquito/http-utils": "^17.2.0",
68
+ "@taquito/taquito": "^17.2.0",
69
+ "@taquito/utils": "^17.2.0",
70
70
  "typedarray-to-buffer": "^4.0.0"
71
71
  },
72
72
  "devDependencies": {
@@ -98,5 +98,5 @@
98
98
  "ts-toolbelt": "^9.6.0",
99
99
  "typescript": "~4.1.5"
100
100
  },
101
- "gitHead": "8f685d3d4fef68a2cfc44f8da7ba866a11478681"
101
+ "gitHead": "8fe3376401f12f5a97556479620c0414a6e5c7c3"
102
102
  }