@revibase/transaction-manager 0.5.0 → 0.5.2

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
@@ -63,7 +63,7 @@ Set the following environment variables for your signing service:
63
63
 
64
64
  - **`TX_MANAGER_PRIVATE_KEY`**: Manager private key (JWK JSON string).
65
65
  - **`TX_MANAGER_PUBLIC_KEY`**: Manager public key (base58).
66
- - **`TX_MANAGER_URL`**: Public HTTPS URL of your signing endpoint.
66
+ - **`TX_MANAGER_URL`**: Public HTTPS URL of your signing endpoint (the client will connect via WebSocket at the same URL).
67
67
  - **`RPC_URL`** (optional): Solana RPC URL. Defaults to `https://api.mainnet-beta.solana.com`.
68
68
 
69
69
  ### 3. Implement a basic signing endpoint
@@ -72,6 +72,12 @@ Expose a public HTTPS endpoint, for example:
72
72
 
73
73
  `https://your-transaction-manager.com/sign`
74
74
 
75
+ This section uses the [`ws`](https://www.npmjs.com/package/ws) package for the WebSocket server:
76
+
77
+ ```bash
78
+ npm install ws
79
+ ```
80
+
75
81
  This endpoint:
76
82
 
77
83
  - Verifies that the request is intended for this transaction manager.
@@ -81,9 +87,19 @@ This endpoint:
81
87
  - Returns base58-encoded signatures.
82
88
 
83
89
  ```ts
84
- import { verifyTransaction } from "@revibase/transaction-manager";
90
+ import {
91
+ verifyMessage,
92
+ verifyTransaction,
93
+ } from "@revibase/transaction-manager";
85
94
  import { createSolanaRpc, getBase58Decoder } from "gill";
86
95
  import { enforcePolicies } from "@/lib/policy";
96
+ import {
97
+ createMessageChallenge,
98
+ type CompleteMessageRequest,
99
+ type TransactionAuthDetails,
100
+ } from "@revibase/core";
101
+ import http from "node:http";
102
+ import { WebSocketServer } from "ws";
87
103
 
88
104
  const rpc = createSolanaRpc(
89
105
  process.env.RPC_URL ?? "https://api.mainnet-beta.solana.com",
@@ -94,24 +110,75 @@ const transactionManagerConfig = {
94
110
  url: process.env.TX_MANAGER_URL!, // public HTTPS URL of this endpoint
95
111
  };
96
112
 
97
- export async function POST(req: Request) {
113
+ /**
114
+ * The @revibase/core client connects using WebSocket (wss://...) and sends one JSON message.
115
+ * This is the exact shape produced by createTransactionManagerSigner():
116
+ *
117
+ * Transaction signing:
118
+ * {
119
+ * type: "transaction",
120
+ * data: {
121
+ * publicKey: string,
122
+ * payload: Array<{
123
+ * transaction: string,
124
+ * transactionMessageBytes?: string,
125
+ * authResponses?: TransactionAuthDetails[],
126
+ * }>,
127
+ * }
128
+ * }
129
+ *
130
+ * Message signing:
131
+ * {
132
+ * type: "message",
133
+ * data: CompleteMessageRequest
134
+ * }
135
+ *
136
+ * Your service should respond with JSON events:
137
+ * - { event: "signatures", data: { signatures: string[] } } // base58 signatures
138
+ * - { event: "error", data: { error: string } }
139
+ *
140
+ * (Optional) approval UX:
141
+ * - { event: "pending_transaction_approval", data: { validTill: number } }
142
+ * - { event: "transaction_approved", data: {} }
143
+ */
144
+ const server = http.createServer();
145
+
146
+ // Route upgrade requests for "/sign" to WebSocket.
147
+ const wss = new WebSocketServer({ noServer: true });
148
+ server.on("upgrade", (req, socket, head) => {
98
149
  try {
99
- const { publicKey, payload } = (await req.json()) as {
100
- publicKey: string;
101
- payload: {
102
- transaction: string;
103
- transactionMessageBytes?: string;
104
- authResponses?: unknown[];
105
- }[];
106
- };
150
+ const url = new URL(req.url ?? "/", "http://localhost");
151
+ if (url.pathname !== "/sign") {
152
+ socket.destroy();
153
+ return;
154
+ }
155
+ wss.handleUpgrade(req, socket, head, (ws) => {
156
+ wss.emit("connection", ws, req);
157
+ });
158
+ } catch {
159
+ socket.destroy();
160
+ }
161
+ });
107
162
 
108
- if (publicKey !== transactionManagerConfig.publicKey) {
109
- return Response.json(
110
- { error: "Invalid transaction manager public key" },
111
- { status: 400 },
163
+ wss.on("connection", async (ws) => {
164
+ try {
165
+ // Read exactly one request message from the client.
166
+ const msg = (await readJsonOnce(ws)) as {
167
+ type: string;
168
+ data?: unknown;
169
+ };
170
+ if (msg.type !== "transaction" && msg.type !== "message") {
171
+ ws.send(
172
+ JSON.stringify({
173
+ event: "error",
174
+ data: { error: `Unsupported request type: ${msg.type}` },
175
+ }),
112
176
  );
177
+ ws.close();
178
+ return;
113
179
  }
114
180
 
181
+ // Shared: load signer key once per connection.
115
182
  const jwk = JSON.parse(process.env.TX_MANAGER_PRIVATE_KEY!);
116
183
  const privateKey = await crypto.subtle.importKey(
117
184
  "jwk",
@@ -121,33 +188,124 @@ export async function POST(req: Request) {
121
188
  ["sign"],
122
189
  );
123
190
 
124
- const signatures: string[] = [];
191
+ if (msg.type === "transaction") {
192
+ const { publicKey, payload } = (msg.data ?? {}) as {
193
+ publicKey: string;
194
+ payload: {
195
+ transaction: string;
196
+ transactionMessageBytes?: string;
197
+ authResponses?: TransactionAuthDetails[];
198
+ }[];
199
+ };
200
+
201
+ if (publicKey !== transactionManagerConfig.publicKey) {
202
+ ws.send(
203
+ JSON.stringify({
204
+ event: "error",
205
+ data: { error: "Invalid transaction manager public key" },
206
+ }),
207
+ );
208
+ ws.close();
209
+ return;
210
+ }
125
211
 
126
- for (const payloadItem of payload) {
127
- const result = await verifyTransaction(
128
- rpc,
129
- transactionManagerConfig,
130
- payloadItem,
131
- );
212
+ const signatures: string[] = [];
213
+ for (const payloadItem of payload) {
214
+ const result = await verifyTransaction(
215
+ rpc,
216
+ transactionManagerConfig,
217
+ payloadItem,
218
+ );
219
+
220
+ await enforcePolicies(result);
132
221
 
133
- await enforcePolicies(result);
222
+ // (Optional) if your policy requires an out-of-band human approval:
223
+ // ws.send(JSON.stringify({ event: "pending_transaction_approval", data: { validTill: Date.now() + 60_000 } }));
224
+
225
+ // await waitForYourApprovalSystem(...);
226
+
227
+ // ws.send(JSON.stringify({ event: "transaction_approved", data: {} }));
228
+
229
+ const signatureBytes = await crypto.subtle.sign(
230
+ { name: "Ed25519" },
231
+ privateKey,
232
+ result.transactionMessage,
233
+ );
234
+
235
+ signatures.push(
236
+ getBase58Decoder().decode(new Uint8Array(signatureBytes)),
237
+ );
238
+ }
239
+
240
+ ws.send(JSON.stringify({ event: "signatures", data: { signatures } }));
241
+ ws.close();
242
+ } else {
243
+ // msg.type === "message"
244
+ const payload = msg.data as CompleteMessageRequest;
245
+
246
+ await verifyMessage(payload);
247
+
248
+ // (Optional) if your policy requires an out-of-band human approval:
249
+
250
+ // ws.send(JSON.stringify({ event: "pending_transaction_approval", data: { validTill: Date.now() + 60_000 } }));
251
+
252
+ // await waitForYourApprovalSystem(...);
253
+
254
+ // ws.send(JSON.stringify({ event: "transaction_approved", data: {} }));
255
+
256
+ const expectedChallenge = createMessageChallenge(
257
+ payload.data.payload.startRequest.data.payload,
258
+ payload.data.payload.startRequest.clientOrigin,
259
+ payload.data.payload.device.jwk,
260
+ payload.data.payload.startRequest.rid,
261
+ );
134
262
 
135
263
  const signatureBytes = await crypto.subtle.sign(
136
264
  { name: "Ed25519" },
137
265
  privateKey,
138
- result.transactionMessage,
266
+ expectedChallenge,
139
267
  );
140
268
 
141
- signatures.push(
142
- getBase58Decoder().decode(new Uint8Array(signatureBytes)),
269
+ ws.send(
270
+ JSON.stringify({
271
+ event: "signatures",
272
+ data: {
273
+ signatures: [
274
+ getBase58Decoder().decode(new Uint8Array(signatureBytes)),
275
+ ],
276
+ },
277
+ }),
143
278
  );
279
+ ws.close();
144
280
  }
145
-
146
- return Response.json({ signatures });
147
281
  } catch (e) {
148
282
  const msg = e instanceof Error ? e.message : String(e);
149
- return Response.json({ error: msg }, { status: 500 });
283
+ try {
284
+ ws.send(JSON.stringify({ event: "error", data: { error: msg } }));
285
+ } finally {
286
+ ws.close();
287
+ }
150
288
  }
289
+ });
290
+
291
+ server.listen(3000, () => {
292
+ console.log("Transaction manager listening on http://localhost:3000/sign");
293
+ });
294
+
295
+ function readJsonOnce(ws: import("ws").WebSocket): Promise<unknown> {
296
+ return new Promise((resolve, reject) => {
297
+ const onMessage = (data: import("ws").RawData) => {
298
+ try {
299
+ const text = typeof data === "string" ? data : data.toString("utf8");
300
+ resolve(JSON.parse(text));
301
+ } catch (e) {
302
+ reject(e);
303
+ } finally {
304
+ ws.off("message", onMessage);
305
+ }
306
+ };
307
+ ws.on("message", onMessage);
308
+ });
151
309
  }
152
310
  ```
153
311
 
@@ -233,10 +391,15 @@ export async function enforcePolicies(results: VerificationResults) {
233
391
 
234
392
  This package exports the following public API:
235
393
 
236
- - **`verifyTransaction(rpc, transactionManagerConfig, payload, wellKnownProxyUrl?)`**
394
+ - **`verifyTransaction(rpc, transactionManagerConfig, payload, getClientDetails?)`**
237
395
  - Decodes and verifies a serialized Solana transaction.
238
396
  - Returns a `VerificationResults` object with the transaction message bytes and verification batches.
239
397
 
398
+ - **`verifyMessage(payload, getClientDetails?)`**
399
+ - Verifies a sign-in / message authorization payload (`CompleteMessageRequest`).
400
+ - Returns `{ payload, clientDetails }` after verifying client, device, and user signatures.
401
+ - Uses `payload.data.payload.startRequest.rpId` and `payload.data.payload.startRequest.providerOrigin` for WebAuthn verification (RP ID + expected origin).
402
+
240
403
  - **`TransactionManagerConfig`**
241
404
  - `publicKey`: Transaction manager public key (base58 string).
242
405
  - `url`: Public URL of your transaction manager endpoint.
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
1
- 'use strict';var core=require('@revibase/core');require('@noble/hashes/utils.js');var sha2_js=require('@noble/hashes/sha2.js'),jose=require('jose');var Nn=1,Dn=2,On=3,Cn=4,mn=5,pn=6,hn=7,Ln=8,Mn=9,yn=10,Un=-32700,bn=-32603,vn=-32602,wn=-32601,Bn=-32600,Pn=-32019,Fn=-32018,xn=-32017,zn=-32016,kn=-32015,Vn=-32014,Wn=-32013,Gn=-32012,Hn=-32011,Kn=-32010,$n=-32009,Yn=-32008,Xn=-32007,jn=-32006,Zn=-32005,qn=-32004,Jn=-32003,Qn=-32002,er=-32001,J=28e5,Q=2800001,tr=2800002,$e=2800003,Ye=2800004,Xe=2800005,je=2800006,Ze=2800007,qe=2800008,Je=2800009,Qe=2800010,et=2800011,tt=323e4,ee=32300001,nt=3230002,rt=3230003,te=3230004,nr=361e4,rr=3610001,or=3610002,ar=3610003,ir=3610004,sr=3610005,cr=3610006,ur=3610007,dr=3611e3,_r=3704e3,Ar=3704001,lr=3704002,Ir=3704003,Rr=3704004,Er=4128e3,Tr=4128001,gr=4128002,fr=4615e3,Sr=4615001,Nr=4615002,Dr=4615003,Or=4615004,Cr=4615005,mr=4615006,pr=4615007,hr=4615008,Lr=4615009,Mr=4615010,yr=4615011,Ur=4615012,br=4615013,vr=4615014,wr=4615015,Br=4615016,Pr=4615017,Fr=4615018,xr=4615019,zr=4615020,kr=4615021,Vr=4615022,Wr=4615023,Gr=4615024,Hr=4615025,Kr=4615026,$r=4615027,Yr=4615028,Xr=4615029,jr=4615030,Zr=4615031,qr=4615032,Jr=4615033,Qr=4615034,eo=4615035,to=4615036,no=4615037,ro=4615038,oo=4615039,ao=4615040,io=4615041,so=4615042,co=4615043,uo=4615044,_o=4615045,Ao=4615046,lo=4615047,Io=4615048,Ro=4615049,Eo=4615050,To=4615051,go=4615052,fo=4615053,So=4615054,No=5508e3,Do=5508001,Oo=5508002,Co=5508003,mo=5508004,po=5508005,ho=5508006,Lo=5508007,Mo=5508008,yo=5508009,Uo=5508010,bo=5508011,ot=5663e3,at=5663001,ne=5663002,re=5663003,it=5663004,oe=5663005,ae=5663006,ie=5663007,se=5663008,st=5663009,vo=5663010,wo=5663011,ct=5663012,Bo=5663013,Po=5663014,ut=5663015,dt=5663016,ce=5663017,Fo=5663018,xo=5663019,_t=5663020,ue=5663021,At=5663022,zo=705e4,ko=7050001,Vo=7050002,Wo=7050003,Go=7050004,Ho=7050005,Ko=7050006,$o=7050007,Yo=7050008,Xo=7050009,jo=7050010,Zo=7050011,qo=7050012,Jo=7050013,Qo=7050014,ea=7050015,ta=7050016,na=7050017,ra=7050018,oa=7050019,aa=7050020,ia=7050021,sa=7050022,ca=7050023,ua=7050024,da=7050025,_a=7050026,Aa=7050027,la=7050028,Ia=7050029,Ra=7050030,Ea=7050031,Ta=7050032,ga=7050033,fa=7050034,Sa=7050035,Na=7050036,Da=7618e3,Oa=7618001,Ca=7618002,ma=7618003,de=8078e3,_e=8078001,lt=8078002,It=8078003,Rt=8078004,Et=8078005,Tt=8078006,pa=8078007,ha=8078008,La=8078009,Ma=8078010,Ae=8078011,W=8078012,le=8078013,Ie=8078014,ya=8078015,Ua=8078016,ba=8078017,va=8078018,wa=8078019,gt=8078020,ft=8078021,Ba=8078022,St=8078023,Pa=81e5,Fa=8100001,xa=8100002,za=8100003,ka=819e4,Va=8190001,Wa=8190002,Ga=8190003,Ha=8190004,Ka=99e5,$a=9900001,Ya=9900002,Xa=9900003,ja=9900004,Za=9900005,qa=9900006;function Nt(e){return Array.isArray(e)?"%5B"+e.map(Nt).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Ja([e,t]){return `${e}=${Nt(t)}`}function Qa(e){let t=Object.entries(e).map(Ja).join("&");return Buffer.from(t,"utf8").toString("base64")}var ei={[tt]:"Account not found at address: $address",[te]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[rt]:"Expected decoded account at address: $address",[nt]:"Failed to decode account data at address: $address",[ee]:"Accounts not found at addresses: $addresses",[Je]:"Unable to find a viable program address bump seed.",[tr]:"$putativeAddress is not a base58-encoded address.",[J]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[$e]:"The `CryptoKey` must be an `Ed25519` public key.",[et]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[qe]:"Invalid seeds; point must fall off the Ed25519 curve.",[Ye]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[je]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ze]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Xe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[Qe]:"Program address cannot end with PDA marker.",[Q]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Cn]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Nn]:"The network has progressed past the last block for which this transaction could have been committed.",[de]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Ba]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[gt]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Et]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Tt]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Rt]:"Encoder and decoder must either both be fixed-size or variable-size.",[ha]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[lt]:"Expected a fixed-size codec, got a variable-size one.",[le]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[It]:"Expected a variable-size codec, got a fixed-size one.",[wa]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[_e]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[va]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[La]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Ma]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[ya]:"Invalid literal union variant. Expected one of [$variants], got $value.",[pa]:"Expected [$codecDescription] to have $expected items, got $actual.",[W]:"Invalid value $value for base $base with alphabet $alphabet.",[Ua]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Ae]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Ie]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[ft]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[ba]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[St]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[dr]:"No random values implementation could be found.",[Lr]:"instruction requires an uninitialized account",[Wr]:"instruction tries to borrow reference for an account which is already borrowed",[Gr]:"instruction left account with an outstanding borrowed reference",[kr]:"program other than the account's owner changed the size of the account data",[Cr]:"account data too small for instruction",[Vr]:"instruction expected an executable account",[Ao]:"An account does not have enough lamports to be rent-exempt",[Io]:"Program arithmetic overflowed",[_o]:"Failed to serialize or deserialize account data: $encodedData",[So]:"Builtin programs must consume compute units",[qr]:"Cross-program invocation call depth too deep",[ro]:"Computational budget exceeded",[Kr]:"custom program error: #$code",[Pr]:"instruction contains duplicate accounts",[Hr]:"instruction modifications of multiply-passed account differ",[jr]:"executable accounts must be rent exempt",[Yr]:"instruction changed executable accounts data",[Xr]:"instruction changed the balance of an executable account",[Fr]:"instruction changed executable bit of an account",[vr]:"instruction modified data of an account it does not own",[br]:"instruction spent from the balance of an account it does not own",[Sr]:"generic instruction error",[Eo]:"Provided owner is not allowed",[co]:"Account is immutable",[uo]:"Incorrect authority provided",[pr]:"incorrect program id for instruction",[mr]:"insufficient funds for instruction",[Or]:"invalid account data for instruction",[lo]:"Invalid account owner",[Nr]:"invalid program argument",[$r]:"program returned invalid error code",[Dr]:"invalid instruction data",[no]:"Failed to reallocate account data",[to]:"Provided seeds do not result in a valid address",[To]:"Accounts data allocations exceeded the maximum allowed per transaction",[go]:"Max accounts exceeded",[fo]:"Max instruction trace length exceeded",[eo]:"Length of the seed is too long for address generation",[Jr]:"An account required by the instruction is missing",[hr]:"missing required signature for instruction",[Ur]:"instruction illegally modified the program id of an account",[zr]:"insufficient account keys for instruction",[oo]:"Cross-program invocation with unauthorized signer or writable account",[ao]:"Failed to create program execution environment",[so]:"Program failed to compile",[io]:"Program failed to complete",[Br]:"instruction modified data of a read-only account",[wr]:"instruction changed the balance of a read-only account",[Qr]:"Cross-program invocation reentrancy not allowed for this instruction",[xr]:"instruction modified rent epoch of an account",[yr]:"sum of account balances before and after instruction do not match",[Mr]:"instruction requires an initialized account",[fr]:"",[Zr]:"Unsupported program id",[Ro]:"Unsupported sysvar",[Za]:"Invalid instruction plan kind: $kind.",[Ca]:"The provided instruction plan is empty.",[ma]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Da]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[qa]:"Invalid transaction plan kind: $kind.",[Oa]:"No more instructions to pack; the message packer has completed the instruction plan.",[Er]:"The instruction does not have any accounts.",[Tr]:"The instruction does not have any data.",[gr]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[mn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Dn]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Ya]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ja]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[$a]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Ka]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Xa]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[bn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[vn]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Bn]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[wn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Un]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Gn]:"$__serverMessage",[er]:"$__serverMessage",[qn]:"$__serverMessage",[Vn]:"$__serverMessage",[xn]:"Epoch rewards period still active at slot $slot",[Kn]:"$__serverMessage",[$n]:"$__serverMessage",[Pn]:"Failed to query long-term storage; please try again",[zn]:"Minimum context slot has not been reached",[Zn]:"Node is unhealthy; behind by $numSlotsBehind slots",[Yn]:"No snapshot",[Qn]:"Transaction simulation failed",[Fn]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[Xn]:"$__serverMessage",[Hn]:"Transaction history is not available from this node",[jn]:"$__serverMessage",[Wn]:"Transaction signature length mismatch",[Jn]:"Transaction signature verification failure",[kn]:"$__serverMessage",[_r]:"Key pair bytes must be of length 64, got $byteLength.",[Ar]:"Expected private key bytes with length 32. Actual length: $actualLength.",[lr]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Rr]:"The provided private key does not match the provided public key.",[Ir]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[pn]:"Lamports value must be in the range [0, 2e64-1]",[hn]:"`$value` cannot be parsed as a `BigInt`",[yn]:"$message",[Ln]:"`$value` cannot be parsed as a `Number`",[On]:"No nonce account could be found at address `$nonceAccountAddress`",[ka]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Wa]:"WebSocket was closed before payload could be added to the send buffer",[Ga]:"WebSocket connection closed",[Ha]:"WebSocket failed to connect",[Va]:"Failed to obtain a subscription id from the server",[za]:"Could not find an API plan for RPC method: `$method`",[Pa]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[xa]:"HTTP error ($statusCode): $message",[Fa]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[No]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Do]:"The provided value does not implement the `KeyPairSigner` interface",[Co]:"The provided value does not implement the `MessageModifyingSigner` interface",[mo]:"The provided value does not implement the `MessagePartialSigner` interface",[Oo]:"The provided value does not implement any of the `MessageSigner` interfaces",[ho]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Lo]:"The provided value does not implement the `TransactionPartialSigner` interface",[Mo]:"The provided value does not implement the `TransactionSendingSigner` interface",[po]:"The provided value does not implement any of the `TransactionSigner` interfaces",[yo]:"More than one `TransactionSendingSigner` was identified.",[Uo]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[bo]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[ur]:"Cannot export a non-extractable key.",[rr]:"No digest implementation could be found.",[nr]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[or]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ 'use strict';var core=require('@revibase/core'),sha2_js=require('@noble/hashes/sha2.js'),server=require('@simplewebauthn/server'),jose=require('jose');require('@noble/hashes/utils.js');var Dn=1,On=2,Cn=3,mn=4,pn=5,hn=6,Ln=7,Mn=8,yn=9,Un=10,bn=-32700,vn=-32603,wn=-32602,Bn=-32601,Pn=-32600,Fn=-32019,xn=-32018,zn=-32017,kn=-32016,Vn=-32015,Wn=-32014,Gn=-32013,Hn=-32012,Kn=-32011,$n=-32010,Yn=-32009,Xn=-32008,jn=-32007,qn=-32006,Zn=-32005,Jn=-32004,Qn=-32003,er=-32002,tr=-32001,ee=28e5,te=2800001,nr=2800002,Xe=2800003,je=2800004,qe=2800005,Ze=2800006,Je=2800007,Qe=2800008,et=2800009,tt=2800010,nt=2800011,rt=323e4,ne=32300001,ot=3230002,at=3230003,re=3230004,rr=361e4,or=3610001,ar=3610002,ir=3610003,sr=3610004,cr=3610005,ur=3610006,dr=3610007,_r=3611e3,Ar=3704e3,lr=3704001,Ir=3704002,Er=3704003,Rr=3704004,gr=4128e3,Tr=4128001,fr=4128002,Sr=4615e3,Nr=4615001,Dr=4615002,Or=4615003,Cr=4615004,mr=4615005,pr=4615006,hr=4615007,Lr=4615008,Mr=4615009,yr=4615010,Ur=4615011,br=4615012,vr=4615013,wr=4615014,Br=4615015,Pr=4615016,Fr=4615017,xr=4615018,zr=4615019,kr=4615020,Vr=4615021,Wr=4615022,Gr=4615023,Hr=4615024,Kr=4615025,$r=4615026,Yr=4615027,Xr=4615028,jr=4615029,qr=4615030,Zr=4615031,Jr=4615032,Qr=4615033,eo=4615034,to=4615035,no=4615036,ro=4615037,oo=4615038,ao=4615039,io=4615040,so=4615041,co=4615042,uo=4615043,_o=4615044,Ao=4615045,lo=4615046,Io=4615047,Eo=4615048,Ro=4615049,go=4615050,To=4615051,fo=4615052,So=4615053,No=4615054,Do=5508e3,Oo=5508001,Co=5508002,mo=5508003,po=5508004,ho=5508005,Lo=5508006,Mo=5508007,yo=5508008,Uo=5508009,bo=5508010,vo=5508011,it=5663e3,st=5663001,oe=5663002,ae=5663003,ct=5663004,ie=5663005,se=5663006,ce=5663007,ue=5663008,ut=5663009,wo=5663010,Bo=5663011,dt=5663012,Po=5663013,Fo=5663014,_t=5663015,At=5663016,de=5663017,xo=5663018,zo=5663019,lt=5663020,_e=5663021,It=5663022,ko=705e4,Vo=7050001,Wo=7050002,Go=7050003,Ho=7050004,Ko=7050005,$o=7050006,Yo=7050007,Xo=7050008,jo=7050009,qo=7050010,Zo=7050011,Jo=7050012,Qo=7050013,ea=7050014,ta=7050015,na=7050016,ra=7050017,oa=7050018,aa=7050019,ia=7050020,sa=7050021,ca=7050022,ua=7050023,da=7050024,_a=7050025,Aa=7050026,la=7050027,Ia=7050028,Ea=7050029,Ra=7050030,ga=7050031,Ta=7050032,fa=7050033,Sa=7050034,Na=7050035,Da=7050036,Oa=7618e3,Ca=7618001,ma=7618002,pa=7618003,Ae=8078e3,le=8078001,Et=8078002,Rt=8078003,gt=8078004,Tt=8078005,ft=8078006,ha=8078007,La=8078008,Ma=8078009,ya=8078010,Ie=8078011,W=8078012,Ee=8078013,Re=8078014,Ua=8078015,ba=8078016,va=8078017,wa=8078018,Ba=8078019,St=8078020,Nt=8078021,Pa=8078022,Dt=8078023,Fa=81e5,xa=8100001,za=8100002,ka=8100003,Va=819e4,Wa=8190001,Ga=8190002,Ha=8190003,Ka=8190004,$a=99e5,Ya=9900001,Xa=9900002,ja=9900003,qa=9900004,Za=9900005,Ja=9900006;function Ot(e){return Array.isArray(e)?"%5B"+e.map(Ot).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Qa([e,t]){return `${e}=${Ot(t)}`}function ei(e){let t=Object.entries(e).map(Qa).join("&");return Buffer.from(t,"utf8").toString("base64")}var ti={[rt]:"Account not found at address: $address",[re]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[at]:"Expected decoded account at address: $address",[ot]:"Failed to decode account data at address: $address",[ne]:"Accounts not found at addresses: $addresses",[et]:"Unable to find a viable program address bump seed.",[nr]:"$putativeAddress is not a base58-encoded address.",[ee]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Xe]:"The `CryptoKey` must be an `Ed25519` public key.",[nt]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Qe]:"Invalid seeds; point must fall off the Ed25519 curve.",[je]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Ze]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Je]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[qe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[tt]:"Program address cannot end with PDA marker.",[te]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[mn]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Dn]:"The network has progressed past the last block for which this transaction could have been committed.",[Ae]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Pa]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[St]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Tt]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ft]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[gt]:"Encoder and decoder must either both be fixed-size or variable-size.",[La]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Et]:"Expected a fixed-size codec, got a variable-size one.",[Ee]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Rt]:"Expected a variable-size codec, got a fixed-size one.",[Ba]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[le]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[wa]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Ma]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[ya]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Ua]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ha]:"Expected [$codecDescription] to have $expected items, got $actual.",[W]:"Invalid value $value for base $base with alphabet $alphabet.",[ba]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Ie]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Re]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Nt]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[va]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Dt]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[_r]:"No random values implementation could be found.",[Mr]:"instruction requires an uninitialized account",[Gr]:"instruction tries to borrow reference for an account which is already borrowed",[Hr]:"instruction left account with an outstanding borrowed reference",[Vr]:"program other than the account's owner changed the size of the account data",[mr]:"account data too small for instruction",[Wr]:"instruction expected an executable account",[lo]:"An account does not have enough lamports to be rent-exempt",[Eo]:"Program arithmetic overflowed",[Ao]:"Failed to serialize or deserialize account data: $encodedData",[No]:"Builtin programs must consume compute units",[Jr]:"Cross-program invocation call depth too deep",[oo]:"Computational budget exceeded",[$r]:"custom program error: #$code",[Fr]:"instruction contains duplicate accounts",[Kr]:"instruction modifications of multiply-passed account differ",[qr]:"executable accounts must be rent exempt",[Xr]:"instruction changed executable accounts data",[jr]:"instruction changed the balance of an executable account",[xr]:"instruction changed executable bit of an account",[wr]:"instruction modified data of an account it does not own",[vr]:"instruction spent from the balance of an account it does not own",[Nr]:"generic instruction error",[go]:"Provided owner is not allowed",[uo]:"Account is immutable",[_o]:"Incorrect authority provided",[hr]:"incorrect program id for instruction",[pr]:"insufficient funds for instruction",[Cr]:"invalid account data for instruction",[Io]:"Invalid account owner",[Dr]:"invalid program argument",[Yr]:"program returned invalid error code",[Or]:"invalid instruction data",[ro]:"Failed to reallocate account data",[no]:"Provided seeds do not result in a valid address",[To]:"Accounts data allocations exceeded the maximum allowed per transaction",[fo]:"Max accounts exceeded",[So]:"Max instruction trace length exceeded",[to]:"Length of the seed is too long for address generation",[Qr]:"An account required by the instruction is missing",[Lr]:"missing required signature for instruction",[br]:"instruction illegally modified the program id of an account",[kr]:"insufficient account keys for instruction",[ao]:"Cross-program invocation with unauthorized signer or writable account",[io]:"Failed to create program execution environment",[co]:"Program failed to compile",[so]:"Program failed to complete",[Pr]:"instruction modified data of a read-only account",[Br]:"instruction changed the balance of a read-only account",[eo]:"Cross-program invocation reentrancy not allowed for this instruction",[zr]:"instruction modified rent epoch of an account",[Ur]:"sum of account balances before and after instruction do not match",[yr]:"instruction requires an initialized account",[Sr]:"",[Zr]:"Unsupported program id",[Ro]:"Unsupported sysvar",[Za]:"Invalid instruction plan kind: $kind.",[ma]:"The provided instruction plan is empty.",[pa]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Oa]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[Ja]:"Invalid transaction plan kind: $kind.",[Ca]:"No more instructions to pack; the message packer has completed the instruction plan.",[gr]:"The instruction does not have any accounts.",[Tr]:"The instruction does not have any data.",[fr]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[pn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[On]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Xa]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[qa]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Ya]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[$a]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[ja]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[vn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[wn]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Pn]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Bn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[bn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Hn]:"$__serverMessage",[tr]:"$__serverMessage",[Jn]:"$__serverMessage",[Wn]:"$__serverMessage",[zn]:"Epoch rewards period still active at slot $slot",[$n]:"$__serverMessage",[Yn]:"$__serverMessage",[Fn]:"Failed to query long-term storage; please try again",[kn]:"Minimum context slot has not been reached",[Zn]:"Node is unhealthy; behind by $numSlotsBehind slots",[Xn]:"No snapshot",[er]:"Transaction simulation failed",[xn]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[jn]:"$__serverMessage",[Kn]:"Transaction history is not available from this node",[qn]:"$__serverMessage",[Gn]:"Transaction signature length mismatch",[Qn]:"Transaction signature verification failure",[Vn]:"$__serverMessage",[Ar]:"Key pair bytes must be of length 64, got $byteLength.",[lr]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Ir]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Rr]:"The provided private key does not match the provided public key.",[Er]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[hn]:"Lamports value must be in the range [0, 2e64-1]",[Ln]:"`$value` cannot be parsed as a `BigInt`",[Un]:"$message",[Mn]:"`$value` cannot be parsed as a `Number`",[Cn]:"No nonce account could be found at address `$nonceAccountAddress`",[Va]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Ga]:"WebSocket was closed before payload could be added to the send buffer",[Ha]:"WebSocket connection closed",[Ka]:"WebSocket failed to connect",[Wa]:"Failed to obtain a subscription id from the server",[ka]:"Could not find an API plan for RPC method: `$method`",[Fa]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[za]:"HTTP error ($statusCode): $message",[xa]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Do]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Oo]:"The provided value does not implement the `KeyPairSigner` interface",[mo]:"The provided value does not implement the `MessageModifyingSigner` interface",[po]:"The provided value does not implement the `MessagePartialSigner` interface",[Co]:"The provided value does not implement any of the `MessageSigner` interfaces",[Lo]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Mo]:"The provided value does not implement the `TransactionPartialSigner` interface",[yo]:"The provided value does not implement the `TransactionSendingSigner` interface",[ho]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Uo]:"More than one `TransactionSendingSigner` was identified.",[bo]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[vo]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[dr]:"Cannot export a non-extractable key.",[or]:"No digest implementation could be found.",[rr]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ar]:`This runtime does not support the generation of Ed25519 key pairs.
2
2
 
3
3
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
4
4
 
5
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ar]:"No signature verification implementation could be found.",[ir]:"No key generation implementation could be found.",[sr]:"No signing implementation could be found.",[cr]:"No key export implementation could be found.",[Mn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[ta]:"Transaction processing left an account with an outstanding borrowed reference",[ko]:"Account in use",[Vo]:"Account loaded twice",[Wo]:"Attempt to debit an account but found no record of a prior credit.",[ca]:"Transaction loads an address table account that doesn't exist",[$o]:"This transaction has already been processed",[Yo]:"Blockhash not found",[Xo]:"Loader call chain is too deep",[ea]:"Transactions are currently disabled due to cluster maintenance",[Ra]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ho]:"Insufficient funds for fee",[Ea]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Ko]:"This account may not be used to pay transaction fees",[Zo]:"Transaction contains an invalid account reference",[da]:"Transaction loads an address table account with invalid data",[_a]:"Transaction address table lookup uses an invalid index",[ua]:"Transaction loads an address table account with an invalid owner",[ga]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Jo]:"This program may not be used for executing instructions",[Aa]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[oa]:"Transaction loads a writable account that cannot be written",[Ta]:"Transaction exceeded max loaded accounts data size cap",[jo]:"Transaction requires a fee but has no signature present",[Go]:"Attempt to load a program that does not exist",[Sa]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[fa]:"ResanitizationNeeded",[Qo]:"Transaction failed to sanitize accounts offsets correctly",[qo]:"Transaction did not pass signature verification",[sa]:"Transaction locked too many accounts",[Na]:"Sum of account balances before and after transaction do not match",[zo]:"The transaction failed with the error `$errorName`",[ra]:"Transaction version is unsupported",[ia]:"Transaction would exceed account data limit within the block",[Ia]:"Transaction would exceed total account data limit",[aa]:"Transaction would exceed max account limit within the block",[na]:"Transaction would exceed max Block Cost Limit",[la]:"Transaction would exceed max Vote Cost Limit",[ut]:"Attempted to sign a transaction with an address that is not a signer for it",[vo]:"Transaction is missing an address at index: $index.",[dt]:"Transaction has no expected signers therefore it cannot be encoded",[_t]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[ne]:"Transaction does not have a blockhash lifetime",[re]:"Transaction is not a durable nonce transaction",[oe]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[ae]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[se]:"No fee payer set in CompiledTransaction",[ie]:"Could not find program address at index $index",[Fo]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[xo]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[wo]:"Transaction is missing a fee payer.",[ct]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Po]:"Transaction first instruction is not advance nonce account instruction.",[Bo]:"Transaction with no instructions cannot be durable nonce transaction.",[ot]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[at]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ce]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[st]:"Transaction is missing signatures for addresses: $addresses.",[it]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[ue]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[At]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},D="i",S="t";function ti(e,t={}){let n=ei[e];if(n.length===0)return "";let r;function o(i){if(r[S]===2){let s=n.slice(r[D]+1,i);a.push(s in t?`${t[s]}`:`$${s}`);}else r[S]===1&&a.push(n.slice(r[D],i));}let a=[];return n.split("").forEach((i,s)=>{if(s===0){r={[D]:0,[S]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[S]){case 0:c={[D]:s,[S]:1};break;case 1:i==="\\"?c={[D]:s,[S]:0}:i==="$"&&(c={[D]:s,[S]:2});break;case 2:i==="\\"?c={[D]:s,[S]:0}:i==="$"?c={[D]:s,[S]:2}:i.match(/\w/)||(c={[D]:s,[S]:1});break}c&&(r!==c&&o(s),r=c);}),o(),a.join("")}function ni(e,t={}){if(process.env.NODE_ENV!=="production")return ti(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Qa(t)}'`),`${n}\``}}var l=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([a,i])=>{a==="cause"?r={cause:i.value}:(n===void 0&&(n={}),Object.defineProperty(n,a,i));});let o=ni(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function ri(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var oi=(e,t)=>ri(e.length<=t?e:e.slice(0,t),t);function E(e,t,n){let r=e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,a)=>o===r[a])}function Ot(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function M(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Ot(t,e));return e.write(t,n,0),n}})}function I(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function O(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Ct(e,t,n=0){if(t.length-n<=0)throw new l(de,{codecDescription:e})}function F(e,t,n,r=0){let o=n.length-r;if(o<t)throw new l(_e,{bytesLength:o,codecDescription:e,expected:t})}function Dt(e,t,n){if(t<0||t>n)throw new l(Ie,{bytesLength:n,codecDescription:e,offset:t})}function Re(e,t){let n=(i,s)=>{let[c,u]=t.read(i,s),d=Number(c);return s=u,(s>0||i.length>d)&&(i=i.slice(s,s+d)),F("addDecoderSizePrefix",d,i),[e.decode(i),s+d]};if(O(t)&&O(e))return I({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=O(t)?t.fixedSize:t.maxSize??null,o=O(e)?e.fixedSize:e.maxSize??null,a=r!==null&&o!==null?r+o:null;return I({...e,...a!==null?{maxSize:a}:{},read:n})}function y(e,t){return I({fixedSize:t,read:(n,r)=>{F("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),O(e)&&(n=oi(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function ai(e,t){return I({...e,read:(n,r)=>{let o=u=>ii(u,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;Dt("offsetDecoder",a,n.length);let[i,s]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:s,preOffset:r,wrapBytes:o}):s;return Dt("offsetDecoder",c,n.length),[i,c]}})}function ii(e,t){return t===0?0:(e%t+t)%t}function si(e,t){if(O(e)){let n=t(e.fixedSize);if(n<0)throw new l(le,{bytesLength:n,codecDescription:"resizeDecoder"});return I({...e,fixedSize:n})}return e}function mt(e,t){return ai(si(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function b(e,t){return I({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function Lt(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new l(W,{alphabet:e,base:e.length,value:n})}var ci=e=>M({getSizeFromValue:t=>{let[n,r]=pt(t,e[0]);if(!r)return t.length;let o=ht(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Lt(e,t),t==="")return r;let[o,a]=pt(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=ht(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),ui=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=di(i,e);return [a+s,t.length]}});function pt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function ht(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function di(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Mt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Ee=()=>ci(Mt),yt=()=>ui(Mt);var _i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=()=>M({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){Lt(_i,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}});var Ai=e=>e.replace(/\u0000/g,"");var li=globalThis.TextDecoder;var Te=()=>{let e;return I({read(t,n){let r=(e||=new li).decode(t.slice(n));return [Ai(r),t.length]}})};function Ii(e){return !("exists"in e)||"exists"in e&&e.exists}function Ut(e){let t=e.filter(n=>Ii(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new l(te,{addresses:n})}}function Ri(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=w().encode(t.data[0]);return Object.freeze({...bt(t),address:e,data:n,exists:true})}function Ei(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...bt(t),address:e,data:n,exists:true})}function bt(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function vt(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((i,s)=>i&&typeof i=="object"&&"parsed"in i.data?Ei(t[s],i):Ri(t[s],i))}function ge(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new l(ee,{addresses:n})}}var fe,Se;function Ti(){return fe||(fe=Ee()),fe}function gi(){return Se||(Se=yt()),Se}function H(e){if(e.length<32||e.length>44)throw new l(Q,{actualLength:e.length});let r=Ti().encode(e).byteLength;if(r!==32)throw new l(J,{actualLength:r})}function B(e){return H(e),e}function P(){return y(gi(),32)}function fi(e,t,n,r){if(r<t||r>n)throw new l(Ae,{codecDescription:e,max:n,min:t,value:r})}function wt(e){return e?.endian!==1}function Si(e){return M({fixedSize:e.size,write(t,n,r){e.range&&fi(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,wt(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function Bt(e){return I({fixedSize:e.size,read(t,n=0){Ct(e.name,t,n),F(e.name,e.size,t,n);let r=new DataView(Ni(t,n,e.size));return [e.get(r,wt(e.config)),n+e.size]}})}function Ni(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var N=()=>I({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],i=127&a;if(n|=i<<o*7,(a&128)===0)break}return [n,t+r]}});var T=(e={})=>Si({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),De=(e={})=>Bt({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var p=()=>Bt({get:e=>e.getUint8(0),name:"u8",size:1});function K(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function Oe(e){return O(e)?e.fixedSize:null}function Ce(e){return O(e)?e.fixedSize:e.maxSize??null}function C(e,t={}){let n=t.size??De(),r=Oe(e),o=Pt(n,r),a=Pt(n,Ce(e))??void 0;return I({...o!==null?{fixedSize:o}:{maxSize:a},read:(i,s)=>{let c=[];if(typeof n=="object"&&i.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<i.length;){let[A,_]=e.read(i,s);s=_,c.push(A);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(i,s);s=d;for(let A=0;A<u;A+=1){let[_,f]=e.read(i,s);s=f,c.push(_);}return [c,s]}})}function Pt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function x(){return I({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function Ft(e){let t=K(e.map(Oe)),n=K(e.map(Ce))??void 0;return I({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let a=[];return e.forEach(i=>{let[s,c]=i.read(r,o);a.push(s),o=c;}),[a,o]}})}function h(e){let t=e.map(([,o])=>o),n=K(t.map(Oe)),r=K(t.map(Ce))??void 0;return I({...n===null?{maxSize:r}:{fixedSize:n},read:(o,a)=>{let i={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,a);a=d,i[s]=u;}),[i,a]}})}function xt(e,...t){return t.reduce((n,r)=>r(n),e)}var R=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(R||{});function zt(e){return e>=2}function Li(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}var Mi=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=yi(i,e);return [a+s,t.length]}});function yi(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ui="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var bi=()=>Mi(Ui);var me;function vi(){if(!me){let e=C(p(),{size:N()});me=h([["lookupTableAddress",P()],["writableIndexes",e],["readonlyIndexes",e]]);}return me}var pe;function he(){return pe||(pe=p()),pe}function wi(){return h([["numSignerAccounts",he()],["numReadonlySignerAccounts",he()],["numReadonlyNonSignerAccounts",he()]])}var Le;function Bi(){return Le||(Le=b(h([["programAddressIndex",p()],["accountIndices",C(p(),{size:N()})],["data",Re(x(),N())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),Le}var Pi=0,kt=128;function Me(){return I({maxSize:1,read:(e,t)=>{let n=e[t];if((n&kt)===0)return ["legacy",t];{let r=n^kt;if(r>Pi)throw new l(ue,{unsupportedVersion:r});return [r,t+1]}}})}function Fi(){return [["version",Me()],["header",wi()],["staticAccounts",C(P(),{size:N()})],["lifetimeToken",y(bi(),32)],["instructions",C(Bi(),{size:N()})],["addressTableLookups",xi()]]}function xi(){return C(vi(),{size:N()})}function Gt(){return b(h(Fi()),({addressTableLookups:e,...t})=>t.version==="legacy"||!e?.length?t:{...t,addressTableLookups:e})}function zi(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var Ht="SysvarRecentB1ockHashes11111111111111111111",Kt="11111111111111111111111111111111";function Vt(e,t){return {accounts:[{address:e,role:R.WRITABLE},{address:Ht,role:R.READONLY},{address:t,role:R.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Kt}}function ye(e){return e.programAddress===Kt&&e.data!=null&&ki(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===R.WRITABLE&&e.accounts[1].address===Ht&&e.accounts[1].role===R.READONLY&&e.accounts[2].address!=null&&zt(e.accounts[2].role)}function ki(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function $t(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&ye(e.instructions[0])}function Vi(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function Wi({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,a=r.instructions[0];if(a&&ye(a))if(Vi(a,t,n)){if($t(r)&&r.lifetimeConstraint.nonce===e)return r;o=[a,...r.instructions.slice(1)];}else o=[Object.freeze(Vt(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Vt(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function Gi(e,t){if("feePayer"in t&&e===t.feePayer?.address&&Hi(t.feePayer))return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function Hi(e){return !!e&&"address"in e&&typeof e.address=="string"&&Object.keys(e).length===1}function Ki(e,t){return $i([e],t)}function $i(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Yi(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],a=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[a],role:R.WRITABLE_SIGNER}),a++;for(let i=0;i<t.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[a],role:R.READONLY_SIGNER}),a++;for(let i=0;i<r;i++)o.push({address:e.staticAccounts[a],role:R.WRITABLE}),a++;for(let i=0;i<t.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[a],role:R.READONLY}),a++;return o}function Xi(e,t){let r=e.map(i=>i.lookupTableAddress).filter(i=>t[i]===void 0);if(r.length>0)throw new l(oe,{lookupTableAddresses:r});let o=[],a=[];for(let i of e){let s=t[i.lookupTableAddress],c=i.readonlyIndexes,u=i.writableIndexes,d=Math.max(...c,...u);if(d>=s.length)throw new l(ae,{highestKnownIndex:s.length-1,highestRequestedIndex:d,lookupTableAddress:i.lookupTableAddress});let A=c.map(f=>({address:s[f],addressIndex:f,lookupTableAddress:i.lookupTableAddress,role:R.READONLY}));o.push(...A);let _=u.map(f=>({address:s[f],addressIndex:f,lookupTableAddress:i.lookupTableAddress,role:R.WRITABLE}));a.push(..._);}return [...a,...o]}function ji(e,t){let n=t[e.programAddressIndex]?.address;if(!n)throw new l(ie,{index:e.programAddressIndex});let r=e.accountIndices?.map(a=>t[a]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function Zi(e,t,n){if(!t||!ye(t))return {blockhash:e,lastValidBlockHeight:n??2n**64n-1n};{let r=t.accounts[0].address;H(r);let o=t.accounts[2].address;return H(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function Yt(e,t){let n=e.staticAccounts[0];if(!n)throw new l(se);let r=Yi(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?Xi(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[],a=[...r,...o],i=e.instructions.map(u=>ji(u,a)),s=i[0],c=Zi(e.lifetimeToken,s,t?.lastValidBlockHeight);return xt(zi({version:e.version}),u=>Gi(n,u),u=>i.reduce((d,A)=>Ki(A,d),u),u=>"blockhash"in c?Li(c,u):Wi(c,u))}function Xt(){return b(h([["signatures",C(y(x(),64),{size:N()})],["messageBytes",x()]]),qi)}function qi(e){let{messageBytes:t,signatures:n}=e,r=Ft([Me(),mt(p(),2),C(P(),{size:N()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new l(ce,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((u,d)=>{let A=n[d];A.every(_=>_===0)?c[u]=null:c[u]=A;}),{messageBytes:t,signatures:Object.freeze(c)}}async function Ue(e,t,n){if(e.length===0)return {};let r=await vt(t,e,n);return Ut(r),ge(r),r.reduce((o,a)=>({...o,[a.address]:a.data.addresses}),{})}var $="ComputeBudget111111111111111111111111111111";var z="11111111111111111111111111111111";var Y=(e=>(e[e.CreateAccount=0]="CreateAccount",e[e.Assign=1]="Assign",e[e.TransferSol=2]="TransferSol",e[e.CreateAccountWithSeed=3]="CreateAccountWithSeed",e[e.AdvanceNonceAccount=4]="AdvanceNonceAccount",e[e.WithdrawNonceAccount=5]="WithdrawNonceAccount",e[e.InitializeNonceAccount=6]="InitializeNonceAccount",e[e.AuthorizeNonceAccount=7]="AuthorizeNonceAccount",e[e.Allocate=8]="Allocate",e[e.AllocateWithSeed=9]="AllocateWithSeed",e[e.AssignWithSeed=10]="AssignWithSeed",e[e.TransferSolWithSeed=11]="TransferSolWithSeed",e[e.UpgradeNonceAccount=12]="UpgradeNonceAccount",e))(Y||{});function be(e){let t="data"in e?e.data:e;if(E(t,T().encode(0),0))return 0;if(E(t,T().encode(1),0))return 1;if(E(t,T().encode(2),0))return 2;if(E(t,T().encode(3),0))return 3;if(E(t,T().encode(4),0))return 4;if(E(t,T().encode(5),0))return 5;if(E(t,T().encode(6),0))return 6;if(E(t,T().encode(7),0))return 7;if(E(t,T().encode(8),0))return 8;if(E(t,T().encode(9),0))return 9;if(E(t,T().encode(10),0))return 10;if(E(t,T().encode(11),0))return 11;if(E(t,T().encode(12),0))return 12;throw new Error("The provided instruction could not be identified as a system instruction.")}var jt=0,Zt=1,qt=2,Jt=3,Qt=4,en=5,tn=6,nn=7,rn=8;process.env.NODE_ENV!=="production"&&({[jt]:"an account with the same address already exists",[en]:"provided address does not match addressed derived from seed",[Jt]:"cannot allocate account data of this length",[qt]:"cannot assign account to this program id",[Qt]:"length of requested seed is too long",[nn]:"stored nonce is still in recent_blockhashes",[tn]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[rn]:"specified nonce does not match stored nonce",[Zt]:"account does not have enough SOL to perform the operation"});var on="MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";function an(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var ve="Secp256r1SigVerify1111111111111111111111111",sn=new Set([$,z,core.MULTI_WALLET_PROGRAM_ADDRESS,ve,on]),X="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z";function cn(){return {[B(X)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU","oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto","cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y","bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi","oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg","cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B","bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb","oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ","cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf","bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8","oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq","cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc","bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2","oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P","cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6","amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx","ACXg8a7VaqecBWrSbdu73W4Pg9gsqXJ3EXAqkHyhvVXg","r18WwUxfG8kQ69bQPAB2jV6zGNKy3GosFGctjQoV4ti","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg","2yaSthpW4U4VZvBhwPfGA7HwC9v9Rfq3SNRZvJkKcrNe"].map(B)}}var un=new Map;async function dn(e,t){let n=Date.now(),r=un.get(e);if(r&&n-r.cachedAt<3e5)return r;let o=t?`${t.origin}?origin=${encodeURIComponent(e)}`:`${e}/.well-known/revibase.json`,a=await fetch(o);if(!a.ok)throw new Error(`Failed to fetch .well-known/revibase.json for ${e}`);let i=await a.json();if(!i?.clientJwk)throw new Error(`Invalid .well-known response from ${e}`);let s={...i,cachedAt:n};return un.set(e,s),s}function k(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Rn(e,t){try{let n=await jose.importJWK(core.convertBase64StringToJWK(e.jwk)),r=await jose.compactVerify(e.jws,n);if(!k(r.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Device signature verification failed")}}async function En(e,t,n){let r=await dn(e.clientOrigin,n);try{let o=await jose.importJWK(core.convertBase64StringToJWK(r.clientJwk)),a=await jose.compactVerify(e.jws,o);if(!k(a.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Client signature verification failed ")}return r}async function Tn(e,t){let{authResponse:n,startRequest:r,slotHash:o,slotNumber:a,device:i,client:s,estimatedSlotHashExpiry:c}=e;if(r.data.type!=="transaction")throw new Error("Invalid request type.");let{response:u}=n,d=core.base64URLStringToBuffer(u.clientDataJSON),A=JSON.parse(Te().decode(d)),{challenge:_}=await core.createTransactionChallenge(r.data.payload,s.clientOrigin,i.jwk,r.rid,o,a,c),f=core.base64URLStringToBuffer(A.challenge);if(!k(f,_))throw new Error("Invalid challenge");let V=core.getSecp256r1MessageHash(n);if(!k(V,t))throw new Error("Invalid message hash")}async function we(e,t){let n=sha2_js.sha256(t);return k(e.finalBufferHash,n)}async function m(e,t,n){if(!e)return [];let r=e.find(a=>a.instructionIndex===t-1)?.data;if(!r)return [];let{payload:o}=core.getSecp256r1VerifyInstructionDataDecoder().decode(r);return Promise.all(n.map(async a=>{let i=o[a.verifyArgs.signedMessageIndex],s=sha2_js.sha256(i.message);return {signer:new core.Secp256r1Key(i.publicKey),messageHash:s}}))}function Be(e){return e.map(t=>{if(t.memberKey.keyType===core.KeyType.Secp256r1){if(t.messageHash.__option==="None")throw new Error("Message hash cannot be found.");return {signer:new core.Secp256r1Key(core.convertMemberKeyToString(t.memberKey)),messageHash:t.messageHash.value}}else return {signer:B(core.convertMemberKeyToString(t.memberKey))}})}async function L(e,t,n,r,o){if(!r)throw new Error("Transaction Auth Response is missing");if(n.filter(s=>s.signer instanceof core.Secp256r1Key).length!==r.length)throw new Error(`Signer count mismatch. Expected ${n.length} auth responses, got ${r.length}`);let a=await core.getWalletAddressFromSettings(B(t)),i=await Promise.all(n.map(async({signer:s,messageHash:c})=>{if(s instanceof core.Secp256r1Key){if(!c)throw new Error("Hash not found.");let u=r.find(Sn=>an(core.getSecp256r1MessageHash(Sn.authResponse),c));if(!u)throw new Error("Hash mismatch");let{client:d,device:A,startRequest:_,estimatedSlotHashExpiry:f}=u;if(_.data.type!=="transaction")throw new Error("Invalid request type.");let V=Math.min(f,_.validTill);if(V<Date.now())throw new Error("Request has expired.");let[fn]=await Promise.all([En(d,c,o),Tn(u,c),Rn(A,c)]);return {signer:s,walletAddress:a,client:{origin:d.clientOrigin,...fn},device:A.jwk,startRequest:_,estimatedValidTill:V}}return {signer:s,walletAddress:a}}));return {instructions:e,signers:i}}async function U(e,t){let n=e?.data?.data;if(!n||n.__option==="None")throw new Error(t);return core.getSettingsFromIndex(n.value.index)}async function Pe(e,t){let n=core.vaultTransactionMessageDeserialize(t);return (await xe(n,e)).instructions}function Fe(e,t){if(!e)throw new Error("Invalid instruction accounts.");let n=3+(t.addressTableLookups?.length??0),r=e.slice(n);return t.instructions.map(o=>({accounts:[...o.accountIndices].map(a=>r[a]),data:o.data,programAddress:r[o.programAddressIndex].address}))}async function xe(e,t){let r="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups.map(a=>a.lookupTableAddress):[],o=r.length>0?await rc(r,t):{};return Yt(e,{addressesByLookupTableAddress:o})}async function rc(e,t){if(e.some(r=>r.toString()===X)){let r=e.filter(o=>o.toString()!==X);return {...cn(),...await Ue(r,t)}}return Ue(e,t)}async function ze(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts");let a=core.getChangeConfigCompressedInstructionDataDecoder().decode(e.data),i=await U(a.settingsMutArgs,"Invalid instruction data. Settings not found."),s=await m(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),c=3,u=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[c+d.fields[0]].address}));return L([e],i,s.concat(u),r,o)}async function ke(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts.");let a=core.getChangeConfigInstructionDataDecoder().decode(e.data),i=e.accounts[0].address.toString(),s=await m(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),c=5,u=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[c+d.fields[0]].address}));return L([e],i,s.concat(u),r,o)}async function Ve(e,t,n,r,o,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let s=(e===core.MultiWalletInstruction.NativeTransferIntentCompressed?core.getNativeTransferIntentCompressedInstructionDataDecoder():core.getTokenTransferIntentCompressedInstructionDataDecoder()).decode(t.data),c=await U(s.settingsMutArgs,"Invalid instruction data. Settings not found."),u=await m(n,r,s.signers.filter(_=>_.__kind==="Secp256r1").map(_=>_.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntentCompressed?6:17,A=s.signers.filter(_=>_.__kind==="Ed25519").map(_=>({signer:t.accounts[d+_.fields[0]].address}));return L([t],c,u.concat(A),o,a)}async function We(e,t,n,r,o,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let s=(e===core.MultiWalletInstruction.NativeTransferIntent?core.getNativeTransferIntentInstructionDataDecoder():core.getTokenTransferIntentInstructionDataDecoder()).decode(t.data),c=t.accounts[0].address.toString(),u=await m(n,r,s.signers.filter(_=>_.__kind==="Secp256r1").map(_=>_.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntent?6:18,A=s.signers.filter(_=>_.__kind==="Ed25519").map(_=>({signer:t.accounts[d+_.fields[0]].address}));return L([t],c,u.concat(A),o,a)}function Ge(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getCreateUserAccountsInstructionDataDecoder().decode(e.data);for(let r of n.createUserArgs){if(r.member.toString()!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r.member.toString()}`);if(r.transactionManagerUrl?.__option==="None")throw new Error("Transaction manager URL cannot be empty when creating user accounts");if(r.transactionManagerUrl?.value!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${r.transactionManagerUrl?.value}`)}return null}function He(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getEditTransactionManagerUrlInstructionDataDecoder().decode(e.data),r=core.convertMemberKeyToString(n.userMutArgs.data.member);if(r!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r}`);if(n.transactionManagerUrl!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${n.transactionManagerUrl}`);return null}async function Ke(e,t,n,r,o,a,i,s,c){if(!t.accounts)throw new Error("Invalid instruction accounts");if(!t.data)throw new Error("Invalid instruction data");Tc(t,r);let u=n===core.MultiWalletInstruction.TransactionBufferCreate||n===core.MultiWalletInstruction.TransactionBufferCreateCompressed,d=n===core.MultiWalletInstruction.TransactionBufferCreateCompressed||n===core.MultiWalletInstruction.TransactionExecuteSyncCompressed,A;return u?A=await gc(e,t,d,s):A=await Nc(t,d,i,o),L(A.instructionsToVerify,A.settingsAddress,A.signers,a,c)}function Tc(e,t){let n=e.accounts?.find(r=>r.address.toString()===t.publicKey);if(n&&n.role!==R.READONLY_SIGNER)throw new Error("Transaction Manager should be readonly signer.")}async function gc(e,t,n,r){if(!r)throw new Error("Missing transaction message bytes");if(!t.data||!t.accounts)throw new Error("Invalid instruction");let o=w().encode(r);return n?fc(e,t,o):Sc(e,t,o)}async function fc(e,t,n){let r=core.getTransactionBufferCreateCompressedInstructionDataDecoder().decode(t.data),o=await U(r.settingsReadonlyArgs,"Settings account is required for compressed transaction buffer create"),a=Be(r.args.expectedSigners);if(!await we(r.args,n))throw new Error("Hash mismatch.");let s=await Pe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Sc(e,t,n){let r=core.getTransactionBufferCreateInstructionDataDecoder().decode(t.data),o=t.accounts[0].address.toString(),a=Be(r.args.expectedSigners);if(!await we(r.args,n))throw new Error("Hash mismatch.");let s=await Pe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Nc(e,t,n,r){if(!e.data||!e.accounts)throw new Error("Invalid instruction");return t?Dc(e,n,r):Oc(e,n,r)}async function Dc(e,t,n){if(!e.accounts)throw new Error("Invalid instruction accounts.");let r=core.getTransactionExecuteSyncCompressedInstructionDataDecoder().decode(e.data),o=await U(r.settingsMutArgs,"Settings account is required for compressed transaction execute"),a=await m(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),i=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[i+u.fields[0]].address})),c=Fe(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a.concat(s),instructionsToVerify:c}}async function Oc(e,t,n){if(!e.accounts)throw new Error("Invalid instruction accounts.");let r=core.getTransactionExecuteSyncInstructionDataDecoder().decode(e.data),o=e.accounts[0].address.toString(),a=await m(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),i=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[i+u.fields[0]].address})),c=Fe(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a.concat(s),instructionsToVerify:c}}async function pc(e,t,n,r){let{transaction:o,transactionMessageBytes:a,authResponses:i}=n,{messageBytes:s}=Xt().decode(w().encode(o)),c=Gt().decode(s),{instructions:u}=await xe(c,e),d=hc(u),A=(await Promise.all(u.map((_,f)=>Lc(e,_,t,f,i,d,a,r)))).filter(_=>_!==null);return {transactionMessage:s,verificationResults:A}}function hc(e){return e.map((t,n)=>({instruction:t,instructionIndex:n})).filter(({instruction:t})=>t.programAddress.toString()===ve).map(({instructionIndex:t,instruction:n})=>({instructionIndex:t,data:n.data}))}async function Lc(e,t,n,r,o,a,i,s){let c=t.programAddress.toString();if(!sn.has(c))throw new Error("Instruction rejected by Transaction Manager.");if(!t.data)throw new Error("Invalid instruction data.");if(c===z.toString()){if(be({data:t.data})!==Y.AdvanceNonceAccount)throw new Error("Instruction rejected by Transaction Manager.");return null}if(c!==core.MULTI_WALLET_PROGRAM_ADDRESS.toString())return null;let u=core.identifyMultiWalletInstruction({data:t.data});return Mc(e,t,u,n,r,o,a,i,s)}async function Mc(e,t,n,r,o,a,i,s,c){switch(n){case core.MultiWalletInstruction.DecompressSettingsAccount:case core.MultiWalletInstruction.TransactionBufferClose:case core.MultiWalletInstruction.TransactionBufferCloseCompressed:return null;case core.MultiWalletInstruction.ChangeConfig:return ke(t,i,o,a,c);case core.MultiWalletInstruction.ChangeConfigCompressed:return ze(t,i,o,a,c);case core.MultiWalletInstruction.CreateUserAccounts:return Ge(t,r);case core.MultiWalletInstruction.EditTransactionManagerUrl:return He(t,r);case core.MultiWalletInstruction.NativeTransferIntent:case core.MultiWalletInstruction.TokenTransferIntent:return We(n,t,i,o,a,c);case core.MultiWalletInstruction.NativeTransferIntentCompressed:case core.MultiWalletInstruction.TokenTransferIntentCompressed:return Ve(n,t,i,o,a,c);case core.MultiWalletInstruction.TransactionBufferCreate:case core.MultiWalletInstruction.TransactionBufferCreateCompressed:case core.MultiWalletInstruction.TransactionExecuteSync:case core.MultiWalletInstruction.TransactionExecuteSyncCompressed:return Ke(e,t,n,r,o,a,i,s,c);default:throw new Error("Instruction rejected by transaction manager.")}}/*! Bundled license information:
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[ir]:"No signature verification implementation could be found.",[sr]:"No key generation implementation could be found.",[cr]:"No signing implementation could be found.",[ur]:"No key export implementation could be found.",[yn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[na]:"Transaction processing left an account with an outstanding borrowed reference",[Vo]:"Account in use",[Wo]:"Account loaded twice",[Go]:"Attempt to debit an account but found no record of a prior credit.",[ua]:"Transaction loads an address table account that doesn't exist",[Yo]:"This transaction has already been processed",[Xo]:"Blockhash not found",[jo]:"Loader call chain is too deep",[ta]:"Transactions are currently disabled due to cluster maintenance",[Ra]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ko]:"Insufficient funds for fee",[ga]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[$o]:"This account may not be used to pay transaction fees",[Zo]:"Transaction contains an invalid account reference",[_a]:"Transaction loads an address table account with invalid data",[Aa]:"Transaction address table lookup uses an invalid index",[da]:"Transaction loads an address table account with an invalid owner",[fa]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Qo]:"This program may not be used for executing instructions",[la]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[aa]:"Transaction loads a writable account that cannot be written",[Ta]:"Transaction exceeded max loaded accounts data size cap",[qo]:"Transaction requires a fee but has no signature present",[Ho]:"Attempt to load a program that does not exist",[Na]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Sa]:"ResanitizationNeeded",[ea]:"Transaction failed to sanitize accounts offsets correctly",[Jo]:"Transaction did not pass signature verification",[ca]:"Transaction locked too many accounts",[Da]:"Sum of account balances before and after transaction do not match",[ko]:"The transaction failed with the error `$errorName`",[oa]:"Transaction version is unsupported",[sa]:"Transaction would exceed account data limit within the block",[Ea]:"Transaction would exceed total account data limit",[ia]:"Transaction would exceed max account limit within the block",[ra]:"Transaction would exceed max Block Cost Limit",[Ia]:"Transaction would exceed max Vote Cost Limit",[_t]:"Attempted to sign a transaction with an address that is not a signer for it",[wo]:"Transaction is missing an address at index: $index.",[At]:"Transaction has no expected signers therefore it cannot be encoded",[lt]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[oe]:"Transaction does not have a blockhash lifetime",[ae]:"Transaction is not a durable nonce transaction",[ie]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[se]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[ue]:"No fee payer set in CompiledTransaction",[ce]:"Could not find program address at index $index",[xo]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[zo]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Bo]:"Transaction is missing a fee payer.",[dt]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Fo]:"Transaction first instruction is not advance nonce account instruction.",[Po]:"Transaction with no instructions cannot be durable nonce transaction.",[it]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[st]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[de]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[ut]:"Transaction is missing signatures for addresses: $addresses.",[ct]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[_e]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[It]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},D="i",S="t";function ni(e,t={}){let n=ti[e];if(n.length===0)return "";let r;function o(i){if(r[S]===2){let s=n.slice(r[D]+1,i);a.push(s in t?`${t[s]}`:`$${s}`);}else r[S]===1&&a.push(n.slice(r[D],i));}let a=[];return n.split("").forEach((i,s)=>{if(s===0){r={[D]:0,[S]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[S]){case 0:c={[D]:s,[S]:1};break;case 1:i==="\\"?c={[D]:s,[S]:0}:i==="$"&&(c={[D]:s,[S]:2});break;case 2:i==="\\"?c={[D]:s,[S]:0}:i==="$"?c={[D]:s,[S]:2}:i.match(/\w/)||(c={[D]:s,[S]:1});break}c&&(r!==c&&o(s),r=c);}),o(),a.join("")}function ri(e,t={}){if(process.env.NODE_ENV!=="production")return ni(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${ei(t)}'`),`${n}\``}}var l=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([a,i])=>{a==="cause"?r={cause:i.value}:(n===void 0&&(n={}),Object.defineProperty(n,a,i));});let o=ri(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function oi(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var ai=(e,t)=>oi(e.length<=t?e:e.slice(0,t),t);function R(e,t,n){let r=e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,a)=>o===r[a])}function mt(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function M(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(mt(t,e));return e.write(t,n,0),n}})}function I(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function O(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function pt(e,t,n=0){if(t.length-n<=0)throw new l(Ae,{codecDescription:e})}function F(e,t,n,r=0){let o=n.length-r;if(o<t)throw new l(le,{bytesLength:o,codecDescription:e,expected:t})}function Ct(e,t,n){if(t<0||t>n)throw new l(Re,{bytesLength:n,codecDescription:e,offset:t})}function ge(e,t){let n=(i,s)=>{let[c,u]=t.read(i,s),d=Number(c);return s=u,(s>0||i.length>d)&&(i=i.slice(s,s+d)),F("addDecoderSizePrefix",d,i),[e.decode(i),s+d]};if(O(t)&&O(e))return I({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=O(t)?t.fixedSize:t.maxSize??null,o=O(e)?e.fixedSize:e.maxSize??null,a=r!==null&&o!==null?r+o:null;return I({...e,...a!==null?{maxSize:a}:{},read:n})}function y(e,t){return I({fixedSize:t,read:(n,r)=>{F("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),O(e)&&(n=ai(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function ii(e,t){return I({...e,read:(n,r)=>{let o=u=>si(u,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;Ct("offsetDecoder",a,n.length);let[i,s]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:s,preOffset:r,wrapBytes:o}):s;return Ct("offsetDecoder",c,n.length),[i,c]}})}function si(e,t){return t===0?0:(e%t+t)%t}function ci(e,t){if(O(e)){let n=t(e.fixedSize);if(n<0)throw new l(Ee,{bytesLength:n,codecDescription:"resizeDecoder"});return I({...e,fixedSize:n})}return e}function ht(e,t){return ii(ci(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function b(e,t){return I({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function yt(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new l(W,{alphabet:e,base:e.length,value:n})}var ui=e=>M({getSizeFromValue:t=>{let[n,r]=Lt(t,e[0]);if(!r)return t.length;let o=Mt(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(yt(e,t),t==="")return r;let[o,a]=Lt(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=Mt(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),di=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=_i(i,e);return [a+s,t.length]}});function Lt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Mt(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function _i(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ut="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Te=()=>ui(Ut),bt=()=>di(Ut);var Ai="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=()=>M({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){yt(Ai,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}});var li=e=>e.replace(/\u0000/g,"");var Ii=globalThis.TextDecoder;var fe=()=>{let e;return I({read(t,n){let r=(e||=new Ii).decode(t.slice(n));return [li(r),t.length]}})};function Ei(e){return !("exists"in e)||"exists"in e&&e.exists}function vt(e){let t=e.filter(n=>Ei(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new l(re,{addresses:n})}}function Ri(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=w().encode(t.data[0]);return Object.freeze({...wt(t),address:e,data:n,exists:true})}function gi(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...wt(t),address:e,data:n,exists:true})}function wt(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function Bt(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((i,s)=>i&&typeof i=="object"&&"parsed"in i.data?gi(t[s],i):Ri(t[s],i))}function Se(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new l(ne,{addresses:n})}}var Ne,De;function Ti(){return Ne||(Ne=Te()),Ne}function fi(){return De||(De=bt()),De}function H(e){if(e.length<32||e.length>44)throw new l(te,{actualLength:e.length});let r=Ti().encode(e).byteLength;if(r!==32)throw new l(ee,{actualLength:r})}function B(e){return H(e),e}function P(){return y(fi(),32)}function Si(e,t,n,r){if(r<t||r>n)throw new l(Ie,{codecDescription:e,max:n,min:t,value:r})}function Pt(e){return e?.endian!==1}function Ni(e){return M({fixedSize:e.size,write(t,n,r){e.range&&Si(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,Pt(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function Ft(e){return I({fixedSize:e.size,read(t,n=0){pt(e.name,t,n),F(e.name,e.size,t,n);let r=new DataView(Di(t,n,e.size));return [e.get(r,Pt(e.config)),n+e.size]}})}function Di(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var N=()=>I({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],i=127&a;if(n|=i<<o*7,(a&128)===0)break}return [n,t+r]}});var g=(e={})=>Ni({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Ce=(e={})=>Ft({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var p=()=>Ft({get:e=>e.getUint8(0),name:"u8",size:1});function K(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function me(e){return O(e)?e.fixedSize:null}function pe(e){return O(e)?e.fixedSize:e.maxSize??null}function C(e,t={}){let n=t.size??Ce(),r=me(e),o=xt(n,r),a=xt(n,pe(e))??void 0;return I({...o!==null?{fixedSize:o}:{maxSize:a},read:(i,s)=>{let c=[];if(typeof n=="object"&&i.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<i.length;){let[A,_]=e.read(i,s);s=_,c.push(A);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(i,s);s=d;for(let A=0;A<u;A+=1){let[_,f]=e.read(i,s);s=f,c.push(_);}return [c,s]}})}function xt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function x(){return I({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function zt(e){let t=K(e.map(me)),n=K(e.map(pe))??void 0;return I({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let a=[];return e.forEach(i=>{let[s,c]=i.read(r,o);a.push(s),o=c;}),[a,o]}})}function h(e){let t=e.map(([,o])=>o),n=K(t.map(me)),r=K(t.map(pe))??void 0;return I({...n===null?{maxSize:r}:{fixedSize:n},read:(o,a)=>{let i={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,a);a=d,i[s]=u;}),[i,a]}})}function kt(e,...t){return t.reduce((n,r)=>r(n),e)}var E=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(E||{});function Vt(e){return e>=2}function Mi(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}var yi=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Ui(i,e);return [a+s,t.length]}});function Ui(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var bi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var vi=()=>yi(bi);var he;function wi(){if(!he){let e=C(p(),{size:N()});he=h([["lookupTableAddress",P()],["writableIndexes",e],["readonlyIndexes",e]]);}return he}var Le;function Me(){return Le||(Le=p()),Le}function Bi(){return h([["numSignerAccounts",Me()],["numReadonlySignerAccounts",Me()],["numReadonlyNonSignerAccounts",Me()]])}var ye;function Pi(){return ye||(ye=b(h([["programAddressIndex",p()],["accountIndices",C(p(),{size:N()})],["data",ge(x(),N())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),ye}var Fi=0,Wt=128;function Ue(){return I({maxSize:1,read:(e,t)=>{let n=e[t];if((n&Wt)===0)return ["legacy",t];{let r=n^Wt;if(r>Fi)throw new l(_e,{unsupportedVersion:r});return [r,t+1]}}})}function xi(){return [["version",Ue()],["header",Bi()],["staticAccounts",C(P(),{size:N()})],["lifetimeToken",y(vi(),32)],["instructions",C(Pi(),{size:N()})],["addressTableLookups",zi()]]}function zi(){return C(wi(),{size:N()})}function Kt(){return b(h(xi()),({addressTableLookups:e,...t})=>t.version==="legacy"||!e?.length?t:{...t,addressTableLookups:e})}function ki(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var $t="SysvarRecentB1ockHashes11111111111111111111",Yt="11111111111111111111111111111111";function Gt(e,t){return {accounts:[{address:e,role:E.WRITABLE},{address:$t,role:E.READONLY},{address:t,role:E.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:Yt}}function be(e){return e.programAddress===Yt&&e.data!=null&&Vi(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===E.WRITABLE&&e.accounts[1].address===$t&&e.accounts[1].role===E.READONLY&&e.accounts[2].address!=null&&Vt(e.accounts[2].role)}function Vi(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Xt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&be(e.instructions[0])}function Wi(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function Gi({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,a=r.instructions[0];if(a&&be(a))if(Wi(a,t,n)){if(Xt(r)&&r.lifetimeConstraint.nonce===e)return r;o=[a,...r.instructions.slice(1)];}else o=[Object.freeze(Gt(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Gt(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function Hi(e,t){if("feePayer"in t&&e===t.feePayer?.address&&Ki(t.feePayer))return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function Ki(e){return !!e&&"address"in e&&typeof e.address=="string"&&Object.keys(e).length===1}function $i(e,t){return Yi([e],t)}function Yi(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Xi(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],a=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[a],role:E.WRITABLE_SIGNER}),a++;for(let i=0;i<t.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[a],role:E.READONLY_SIGNER}),a++;for(let i=0;i<r;i++)o.push({address:e.staticAccounts[a],role:E.WRITABLE}),a++;for(let i=0;i<t.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[a],role:E.READONLY}),a++;return o}function ji(e,t){let r=e.map(i=>i.lookupTableAddress).filter(i=>t[i]===void 0);if(r.length>0)throw new l(ie,{lookupTableAddresses:r});let o=[],a=[];for(let i of e){let s=t[i.lookupTableAddress],c=i.readonlyIndexes,u=i.writableIndexes,d=Math.max(...c,...u);if(d>=s.length)throw new l(se,{highestKnownIndex:s.length-1,highestRequestedIndex:d,lookupTableAddress:i.lookupTableAddress});let A=c.map(f=>({address:s[f],addressIndex:f,lookupTableAddress:i.lookupTableAddress,role:E.READONLY}));o.push(...A);let _=u.map(f=>({address:s[f],addressIndex:f,lookupTableAddress:i.lookupTableAddress,role:E.WRITABLE}));a.push(..._);}return [...a,...o]}function qi(e,t){let n=t[e.programAddressIndex]?.address;if(!n)throw new l(ce,{index:e.programAddressIndex});let r=e.accountIndices?.map(a=>t[a]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function Zi(e,t,n){if(!t||!be(t))return {blockhash:e,lastValidBlockHeight:n??2n**64n-1n};{let r=t.accounts[0].address;H(r);let o=t.accounts[2].address;return H(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function jt(e,t){let n=e.staticAccounts[0];if(!n)throw new l(ue);let r=Xi(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?ji(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[],a=[...r,...o],i=e.instructions.map(u=>qi(u,a)),s=i[0],c=Zi(e.lifetimeToken,s,t?.lastValidBlockHeight);return kt(ki({version:e.version}),u=>Hi(n,u),u=>i.reduce((d,A)=>$i(A,d),u),u=>"blockhash"in c?Mi(c,u):Gi(c,u))}function qt(){return b(h([["signatures",C(y(x(),64),{size:N()})],["messageBytes",x()]]),Ji)}function Ji(e){let{messageBytes:t,signatures:n}=e,r=zt([Ue(),ht(p(),2),C(P(),{size:N()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new l(de,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((u,d)=>{let A=n[d];A.every(_=>_===0)?c[u]=null:c[u]=A;}),{messageBytes:t,signatures:Object.freeze(c)}}async function ve(e,t,n){if(e.length===0)return {};let r=await Bt(t,e,n);return vt(r),Se(r),r.reduce((o,a)=>({...o,[a.address]:a.data.addresses}),{})}var $="ComputeBudget111111111111111111111111111111";var Zt=new Map;async function Jt(e){let t=Date.now(),n=Zt.get(e);if(n&&t-n.cachedAt<3e5)return n;let r=`${e}/.well-known/revibase.json`,o=await fetch(r);if(!o.ok)throw new Error(`Failed to fetch .well-known/revibase.json for ${e}`);let a=await o.json();if(!a?.clientJwk)throw new Error(`Invalid .well-known response from ${e}`);let i={...a,cachedAt:t};return Zt.set(e,i),i}function z(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Y(e,t){try{let n=await jose.importJWK(core.convertBase64StringToJWK(e.jwk)),r=await jose.compactVerify(e.jws,n);if(!z(r.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Device signature verification failed")}}async function X(e,t,n){let r=await n?.(e.clientOrigin)??await Jt(e.clientOrigin);try{let o=await jose.importJWK(core.convertBase64StringToJWK(r.clientJwk)),a=await jose.compactVerify(e.jws,o);if(!z(a.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Client signature verification failed ")}return r}async function rn(e,t){let{authResponse:n,startRequest:r,slotHash:o,slotNumber:a,device:i,client:s,estimatedSlotHashExpiry:c}=e;if(r.data.type!=="transaction")throw new Error("Invalid request type.");if(s.clientOrigin!==r.clientOrigin)throw new Error("Client mismatch");let{response:u}=n,d=core.base64URLStringToBuffer(u.clientDataJSON),A=JSON.parse(fe().decode(d)),{challenge:_}=await core.createTransactionChallenge(r.data.payload,r.clientOrigin,i.jwk,r.rid,o,a,c),f=core.base64URLStringToBuffer(A.challenge);if(!z(f,_))throw new Error("Invalid challenge");let V=core.getSecp256r1MessageHash(n);if(!z(V,t))throw new Error("Invalid message hash")}async function we(e,t){let n=sha2_js.sha256(t);return z(e.finalBufferHash,n)}async function on(e){let{startRequest:t}=e.data.payload,n=core.createMessageChallenge(t.data.payload,t.clientOrigin,e.data.payload.device.jwk,t.rid),{verified:r}=await server.verifyAuthenticationResponse({response:e.data.payload.authResponse,expectedChallenge:core.bufferToBase64URLString(n),expectedRPID:t.rpId,expectedOrigin:t.providerOrigin,requireUserVerification:false,credential:{counter:0,id:e.data.payload.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(e.data.payload.signer)}});if(!r)throw new Error("Invalid user siganture")}async function tc(e,t){let{startRequest:n}=e.data.payload;if(n.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>n.validTill)throw new Error("Request expired.");let[r]=await Promise.all([X(e.data.payload.client,core.createClientAuthorizationStartRequestChallenge(n),t),Y(e.data.payload.device,core.getSecp256r1MessageHash(e.data.payload.authResponse)),on(e)]);return {payload:e,clientDetails:r}}var k="11111111111111111111111111111111";var j=(e=>(e[e.CreateAccount=0]="CreateAccount",e[e.Assign=1]="Assign",e[e.TransferSol=2]="TransferSol",e[e.CreateAccountWithSeed=3]="CreateAccountWithSeed",e[e.AdvanceNonceAccount=4]="AdvanceNonceAccount",e[e.WithdrawNonceAccount=5]="WithdrawNonceAccount",e[e.InitializeNonceAccount=6]="InitializeNonceAccount",e[e.AuthorizeNonceAccount=7]="AuthorizeNonceAccount",e[e.Allocate=8]="Allocate",e[e.AllocateWithSeed=9]="AllocateWithSeed",e[e.AssignWithSeed=10]="AssignWithSeed",e[e.TransferSolWithSeed=11]="TransferSolWithSeed",e[e.UpgradeNonceAccount=12]="UpgradeNonceAccount",e))(j||{});function Be(e){let t="data"in e?e.data:e;if(R(t,g().encode(0),0))return 0;if(R(t,g().encode(1),0))return 1;if(R(t,g().encode(2),0))return 2;if(R(t,g().encode(3),0))return 3;if(R(t,g().encode(4),0))return 4;if(R(t,g().encode(5),0))return 5;if(R(t,g().encode(6),0))return 6;if(R(t,g().encode(7),0))return 7;if(R(t,g().encode(8),0))return 8;if(R(t,g().encode(9),0))return 9;if(R(t,g().encode(10),0))return 10;if(R(t,g().encode(11),0))return 11;if(R(t,g().encode(12),0))return 12;throw new Error("The provided instruction could not be identified as a system instruction.")}var an=0,sn=1,cn=2,un=3,dn=4,_n=5,An=6,ln=7,In=8;process.env.NODE_ENV!=="production"&&({[an]:"an account with the same address already exists",[_n]:"provided address does not match addressed derived from seed",[un]:"cannot allocate account data of this length",[cn]:"cannot assign account to this program id",[dn]:"length of requested seed is too long",[ln]:"stored nonce is still in recent_blockhashes",[An]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[In]:"specified nonce does not match stored nonce",[sn]:"account does not have enough SOL to perform the operation"});var En="MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";function Rn(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}var Pe="Secp256r1SigVerify1111111111111111111111111",gn=new Set([$,k,core.MULTI_WALLET_PROGRAM_ADDRESS,Pe,En]),q="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z";function Tn(){return {[B(q)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU","oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto","cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y","bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi","oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg","cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B","bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb","oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ","cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf","bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8","oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq","cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc","bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2","oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P","cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6","amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx","ACXg8a7VaqecBWrSbdu73W4Pg9gsqXJ3EXAqkHyhvVXg","r18WwUxfG8kQ69bQPAB2jV6zGNKy3GosFGctjQoV4ti","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg","2yaSthpW4U4VZvBhwPfGA7HwC9v9Rfq3SNRZvJkKcrNe"].map(B)}}async function m(e,t,n){if(!e)return [];let r=e.find(a=>a.instructionIndex===t-1)?.data;if(!r)return [];let{payload:o}=core.getSecp256r1VerifyInstructionDataDecoder().decode(r);return Promise.all(n.map(async a=>{let i=o[a.verifyArgs.signedMessageIndex],s=sha2_js.sha256(i.message);return {signer:new core.Secp256r1Key(i.publicKey),messageHash:s}}))}function Fe(e){return e.map(t=>{if(t.memberKey.keyType===core.KeyType.Secp256r1){if(t.messageHash.__option==="None")throw new Error("Message hash cannot be found.");return {signer:new core.Secp256r1Key(core.convertMemberKeyToString(t.memberKey)),messageHash:t.messageHash.value}}else return {signer:B(core.convertMemberKeyToString(t.memberKey))}})}async function L(e,t,n,r,o){if(!r)throw new Error("Transaction Auth Response is missing");if(n.filter(s=>s.signer instanceof core.Secp256r1Key).length!==r.length)throw new Error(`Signer count mismatch. Expected ${n.length} auth responses, got ${r.length}`);let a=await core.getWalletAddressFromSettings(B(t)),i=await Promise.all(n.map(async({signer:s,messageHash:c})=>{if(s instanceof core.Secp256r1Key){if(!c)throw new Error("Hash not found.");let u=r.find(Nn=>Rn(core.getSecp256r1MessageHash(Nn.authResponse),c));if(!u)throw new Error("Hash mismatch");let{client:d,device:A,startRequest:_,estimatedSlotHashExpiry:f}=u;if(_.data.type!=="transaction")throw new Error("Invalid request type.");let V=Math.min(f,_.validTill);if(V<Date.now())throw new Error("Request has expired.");let[Sn]=await Promise.all([X(d,c,o),rn(u,c),Y(A,c)]);return {signer:s,walletAddress:a,client:{origin:d.clientOrigin,...Sn},device:A.jwk,startRequest:_,estimatedValidTill:V}}return {signer:s,walletAddress:a}}));return {instructions:e,signers:i}}async function U(e,t){let n=e?.data?.data;if(!n||n.__option==="None")throw new Error(t);return core.getSettingsFromIndex(n.value.index)}async function xe(e,t){let n=core.vaultTransactionMessageDeserialize(t);return (await ke(n,e)).instructions}function ze(e,t){if(!e)throw new Error("Invalid instruction accounts.");let n=3+(t.addressTableLookups?.length??0),r=e.slice(n);return t.instructions.map(o=>({accounts:[...o.accountIndices].map(a=>r[a]),data:o.data,programAddress:r[o.programAddressIndex].address}))}async function ke(e,t){let r="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups.map(a=>a.lookupTableAddress):[],o=r.length>0?await _c(r,t):{};return jt(e,{addressesByLookupTableAddress:o})}async function _c(e,t){if(e.some(r=>r.toString()===q)){let r=e.filter(o=>o.toString()!==q);return {...Tn(),...await ve(r,t)}}return ve(e,t)}async function Ve(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts");let a=core.getChangeConfigCompressedInstructionDataDecoder().decode(e.data),i=await U(a.settingsMutArgs,"Invalid instruction data. Settings not found."),s=await m(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),c=3,u=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[c+d.fields[0]].address}));return L([e],i,s.concat(u),r,o)}async function We(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts.");let a=core.getChangeConfigInstructionDataDecoder().decode(e.data),i=e.accounts[0].address.toString(),s=await m(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),c=5,u=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[c+d.fields[0]].address}));return L([e],i,s.concat(u),r,o)}async function Ge(e,t,n,r,o,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let s=(e===core.MultiWalletInstruction.NativeTransferIntentCompressed?core.getNativeTransferIntentCompressedInstructionDataDecoder():core.getTokenTransferIntentCompressedInstructionDataDecoder()).decode(t.data),c=await U(s.settingsMutArgs,"Invalid instruction data. Settings not found."),u=await m(n,r,s.signers.filter(_=>_.__kind==="Secp256r1").map(_=>_.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntentCompressed?6:17,A=s.signers.filter(_=>_.__kind==="Ed25519").map(_=>({signer:t.accounts[d+_.fields[0]].address}));return L([t],c,u.concat(A),o,a)}async function He(e,t,n,r,o,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let s=(e===core.MultiWalletInstruction.NativeTransferIntent?core.getNativeTransferIntentInstructionDataDecoder():core.getTokenTransferIntentInstructionDataDecoder()).decode(t.data),c=t.accounts[0].address.toString(),u=await m(n,r,s.signers.filter(_=>_.__kind==="Secp256r1").map(_=>_.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntent?6:18,A=s.signers.filter(_=>_.__kind==="Ed25519").map(_=>({signer:t.accounts[d+_.fields[0]].address}));return L([t],c,u.concat(A),o,a)}function Ke(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getCreateUserAccountsInstructionDataDecoder().decode(e.data);for(let r of n.createUserArgs){if(r.member.toString()!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r.member.toString()}`);if(r.transactionManagerUrl?.__option==="None")throw new Error("Transaction manager URL cannot be empty when creating user accounts");if(r.transactionManagerUrl?.value!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${r.transactionManagerUrl?.value}`)}return null}function $e(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getEditTransactionManagerUrlInstructionDataDecoder().decode(e.data),r=core.convertMemberKeyToString(n.userMutArgs.data.member);if(r!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r}`);if(n.transactionManagerUrl!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${n.transactionManagerUrl}`);return null}async function Ye(e,t,n,r,o,a,i,s,c){if(!t.accounts)throw new Error("Invalid instruction accounts");if(!t.data)throw new Error("Invalid instruction data");mc(t,r);let u=n===core.MultiWalletInstruction.TransactionBufferCreate||n===core.MultiWalletInstruction.TransactionBufferCreateCompressed,d=n===core.MultiWalletInstruction.TransactionBufferCreateCompressed||n===core.MultiWalletInstruction.TransactionExecuteSyncCompressed,A;return u?A=await pc(e,t,d,s):A=await Mc(t,d,i,o),L(A.instructionsToVerify,A.settingsAddress,A.signers,a,c)}function mc(e,t){let n=e.accounts?.find(r=>r.address.toString()===t.publicKey);if(n&&n.role!==E.READONLY_SIGNER)throw new Error("Transaction Manager should be readonly signer.")}async function pc(e,t,n,r){if(!r)throw new Error("Missing transaction message bytes");if(!t.data||!t.accounts)throw new Error("Invalid instruction");let o=w().encode(r);return n?hc(e,t,o):Lc(e,t,o)}async function hc(e,t,n){let r=core.getTransactionBufferCreateCompressedInstructionDataDecoder().decode(t.data),o=await U(r.settingsReadonlyArgs,"Settings account is required for compressed transaction buffer create"),a=Fe(r.args.expectedSigners);if(!await we(r.args,n))throw new Error("Hash mismatch.");let s=await xe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Lc(e,t,n){let r=core.getTransactionBufferCreateInstructionDataDecoder().decode(t.data),o=t.accounts[0].address.toString(),a=Fe(r.args.expectedSigners);if(!await we(r.args,n))throw new Error("Hash mismatch.");let s=await xe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Mc(e,t,n,r){if(!e.data||!e.accounts)throw new Error("Invalid instruction");return t?yc(e,n,r):Uc(e,n,r)}async function yc(e,t,n){if(!e.accounts)throw new Error("Invalid instruction accounts.");let r=core.getTransactionExecuteSyncCompressedInstructionDataDecoder().decode(e.data),o=await U(r.settingsMutArgs,"Settings account is required for compressed transaction execute"),a=await m(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),i=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[i+u.fields[0]].address})),c=ze(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a.concat(s),instructionsToVerify:c}}async function Uc(e,t,n){if(!e.accounts)throw new Error("Invalid instruction accounts.");let r=core.getTransactionExecuteSyncInstructionDataDecoder().decode(e.data),o=e.accounts[0].address.toString(),a=await m(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),i=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[i+u.fields[0]].address})),c=ze(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a.concat(s),instructionsToVerify:c}}async function wc(e,t,n,r){let{transaction:o,transactionMessageBytes:a,authResponses:i}=n,{messageBytes:s}=qt().decode(w().encode(o)),c=Kt().decode(s),{instructions:u}=await ke(c,e),d=Bc(u),A=(await Promise.all(u.map((_,f)=>Pc(e,_,t,f,i,d,a,r)))).filter(_=>_!==null);return {transactionMessage:s,verificationResults:A}}function Bc(e){return e.map((t,n)=>({instruction:t,instructionIndex:n})).filter(({instruction:t})=>t.programAddress.toString()===Pe).map(({instructionIndex:t,instruction:n})=>({instructionIndex:t,data:n.data}))}async function Pc(e,t,n,r,o,a,i,s){let c=t.programAddress.toString();if(!gn.has(c))throw new Error("Instruction rejected by Transaction Manager.");if(!t.data)throw new Error("Invalid instruction data.");if(c===k.toString()){if(Be({data:t.data})!==j.AdvanceNonceAccount)throw new Error("Instruction rejected by Transaction Manager.");return null}if(c!==core.MULTI_WALLET_PROGRAM_ADDRESS.toString())return null;let u=core.identifyMultiWalletInstruction({data:t.data});return Fc(e,t,u,n,r,o,a,i,s)}async function Fc(e,t,n,r,o,a,i,s,c){switch(n){case core.MultiWalletInstruction.DecompressSettingsAccount:case core.MultiWalletInstruction.TransactionBufferClose:case core.MultiWalletInstruction.TransactionBufferCloseCompressed:return null;case core.MultiWalletInstruction.ChangeConfig:return We(t,i,o,a,c);case core.MultiWalletInstruction.ChangeConfigCompressed:return Ve(t,i,o,a,c);case core.MultiWalletInstruction.CreateUserAccounts:return Ke(t,r);case core.MultiWalletInstruction.EditTransactionManagerUrl:return $e(t,r);case core.MultiWalletInstruction.NativeTransferIntent:case core.MultiWalletInstruction.TokenTransferIntent:return He(n,t,i,o,a,c);case core.MultiWalletInstruction.NativeTransferIntentCompressed:case core.MultiWalletInstruction.TokenTransferIntentCompressed:return Ge(n,t,i,o,a,c);case core.MultiWalletInstruction.TransactionBufferCreate:case core.MultiWalletInstruction.TransactionBufferCreateCompressed:case core.MultiWalletInstruction.TransactionExecuteSync:case core.MultiWalletInstruction.TransactionExecuteSyncCompressed:return Ye(e,t,n,r,o,a,i,s,c);default:throw new Error("Instruction rejected by transaction manager.")}}/*! Bundled license information:
6
6
 
7
7
  @noble/curves/utils.js:
8
8
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
9
- */exports.verifyTransaction=pc;//# sourceMappingURL=index.cjs.map
9
+ */exports.verifyMessage=tc;exports.verifyTransaction=wc;//# sourceMappingURL=index.cjs.map
10
10
  //# sourceMappingURL=index.cjs.map