tenzro-sdk 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +4 -15
- package/README.md +196 -3
- package/dist/adaptive-burn.d.ts +40 -0
- package/dist/adaptive-burn.d.ts.map +1 -0
- package/dist/adaptive-burn.js +53 -0
- package/dist/adaptive-burn.js.map +1 -0
- package/dist/agent.d.ts +8 -1
- package/dist/agent.d.ts.map +1 -1
- package/dist/agent.js +14 -2
- package/dist/agent.js.map +1 -1
- package/dist/ap2.d.ts +96 -0
- package/dist/ap2.d.ts.map +1 -1
- package/dist/ap2.js +65 -0
- package/dist/ap2.js.map +1 -1
- package/dist/app.js +4 -4
- package/dist/app.js.map +1 -1
- package/dist/auth.d.ts +357 -0
- package/dist/auth.d.ts.map +1 -0
- package/dist/auth.js +226 -0
- package/dist/auth.js.map +1 -0
- package/dist/bond.d.ts +70 -0
- package/dist/bond.d.ts.map +1 -0
- package/dist/bond.js +172 -0
- package/dist/bond.js.map +1 -0
- package/dist/cct.d.ts +53 -0
- package/dist/cct.d.ts.map +1 -0
- package/dist/cct.js +30 -0
- package/dist/cct.js.map +1 -0
- package/dist/client.d.ts +134 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +196 -12
- package/dist/client.js.map +1 -1
- package/dist/cortex.d.ts +227 -0
- package/dist/cortex.d.ts.map +1 -0
- package/dist/cortex.js +137 -0
- package/dist/cortex.js.map +1 -0
- package/dist/custody.d.ts +251 -0
- package/dist/custody.d.ts.map +1 -1
- package/dist/custody.js +216 -0
- package/dist/custody.js.map +1 -1
- package/dist/eip6963.d.ts +63 -0
- package/dist/eip6963.d.ts.map +1 -0
- package/dist/eip6963.js +67 -0
- package/dist/eip6963.js.map +1 -0
- package/dist/erc8004.d.ts +97 -0
- package/dist/erc8004.d.ts.map +1 -0
- package/dist/erc8004.js +182 -0
- package/dist/erc8004.js.map +1 -0
- package/dist/identity.d.ts +15 -1
- package/dist/identity.d.ts.map +1 -1
- package/dist/identity.js +18 -0
- package/dist/identity.js.map +1 -1
- package/dist/index.d.ts +28 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +49 -1
- package/dist/index.js.map +1 -1
- package/dist/insurance.d.ts +38 -0
- package/dist/insurance.d.ts.map +1 -0
- package/dist/insurance.js +51 -0
- package/dist/insurance.js.map +1 -0
- package/dist/lifecycle.d.ts +41 -0
- package/dist/lifecycle.d.ts.map +1 -0
- package/dist/lifecycle.js +56 -0
- package/dist/lifecycle.js.map +1 -0
- package/dist/marketplace.d.ts +30 -2
- package/dist/marketplace.d.ts.map +1 -1
- package/dist/marketplace.js +36 -2
- package/dist/marketplace.js.map +1 -1
- package/dist/payment.d.ts +14 -1
- package/dist/payment.d.ts.map +1 -1
- package/dist/payment.js +15 -0
- package/dist/payment.js.map +1 -1
- package/dist/principal-chain.d.ts +41 -0
- package/dist/principal-chain.d.ts.map +1 -0
- package/dist/principal-chain.js +56 -0
- package/dist/principal-chain.js.map +1 -0
- package/dist/provider.d.ts +2 -2
- package/dist/provider.js +1 -1
- package/dist/quota.d.ts +54 -0
- package/dist/quota.d.ts.map +1 -0
- package/dist/quota.js +71 -0
- package/dist/quota.js.map +1 -0
- package/dist/rpc.d.ts +43 -4
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +110 -3
- package/dist/rpc.js.map +1 -1
- package/dist/seed-agent.d.ts +52 -0
- package/dist/seed-agent.d.ts.map +1 -0
- package/dist/seed-agent.js +69 -0
- package/dist/seed-agent.js.map +1 -0
- package/dist/settlement.d.ts +52 -10
- package/dist/settlement.d.ts.map +1 -1
- package/dist/settlement.js +197 -16
- package/dist/settlement.js.map +1 -1
- package/dist/streaming.js.map +1 -1
- package/dist/svm-cross-vm.d.ts +109 -0
- package/dist/svm-cross-vm.d.ts.map +1 -0
- package/dist/svm-cross-vm.js +215 -0
- package/dist/svm-cross-vm.js.map +1 -0
- package/dist/types.d.ts +175 -6
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/dist/wallet.d.ts +26 -9
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +34 -19
- package/dist/wallet.js.map +1 -1
- package/dist/wormhole.d.ts +76 -0
- package/dist/wormhole.d.ts.map +1 -0
- package/dist/wormhole.js +56 -0
- package/dist/wormhole.js.map +1 -0
- package/package.json +2 -2
package/dist/custody.js
CHANGED
|
@@ -91,6 +91,222 @@ class CustodyClient {
|
|
|
91
91
|
{ wallet_id: walletId, duration_secs: durationSecs, operations },
|
|
92
92
|
]);
|
|
93
93
|
}
|
|
94
|
+
// ── ML-DSA-65 (FIPS 204) — post-quantum wallet signing surface ──
|
|
95
|
+
//
|
|
96
|
+
// These methods call the `/wallet/mldsa/*` Web API endpoints (not
|
|
97
|
+
// JSON-RPC). Each call requires a caller-supplied DPoP-bound JWT and
|
|
98
|
+
// a fresh DPoP proof signed over `(method, htu)`. The proof is opaque
|
|
99
|
+
// to the SDK — the wallet kernel constructs it.
|
|
100
|
+
/**
|
|
101
|
+
* Discover the node's ML-DSA-65 signing mode.
|
|
102
|
+
*
|
|
103
|
+
* Always `tee-only` on testnet. The wallet uses this to decide
|
|
104
|
+
* whether to invoke threshold-coordination methods (skipped in
|
|
105
|
+
* `tee-only`) or fall through to the single-shot {@link mldsaSign}.
|
|
106
|
+
*
|
|
107
|
+
* Required AAP capability: `wallet.mldsa.sign`.
|
|
108
|
+
*/
|
|
109
|
+
async mldsaCapabilities(bearerJwt, dpopProof) {
|
|
110
|
+
return this.rpc.getWithAuth('/wallet/mldsa/capabilities', bearerJwt, dpopProof);
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Sign a preimage with the node-held ML-DSA-65 key bound to
|
|
114
|
+
* `(did, surfaceKey)`. The returned signature is 3309 bytes per
|
|
115
|
+
* FIPS 204 §4 Table 2.
|
|
116
|
+
*
|
|
117
|
+
* Required AAP capability: `wallet.mldsa.sign`.
|
|
118
|
+
*
|
|
119
|
+
* @param bearerJwt - DPoP-bound bearer JWT.
|
|
120
|
+
* @param dpopProof - Fresh DPoP proof signed over `(POST, "<base>/wallet/mldsa/sign")`.
|
|
121
|
+
* @param did - Bearer DID owning the surface key.
|
|
122
|
+
* @param surfaceKey - Wallet-defined surface identifier (e.g. `"vault.0"`).
|
|
123
|
+
* @param preimage - Raw bytes to be signed (encoded base64url no-pad on the wire).
|
|
124
|
+
* @param purpose - Optional caller-supplied purpose string for audit logging.
|
|
125
|
+
*/
|
|
126
|
+
async mldsaSign(bearerJwt, dpopProof, did, surfaceKey, preimage, purpose) {
|
|
127
|
+
return this.rpc.postWithAuth('/wallet/mldsa/sign', {
|
|
128
|
+
did,
|
|
129
|
+
surface_key: surfaceKey,
|
|
130
|
+
preimage_b64: base64UrlNoPadEncode(preimage),
|
|
131
|
+
purpose,
|
|
132
|
+
}, bearerJwt, dpopProof);
|
|
133
|
+
}
|
|
134
|
+
// ── FROST (RFC 9591) — threshold Schnorr signing surface ──
|
|
135
|
+
//
|
|
136
|
+
// Per-curve `:scheme` path dispatch (`ed25519` | `secp256k1`). The
|
|
137
|
+
// node holds one share, the wallet holds the other (2-of-2). The
|
|
138
|
+
// wallet drives the protocol; the node is purely reactive. Each call
|
|
139
|
+
// is gated by AAP capability `wallet.frost.sign` and requires a
|
|
140
|
+
// fresh DPoP proof bound to the request's `(method, htu)`.
|
|
141
|
+
//
|
|
142
|
+
// Wire bytes (`*_b64` fields) are the FROST crate's canonical
|
|
143
|
+
// `.serialize()` of the corresponding round structure.
|
|
144
|
+
/**
|
|
145
|
+
* Start a FROST signing session.
|
|
146
|
+
*
|
|
147
|
+
* Server allocates a session, runs Round 1, and returns its
|
|
148
|
+
* commitments together with both participant identifiers. The
|
|
149
|
+
* wallet then runs its own Round 1 against the same `preimage`
|
|
150
|
+
* and the returned identifiers, and submits its commitments via
|
|
151
|
+
* {@link frostCommit}.
|
|
152
|
+
*
|
|
153
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
154
|
+
*/
|
|
155
|
+
async frostStart(bearerJwt, dpopProof, scheme, did, surfaceKey, preimage) {
|
|
156
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/start`, {
|
|
157
|
+
did,
|
|
158
|
+
surface_key: surfaceKey,
|
|
159
|
+
preimage_b64: base64UrlNoPadEncode(preimage),
|
|
160
|
+
}, bearerJwt, dpopProof);
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Submit the wallet's Round 1 commitments.
|
|
164
|
+
*
|
|
165
|
+
* Transitions the session from `pending` to `committed`. After this
|
|
166
|
+
* call the wallet should call {@link frostAwaitChallenge} to receive
|
|
167
|
+
* the `SigningPackage` it must feed into the FROST crate's
|
|
168
|
+
* `round2::sign`.
|
|
169
|
+
*
|
|
170
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
171
|
+
*/
|
|
172
|
+
async frostCommit(bearerJwt, dpopProof, scheme, sessionId, deviceCommitments) {
|
|
173
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/commit`, {
|
|
174
|
+
session_id: sessionId,
|
|
175
|
+
device_commitments_b64: base64UrlNoPadEncode(deviceCommitments),
|
|
176
|
+
}, bearerJwt, dpopProof);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Long-poll for the challenge (`SigningPackage`).
|
|
180
|
+
*
|
|
181
|
+
* Returns immediately if the session is already `committed`. Polls
|
|
182
|
+
* for up to ~5s otherwise. The wallet feeds `signing_package_b64`
|
|
183
|
+
* into `round2::sign(signing_package, signer_nonces, key_package)`
|
|
184
|
+
* to produce its signature share.
|
|
185
|
+
*
|
|
186
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
187
|
+
*/
|
|
188
|
+
async frostAwaitChallenge(bearerJwt, dpopProof, scheme, sessionId) {
|
|
189
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/await-challenge`, { session_id: sessionId }, bearerJwt, dpopProof);
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Submit the wallet's Round 2 signature share.
|
|
193
|
+
*
|
|
194
|
+
* Server runs its own Round 2, aggregates the two shares, and
|
|
195
|
+
* transitions the session to `finalized`. The aggregated signature
|
|
196
|
+
* is then retrievable via {@link frostFinalize}.
|
|
197
|
+
*
|
|
198
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
199
|
+
*/
|
|
200
|
+
async frostRespond(bearerJwt, dpopProof, scheme, sessionId, deviceSignatureShare) {
|
|
201
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/respond`, {
|
|
202
|
+
session_id: sessionId,
|
|
203
|
+
device_signature_share_b64: base64UrlNoPadEncode(deviceSignatureShare),
|
|
204
|
+
}, bearerJwt, dpopProof);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Long-poll for the aggregated signature.
|
|
208
|
+
*
|
|
209
|
+
* Returns immediately if the session is already `finalized`. Polls
|
|
210
|
+
* for up to ~5s otherwise. `signature_b64` is the canonical Schnorr
|
|
211
|
+
* signature: 64 bytes for Ed25519, 65 for secp256k1 (Taproot).
|
|
212
|
+
*
|
|
213
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
214
|
+
*/
|
|
215
|
+
async frostFinalize(bearerJwt, dpopProof, scheme, sessionId) {
|
|
216
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/finalize`, { session_id: sessionId }, bearerJwt, dpopProof);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Abort an in-flight FROST session.
|
|
220
|
+
*
|
|
221
|
+
* Idempotent: an already-aborted session returns `aborted`. A
|
|
222
|
+
* session that has already finalized stays `finalized` (the abort
|
|
223
|
+
* is a no-op rather than an error).
|
|
224
|
+
*
|
|
225
|
+
* Required AAP capability: `wallet.frost.sign`.
|
|
226
|
+
*/
|
|
227
|
+
async frostAbort(bearerJwt, dpopProof, scheme, sessionId) {
|
|
228
|
+
return this.rpc.postWithAuth(`/wallet/frost/${scheme}/abort`, { session_id: sessionId }, bearerJwt, dpopProof);
|
|
229
|
+
}
|
|
230
|
+
// ── Passkey share-unwrap surface (`/wallet/share/*`) ──
|
|
231
|
+
//
|
|
232
|
+
// Three-step flow:
|
|
233
|
+
// 1. shareEnvelope — fetch the wrapped FROST share blob.
|
|
234
|
+
// 2. shareEscrowChallenge — mint a single-use 30s nonce.
|
|
235
|
+
// 3. shareEscrowUnwrap — submit the WebAuthn assertion + nonce
|
|
236
|
+
// to receive `(wrapped_share, pepper)`.
|
|
237
|
+
//
|
|
238
|
+
// The pepper is mixed into the wallet's local unwrap KDF; without it
|
|
239
|
+
// the wrapped share is gibberish even to a caller that holds a valid
|
|
240
|
+
// AAP token. All endpoints require capability `wallet.share.unwrap`.
|
|
241
|
+
/**
|
|
242
|
+
* Fetch the wrapped FROST share for `(credentialId, surfaceKey)`.
|
|
243
|
+
*
|
|
244
|
+
* Idempotent — repeated calls return identical bytes for the same
|
|
245
|
+
* pair. The returned blob is useless on its own; the wallet must
|
|
246
|
+
* also obtain the per-assertion pepper via {@link shareEscrowUnwrap}
|
|
247
|
+
* and combine the two through its local KDF to recover the cleartext
|
|
248
|
+
* share.
|
|
249
|
+
*
|
|
250
|
+
* Required AAP capability: `wallet.share.unwrap`.
|
|
251
|
+
*/
|
|
252
|
+
async shareEnvelope(bearerJwt, dpopProof, credentialId, surfaceKey) {
|
|
253
|
+
const path = `/wallet/share/envelope?credential_id=${encodeURIComponent(credentialId)}&surface_key=${encodeURIComponent(surfaceKey)}`;
|
|
254
|
+
return this.rpc.getWithAuth(path, bearerJwt, dpopProof);
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Mint a single-use, 30-second-TTL nonce for an upcoming WebAuthn
|
|
258
|
+
* ceremony.
|
|
259
|
+
*
|
|
260
|
+
* The wallet must use the returned `nonce_b64` value verbatim as
|
|
261
|
+
* the WebAuthn `challenge` field when prompting the user's passkey.
|
|
262
|
+
* Server-side the nonce is held in an in-memory escrow; it is
|
|
263
|
+
* consumed by {@link shareEscrowUnwrap} regardless of whether the
|
|
264
|
+
* assertion verifies.
|
|
265
|
+
*
|
|
266
|
+
* Required AAP capability: `wallet.share.unwrap`.
|
|
267
|
+
*/
|
|
268
|
+
async shareEscrowChallenge(bearerJwt, dpopProof, credentialId, surfaceKey) {
|
|
269
|
+
return this.rpc.postWithAuth('/wallet/share/escrow/challenge', { credential_id: credentialId, surface_key: surfaceKey }, bearerJwt, dpopProof);
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* Verify a WebAuthn assertion, consume the escrow nonce, and return
|
|
273
|
+
* `(wrapped_share, pepper)`.
|
|
274
|
+
*
|
|
275
|
+
* Single-use: the nonce is removed from the escrow before the
|
|
276
|
+
* assertion is verified, so a successful unwrap cannot be replayed
|
|
277
|
+
* and a failed verification still consumes the nonce. The wallet
|
|
278
|
+
* must request a fresh challenge before retrying.
|
|
279
|
+
*
|
|
280
|
+
* Required AAP capability: `wallet.share.unwrap`.
|
|
281
|
+
*/
|
|
282
|
+
async shareEscrowUnwrap(bearerJwt, dpopProof, credentialId, surfaceKey, nonceB64, assertion) {
|
|
283
|
+
return this.rpc.postWithAuth('/wallet/share/escrow/unwrap', {
|
|
284
|
+
credential_id: credentialId,
|
|
285
|
+
surface_key: surfaceKey,
|
|
286
|
+
nonce_b64: nonceB64,
|
|
287
|
+
assertion,
|
|
288
|
+
}, bearerJwt, dpopProof);
|
|
289
|
+
}
|
|
94
290
|
}
|
|
95
291
|
exports.CustodyClient = CustodyClient;
|
|
292
|
+
// ── helpers ──
|
|
293
|
+
/**
|
|
294
|
+
* Encode bytes as base64url with no padding (RFC 4648 §5). Used for
|
|
295
|
+
* the `*_b64` fields on the wire format. Implemented locally so the
|
|
296
|
+
* SDK does not pull in a runtime dependency.
|
|
297
|
+
*/
|
|
298
|
+
function base64UrlNoPadEncode(bytes) {
|
|
299
|
+
let binary = '';
|
|
300
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
301
|
+
binary += String.fromCharCode(bytes[i]);
|
|
302
|
+
}
|
|
303
|
+
// btoa is available in browsers and modern Node (≥16); fall back
|
|
304
|
+
// to a Buffer path on older runtimes.
|
|
305
|
+
const b64 = typeof btoa !== 'undefined'
|
|
306
|
+
? btoa(binary)
|
|
307
|
+
: globalThis
|
|
308
|
+
.Buffer.from(binary, 'binary')
|
|
309
|
+
.toString('base64');
|
|
310
|
+
return b64.replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
311
|
+
}
|
|
96
312
|
//# sourceMappingURL=custody.js.map
|
package/dist/custody.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"custody.js","sourceRoot":"","sources":["../src/custody.ts"],"names":[],"mappings":";;;AAgEA,eAAe;AAEf;;;;;GAKG;AACH,MAAa,aAAa;IACK;IAA7B,YAA6B,GAAc;QAAd,QAAG,GAAH,GAAG,CAAW;IAAG,CAAC;IAE/C;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CACnB,SAAiB,EACjB,WAAmB,EACnB,OAAgC;QAEhC,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAY,wBAAwB,EAAE;YACxD,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAE;SAC5D,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,QAAgB;QACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAoB,uBAAuB,EAAE;YAC/D,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE;SAClC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc,CAAC,QAAgB,EAAE,QAAgB;QACrD,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAY,uBAAuB,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC;IACrF,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,YA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;;;;OAUG;IACH,KAAK,CAAC,iBAAiB,CACrB,SAAiB,EACjB,SAAiB,EACjB,YAAoB,EACpB,UAAkB,EAClB,QAAgB,EAChB,SAA2B;QAE3B,OAAO,IAAI,CAAC,GAAG,CAAC,YAAY,CAC1B,6BAA6B,EAC7B;YACE,aAAa,EAAE,YAAY;YAC3B,WAAW,EAAE,UAAU;YACvB,SAAS,EAAE,QAAQ;YACnB,SAAS;SACV,EACD,SAAS,EACT,SAAS,CACV,CAAC;IACJ,CAAC;CACF;AApaD,sCAoaC;AAiJD,gBAAgB;AAEhB;;;;GAIG;AACH,SAAS,oBAAoB,CAAC,KAAiB;IAC7C,IAAI,MAAM,GAAG,EAAE,CAAC;IAChB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtC,MAAM,IAAI,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,iEAAiE;IACjE,sCAAsC;IACtC,MAAM,GAAG,GACP,OAAO,IAAI,KAAK,WAAW;QACzB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC;QACd,CAAC,CAAE,UAAqG;aACnG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC;aAC7B,QAAQ,CAAC,QAAQ,CAAC,CAAC;IAC5B,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal EIP-6963 provider discovery for `TenzroClient.fromInjected()`.
|
|
3
|
+
*
|
|
4
|
+
* The browser extension installs `window.tenzro` and announces itself
|
|
5
|
+
* via `eip6963:announceProvider` (the multi-wallet discovery standard
|
|
6
|
+
* from EIP-6963 §Specification). This helper listens for the matching
|
|
7
|
+
* announcement and returns the provider, with a typed
|
|
8
|
+
* `TenzroNotInstalledError` for the not-installed case.
|
|
9
|
+
*
|
|
10
|
+
* The discovery code is inlined here rather than imported from a
|
|
11
|
+
* separate `@tenzro/inject` package so the SDK has zero peer
|
|
12
|
+
* dependencies — `npm install tenzro-sdk` is enough to opt into the
|
|
13
|
+
* injected-provider path.
|
|
14
|
+
*/
|
|
15
|
+
export interface EIP1193Provider {
|
|
16
|
+
request<T = unknown>(args: {
|
|
17
|
+
method: string;
|
|
18
|
+
params?: readonly unknown[] | Record<string, unknown>;
|
|
19
|
+
}): Promise<T>;
|
|
20
|
+
}
|
|
21
|
+
export interface EIP6963ProviderInfo {
|
|
22
|
+
readonly uuid: string;
|
|
23
|
+
readonly name: string;
|
|
24
|
+
readonly icon: string;
|
|
25
|
+
readonly rdns: string;
|
|
26
|
+
}
|
|
27
|
+
export interface EIP6963ProviderDetail {
|
|
28
|
+
readonly info: EIP6963ProviderInfo;
|
|
29
|
+
readonly provider: EIP1193Provider;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Default `rdns` for the Tenzro browser-extension provider.
|
|
33
|
+
*
|
|
34
|
+
* Pre-registration value — kept aligned with the extension's
|
|
35
|
+
* `installTenzroProvider({ rdns })` default. Will become a
|
|
36
|
+
* formally-registered RDNS once the CAIP-2 `tenzro:` namespace PR
|
|
37
|
+
* lands upstream.
|
|
38
|
+
*/
|
|
39
|
+
export declare const TENZRO_PROVIDER_RDNS = "network.tenzro.wallet";
|
|
40
|
+
/**
|
|
41
|
+
* Listen for EIP-6963 announcements and resolve when a provider
|
|
42
|
+
* matching `rdns` arrives. Defaults to the Tenzro extension's RDNS.
|
|
43
|
+
*
|
|
44
|
+
* Rejects with {@link TenzroNotInstalledError} if no matching
|
|
45
|
+
* provider announces within `timeoutMs` (default 3000ms).
|
|
46
|
+
*/
|
|
47
|
+
export declare function discoverEip6963Provider(options?: {
|
|
48
|
+
rdns?: string;
|
|
49
|
+
timeoutMs?: number;
|
|
50
|
+
}): Promise<EIP6963ProviderDetail>;
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when a Tenzro provider is expected but not present in the page.
|
|
53
|
+
*
|
|
54
|
+
* Catch this in dApps to render an "Install Tenzro" CTA rather than
|
|
55
|
+
* a generic error. The `code` field is also set to the literal string
|
|
56
|
+
* `"TENZRO_NOT_INSTALLED"` for callers that prefer duck-typing over
|
|
57
|
+
* `instanceof`.
|
|
58
|
+
*/
|
|
59
|
+
export declare class TenzroNotInstalledError extends Error {
|
|
60
|
+
readonly code: "TENZRO_NOT_INSTALLED";
|
|
61
|
+
constructor(message: string);
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=eip6963.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"eip6963.d.ts","sourceRoot":"","sources":["../src/eip6963.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,MAAM,WAAW,eAAe;IAC9B,OAAO,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE;QACzB,MAAM,EAAE,MAAM,CAAC;QACf,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACvD,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,eAAe,CAAC;CACpC;AAMD;;;;;;;GAOG;AACH,eAAO,MAAM,oBAAoB,0BAA0B,CAAC;AAE5D;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,CAAC,EAAE;IAChD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAwCjC;AAED;;;;;;;GAOG;AACH,qBAAa,uBAAwB,SAAQ,KAAK;IAChD,QAAQ,CAAC,IAAI,EAAG,sBAAsB,CAAU;gBAEpC,OAAO,EAAE,MAAM;CAI5B"}
|
package/dist/eip6963.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TenzroNotInstalledError = exports.TENZRO_PROVIDER_RDNS = void 0;
|
|
4
|
+
exports.discoverEip6963Provider = discoverEip6963Provider;
|
|
5
|
+
/**
|
|
6
|
+
* Default `rdns` for the Tenzro browser-extension provider.
|
|
7
|
+
*
|
|
8
|
+
* Pre-registration value — kept aligned with the extension's
|
|
9
|
+
* `installTenzroProvider({ rdns })` default. Will become a
|
|
10
|
+
* formally-registered RDNS once the CAIP-2 `tenzro:` namespace PR
|
|
11
|
+
* lands upstream.
|
|
12
|
+
*/
|
|
13
|
+
exports.TENZRO_PROVIDER_RDNS = "network.tenzro.wallet";
|
|
14
|
+
/**
|
|
15
|
+
* Listen for EIP-6963 announcements and resolve when a provider
|
|
16
|
+
* matching `rdns` arrives. Defaults to the Tenzro extension's RDNS.
|
|
17
|
+
*
|
|
18
|
+
* Rejects with {@link TenzroNotInstalledError} if no matching
|
|
19
|
+
* provider announces within `timeoutMs` (default 3000ms).
|
|
20
|
+
*/
|
|
21
|
+
function discoverEip6963Provider(options) {
|
|
22
|
+
const wantRdns = options?.rdns ?? exports.TENZRO_PROVIDER_RDNS;
|
|
23
|
+
const timeoutMs = options?.timeoutMs ?? 3000;
|
|
24
|
+
if (typeof window === "undefined") {
|
|
25
|
+
return Promise.reject(new TenzroNotInstalledError("not running in a browser context"));
|
|
26
|
+
}
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
let settled = false;
|
|
29
|
+
const onAnnounce = (rawEvent) => {
|
|
30
|
+
const event = rawEvent;
|
|
31
|
+
if (event.detail?.info?.rdns === wantRdns && !settled) {
|
|
32
|
+
settled = true;
|
|
33
|
+
window.removeEventListener("eip6963:announceProvider", onAnnounce);
|
|
34
|
+
window.clearTimeout(timer);
|
|
35
|
+
resolve(event.detail);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener("eip6963:announceProvider", onAnnounce);
|
|
39
|
+
// Per EIP-6963 §Specification, dApps signal readiness with this
|
|
40
|
+
// event; already-installed wallets re-announce in response.
|
|
41
|
+
window.dispatchEvent(new Event("eip6963:requestProvider"));
|
|
42
|
+
const timer = window.setTimeout(() => {
|
|
43
|
+
if (settled)
|
|
44
|
+
return;
|
|
45
|
+
settled = true;
|
|
46
|
+
window.removeEventListener("eip6963:announceProvider", onAnnounce);
|
|
47
|
+
reject(new TenzroNotInstalledError(`no EIP-6963 provider with rdns="${wantRdns}" announced within ${timeoutMs}ms`));
|
|
48
|
+
}, timeoutMs);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Thrown when a Tenzro provider is expected but not present in the page.
|
|
53
|
+
*
|
|
54
|
+
* Catch this in dApps to render an "Install Tenzro" CTA rather than
|
|
55
|
+
* a generic error. The `code` field is also set to the literal string
|
|
56
|
+
* `"TENZRO_NOT_INSTALLED"` for callers that prefer duck-typing over
|
|
57
|
+
* `instanceof`.
|
|
58
|
+
*/
|
|
59
|
+
class TenzroNotInstalledError extends Error {
|
|
60
|
+
code = "TENZRO_NOT_INSTALLED";
|
|
61
|
+
constructor(message) {
|
|
62
|
+
super(message);
|
|
63
|
+
this.name = "TenzroNotInstalledError";
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.TenzroNotInstalledError = TenzroN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MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;YACnC,IAAI,OAAO;gBAAE,OAAO;YACpB,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,CAAC,mBAAmB,CAAC,0BAA0B,EAAE,UAAU,CAAC,CAAC;YACnE,MAAM,CACJ,IAAI,uBAAuB,CACzB,mCAAmC,QAAQ,sBAAsB,SAAS,IAAI,CAC/E,CACF,CAAC;QACJ,CAAC,EAAE,SAAS,CAAC,CAAC;IAChB,CAAC,CAAC,CAAC;AACL,CAAC;AAED;;;;;;;GAOG;AACH,MAAa,uBAAwB,SAAQ,KAAK;IACvC,IAAI,GAAG,sBAA+B,CAAC;IAEhD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACxC,CAAC;CACF;AAPD,0DAOC"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { RpcClient } from './rpc';
|
|
2
|
+
/**
|
|
3
|
+
* Deterministic agent id derived from a Tenzro DID via
|
|
4
|
+
* `keccak256(utf8(did))`.
|
|
5
|
+
*/
|
|
6
|
+
export interface Erc8004AgentId {
|
|
7
|
+
/** DID echoed back. */
|
|
8
|
+
did: string;
|
|
9
|
+
/** 32-byte agent id as 0x-prefixed hex. */
|
|
10
|
+
agent_id: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Hex-encoded ABI calldata ready for `eth_sendRawTransaction` / `eth_call`.
|
|
14
|
+
*/
|
|
15
|
+
export interface Erc8004Calldata {
|
|
16
|
+
/** Full hex-encoded calldata (selector + abi-encoded args). */
|
|
17
|
+
calldata: string;
|
|
18
|
+
/** Echoed agent id from `encodeRegister`; empty for other encoders. */
|
|
19
|
+
agent_id?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Decoded agent record returned by `IdentityRegistry.getAgent()`.
|
|
23
|
+
*/
|
|
24
|
+
export interface Erc8004Agent {
|
|
25
|
+
/** Agent owner / controller address. */
|
|
26
|
+
agent_address: string;
|
|
27
|
+
/** Off-chain metadata URI (e.g. IPFS, HTTPS). */
|
|
28
|
+
metadata_uri: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Decoded `bytes` value returned by `IdentityRegistry.getMetadata()`.
|
|
32
|
+
*/
|
|
33
|
+
export interface Erc8004Metadata {
|
|
34
|
+
/** Hex-encoded value (`0x` prefix), or empty hex when unset. */
|
|
35
|
+
metadata_value: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Client for the ERC-8004 Trustless Agents Registry family
|
|
39
|
+
* (IdentityRegistry, ReputationRegistry, ValidationRegistry).
|
|
40
|
+
*
|
|
41
|
+
* Covers the canonical v0.6+ surface — base register/feedback/validation
|
|
42
|
+
* plus `setAgentURI` / `setAgentWallet` / `setMetadata` / `getMetadata`
|
|
43
|
+
* / `getAgentURI` / `getAgentWallet` / `revokeFeedback` /
|
|
44
|
+
* `appendResponse` / `isFeedbackRevoked` / `getFeedbackResponses` /
|
|
45
|
+
* `getFeedback` / `getFeedbackCount` / `getValidation`.
|
|
46
|
+
*
|
|
47
|
+
* All `encode*` methods return hex calldata that callers can sign and
|
|
48
|
+
* broadcast through any EVM wallet. `decode*` helpers round-trip
|
|
49
|
+
* return data from `eth_call` into typed structs.
|
|
50
|
+
*/
|
|
51
|
+
export declare class Erc8004Client {
|
|
52
|
+
private readonly rpc;
|
|
53
|
+
constructor(rpc: RpcClient);
|
|
54
|
+
/** Derive a canonical ERC-8004 `agentId = keccak256(utf8(did))`. */
|
|
55
|
+
deriveAgentId(did: string): Promise<Erc8004AgentId>;
|
|
56
|
+
/** ABI-encode `IdentityRegistry.registerAgent(bytes32 agentId, address agentAddress, string metadataURI)`. */
|
|
57
|
+
encodeRegister(did: string, agentAddress: string, metadataUri: string): Promise<Erc8004Calldata>;
|
|
58
|
+
/** ABI-encode `IdentityRegistry.getAgent(bytes32 agentId)`. */
|
|
59
|
+
encodeGetAgent(agentId: string): Promise<Erc8004Calldata>;
|
|
60
|
+
/** Decode `(address, string)` returndata from `getAgent()`. */
|
|
61
|
+
decodeGetAgent(returnData: string): Promise<Erc8004Agent>;
|
|
62
|
+
/** ABI-encode `IdentityRegistry.setAgentURI(uint256 agentId, string metadataURI)`. */
|
|
63
|
+
encodeSetAgentURI(agentId: string, metadataUri: string): Promise<Erc8004Calldata>;
|
|
64
|
+
/** ABI-encode `IdentityRegistry.setAgentWallet(uint256 agentId, address newWallet, uint256 deadline, bytes signature)`. */
|
|
65
|
+
encodeSetAgentWallet(agentId: string, newWallet: string, deadline: number, signature: string): Promise<Erc8004Calldata>;
|
|
66
|
+
/** ABI-encode `IdentityRegistry.setMetadata(uint256 agentId, string metadataKey, bytes metadataValue)`. */
|
|
67
|
+
encodeSetMetadata(agentId: string, metadataKey: string, metadataValue: string): Promise<Erc8004Calldata>;
|
|
68
|
+
/** ABI-encode `IdentityRegistry.getMetadata(uint256 agentId, string metadataKey)`. */
|
|
69
|
+
encodeGetMetadata(agentId: string, metadataKey: string): Promise<Erc8004Calldata>;
|
|
70
|
+
/** Decode `bytes` returndata from `getMetadata()`. */
|
|
71
|
+
decodeGetMetadata(returnData: string): Promise<Erc8004Metadata>;
|
|
72
|
+
/** ABI-encode `IdentityRegistry.getAgentURI(uint256 agentId)`. */
|
|
73
|
+
encodeGetAgentURI(agentId: string): Promise<Erc8004Calldata>;
|
|
74
|
+
/** ABI-encode `IdentityRegistry.getAgentWallet(uint256 agentId)`. */
|
|
75
|
+
encodeGetAgentWallet(agentId: string): Promise<Erc8004Calldata>;
|
|
76
|
+
/** ABI-encode `ReputationRegistry.submitFeedback(bytes32 subjectAgentId, int8 rating, string contextURI)`. */
|
|
77
|
+
encodeFeedback(subjectAgentId: string, rating: number, contextUri: string): Promise<Erc8004Calldata>;
|
|
78
|
+
/** ABI-encode `ReputationRegistry.getFeedback(bytes32 subject, uint256 index)`. */
|
|
79
|
+
encodeGetFeedback(subjectAgentId: string, index: number): Promise<Erc8004Calldata>;
|
|
80
|
+
/** ABI-encode `ReputationRegistry.getFeedbackCount(bytes32 subject)`. */
|
|
81
|
+
encodeGetFeedbackCount(subjectAgentId: string): Promise<Erc8004Calldata>;
|
|
82
|
+
/** ABI-encode `ReputationRegistry.revokeFeedback(uint256 agentId, bytes32 feedbackId)` (v0.6+). */
|
|
83
|
+
encodeRevokeFeedback(agentId: string, feedbackId: string): Promise<Erc8004Calldata>;
|
|
84
|
+
/** ABI-encode `ReputationRegistry.appendResponse(uint256 agentId, bytes32 feedbackId, string responseURI)` (v0.6+). */
|
|
85
|
+
encodeAppendResponse(agentId: string, feedbackId: string, responseUri: string): Promise<Erc8004Calldata>;
|
|
86
|
+
/** ABI-encode `ReputationRegistry.isFeedbackRevoked(uint256 agentId, bytes32 feedbackId)` (v0.6+). */
|
|
87
|
+
encodeIsFeedbackRevoked(agentId: string, feedbackId: string): Promise<Erc8004Calldata>;
|
|
88
|
+
/** ABI-encode `ReputationRegistry.getFeedbackResponses(uint256 agentId, bytes32 feedbackId)` (v0.6+). */
|
|
89
|
+
encodeGetFeedbackResponses(agentId: string, feedbackId: string): Promise<Erc8004Calldata>;
|
|
90
|
+
/** ABI-encode `ValidationRegistry.validationRequest(address validatorAddress, uint256 agentId, string requestURI, bytes32 requestHash)`. */
|
|
91
|
+
encodeValidationRequest(validatorAddress: string, agentId: string, requestUri: string, requestHash: string): Promise<Erc8004Calldata>;
|
|
92
|
+
/** ABI-encode `ValidationRegistry.validationResponse(bytes32 requestHash, uint8 response, string responseURI, bytes32 responseHash, string tag)`. `response` is a 0-100 quality score. */
|
|
93
|
+
encodeValidationResponse(requestHash: string, response: number, responseUri: string, responseHash: string, tag: string): Promise<Erc8004Calldata>;
|
|
94
|
+
/** ABI-encode `ValidationRegistry.getValidation(bytes32 requestHash)`. */
|
|
95
|
+
encodeGetValidation(requestHash: string): Promise<Erc8004Calldata>;
|
|
96
|
+
}
|
|
97
|
+
//# source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