@tesser-payments/sdk-ts 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/README.md +205 -0
- package/dist/client.d.ts +32 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +184 -0
- package/dist/internal/errors.d.ts +65 -0
- package/dist/internal/http.d.ts +23 -0
- package/dist/internal/logger.d.ts +3 -0
- package/dist/internal/types.d.ts +52 -0
- package/dist/signer.d.ts +34 -0
- package/dist/signing/create-wallet.d.ts +2 -0
- package/dist/signing/network-type.d.ts +11 -0
- package/dist/signing/sign-step.d.ts +2 -0
- package/dist/signing/stamp.d.ts +11 -0
- package/package.json +41 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
# @tesser-payments/sdk-ts
|
|
2
|
+
|
|
3
|
+
Signer-only TypeScript SDK for Tesser API: locally stamp `signCreateWallet` and
|
|
4
|
+
`signStep` activities using Turnkey API keys. The SDK does not own HTTP or
|
|
5
|
+
OAuth — Tesser API supplies the unsigned transaction; this library only stamps
|
|
6
|
+
it. Bring your own client.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```sh
|
|
11
|
+
bun add @tesser-payments/sdk-ts @turnkey/api-key-stamper @tesser-payments/types
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Both `@turnkey/api-key-stamper` and `@tesser-payments/types` are peer
|
|
15
|
+
dependencies (no runtime dependencies of our own). Apache 2.0 licensed.
|
|
16
|
+
|
|
17
|
+
## Quick start
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { LocalSigner } from '@tesser-payments/sdk-ts';
|
|
21
|
+
|
|
22
|
+
const signer = new LocalSigner({
|
|
23
|
+
signing: {
|
|
24
|
+
publicKey: process.env.SIGNING_PUBLIC_KEY!, // 33-byte compressed P-256
|
|
25
|
+
privateKey: process.env.SIGNING_PRIVATE_KEY!,
|
|
26
|
+
enclaveId: process.env.SIGNING_ENCLAVE_ID!, // Turnkey suborg ID
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { signature } = await signer.signCreateWallet({
|
|
31
|
+
name: 'My new wallet',
|
|
32
|
+
type: 'stablecoin_ethereum',
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const res = await fetch(`${API_BASE_URL}/v1/accounts/wallets`, {
|
|
36
|
+
method: 'POST',
|
|
37
|
+
headers: {
|
|
38
|
+
Authorization: `Bearer ${token}`,
|
|
39
|
+
'Content-Type': 'application/json',
|
|
40
|
+
},
|
|
41
|
+
body: JSON.stringify({
|
|
42
|
+
signature,
|
|
43
|
+
name: 'My new wallet',
|
|
44
|
+
type: 'stablecoin_ethereum',
|
|
45
|
+
is_managed: true,
|
|
46
|
+
}),
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
`signature` is `base64(JSON.stringify({ body, stamp }))` — drop it into the
|
|
51
|
+
Tesser API request body as the documented `signature` field.
|
|
52
|
+
|
|
53
|
+
**Private-key handling.** `signer.signing` exposes only `{ publicKey, enclaveId }`.
|
|
54
|
+
The private key lives on the instance as an ECMA private field and is not
|
|
55
|
+
reachable via property access, `console.log`, or `JSON.stringify`. The SDK still
|
|
56
|
+
uses it internally to stamp activities — you just can't pull it back out.
|
|
57
|
+
|
|
58
|
+
## `signStep`
|
|
59
|
+
|
|
60
|
+
`signStep` stamps a Turnkey `ACTIVITY_TYPE_SIGN_TRANSACTION_V2` body for a
|
|
61
|
+
single rebalance step. Pass the unsigned transaction Tesser returned, the
|
|
62
|
+
on-chain `signWith` address, and the network — that's all the SDK needs to
|
|
63
|
+
produce a signature:
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
import { LocalSigner, type StepForSigning } from '@tesser-payments/sdk-ts';
|
|
67
|
+
|
|
68
|
+
const step: StepForSigning = {
|
|
69
|
+
unsignedTransaction: '0x02...', // hex-encoded raw tx Tesser returned
|
|
70
|
+
signWith: '0xabc...', // account.crypto_wallet_address from
|
|
71
|
+
// GET /v1/accounts/{from_account_id}
|
|
72
|
+
network: 'BASE_SEPOLIA', // BASE | BASE_SEPOLIA | ETHEREUM |
|
|
73
|
+
// POLYGON | POLYGON_AMOY | SOLANA
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const signed = await signer.signStep(step);
|
|
77
|
+
|
|
78
|
+
// POST /v1/treasury/rebalances/{rebalanceId}/steps/{stepId}/sign
|
|
79
|
+
// The IDs are yours to track — you got them from the API response or webhook;
|
|
80
|
+
// the SDK has no use for them, so they're not in `StepForSigning`.
|
|
81
|
+
await fetch(
|
|
82
|
+
`${API_BASE_URL}/v1/treasury/rebalances/${rebalanceId}/steps/${stepId}/sign`,
|
|
83
|
+
{
|
|
84
|
+
method: 'POST',
|
|
85
|
+
headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
|
|
86
|
+
body: JSON.stringify({ signature: signed.signature }),
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`signStep` returns `{ signature, metadata }`. The `signature` field is what
|
|
92
|
+
the Tesser API needs; `metadata` carries the underlying Turnkey activity body
|
|
93
|
+
and stamp header value for debugging.
|
|
94
|
+
|
|
95
|
+
The `network` field is typed as `SupportedNetwork`, derived from the SDK's
|
|
96
|
+
network-to-Turnkey-type table — so a typo like `'BASE-SEPOLIA'` (hyphen) is a
|
|
97
|
+
compile-time error. If you're pulling the value out of a webhook payload or
|
|
98
|
+
env var, cast it at that boundary.
|
|
99
|
+
|
|
100
|
+
## Error handling
|
|
101
|
+
|
|
102
|
+
The SDK mirrors Tesser's documented error envelope
|
|
103
|
+
(<https://docs.tesser.xyz/overviews/errors>) rather than inventing a custom
|
|
104
|
+
HTTP-status taxonomy. v0.0.1 only signs locally, so only the signing-side
|
|
105
|
+
errors are exported:
|
|
106
|
+
|
|
107
|
+
```
|
|
108
|
+
TesserError (base; .cause set on all)
|
|
109
|
+
├── TesserConfigError bad input at construction or call site
|
|
110
|
+
└── TesserSigningError local signing failure
|
|
111
|
+
└── StampError Turnkey ApiKeyStamper failed
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
All three carry the original failure as `.cause` and can be discriminated via
|
|
115
|
+
`instanceof` or the static `.is()` guard:
|
|
116
|
+
|
|
117
|
+
```typescript
|
|
118
|
+
import { TesserError, StampError } from '@tesser-payments/sdk-ts';
|
|
119
|
+
|
|
120
|
+
try {
|
|
121
|
+
await signer.signStep(step);
|
|
122
|
+
} catch (err) {
|
|
123
|
+
if (StampError.is(err)) {
|
|
124
|
+
// Turnkey rejected the stamp — usually a key-format problem.
|
|
125
|
+
}
|
|
126
|
+
if (TesserError.is(err)) {
|
|
127
|
+
console.error('Signing failed', { name: err.name, cause: err.cause });
|
|
128
|
+
}
|
|
129
|
+
throw err;
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
HTTP-side errors (`TesserAPIError`, `TesserConnectionError`,
|
|
134
|
+
`TesserTimeoutError`) will return when the optional bundled client lands in a
|
|
135
|
+
future version. Until then, model HTTP failures with whatever your `fetch`
|
|
136
|
+
wrapper produces.
|
|
137
|
+
|
|
138
|
+
## Setup notes
|
|
139
|
+
|
|
140
|
+
`signing.publicKey` must be the **33-byte compressed** form Turnkey uses for
|
|
141
|
+
API-key auth lookups (66 hex chars, prefix `02` or `03`). Dashboards that
|
|
142
|
+
display the 65-byte uncompressed form need to be compressed before use:
|
|
143
|
+
|
|
144
|
+
```sh
|
|
145
|
+
bunx -p @turnkey/crypto node -e \
|
|
146
|
+
'const c = require("@turnkey/crypto"); \
|
|
147
|
+
const u = process.argv[1].replace(/^0x/i,""); \
|
|
148
|
+
const b = Buffer.from(u, "hex"); \
|
|
149
|
+
console.log(Buffer.from(c.compressRawPublicKey(b)).toString("hex"))' \
|
|
150
|
+
04...your-uncompressed-key...
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
If a key is registered on Turnkey in uncompressed form, Turnkey rejects
|
|
154
|
+
auth with `PUBLIC_KEY_NOT_FOUND` even when the keypair is logically
|
|
155
|
+
correct — re-register the key in compressed form to fix.
|
|
156
|
+
|
|
157
|
+
## Examples
|
|
158
|
+
|
|
159
|
+
| Path | What it demonstrates |
|
|
160
|
+
|---|---|
|
|
161
|
+
| [`examples/create-wallet.ts`](./examples/create-wallet.ts) | OAuth → `signCreateWallet({ type: 'stablecoin_ethereum' })` → `POST /v1/accounts/wallets` with `is_managed: true`. Solana and Stellar paths are not exercised in v0.0.1. |
|
|
162
|
+
| [`examples/sign-step-polling.ts`](./examples/sign-step-polling.ts) | End-to-end rebalance signing driven by `GET /v1/treasury/rebalances/{id}` polling. |
|
|
163
|
+
| [`examples/sign-step-webhooks.ts`](./examples/sign-step-webhooks.ts) | End-to-end rebalance signing driven by Tesser `step.*` webhooks. Best-effort: webhook signature verification is **not** wired up (the algorithm isn't currently documented), so do not run this against production. |
|
|
164
|
+
| [`examples/lib/oauth.ts`](./examples/lib/oauth.ts) | Shared `client_credentials` token helper for the three scripts above. |
|
|
165
|
+
| [`examples/lib/require-env.ts`](./examples/lib/require-env.ts) | Typed env-validation helper. |
|
|
166
|
+
|
|
167
|
+
Run with `bun run examples/<name>.ts`. Bun loads `.env.local` automatically;
|
|
168
|
+
copy [`.env.example`](./.env.example) and fill in the values first.
|
|
169
|
+
|
|
170
|
+
## Out of scope
|
|
171
|
+
|
|
172
|
+
- **`TesserClient`** — the previous bundled HTTP client (`getAccountAddress`,
|
|
173
|
+
retry/timeout/logger plumbing) is intentionally not in v0.0.1. We expect to
|
|
174
|
+
re-add it later as an opt-in `LocalSignerOptions.client` field; that change
|
|
175
|
+
is purely additive and will not break v0.0.1 call sites.
|
|
176
|
+
- **Webhook signature verification** — the header name and HMAC algorithm
|
|
177
|
+
aren't currently documented in public Tesser docs.
|
|
178
|
+
- **Solana / Stellar `signCreateWallet`** — exported as `@experimental` types;
|
|
179
|
+
not verified end-to-end. Stellar is supported by Tesser only as a receive
|
|
180
|
+
(unmanaged) wallet.
|
|
181
|
+
- **Browser, edge, and React Native runtimes** — Node ≥ 20 / Bun ≥ 1.3 only.
|
|
182
|
+
|
|
183
|
+
## Development
|
|
184
|
+
|
|
185
|
+
```sh
|
|
186
|
+
bun install
|
|
187
|
+
bun run typecheck # tsc --noEmit
|
|
188
|
+
bun run lint # biome check .
|
|
189
|
+
bun run lint:fix # biome check . --write
|
|
190
|
+
bun run test # vitest run
|
|
191
|
+
bun run test:watch
|
|
192
|
+
bun run build # bun build (JS) + tsc --emitDeclarationOnly (.d.ts)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
Conventional commits. Versions are bumped manually in `package.json`;
|
|
196
|
+
`CHANGELOG.md` is hand-authored per release. Cutting a release: bump
|
|
197
|
+
the version, merge to `main`, then trigger the `Release` workflow from
|
|
198
|
+
the Actions tab (see `.github/workflows/release.yml`).
|
|
199
|
+
|
|
200
|
+
CI runs typecheck, lint, test, build on every PR (see
|
|
201
|
+
`.github/workflows/ci.yml`).
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
[Apache License 2.0](./LICENSE). See [`NOTICE`](./NOTICE).
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { LogLevel, Logger, RequestOptions, RpcUrls, SigningConfig } from './internal/types.js';
|
|
2
|
+
export interface TesserClientConfig {
|
|
3
|
+
token: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
rpcUrls?: RpcUrls;
|
|
6
|
+
signing: SigningConfig;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
fetch?: typeof fetch;
|
|
10
|
+
logger?: Logger;
|
|
11
|
+
logLevel?: LogLevel;
|
|
12
|
+
}
|
|
13
|
+
export declare class TesserClient {
|
|
14
|
+
#private;
|
|
15
|
+
readonly baseUrl: string;
|
|
16
|
+
readonly rpcUrls: ReadonlyMap<string, string>;
|
|
17
|
+
readonly signing: Readonly<SigningConfig>;
|
|
18
|
+
readonly timeout: number;
|
|
19
|
+
readonly maxRetries: number;
|
|
20
|
+
readonly fetch: typeof fetch;
|
|
21
|
+
readonly logger: Logger;
|
|
22
|
+
readonly logLevel: LogLevel;
|
|
23
|
+
constructor(config: TesserClientConfig);
|
|
24
|
+
setToken(token: string): void;
|
|
25
|
+
/**
|
|
26
|
+
* Fetches the on-chain address bound to a Tesser account ID. Used by
|
|
27
|
+
* `signStep` to resolve `from_account_id` / `to_account_id` to addresses
|
|
28
|
+
* before building the unsigned transaction; also useful as a standalone
|
|
29
|
+
* lookup for callers that need the address directly.
|
|
30
|
+
*/
|
|
31
|
+
getAccountAddress(accountId: string, opts?: RequestOptions): Promise<string>;
|
|
32
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { LocalSigner } from './signer.js';
|
|
2
|
+
export type { PublicSigningInfo } from './signer.js';
|
|
3
|
+
export type { CreateWalletParams, LocalSignerOptions, SignedResult, SignedResultMetadata, SignedStepResult, SignedStepResultMetadata, SigningConfig, StepForSigning, WalletType, } from './internal/types.js';
|
|
4
|
+
export type { SupportedNetwork } from './signing/network-type.js';
|
|
5
|
+
export { StampError, TesserConfigError, TesserError, TesserSigningError, } from './internal/errors.js';
|
|
6
|
+
export type { TesserErrorDetail } from './internal/errors.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
// src/internal/errors.ts
|
|
2
|
+
class TesserError extends Error {
|
|
3
|
+
name = "TesserError";
|
|
4
|
+
constructor(message, options) {
|
|
5
|
+
super(message);
|
|
6
|
+
if (options?.cause !== undefined) {
|
|
7
|
+
this.cause = options.cause;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
static is(err) {
|
|
11
|
+
return err instanceof TesserError;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
class TesserConfigError extends TesserError {
|
|
16
|
+
name = "TesserConfigError";
|
|
17
|
+
static is(err) {
|
|
18
|
+
return err instanceof TesserConfigError;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
class TesserSigningError extends TesserError {
|
|
22
|
+
name = "TesserSigningError";
|
|
23
|
+
static is(err) {
|
|
24
|
+
return err instanceof TesserSigningError;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
class StampError extends TesserSigningError {
|
|
29
|
+
name = "StampError";
|
|
30
|
+
static is(err) {
|
|
31
|
+
return err instanceof StampError;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// src/signing/stamp.ts
|
|
36
|
+
import { ApiKeyStamper } from "@turnkey/api-key-stamper";
|
|
37
|
+
async function stamp(keys, body) {
|
|
38
|
+
const stamper = new ApiKeyStamper({
|
|
39
|
+
apiPublicKey: keys.publicKey,
|
|
40
|
+
apiPrivateKey: keys.privateKey
|
|
41
|
+
});
|
|
42
|
+
try {
|
|
43
|
+
const result = await stamper.stamp(body);
|
|
44
|
+
return {
|
|
45
|
+
stampHeaderName: result.stampHeaderName,
|
|
46
|
+
stampHeaderValue: result.stampHeaderValue
|
|
47
|
+
};
|
|
48
|
+
} catch (cause) {
|
|
49
|
+
throw new StampError("Turnkey ApiKeyStamper.stamp failed", { cause });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// src/signing/create-wallet.ts
|
|
54
|
+
var WALLET_TYPE_ACCOUNTS = {
|
|
55
|
+
stablecoin_ethereum: [
|
|
56
|
+
{
|
|
57
|
+
curve: "CURVE_SECP256K1",
|
|
58
|
+
pathFormat: "PATH_FORMAT_BIP32",
|
|
59
|
+
path: "m/44'/60'/0'/0/0",
|
|
60
|
+
addressFormat: "ADDRESS_FORMAT_ETHEREUM"
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
stablecoin_solana: [
|
|
64
|
+
{
|
|
65
|
+
curve: "CURVE_ED25519",
|
|
66
|
+
pathFormat: "PATH_FORMAT_BIP32",
|
|
67
|
+
path: "m/44'/501'/0'/0'",
|
|
68
|
+
addressFormat: "ADDRESS_FORMAT_SOLANA"
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
stablecoin_stellar: [
|
|
72
|
+
{
|
|
73
|
+
curve: "CURVE_ED25519",
|
|
74
|
+
pathFormat: "PATH_FORMAT_BIP32",
|
|
75
|
+
path: "m/44'/148'/0'",
|
|
76
|
+
addressFormat: "ADDRESS_FORMAT_XLM"
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
};
|
|
80
|
+
var VALID_WALLET_TYPES = Object.keys(WALLET_TYPE_ACCOUNTS);
|
|
81
|
+
async function signCreateWallet(signing, params) {
|
|
82
|
+
if (!VALID_WALLET_TYPES.includes(params.type)) {
|
|
83
|
+
throw new TesserConfigError(`signCreateWallet: type '${String(params.type)}' is not a valid WalletType. ` + `Valid values: ${VALID_WALLET_TYPES.join(", ")}.`);
|
|
84
|
+
}
|
|
85
|
+
const accounts = WALLET_TYPE_ACCOUNTS[params.type];
|
|
86
|
+
const body = JSON.stringify({
|
|
87
|
+
type: "ACTIVITY_TYPE_CREATE_WALLET",
|
|
88
|
+
timestampMs: String(Date.now()),
|
|
89
|
+
organizationId: signing.enclaveId,
|
|
90
|
+
parameters: {
|
|
91
|
+
walletName: params.name,
|
|
92
|
+
accounts
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const result = await stamp({ publicKey: signing.publicKey, privateKey: signing.privateKey }, body);
|
|
96
|
+
const signature = Buffer.from(JSON.stringify({ body, stamp: result.stampHeaderValue })).toString("base64");
|
|
97
|
+
return {
|
|
98
|
+
signature,
|
|
99
|
+
metadata: {
|
|
100
|
+
stampHeaderName: result.stampHeaderName,
|
|
101
|
+
stampHeaderValue: result.stampHeaderValue,
|
|
102
|
+
body
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// src/signing/network-type.ts
|
|
108
|
+
var NETWORK_TO_TURNKEY_TYPE = {
|
|
109
|
+
BASE: "TRANSACTION_TYPE_ETHEREUM",
|
|
110
|
+
BASE_SEPOLIA: "TRANSACTION_TYPE_ETHEREUM",
|
|
111
|
+
ETHEREUM: "TRANSACTION_TYPE_ETHEREUM",
|
|
112
|
+
POLYGON: "TRANSACTION_TYPE_ETHEREUM",
|
|
113
|
+
POLYGON_AMOY: "TRANSACTION_TYPE_ETHEREUM",
|
|
114
|
+
SOLANA: "TRANSACTION_TYPE_SOLANA"
|
|
115
|
+
};
|
|
116
|
+
function networkToTurnkeyType(network) {
|
|
117
|
+
const turnkeyType = NETWORK_TO_TURNKEY_TYPE[network];
|
|
118
|
+
if (turnkeyType === undefined) {
|
|
119
|
+
const supported = Object.keys(NETWORK_TO_TURNKEY_TYPE).sort().join(", ");
|
|
120
|
+
throw new TesserConfigError(`Unsupported network: '${network}'. Supported: ${supported}`);
|
|
121
|
+
}
|
|
122
|
+
return turnkeyType;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/signing/sign-step.ts
|
|
126
|
+
async function signStep(signing, step) {
|
|
127
|
+
const turnkeyType = networkToTurnkeyType(step.network);
|
|
128
|
+
const body = JSON.stringify({
|
|
129
|
+
type: "ACTIVITY_TYPE_SIGN_TRANSACTION_V2",
|
|
130
|
+
timestampMs: String(Date.now()),
|
|
131
|
+
organizationId: signing.enclaveId,
|
|
132
|
+
parameters: {
|
|
133
|
+
signWith: step.signWith,
|
|
134
|
+
unsignedTransaction: step.unsignedTransaction,
|
|
135
|
+
type: turnkeyType
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const stamped = await stamp({ publicKey: signing.publicKey, privateKey: signing.privateKey }, body);
|
|
139
|
+
const composite = JSON.stringify({ body, stamp: stamped.stampHeaderValue });
|
|
140
|
+
const signature = Buffer.from(composite, "utf-8").toString("base64");
|
|
141
|
+
return {
|
|
142
|
+
signature,
|
|
143
|
+
metadata: {
|
|
144
|
+
stampHeaderName: stamped.stampHeaderName,
|
|
145
|
+
stampHeaderValue: stamped.stampHeaderValue,
|
|
146
|
+
body
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// src/signer.ts
|
|
152
|
+
class LocalSigner {
|
|
153
|
+
signing;
|
|
154
|
+
#privateKey;
|
|
155
|
+
constructor(options) {
|
|
156
|
+
const s = options.signing;
|
|
157
|
+
if (!s || !s.publicKey || !s.privateKey || !s.enclaveId) {
|
|
158
|
+
throw new TesserConfigError("LocalSigner: signing.publicKey, signing.privateKey, and signing.enclaveId are required");
|
|
159
|
+
}
|
|
160
|
+
this.signing = { publicKey: s.publicKey, enclaveId: s.enclaveId };
|
|
161
|
+
this.#privateKey = s.privateKey;
|
|
162
|
+
}
|
|
163
|
+
signCreateWallet(params) {
|
|
164
|
+
return signCreateWallet({
|
|
165
|
+
publicKey: this.signing.publicKey,
|
|
166
|
+
privateKey: this.#privateKey,
|
|
167
|
+
enclaveId: this.signing.enclaveId
|
|
168
|
+
}, params);
|
|
169
|
+
}
|
|
170
|
+
signStep(step) {
|
|
171
|
+
return signStep({
|
|
172
|
+
publicKey: this.signing.publicKey,
|
|
173
|
+
privateKey: this.#privateKey,
|
|
174
|
+
enclaveId: this.signing.enclaveId
|
|
175
|
+
}, step);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
TesserSigningError,
|
|
180
|
+
TesserError,
|
|
181
|
+
TesserConfigError,
|
|
182
|
+
StampError,
|
|
183
|
+
LocalSigner
|
|
184
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export declare class TesserError extends Error {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
constructor(message: string, options?: {
|
|
4
|
+
cause?: unknown;
|
|
5
|
+
});
|
|
6
|
+
static is(err: unknown): err is TesserError;
|
|
7
|
+
}
|
|
8
|
+
export declare class TesserConfigError extends TesserError {
|
|
9
|
+
readonly name = "TesserConfigError";
|
|
10
|
+
static is(err: unknown): err is TesserConfigError;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* One entry from Tesser's documented `{ "errors": [...] }` response envelope.
|
|
14
|
+
* See https://docs.tesser.xyz/overviews/errors. Field names are camelCased
|
|
15
|
+
* for JS idiom; the wire format uses `error_code` / `error_message` /
|
|
16
|
+
* `ui_message` and is converted at the HTTP boundary.
|
|
17
|
+
*/
|
|
18
|
+
export interface TesserErrorDetail {
|
|
19
|
+
errorCode: string;
|
|
20
|
+
errorMessage: string;
|
|
21
|
+
uiMessage?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface TesserAPIErrorOptions {
|
|
24
|
+
cause?: unknown;
|
|
25
|
+
status: number;
|
|
26
|
+
headers?: Headers;
|
|
27
|
+
requestId?: string;
|
|
28
|
+
errors?: readonly TesserErrorDetail[];
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Thrown for any non-2xx HTTP response from Tesser. Carries the parsed
|
|
32
|
+
* `errors[]` envelope so consumers can branch on Tesser's documented error
|
|
33
|
+
* codes (e.g. `accounts-3005`, `idempotency-1001`) rather than HTTP status
|
|
34
|
+
* alone. For responses that are not Tesser-shaped (e.g., a Cloudflare 502
|
|
35
|
+
* page), `errors` is the empty array.
|
|
36
|
+
*/
|
|
37
|
+
export declare class TesserAPIError extends TesserError {
|
|
38
|
+
readonly name: string;
|
|
39
|
+
readonly status: number;
|
|
40
|
+
readonly headers?: Headers;
|
|
41
|
+
readonly requestId?: string;
|
|
42
|
+
readonly errors: readonly TesserErrorDetail[];
|
|
43
|
+
constructor(message: string, options: TesserAPIErrorOptions);
|
|
44
|
+
/** First reported error code, or `undefined` if the body wasn't a Tesser error envelope. */
|
|
45
|
+
get errorCode(): string | undefined;
|
|
46
|
+
/** True if any reported error matches one of the given documented codes. */
|
|
47
|
+
hasCode(...codes: string[]): boolean;
|
|
48
|
+
static is(err: unknown): err is TesserAPIError;
|
|
49
|
+
}
|
|
50
|
+
export declare class TesserConnectionError extends TesserError {
|
|
51
|
+
readonly name = "TesserConnectionError";
|
|
52
|
+
static is(err: unknown): err is TesserConnectionError;
|
|
53
|
+
}
|
|
54
|
+
export declare class TesserTimeoutError extends TesserError {
|
|
55
|
+
readonly name = "TesserTimeoutError";
|
|
56
|
+
static is(err: unknown): err is TesserTimeoutError;
|
|
57
|
+
}
|
|
58
|
+
export declare class TesserSigningError extends TesserError {
|
|
59
|
+
readonly name: string;
|
|
60
|
+
static is(err: unknown): err is TesserSigningError;
|
|
61
|
+
}
|
|
62
|
+
export declare class StampError extends TesserSigningError {
|
|
63
|
+
readonly name = "StampError";
|
|
64
|
+
static is(err: unknown): err is StampError;
|
|
65
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { Logger } from './types.js';
|
|
2
|
+
export interface HttpContext {
|
|
3
|
+
fetch: typeof fetch;
|
|
4
|
+
logger: Logger;
|
|
5
|
+
timeout: number;
|
|
6
|
+
maxRetries: number;
|
|
7
|
+
bearer: string;
|
|
8
|
+
}
|
|
9
|
+
export interface HttpResponse<T> {
|
|
10
|
+
data: T;
|
|
11
|
+
status: number;
|
|
12
|
+
headers: Headers;
|
|
13
|
+
requestId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface FetchWithRetryOptions {
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
timeout?: number;
|
|
18
|
+
maxRetries?: number;
|
|
19
|
+
method?: string;
|
|
20
|
+
body?: BodyInit;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
}
|
|
23
|
+
export declare function fetchWithRetry<T>(ctx: HttpContext, url: string, options?: FetchWithRetryOptions): Promise<HttpResponse<T>>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { SupportedNetwork } from '../signing/network-type.js';
|
|
2
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'off';
|
|
3
|
+
export interface Logger {
|
|
4
|
+
error(...args: unknown[]): void;
|
|
5
|
+
warn(...args: unknown[]): void;
|
|
6
|
+
info(...args: unknown[]): void;
|
|
7
|
+
debug(...args: unknown[]): void;
|
|
8
|
+
}
|
|
9
|
+
export interface SigningConfig {
|
|
10
|
+
publicKey: string;
|
|
11
|
+
privateKey: string;
|
|
12
|
+
enclaveId: string;
|
|
13
|
+
}
|
|
14
|
+
export type WalletType = 'stablecoin_ethereum'
|
|
15
|
+
/** @experimental Solana wallet creation is not yet verified end-to-end against Tesser staging. */
|
|
16
|
+
| 'stablecoin_solana'
|
|
17
|
+
/** @experimental Stellar is supported by Tesser only as a receive (unmanaged) wallet; `signCreateWallet` is unverified. */
|
|
18
|
+
| 'stablecoin_stellar';
|
|
19
|
+
export interface SignedResultMetadata {
|
|
20
|
+
stampHeaderName: string;
|
|
21
|
+
stampHeaderValue: string;
|
|
22
|
+
body: string;
|
|
23
|
+
}
|
|
24
|
+
export interface SignedResult {
|
|
25
|
+
signature: string;
|
|
26
|
+
metadata: SignedResultMetadata;
|
|
27
|
+
}
|
|
28
|
+
export interface CreateWalletParams {
|
|
29
|
+
name: string;
|
|
30
|
+
type: WalletType;
|
|
31
|
+
}
|
|
32
|
+
export interface StepForSigning {
|
|
33
|
+
/** Hex-encoded raw tx bytes, e.g. "0x02..." */
|
|
34
|
+
unsignedTransaction: string;
|
|
35
|
+
/** On-chain address from GET /v1/accounts/{id} → crypto_wallet_address */
|
|
36
|
+
signWith: string;
|
|
37
|
+
/** Network identifier; one of the supported chains in `NETWORK_TO_TURNKEY_TYPE`. */
|
|
38
|
+
network: SupportedNetwork;
|
|
39
|
+
}
|
|
40
|
+
export interface SignedStepResultMetadata {
|
|
41
|
+
stampHeaderName: string;
|
|
42
|
+
stampHeaderValue: string;
|
|
43
|
+
body: string;
|
|
44
|
+
}
|
|
45
|
+
export interface SignedStepResult {
|
|
46
|
+
/** base64(JSON.stringify({body, stamp})) — pass to Tesser API */
|
|
47
|
+
signature: string;
|
|
48
|
+
metadata: SignedStepResultMetadata;
|
|
49
|
+
}
|
|
50
|
+
export interface LocalSignerOptions {
|
|
51
|
+
signing: SigningConfig;
|
|
52
|
+
}
|
package/dist/signer.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { CreateWalletParams, LocalSignerOptions, SignedResult, SignedStepResult, StepForSigning } from './internal/types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The portion of `SigningConfig` that `LocalSigner` exposes on its instance.
|
|
4
|
+
* The private key is held in an ECMA private field and is not reachable via
|
|
5
|
+
* property access, `console.log`, or `JSON.stringify`.
|
|
6
|
+
*/
|
|
7
|
+
export interface PublicSigningInfo {
|
|
8
|
+
readonly publicKey: string;
|
|
9
|
+
readonly enclaveId: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Produces locally-signed activity payloads for Tesser API operations.
|
|
13
|
+
*
|
|
14
|
+
* v0.0.1 supports `signCreateWallet` and `signStep`. A future version will
|
|
15
|
+
* add an optional `client` field to `LocalSignerOptions` for HTTP integration;
|
|
16
|
+
* the addition is purely additive and does not break existing call sites.
|
|
17
|
+
*
|
|
18
|
+
* Key handling: the private key is stored in an ECMA private field (`#privateKey`)
|
|
19
|
+
* and is not reachable via `signer.signing.privateKey` or any other public
|
|
20
|
+
* surface. `signer.signing` exposes only `{ publicKey, enclaveId }`, so logging
|
|
21
|
+
* `signer` or its `signing` property will not leak the private key.
|
|
22
|
+
*
|
|
23
|
+
* Thread-safety: stateless and reentrant. A single LocalSigner instance may
|
|
24
|
+
* be shared across concurrent calls; the SDK never mutates internal state.
|
|
25
|
+
*/
|
|
26
|
+
export declare class LocalSigner {
|
|
27
|
+
#private;
|
|
28
|
+
readonly signing: PublicSigningInfo;
|
|
29
|
+
constructor(options: LocalSignerOptions);
|
|
30
|
+
/** Stamps an `ACTIVITY_TYPE_CREATE_WALLET` Turnkey activity. */
|
|
31
|
+
signCreateWallet(params: CreateWalletParams): Promise<SignedResult>;
|
|
32
|
+
/** Stamps an `ACTIVITY_TYPE_SIGN_TRANSACTION_V2` Turnkey activity. */
|
|
33
|
+
signStep(step: StepForSigning): Promise<SignedStepResult>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
declare const NETWORK_TO_TURNKEY_TYPE: {
|
|
2
|
+
readonly BASE: "TRANSACTION_TYPE_ETHEREUM";
|
|
3
|
+
readonly BASE_SEPOLIA: "TRANSACTION_TYPE_ETHEREUM";
|
|
4
|
+
readonly ETHEREUM: "TRANSACTION_TYPE_ETHEREUM";
|
|
5
|
+
readonly POLYGON: "TRANSACTION_TYPE_ETHEREUM";
|
|
6
|
+
readonly POLYGON_AMOY: "TRANSACTION_TYPE_ETHEREUM";
|
|
7
|
+
readonly SOLANA: "TRANSACTION_TYPE_SOLANA";
|
|
8
|
+
};
|
|
9
|
+
export type SupportedNetwork = keyof typeof NETWORK_TO_TURNKEY_TYPE;
|
|
10
|
+
export declare function networkToTurnkeyType(network: string): string;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SigningConfig } from '../internal/types.js';
|
|
2
|
+
export interface StampResult {
|
|
3
|
+
stampHeaderName: string;
|
|
4
|
+
stampHeaderValue: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The SDK requires `publicKey` to be in 33-byte compressed secp256k1 form
|
|
8
|
+
* (66 hex chars starting with `02` or `03`). Turnkey stores and matches API
|
|
9
|
+
* keys by exact string of this form.
|
|
10
|
+
*/
|
|
11
|
+
export declare function stamp(keys: Pick<SigningConfig, 'publicKey' | 'privateKey'>, body: string): Promise<StampResult>;
|
package/package.json
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@tesser-payments/sdk-ts",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Signer-only TypeScript SDK for Tesser API: locally stamp signCreateWallet and signStep activities. No HTTP, no OAuth — bring your own client.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"files": ["dist", "README.md", "LICENSE"],
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20",
|
|
15
|
+
"bun": ">=1.3"
|
|
16
|
+
},
|
|
17
|
+
"scripts": {
|
|
18
|
+
"build": "bun run build:js && bun run build:types",
|
|
19
|
+
"build:js": "bun build ./src/index.ts --target=node --format=esm --outdir=./dist --external @turnkey/api-key-stamper --external @tesser-payments/types",
|
|
20
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
21
|
+
"prepack": "bun run build",
|
|
22
|
+
"test": "vitest run",
|
|
23
|
+
"test:watch": "vitest",
|
|
24
|
+
"lint": "biome check .",
|
|
25
|
+
"lint:fix": "biome check . --write",
|
|
26
|
+
"typecheck": "tsc --noEmit"
|
|
27
|
+
},
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@tesser-payments/types": "*",
|
|
30
|
+
"@turnkey/api-key-stamper": "*"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@biomejs/biome": "^1.9",
|
|
34
|
+
"@tesser-payments/types": "*",
|
|
35
|
+
"@turnkey/api-key-stamper": "*",
|
|
36
|
+
"@types/node": "^20",
|
|
37
|
+
"typescript": "^5.4",
|
|
38
|
+
"vitest": "^2"
|
|
39
|
+
},
|
|
40
|
+
"trustedDependencies": []
|
|
41
|
+
}
|