@revibase/transaction-manager 0.5.2 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -34,37 +34,34 @@ Use this package when you want a single, auditable place in your backend where e
34
34
  Generate one keypair for the manager and keep the private key server-side only.
35
35
 
36
36
  ```ts
37
- import { getBase58Decoder } from "gill";
38
-
39
- const keyPair = await crypto.subtle.generateKey({ name: "Ed25519" }, true, [
40
- "sign",
41
- "verify",
42
- ]);
37
+ import {
38
+ getBase58Decoder,
39
+ generateExtractableKeyPairSigner,
40
+ extractBytesFromKeyPairSigner,
41
+ } from "gill";
43
42
 
44
- const [pubRaw, privJwk] = await Promise.all([
45
- crypto.subtle.exportKey("raw", keyPair.publicKey),
46
- crypto.subtle.exportKey("jwk", keyPair.privateKey),
47
- ]);
43
+ const keypair = await generateExtractableKeyPairSigner();
44
+ const secretKey = await extractBytesFromKeyPairSigner(keypair);
48
45
 
49
46
  console.log({
50
- publicKey: getBase58Decoder().decode(new Uint8Array(pubRaw)),
51
- privateKey: JSON.stringify(privJwk),
47
+ publicKey: getBase58Decoder().decode(secretKey.slice(32)),
48
+ secretKey: getBase58Decoder().decode(secretKey),
52
49
  });
53
50
  ```
54
51
 
55
52
  Store:
56
53
 
57
54
  - **`publicKey`**: as the transaction manager public key (base58).
58
- - **`privateKey`**: as a JWK JSON string in a secure secret store.
55
+ - **`secretKey`**: as a base58 string in a secure secret store.
59
56
 
60
57
  ### 2. Configure environment
61
58
 
62
59
  Set the following environment variables for your signing service:
63
60
 
64
- - **`TX_MANAGER_PRIVATE_KEY`**: Manager private key (JWK JSON string).
61
+ - **`TX_MANAGER_SECRET_KEY`**: Manager secret key (base58 string).
65
62
  - **`TX_MANAGER_PUBLIC_KEY`**: Manager public key (base58).
66
63
  - **`TX_MANAGER_URL`**: Public HTTPS URL of your signing endpoint (the client will connect via WebSocket at the same URL).
67
- - **`RPC_URL`** (optional): Solana RPC URL. Defaults to `https://api.mainnet-beta.solana.com`.
64
+ - **`RPC_URL`** Solana RPC URL.
68
65
 
69
66
  ### 3. Implement a basic signing endpoint
70
67
 
@@ -88,22 +85,24 @@ This endpoint:
88
85
 
89
86
  ```ts
90
87
  import {
88
+ initialize,
89
+ type CompleteMessageRequest,
90
+ type TransactionAuthDetails,
91
91
  verifyMessage,
92
92
  verifyTransaction,
93
93
  } from "@revibase/transaction-manager";
94
- import { createSolanaRpc, getBase58Decoder } from "gill";
95
- import { enforcePolicies } from "@/lib/policy";
96
94
  import {
97
- createMessageChallenge,
98
- type CompleteMessageRequest,
99
- type TransactionAuthDetails,
100
- } from "@revibase/core";
95
+ getBase58Decoder,
96
+ createKeypairSignerFromBase58,
97
+ signBytes,
98
+ } from "gill";
99
+ import { enforcePolicies } from "@/lib/policy";
101
100
  import http from "node:http";
102
101
  import { WebSocketServer } from "ws";
103
102
 
104
- const rpc = createSolanaRpc(
105
- process.env.RPC_URL ?? "https://api.mainnet-beta.solana.com",
106
- );
103
+ initialize({
104
+ rpcEndpoint: process.env.RPC_URL,
105
+ });
107
106
 
108
107
  const transactionManagerConfig = {
109
108
  publicKey: process.env.TX_MANAGER_PUBLIC_KEY!, // base58
@@ -130,7 +129,10 @@ const transactionManagerConfig = {
130
129
  * Message signing:
131
130
  * {
132
131
  * type: "message",
133
- * data: CompleteMessageRequest
132
+ * data: {
133
+ * publicKey: string,
134
+ * payload: CompleteMessageRequest
135
+ * }
134
136
  * }
135
137
  *
136
138
  * Your service should respond with JSON events:
@@ -179,13 +181,8 @@ wss.on("connection", async (ws) => {
179
181
  }
180
182
 
181
183
  // Shared: load signer key once per connection.
182
- const jwk = JSON.parse(process.env.TX_MANAGER_PRIVATE_KEY!);
183
- const privateKey = await crypto.subtle.importKey(
184
- "jwk",
185
- jwk,
186
- { name: "Ed25519" },
187
- false,
188
- ["sign"],
184
+ const { keyPair } = await createKeypairSignerFromBase58(
185
+ process.env.TX_MANAGER_SECRET_KEY!,
189
186
  );
190
187
 
191
188
  if (msg.type === "transaction") {
@@ -211,13 +208,12 @@ wss.on("connection", async (ws) => {
211
208
 
212
209
  const signatures: string[] = [];
213
210
  for (const payloadItem of payload) {
214
- const result = await verifyTransaction(
215
- rpc,
211
+ const { messageBytes, verificationResults } = await verifyTransaction(
216
212
  transactionManagerConfig,
217
213
  payloadItem,
218
214
  );
219
215
 
220
- await enforcePolicies(result);
216
+ await enforcePolicies(verificationResults);
221
217
 
222
218
  // (Optional) if your policy requires an out-of-band human approval:
223
219
  // ws.send(JSON.stringify({ event: "pending_transaction_approval", data: { validTill: Date.now() + 60_000 } }));
@@ -226,24 +222,38 @@ wss.on("connection", async (ws) => {
226
222
 
227
223
  // ws.send(JSON.stringify({ event: "transaction_approved", data: {} }));
228
224
 
229
- const signatureBytes = await crypto.subtle.sign(
230
- { name: "Ed25519" },
231
- privateKey,
232
- result.transactionMessage,
225
+ const signatureBytes = await signBytes(
226
+ keyPair.privateKey,
227
+ messageBytes,
233
228
  );
234
229
 
235
- signatures.push(
236
- getBase58Decoder().decode(new Uint8Array(signatureBytes)),
237
- );
230
+ signatures.push(getBase58Decoder().decode(signatureBytes));
238
231
  }
239
232
 
240
233
  ws.send(JSON.stringify({ event: "signatures", data: { signatures } }));
241
234
  ws.close();
242
235
  } else {
243
236
  // msg.type === "message"
244
- const payload = msg.data as CompleteMessageRequest;
237
+ const { publicKey, payload } = (msg.data ?? {}) as {
238
+ publicKey: string;
239
+ payload: CompleteMessageRequest;
240
+ };
245
241
 
246
- await verifyMessage(payload);
242
+ if (publicKey !== transactionManagerConfig.publicKey) {
243
+ ws.send(
244
+ JSON.stringify({
245
+ event: "error",
246
+ data: { error: "Invalid transaction manager public key" },
247
+ }),
248
+ );
249
+ ws.close();
250
+ return;
251
+ }
252
+
253
+ const { messageBytes, verificationResults } = await verifyMessage(
254
+ publicKey,
255
+ payload,
256
+ );
247
257
 
248
258
  // (Optional) if your policy requires an out-of-band human approval:
249
259
 
@@ -253,26 +263,13 @@ wss.on("connection", async (ws) => {
253
263
 
254
264
  // ws.send(JSON.stringify({ event: "transaction_approved", data: {} }));
255
265
 
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
- );
262
-
263
- const signatureBytes = await crypto.subtle.sign(
264
- { name: "Ed25519" },
265
- privateKey,
266
- expectedChallenge,
267
- );
266
+ const signatureBytes = await signBytes(keyPair.privateKey, messageBytes);
268
267
 
269
268
  ws.send(
270
269
  JSON.stringify({
271
270
  event: "signatures",
272
271
  data: {
273
- signatures: [
274
- getBase58Decoder().decode(new Uint8Array(signatureBytes)),
275
- ],
272
+ signatures: [getBase58Decoder().decode(signatureBytes)],
276
273
  },
277
274
  }),
278
275
  );
@@ -315,9 +312,9 @@ function readJsonOnce(ws: import("ws").WebSocket): Promise<unknown> {
315
312
 
316
313
  Your transaction manager should express your security model in one place.
317
314
 
318
- `verifyTransaction` returns a `VerificationResults` object with:
315
+ `verifyTransaction` returns a `VerifyTransactionResult` object with:
319
316
 
320
- - **`transactionMessage`**: Raw transaction message bytes to sign.
317
+ - **`messageBytes`**: Raw transaction message bytes to sign.
321
318
  - **`verificationResults`**: An array of batches, where each batch contains:
322
319
  - **`instructions`**: Decoded on-chain instructions.
323
320
  - **`signers`**: The signers that successfully passed verification for those instructions.
@@ -330,7 +327,8 @@ The example below:
330
327
  - Caps each transfer at **1 SOL**.
331
328
 
332
329
  ```ts
