@0xkey-io/eip-1193-provider 0.1.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/CHANGELOG.md +5 -0
- package/LICENSE +201 -0
- package/README.md +133 -0
- package/dist/0xkey.d.ts +34 -0
- package/dist/0xkey.d.ts.map +1 -0
- package/dist/0xkey.js +112 -0
- package/dist/0xkey.js.map +1 -0
- package/dist/0xkey.mjs +107 -0
- package/dist/0xkey.mjs.map +1 -0
- package/dist/constants.d.ts +20 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +25 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +21 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/errors.d.ts +33 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +90 -0
- package/dist/errors.js.map +1 -0
- package/dist/errors.mjs +80 -0
- package/dist/errors.mjs.map +1 -0
- package/dist/index.d.ts +476 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +271 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +269 -0
- package/dist/index.mjs.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/utils.d.ts +18 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +110 -0
- package/dist/utils.js.map +1 -0
- package/dist/utils.mjs +105 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +6 -0
- package/dist/version.js.map +1 -0
- package/dist/version.mjs +4 -0
- package/dist/version.mjs.map +1 -0
- package/package.json +63 -0
package/CHANGELOG.md
ADDED
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 2026 0xkey
|
|
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,133 @@
|
|
|
1
|
+
# ZeroXKey EIP-1193 Provider
|
|
2
|
+
|
|
3
|
+
The `@0xkey-io/eip-1193-provider` package delivers a ZeroXKey-compatible Ethereum provider that adheres to the EIP-1193 standards. It's built to integrate seamlessly with a broad spectrum of EVM-compatible chains, offering capabilities like account management, transaction signing, and blockchain interaction. This initial setup is intended for use in conjunction with the [`@0xkey-io/http`](https://www.npmjs.com/package/@0xkey-io/http) and [`@0xkey-io/webauthn-stamper`](https://www.npmjs.com/package/@0xkey-io/webauthn-stamper) package, for initial authentication.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Before you start using the ZeroXKey EIP-1193 Provider, make sure to install the necessary packages in your project. This guide assumes you have a Node.js environment ready for development.
|
|
8
|
+
|
|
9
|
+
Install the required packages using NPM or Yarn:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @0xkey-io/eip-1193-provider @0xkey-io/http @0xkey-io/webauthn-stamper
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @0xkey-io/eip-1193-provider @0xkey-io/http @0xkey-io/webauthn-stamper
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
yarn add @0xkey-io/eip-1193-provider @0xkey-io/http @0xkey-io/webauthn-stamper
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## Initialization
|
|
24
|
+
|
|
25
|
+
To set up the ZeroXKey EIP-1193 Provider, you need to initialize it with your configuration, which includes setting up the ZeroXKey client with your base URL and stamper.
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
import { WebauthnStamper } from "@0xkey-io/webauthn-stamper";
|
|
29
|
+
import { ZeroXKeyClient } from "@0xkey-io/http";
|
|
30
|
+
|
|
31
|
+
const stamper = new WebauthnStamper({
|
|
32
|
+
rpId: "example.com",
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Initialize the ZeroXKey HTTP client
|
|
36
|
+
const zeroXKeyClient = new ZeroXKeyClient(
|
|
37
|
+
{ baseUrl: "https://api.0xkey.com" },
|
|
38
|
+
stamper,
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// Get the organizationId of the sub-organization connected to the users account
|
|
42
|
+
const { organizationId } = await zeroXKeyClient.getWhoami({
|
|
43
|
+
organizationId: process.env.ORGANIZATION_ID,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
// Get the user wallets associated with their sub-organization
|
|
47
|
+
const { wallets } = await zeroXKeyClient.getWallets({
|
|
48
|
+
organizationId,
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
// Get the walletId to connect to the provider
|
|
52
|
+
const walletId = wallets[0].walletId;
|
|
53
|
+
|
|
54
|
+
const chain = {
|
|
55
|
+
chainName: "Ethereum Mainnet",
|
|
56
|
+
chainId: "0x1",
|
|
57
|
+
rpcUrls: ["https://mainnet.infura.io/v3/your-infura-project-id"],
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
// Initialize the EIP-1193 Provider with your configuration
|
|
61
|
+
const provider = await createEIP1193Provider({
|
|
62
|
+
walletId,
|
|
63
|
+
organizationId,
|
|
64
|
+
zeroXKeyClient,
|
|
65
|
+
chains: [
|
|
66
|
+
chain,
|
|
67
|
+
// Add more chains as needed
|
|
68
|
+
],
|
|
69
|
+
});
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## Usage
|
|
73
|
+
|
|
74
|
+
### `eth_requestAccounts`
|
|
75
|
+
|
|
76
|
+
Requests the user to provide an Ethereum address for identification, as specified by [EIP-1102](https://eips.ethereum.org/EIPS/eip-1102). This method initiates connectivity with the client and will prompt for passkey authentication.
|
|
77
|
+
|
|
78
|
+
```javascript
|
|
79
|
+
const accounts = await provider.request({ method: "eth_requestAccounts" });
|
|
80
|
+
// Logs the array accounts associated with the provided walletId & organization
|
|
81
|
+
console.log(accounts);
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### Authentication Prompt Methods
|
|
85
|
+
|
|
86
|
+
The following methods also prompt for passkey authentication:
|
|
87
|
+
|
|
88
|
+
- `personal_sign`: Signs a message with the specified account.
|
|
89
|
+
- `eth_sign`: Signs data with the specified account.
|
|
90
|
+
- `eth_signTransaction`: Signs a transaction with the specified account.
|
|
91
|
+
- `eth_signTypedData_v4`: Signs typed data according to EIP-712 with the specified account.
|
|
92
|
+
- `eth_sendTransaction`: Submits a transaction to the network for execution.
|
|
93
|
+
|
|
94
|
+
## Testing (Local)
|
|
95
|
+
|
|
96
|
+
1. Copy `.env.example` to `.env`
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
$ cp .env.example .env
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2. Start the Anvil node in one shell:
|
|
103
|
+
- Install [Foundry](https://book.getfoundry.sh/getting-started/installation) & Anvil if you haven't done so already
|
|
104
|
+
- Add Foundry to your `$PATH`
|
|
105
|
+
```bash
|
|
106
|
+
$ export PATH="$PATH:$HOME/.foundry/bin"
|
|
107
|
+
```
|
|
108
|
+
- Source your env e.g.
|
|
109
|
+
```bash
|
|
110
|
+
$ source ~/.zshrc
|
|
111
|
+
```
|
|
112
|
+
- Run `foundryup` to install `Anvil`
|
|
113
|
+
```bash
|
|
114
|
+
$ foundryup
|
|
115
|
+
```
|
|
116
|
+
- Start Anvil
|
|
117
|
+
```
|
|
118
|
+
$ pnpm anvil
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
3. Run the tests in a new shell:
|
|
122
|
+
|
|
123
|
+
```
|
|
124
|
+
$ pnpm test
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Contributing
|
|
128
|
+
|
|
129
|
+
We welcome contributions to improve the `ZeroXKey EIP-1193 Provider`. Please follow the project's [contribution guidelines](https://github.com/0xkey-io/sdk-js/blob/ad9071716919d062ba67fd623a01cbd4523ed444/CONTRIBUTING.md).
|
|
130
|
+
|
|
131
|
+
## License
|
|
132
|
+
|
|
133
|
+
This project is licensed under [LICENSE](./LICENSE), with detailed information available in the repository.
|
package/dist/0xkey.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ZeroXKeyClient } from "@0xkey-io/http";
|
|
2
|
+
import type { ZeroXKeyBrowserClient } from "@0xkey-io/sdk-browser";
|
|
3
|
+
import type { definitions } from "@0xkey-io/http/src/__generated__/services/coordinator/public/v1/public_api.types";
|
|
4
|
+
import type { ZeroXKeySDKClientBase } from "@0xkey-io/core";
|
|
5
|
+
export declare function unwrapActivityResult<T extends definitions["v1ActivityResponse"]>(activityResponse: T, { errorMessage }: {
|
|
6
|
+
errorMessage: string;
|
|
7
|
+
}): T["activity"]["result"];
|
|
8
|
+
export declare function signMessage({ client, message, organizationId, signWith, }: {
|
|
9
|
+
client: ZeroXKeyClient | ZeroXKeyBrowserClient | ZeroXKeySDKClientBase;
|
|
10
|
+
message: `0x${string}`;
|
|
11
|
+
organizationId: string;
|
|
12
|
+
signWith: string;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
export declare function signTransaction({ client, unsignedTransaction, organizationId, signWith, }: {
|
|
15
|
+
client: ZeroXKeyClient | ZeroXKeyBrowserClient | ZeroXKeySDKClientBase;
|
|
16
|
+
unsignedTransaction: string;
|
|
17
|
+
organizationId: string;
|
|
18
|
+
signWith: string;
|
|
19
|
+
}): Promise<string>;
|
|
20
|
+
/**
|
|
21
|
+
* Checks if the error code corresponds to a disconnected state.
|
|
22
|
+
*
|
|
23
|
+
* Determines if provided error code is one of the known
|
|
24
|
+
* error codes that signify a disconnected state, specifically if the wallet
|
|
25
|
+
* or organization was not found.
|
|
26
|
+
*
|
|
27
|
+
* @param {Object} error - The error object containing the error code.
|
|
28
|
+
* @param {number} error.code - The error code to check against known disconnected state codes.
|
|
29
|
+
* @returns {boolean} - Returns true if the error code is for a disconnected state, otherwise false.
|
|
30
|
+
*/
|
|
31
|
+
export declare const zeroXKeyIsDisconnected: (error: {
|
|
32
|
+
code: number;
|
|
33
|
+
}) => boolean;
|
|
34
|
+
//# sourceMappingURL=0xkey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0xkey.d.ts","sourceRoot":"","sources":["../src/0xkey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAgB,MAAM,gBAAgB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAKnE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kFAAkF,CAAC;AAMpH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,wBAAgB,oBAAoB,CAClC,CAAC,SAAS,WAAW,CAAC,oBAAoB,CAAC,EAE3C,gBAAgB,EAAE,CAAC,EACnB,EAAE,YAAY,EAAE,EAAE;IAAE,YAAY,EAAE,MAAM,CAAA;CAAE,GACzC,CAAC,CAAC,UAAU,CAAC,CAAC,QAAQ,CAAC,CAkBzB;AAED,wBAAsB,WAAW,CAAC,EAChC,MAAM,EACN,OAAO,EACP,cAAc,EACd,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,cAAc,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;IACvE,OAAO,EAAE,KAAK,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CA0ClB;AAED,wBAAsB,eAAe,CAAC,EACpC,MAAM,EACN,mBAAmB,EACnB,cAAc,EACd,QAAQ,GACT,EAAE;IACD,MAAM,EAAE,cAAc,GAAG,qBAAqB,GAAG,qBAAqB,CAAC;IACvE,mBAAmB,EAAE,MAAM,CAAC;IAC5B,cAAc,EAAE,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAAC,MAAM,CAAC,CAoClB;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,sBAAsB,UAAW;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,YAI7D,CAAC"}
|
package/dist/0xkey.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var http = require('@0xkey-io/http');
|
|
4
|
+
var viem = require('viem');
|
|
5
|
+
var utils = require('viem/utils');
|
|
6
|
+
var constants = require('./constants.js');
|
|
7
|
+
|
|
8
|
+
function unwrapActivityResult(activityResponse, { errorMessage }) {
|
|
9
|
+
const { activity } = activityResponse;
|
|
10
|
+
switch (activity.status) {
|
|
11
|
+
case "ACTIVITY_STATUS_CONSENSUS_NEEDED": {
|
|
12
|
+
throw "Consensus needed";
|
|
13
|
+
}
|
|
14
|
+
case "ACTIVITY_STATUS_COMPLETED": {
|
|
15
|
+
const result = activity.result;
|
|
16
|
+
if (result === undefined) {
|
|
17
|
+
throw "Activity result is undefined";
|
|
18
|
+
}
|
|
19
|
+
return result;
|
|
20
|
+
}
|
|
21
|
+
default: {
|
|
22
|
+
throw errorMessage;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async function signMessage({ client, message, organizationId, signWith, }) {
|
|
27
|
+
let activityResponse;
|
|
28
|
+
if (http.isHttpClient(client)) {
|
|
29
|
+
activityResponse = await client.signRawPayload({
|
|
30
|
+
type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
|
|
31
|
+
organizationId,
|
|
32
|
+
parameters: {
|
|
33
|
+
signWith,
|
|
34
|
+
payload: utils.pad(message),
|
|
35
|
+
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
|
|
36
|
+
hashFunction: "HASH_FUNCTION_NO_OP",
|
|
37
|
+
},
|
|
38
|
+
timestampMs: String(Date.now()), // millisecond timestamp
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
activityResponse = await client.signRawPayload({
|
|
43
|
+
signWith,
|
|
44
|
+
payload: message,
|
|
45
|
+
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
|
|
46
|
+
hashFunction: "HASH_FUNCTION_NO_OP",
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
const { signRawPayloadResult: signature } = unwrapActivityResult(activityResponse /* Type casting is ok here. The invalid types are both actually strings. TS is too strict here! */, {
|
|
50
|
+
errorMessage: "Error signing message",
|
|
51
|
+
});
|
|
52
|
+
if (!signature) {
|
|
53
|
+
// @todo update error message
|
|
54
|
+
throw "Error signing message";
|
|
55
|
+
}
|
|
56
|
+
return viem.signatureToHex({
|
|
57
|
+
r: `0x${signature.r}`,
|
|
58
|
+
s: `0x${signature.s}`,
|
|
59
|
+
v: BigInt(signature.v) + 27n,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
async function signTransaction({ client, unsignedTransaction, organizationId, signWith, }) {
|
|
63
|
+
let activityResponse;
|
|
64
|
+
if (http.isHttpClient(client)) {
|
|
65
|
+
activityResponse = await client.signTransaction({
|
|
66
|
+
type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2",
|
|
67
|
+
organizationId: organizationId,
|
|
68
|
+
parameters: {
|
|
69
|
+
signWith,
|
|
70
|
+
type: "TRANSACTION_TYPE_ETHEREUM",
|
|
71
|
+
unsignedTransaction: unsignedTransaction,
|
|
72
|
+
},
|
|
73
|
+
timestampMs: String(Date.now()), // millisecond timestamp
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
activityResponse = await client.signTransaction({
|
|
78
|
+
signWith,
|
|
79
|
+
type: "TRANSACTION_TYPE_ETHEREUM",
|
|
80
|
+
unsignedTransaction: unsignedTransaction,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const { signTransactionResult } = unwrapActivityResult(activityResponse /* Type casting is ok here. The invalid types are both actually strings. TS is too strict here! */, {
|
|
84
|
+
errorMessage: "Error signing transaction",
|
|
85
|
+
});
|
|
86
|
+
if (!signTransactionResult) {
|
|
87
|
+
// @todo update error handling (e.g. consensus)
|
|
88
|
+
throw "Error signing transaction";
|
|
89
|
+
}
|
|
90
|
+
return signTransactionResult.signedTransaction;
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Checks if the error code corresponds to a disconnected state.
|
|
94
|
+
*
|
|
95
|
+
* Determines if provided error code is one of the known
|
|
96
|
+
* error codes that signify a disconnected state, specifically if the wallet
|
|
97
|
+
* or organization was not found.
|
|
98
|
+
*
|
|
99
|
+
* @param {Object} error - The error object containing the error code.
|
|
100
|
+
* @param {number} error.code - The error code to check against known disconnected state codes.
|
|
101
|
+
* @returns {boolean} - Returns true if the error code is for a disconnected state, otherwise false.
|
|
102
|
+
*/
|
|
103
|
+
const zeroXKeyIsDisconnected = (error) => {
|
|
104
|
+
const { WALLET_NOT_FOUND, ORG_NOT_FOUND } = constants.ZEROXKEY_ERROR_CODE;
|
|
105
|
+
return [WALLET_NOT_FOUND, ORG_NOT_FOUND].includes(error.code);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
exports.signMessage = signMessage;
|
|
109
|
+
exports.signTransaction = signTransaction;
|
|
110
|
+
exports.unwrapActivityResult = unwrapActivityResult;
|
|
111
|
+
exports.zeroXKeyIsDisconnected = zeroXKeyIsDisconnected;
|
|
112
|
+
//# sourceMappingURL=0xkey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0xkey.js","sources":["../src/0xkey.ts"],"sourcesContent":[null],"names":["isHttpClient","pad","signatureToHex","ZEROXKEY_ERROR_CODE"],"mappings":";;;;;;;SAcgB,oBAAoB,CAGlC,gBAAmB,EACnB,EAAE,YAAY,EAA4B,EAAA;AAE1C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,gBAAgB;AAErC,IAAA,QAAQ,QAAQ,CAAC,MAAM;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B;AAE/D,IAAA,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC;AAC/D;;;;;;;"}
|
package/dist/0xkey.mjs
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { isHttpClient } from '@0xkey-io/http';
|
|
2
|
+
import { signatureToHex } from 'viem';
|
|
3
|
+
import { pad } from 'viem/utils';
|
|
4
|
+
import { ZEROXKEY_ERROR_CODE } from './constants.mjs';
|
|
5
|
+
|
|
6
|
+
function unwrapActivityResult(activityResponse, { errorMessage }) {
|
|
7
|
+
const { activity } = activityResponse;
|
|
8
|
+
switch (activity.status) {
|
|
9
|
+
case "ACTIVITY_STATUS_CONSENSUS_NEEDED": {
|
|
10
|
+
throw "Consensus needed";
|
|
11
|
+
}
|
|
12
|
+
case "ACTIVITY_STATUS_COMPLETED": {
|
|
13
|
+
const result = activity.result;
|
|
14
|
+
if (result === undefined) {
|
|
15
|
+
throw "Activity result is undefined";
|
|
16
|
+
}
|
|
17
|
+
return result;
|
|
18
|
+
}
|
|
19
|
+
default: {
|
|
20
|
+
throw errorMessage;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async function signMessage({ client, message, organizationId, signWith, }) {
|
|
25
|
+
let activityResponse;
|
|
26
|
+
if (isHttpClient(client)) {
|
|
27
|
+
activityResponse = await client.signRawPayload({
|
|
28
|
+
type: "ACTIVITY_TYPE_SIGN_RAW_PAYLOAD_V2",
|
|
29
|
+
organizationId,
|
|
30
|
+
parameters: {
|
|
31
|
+
signWith,
|
|
32
|
+
payload: pad(message),
|
|
33
|
+
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
|
|
34
|
+
hashFunction: "HASH_FUNCTION_NO_OP",
|
|
35
|
+
},
|
|
36
|
+
timestampMs: String(Date.now()), // millisecond timestamp
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
activityResponse = await client.signRawPayload({
|
|
41
|
+
signWith,
|
|
42
|
+
payload: message,
|
|
43
|
+
encoding: "PAYLOAD_ENCODING_HEXADECIMAL",
|
|
44
|
+
hashFunction: "HASH_FUNCTION_NO_OP",
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
const { signRawPayloadResult: signature } = unwrapActivityResult(activityResponse /* Type casting is ok here. The invalid types are both actually strings. TS is too strict here! */, {
|
|
48
|
+
errorMessage: "Error signing message",
|
|
49
|
+
});
|
|
50
|
+
if (!signature) {
|
|
51
|
+
// @todo update error message
|
|
52
|
+
throw "Error signing message";
|
|
53
|
+
}
|
|
54
|
+
return signatureToHex({
|
|
55
|
+
r: `0x${signature.r}`,
|
|
56
|
+
s: `0x${signature.s}`,
|
|
57
|
+
v: BigInt(signature.v) + 27n,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
async function signTransaction({ client, unsignedTransaction, organizationId, signWith, }) {
|
|
61
|
+
let activityResponse;
|
|
62
|
+
if (isHttpClient(client)) {
|
|
63
|
+
activityResponse = await client.signTransaction({
|
|
64
|
+
type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2",
|
|
65
|
+
organizationId: organizationId,
|
|
66
|
+
parameters: {
|
|
67
|
+
signWith,
|
|
68
|
+
type: "TRANSACTION_TYPE_ETHEREUM",
|
|
69
|
+
unsignedTransaction: unsignedTransaction,
|
|
70
|
+
},
|
|
71
|
+
timestampMs: String(Date.now()), // millisecond timestamp
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
activityResponse = await client.signTransaction({
|
|
76
|
+
signWith,
|
|
77
|
+
type: "TRANSACTION_TYPE_ETHEREUM",
|
|
78
|
+
unsignedTransaction: unsignedTransaction,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
const { signTransactionResult } = unwrapActivityResult(activityResponse /* Type casting is ok here. The invalid types are both actually strings. TS is too strict here! */, {
|
|
82
|
+
errorMessage: "Error signing transaction",
|
|
83
|
+
});
|
|
84
|
+
if (!signTransactionResult) {
|
|
85
|
+
// @todo update error handling (e.g. consensus)
|
|
86
|
+
throw "Error signing transaction";
|
|
87
|
+
}
|
|
88
|
+
return signTransactionResult.signedTransaction;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Checks if the error code corresponds to a disconnected state.
|
|
92
|
+
*
|
|
93
|
+
* Determines if provided error code is one of the known
|
|
94
|
+
* error codes that signify a disconnected state, specifically if the wallet
|
|
95
|
+
* or organization was not found.
|
|
96
|
+
*
|
|
97
|
+
* @param {Object} error - The error object containing the error code.
|
|
98
|
+
* @param {number} error.code - The error code to check against known disconnected state codes.
|
|
99
|
+
* @returns {boolean} - Returns true if the error code is for a disconnected state, otherwise false.
|
|
100
|
+
*/
|
|
101
|
+
const zeroXKeyIsDisconnected = (error) => {
|
|
102
|
+
const { WALLET_NOT_FOUND, ORG_NOT_FOUND } = ZEROXKEY_ERROR_CODE;
|
|
103
|
+
return [WALLET_NOT_FOUND, ORG_NOT_FOUND].includes(error.code);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export { signMessage, signTransaction, unwrapActivityResult, zeroXKeyIsDisconnected };
|
|
107
|
+
//# sourceMappingURL=0xkey.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"0xkey.mjs","sources":["../src/0xkey.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;SAcgB,oBAAoB,CAGlC,gBAAmB,EACnB,EAAE,YAAY,EAA4B,EAAA;AAE1C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,gBAAgB;AAErC,IAAA,QAAQ,QAAQ,CAAC,MAAM;QACrB,KAAK,kCAAkC,EAAE;AACvC,YAAA,MAAM,kBAAkB;QAC1B;QACA,KAAK,2BAA2B,EAAE;AAChC,YAAA,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM;AAC9B,YAAA,IAAI,MAAM,KAAK,SAAS,EAAE;AACxB,gBAAA,MAAM,8BAA8B;Y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
|
3
|
+
INVALID_CHAIN_ID_HEX: string;
|
|
4
|
+
INVALID_CHAIN_ID_VALUE: string;
|
|
5
|
+
NATIVE_CURRENCY_SYMBOL_LENGTH: string;
|
|
6
|
+
NATIVE_CURRENCY_SYMBOL_MISMATCH: string;
|
|
7
|
+
INVALID_RPC_URL: string;
|
|
8
|
+
UNRECOGNIZED_CHAIN_ID: string;
|
|
9
|
+
CHAIN_ID_RPC_MISMATCH: string;
|
|
10
|
+
PROVIDER_DISCONNECTED: string;
|
|
11
|
+
RPC_URLS_REQUIRED: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const PROVIDER_ERROR_CODE: {
|
|
14
|
+
ADD_ETHEREUM_CHAIN: number;
|
|
15
|
+
};
|
|
16
|
+
export declare const ZEROXKEY_ERROR_CODE: {
|
|
17
|
+
WALLET_NOT_FOUND: number;
|
|
18
|
+
ORG_NOT_FOUND: number;
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB;;;;;;;;;;;CAmBlC,CAAC;AAEF,eAAO,MAAM,mBAAmB;;CAE/B,CAAC;AAEF,eAAO,MAAM,mBAAmB;;;CAG/B,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PROVIDER_ERROR_MESSAGE = {
|
|
4
|
+
BLOCK_EXPLORER_URL: "Expected null or array with at least one valid string HTTPS URL 'blockExplorerUrl'. Received: ",
|
|
5
|
+
INVALID_CHAIN_ID_HEX: "Expected 0x-prefixed, unpadded, non-zero hexadecimal string 'chainId'. Received: ",
|
|
6
|
+
INVALID_CHAIN_ID_VALUE: "Expected numerical value greater than max safe value. Received: ",
|
|
7
|
+
NATIVE_CURRENCY_SYMBOL_LENGTH: "Expected 2-6 character string 'nativeCurrency.symbol'. Received: ",
|
|
8
|
+
NATIVE_CURRENCY_SYMBOL_MISMATCH: "nativeCurrency.symbol does not match currency symbol for a network the user already has added with the same chainId. Received: ",
|
|
9
|
+
INVALID_RPC_URL: "rpcUrls field is required and must contain at least one valid HTTP/HTTPS URL",
|
|
10
|
+
UNRECOGNIZED_CHAIN_ID: "Unrecognized chain ID. Try adding the chain using wallet_addEthereumChain first. Received: ",
|
|
11
|
+
CHAIN_ID_RPC_MISMATCH: "Chain ID does not match the RPC endpoint. Provider Chain ID: ",
|
|
12
|
+
RPC_URLS_REQUIRED: "rpcUrls field is required and cannot be empty",
|
|
13
|
+
};
|
|
14
|
+
const PROVIDER_ERROR_CODE = {
|
|
15
|
+
ADD_ETHEREUM_CHAIN: -32602,
|
|
16
|
+
};
|
|
17
|
+
const ZEROXKEY_ERROR_CODE = {
|
|
18
|
+
WALLET_NOT_FOUND: 5,
|
|
19
|
+
ORG_NOT_FOUND: 3,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
exports.PROVIDER_ERROR_CODE = PROVIDER_ERROR_CODE;
|
|
23
|
+
exports.PROVIDER_ERROR_MESSAGE = PROVIDER_ERROR_MESSAGE;
|
|
24
|
+
exports.ZEROXKEY_ERROR_CODE = ZEROXKEY_ERROR_CODE;
|
|
25
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../src/constants.ts"],"sourcesContent":[null],"names":[],"mappings":";;AAAO,MAAM,sBAAsB,GAAG;AACpC,IAAA,kBAAkB,EAChB,gGAAgG;AAClG,IAAA,oBAAoB,EAClB,mFAAmF;AACrF,IAAA,sBAAsB,EACpB,kEAAkE;AACpE,IAAA,6BAA6B,EAC3B,mEAAmE;AACrE,IAAA,+BAA+B,EAC7B,iIAAiI;AACnI,IAAA,eAAe,EACb,8EAA8E;AAChF,IAAA,qBAAqB,EACnB,6FAA6F;AAC/F,IAAA,qBAAqB,EACnB,+DAA+D;AACjE,IACA,iBAAiB,EAAE,+CAA+C;;AAG7D,MAAM,mBAAmB,GAAG;IACjC,kBAAkB,EAAE,MAAM;;AAGrB,MAAM,mBAAmB,GAAG;AACjC,IAAA,gBAAgB,EAAE,CAAC;AACnB,IAAA,aAAa,EAAE,CAAC;;;;;;;"}
|