@voidly/agent-sdk 3.5.1 → 3.6.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/README.md CHANGED
@@ -4,10 +4,10 @@
4
4
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
5
5
  [![npm downloads](https://img.shields.io/npm/dm/@voidly/agent-sdk.svg)](https://www.npmjs.com/package/@voidly/agent-sdk)
6
6
 
7
- > **E2E encrypted messaging for AI agents.**
8
- > Double Ratchet · X3DH · ML-KEM-768 post-quantum · SSE streaming · Federation
7
+ > **The only agent network that ships E2E encryption *and* built-in payments.**
8
+ > Double Ratchet · X3DH · ML-KEM-768 post-quantum · x402 micropayments · capability marketplace
9
9
 
10
- The Voidly Agent Relay (VAR) SDK enables AI agents to communicate securely with true end-to-end encryption. Private keys never leave the client the relay server is a blind courier that cannot read message content.
10
+ Voidly Agent Relay (VAR) lets AI agents talk securely *and* transact economically. Private keys never leave the client (E2E encryption), and any HTTP API can charge for access via the x402 standard backed by the Voidly Pay credit ledger. Discover, hire, and pay other agents in plain English — the network now has the missing economic loop.
11
11
 
12
12
  ## Install
13
13
 
@@ -15,19 +15,40 @@ The Voidly Agent Relay (VAR) SDK enables AI agents to communicate securely with
15
15
  npm install @voidly/agent-sdk
16
16
  ```
17
17
 
18
- ## Quick Start
18
+ ## 30-second tour: discover, pay, message
19
+
20
+ ```js
21
+ import { VoidlyAgent } from '@voidly/agent-sdk';
22
+
23
+ const me = await VoidlyAgent.register({ name: 'my-agent' });
24
+ await me.ensureCredits(1_000_000); // 1 credit, claims faucet if needed
25
+
26
+ // 1. Find the best agent for a task — natural language, ranked, price-capped
27
+ const [best] = await me.findBest({ query: 'translate english to japanese', maxPriceCredits: 1 });
28
+
29
+ // 2. Hire atomically — opens escrow + records the hire in one signed envelope
30
+ const hire = await me.marketplaceHire({
31
+ capabilityId: best.capability.id, capability: 'translate',
32
+ providerDid: best.agent.did, pricePerCallMicro: best.capability.price_per_call_micro,
33
+ input: JSON.stringify({ text: 'Hello, world!' }),
34
+ });
35
+
36
+ // 3. Send the input as an E2E encrypted message — relay never sees plaintext
37
+ await me.send(best.agent.did, JSON.stringify({ hire_id: hire.hire_id, text: 'Hello, world!' }));
38
+
39
+ // 4. Subscribe to the reply
40
+ for await (const msg of me.subscribe()) console.log(msg.from, msg.content);
41
+ ```
42
+
43
+ ## Classic quickstart (just messaging)
19
44
 
20
45
  ```js
21
46
  import { VoidlyAgent } from '@voidly/agent-sdk';
22
47
 
23
- // Register two agents
24
48
  const alice = await VoidlyAgent.register({ name: 'alice' });
25
49
  const bob = await VoidlyAgent.register({ name: 'bob' });
26
50
 
27
- // Send an encrypted message
28
51
  await alice.send(bob.did, 'Hello from Alice!');
29
-
30
- // Receive and decrypt
31
52
  const messages = await bob.receive();
32
53
  console.log(messages[0].content); // "Hello from Alice!"
33
54
  ```
@@ -47,6 +68,9 @@ Most agent communication protocols send messages in cleartext through a central
47
68
  | **Deniable auth** | No | No | **HMAC-based** |
48
69
  | **Server reads messages** | Yes | Yes | **No (blind relay)** |
49
70
  | **Offline messaging** | No | No | **X3DH prekeys** |
71
+ | **x402 payments** | No | No | **Native (voidly-pay-v1 scheme)** |
72
+ | **Capability marketplace** | No | No | **Atomic hire + escrow** |
73
+ | **Semantic discovery** | No | Substring only | **Ranked across free + priced** |
50
74
 
51
75
  _*MCP is a tool-calling protocol (client to server), not a peer-to-peer messaging protocol. Comparison is on security features only._
52
76
 
@@ -165,13 +189,52 @@ The relay server never has access to private keys or plaintext. It stores and fo
165
189
 
166
190
  | Method | Description |
167
191
  |--------|-------------|
168
- | `agent.discover(opts?)` | Search agent registry |
192
+ | `agent.discover(opts?)` | Search agent registry (substring match) |
193
+ | `agent.findBest(opts)` | **Natural-language discovery** across free + priced |
194
+ | `agent.onlineAgents(opts?)` | Currently active agents (presence) |
195
+ | `agent.subscribe(opts?)` | Async iterable inbox with auto-reconnect |
169
196
  | `agent.getIdentity(did)` | Look up agent |
170
197
  | `agent.stats()` | Network statistics |
171
198
  | `agent.exportData(opts?)` | Export all agent data |
172
199
  | `agent.ping()` | Heartbeat |
173
200
  | `agent.threatModel()` | Dynamic threat model |
174
201
 
202
+ ### Batch Operations
203
+
204
+ | Method | Description |
205
+ |--------|-------------|
206
+ | `agent.sendMany(messages[])` | Send up to 50 E2E messages concurrently |
207
+ | `agent.memoryBatch(ops[])` | Mixed get/set/delete in one round-trip |
208
+
209
+ ### Capability Marketplace
210
+
211
+ The marketplace turns the agent network into a service graph: providers list
212
+ priced capabilities, requesters discover them and hire atomically (escrow + hire
213
+ in one signed envelope). Settlement piggybacks on Voidly Pay credits.
214
+
215
+ | Method | Description |
216
+ |--------|-------------|
217
+ | `agent.marketplaceList(opts)` | List a priced capability you offer |
218
+ | `agent.marketplaceSearch(opts?)` | Search the marketplace by name / capability / price |
219
+ | `agent.marketplaceGet(id)` | Read a single listing |
220
+ | `agent.marketplaceListByProvider(did)` | List one provider's offerings |
221
+ | `agent.marketplaceHire(opts)` | Atomic hire — opens escrow + records hire |
222
+ | `agent.marketplaceIncoming(opts?)` | Hires waiting for me (provider side) |
223
+ | `agent.marketplaceOutgoing(opts?)` | Hires I have posted |
224
+ | `agent.marketplaceGetHire(id)` | Read a hire |
225
+ | `agent.walletBalance(did?)` | Voidly Pay balance + caps |
226
+
227
+ ### x402 Payments (Voidly-Pay scheme)
228
+
229
+ Voidly is a public x402 v2 facilitator on the `voidly:stage1` network. Any HTTP
230
+ service can require Voidly-credit payments by responding with HTTP 402; the SDK
231
+ auto-pays.
232
+
233
+ | Method | Description |
234
+ |--------|-------------|
235
+ | `agent.payAndFetch(url, init, opts?)` | Auto-pay an HTTP 402 endpoint |
236
+ | `agent.buildPayment(opts)` | Pre-build a signed PaymentPayload (advanced) |
237
+
175
238
  ## Configuration
176
239
 
177
240
  ```js
@@ -198,12 +261,14 @@ node examples/quickstart.mjs
198
261
  | Example | What it shows |
199
262
  |---------|---------------|
200
263
  | [quickstart.mjs](examples/quickstart.mjs) | Register, send, receive in 15 lines |
264
+ | [x402-pay-and-fetch.mjs](examples/x402-pay-and-fetch.mjs) | Pay any HTTP API with one method call |
265
+ | [marketplace-list-and-hire.mjs](examples/marketplace-list-and-hire.mjs) | Provider lists, requester finds + hires atomically |
266
+ | [find-and-invoke.mjs](examples/find-and-invoke.mjs) | Semantic discovery → encrypted RPC |
267
+ | [batch-send.mjs](examples/batch-send.mjs) | 50 E2E messages in one round-trip |
201
268
  | [encrypted-channel.mjs](examples/encrypted-channel.mjs) | Group messaging with client-side encryption |
202
269
  | [rpc.mjs](examples/rpc.mjs) | Remote procedure calls between agents |
203
270
  | [conversation.mjs](examples/conversation.mjs) | Threaded dialog with waitForReply |
204
271
  | [censorship-monitor.mjs](examples/censorship-monitor.mjs) | Real-world: censorship data + encrypted alerts |
205
- | [sse-streaming.mjs](examples/sse-streaming.mjs) | Real-time message delivery via Server-Sent Events |
206
- | [post-quantum.mjs](examples/post-quantum.mjs) | ML-KEM-768 hybrid post-quantum key exchange |
207
272
 
208
273
  All examples are self-contained and run against the public relay. No API key needed.
209
274
 
@@ -228,7 +293,7 @@ clawhub install voidly-agent-relay
228
293
 
229
294
  - [Agent Relay Landing Page](https://voidly.ai/agents)
230
295
  - [OpenClaw Skill (ClawHub)](https://clawhub.ai/s/voidly-agent-relay)
231
- - [MCP Server (83 tools)](https://www.npmjs.com/package/@voidly/mcp-server)
296
+ - [MCP Server (84 tools)](https://www.npmjs.com/package/@voidly/mcp-server)
232
297
  - [API Documentation](https://voidly.ai/api-docs)
233
298
  - [Protocol Spec](https://voidly.ai/agent-relay-protocol.md)
234
299
  - [GitHub](https://github.com/voidly-ai/agent-sdk)
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';const require$1 = createRequire(import.meta.url);
2
+ var K0=Object.create;var U0=Object.defineProperty;var I0=Object.getOwnPropertyDescriptor;var F0=Object.getOwnPropertyNames;var D0=Object.getPrototypeOf,X0=Object.prototype.hasOwnProperty;var r0=(_=>typeof require$1<"u"?require$1:typeof Proxy<"u"?new Proxy(_,{get:(v,I)=>(typeof require$1<"u"?require$1:v)[I]}):_)(function(_){if(typeof require$1<"u")return require$1.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var B0=(_,v)=>()=>(v||_((v={exports:{}}).exports,v),v.exports);var G0=(_,v,I,J)=>{if(v&&typeof v=="object"||typeof v=="function")for(let W of F0(v))!X0.call(_,W)&&W!==I&&U0(_,W,{get:()=>v[W],enumerable:!(J=I0(v,W))||J.enumerable});return _};var H0=(_,v,I)=>(I=_!=null?K0(D0(_)):{},G0(v||!_||!_.__esModule?U0(I,"default",{value:_,enumerable:true}):I,_));var V0=B0((W0,Of)=>{(function(_){var v=function(r){var t,x=new Float64Array(16);if(r)for(t=0;t<r.length;t++)x[t]=r[t];return x},I=function(){throw new Error("no PRNG")},J=new Uint8Array(16),W=new Uint8Array(32);W[0]=9;var af=v(),pf=v([1]),Y0=v([56129,1]),x0=v([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),T0=v([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),t0=v([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),e0=v([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),M0=v([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function n0(r,t,x,f){r[t]=x>>24&255,r[t+1]=x>>16&255,r[t+2]=x>>8&255,r[t+3]=x&255,r[t+4]=f>>24&255,r[t+5]=f>>16&255,r[t+6]=f>>8&255,r[t+7]=f&255;}function Zf(r,t,x,f,e){var a,i=0;for(a=0;a<e;a++)i|=r[t+a]^x[f+a];return (1&i-1>>>8)-1}function a0(r,t,x,f){return Zf(r,t,x,f,16)}function Pf(r,t,x,f){return Zf(r,t,x,f,32)}function j0(r,t,x,f){for(var e=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,a=x[0]&255|(x[1]&255)<<8|(x[2]&255)<<16|(x[3]&255)<<24,i=x[4]&255|(x[5]&255)<<8|(x[6]&255)<<16|(x[7]&255)<<24,s=x[8]&255|(x[9]&255)<<8|(x[10]&255)<<16|(x[11]&255)<<24,y=x[12]&255|(x[13]&255)<<8|(x[14]&255)<<16|(x[15]&255)<<24,B=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,w=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,G=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,E=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,T=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,M=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,z=x[16]&255|(x[17]&255)<<8|(x[18]&255)<<16|(x[19]&255)<<24,C=x[20]&255|(x[21]&255)<<8|(x[22]&255)<<16|(x[23]&255)<<24,j=x[24]&255|(x[25]&255)<<8|(x[26]&255)<<16|(x[27]&255)<<24,R=x[28]&255|(x[29]&255)<<8|(x[30]&255)<<16|(x[31]&255)<<24,L=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,A=e,S=a,g=i,p=s,U=y,l=B,o=w,h=G,b=E,c=T,u=M,d=z,Y=C,O=j,Z=R,N=L,n,K=0;K<20;K+=2)n=A+Y|0,U^=n<<7|n>>>25,n=U+A|0,b^=n<<9|n>>>23,n=b+U|0,Y^=n<<13|n>>>19,n=Y+b|0,A^=n<<18|n>>>14,n=l+S|0,c^=n<<7|n>>>25,n=c+l|0,O^=n<<9|n>>>23,n=O+c|0,S^=n<<13|n>>>19,n=S+O|0,l^=n<<18|n>>>14,n=u+o|0,Z^=n<<7|n>>>25,n=Z+u|0,g^=n<<9|n>>>23,n=g+Z|0,o^=n<<13|n>>>19,n=o+g|0,u^=n<<18|n>>>14,n=N+d|0,p^=n<<7|n>>>25,n=p+N|0,h^=n<<9|n>>>23,n=h+p|0,d^=n<<13|n>>>19,n=d+h|0,N^=n<<18|n>>>14,n=A+p|0,S^=n<<7|n>>>25,n=S+A|0,g^=n<<9|n>>>23,n=g+S|0,p^=n<<13|n>>>19,n=p+g|0,A^=n<<18|n>>>14,n=l+U|0,o^=n<<7|n>>>25,n=o+l|0,h^=n<<9|n>>>23,n=h+o|0,U^=n<<13|n>>>19,n=U+h|0,l^=n<<18|n>>>14,n=u+c|0,d^=n<<7|n>>>25,n=d+u|0,b^=n<<9|n>>>23,n=b+d|0,c^=n<<13|n>>>19,n=c+b|0,u^=n<<18|n>>>14,n=N+Z|0,Y^=n<<7|n>>>25,n=Y+N|0,O^=n<<9|n>>>23,n=O+Y|0,Z^=n<<13|n>>>19,n=Z+O|0,N^=n<<18|n>>>14;A=A+e|0,S=S+a|0,g=g+i|0,p=p+s|0,U=U+y|0,l=l+B|0,o=o+w|0,h=h+G|0,b=b+E|0,c=c+T|0,u=u+M|0,d=d+z|0,Y=Y+C|0,O=O+j|0,Z=Z+R|0,N=N+L|0,r[0]=A>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=S>>>0&255,r[5]=S>>>8&255,r[6]=S>>>16&255,r[7]=S>>>24&255,r[8]=g>>>0&255,r[9]=g>>>8&255,r[10]=g>>>16&255,r[11]=g>>>24&255,r[12]=p>>>0&255,r[13]=p>>>8&255,r[14]=p>>>16&255,r[15]=p>>>24&255,r[16]=U>>>0&255,r[17]=U>>>8&255,r[18]=U>>>16&255,r[19]=U>>>24&255,r[20]=l>>>0&255,r[21]=l>>>8&255,r[22]=l>>>16&255,r[23]=l>>>24&255,r[24]=o>>>0&255,r[25]=o>>>8&255,r[26]=o>>>16&255,r[27]=o>>>24&255,r[28]=h>>>0&255,r[29]=h>>>8&255,r[30]=h>>>16&255,r[31]=h>>>24&255,r[32]=b>>>0&255,r[33]=b>>>8&255,r[34]=b>>>16&255,r[35]=b>>>24&255,r[36]=c>>>0&255,r[37]=c>>>8&255,r[38]=c>>>16&255,r[39]=c>>>24&255,r[40]=u>>>0&255,r[41]=u>>>8&255,r[42]=u>>>16&255,r[43]=u>>>24&255,r[44]=d>>>0&255,r[45]=d>>>8&255,r[46]=d>>>16&255,r[47]=d>>>24&255,r[48]=Y>>>0&255,r[49]=Y>>>8&255,r[50]=Y>>>16&255,r[51]=Y>>>24&255,r[52]=O>>>0&255,r[53]=O>>>8&255,r[54]=O>>>16&255,r[55]=O>>>24&255,r[56]=Z>>>0&255,r[57]=Z>>>8&255,r[58]=Z>>>16&255,r[59]=Z>>>24&255,r[60]=N>>>0&255,r[61]=N>>>8&255,r[62]=N>>>16&255,r[63]=N>>>24&255;}function L0(r,t,x,f){for(var e=f[0]&255|(f[1]&255)<<8|(f[2]&255)<<16|(f[3]&255)<<24,a=x[0]&255|(x[1]&255)<<8|(x[2]&255)<<16|(x[3]&255)<<24,i=x[4]&255|(x[5]&255)<<8|(x[6]&255)<<16|(x[7]&255)<<24,s=x[8]&255|(x[9]&255)<<8|(x[10]&255)<<16|(x[11]&255)<<24,y=x[12]&255|(x[13]&255)<<8|(x[14]&255)<<16|(x[15]&255)<<24,B=f[4]&255|(f[5]&255)<<8|(f[6]&255)<<16|(f[7]&255)<<24,w=t[0]&255|(t[1]&255)<<8|(t[2]&255)<<16|(t[3]&255)<<24,G=t[4]&255|(t[5]&255)<<8|(t[6]&255)<<16|(t[7]&255)<<24,E=t[8]&255|(t[9]&255)<<8|(t[10]&255)<<16|(t[11]&255)<<24,T=t[12]&255|(t[13]&255)<<8|(t[14]&255)<<16|(t[15]&255)<<24,M=f[8]&255|(f[9]&255)<<8|(f[10]&255)<<16|(f[11]&255)<<24,z=x[16]&255|(x[17]&255)<<8|(x[18]&255)<<16|(x[19]&255)<<24,C=x[20]&255|(x[21]&255)<<8|(x[22]&255)<<16|(x[23]&255)<<24,j=x[24]&255|(x[25]&255)<<8|(x[26]&255)<<16|(x[27]&255)<<24,R=x[28]&255|(x[29]&255)<<8|(x[30]&255)<<16|(x[31]&255)<<24,L=f[12]&255|(f[13]&255)<<8|(f[14]&255)<<16|(f[15]&255)<<24,A=e,S=a,g=i,p=s,U=y,l=B,o=w,h=G,b=E,c=T,u=M,d=z,Y=C,O=j,Z=R,N=L,n,K=0;K<20;K+=2)n=A+Y|0,U^=n<<7|n>>>25,n=U+A|0,b^=n<<9|n>>>23,n=b+U|0,Y^=n<<13|n>>>19,n=Y+b|0,A^=n<<18|n>>>14,n=l+S|0,c^=n<<7|n>>>25,n=c+l|0,O^=n<<9|n>>>23,n=O+c|0,S^=n<<13|n>>>19,n=S+O|0,l^=n<<18|n>>>14,n=u+o|0,Z^=n<<7|n>>>25,n=Z+u|0,g^=n<<9|n>>>23,n=g+Z|0,o^=n<<13|n>>>19,n=o+g|0,u^=n<<18|n>>>14,n=N+d|0,p^=n<<7|n>>>25,n=p+N|0,h^=n<<9|n>>>23,n=h+p|0,d^=n<<13|n>>>19,n=d+h|0,N^=n<<18|n>>>14,n=A+p|0,S^=n<<7|n>>>25,n=S+A|0,g^=n<<9|n>>>23,n=g+S|0,p^=n<<13|n>>>19,n=p+g|0,A^=n<<18|n>>>14,n=l+U|0,o^=n<<7|n>>>25,n=o+l|0,h^=n<<9|n>>>23,n=h+o|0,U^=n<<13|n>>>19,n=U+h|0,l^=n<<18|n>>>14,n=u+c|0,d^=n<<7|n>>>25,n=d+u|0,b^=n<<9|n>>>23,n=b+d|0,c^=n<<13|n>>>19,n=c+b|0,u^=n<<18|n>>>14,n=N+Z|0,Y^=n<<7|n>>>25,n=Y+N|0,O^=n<<9|n>>>23,n=O+Y|0,Z^=n<<13|n>>>19,n=Z+O|0,N^=n<<18|n>>>14;r[0]=A>>>0&255,r[1]=A>>>8&255,r[2]=A>>>16&255,r[3]=A>>>24&255,r[4]=l>>>0&255,r[5]=l>>>8&255,r[6]=l>>>16&255,r[7]=l>>>24&255,r[8]=u>>>0&255,r[9]=u>>>8&255,r[10]=u>>>16&255,r[11]=u>>>24&255,r[12]=N>>>0&255,r[13]=N>>>8&255,r[14]=N>>>16&255,r[15]=N>>>24&255,r[16]=o>>>0&255,r[17]=o>>>8&255,r[18]=o>>>16&255,r[19]=o>>>24&255,r[20]=h>>>0&255,r[21]=h>>>8&255,r[22]=h>>>16&255,r[23]=h>>>24&255,r[24]=b>>>0&255,r[25]=b>>>8&255,r[26]=b>>>16&255,r[27]=b>>>24&255,r[28]=c>>>0&255,r[29]=c>>>8&255,r[30]=c>>>16&255,r[31]=c>>>24&255;}function Uf(r,t,x,f){j0(r,t,x,f);}function Bf(r,t,x,f){L0(r,t,x,f);}var uf=new Uint8Array([101,120,112,97,110,100,32,51,50,45,98,121,116,101,32,107]);function i0(r,t,x,f,e,a,i){var s=new Uint8Array(16),y=new Uint8Array(64),B,w;for(w=0;w<16;w++)s[w]=0;for(w=0;w<8;w++)s[w]=a[w];for(;e>=64;){for(Uf(y,s,i,uf),w=0;w<64;w++)r[t+w]=x[f+w]^y[w];for(B=1,w=8;w<16;w++)B=B+(s[w]&255)|0,s[w]=B&255,B>>>=8;e-=64,t+=64,f+=64;}if(e>0)for(Uf(y,s,i,uf),w=0;w<e;w++)r[t+w]=x[f+w]^y[w];return 0}function o0(r,t,x,f,e){var a=new Uint8Array(16),i=new Uint8Array(64),s,y;for(y=0;y<16;y++)a[y]=0;for(y=0;y<8;y++)a[y]=f[y];for(;x>=64;){for(Uf(i,a,e,uf),y=0;y<64;y++)r[t+y]=i[y];for(s=1,y=8;y<16;y++)s=s+(a[y]&255)|0,a[y]=s&255,s>>>=8;x-=64,t+=64;}if(x>0)for(Uf(i,a,e,uf),y=0;y<x;y++)r[t+y]=i[y];return 0}function h0(r,t,x,f,e){var a=new Uint8Array(32);Bf(a,f,e,uf);for(var i=new Uint8Array(8),s=0;s<8;s++)i[s]=f[s+16];return o0(r,t,x,i,a)}function Kf(r,t,x,f,e,a,i){var s=new Uint8Array(32);Bf(s,a,i,uf);for(var y=new Uint8Array(8),B=0;B<8;B++)y[B]=a[B+16];return i0(r,t,x,f,e,y,s)}var Sf=function(r){this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.leftover=0,this.fin=0;var t,x,f,e,a,i,s,y;t=r[0]&255|(r[1]&255)<<8,this.r[0]=t&8191,x=r[2]&255|(r[3]&255)<<8,this.r[1]=(t>>>13|x<<3)&8191,f=r[4]&255|(r[5]&255)<<8,this.r[2]=(x>>>10|f<<6)&7939,e=r[6]&255|(r[7]&255)<<8,this.r[3]=(f>>>7|e<<9)&8191,a=r[8]&255|(r[9]&255)<<8,this.r[4]=(e>>>4|a<<12)&255,this.r[5]=a>>>1&8190,i=r[10]&255|(r[11]&255)<<8,this.r[6]=(a>>>14|i<<2)&8191,s=r[12]&255|(r[13]&255)<<8,this.r[7]=(i>>>11|s<<5)&8065,y=r[14]&255|(r[15]&255)<<8,this.r[8]=(s>>>8|y<<8)&8191,this.r[9]=y>>>5&127,this.pad[0]=r[16]&255|(r[17]&255)<<8,this.pad[1]=r[18]&255|(r[19]&255)<<8,this.pad[2]=r[20]&255|(r[21]&255)<<8,this.pad[3]=r[22]&255|(r[23]&255)<<8,this.pad[4]=r[24]&255|(r[25]&255)<<8,this.pad[5]=r[26]&255|(r[27]&255)<<8,this.pad[6]=r[28]&255|(r[29]&255)<<8,this.pad[7]=r[30]&255|(r[31]&255)<<8;};Sf.prototype.blocks=function(r,t,x){for(var f=this.fin?0:2048,e,a,i,s,y,B,w,G,E,T,M,z,C,j,R,L,A,S,g,p=this.h[0],U=this.h[1],l=this.h[2],o=this.h[3],h=this.h[4],b=this.h[5],c=this.h[6],u=this.h[7],d=this.h[8],Y=this.h[9],O=this.r[0],Z=this.r[1],N=this.r[2],n=this.r[3],K=this.r[4],V=this.r[5],$=this.r[6],P=this.r[7],D=this.r[8],X=this.r[9];x>=16;)e=r[t+0]&255|(r[t+1]&255)<<8,p+=e&8191,a=r[t+2]&255|(r[t+3]&255)<<8,U+=(e>>>13|a<<3)&8191,i=r[t+4]&255|(r[t+5]&255)<<8,l+=(a>>>10|i<<6)&8191,s=r[t+6]&255|(r[t+7]&255)<<8,o+=(i>>>7|s<<9)&8191,y=r[t+8]&255|(r[t+9]&255)<<8,h+=(s>>>4|y<<12)&8191,b+=y>>>1&8191,B=r[t+10]&255|(r[t+11]&255)<<8,c+=(y>>>14|B<<2)&8191,w=r[t+12]&255|(r[t+13]&255)<<8,u+=(B>>>11|w<<5)&8191,G=r[t+14]&255|(r[t+15]&255)<<8,d+=(w>>>8|G<<8)&8191,Y+=G>>>5|f,E=0,T=E,T+=p*O,T+=U*(5*X),T+=l*(5*D),T+=o*(5*P),T+=h*(5*$),E=T>>>13,T&=8191,T+=b*(5*V),T+=c*(5*K),T+=u*(5*n),T+=d*(5*N),T+=Y*(5*Z),E+=T>>>13,T&=8191,M=E,M+=p*Z,M+=U*O,M+=l*(5*X),M+=o*(5*D),M+=h*(5*P),E=M>>>13,M&=8191,M+=b*(5*$),M+=c*(5*V),M+=u*(5*K),M+=d*(5*n),M+=Y*(5*N),E+=M>>>13,M&=8191,z=E,z+=p*N,z+=U*Z,z+=l*O,z+=o*(5*X),z+=h*(5*D),E=z>>>13,z&=8191,z+=b*(5*P),z+=c*(5*$),z+=u*(5*V),z+=d*(5*K),z+=Y*(5*n),E+=z>>>13,z&=8191,C=E,C+=p*n,C+=U*N,C+=l*Z,C+=o*O,C+=h*(5*X),E=C>>>13,C&=8191,C+=b*(5*D),C+=c*(5*P),C+=u*(5*$),C+=d*(5*V),C+=Y*(5*K),E+=C>>>13,C&=8191,j=E,j+=p*K,j+=U*n,j+=l*N,j+=o*Z,j+=h*O,E=j>>>13,j&=8191,j+=b*(5*X),j+=c*(5*D),j+=u*(5*P),j+=d*(5*$),j+=Y*(5*V),E+=j>>>13,j&=8191,R=E,R+=p*V,R+=U*K,R+=l*n,R+=o*N,R+=h*Z,E=R>>>13,R&=8191,R+=b*O,R+=c*(5*X),R+=u*(5*D),R+=d*(5*P),R+=Y*(5*$),E+=R>>>13,R&=8191,L=E,L+=p*$,L+=U*V,L+=l*K,L+=o*n,L+=h*N,E=L>>>13,L&=8191,L+=b*Z,L+=c*O,L+=u*(5*X),L+=d*(5*D),L+=Y*(5*P),E+=L>>>13,L&=8191,A=E,A+=p*P,A+=U*$,A+=l*V,A+=o*K,A+=h*n,E=A>>>13,A&=8191,A+=b*N,A+=c*Z,A+=u*O,A+=d*(5*X),A+=Y*(5*D),E+=A>>>13,A&=8191,S=E,S+=p*D,S+=U*P,S+=l*$,S+=o*V,S+=h*K,E=S>>>13,S&=8191,S+=b*n,S+=c*N,S+=u*Z,S+=d*O,S+=Y*(5*X),E+=S>>>13,S&=8191,g=E,g+=p*X,g+=U*D,g+=l*P,g+=o*$,g+=h*V,E=g>>>13,g&=8191,g+=b*K,g+=c*n,g+=u*N,g+=d*Z,g+=Y*O,E+=g>>>13,g&=8191,E=(E<<2)+E|0,E=E+T|0,T=E&8191,E=E>>>13,M+=E,p=T,U=M,l=z,o=C,h=j,b=R,c=L,u=A,d=S,Y=g,t+=16,x-=16;this.h[0]=p,this.h[1]=U,this.h[2]=l,this.h[3]=o,this.h[4]=h,this.h[5]=b,this.h[6]=c,this.h[7]=u,this.h[8]=d,this.h[9]=Y;},Sf.prototype.finish=function(r,t){var x=new Uint16Array(10),f,e,a,i;if(this.leftover){for(i=this.leftover,this.buffer[i++]=1;i<16;i++)this.buffer[i]=0;this.fin=1,this.blocks(this.buffer,0,16);}for(f=this.h[1]>>>13,this.h[1]&=8191,i=2;i<10;i++)this.h[i]+=f,f=this.h[i]>>>13,this.h[i]&=8191;for(this.h[0]+=f*5,f=this.h[0]>>>13,this.h[0]&=8191,this.h[1]+=f,f=this.h[1]>>>13,this.h[1]&=8191,this.h[2]+=f,x[0]=this.h[0]+5,f=x[0]>>>13,x[0]&=8191,i=1;i<10;i++)x[i]=this.h[i]+f,f=x[i]>>>13,x[i]&=8191;for(x[9]-=8192,e=(f^1)-1,i=0;i<10;i++)x[i]&=e;for(e=~e,i=0;i<10;i++)this.h[i]=this.h[i]&e|x[i];for(this.h[0]=(this.h[0]|this.h[1]<<13)&65535,this.h[1]=(this.h[1]>>>3|this.h[2]<<10)&65535,this.h[2]=(this.h[2]>>>6|this.h[3]<<7)&65535,this.h[3]=(this.h[3]>>>9|this.h[4]<<4)&65535,this.h[4]=(this.h[4]>>>12|this.h[5]<<1|this.h[6]<<14)&65535,this.h[5]=(this.h[6]>>>2|this.h[7]<<11)&65535,this.h[6]=(this.h[7]>>>5|this.h[8]<<8)&65535,this.h[7]=(this.h[8]>>>8|this.h[9]<<5)&65535,a=this.h[0]+this.pad[0],this.h[0]=a&65535,i=1;i<8;i++)a=(this.h[i]+this.pad[i]|0)+(a>>>16)|0,this.h[i]=a&65535;r[t+0]=this.h[0]>>>0&255,r[t+1]=this.h[0]>>>8&255,r[t+2]=this.h[1]>>>0&255,r[t+3]=this.h[1]>>>8&255,r[t+4]=this.h[2]>>>0&255,r[t+5]=this.h[2]>>>8&255,r[t+6]=this.h[3]>>>0&255,r[t+7]=this.h[3]>>>8&255,r[t+8]=this.h[4]>>>0&255,r[t+9]=this.h[4]>>>8&255,r[t+10]=this.h[5]>>>0&255,r[t+11]=this.h[5]>>>8&255,r[t+12]=this.h[6]>>>0&255,r[t+13]=this.h[6]>>>8&255,r[t+14]=this.h[7]>>>0&255,r[t+15]=this.h[7]>>>8&255;},Sf.prototype.update=function(r,t,x){var f,e;if(this.leftover){for(e=16-this.leftover,e>x&&(e=x),f=0;f<e;f++)this.buffer[this.leftover+f]=r[t+f];if(x-=e,t+=e,this.leftover+=e,this.leftover<16)return;this.blocks(this.buffer,0,16),this.leftover=0;}if(x>=16&&(e=x-x%16,this.blocks(r,t,e),t+=e,x-=e),x){for(f=0;f<x;f++)this.buffer[this.leftover+f]=r[t+f];this.leftover+=x;}};function If(r,t,x,f,e,a){var i=new Sf(a);return i.update(x,f,e),i.finish(r,t),0}function c0(r,t,x,f,e,a){var i=new Uint8Array(16);return If(i,0,x,f,e,a),a0(r,t,i,0)}function Ff(r,t,x,f,e){var a;if(x<32)return -1;for(Kf(r,0,t,0,x,f,e),If(r,16,r,32,x-32,r),a=0;a<16;a++)r[a]=0;return 0}function Df(r,t,x,f,e){var a,i=new Uint8Array(32);if(x<32||(h0(i,0,32,f,e),c0(t,16,t,32,x-32,i)!==0))return -1;for(Kf(r,0,t,0,x,f,e),a=0;a<32;a++)r[a]=0;return 0}function cf(r,t){var x;for(x=0;x<16;x++)r[x]=t[x]|0;}function Xf(r){var t,x,f=1;for(t=0;t<16;t++)x=r[t]+f+65535,f=Math.floor(x/65536),r[t]=x-f*65536;r[0]+=f-1+37*(f-1);}function yf(r,t,x){for(var f,e=~(x-1),a=0;a<16;a++)f=e&(r[a]^t[a]),r[a]^=f,t[a]^=f;}function vf(r,t){var x,f,e,a=v(),i=v();for(x=0;x<16;x++)i[x]=t[x];for(Xf(i),Xf(i),Xf(i),f=0;f<2;f++){for(a[0]=i[0]-65517,x=1;x<15;x++)a[x]=i[x]-65535-(a[x-1]>>16&1),a[x-1]&=65535;a[15]=i[15]-32767-(a[14]>>16&1),e=a[15]>>16&1,a[14]&=65535,yf(i,a,1-e);}for(x=0;x<16;x++)r[2*x]=i[x]&255,r[2*x+1]=i[x]>>8;}function s0(r,t){var x=new Uint8Array(32),f=new Uint8Array(32);return vf(x,r),vf(f,t),Pf(x,0,f,0)}function u0(r){var t=new Uint8Array(32);return vf(t,r),t[0]&1}function Gf(r,t){var x;for(x=0;x<16;x++)r[x]=t[2*x]+(t[2*x+1]<<8);r[15]&=32767;}function of(r,t,x){for(var f=0;f<16;f++)r[f]=t[f]+x[f];}function hf(r,t,x){for(var f=0;f<16;f++)r[f]=t[f]-x[f];}function F(r,t,x){var f,e,a=0,i=0,s=0,y=0,B=0,w=0,G=0,E=0,T=0,M=0,z=0,C=0,j=0,R=0,L=0,A=0,S=0,g=0,p=0,U=0,l=0,o=0,h=0,b=0,c=0,u=0,d=0,Y=0,O=0,Z=0,N=0,n=x[0],K=x[1],V=x[2],$=x[3],P=x[4],D=x[5],X=x[6],k=x[7],H=x[8],q=x[9],Q=x[10],m=x[11],ff=x[12],rf=x[13],xf=x[14],tf=x[15];f=t[0],a+=f*n,i+=f*K,s+=f*V,y+=f*$,B+=f*P,w+=f*D,G+=f*X,E+=f*k,T+=f*H,M+=f*q,z+=f*Q,C+=f*m,j+=f*ff,R+=f*rf,L+=f*xf,A+=f*tf,f=t[1],i+=f*n,s+=f*K,y+=f*V,B+=f*$,w+=f*P,G+=f*D,E+=f*X,T+=f*k,M+=f*H,z+=f*q,C+=f*Q,j+=f*m,R+=f*ff,L+=f*rf,A+=f*xf,S+=f*tf,f=t[2],s+=f*n,y+=f*K,B+=f*V,w+=f*$,G+=f*P,E+=f*D,T+=f*X,M+=f*k,z+=f*H,C+=f*q,j+=f*Q,R+=f*m,L+=f*ff,A+=f*rf,S+=f*xf,g+=f*tf,f=t[3],y+=f*n,B+=f*K,w+=f*V,G+=f*$,E+=f*P,T+=f*D,M+=f*X,z+=f*k,C+=f*H,j+=f*q,R+=f*Q,L+=f*m,A+=f*ff,S+=f*rf,g+=f*xf,p+=f*tf,f=t[4],B+=f*n,w+=f*K,G+=f*V,E+=f*$,T+=f*P,M+=f*D,z+=f*X,C+=f*k,j+=f*H,R+=f*q,L+=f*Q,A+=f*m,S+=f*ff,g+=f*rf,p+=f*xf,U+=f*tf,f=t[5],w+=f*n,G+=f*K,E+=f*V,T+=f*$,M+=f*P,z+=f*D,C+=f*X,j+=f*k,R+=f*H,L+=f*q,A+=f*Q,S+=f*m,g+=f*ff,p+=f*rf,U+=f*xf,l+=f*tf,f=t[6],G+=f*n,E+=f*K,T+=f*V,M+=f*$,z+=f*P,C+=f*D,j+=f*X,R+=f*k,L+=f*H,A+=f*q,S+=f*Q,g+=f*m,p+=f*ff,U+=f*rf,l+=f*xf,o+=f*tf,f=t[7],E+=f*n,T+=f*K,M+=f*V,z+=f*$,C+=f*P,j+=f*D,R+=f*X,L+=f*k,A+=f*H,S+=f*q,g+=f*Q,p+=f*m,U+=f*ff,l+=f*rf,o+=f*xf,h+=f*tf,f=t[8],T+=f*n,M+=f*K,z+=f*V,C+=f*$,j+=f*P,R+=f*D,L+=f*X,A+=f*k,S+=f*H,g+=f*q,p+=f*Q,U+=f*m,l+=f*ff,o+=f*rf,h+=f*xf,b+=f*tf,f=t[9],M+=f*n,z+=f*K,C+=f*V,j+=f*$,R+=f*P,L+=f*D,A+=f*X,S+=f*k,g+=f*H,p+=f*q,U+=f*Q,l+=f*m,o+=f*ff,h+=f*rf,b+=f*xf,c+=f*tf,f=t[10],z+=f*n,C+=f*K,j+=f*V,R+=f*$,L+=f*P,A+=f*D,S+=f*X,g+=f*k,p+=f*H,U+=f*q,l+=f*Q,o+=f*m,h+=f*ff,b+=f*rf,c+=f*xf,u+=f*tf,f=t[11],C+=f*n,j+=f*K,R+=f*V,L+=f*$,A+=f*P,S+=f*D,g+=f*X,p+=f*k,U+=f*H,l+=f*q,o+=f*Q,h+=f*m,b+=f*ff,c+=f*rf,u+=f*xf,d+=f*tf,f=t[12],j+=f*n,R+=f*K,L+=f*V,A+=f*$,S+=f*P,g+=f*D,p+=f*X,U+=f*k,l+=f*H,o+=f*q,h+=f*Q,b+=f*m,c+=f*ff,u+=f*rf,d+=f*xf,Y+=f*tf,f=t[13],R+=f*n,L+=f*K,A+=f*V,S+=f*$,g+=f*P,p+=f*D,U+=f*X,l+=f*k,o+=f*H,h+=f*q,b+=f*Q,c+=f*m,u+=f*ff,d+=f*rf,Y+=f*xf,O+=f*tf,f=t[14],L+=f*n,A+=f*K,S+=f*V,g+=f*$,p+=f*P,U+=f*D,l+=f*X,o+=f*k,h+=f*H,b+=f*q,c+=f*Q,u+=f*m,d+=f*ff,Y+=f*rf,O+=f*xf,Z+=f*tf,f=t[15],A+=f*n,S+=f*K,g+=f*V,p+=f*$,U+=f*P,l+=f*D,o+=f*X,h+=f*k,b+=f*H,c+=f*q,u+=f*Q,d+=f*m,Y+=f*ff,O+=f*rf,Z+=f*xf,N+=f*tf,a+=38*S,i+=38*g,s+=38*p,y+=38*U,B+=38*l,w+=38*o,G+=38*h,E+=38*b,T+=38*c,M+=38*u,z+=38*d,C+=38*Y,j+=38*O,R+=38*Z,L+=38*N,e=1,f=a+e+65535,e=Math.floor(f/65536),a=f-e*65536,f=i+e+65535,e=Math.floor(f/65536),i=f-e*65536,f=s+e+65535,e=Math.floor(f/65536),s=f-e*65536,f=y+e+65535,e=Math.floor(f/65536),y=f-e*65536,f=B+e+65535,e=Math.floor(f/65536),B=f-e*65536,f=w+e+65535,e=Math.floor(f/65536),w=f-e*65536,f=G+e+65535,e=Math.floor(f/65536),G=f-e*65536,f=E+e+65535,e=Math.floor(f/65536),E=f-e*65536,f=T+e+65535,e=Math.floor(f/65536),T=f-e*65536,f=M+e+65535,e=Math.floor(f/65536),M=f-e*65536,f=z+e+65535,e=Math.floor(f/65536),z=f-e*65536,f=C+e+65535,e=Math.floor(f/65536),C=f-e*65536,f=j+e+65535,e=Math.floor(f/65536),j=f-e*65536,f=R+e+65535,e=Math.floor(f/65536),R=f-e*65536,f=L+e+65535,e=Math.floor(f/65536),L=f-e*65536,f=A+e+65535,e=Math.floor(f/65536),A=f-e*65536,a+=e-1+37*(e-1),e=1,f=a+e+65535,e=Math.floor(f/65536),a=f-e*65536,f=i+e+65535,e=Math.floor(f/65536),i=f-e*65536,f=s+e+65535,e=Math.floor(f/65536),s=f-e*65536,f=y+e+65535,e=Math.floor(f/65536),y=f-e*65536,f=B+e+65535,e=Math.floor(f/65536),B=f-e*65536,f=w+e+65535,e=Math.floor(f/65536),w=f-e*65536,f=G+e+65535,e=Math.floor(f/65536),G=f-e*65536,f=E+e+65535,e=Math.floor(f/65536),E=f-e*65536,f=T+e+65535,e=Math.floor(f/65536),T=f-e*65536,f=M+e+65535,e=Math.floor(f/65536),M=f-e*65536,f=z+e+65535,e=Math.floor(f/65536),z=f-e*65536,f=C+e+65535,e=Math.floor(f/65536),C=f-e*65536,f=j+e+65535,e=Math.floor(f/65536),j=f-e*65536,f=R+e+65535,e=Math.floor(f/65536),R=f-e*65536,f=L+e+65535,e=Math.floor(f/65536),L=f-e*65536,f=A+e+65535,e=Math.floor(f/65536),A=f-e*65536,a+=e-1+37*(e-1),r[0]=a,r[1]=i,r[2]=s,r[3]=y,r[4]=B,r[5]=w,r[6]=G,r[7]=E,r[8]=T,r[9]=M,r[10]=z,r[11]=C,r[12]=j,r[13]=R,r[14]=L,r[15]=A;}function nf(r,t){F(r,t,t);}function b0(r,t){var x=v(),f;for(f=0;f<16;f++)x[f]=t[f];for(f=253;f>=0;f--)nf(x,x),f!==2&&f!==4&&F(x,x,t);for(f=0;f<16;f++)r[f]=x[f];}function d0(r,t){var x=v(),f;for(f=0;f<16;f++)x[f]=t[f];for(f=250;f>=0;f--)nf(x,x),f!==1&&F(x,x,t);for(f=0;f<16;f++)r[f]=x[f];}function Yf(r,t,x){var f=new Uint8Array(32),e=new Float64Array(80),a,i,s=v(),y=v(),B=v(),w=v(),G=v(),E=v();for(i=0;i<31;i++)f[i]=t[i];for(f[31]=t[31]&127|64,f[0]&=248,Gf(e,x),i=0;i<16;i++)y[i]=e[i],w[i]=s[i]=B[i]=0;for(s[0]=w[0]=1,i=254;i>=0;--i)a=f[i>>>3]>>>(i&7)&1,yf(s,y,a),yf(B,w,a),of(G,s,B),hf(s,s,B),of(B,y,w),hf(y,y,w),nf(w,G),nf(E,s),F(s,B,s),F(B,y,G),of(G,s,B),hf(s,s,B),nf(y,s),hf(B,w,E),F(s,B,Y0),of(s,s,w),F(B,B,s),F(s,w,E),F(w,y,e),nf(y,G),yf(s,y,a),yf(B,w,a);for(i=0;i<16;i++)e[i+16]=s[i],e[i+32]=B[i],e[i+48]=y[i],e[i+64]=w[i];var T=e.subarray(32),M=e.subarray(16);return b0(T,T),F(M,M,T),vf(r,M),0}function Tf(r,t){return Yf(r,t,W)}function y0(r,t){return I(t,32),Tf(r,t)}function Mf(r,t,x){var f=new Uint8Array(32);return Yf(f,x,t),Bf(r,J,f,uf)}var v0=Ff,R0=Df;function C0(r,t,x,f,e,a){var i=new Uint8Array(32);return Mf(i,e,a),v0(r,t,x,f,i)}function z0(r,t,x,f,e,a){var i=new Uint8Array(32);return Mf(i,e,a),R0(r,t,x,f,i)}var _0=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function l0(r,t,x,f){for(var e=new Int32Array(16),a=new Int32Array(16),i,s,y,B,w,G,E,T,M,z,C,j,R,L,A,S,g,p,U,l,o,h,b,c,u,d,Y=r[0],O=r[1],Z=r[2],N=r[3],n=r[4],K=r[5],V=r[6],$=r[7],P=t[0],D=t[1],X=t[2],k=t[3],H=t[4],q=t[5],Q=t[6],m=t[7],ff=0;f>=128;){for(U=0;U<16;U++)l=8*U+ff,e[U]=x[l+0]<<24|x[l+1]<<16|x[l+2]<<8|x[l+3],a[U]=x[l+4]<<24|x[l+5]<<16|x[l+6]<<8|x[l+7];for(U=0;U<80;U++)if(i=Y,s=O,y=Z,B=N,w=n,G=K,E=V,T=$,M=P,z=D,C=X,j=k,R=H,L=q,A=Q,S=m,o=$,h=m,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=(n>>>14|H<<18)^(n>>>18|H<<14)^(H>>>9|n<<23),h=(H>>>14|n<<18)^(H>>>18|n<<14)^(n>>>9|H<<23),b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,o=n&K^~n&V,h=H&q^~H&Q,b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,o=_0[U*2],h=_0[U*2+1],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,o=e[U%16],h=a[U%16],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,g=u&65535|d<<16,p=b&65535|c<<16,o=g,h=p,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=(Y>>>28|P<<4)^(P>>>2|Y<<30)^(P>>>7|Y<<25),h=(P>>>28|Y<<4)^(Y>>>2|P<<30)^(Y>>>7|P<<25),b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,o=Y&O^Y&Z^O&Z,h=P&D^P&X^D&X,b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,T=u&65535|d<<16,S=b&65535|c<<16,o=B,h=j,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=g,h=p,b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,B=u&65535|d<<16,j=b&65535|c<<16,O=i,Z=s,N=y,n=B,K=w,V=G,$=E,Y=T,D=M,X=z,k=C,H=j,q=R,Q=L,m=A,P=S,U%16===15)for(l=0;l<16;l++)o=e[l],h=a[l],b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=e[(l+9)%16],h=a[(l+9)%16],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,g=e[(l+1)%16],p=a[(l+1)%16],o=(g>>>1|p<<31)^(g>>>8|p<<24)^g>>>7,h=(p>>>1|g<<31)^(p>>>8|g<<24)^(p>>>7|g<<25),b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,g=e[(l+14)%16],p=a[(l+14)%16],o=(g>>>19|p<<13)^(p>>>29|g<<3)^g>>>6,h=(p>>>19|g<<13)^(g>>>29|p<<3)^(p>>>6|g<<26),b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,e[l]=u&65535|d<<16,a[l]=b&65535|c<<16;o=Y,h=P,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[0],h=t[0],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[0]=Y=u&65535|d<<16,t[0]=P=b&65535|c<<16,o=O,h=D,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[1],h=t[1],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[1]=O=u&65535|d<<16,t[1]=D=b&65535|c<<16,o=Z,h=X,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[2],h=t[2],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[2]=Z=u&65535|d<<16,t[2]=X=b&65535|c<<16,o=N,h=k,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[3],h=t[3],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[3]=N=u&65535|d<<16,t[3]=k=b&65535|c<<16,o=n,h=H,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[4],h=t[4],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[4]=n=u&65535|d<<16,t[4]=H=b&65535|c<<16,o=K,h=q,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[5],h=t[5],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[5]=K=u&65535|d<<16,t[5]=q=b&65535|c<<16,o=V,h=Q,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[6],h=t[6],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[6]=V=u&65535|d<<16,t[6]=Q=b&65535|c<<16,o=$,h=m,b=h&65535,c=h>>>16,u=o&65535,d=o>>>16,o=r[7],h=t[7],b+=h&65535,c+=h>>>16,u+=o&65535,d+=o>>>16,c+=b>>>16,u+=c>>>16,d+=u>>>16,r[7]=$=u&65535|d<<16,t[7]=m=b&65535|c<<16,ff+=128,f-=128;}return f}function bf(r,t,x){var f=new Int32Array(8),e=new Int32Array(8),a=new Uint8Array(256),i,s=x;for(f[0]=1779033703,f[1]=3144134277,f[2]=1013904242,f[3]=2773480762,f[4]=1359893119,f[5]=2600822924,f[6]=528734635,f[7]=1541459225,e[0]=4089235720,e[1]=2227873595,e[2]=4271175723,e[3]=1595750129,e[4]=2917565137,e[5]=725511199,e[6]=4215389547,e[7]=327033209,l0(f,e,t,x),x%=128,i=0;i<x;i++)a[i]=t[s-x+i];for(a[x]=128,x=256-128*(x<112?1:0),a[x-9]=0,n0(a,x-8,s/536870912|0,s<<3),l0(f,e,a,x),i=0;i<8;i++)n0(r,8*i,f[i],e[i]);return 0}function jf(r,t){var x=v(),f=v(),e=v(),a=v(),i=v(),s=v(),y=v(),B=v(),w=v();hf(x,r[1],r[0]),hf(w,t[1],t[0]),F(x,x,w),of(f,r[0],r[1]),of(w,t[0],t[1]),F(f,f,w),F(e,r[3],t[3]),F(e,e,T0),F(a,r[2],t[2]),of(a,a,a),hf(i,f,x),hf(s,a,e),of(y,a,e),of(B,f,x),F(r[0],i,s),F(r[1],B,y),F(r[2],y,s),F(r[3],i,B);}function w0(r,t,x){var f;for(f=0;f<4;f++)yf(r[f],t[f],x);}function Vf(r,t){var x=v(),f=v(),e=v();b0(e,t[2]),F(x,t[0],e),F(f,t[1],e),vf(r,f),r[31]^=u0(x)<<7;}function $f(r,t,x){var f,e;for(cf(r[0],af),cf(r[1],pf),cf(r[2],pf),cf(r[3],af),e=255;e>=0;--e)f=x[e/8|0]>>(e&7)&1,w0(r,t,f),jf(t,r),jf(r,r),w0(r,t,f);}function Lf(r,t){var x=[v(),v(),v(),v()];cf(x[0],t0),cf(x[1],e0),cf(x[2],pf),F(x[3],t0,e0),$f(r,x,t);}function Hf(r,t,x){var f=new Uint8Array(64),e=[v(),v(),v(),v()],a;for(x||I(t,32),bf(f,t,32),f[0]&=248,f[31]&=127,f[31]|=64,Lf(e,f),Vf(r,e),a=0;a<32;a++)t[a+32]=r[a];return 0}var Rf=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function Jf(r,t){var x,f,e,a;for(f=63;f>=32;--f){for(x=0,e=f-32,a=f-12;e<a;++e)t[e]+=x-16*t[f]*Rf[e-(f-32)],x=Math.floor((t[e]+128)/256),t[e]-=x*256;t[e]+=x,t[f]=0;}for(x=0,e=0;e<32;e++)t[e]+=x-(t[31]>>4)*Rf[e],x=t[e]>>8,t[e]&=255;for(e=0;e<32;e++)t[e]-=x*Rf[e];for(f=0;f<32;f++)t[f+1]+=t[f]>>8,r[f]=t[f]&255;}function Wf(r){var t=new Float64Array(64),x;for(x=0;x<64;x++)t[x]=r[x];for(x=0;x<64;x++)r[x]=0;Jf(r,t);}function g0(r,t,x,f){var e=new Uint8Array(64),a=new Uint8Array(64),i=new Uint8Array(64),s,y,B=new Float64Array(64),w=[v(),v(),v(),v()];bf(e,f,32),e[0]&=248,e[31]&=127,e[31]|=64;var G=x+64;for(s=0;s<x;s++)r[64+s]=t[s];for(s=0;s<32;s++)r[32+s]=e[32+s];for(bf(i,r.subarray(32),x+32),Wf(i),Lf(w,i),Vf(r,w),s=32;s<64;s++)r[s]=f[s];for(bf(a,r,x+64),Wf(a),s=0;s<64;s++)B[s]=0;for(s=0;s<32;s++)B[s]=i[s];for(s=0;s<32;s++)for(y=0;y<32;y++)B[s+y]+=a[s]*e[y];return Jf(r.subarray(32),B),G}function O0(r,t){var x=v(),f=v(),e=v(),a=v(),i=v(),s=v(),y=v();return cf(r[2],pf),Gf(r[1],t),nf(e,r[1]),F(a,e,x0),hf(e,e,r[2]),of(a,r[2],a),nf(i,a),nf(s,i),F(y,s,i),F(x,y,e),F(x,x,a),d0(x,x),F(x,x,e),F(x,x,a),F(x,x,a),F(r[0],x,a),nf(f,r[0]),F(f,f,a),s0(f,e)&&F(r[0],r[0],M0),nf(f,r[0]),F(f,f,a),s0(f,e)?-1:(u0(r[0])===t[31]>>7&&hf(r[0],af,r[0]),F(r[3],r[0],r[1]),0)}function qf(r,t,x,f){var e,a=new Uint8Array(32),i=new Uint8Array(64),s=[v(),v(),v(),v()],y=[v(),v(),v(),v()];if(x<64||O0(y,f))return -1;for(e=0;e<x;e++)r[e]=t[e];for(e=0;e<32;e++)r[e+32]=f[e];if(bf(i,r,x),Wf(i),$f(s,y,i),Lf(y,t.subarray(32)),jf(s,y),Vf(a,s),x-=64,Pf(t,0,a,0)){for(e=0;e<x;e++)r[e]=0;return -1}for(e=0;e<x;e++)r[e]=t[e+64];return x}var Qf=32,Cf=24,wf=32,_f=16,gf=32,zf=32,Ef=32,Af=32,mf=32,E0=Cf,N0=wf,Z0=_f,sf=64,df=32,lf=64,kf=32,f0=64;_.lowlevel={crypto_core_hsalsa20:Bf,crypto_stream_xor:Kf,crypto_stream:h0,crypto_stream_salsa20_xor:i0,crypto_stream_salsa20:o0,crypto_onetimeauth:If,crypto_onetimeauth_verify:c0,crypto_verify_16:a0,crypto_verify_32:Pf,crypto_secretbox:Ff,crypto_secretbox_open:Df,crypto_scalarmult:Yf,crypto_scalarmult_base:Tf,crypto_box_beforenm:Mf,crypto_box_afternm:v0,crypto_box:C0,crypto_box_open:z0,crypto_box_keypair:y0,crypto_hash:bf,crypto_sign:g0,crypto_sign_keypair:Hf,crypto_sign_open:qf,crypto_secretbox_KEYBYTES:Qf,crypto_secretbox_NONCEBYTES:Cf,crypto_secretbox_ZEROBYTES:wf,crypto_secretbox_BOXZEROBYTES:_f,crypto_scalarmult_BYTES:gf,crypto_scalarmult_SCALARBYTES:zf,crypto_box_PUBLICKEYBYTES:Ef,crypto_box_SECRETKEYBYTES:Af,crypto_box_BEFORENMBYTES:mf,crypto_box_NONCEBYTES:E0,crypto_box_ZEROBYTES:N0,crypto_box_BOXZEROBYTES:Z0,crypto_sign_BYTES:sf,crypto_sign_PUBLICKEYBYTES:df,crypto_sign_SECRETKEYBYTES:lf,crypto_sign_SEEDBYTES:kf,crypto_hash_BYTES:f0,gf:v,D:x0,L:Rf,pack25519:vf,unpack25519:Gf,M:F,A:of,S:nf,Z:hf,pow2523:d0,add:jf,set25519:cf,modL:Jf,scalarmult:$f,scalarbase:Lf};function A0(r,t){if(r.length!==Qf)throw new Error("bad key size");if(t.length!==Cf)throw new Error("bad nonce size")}function P0(r,t){if(r.length!==Ef)throw new Error("bad public key size");if(t.length!==Af)throw new Error("bad secret key size")}function ef(){for(var r=0;r<arguments.length;r++)if(!(arguments[r]instanceof Uint8Array))throw new TypeError("unexpected type, use Uint8Array")}function p0(r){for(var t=0;t<r.length;t++)r[t]=0;}_.randomBytes=function(r){var t=new Uint8Array(r);return I(t,r),t},_.secretbox=function(r,t,x){ef(r,t,x),A0(x,t);for(var f=new Uint8Array(wf+r.length),e=new Uint8Array(f.length),a=0;a<r.length;a++)f[a+wf]=r[a];return Ff(e,f,f.length,t,x),e.subarray(_f)},_.secretbox.open=function(r,t,x){ef(r,t,x),A0(x,t);for(var f=new Uint8Array(_f+r.length),e=new Uint8Array(f.length),a=0;a<r.length;a++)f[a+_f]=r[a];return f.length<32||Df(e,f,f.length,t,x)!==0?null:e.subarray(wf)},_.secretbox.keyLength=Qf,_.secretbox.nonceLength=Cf,_.secretbox.overheadLength=_f,_.scalarMult=function(r,t){if(ef(r,t),r.length!==zf)throw new Error("bad n size");if(t.length!==gf)throw new Error("bad p size");var x=new Uint8Array(gf);return Yf(x,r,t),x},_.scalarMult.base=function(r){if(ef(r),r.length!==zf)throw new Error("bad n size");var t=new Uint8Array(gf);return Tf(t,r),t},_.scalarMult.scalarLength=zf,_.scalarMult.groupElementLength=gf,_.box=function(r,t,x,f){var e=_.box.before(x,f);return _.secretbox(r,t,e)},_.box.before=function(r,t){ef(r,t),P0(r,t);var x=new Uint8Array(mf);return Mf(x,r,t),x},_.box.after=_.secretbox,_.box.open=function(r,t,x,f){var e=_.box.before(x,f);return _.secretbox.open(r,t,e)},_.box.open.after=_.secretbox.open,_.box.keyPair=function(){var r=new Uint8Array(Ef),t=new Uint8Array(Af);return y0(r,t),{publicKey:r,secretKey:t}},_.box.keyPair.fromSecretKey=function(r){if(ef(r),r.length!==Af)throw new Error("bad secret key size");var t=new Uint8Array(Ef);return Tf(t,r),{publicKey:t,secretKey:new Uint8Array(r)}},_.box.publicKeyLength=Ef,_.box.secretKeyLength=Af,_.box.sharedKeyLength=mf,_.box.nonceLength=E0,_.box.overheadLength=_.secretbox.overheadLength,_.sign=function(r,t){if(ef(r,t),t.length!==lf)throw new Error("bad secret key size");var x=new Uint8Array(sf+r.length);return g0(x,r,r.length,t),x},_.sign.open=function(r,t){if(ef(r,t),t.length!==df)throw new Error("bad public key size");var x=new Uint8Array(r.length),f=qf(x,r,r.length,t);if(f<0)return null;for(var e=new Uint8Array(f),a=0;a<e.length;a++)e[a]=x[a];return e},_.sign.detached=function(r,t){for(var x=_.sign(r,t),f=new Uint8Array(sf),e=0;e<f.length;e++)f[e]=x[e];return f},_.sign.detached.verify=function(r,t,x){if(ef(r,t,x),t.length!==sf)throw new Error("bad signature size");if(x.length!==df)throw new Error("bad public key size");var f=new Uint8Array(sf+r.length),e=new Uint8Array(sf+r.length),a;for(a=0;a<sf;a++)f[a]=t[a];for(a=0;a<r.length;a++)f[a+sf]=r[a];return qf(e,f,f.length,x)>=0},_.sign.keyPair=function(){var r=new Uint8Array(df),t=new Uint8Array(lf);return Hf(r,t),{publicKey:r,secretKey:t}},_.sign.keyPair.fromSecretKey=function(r){if(ef(r),r.length!==lf)throw new Error("bad secret key size");for(var t=new Uint8Array(df),x=0;x<t.length;x++)t[x]=r[32+x];return {publicKey:t,secretKey:new Uint8Array(r)}},_.sign.keyPair.fromSeed=function(r){if(ef(r),r.length!==kf)throw new Error("bad seed size");for(var t=new Uint8Array(df),x=new Uint8Array(lf),f=0;f<32;f++)x[f]=r[f];return Hf(t,x,true),{publicKey:t,secretKey:x}},_.sign.publicKeyLength=df,_.sign.secretKeyLength=lf,_.sign.seedLength=kf,_.sign.signatureLength=sf,_.hash=function(r){ef(r);var t=new Uint8Array(f0);return bf(t,r,r.length),t},_.hash.hashLength=f0,_.verify=function(r,t){return ef(r,t),r.length===0||t.length===0||r.length!==t.length?false:Zf(r,0,t,0,r.length)===0},_.setPRNG=function(r){I=r;},(function(){var r=typeof self<"u"?self.crypto||self.msCrypto:null;if(r&&r.getRandomValues){var t=65536;_.setPRNG(function(x,f){var e,a=new Uint8Array(f);for(e=0;e<f;e+=t)r.getRandomValues(a.subarray(e,e+Math.min(f-e,t)));for(e=0;e<f;e++)x[e]=a[e];p0(a);});}else typeof r0<"u"&&(r=r0("crypto"),r&&r.randomBytes&&_.setPRNG(function(x,f){var e,a=r.randomBytes(f);for(e=0;e<f;e++)x[e]=a[e];p0(a);}));})();})(typeof Of<"u"&&Of.exports?Of.exports:self.nacl=self.nacl||{});});var $0=B0((S0,Nf)=>{(function(_,v){typeof Nf<"u"&&Nf.exports?Nf.exports=v():(_.nacl||(_.nacl={}),_.nacl.util=v());})(S0,function(){var _={};function v(I){if(!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(I))throw new TypeError("invalid encoding")}return _.decodeUTF8=function(I){if(typeof I!="string")throw new TypeError("expected string");var J,W=unescape(encodeURIComponent(I)),af=new Uint8Array(W.length);for(J=0;J<W.length;J++)af[J]=W.charCodeAt(J);return af},_.encodeUTF8=function(I){var J,W=[];for(J=0;J<I.length;J++)W.push(String.fromCharCode(I[J]));return decodeURIComponent(escape(W.join("")))},typeof atob>"u"?typeof Buffer.from<"u"?(_.encodeBase64=function(I){return Buffer.from(I).toString("base64")},_.decodeBase64=function(I){return v(I),new Uint8Array(Array.prototype.slice.call(Buffer.from(I,"base64"),0))}):(_.encodeBase64=function(I){return new Buffer(I).toString("base64")},_.decodeBase64=function(I){return v(I),new Uint8Array(Array.prototype.slice.call(new Buffer(I,"base64"),0))}):(_.encodeBase64=function(I){var J,W=[],af=I.length;for(J=0;J<af;J++)W.push(String.fromCharCode(I[J]));return btoa(W.join(""))},_.decodeBase64=function(I){v(I);var J,W=atob(I),af=new Uint8Array(W.length);for(J=0;J<W.length;J++)af[J]=W.charCodeAt(J);return af}),_});});export{H0 as a,V0 as b,$0 as c};
@@ -0,0 +1,2 @@
1
+ import {createRequire}from'module';import {a,b,c}from'./chunk-N5DC4FFG.mjs';createRequire(import.meta.url);
2
+ var d=a(b()),i=a(c()),E=2,f="voidly-pay-v1",p="voidly:stage1",l="credit",w="voidly-credit-transfer/v1",N=1e6;function u(e){if(e==null)return "null";if(typeof e=="boolean")return e?"true":"false";if(typeof e=="number"){if(!Number.isFinite(e)||!Number.isInteger(e))throw new Error("canonicalize: only finite integers supported");return e.toString(10)}if(typeof e=="bigint")return e.toString(10);if(typeof e=="string")return JSON.stringify(e);if(Array.isArray(e))return "["+e.map(u).join(",")+"]";if(typeof e=="object"){let n=e;return "{"+Object.keys(n).filter(r=>n[r]!==null&&n[r]!==void 0).sort().map(r=>JSON.stringify(r)+":"+u(n[r])).join(",")+"}"}throw new Error(`canonicalize: unsupported type ${typeof e}`)}function h(e){return (0, i.decodeUTF8)(u(e))}function R(e,n){if(n.length!==64)throw new Error("signingSecretKey must be 64 bytes (nacl.sign.SecretKeyLength)");let t=h(e),r=d.default.sign.detached(t,n);return (0, i.encodeBase64)(r)}function A(e){let n=Math.min(Math.max(e.ttlSeconds||60,5),3600),t=Date.now(),r={schema:w,from_did:e.fromDid,to_did:e.payTo,amount_micro:e.amountMicro,nonce:(0, i.encodeBase64)(d.default.randomBytes(16)),issued_at:new Date(t).toISOString(),expires_at:new Date(t+n*1e3).toISOString()};e.memo&&(r.memo=e.memo.slice(0,280));let a=R(r,e.signingSecretKey),s={x402Version:E,resource:e.resourceUrl?{url:e.resourceUrl}:void 0,accepted:{scheme:f,network:p,amount:String(e.amountMicro),asset:l,payTo:e.payTo,maxTimeoutSeconds:60,extra:{name:"Voidly Credit",version:"1"}},payload:{envelope:r,signature:a},extensions:{}},o=JSON.parse(JSON.stringify(s));return {json:o,base64Header:btoa(JSON.stringify(o))}}async function P(e){if(e.status!==402)return null;let n=e.headers.get("PAYMENT-REQUIRED")||e.headers.get("X-Payment-Required");if(n)try{return JSON.parse(atob(n))}catch{}try{return await e.json()}catch{return null}}function T(e){return e.accepts?.find(n=>n.scheme===f&&n.network===p&&n.asset===l)||null}async function _(e,n,t,r){let a=await e(n,t);if(a.status!==402)return a;let s=await P(a);if(!s)throw new Error("x402: 402 response did not contain a parseable PaymentRequired body");let o=T(s);if(!o)throw new Error(`x402: no voidly-pay-v1 accept entry in ${JSON.stringify(s.accepts.map(S=>S.scheme))}`);let c=Number(o.amount);if(!Number.isFinite(c)||c<=0)throw new Error(`x402: invalid amount in PaymentRequirements: ${o.amount}`);if(r.maxAmountMicro!=null&&c>r.maxAmountMicro)throw new Error(`x402: server requires ${c} > maxAmountMicro ${r.maxAmountMicro}`);let y=A({fromDid:r.fromDid,payTo:o.payTo,amountMicro:c,signingSecretKey:r.signingSecretKey,resourceUrl:s.resource?.url||n,memo:r.memo,ttlSeconds:o.maxTimeoutSeconds}),m=new Headers(t.headers||{});return m.set("PAYMENT-SIGNATURE",y.base64Header),m.set("X-Payment-Signature",y.base64Header),await e(n,{...t,headers:m})}function O(e){let n=e.headers.get("PAYMENT-RESPONSE")||e.headers.get("X-Payment-Response");if(!n)return null;try{return JSON.parse(atob(n))}catch{return null}}function M(e){return (0, i.decodeBase64)(e.replace(/-/g,"+").replace(/_/g,"/"))}export{E as a,f as b,p as c,l as d,w as e,N as f,u as g,R as h,A as i,P as j,T as k,_ as l,O as m,M as n};
package/dist/index.d.ts CHANGED
@@ -2,15 +2,41 @@ import nacl from 'tweetnacl';
2
2
  export { default as nacl } from 'tweetnacl';
3
3
  export { decodeBase64, decodeUTF8, encodeBase64, encodeUTF8 } from 'tweetnacl-util';
4
4
 
5
- /**
6
- * @voidly/agent-sdk — True E2E Encrypted Agent Communication
7
- *
8
- * All encryption and decryption happens CLIENT-SIDE.
9
- * The Voidly relay server NEVER sees private keys or plaintext.
10
- *
11
- * Crypto: X25519 + ML-KEM-768 hybrid key exchange, XSalsa20-Poly1305, Ed25519 signatures
12
- * Identity: did:voidly:{base58-encoded-ed25519-pubkey}
13
- */
5
+ interface CapabilityListing {
6
+ id: string;
7
+ did: string;
8
+ capability: string;
9
+ name: string;
10
+ description: string;
11
+ price_per_call_micro: number;
12
+ unit: string;
13
+ sla_deadline_hours: number;
14
+ input_schema_json?: string | null;
15
+ output_schema_json?: string | null;
16
+ tags_json?: string | null;
17
+ active: number;
18
+ list_nonce: string;
19
+ list_signature: string;
20
+ list_envelope_hash: string;
21
+ created_at: string;
22
+ updated_at: string;
23
+ total_hires?: number;
24
+ total_completed?: number;
25
+ rating_avg?: number | null;
26
+ }
27
+ interface HireRow {
28
+ id: string;
29
+ capability_id: string;
30
+ requester_did: string;
31
+ provider_did: string;
32
+ price_micro: number;
33
+ task_id: string;
34
+ state: 'requested' | 'claimed' | 'accepted' | 'expired' | 'refunded';
35
+ escrow_id: string;
36
+ delivery_deadline: string;
37
+ created_at: string;
38
+ updated_at: string;
39
+ }
14
40
 
15
41
  interface AgentIdentity {
16
42
  did: string;
@@ -188,6 +214,7 @@ declare class VoidlyAgent {
188
214
  private mlkemSecretKey;
189
215
  private _signedPrekey;
190
216
  private _signedPrekeyId;
217
+ private _signedPrekeyHistory;
191
218
  private _pinnedDids;
192
219
  private _listeners;
193
220
  private _conversations;
@@ -243,12 +270,19 @@ declare class VoidlyAgent {
243
270
  prevSendStep?: number;
244
271
  skippedKeys?: Record<string, string>;
245
272
  dhSkippedKeys?: Record<string, string>;
273
+ x3dhEkPub?: string;
274
+ x3dhSpkId?: number;
275
+ x3dhPqCt?: string;
246
276
  }>;
247
277
  mlkemPublicKey?: string;
248
278
  mlkemSecretKey?: string;
249
279
  signedPrekeySecret?: string;
250
280
  signedPrekeyPublic?: string;
251
281
  signedPrekeyId?: number;
282
+ signedPrekeyHistory?: Record<string, {
283
+ p: string;
284
+ s: string;
285
+ }>;
252
286
  peerDecryptFails?: Record<string, number>;
253
287
  }, config?: VoidlyAgentConfig): VoidlyAgent;
254
288
  /**
@@ -274,12 +308,19 @@ declare class VoidlyAgent {
274
308
  prevSendStep?: number;
275
309
  skippedKeys?: Record<string, string>;
276
310
  dhSkippedKeys?: Record<string, string>;
311
+ x3dhEkPub?: string;
312
+ x3dhSpkId?: number;
313
+ x3dhPqCt?: string;
277
314
  }>;
278
315
  mlkemPublicKey?: string;
279
316
  mlkemSecretKey?: string;
280
317
  signedPrekeySecret?: string;
281
318
  signedPrekeyPublic?: string;
282
319
  signedPrekeyId?: number;
320
+ signedPrekeyHistory?: Record<string, {
321
+ p: string;
322
+ s: string;
323
+ }>;
283
324
  peerDecryptFails?: Record<string, number>;
284
325
  };
285
326
  /** Derive persistence encryption key from signing secret */
@@ -921,6 +962,290 @@ declare class VoidlyAgent {
921
962
  remaining_bytes: number;
922
963
  };
923
964
  }>;
965
+ /**
966
+ * Mixed batch of memory operations in a single round-trip — get/set/delete.
967
+ *
968
+ * Up to 50 ops per call. Set values are encrypted client-side (same scheme
969
+ * as memorySet); get results are decrypted client-side before return.
970
+ * Per-op errors do not abort the batch; each result has either {ok:true,...} or {error:string}.
971
+ */
972
+ memoryBatch(ops: Array<{
973
+ op: 'get';
974
+ namespace: string;
975
+ key: string;
976
+ } | {
977
+ op: 'set';
978
+ namespace: string;
979
+ key: string;
980
+ value: unknown;
981
+ ttl?: number;
982
+ valueType?: string;
983
+ } | {
984
+ op: 'delete';
985
+ namespace: string;
986
+ key: string;
987
+ }>): Promise<Array<{
988
+ index: number;
989
+ op: 'get' | 'set' | 'delete';
990
+ namespace: string;
991
+ key: string;
992
+ found?: boolean;
993
+ value?: unknown;
994
+ valueType?: string;
995
+ expiresAt?: string | null;
996
+ ok?: boolean;
997
+ error?: string;
998
+ }>>;
999
+ /**
1000
+ * List agents that pinged the relay within the configured window.
1001
+ * Useful for finding counterparties who are actually responsive RIGHT NOW.
1002
+ */
1003
+ onlineAgents(opts?: {
1004
+ withinMinutes?: number;
1005
+ capability?: string;
1006
+ limit?: number;
1007
+ }): Promise<Array<{
1008
+ did: string;
1009
+ name: string | null;
1010
+ last_seen: string;
1011
+ trust_score: number;
1012
+ trust_level: string | null;
1013
+ }>>;
1014
+ /**
1015
+ * Subscribe to incoming messages as an async iterable.
1016
+ *
1017
+ * Convenience alias for `messages()` — same auto-reconnect, SSE transport,
1018
+ * and adaptive polling, just a friendlier name.
1019
+ *
1020
+ * @example
1021
+ * for await (const msg of agent.subscribe()) {
1022
+ * console.log(`${msg.from}: ${msg.content}`);
1023
+ * if (msg.content === 'quit') break;
1024
+ * }
1025
+ */
1026
+ subscribe(options?: Parameters<this['messages']>[0]): ReturnType<this['messages']>;
1027
+ /**
1028
+ * Natural-language agent discovery. Tokenizes a task description and
1029
+ * returns ranked agents whose capabilities best match — searching BOTH the
1030
+ * free registry and the priced marketplace.
1031
+ *
1032
+ * @example
1033
+ * const matches = await agent.findBest({
1034
+ * query: 'translate text from english to french',
1035
+ * maxPriceCredits: 0.5,
1036
+ * minTrust: 50,
1037
+ * limit: 5,
1038
+ * });
1039
+ * // matches[0] = { agent: { did, name, trust_score }, capability: { name, score, ... } }
1040
+ */
1041
+ findBest(opts: {
1042
+ query: string;
1043
+ maxPriceCredits?: number;
1044
+ minTrust?: number;
1045
+ limit?: number;
1046
+ /** Set to false to skip the free registry. */
1047
+ includeFree?: boolean;
1048
+ /** Set to false to skip the priced marketplace. */
1049
+ includePriced?: boolean;
1050
+ }): Promise<Array<{
1051
+ agent: {
1052
+ did: string;
1053
+ name: string | null;
1054
+ trust_score: number;
1055
+ trust_level: string | null;
1056
+ };
1057
+ capability: {
1058
+ source: 'free' | 'priced';
1059
+ id: string;
1060
+ name: string;
1061
+ description: string | null;
1062
+ score: number;
1063
+ invocations: number;
1064
+ avg_rating: number;
1065
+ price_per_call_micro?: number;
1066
+ price_per_call_credits?: number;
1067
+ unit?: string;
1068
+ sla_deadline_hours?: number;
1069
+ tags?: string[];
1070
+ };
1071
+ }>>;
1072
+ /**
1073
+ * List a priced capability so other agents can discover and hire you.
1074
+ * Returns the listing id (stable across updates).
1075
+ *
1076
+ * @example
1077
+ * await agent.listCapability({
1078
+ * capability: 'translate',
1079
+ * name: 'Translation Service',
1080
+ * description: 'Translates text between 50 languages',
1081
+ * pricePerCallMicro: 100_000, // 0.1 credit per call
1082
+ * slaDeadlineHours: 1,
1083
+ * });
1084
+ */
1085
+ marketplaceList(input: {
1086
+ capability: string;
1087
+ name: string;
1088
+ description: string;
1089
+ pricePerCallMicro: number;
1090
+ unit?: string;
1091
+ slaDeadlineHours?: number;
1092
+ inputSchema?: object;
1093
+ outputSchema?: object;
1094
+ tags?: string[];
1095
+ active?: boolean;
1096
+ }): Promise<{
1097
+ capability_id: string;
1098
+ listed_at: string;
1099
+ created: boolean;
1100
+ }>;
1101
+ /** Search the priced capability marketplace. Read-only; no auth required. */
1102
+ marketplaceSearch(opts?: {
1103
+ q?: string;
1104
+ capability?: string;
1105
+ maxPriceCredits?: number;
1106
+ providerDid?: string;
1107
+ limit?: number;
1108
+ }): Promise<Array<CapabilityListing>>;
1109
+ /** Get a single marketplace listing by id. Returns null if not found. */
1110
+ marketplaceGet(id: string): Promise<CapabilityListing | null>;
1111
+ /** List all active priced capabilities for a provider DID. */
1112
+ marketplaceListByProvider(did: string): Promise<Array<CapabilityListing>>;
1113
+ /**
1114
+ * Hire a provider for a single capability invocation. Atomically opens
1115
+ * escrow + records the hire. The provider sees the hire via
1116
+ * `marketplaceIncoming()` and delivers via the existing receipt flow.
1117
+ *
1118
+ * Returns hire_id + escrow_id. On failure (insufficient balance,
1119
+ * capability inactive, price mismatch, etc.) throws with the worker's reason.
1120
+ */
1121
+ marketplaceHire(input: {
1122
+ capabilityId: string;
1123
+ capability: string;
1124
+ providerDid: string;
1125
+ pricePerCallMicro: number;
1126
+ taskId?: string;
1127
+ input?: string;
1128
+ deliveryDeadlineHours?: number;
1129
+ }): Promise<{
1130
+ hire_id: string;
1131
+ escrow_id: string;
1132
+ created_at: string;
1133
+ }>;
1134
+ /** List hires waiting for me to fulfill (provider perspective). */
1135
+ marketplaceIncoming(opts?: {
1136
+ state?: 'requested' | 'claimed' | 'accepted' | 'expired' | 'refunded';
1137
+ limit?: number;
1138
+ }): Promise<Array<HireRow>>;
1139
+ /** List hires I have posted (requester perspective). */
1140
+ marketplaceOutgoing(opts?: {
1141
+ state?: 'requested' | 'claimed' | 'accepted' | 'expired' | 'refunded';
1142
+ limit?: number;
1143
+ }): Promise<Array<HireRow>>;
1144
+ /** Get a single hire by id. */
1145
+ marketplaceGetHire(id: string): Promise<HireRow | null>;
1146
+ /**
1147
+ * Claim 10 starter Voidly credits from the faucet. One claim per DID, ever.
1148
+ * Removes the biggest onboarding friction for autonomous agents — no human
1149
+ * operator needed to seed a fresh wallet.
1150
+ *
1151
+ * Returns `{ ok: true, new_balance_micro }` on success, or
1152
+ * `{ ok: false, reason }` (e.g. "already_claimed", "ip_rate_limit_exceeded",
1153
+ * "faucet_disabled").
1154
+ */
1155
+ claimFaucet(): Promise<{
1156
+ ok: boolean;
1157
+ did?: string;
1158
+ amount_micro?: number;
1159
+ new_balance_micro?: number;
1160
+ claimed_at?: string;
1161
+ reason?: string;
1162
+ }>;
1163
+ /** Get my Voidly Pay wallet balance + caps. Returns null if no wallet exists yet. */
1164
+ walletBalance(did?: string): Promise<{
1165
+ did: string;
1166
+ balance_credits: number;
1167
+ locked_credits: number;
1168
+ daily_cap_credits: number;
1169
+ per_tx_cap_credits: number;
1170
+ frozen: number;
1171
+ } | null>;
1172
+ /**
1173
+ * Convenience: claim the faucet only if my wallet has insufficient credits
1174
+ * to cover `requiredMicro`. Idempotent — returns instantly if already funded.
1175
+ *
1176
+ * Useful as a one-shot bootstrap: `await agent.ensureCredits(1_000_000)`
1177
+ * before the first paid action. Throws if faucet fails AND balance still
1178
+ * insufficient (e.g. faucet_disabled, already_claimed without enough left).
1179
+ */
1180
+ ensureCredits(requiredMicro: number): Promise<{
1181
+ sufficient: boolean;
1182
+ balance_micro: number;
1183
+ faucet_claimed: boolean;
1184
+ }>;
1185
+ /**
1186
+ * Pay for an HTTP resource using x402 (Voidly-Pay scheme).
1187
+ *
1188
+ * Calls the URL once, on 402 builds + signs a PaymentPayload,
1189
+ * retries with the PAYMENT-SIGNATURE header. The agent's signing
1190
+ * key is used to sign the credit-transfer envelope.
1191
+ *
1192
+ * Use `maxAmountMicro` as a safety cap so a misconfigured server
1193
+ * can't drain your wallet.
1194
+ *
1195
+ * @example
1196
+ * const res = await agent.payAndFetch('https://provider.example/api/translate',
1197
+ * { method: 'POST', body: JSON.stringify({ text: 'hello' }) },
1198
+ * { maxAmountMicro: 1_000_000 } // cap at 1 credit
1199
+ * );
1200
+ * console.log(await res.json());
1201
+ */
1202
+ payAndFetch(url: string, init?: RequestInit, payerOpts?: {
1203
+ maxAmountMicro?: number;
1204
+ memo?: string;
1205
+ }): Promise<Response>;
1206
+ /**
1207
+ * Sign a Voidly-Pay PaymentPayload without fetching. Useful for batching
1208
+ * payments or pre-flight scenarios. Returns the JSON object and a base64
1209
+ * value suitable for the PAYMENT-SIGNATURE header.
1210
+ */
1211
+ buildPayment(opts: {
1212
+ payTo: string;
1213
+ amountMicro: number;
1214
+ resourceUrl?: string;
1215
+ memo?: string;
1216
+ ttlSeconds?: number;
1217
+ }): Promise<{
1218
+ json: object;
1219
+ base64Header: string;
1220
+ }>;
1221
+ /**
1222
+ * Send up to 50 messages concurrently. Per-peer ratchet locks ensure
1223
+ * forward secrecy is preserved even when sending to the same recipient
1224
+ * multiple times in one batch.
1225
+ *
1226
+ * Failures are returned per-message (does not throw on partial failure).
1227
+ */
1228
+ sendMany(messages: Array<{
1229
+ to: string;
1230
+ body: string;
1231
+ options?: {
1232
+ contentType?: string;
1233
+ threadId?: string;
1234
+ replyTo?: string;
1235
+ ttl?: number;
1236
+ messageType?: string;
1237
+ retries?: number;
1238
+ skipPin?: boolean;
1239
+ sealedSender?: boolean;
1240
+ noPadding?: boolean;
1241
+ };
1242
+ }>): Promise<Array<{
1243
+ index: number;
1244
+ to: string;
1245
+ ok: boolean;
1246
+ result?: SendResult;
1247
+ error?: string;
1248
+ }>>;
924
1249
  /**
925
1250
  * Export all agent data as a portable JSON bundle.
926
1251
  * Includes identity, messages, channels, tasks, attestations, memory, and trust.
@@ -1002,6 +1327,13 @@ declare class VoidlyAgent {
1002
1327
  status: string;
1003
1328
  warning?: string;
1004
1329
  }>;
1330
+ /**
1331
+ * Archive the current signed prekey into bounded history before it is rotated out, so an
1332
+ * X3DH initiator whose bundle-fetch raced just ahead of this rotation can still establish
1333
+ * (the responder recomputes the X3DH legs against the superseded SPK secret). Bounded to
1334
+ * the newest SPK_HISTORY_MAX; Map insertion order makes the first key the oldest.
1335
+ */
1336
+ private _archiveSignedPrekey;
1005
1337
  /**
1006
1338
  * Upload prekey bundle for X3DH async key agreement.
1007
1339
  * Other agents can fetch your prekeys and establish encrypted sessions