333
- import type { VerificationResults } from "@revibase/transaction-manager";
330
+ import type { ExpectedTransactionSigner } from "@revibase/transaction-manager";
331
+ import type { Instruction } from "gill";
334
332
  import {
335
333
  SYSTEM_PROGRAM_ADDRESS,
336
334
  identifySystemInstruction,
@@ -342,13 +340,18 @@ import {
342
340
  const ALLOWED_ORIGINS = new Set(["https://app.revibase.com"]);
343
341
  const MAX_TRANSFER_LAMPORTS = 1_000_000_000n; // 1 SOL
344
342
 
345
- export async function enforcePolicies(results: VerificationResults) {
346
- for (const batch of results.verificationResults) {
343
+ export async function enforcePolicies(
344
+ verificationResults: {
345
+ instructions: Instruction[];
346
+ signers: ExpectedTransactionSigner[];
347
+ }[],
348
+ ) {
349
+ for (const batch of verificationResults) {
347
350
  const { signers, instructions } = batch;
348
351
 
349
352
  for (const signer of signers) {
350
- const origin = "client" in signer ? signer.client?.origin : undefined;
351
- if (origin && !ALLOWED_ORIGINS.has(origin)) {
353
+ // Only secp256r1/passkey signers include `client` metadata (origin + client JWK).
354
+ if ("client" in signer && !ALLOWED_ORIGINS.has(signer.client.origin)) {
352
355
  throw new Error("Unauthorized app origin");
353
356
  }
354
357
  }
@@ -391,21 +394,23 @@ export async function enforcePolicies(results: VerificationResults) {
391
394
 
392
395
  This package exports the following public API:
393
396
 
394
- - **`verifyTransaction(rpc, transactionManagerConfig, payload, getClientDetails?)`**
397
+ - **`verifyTransaction(transactionManagerConfig, payload, getClientDetails?)`**
395
398
  - Decodes and verifies a serialized Solana transaction.
396
- - Returns a `VerificationResults` object with the transaction message bytes and verification batches.
399
+ - Returns a `VerifyTransactionResult` object with the transaction message bytes and verification batches.
397
400
 
398
- - **`verifyMessage(payload, getClientDetails?)`**
401
+ - **`verifyMessage(publicKey, payload, getClientDetails?)`**
399
402
  - 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).
403
+ - Returns a `VerifyMessageResult` containing:
404
+ - `messageBytes`: the message bytes to sign (Ed25519).
405
+ - `verificationResults`: the verified payload plus the extracted signer metadata.
406
+ - Uses `payload.data.payload.startRequest.rpId` and `payload.data.payload.startRequest.clientOrigin` for WebAuthn verification (RP ID + expected origin).
402
407
 
403
408
  - **`TransactionManagerConfig`**
404
409
  - `publicKey`: Transaction manager public key (base58 string).
405
410
  - `url`: Public URL of your transaction manager endpoint.
406
411
 
407
- - **`VerificationResults`**
408
- - `transactionMessage`: Transaction message bytes to sign.
412
+ - **`VerifyTransactionResult`**
413
+ - `messageBytes`: Transaction message bytes to sign.
409
414
  - `verificationResults`: Array of `{ instructions, signers }` batches used by your policy.
410
415
 
411
416
  ---
package/dist/index.cjs CHANGED
@@ -1,10 +1,10 @@
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.
1
+ 'use strict';var core=require('@revibase/core'),sha2_js=require('@noble/hashes/sha2.js'),server=require('@simplewebauthn/server'),jose=require('jose'),jsonCanonicalize=require('json-canonicalize');require('@noble/hashes/utils.js');var pn=1,hn=2,Ln=3,Mn=4,yn=5,Un=6,bn=7,vn=8,wn=9,Bn=10,Pn=-32700,Fn=-32603,xn=-32602,zn=-32601,kn=-32600,Vn=-32019,Wn=-32018,Gn=-32017,Hn=-32016,Kn=-32015,$n=-32014,Yn=-32013,Xn=-32012,jn=-32011,qn=-32010,Zn=-32009,Jn=-32008,Qn=-32007,er=-32006,tr=-32005,nr=-32004,rr=-32003,or=-32002,ar=-32001,ee=28e5,te=2800001,ir=2800002,qe=2800003,Ze=2800004,Je=2800005,Qe=2800006,et=2800007,tt=2800008,nt=2800009,rt=2800010,ot=2800011,at=323e4,ne=32300001,it=3230002,st=3230003,re=3230004,sr=361e4,cr=3610001,ur=3610002,dr=3610003,_r=3610004,Ar=3610005,lr=3610006,Ir=3610007,Er=3611e3,Rr=3704e3,gr=3704001,Tr=3704002,fr=3704003,Sr=3704004,Nr=4128e3,Dr=4128001,Or=4128002,mr=4615e3,Cr=4615001,pr=4615002,hr=4615003,Lr=4615004,Mr=4615005,yr=4615006,Ur=4615007,br=4615008,vr=4615009,wr=4615010,Br=4615011,Pr=4615012,Fr=4615013,xr=4615014,zr=4615015,kr=4615016,Vr=4615017,Wr=4615018,Gr=4615019,Hr=4615020,Kr=4615021,$r=4615022,Yr=4615023,Xr=4615024,jr=4615025,qr=4615026,Zr=4615027,Jr=4615028,Qr=4615029,eo=4615030,to=4615031,no=4615032,ro=4615033,oo=4615034,ao=4615035,io=4615036,so=4615037,co=4615038,uo=4615039,_o=4615040,Ao=4615041,lo=4615042,Io=4615043,Eo=4615044,Ro=4615045,go=4615046,To=4615047,fo=4615048,So=4615049,No=4615050,Do=4615051,Oo=4615052,mo=4615053,Co=4615054,po=5508e3,ho=5508001,Lo=5508002,Mo=5508003,yo=5508004,Uo=5508005,bo=5508006,vo=5508007,wo=5508008,Bo=5508009,Po=5508010,Fo=5508011,ct=5663e3,ut=5663001,oe=5663002,ae=5663003,dt=5663004,ie=5663005,se=5663006,ce=5663007,ue=5663008,_t=5663009,xo=5663010,zo=5663011,At=5663012,ko=5663013,Vo=5663014,lt=5663015,It=5663016,de=5663017,Wo=5663018,Go=5663019,Et=5663020,_e=5663021,Rt=5663022,Ho=705e4,Ko=7050001,$o=7050002,Yo=7050003,Xo=7050004,jo=7050005,qo=7050006,Zo=7050007,Jo=7050008,Qo=7050009,ea=7050010,ta=7050011,na=7050012,ra=7050013,oa=7050014,aa=7050015,ia=7050016,sa=7050017,ca=7050018,ua=7050019,da=7050020,_a=7050021,Aa=7050022,la=7050023,Ia=7050024,Ea=7050025,Ra=7050026,ga=7050027,Ta=7050028,fa=7050029,Sa=7050030,Na=7050031,Da=7050032,Oa=7050033,ma=7050034,Ca=7050035,pa=7050036,ha=7618e3,La=7618001,Ma=7618002,ya=7618003,Ae=8078e3,le=8078001,gt=8078002,Tt=8078003,ft=8078004,St=8078005,Nt=8078006,Ua=8078007,ba=8078008,va=8078009,wa=8078010,Ie=8078011,W=8078012,Ee=8078013,Re=8078014,Ba=8078015,Pa=8078016,Fa=8078017,xa=8078018,za=8078019,Dt=8078020,Ot=8078021,ka=8078022,mt=8078023,Va=81e5,Wa=8100001,Ga=8100002,Ha=8100003,Ka=819e4,$a=8190001,Ya=8190002,Xa=8190003,ja=8190004,qa=99e5,Za=9900001,Ja=9900002,Qa=9900003,ei=9900004,ti=9900005,ni=9900006;function Ct(e){return Array.isArray(e)?"%5B"+e.map(Ct).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function ri([e,t]){return `${e}=${Ct(t)}`}function oi(e){let t=Object.entries(e).map(ri).join("&");return Buffer.from(t,"utf8").toString("base64")}var ai={[at]:"Account not found at address: $address",[re]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[st]:"Expected decoded account at address: $address",[it]:"Failed to decode account data at address: $address",[ne]:"Accounts not found at addresses: $addresses",[nt]:"Unable to find a viable program address bump seed.",[ir]:"$putativeAddress is not a base58-encoded address.",[ee]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[qe]:"The `CryptoKey` must be an `Ed25519` public key.",[ot]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[tt]:"Invalid seeds; point must fall off the Ed25519 curve.",[Ze]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Qe]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[et]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Je]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[rt]:"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.",[pn]:"The network has progressed past the last block for which this transaction could have been committed.",[Ae]:"Codec [$codecDescription] cannot decode empty byte arrays.",[ka]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Dt]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[St]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Nt]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ft]:"Encoder and decoder must either both be fixed-size or variable-size.",[ba]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[gt]:"Expected a fixed-size codec, got a variable-size one.",[Ee]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Tt]:"Expected a variable-size codec, got a fixed-size one.",[za]:"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.",[xa]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[va]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[wa]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Ba]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Ua]:"Expected [$codecDescription] to have $expected items, got $actual.",[W]:"Invalid value $value for base $base with alphabet $alphabet.",[Pa]:"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.",[Ot]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Fa]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[mt]:"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?",[Er]:"No random values implementation could be found.",[vr]:"instruction requires an uninitialized account",[Yr]:"instruction tries to borrow reference for an account which is already borrowed",[Xr]:"instruction left account with an outstanding borrowed reference",[Kr]:"program other than the account's owner changed the size of the account data",[Mr]:"account data too small for instruction",[$r]:"instruction expected an executable account",[go]:"An account does not have enough lamports to be rent-exempt",[fo]:"Program arithmetic overflowed",[Ro]:"Failed to serialize or deserialize account data: $encodedData",[Co]:"Builtin programs must consume compute units",[no]:"Cross-program invocation call depth too deep",[co]:"Computational budget exceeded",[qr]:"custom program error: #$code",[Vr]:"instruction contains duplicate accounts",[jr]:"instruction modifications of multiply-passed account differ",[eo]:"executable accounts must be rent exempt",[Jr]:"instruction changed executable accounts data",[Qr]:"instruction changed the balance of an executable account",[Wr]:"instruction changed executable bit of an account",[xr]:"instruction modified data of an account it does not own",[Fr]:"instruction spent from the balance of an account it does not own",[Cr]:"generic instruction error",[No]:"Provided owner is not allowed",[Io]:"Account is immutable",[Eo]:"Incorrect authority provided",[Ur]:"incorrect program id for instruction",[yr]:"insufficient funds for instruction",[Lr]:"invalid account data for instruction",[To]:"Invalid account owner",[pr]:"invalid program argument",[Zr]:"program returned invalid error code",[hr]:"invalid instruction data",[so]:"Failed to reallocate account data",[io]:"Provided seeds do not result in a valid address",[Do]:"Accounts data allocations exceeded the maximum allowed per transaction",[Oo]:"Max accounts exceeded",[mo]:"Max instruction trace length exceeded",[ao]:"Length of the seed is too long for address generation",[ro]:"An account required by the instruction is missing",[br]:"missing required signature for instruction",[Pr]:"instruction illegally modified the program id of an account",[Hr]:"insufficient account keys for instruction",[uo]:"Cross-program invocation with unauthorized signer or writable account",[_o]:"Failed to create program execution environment",[lo]:"Program failed to compile",[Ao]:"Program failed to complete",[kr]:"instruction modified data of a read-only account",[zr]:"instruction changed the balance of a read-only account",[oo]:"Cross-program invocation reentrancy not allowed for this instruction",[Gr]:"instruction modified rent epoch of an account",[Br]:"sum of account balances before and after instruction do not match",[wr]:"instruction requires an initialized account",[mr]:"",[to]:"Unsupported program id",[So]:"Unsupported sysvar",[ti]:"Invalid instruction plan kind: $kind.",[Ma]:"The provided instruction plan is empty.",[ya]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[ha]:"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).",[ni]:"Invalid transaction plan kind: $kind.",[La]:"No more instructions to pack; the message packer has completed the instruction plan.",[Nr]:"The instruction does not have any accounts.",[Dr]:"The instruction does not have any data.",[Or]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[hn]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Ja]:"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",[ei]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Za]:"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",[qa]:"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",[Qa]:"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",[Fn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[xn]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[kn]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[zn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Pn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Xn]:"$__serverMessage",[ar]:"$__serverMessage",[nr]:"$__serverMessage",[$n]:"$__serverMessage",[Gn]:"Epoch rewards period still active at slot $slot",[qn]:"$__serverMessage",[Zn]:"$__serverMessage",[Vn]:"Failed to query long-term storage; please try again",[Hn]:"Minimum context slot has not been reached",[tr]:"Node is unhealthy; behind by $numSlotsBehind slots",[Jn]:"No snapshot",[or]:"Transaction simulation failed",[Wn]:"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",[Qn]:"$__serverMessage",[jn]:"Transaction history is not available from this node",[er]:"$__serverMessage",[Yn]:"Transaction signature length mismatch",[rr]:"Transaction signature verification failure",[Kn]:"$__serverMessage",[Rr]:"Key pair bytes must be of length 64, got $byteLength.",[gr]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Tr]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Sr]:"The provided private key does not match the provided public key.",[fr]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Un]:"Lamports value must be in the range [0, 2e64-1]",[bn]:"`$value` cannot be parsed as a `BigInt`",[Bn]:"$message",[vn]:"`$value` cannot be parsed as a `Number`",[Ln]:"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'.",[Ya]:"WebSocket was closed before payload could be added to the send buffer",[Xa]:"WebSocket connection closed",[ja]:"WebSocket failed to connect",[$a]:"Failed to obtain a subscription id from the server",[Ha]:"Could not find an API plan for RPC method: `$method`",[Va]:"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`.",[Ga]:"HTTP error ($statusCode): $message",[Wa]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[po]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[ho]:"The provided value does not implement the `KeyPairSigner` interface",[Mo]:"The provided value does not implement the `MessageModifyingSigner` interface",[yo]:"The provided value does not implement the `MessagePartialSigner` interface",[Lo]:"The provided value does not implement any of the `MessageSigner` interfaces",[bo]:"The provided value does not implement the `TransactionModifyingSigner` interface",[vo]:"The provided value does not implement the `TransactionPartialSigner` interface",[wo]:"The provided value does not implement the `TransactionSendingSigner` interface",[Uo]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Bo]:"More than one `TransactionSendingSigner` was identified.",[Po]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Fo]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Ir]:"Cannot export a non-extractable key.",[cr]:"No digest implementation could be found.",[sr]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ur]:`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.`,[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:
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[dr]:"No signature verification implementation could be found.",[_r]:"No key generation implementation could be found.",[Ar]:"No signing implementation could be found.",[lr]:"No key export implementation could be found.",[wn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[ia]:"Transaction processing left an account with an outstanding borrowed reference",[Ko]:"Account in use",[$o]:"Account loaded twice",[Yo]:"Attempt to debit an account but found no record of a prior credit.",[la]:"Transaction loads an address table account that doesn't exist",[Zo]:"This transaction has already been processed",[Jo]:"Blockhash not found",[Qo]:"Loader call chain is too deep",[aa]:"Transactions are currently disabled due to cluster maintenance",[Sa]:"Transaction contains a duplicate instruction ($index) that is not allowed",[jo]:"Insufficient funds for fee",[Na]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[qo]:"This account may not be used to pay transaction fees",[ta]:"Transaction contains an invalid account reference",[Ea]:"Transaction loads an address table account with invalid data",[Ra]:"Transaction address table lookup uses an invalid index",[Ia]:"Transaction loads an address table account with an invalid owner",[Oa]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[ra]:"This program may not be used for executing instructions",[ga]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[ua]:"Transaction loads a writable account that cannot be written",[Da]:"Transaction exceeded max loaded accounts data size cap",[ea]:"Transaction requires a fee but has no signature present",[Xo]:"Attempt to load a program that does not exist",[Ca]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[ma]:"ResanitizationNeeded",[oa]:"Transaction failed to sanitize accounts offsets correctly",[na]:"Transaction did not pass signature verification",[Aa]:"Transaction locked too many accounts",[pa]:"Sum of account balances before and after transaction do not match",[Ho]:"The transaction failed with the error `$errorName`",[ca]:"Transaction version is unsupported",[_a]:"Transaction would exceed account data limit within the block",[fa]:"Transaction would exceed total account data limit",[da]:"Transaction would exceed max account limit within the block",[sa]:"Transaction would exceed max Block Cost Limit",[Ta]:"Transaction would exceed max Vote Cost Limit",[lt]:"Attempted to sign a transaction with an address that is not a signer for it",[xo]:"Transaction is missing an address at index: $index.",[It]:"Transaction has no expected signers therefore it cannot be encoded",[Et]:"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",[Wo]:"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",[Go]:"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",[zo]:"Transaction is missing a fee payer.",[At]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Vo]:"Transaction first instruction is not advance nonce account instruction.",[ko]:"Transaction with no instructions cannot be durable nonce transaction.",[ct]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[ut]:"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.",[_t]:"Transaction is missing signatures for addresses: $addresses.",[dt]:"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.",[Rt]:"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 ii(e,t={}){let n=ai[e];if(n.length===0)return "";let r;function o(a){if(r[S]===2){let s=n.slice(r[D]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[S]===1&&i.push(n.slice(r[D],a));}let i=[];return n.split("").forEach((a,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:a==="\\"?c={[D]:s,[S]:0}:a==="$"&&(c={[D]:s,[S]:2});break;case 2:a==="\\"?c={[D]:s,[S]:0}:a==="$"?c={[D]:s,[S]:2}:a.match(/\w/)||(c={[D]:s,[S]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function si(e,t={}){if(process.env.NODE_ENV!=="production")return ii(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${oi(t)}'`),`${n}\``}}var l=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,a])=>{i==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,i,a));});let o=si(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function ci(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var ui=(e,t)=>ci(e.length<=t?e:e.slice(0,t),t);function g(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,i)=>o===r[i])}function ht(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function p(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(ht(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 Lt(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 pt(e,t,n){if(t<0||t>n)throw new l(Re,{bytesLength:n,codecDescription:e,offset:t})}function ge(e,t){let n=(a,s)=>{let[c,u]=t.read(a,s),_=Number(c);return s=u,(s>0||a.length>_)&&(a=a.slice(s,s+_)),F("addDecoderSizePrefix",_,a),[e.decode(a),s+_]};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,i=r!==null&&o!==null?r+o:null;return I({...e,...i!==null?{maxSize:i}:{},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=ui(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function di(e,t){return I({...e,read:(n,r)=>{let o=u=>_i(u,n.length),i=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;pt("offsetDecoder",i,n.length);let[a,s]=e.read(n,i),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:i,postOffset:s,preOffset:r,wrapBytes:o}):s;return pt("offsetDecoder",c,n.length),[a,c]}})}function _i(e,t){return t===0?0:(e%t+t)%t}function Ai(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 Mt(e,t){return di(Ai(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function b(e,t){return I({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function vt(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new l(W,{alphabet:e,base:e.length,value:n})}var li=e=>p({getSizeFromValue:t=>{let[n,r]=yt(t,e[0]);if(!r)return t.length;let o=Ut(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(vt(e,t),t==="")return r;let[o,i]=yt(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=Ut(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),Ii=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 i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Ei(a,e);return [i+s,t.length]}});function yt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ut(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Ei(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var wt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Te=()=>li(wt),Bt=()=>Ii(wt);var Ri="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",w=()=>p({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){vt(Ri,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}});var gi=e=>e.replace(/\u0000/g,"");var Ti=globalThis.TextDecoder,bt=globalThis.TextEncoder,fe=()=>{let e;return p({getSizeFromValue:t=>(e||=new bt).encode(t).length,write:(t,n,r)=>{let o=(e||=new bt).encode(t);return n.set(o,r),r+o.length}})},Se=()=>{let e;return I({read(t,n){let r=(e||=new Ti).decode(t.slice(n));return [gi(r),t.length]}})};function fi(e){return !("exists"in e)||"exists"in e&&e.exists}function Pt(e){let t=e.filter(n=>fi(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new l(re,{addresses:n})}}function Si(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=w().encode(t.data[0]);return Object.freeze({...Ft(t),address:e,data:n,exists:true})}function Ni(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...Ft(t),address:e,data:n,exists:true})}function Ft(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function xt(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?Ni(t[s],a):Si(t[s],a))}function Ne(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 De,Oe;function Di(){return De||(De=Te()),De}function Oi(){return Oe||(Oe=Bt()),Oe}function H(e){if(e.length<32||e.length>44)throw new l(te,{actualLength:e.length});let r=Di().encode(e).byteLength;if(r!==32)throw new l(ee,{actualLength:r})}function B(e){return H(e),e}function P(){return y(Oi(),32)}function mi(e,t,n,r){if(r<t||r>n)throw new l(Ie,{codecDescription:e,max:n,min:t,value:r})}function zt(e){return e?.endian!==1}function Ci(e){return p({fixedSize:e.size,write(t,n,r){e.range&&mi(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,zt(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function kt(e){return I({fixedSize:e.size,read(t,n=0){Lt(e.name,t,n),F(e.name,e.size,t,n);let r=new DataView(pi(t,n,e.size));return [e.get(r,zt(e.config)),n+e.size]}})}function pi(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,i=e[t+o],a=127&i;if(n|=a<<o*7,(i&128)===0)break}return [n,t+r]}});var T=(e={})=>Ci({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Ce=(e={})=>kt({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var h=()=>kt({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 pe(e){return O(e)?e.fixedSize:null}function he(e){return O(e)?e.fixedSize:e.maxSize??null}function m(e,t={}){let n=t.size??Ce(),r=pe(e),o=Vt(n,r),i=Vt(n,he(e))??void 0;return I({...o!==null?{fixedSize:o}:{maxSize:i},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[d,E]=e.read(a,s);s=E,c.push(d);}return [c,s]}let[u,_]=typeof n=="number"?[n,s]:n.read(a,s);s=_;for(let d=0;d<u;d+=1){let[E,A]=e.read(a,s);s=A,c.push(E);}return [c,s]}})}function Vt(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 Wt(e){let t=K(e.map(pe)),n=K(e.map(he))??void 0;return I({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let i=[];return e.forEach(a=>{let[s,c]=a.read(r,o);i.push(s),o=c;}),[i,o]}})}function L(e){let t=e.map(([,o])=>o),n=K(t.map(pe)),r=K(t.map(he))??void 0;return I({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[u,_]=c.read(o,i);i=_,a[s]=u;}),[a,i]}})}function Gt(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 Ht(e){return e>=2}function vi(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 wi=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 i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Bi(a,e);return [i+s,t.length]}});function Bi(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Pi="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var Fi=()=>wi(Pi);var Le;function xi(){if(!Le){let e=m(h(),{size:N()});Le=L([["lookupTableAddress",P()],["writableIndexes",e],["readonlyIndexes",e]]);}return Le}var Me;function ye(){return Me||(Me=h()),Me}function zi(){return L([["numSignerAccounts",ye()],["numReadonlySignerAccounts",ye()],["numReadonlyNonSignerAccounts",ye()]])}var Ue;function ki(){return Ue||(Ue=b(L([["programAddressIndex",h()],["accountIndices",m(h(),{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}})),Ue}var Vi=0,Kt=128;function be(){return I({maxSize:1,read:(e,t)=>{let n=e[t];if((n&Kt)===0)return ["legacy",t];{let r=n^Kt;if(r>Vi)throw new l(_e,{unsupportedVersion:r});return [r,t+1]}}})}function Wi(){return [["version",be()],["header",zi()],["staticAccounts",m(P(),{size:N()})],["lifetimeToken",y(Fi(),32)],["instructions",m(ki(),{size:N()})],["addressTableLookups",Gi()]]}function Gi(){return m(xi(),{size:N()})}function Xt(){return b(L(Wi()),({addressTableLookups:e,...t})=>t.version==="legacy"||!e?.length?t:{...t,addressTableLookups:e})}function Hi(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var jt="SysvarRecentB1ockHashes11111111111111111111",qt="11111111111111111111111111111111";function $t(e,t){return {accounts:[{address:e,role:R.WRITABLE},{address:jt,role:R.READONLY},{address:t,role:R.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:qt}}function ve(e){return e.programAddress===qt&&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===jt&&e.accounts[1].role===R.READONLY&&e.accounts[2].address!=null&&Ht(e.accounts[2].role)}function Ki(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function Zt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&ve(e.instructions[0])}function $i(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function Yi({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,i=r.instructions[0];if(i&&ve(i))if($i(i,t,n)){if(Zt(r)&&r.lifetimeConstraint.nonce===e)return r;o=[i,...r.instructions.slice(1)];}else o=[Object.freeze($t(t,n)),...r.instructions.slice(1)];else o=[Object.freeze($t(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function Xi(e,t){if("feePayer"in t&&e===t.feePayer?.address&&ji(t.feePayer))return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function ji(e){return !!e&&"address"in e&&typeof e.address=="string"&&Object.keys(e).length===1}function qi(e,t){return Zi([e],t)}function Zi(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Ji(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],i=0;for(let a=0;a<n;a++)o.push({address:e.staticAccounts[i],role:R.WRITABLE_SIGNER}),i++;for(let a=0;a<t.numReadonlySignerAccounts;a++)o.push({address:e.staticAccounts[i],role:R.READONLY_SIGNER}),i++;for(let a=0;a<r;a++)o.push({address:e.staticAccounts[i],role:R.WRITABLE}),i++;for(let a=0;a<t.numReadonlyNonSignerAccounts;a++)o.push({address:e.staticAccounts[i],role:R.READONLY}),i++;return o}function Qi(e,t){let r=e.map(a=>a.lookupTableAddress).filter(a=>t[a]===void 0);if(r.length>0)throw new l(ie,{lookupTableAddresses:r});let o=[],i=[];for(let a of e){let s=t[a.lookupTableAddress],c=a.readonlyIndexes,u=a.writableIndexes,_=Math.max(...c,...u);if(_>=s.length)throw new l(se,{highestKnownIndex:s.length-1,highestRequestedIndex:_,lookupTableAddress:a.lookupTableAddress});let d=c.map(A=>({address:s[A],addressIndex:A,lookupTableAddress:a.lookupTableAddress,role:R.READONLY}));o.push(...d);let E=u.map(A=>({address:s[A],addressIndex:A,lookupTableAddress:a.lookupTableAddress,role:R.WRITABLE}));i.push(...E);}return [...i,...o]}function es(e,t){let n=t[e.programAddressIndex]?.address;if(!n)throw new l(ce,{index:e.programAddressIndex});let r=e.accountIndices?.map(i=>t[i]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function ts(e,t,n){if(!t||!ve(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=Ji(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?Qi(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[],i=[...r,...o],a=e.instructions.map(u=>es(u,i)),s=a[0],c=ts(e.lifetimeToken,s,t?.lastValidBlockHeight);return Gt(Hi({version:e.version}),u=>Xi(n,u),u=>a.reduce((_,d)=>qi(d,_),u),u=>"blockhash"in c?vi(c,u):Yi(c,u))}function Qt(){return b(L([["signatures",m(y(x(),64),{size:N()})],["messageBytes",x()]]),ns)}function ns(e){let{messageBytes:t,signatures:n}=e,r=Wt([be(),Mt(h(),2),m(P(),{size:N()})]),[o,i,a]=r.decode(t),s=a.slice(0,i);if(s.length!==n.length)throw new l(de,{numRequiredSignatures:i,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((u,_)=>{let d=n[_];d.every(E=>E===0)?c[u]=null:c[u]=d;}),{messageBytes:t,signatures:Object.freeze(c)}}async function we(e,t,n){if(e.length===0)return {};let r=await xt(t,e,n);return Pt(r),Ne(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var $="ComputeBudget111111111111111111111111111111";var en=new Map;async function tn(e){let t=Date.now(),n=en.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 i=await o.json();if(!i?.clientJwk)throw new Error(`Invalid .well-known response from ${e}`);let a={...i,cachedAt:t};return en.set(e,a),a}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){if(e.jwk!==e.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");try{let n=await jose.importJWK(core.convertBase64StringToJWK(e.jwk)),r=await jose.compactVerify(e.jws,n);if(!z(r.payload,new Uint8Array([...t,...fe().encode(jsonCanonicalize.canonicalize(e.deviceProfile))])))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 tn(e.clientOrigin);try{let o=await jose.importJWK(core.convertBase64StringToJWK(r.clientJwk)),i=await jose.compactVerify(e.jws,o);if(!z(i.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Client signature verification failed ")}return r}async function sn(e,t){let{authResponse:n,startRequest:r,slotHash:o,slotNumber:i,device:a,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,_=core.base64URLStringToBuffer(u.clientDataJSON),d=JSON.parse(Se().decode(_)),{challenge:E}=await core.createTransactionChallenge(r.data.payload,r.clientOrigin,a.jwk,r.rid,o,i,c),A=core.base64URLStringToBuffer(d.challenge);if(!z(A,E))throw new Error("Invalid challenge");let Q=core.getSecp256r1MessageHash(n);if(!z(Q,t))throw new Error("Invalid message hash")}async function Be(e,t){let n=sha2_js.sha256(t);return z(e.finalBufferHash,n)}async function cn(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 Ic(e,t,n){let{startRequest:r,authResponse:o}=t.data.payload;if(r.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>r.validTill)throw new Error("Request expired.");let[i]=await Promise.all([X(t.data.payload.client,core.createClientAuthorizationStartRequestChallenge(r),n),Y(t.data.payload.device,core.getSecp256r1MessageHash(t.data.payload.authResponse)),cn(t)]),a=await core.fetchUserAccountByFilters(await core.getDomainConfigAddress({rpId:r.rpId}),{credentialId:o.id});if(!a)throw new Error("No user found.");let s=a?.wallets.find(d=>d.isDelegate);if(!s)throw new Error("User does not have a delegated wallet");let u=(await core.fetchSettingsAccountData(await core.getSettingsFromIndex(s.index))).members.find(d=>d.role===core.UserRole.TransactionManager);if(!u)throw new Error("No transaction manager found.");if(e!==core.convertMemberKeyToString(u.pubkey))throw new Error("Transaction manager mismatch.");return {messageBytes:core.createMessageChallenge(t.data.payload.startRequest.data.payload,t.data.payload.startRequest.clientOrigin,t.data.payload.device.jwk,t.data.payload.startRequest.rid),verificationResults:{payload:t,signer:{client:{origin:t.data.payload.startRequest.clientOrigin,...i},device:t.data.payload.device.deviceProfile,estimatedValidTill:t.data.payload.startRequest.validTill,signer:new core.Secp256r1Key(core.convertMemberKeyToString(a.member)),startRequest:t.data.payload.startRequest,walletAddress:await core.getWalletAddressFromIndex(s.index)}}}}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 Pe(e){let t="data"in e?e.data:e;if(g(t,T().encode(0),0))return 0;if(g(t,T().encode(1),0))return 1;if(g(t,T().encode(2),0))return 2;if(g(t,T().encode(3),0))return 3;if(g(t,T().encode(4),0))return 4;if(g(t,T().encode(5),0))return 5;if(g(t,T().encode(6),0))return 6;if(g(t,T().encode(7),0))return 7;if(g(t,T().encode(8),0))return 8;if(g(t,T().encode(9),0))return 9;if(g(t,T().encode(10),0))return 10;if(g(t,T().encode(11),0))return 11;if(g(t,T().encode(12),0))return 12;throw new Error("The provided instruction could not be identified as a system instruction.")}var dn=0,_n=1,An=2,ln=3,In=4,En=5,Rn=6,gn=7,Tn=8;process.env.NODE_ENV!=="production"&&({[dn]:"an account with the same address already exists",[En]:"provided address does not match addressed derived from seed",[ln]:"cannot allocate account data of this length",[An]:"cannot assign account to this program id",[In]:"length of requested seed is too long",[gn]:"stored nonce is still in recent_blockhashes",[Rn]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[Tn]:"specified nonce does not match stored nonce",[_n]:"account does not have enough SOL to perform the operation"});var fn="MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";function Sn(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 Fe="Secp256r1SigVerify1111111111111111111111111",Nn=new Set([$,k,core.MULTI_WALLET_PROGRAM_ADDRESS,Fe,fn]),q="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z";function Dn(){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 C(e,t,n){if(!e)return [];let r=e.find(i=>i.instructionIndex===t-1)?.data;if(!r)return [];let{payload:o}=core.getSecp256r1VerifyInstructionDataDecoder().decode(r);return Promise.all(n.map(async i=>{let a=o[i.verifyArgs.signedMessageIndex],s=sha2_js.sha256(a.message);return {signer:new core.Secp256r1Key(a.publicKey),messageHash:s}}))}function xe(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 M(e,t,n,r,o,i){if(!o)throw new Error("Transaction Auth Response is missing");if(n.filter(c=>c.signer instanceof core.Secp256r1Key).length!==o.length)throw new Error(`Signer count mismatch. Expected ${n.length} auth responses, got ${o.length}`);if(n.filter(c=>!(c.signer instanceof core.Secp256r1Key)).every(c=>c.signer.toString()!==r.publicKey))throw new Error("Transaction manager not found in instructions.");let a=await core.getWalletAddressFromSettings(B(t)),s=await Promise.all(n.map(async({signer:c,messageHash:u})=>{if(c instanceof core.Secp256r1Key){if(!u)throw new Error("Hash not found.");let _=o.find(Cn=>Sn(core.getSecp256r1MessageHash(Cn.authResponse),u));if(!_)throw new Error("Hash mismatch");let{client:d,device:E,startRequest:A,estimatedSlotHashExpiry:Q}=_;if(A.data.type!=="transaction")throw new Error("Invalid request type.");let je=Math.min(Q,A.validTill);if(je<Date.now())throw new Error("Request has expired.");let[mn]=await Promise.all([X(d,u,i),sn(_,u),Y(E,u)]);return {signer:c,walletAddress:a,client:{origin:d.clientOrigin,...mn},device:E.deviceProfile,startRequest:A,estimatedValidTill:je}}return {signer:c,walletAddress:a}}));return {instructions:e,signers:s}}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 ze(e){let t=core.vaultTransactionMessageDeserialize(e);return (await Ve(t,core.getSolanaRpc())).instructions}function ke(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(i=>r[i]),data:o.data,programAddress:r[o.programAddressIndex].address}))}async function Ve(e,t){let r="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups.map(i=>i.lookupTableAddress):[],o=r.length>0?await Cc(r,t):{};return Jt(e,{addressesByLookupTableAddress:o})}async function Cc(e,t){if(e.some(r=>r.toString()===q)){let r=e.filter(o=>o.toString()!==q);return {...Dn(),...await we(r,t)}}return we(e,t)}async function We(e,t,n,r,o,i){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),s=await U(a.settingsMutArgs,"Invalid instruction data. Settings not found."),c=await C(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),u=3,_=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[u+d.fields[0]].address}));return M([e],s,c.concat(_),o,r,i)}async function Ge(e,t,n,r,o,i){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),s=e.accounts[0].address.toString(),c=await C(t,n,a.signers.filter(d=>d.__kind==="Secp256r1").map(d=>d.fields[0])),u=5,_=a.signers.filter(d=>d.__kind==="Ed25519").map(d=>({signer:e.accounts[u+d.fields[0]].address}));return M([e],s,c.concat(_),o,r,i)}async function He(e,t,n,r,o,i,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let c=(e===core.MultiWalletInstruction.NativeTransferIntentCompressed?core.getNativeTransferIntentCompressedInstructionDataDecoder():core.getTokenTransferIntentCompressedInstructionDataDecoder()).decode(t.data),u=await U(c.settingsMutArgs,"Invalid instruction data. Settings not found."),_=await C(n,r,c.signers.filter(A=>A.__kind==="Secp256r1").map(A=>A.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntentCompressed?6:17,E=c.signers.filter(A=>A.__kind==="Ed25519").map(A=>({signer:t.accounts[d+A.fields[0]].address}));return M([t],u,_.concat(E),i,o,a)}async function Ke(e,t,n,r,o,i,a){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let c=(e===core.MultiWalletInstruction.NativeTransferIntent?core.getNativeTransferIntentInstructionDataDecoder():core.getTokenTransferIntentInstructionDataDecoder()).decode(t.data),u=t.accounts[0].address.toString(),_=await C(n,r,c.signers.filter(A=>A.__kind==="Secp256r1").map(A=>A.fields[0])),d=e===core.MultiWalletInstruction.NativeTransferIntent?6:18,E=c.signers.filter(A=>A.__kind==="Ed25519").map(A=>({signer:t.accounts[d+A.fields[0]].address}));return M([t],u,_.concat(E),i,o,a)}function $e(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 Ye(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 Xe(e,t,n,r,o,i,a,s){if(!e.accounts)throw new Error("Invalid instruction accounts");if(!e.data)throw new Error("Invalid instruction data");zc(e,n);let c=t===core.MultiWalletInstruction.TransactionBufferCreate||t===core.MultiWalletInstruction.TransactionBufferCreateCompressed,u=t===core.MultiWalletInstruction.TransactionBufferCreateCompressed||t===core.MultiWalletInstruction.TransactionExecuteSyncCompressed,_;return c?_=await kc(e,u,a):_=await Gc(e,u,i,r),M(_.instructionsToVerify,_.settingsAddress,_.signers,n,o,s)}function zc(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 kc(e,t,n){if(!n)throw new Error("Missing transaction message bytes");if(!e.data||!e.accounts)throw new Error("Invalid instruction");let r=w().encode(n);return t?Vc(e,r):Wc(e,r)}async function Vc(e,t){let n=core.getTransactionBufferCreateCompressedInstructionDataDecoder().decode(e.data),r=await U(n.settingsReadonlyArgs,"Settings account is required for compressed transaction buffer create"),o=xe(n.args.expectedSigners);if(!await Be(n.args,t))throw new Error("Hash mismatch.");let a=await ze(t);return {settingsAddress:r,signers:o,instructionsToVerify:a}}async function Wc(e,t){let n=core.getTransactionBufferCreateInstructionDataDecoder().decode(e.data),r=e.accounts[0].address.toString(),o=xe(n.args.expectedSigners);if(!await Be(n.args,t))throw new Error("Hash mismatch.");let a=await ze(t);return {settingsAddress:r,signers:o,instructionsToVerify:a}}async function Gc(e,t,n,r){if(!e.data||!e.accounts)throw new Error("Invalid instruction");return t?Hc(e,n,r):Kc(e,n,r)}async function Hc(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"),i=await C(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),a=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[a+u.fields[0]].address})),c=ke(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:i.concat(s),instructionsToVerify:c}}async function Kc(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(),i=await C(t,n,r.signers.filter(u=>u.__kind==="Secp256r1").map(u=>u.fields[0])),a=3,s=r.signers.filter(u=>u.__kind==="Ed25519").map(u=>({signer:e.accounts[a+u.fields[0]].address})),c=ke(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:i.concat(s),instructionsToVerify:c}}async function jc(e,t,n){let{transaction:r,transactionMessageBytes:o,authResponses:i}=t,{messageBytes:a}=Qt().decode(w().encode(r)),s=Xt().decode(a),{instructions:c}=await Ve(s,core.getSolanaRpc()),u=qc(c),_=(await Promise.all(c.map((d,E)=>Zc(d,e,E,i,u,o,n)))).filter(d=>d!==null);return {messageBytes:new Uint8Array(a),verificationResults:_}}function qc(e){return e.map((t,n)=>({instruction:t,instructionIndex:n})).filter(({instruction:t})=>t.programAddress.toString()===Fe).map(({instructionIndex:t,instruction:n})=>({instructionIndex:t,data:n.data}))}async function Zc(e,t,n,r,o,i,a){let s=e.programAddress.toString();if(!Nn.has(s))throw new Error("Instruction rejected by Transaction Manager.");if(!e.data)throw new Error("Invalid instruction data.");if(s===k.toString()){if(Pe({data:e.data})!==j.AdvanceNonceAccount)throw new Error("Instruction rejected by Transaction Manager.");return null}if(s!==core.MULTI_WALLET_PROGRAM_ADDRESS.toString())return null;let c=core.identifyMultiWalletInstruction({data:e.data});return Jc(e,c,t,n,r,o,i,a)}async function Jc(e,t,n,r,o,i,a,s){switch(t){case core.MultiWalletInstruction.DecompressSettingsAccount:case core.MultiWalletInstruction.TransactionBufferClose:case core.MultiWalletInstruction.TransactionBufferCloseCompressed:return null;case core.MultiWalletInstruction.ChangeConfig:return Ge(e,i,r,o,n,s);case core.MultiWalletInstruction.ChangeConfigCompressed:return We(e,i,r,o,n,s);case core.MultiWalletInstruction.CreateUserAccounts:return $e(e,n);case core.MultiWalletInstruction.EditTransactionManagerUrl:return Ye(e,n);case core.MultiWalletInstruction.NativeTransferIntent:case core.MultiWalletInstruction.TokenTransferIntent:return Ke(t,e,i,r,o,n,s);case core.MultiWalletInstruction.NativeTransferIntentCompressed:case core.MultiWalletInstruction.TokenTransferIntentCompressed:return He(t,e,i,r,o,n,s);case core.MultiWalletInstruction.TransactionBufferCreate:case core.MultiWalletInstruction.TransactionBufferCreateCompressed:case core.MultiWalletInstruction.TransactionExecuteSync:case core.MultiWalletInstruction.TransactionExecuteSyncCompressed:return Xe(e,t,n,r,o,i,a,s);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.verifyMessage=tc;exports.verifyTransaction=wc;//# sourceMappingURL=index.cjs.map
9
+ */Object.defineProperty(exports,"initialize",{enumerable:true,get:function(){return core.initialize}});exports.verifyMessage=Ic;exports.verifyTransaction=jc;//# sourceMappingURL=index.cjs.map
10
10
  //# sourceMappingURL=index.cjs.map