@valora/viem-account-hsm-gcp 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # @valora/viem-account-hsm-gcp
2
+
3
+ [![GitHub License](https://img.shields.io/github/license/valora-inc/viem-account-hsm-gcp?color=blue)](https://github.com/valora-inc/viem-account-hsm-gcp/blob/main/LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/@valora/viem-account-hsm-gcp.svg)](https://www.npmjs.com/package/@valora/viem-account-hsm-gcp)
5
+ [![GitHub Workflow Status](https://img.shields.io/github/actions/workflow/status/valora-inc/viem-account-hsm-gcp/.github/workflows/workflow.yaml?branch=main)](https://github.com/valora-inc/viem-account-hsm-gcp/actions/workflows/workflow.yaml?query=branch%3Amain)
6
+ [![Codecov](https://img.shields.io/codecov/c/github/valora-inc/viem-account-hsm-gcp)](https://codecov.io/gh/valora-inc/viem-account-hsm-gcp)
7
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/valora-inc/viem-account-hsm-gcp#contributing)
8
+
9
+ Use a Google Cloud HSM key to sign transactions with [viem](https://viem.sh/).
10
+
11
+ ## Installing the library
12
+
13
+ ```
14
+ yarn add @valora/viem-account-hsm-gcp
15
+ ```
16
+
17
+ Note: viem is a peer dependency, so make it sure it's installed in your project.
18
+
19
+ ## Using the library
20
+
21
+ ### Simple usage
22
+
23
+ ```typescript
24
+ import { createWalletClient, http } from 'viem'
25
+ import { mainnet } from 'viem/chains'
26
+ import { gcpHsmToAccount } from '@valora/viem-account-hsm-gcp'
27
+
28
+ const account = await gcpHsmToAccount({
29
+ hsmKeyVersion:
30
+ 'projects/your-gcp-project/locations/global/keyRings/your-keyring/cryptoKeys/your-hsm/cryptoKeyVersions/1',
31
+ })
32
+
33
+ const client = createWalletClient({
34
+ account,
35
+ chain: mainnet,
36
+ transport: http(),
37
+ })
38
+
39
+ // Test send a transaction to the HSM key (the HSM key needs to be funded)
40
+ const hash = await client.sendTransaction({
41
+ to: account.address,
42
+ value: parseEther('0.001'),
43
+ })
44
+ ```
45
+
46
+ > [!IMPORTANT]
47
+ > Make sure the key in [Google Cloud KMS](https://console.cloud.google.com/security/kms/keyrings) is a secp256k1 key.
48
+
49
+ <img src="./docs/images/gcp-key-creation.png" alt="gcp-key-creation" width="500"/>
50
+
51
+ > [!TIP]
52
+ > You don't have to use an HSM key, you can use a software key as well. See the [Google Cloud KMS documentation](https://cloud.google.com/kms/docs/algorithms#protection_levels) for more information.
53
+
54
+ ## Resources
55
+
56
+ - [viem](https://viem.sh/)
57
+ - [@google-cloud/kms](https://www.npmjs.com/package/@google-cloud/kms)
58
+
59
+ ## Acknowledgements
60
+
61
+ This library is a port of [@celo/wallet-hsm-gcp](https://github.com/celo-org/developer-tooling/tree/0c61e7e02c741fe10ecd1d733a33692d324cdc82/packages/sdk/wallets/wallet-hsm-gcp) to viem.
62
+
63
+ Big thanks to the Celo team for the original implementation.
64
+
65
+ ## Contributing
66
+
67
+ - [Reporting issues](https://github.com/valora-inc/viem-account-hsm-gcp/issues)
68
+ - [Submitting a pull request](https://github.com/valora-inc/viem-account-hsm-gcp/pulls)
69
+ - Publishing updates is done automatically via [semantic-release](https://github.com/semantic-release/semantic-release).
70
+ Remember to use [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) or your PR will be rejected (since
71
+ merging it would mess up the changelog and version numbers).
@@ -0,0 +1,141 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.gcpHsmToAccount = void 0;
27
+ const kms_1 = require("@google-cloud/kms");
28
+ const asn1 = __importStar(require("asn1js"));
29
+ const accounts_1 = require("viem/accounts");
30
+ const viem_1 = require("viem");
31
+ const secp256k1_1 = require("@noble/curves/secp256k1");
32
+ // Including 0x prefix
33
+ const UNCOMPRESSED_PUBLIC_KEY_HEX_LENGTH = 132; // 2 * 66
34
+ async function getPublicKey(kmsClient, hsmKeyVersion) {
35
+ const [pk] = await kmsClient.getPublicKey({ name: hsmKeyVersion });
36
+ if (!pk.pem) {
37
+ throw new Error('PublicKey pem is not defined');
38
+ }
39
+ const derEncodedPk = pemToDer(pk.pem);
40
+ return publicKeyFromDer(derEncodedPk);
41
+ }
42
+ /**
43
+ * Converts key from PEM to DER encoding.
44
+ *
45
+ * DER (Distinguished Encoding Rules) is a binary encoding for X.509 certificates and private keys.
46
+ * Unlike PEM, DER-encoded files do not contain plain text statements such as -----BEGIN CERTIFICATE-----
47
+ *
48
+ * https://www.ssl.com/guide/pem-der-crt-and-cer-x-509-encodings-and-conversions/#:~:text=DER%20(Distinguished%20Encoding%20Rules)%20is,commonly%20seen%20in%20Java%20contexts.
49
+ */
50
+ function pemToDer(pem) {
51
+ const base64 = pem.split('\n').slice(1, -2).join('').trim();
52
+ return Buffer.from(base64, 'base64');
53
+ }
54
+ function publicKeyFromDer(bytes) {
55
+ // DER is a subset of BER (Basic Encoding Rules)
56
+ const { result } = asn1.fromBER(bytes);
57
+ const values = result.valueBlock.value;
58
+ if (values.length < 2) {
59
+ throw new Error('Cannot get public key from ASN.1: invalid sequence');
60
+ }
61
+ const value = values[1];
62
+ return (0, viem_1.toHex)(value.valueBlock.valueHexView);
63
+ }
64
+ async function signWithKms(kmsClient, hsmKeyVersion, hash) {
65
+ const [signResponse] = await kmsClient.asymmetricSign({
66
+ name: hsmKeyVersion,
67
+ digest: {
68
+ sha256: hash,
69
+ },
70
+ });
71
+ // Return normalized signature
72
+ // > All transaction signatures whose s-value is greater than secp256k1n/2 are now considered invalid.
73
+ // See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-2.md
74
+ return secp256k1_1.secp256k1.Signature.fromDER(signResponse.signature).normalizeS();
75
+ }
76
+ /**
77
+ * Attempts each recovery key to find a match
78
+ */
79
+ async function getRecoveredSignature(signature, publicKey, hash) {
80
+ for (let i = 0; i < 4; i++) {
81
+ const recoveredSig = signature.addRecoveryBit(i);
82
+ const compressed = publicKey.length < UNCOMPRESSED_PUBLIC_KEY_HEX_LENGTH;
83
+ const recoveredPublicKey = `0x${recoveredSig.recoverPublicKey(hash).toHex(compressed)}`;
84
+ if (publicKey === recoveredPublicKey) {
85
+ return recoveredSig;
86
+ }
87
+ }
88
+ throw new Error('Unable to generate recovery key from signature.');
89
+ }
90
+ async function sign(kmsClient, hsmKeyVersion, publicKey, msgHash) {
91
+ const hash = (0, viem_1.hexToBytes)(msgHash);
92
+ const signature = await signWithKms(kmsClient, hsmKeyVersion, hash);
93
+ const { r, s, recovery } = await getRecoveredSignature(signature, publicKey, hash);
94
+ return {
95
+ r: (0, viem_1.toHex)(r),
96
+ s: (0, viem_1.toHex)(s),
97
+ v: BigInt(recovery) + 27n,
98
+ yParity: recovery,
99
+ };
100
+ }
101
+ async function gcpHsmToAccount({ hsmKeyVersion, kmsClient: kmsClient_, }) {
102
+ const kmsClient = kmsClient_ ?? new kms_1.KeyManagementServiceClient();
103
+ const publicKey = await getPublicKey(kmsClient, hsmKeyVersion);
104
+ const address = (0, accounts_1.publicKeyToAddress)(publicKey);
105
+ const account = (0, accounts_1.toAccount)({
106
+ address,
107
+ async signMessage({ message }) {
108
+ const signature = await sign(kmsClient, hsmKeyVersion, publicKey, (0, viem_1.hashMessage)(message));
109
+ return (0, viem_1.signatureToHex)(signature);
110
+ },
111
+ async signTransaction(transaction, { serializer = viem_1.serializeTransaction } = {}) {
112
+ // Copied from https://github.com/wevm/viem/blob/e6c47807f32d14ded53c40831177ee80c5a47a10/src/accounts/utils/signTransaction.ts
113
+ // TODO: would be nice for this to be done before in viem
114
+ // so custom Account implementations don't have to worry about it
115
+ const signableTransaction = (() => {
116
+ // For EIP-4844 Transactions, we want to sign the transaction payload body (tx_payload_body) without the sidecars (ie. without the network wrapper).
117
+ // See: https://github.com/ethereum/EIPs/blob/e00f4daa66bd56e2dbd5f1d36d09fd613811a48b/EIPS/eip-4844.md#networking
118
+ if (transaction.type === 'eip4844')
119
+ return {
120
+ ...transaction,
121
+ sidecars: false,
122
+ };
123
+ return transaction;
124
+ })();
125
+ const hash = (0, viem_1.keccak256)(serializer(signableTransaction));
126
+ const signature = await sign(kmsClient, hsmKeyVersion, publicKey, hash);
127
+ return serializer(transaction, signature);
128
+ },
129
+ async signTypedData(typedData) {
130
+ const signature = await sign(kmsClient, hsmKeyVersion, publicKey, (0, viem_1.hashTypedData)(typedData));
131
+ return (0, viem_1.signatureToHex)(signature);
132
+ },
133
+ });
134
+ return {
135
+ ...account,
136
+ publicKey,
137
+ source: 'gcpHsm',
138
+ };
139
+ }
140
+ exports.gcpHsmToAccount = gcpHsmToAccount;
141
+ //# sourceMappingURL=gcpHsmToAccount.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gcpHsmToAccount.js","sourceRoot":"","sources":["../src/gcpHsm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A;YACpB,CAAC,CAAC,EAAE,CAAA;YAEJ,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,UAAU,CAAC,mBAAmB,CAAC,CAAC,CAAA;YACvD,MAAM,SAAS,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,aAAa,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;YAEvE,OAAO,UAAU,CAAC,WAAW,EAAE,SAAS,CAAC,CAAA;QAC3C,CAAC;QACD,KAAK,CAAC,aAAa,CAAC,SAAS;YAC3B,MAAM,SAAS,GAAG,MAAM,IAAI,CAC1B,SAAS,EACT,aAAa,EACb,SAAS,EACT,IAAA,oBAAa,EAAC,SAAS,CAAC,CACzB,CAAA;YACD,OAAO,IAAA,qBAAc,EAAC,SAAS,CAAC,CAAA;QAClC,CAAC;KACF,CAAC,CAAA;IAEF,OAAO;QACL,GAAG,OAAO;QACV,SAAS;QACT,MAAM,EAAE,QAAQ;KACjB,CAAA;AACH,CAAC;AA7DD,0CA6DC"}
package/package.json ADDED
@@ -0,0 +1,80 @@
1
+ {
2
+ "name": "@valora/viem-account-hsm-gcp",
3
+ "version": "1.0.0",
4
+ "main": "dist/gcpHsmToAccount.js",
5
+ "typings": "dist/gcpHsmToAccount.d.ts",
6
+ "repository": "https://github.com/valora-inc/viem-account-hsm-gcp",
7
+ "author": "Valora Inc",
8
+ "license": "Apache-2.0",
9
+ "engines": {
10
+ "node": "^20"
11
+ },
12
+ "files": [
13
+ "dist"
14
+ ],
15
+ "keywords": [
16
+ "viem",
17
+ "hsm",
18
+ "evm",
19
+ "blockchain",
20
+ "signing",
21
+ "cloud",
22
+ "google cloud",
23
+ "google kms"
24
+ ],
25
+ "scripts": {
26
+ "build": "tsc",
27
+ "build:scripts": "tsc --project scripts/tsconfig.json",
28
+ "typecheck": "yarn build && yarn build:scripts",
29
+ "lint": "eslint --ext=.tsx,.ts,.json src/ scripts/",
30
+ "lint:fix": "yarn lint --fix",
31
+ "format": "prettier --log-level error --write .",
32
+ "format:check": "prettier --check .",
33
+ "test": "jest",
34
+ "test:watch": "yarn test --watch",
35
+ "test:ci": "yarn test --ci --coverage",
36
+ "supercheck": "yarn format && yarn lint:fix && yarn typecheck && yarn knip && yarn test",
37
+ "send": "ts-node ./scripts/send.ts",
38
+ "knip": "knip",
39
+ "release": "semantic-release"
40
+ },
41
+ "peerDependencies": {
42
+ "viem": "^2.9.20"
43
+ },
44
+ "dependencies": {
45
+ "@google-cloud/kms": "^4.2.0",
46
+ "@noble/curves": "^1.4.0",
47
+ "asn1js": "^3.0.5"
48
+ },
49
+ "devDependencies": {
50
+ "@types/jest": "^29.5.12",
51
+ "@typescript-eslint/eslint-plugin": "^7.3.1",
52
+ "@valora/eslint-config-typescript": "^1.0.2",
53
+ "@valora/prettier-config": "^0.0.1",
54
+ "conventional-changelog-conventionalcommits": "^7.0.2",
55
+ "eslint": "^8.57.0",
56
+ "eslint-plugin-import": "^2.29.1",
57
+ "eslint-plugin-jest": "^27.9.0",
58
+ "eslint-plugin-react": "^7.34.1",
59
+ "eslint-plugin-react-hooks": "^4.6.0",
60
+ "eslint-plugin-react-native": "^4.1.0",
61
+ "jest": "^29.7.0",
62
+ "knip": "^5.2.2",
63
+ "prettier": "^3.2.5",
64
+ "semantic-release": "^23.0.8",
65
+ "ts-jest": "^29.1.2",
66
+ "ts-node": "^10.9.2",
67
+ "typescript": "^5.4.4",
68
+ "viem": "^2.9.20"
69
+ },
70
+ "prettier": "@valora/prettier-config",
71
+ "release": {
72
+ "branches": [
73
+ "main"
74
+ ],
75
+ "preset": "conventionalcommits"
76
+ },
77
+ "publishConfig": {
78
+ "access": "public"
79
+ }
80
+ }