@revibase/lite 0.0.35 → 0.0.36

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
@@ -10,6 +10,8 @@ Add **Revibase** (passkey-based Solana wallet) to your app. Users sign in and si
10
10
 
11
11
  The private key is only used on the server. The client only sees the request/result payloads.
12
12
 
13
+ **Device binding (optional)** — When you pass a `channelId` to the provider, the SDK creates a **device-bound key** (Ed25519, non-exportable) and stores it in the browser’s IndexedDB. That key is used to sign the channel id; your backend receives `device: { jwk, jws }` and can bind the session to that device. The private key never leaves the device and cannot be exported.
14
+
13
15
  ## Prerequisites
14
16
 
15
17
  Get a single **key pair** from [developers.revibase.com](https://developers.revibase.com). You will use:
@@ -46,11 +48,17 @@ import { processClientAuthCallback } from "@revibase/lite";
46
48
 
47
49
  export async function POST(req: Request) {
48
50
  try {
49
- const { request } = (await req.json()) as { request: unknown };
51
+ const { request, device, channelId } = (await req.json()) as {
52
+ request: StartMessageRequest | StartTransactionRequest;
53
+ device?: DeviceSignature;
54
+ channelId?: string;
55
+ };
50
56
  const result = await processClientAuthCallback({
51
57
  request,
52
58
  privateKey: process.env.PRIVATE_KEY!,
53
59
  signal: req.signal,
60
+ device,
61
+ channelId,
54
62
  });
55
63
  return new Response(JSON.stringify(result));
56
64
  } catch (error) {
@@ -75,11 +83,11 @@ import {
75
83
  } from "@revibase/lite";
76
84
 
77
85
  const provider = new RevibaseProvider({
78
- onClientAuthorizationCallback: async (request, signal) => {
86
+ onClientAuthorizationCallback: async (request, signal, device, channelId) => {
79
87
  const res = await fetch("/api/clientAuthorization", {
80
88
  method: "POST",
81
89
  headers: { "Content-Type": "application/json" },
82
- body: JSON.stringify({ request }),
90
+ body: JSON.stringify({ request, device, channelId }),
83
91
  signal,
84
92
  });
85
93
  const data = await res.json();
@@ -89,6 +97,7 @@ const provider = new RevibaseProvider({
89
97
  );
90
98
  return data;
91
99
  },
100
+ channelId,
92
101
  });
93
102
  ```
94
103
 
@@ -111,7 +120,7 @@ For custom instructions, use **`executeTransaction`** (see API reference).
111
120
 
112
121
  ---
113
122
 
114
- **Checklist:** Install → add `/.well-known/revibase.json` with `clientJwk` → set `PRIVATE_KEY` → add POST route with `processClientAuthCallback` and `req.signal` → create `RevibaseProvider` with callback that passes `signal` to `fetch` → call `signIn(provider)` and/or `transferTokens` / `executeTransaction`.
123
+ **Checklist:** Install → add `/.well-known/revibase.json` with `clientJwk` → set `PRIVATE_KEY` → add POST route with `processClientAuthCallback` and `req.signal` (and `device`, `channelId` if using device binding) → create `RevibaseProvider` with callback that passes `signal` to `fetch` (optionally pass `channelId` for device-bound keys) → call `signIn(provider)` and/or `transferTokens` / `executeTransaction`.
115
124
 
116
125
  **Security:** Store `PRIVATE_KEY` only on the server. Use HTTPS in production.
117
126
 
@@ -162,7 +171,8 @@ function transferTokens(
162
171
  **`RevibaseProvider`** — Connects your app to the Revibase auth popup and your backend.
163
172
 
164
173
  - **Constructor:** `new RevibaseProvider(opts)`
165
- - `opts.onClientAuthorizationCallback` — **Required.** Called with `(request, signal)`; must POST `request` to your backend and return the JSON result. Pass `signal` to `fetch` for cancellation.
174
+ - `opts.onClientAuthorizationCallback` — **Required.** Called with `(request, signal, device, channelId)`. POST `request`, `device`, and `channelId` to your backend and return the JSON result. Pass `signal` to `fetch` for cancellation.
175
+ - `opts.channelId` — Optional. When set, a device-bound key is created (or reused) and used to sign the channel; the callback receives `device: { jwk, jws }` for your backend to verify and bind the session.
166
176
  - `opts.providerOrigin` — Optional. Default `https://auth.revibase.com`.
167
177
 
168
178
  ### Server
@@ -179,6 +189,8 @@ function processClientAuthCallback(options: {
179
189
  request: StartMessageRequest | StartTransactionRequest;
180
190
  signal: AbortSignal;
181
191
  privateKey: string; // base64-encoded JWK
192
+ device?: DeviceSignature; // { jwk, jws } from device-bound key when channelId is used
193
+ channelId?: string;
182
194
  providerOrigin?: string;
183
195
  rpId?: string;
184
196
  }): Promise<{ txSig?: string; user: UserInfo }>;
package/dist/index.cjs CHANGED
@@ -1,12 +1,12 @@
1
- 'use strict';var core=require('@revibase/core'),$i=require('zod'),jose=require('jose'),server=require('@simplewebauthn/server');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var $i__default=/*#__PURE__*/_interopDefault($i);var Ct=1,Ot=2,ft=3,mt=4,pt=5,ht=6,Mt=7,Lt=8,yt=9,Ut=10,bt=-32700,Ft=-32603,Pt=-32602,vt=-32601,Bt=-32600,zt=-32019,wt=-32018,kt=-32017,xt=-32016,Wt=-32015,Vt=-32014,Gt=-32013,Ht=-32012,Kt=-32011,$t=-32010,Yt=-32009,Xt=-32008,Zt=-32007,jt=-32006,qt=-32005,Jt=-32004,Qt=-32003,en=-32002,tn=-32001,W=28e5,V=2800001,nn=2800002,ue=2800003,de=2800004,Ie=2800005,_e=2800006,Ae=2800007,le=2800008,Ee=2800009,Re=2800010,Te=2800011,rn=323e4,on=32300001,an=3230002,sn=3230003,cn=3230004,un=361e4,dn=3610001,In=3610002,_n=3610003,An=3610004,ln=3610005,En=3610006,Rn=3610007,Tn=3611e3,gn=3704e3,Dn=3704001,Nn=3704002,Sn=3704003,Cn=3704004,On=4128e3,fn=4128001,mn=4128002,pn=4615e3,hn=4615001,Mn=4615002,Ln=4615003,yn=4615004,Un=4615005,bn=4615006,Fn=4615007,Pn=4615008,vn=4615009,Bn=4615010,zn=4615011,wn=4615012,kn=4615013,xn=4615014,Wn=4615015,Vn=4615016,Gn=4615017,Hn=4615018,Kn=4615019,$n=4615020,Yn=4615021,Xn=4615022,Zn=4615023,jn=4615024,qn=4615025,Jn=4615026,Qn=4615027,er=4615028,tr=4615029,nr=4615030,rr=4615031,or=4615032,ir=4615033,ar=4615034,sr=4615035,cr=4615036,ur=4615037,dr=4615038,Ir=4615039,_r=4615040,Ar=4615041,lr=4615042,Er=4615043,Rr=4615044,Tr=4615045,gr=4615046,Dr=4615047,Nr=4615048,Sr=4615049,Cr=4615050,Or=4615051,fr=4615052,mr=4615053,pr=4615054,hr=5508e3,Mr=5508001,Lr=5508002,yr=5508003,Ur=5508004,br=5508005,Fr=5508006,Pr=5508007,vr=5508008,Br=5508009,zr=5508010,wr=5508011,ge=5663e3,De=5663001,G=5663002,H=5663003,Ne=5663004,Se=5663005,Ce=5663006,Oe=5663007,fe=5663008,me=5663009,kr=5663010,xr=5663011,pe=5663012,Wr=5663013,Vr=5663014,he=5663015,Me=5663016,K=5663017,Gr=5663018,Hr=5663019,Le=5663020,$=5663021,ye=5663022,Kr=705e4,$r=7050001,Yr=7050002,Xr=7050003,Zr=7050004,jr=7050005,qr=7050006,Jr=7050007,Qr=7050008,eo=7050009,to=7050010,no=7050011,ro=7050012,oo=7050013,io=7050014,ao=7050015,so=7050016,co=7050017,uo=7050018,Io=7050019,_o=7050020,Ao=7050021,lo=7050022,Eo=7050023,Ro=7050024,To=7050025,go=7050026,Do=7050027,No=7050028,So=7050029,Co=7050030,Oo=7050031,fo=7050032,mo=7050033,po=7050034,ho=7050035,Mo=7050036,Lo=7618e3,yo=7618001,Uo=7618002,bo=7618003,Y=8078e3,X=8078001,Ue=8078002,be=8078003,Fe=8078004,Pe=8078005,ve=8078006,Fo=8078007,Po=8078008,vo=8078009,Bo=8078010,Z=8078011,F=8078012,j=8078013,q=8078014,zo=8078015,wo=8078016,ko=8078017,xo=8078018,Wo=8078019,Be=8078020,ze=8078021,Vo=8078022,we=8078023,Go=81e5,Ho=8100001,Ko=8100002,$o=8100003,Yo=819e4,Xo=8190001,Zo=8190002,jo=8190003,qo=8190004,Jo=99e5,Qo=9900001,ei=9900002,ti=9900003,ni=9900004,ri=9900005,oi=9900006;function ke(e){return Array.isArray(e)?"%5B"+e.map(ke).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function ii([e,t]){return `${e}=${ke(t)}`}function ai(e){let t=Object.entries(e).map(ii).join("&");return Buffer.from(t,"utf8").toString("base64")}var si={[rn]:"Account not found at address: $address",[cn]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[sn]:"Expected decoded account at address: $address",[an]:"Failed to decode account data at address: $address",[on]:"Accounts not found at addresses: $addresses",[Ee]:"Unable to find a viable program address bump seed.",[nn]:"$putativeAddress is not a base58-encoded address.",[W]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[ue]:"The `CryptoKey` must be an `Ed25519` public key.",[Te]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[le]:"Invalid seeds; point must fall off the Ed25519 curve.",[de]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[_e]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ae]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Ie]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[Re]:"Program address cannot end with PDA marker.",[V]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[mt]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Ct]:"The network has progressed past the last block for which this transaction could have been committed.",[Y]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Vo]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Be]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Pe]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ve]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[Fe]:"Encoder and decoder must either both be fixed-size or variable-size.",[Po]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Ue]:"Expected a fixed-size codec, got a variable-size one.",[j]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[be]:"Expected a variable-size codec, got a fixed-size one.",[Wo]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[X]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[xo]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[vo]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Bo]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[zo]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Fo]:"Expected [$codecDescription] to have $expected items, got $actual.",[F]:"Invalid value $value for base $base with alphabet $alphabet.",[wo]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Z]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[q]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[ze]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[ko]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[we]:"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?",[Tn]:"No random values implementation could be found.",[vn]:"instruction requires an uninitialized account",[Zn]:"instruction tries to borrow reference for an account which is already borrowed",[jn]:"instruction left account with an outstanding borrowed reference",[Yn]:"program other than the account's owner changed the size of the account data",[Un]:"account data too small for instruction",[Xn]:"instruction expected an executable account",[gr]:"An account does not have enough lamports to be rent-exempt",[Nr]:"Program arithmetic overflowed",[Tr]:"Failed to serialize or deserialize account data: $encodedData",[pr]:"Builtin programs must consume compute units",[or]:"Cross-program invocation call depth too deep",[dr]:"Computational budget exceeded",[Jn]:"custom program error: #$code",[Gn]:"instruction contains duplicate accounts",[qn]:"instruction modifications of multiply-passed account differ",[nr]:"executable accounts must be rent exempt",[er]:"instruction changed executable accounts data",[tr]:"instruction changed the balance of an executable account",[Hn]:"instruction changed executable bit of an account",[xn]:"instruction modified data of an account it does not own",[kn]:"instruction spent from the balance of an account it does not own",[hn]:"generic instruction error",[Cr]:"Provided owner is not allowed",[Er]:"Account is immutable",[Rr]:"Incorrect authority provided",[Fn]:"incorrect program id for instruction",[bn]:"insufficient funds for instruction",[yn]:"invalid account data for instruction",[Dr]:"Invalid account owner",[Mn]:"invalid program argument",[Qn]:"program returned invalid error code",[Ln]:"invalid instruction data",[ur]:"Failed to reallocate account data",[cr]:"Provided seeds do not result in a valid address",[Or]:"Accounts data allocations exceeded the maximum allowed per transaction",[fr]:"Max accounts exceeded",[mr]:"Max instruction trace length exceeded",[sr]:"Length of the seed is too long for address generation",[ir]:"An account required by the instruction is missing",[Pn]:"missing required signature for instruction",[wn]:"instruction illegally modified the program id of an account",[$n]:"insufficient account keys for instruction",[Ir]:"Cross-program invocation with unauthorized signer or writable account",[_r]:"Failed to create program execution environment",[lr]:"Program failed to compile",[Ar]:"Program failed to complete",[Vn]:"instruction modified data of a read-only account",[Wn]:"instruction changed the balance of a read-only account",[ar]:"Cross-program invocation reentrancy not allowed for this instruction",[Kn]:"instruction modified rent epoch of an account",[zn]:"sum of account balances before and after instruction do not match",[Bn]:"instruction requires an initialized account",[pn]:"",[rr]:"Unsupported program id",[Sr]:"Unsupported sysvar",[ri]:"Invalid instruction plan kind: $kind.",[Uo]:"The provided instruction plan is empty.",[bo]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Lo]:"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).",[oi]:"Invalid transaction plan kind: $kind.",[yo]:"No more instructions to pack; the message packer has completed the instruction plan.",[On]:"The instruction does not have any accounts.",[fn]:"The instruction does not have any data.",[mn]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[pt]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Ot]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[ei]:"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",[ni]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Qo]:"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",[Jo]:"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",[ti]:"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",[Ft]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Pt]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Bt]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[vt]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[bt]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Ht]:"$__serverMessage",[tn]:"$__serverMessage",[Jt]:"$__serverMessage",[Vt]:"$__serverMessage",[kt]:"Epoch rewards period still active at slot $slot",[$t]:"$__serverMessage",[Yt]:"$__serverMessage",[zt]:"Failed to query long-term storage; please try again",[xt]:"Minimum context slot has not been reached",[qt]:"Node is unhealthy; behind by $numSlotsBehind slots",[Xt]:"No snapshot",[en]:"Transaction simulation failed",[wt]:"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",[Zt]:"$__serverMessage",[Kt]:"Transaction history is not available from this node",[jt]:"$__serverMessage",[Gt]:"Transaction signature length mismatch",[Qt]:"Transaction signature verification failure",[Wt]:"$__serverMessage",[gn]:"Key pair bytes must be of length 64, got $byteLength.",[Dn]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Nn]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Cn]:"The provided private key does not match the provided public key.",[Sn]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[ht]:"Lamports value must be in the range [0, 2e64-1]",[Mt]:"`$value` cannot be parsed as a `BigInt`",[Ut]:"$message",[Lt]:"`$value` cannot be parsed as a `Number`",[ft]:"No nonce account could be found at address `$nonceAccountAddress`",[Yo]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Zo]:"WebSocket was closed before payload could be added to the send buffer",[jo]:"WebSocket connection closed",[qo]:"WebSocket failed to connect",[Xo]:"Failed to obtain a subscription id from the server",[$o]:"Could not find an API plan for RPC method: `$method`",[Go]:"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`.",[Ko]:"HTTP error ($statusCode): $message",[Ho]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[hr]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Mr]:"The provided value does not implement the `KeyPairSigner` interface",[yr]:"The provided value does not implement the `MessageModifyingSigner` interface",[Ur]:"The provided value does not implement the `MessagePartialSigner` interface",[Lr]:"The provided value does not implement any of the `MessageSigner` interfaces",[Fr]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Pr]:"The provided value does not implement the `TransactionPartialSigner` interface",[vr]:"The provided value does not implement the `TransactionSendingSigner` interface",[br]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Br]:"More than one `TransactionSendingSigner` was identified.",[zr]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[wr]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Rn]:"Cannot export a non-extractable key.",[dn]:"No digest implementation could be found.",[un]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[In]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ 'use strict';var core=require('@revibase/core'),jose=require('jose'),Qi=require('zod'),server=require('@simplewebauthn/server');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var Qi__default=/*#__PURE__*/_interopDefault(Qi);var pt=1,ht=2,Mt=3,Lt=4,yt=5,Ut=6,bt=7,Ft=8,Pt=9,vt=10,Bt=-32700,zt=-32603,wt=-32602,kt=-32601,xt=-32600,Wt=-32019,Vt=-32018,Gt=-32017,Ht=-32016,Kt=-32015,$t=-32014,Yt=-32013,Xt=-32012,Zt=-32011,jt=-32010,qt=-32009,Jt=-32008,Qt=-32007,en=-32006,tn=-32005,nn=-32004,rn=-32003,on=-32002,an=-32001,G=28e5,H=2800001,sn=2800002,Ie=2800003,_e=2800004,Ae=2800005,le=2800006,Ee=2800007,Re=2800008,Te=2800009,ge=2800010,De=2800011,cn=323e4,un=32300001,dn=3230002,In=3230003,_n=3230004,An=361e4,ln=3610001,En=3610002,Rn=3610003,Tn=3610004,gn=3610005,Dn=3610006,Nn=3610007,Sn=3611e3,Cn=3704e3,On=3704001,fn=3704002,mn=3704003,pn=3704004,hn=4128e3,Mn=4128001,Ln=4128002,yn=4615e3,Un=4615001,bn=4615002,Fn=4615003,Pn=4615004,vn=4615005,Bn=4615006,zn=4615007,wn=4615008,kn=4615009,xn=4615010,Wn=4615011,Vn=4615012,Gn=4615013,Hn=4615014,Kn=4615015,$n=4615016,Yn=4615017,Xn=4615018,Zn=4615019,jn=4615020,qn=4615021,Jn=4615022,Qn=4615023,er=4615024,tr=4615025,nr=4615026,rr=4615027,or=4615028,ir=4615029,ar=4615030,sr=4615031,cr=4615032,ur=4615033,dr=4615034,Ir=4615035,_r=4615036,Ar=4615037,lr=4615038,Er=4615039,Rr=4615040,Tr=4615041,gr=4615042,Dr=4615043,Nr=4615044,Sr=4615045,Cr=4615046,Or=4615047,fr=4615048,mr=4615049,pr=4615050,hr=4615051,Mr=4615052,Lr=4615053,yr=4615054,Ur=5508e3,br=5508001,Fr=5508002,Pr=5508003,vr=5508004,Br=5508005,zr=5508006,wr=5508007,kr=5508008,xr=5508009,Wr=5508010,Vr=5508011,Ne=5663e3,Se=5663001,K=5663002,$=5663003,Ce=5663004,Oe=5663005,fe=5663006,me=5663007,pe=5663008,he=5663009,Gr=5663010,Hr=5663011,Me=5663012,Kr=5663013,$r=5663014,Le=5663015,ye=5663016,Y=5663017,Yr=5663018,Xr=5663019,Ue=5663020,X=5663021,be=5663022,Zr=705e4,jr=7050001,qr=7050002,Jr=7050003,Qr=7050004,eo=7050005,to=7050006,no=7050007,ro=7050008,oo=7050009,io=7050010,ao=7050011,so=7050012,co=7050013,uo=7050014,Io=7050015,_o=7050016,Ao=7050017,lo=7050018,Eo=7050019,Ro=7050020,To=7050021,go=7050022,Do=7050023,No=7050024,So=7050025,Co=7050026,Oo=7050027,fo=7050028,mo=7050029,po=7050030,ho=7050031,Mo=7050032,Lo=7050033,yo=7050034,Uo=7050035,bo=7050036,Fo=7618e3,Po=7618001,vo=7618002,Bo=7618003,Z=8078e3,j=8078001,Fe=8078002,Pe=8078003,ve=8078004,Be=8078005,ze=8078006,zo=8078007,wo=8078008,ko=8078009,xo=8078010,q=8078011,v=8078012,J=8078013,Q=8078014,Wo=8078015,Vo=8078016,Go=8078017,Ho=8078018,Ko=8078019,we=8078020,ke=8078021,$o=8078022,xe=8078023,Yo=81e5,Xo=8100001,Zo=8100002,jo=8100003,qo=819e4,Jo=8190001,Qo=8190002,ei=8190003,ti=8190004,ni=99e5,ri=9900001,oi=9900002,ii=9900003,ai=9900004,si=9900005,ci=9900006;function We(e){return Array.isArray(e)?"%5B"+e.map(We).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function ui([e,t]){return `${e}=${We(t)}`}function di(e){let t=Object.entries(e).map(ui).join("&");return Buffer.from(t,"utf8").toString("base64")}var Ii={[cn]:"Account not found at address: $address",[_n]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[In]:"Expected decoded account at address: $address",[dn]:"Failed to decode account data at address: $address",[un]:"Accounts not found at addresses: $addresses",[Te]:"Unable to find a viable program address bump seed.",[sn]:"$putativeAddress is not a base58-encoded address.",[G]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Ie]:"The `CryptoKey` must be an `Ed25519` public key.",[De]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Re]:"Invalid seeds; point must fall off the Ed25519 curve.",[_e]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[le]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ee]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Ae]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[ge]:"Program address cannot end with PDA marker.",[H]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Lt]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[pt]:"The network has progressed past the last block for which this transaction could have been committed.",[Z]:"Codec [$codecDescription] cannot decode empty byte arrays.",[$o]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[we]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Be]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ze]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[ve]:"Encoder and decoder must either both be fixed-size or variable-size.",[wo]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Fe]:"Expected a fixed-size codec, got a variable-size one.",[J]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[Pe]:"Expected a variable-size codec, got a fixed-size one.",[Ko]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[j]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Ho]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[ko]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[xo]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Wo]:"Invalid literal union variant. Expected one of [$variants], got $value.",[zo]:"Expected [$codecDescription] to have $expected items, got $actual.",[v]:"Invalid value $value for base $base with alphabet $alphabet.",[Vo]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[q]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[Q]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[ke]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Go]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[xe]:"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?",[Sn]:"No random values implementation could be found.",[kn]:"instruction requires an uninitialized account",[Qn]:"instruction tries to borrow reference for an account which is already borrowed",[er]:"instruction left account with an outstanding borrowed reference",[qn]:"program other than the account's owner changed the size of the account data",[vn]:"account data too small for instruction",[Jn]:"instruction expected an executable account",[Cr]:"An account does not have enough lamports to be rent-exempt",[fr]:"Program arithmetic overflowed",[Sr]:"Failed to serialize or deserialize account data: $encodedData",[yr]:"Builtin programs must consume compute units",[cr]:"Cross-program invocation call depth too deep",[lr]:"Computational budget exceeded",[nr]:"custom program error: #$code",[Yn]:"instruction contains duplicate accounts",[tr]:"instruction modifications of multiply-passed account differ",[ar]:"executable accounts must be rent exempt",[or]:"instruction changed executable accounts data",[ir]:"instruction changed the balance of an executable account",[Xn]:"instruction changed executable bit of an account",[Hn]:"instruction modified data of an account it does not own",[Gn]:"instruction spent from the balance of an account it does not own",[Un]:"generic instruction error",[pr]:"Provided owner is not allowed",[Dr]:"Account is immutable",[Nr]:"Incorrect authority provided",[zn]:"incorrect program id for instruction",[Bn]:"insufficient funds for instruction",[Pn]:"invalid account data for instruction",[Or]:"Invalid account owner",[bn]:"invalid program argument",[rr]:"program returned invalid error code",[Fn]:"invalid instruction data",[Ar]:"Failed to reallocate account data",[_r]:"Provided seeds do not result in a valid address",[hr]:"Accounts data allocations exceeded the maximum allowed per transaction",[Mr]:"Max accounts exceeded",[Lr]:"Max instruction trace length exceeded",[Ir]:"Length of the seed is too long for address generation",[ur]:"An account required by the instruction is missing",[wn]:"missing required signature for instruction",[Vn]:"instruction illegally modified the program id of an account",[jn]:"insufficient account keys for instruction",[Er]:"Cross-program invocation with unauthorized signer or writable account",[Rr]:"Failed to create program execution environment",[gr]:"Program failed to compile",[Tr]:"Program failed to complete",[$n]:"instruction modified data of a read-only account",[Kn]:"instruction changed the balance of a read-only account",[dr]:"Cross-program invocation reentrancy not allowed for this instruction",[Zn]:"instruction modified rent epoch of an account",[Wn]:"sum of account balances before and after instruction do not match",[xn]:"instruction requires an initialized account",[yn]:"",[sr]:"Unsupported program id",[mr]:"Unsupported sysvar",[si]:"Invalid instruction plan kind: $kind.",[vo]:"The provided instruction plan is empty.",[Bo]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Fo]:"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).",[ci]:"Invalid transaction plan kind: $kind.",[Po]:"No more instructions to pack; the message packer has completed the instruction plan.",[hn]:"The instruction does not have any accounts.",[Mn]:"The instruction does not have any data.",[Ln]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[yt]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[ht]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[oi]:"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",[ai]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[ri]:"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",[ni]:"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",[ii]:"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",[zt]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[wt]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[xt]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[kt]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Bt]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Xt]:"$__serverMessage",[an]:"$__serverMessage",[nn]:"$__serverMessage",[$t]:"$__serverMessage",[Gt]:"Epoch rewards period still active at slot $slot",[jt]:"$__serverMessage",[qt]:"$__serverMessage",[Wt]:"Failed to query long-term storage; please try again",[Ht]:"Minimum context slot has not been reached",[tn]:"Node is unhealthy; behind by $numSlotsBehind slots",[Jt]:"No snapshot",[on]:"Transaction simulation failed",[Vt]:"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",[Qt]:"$__serverMessage",[Zt]:"Transaction history is not available from this node",[en]:"$__serverMessage",[Yt]:"Transaction signature length mismatch",[rn]:"Transaction signature verification failure",[Kt]:"$__serverMessage",[Cn]:"Key pair bytes must be of length 64, got $byteLength.",[On]:"Expected private key bytes with length 32. Actual length: $actualLength.",[fn]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[pn]:"The provided private key does not match the provided public key.",[mn]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Ut]:"Lamports value must be in the range [0, 2e64-1]",[bt]:"`$value` cannot be parsed as a `BigInt`",[vt]:"$message",[Ft]:"`$value` cannot be parsed as a `Number`",[Mt]:"No nonce account could be found at address `$nonceAccountAddress`",[qo]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Qo]:"WebSocket was closed before payload could be added to the send buffer",[ei]:"WebSocket connection closed",[ti]:"WebSocket failed to connect",[Jo]:"Failed to obtain a subscription id from the server",[jo]:"Could not find an API plan for RPC method: `$method`",[Yo]:"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`.",[Zo]:"HTTP error ($statusCode): $message",[Xo]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Ur]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[br]:"The provided value does not implement the `KeyPairSigner` interface",[Pr]:"The provided value does not implement the `MessageModifyingSigner` interface",[vr]:"The provided value does not implement the `MessagePartialSigner` interface",[Fr]:"The provided value does not implement any of the `MessageSigner` interfaces",[zr]:"The provided value does not implement the `TransactionModifyingSigner` interface",[wr]:"The provided value does not implement the `TransactionPartialSigner` interface",[kr]:"The provided value does not implement the `TransactionSendingSigner` interface",[Br]:"The provided value does not implement any of the `TransactionSigner` interfaces",[xr]:"More than one `TransactionSendingSigner` was identified.",[Wr]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Vr]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Nn]:"Cannot export a non-extractable key.",[ln]:"No digest implementation could be found.",[An]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[En]:`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.`,[_n]:"No signature verification implementation could be found.",[An]:"No key generation implementation could be found.",[ln]:"No signing implementation could be found.",[En]:"No key export implementation could be found.",[yt]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[so]:"Transaction processing left an account with an outstanding borrowed reference",[$r]:"Account in use",[Yr]:"Account loaded twice",[Xr]:"Attempt to debit an account but found no record of a prior credit.",[Eo]:"Transaction loads an address table account that doesn't exist",[Jr]:"This transaction has already been processed",[Qr]:"Blockhash not found",[eo]:"Loader call chain is too deep",[ao]:"Transactions are currently disabled due to cluster maintenance",[Co]:"Transaction contains a duplicate instruction ($index) that is not allowed",[jr]:"Insufficient funds for fee",[Oo]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[qr]:"This account may not be used to pay transaction fees",[no]:"Transaction contains an invalid account reference",[To]:"Transaction loads an address table account with invalid data",[go]:"Transaction address table lookup uses an invalid index",[Ro]:"Transaction loads an address table account with an invalid owner",[mo]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[oo]:"This program may not be used for executing instructions",[Do]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Io]:"Transaction loads a writable account that cannot be written",[fo]:"Transaction exceeded max loaded accounts data size cap",[to]:"Transaction requires a fee but has no signature present",[Zr]:"Attempt to load a program that does not exist",[ho]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[po]:"ResanitizationNeeded",[io]:"Transaction failed to sanitize accounts offsets correctly",[ro]:"Transaction did not pass signature verification",[lo]:"Transaction locked too many accounts",[Mo]:"Sum of account balances before and after transaction do not match",[Kr]:"The transaction failed with the error `$errorName`",[uo]:"Transaction version is unsupported",[Ao]:"Transaction would exceed account data limit within the block",[So]:"Transaction would exceed total account data limit",[_o]:"Transaction would exceed max account limit within the block",[co]:"Transaction would exceed max Block Cost Limit",[No]:"Transaction would exceed max Vote Cost Limit",[he]:"Attempted to sign a transaction with an address that is not a signer for it",[kr]:"Transaction is missing an address at index: $index.",[Me]:"Transaction has no expected signers therefore it cannot be encoded",[Le]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[G]:"Transaction does not have a blockhash lifetime",[H]:"Transaction is not a durable nonce transaction",[Se]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Ce]:"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",[fe]:"No fee payer set in CompiledTransaction",[Oe]:"Could not find program address at index $index",[Gr]:"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",[Hr]:"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",[xr]:"Transaction is missing a fee payer.",[pe]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Vr]:"Transaction first instruction is not advance nonce account instruction.",[Wr]:"Transaction with no instructions cannot be durable nonce transaction.",[ge]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[De]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[K]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[me]:"Transaction is missing signatures for addresses: $addresses.",[Ne]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[$]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[ye]:"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",T="t";function ci(e,t={}){let n=si[e];if(n.length===0)return "";let r;function o(s){if(r[T]===2){let i=n.slice(r[D]+1,s);a.push(i in t?`${t[i]}`:`$${i}`);}else r[T]===1&&a.push(n.slice(r[D],s));}let a=[];return n.split("").forEach((s,i)=>{if(i===0){r={[D]:0,[T]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[T]){case 0:c={[D]:i,[T]:1};break;case 1:s==="\\"?c={[D]:i,[T]:0}:s==="$"&&(c={[D]:i,[T]:2});break;case 2:s==="\\"?c={[D]:i,[T]:0}:s==="$"?c={[D]:i,[T]:2}:s.match(/\w/)||(c={[D]:i,[T]:1});break}c&&(r!==c&&o(i),r=c);}),o(),a.join("")}function ui(e,t={}){if(process.env.NODE_ENV!=="production")return ci(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${ai(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,s])=>{a==="cause"?r={cause:s.value}:(n===void 0&&(n={}),Object.defineProperty(n,a,s));});let o=ui(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function di(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Ii=(e,t)=>di(e.length<=t?e:e.slice(0,t),t);function We(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function N(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(We(t,e));return e.write(t,n,0),n}})}function A(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function p(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function _i(e){return !p(e)}function Ve(e,t,n=0){if(t.length-n<=0)throw new l(Y,{codecDescription:e})}function P(e,t,n,r=0){let o=n.length-r;if(o<t)throw new l(X,{bytesLength:o,codecDescription:e,expected:t})}function xe(e,t,n){if(t<0||t>n)throw new l(q,{bytesLength:n,codecDescription:e,offset:t})}function y(e,t){return N({fixedSize:t,write:(n,r,o)=>{let a=e.encode(n),s=a.length>t?a.slice(0,t):a;return r.set(s,o),o+t}})}function h(e,t){return A({fixedSize:t,read:(n,r)=>{P("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),p(e)&&(n=Ii(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function Ai(e,t){return A({...e,read:(n,r)=>{let o=u=>li(u,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;xe("offsetDecoder",a,n.length);let[s,i]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:i,preOffset:r,wrapBytes:o}):i;return xe("offsetDecoder",c,n.length),[s,c]}})}function li(e,t){return t===0?0:(e%t+t)%t}function Ei(e,t){if(p(e)){let n=t(e.fixedSize);if(n<0)throw new l(j,{bytesLength:n,codecDescription:"resizeDecoder"});return A({...e,fixedSize:n})}return e}function Ge(e,t){return Ai(Ei(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function U(e,t){return N({..._i(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function v(e,t){return A({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function $e(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new l(F,{alphabet:e,base:e.length,value:n})}var Ri=e=>N({getSizeFromValue:t=>{let[n,r]=He(t,e[0]);if(!r)return t.length;let o=Ke(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if($e(e,t),t==="")return r;let[o,a]=He(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let s=Ke(a,e),i=[];for(;s>0n;)i.unshift(Number(s%256n)),s/=256n;let c=[...Array(o.length).fill(0),...i];return n.set(c,r),r+c.length}}),Ti=e=>A({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 s=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),i=gi(s,e);return [a+i,t.length]}});function He(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ke(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function gi(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ye="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Xe=()=>Ri(Ye),B=()=>Ti(Ye);var Di="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",z=()=>N({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){$e(Di,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),S=()=>A({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var J,Q;function Ze(){return J||(J=Xe()),J}function Ni(){return Q||(Q=B()),Q}function Si(e){if(e.length<32||e.length>44)throw new l(V,{actualLength:e.length});let r=Ze().encode(e).byteLength;if(r!==32)throw new l(W,{actualLength:r})}function M(e){return Si(e),e}function ee(){return U(y(Ze(),32),e=>M(e))}function je(){return h(Ni(),32)}function Ci(e,t,n,r){if(r<t||r>n)throw new l(Z,{codecDescription:e,max:n,min:t,value:r})}function qe(e){return e?.endian!==1}function Oi(e){return N({fixedSize:e.size,write(t,n,r){e.range&&Ci(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,qe(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function Je(e){return A({fixedSize:e.size,read(t,n=0){Ve(e.name,t,n),P(e.name,e.size,t,n);let r=new DataView(fi(t,n,e.size));return [e.get(r,qe(e.config)),n+e.size]}})}function fi(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var te=()=>A({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],s=127&a;if(n|=s<<o*7,(a&128)===0)break}return [n,t+r]}});var Qe=(e={})=>Je({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var et=(e={})=>Oi({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8});var ne=()=>Je({get:e=>e.getUint8(0),name:"u8",size:1});function w(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function re(e){return p(e)?e.fixedSize:null}function oe(e){return p(e)?e.fixedSize:e.maxSize??null}function ie(e,t={}){let n=t.size??Qe(),r=re(e),o=tt(n,r),a=tt(n,oe(e))??void 0;return A({...o!==null?{fixedSize:o}:{maxSize:a},read:(s,i)=>{let c=[];if(typeof n=="object"&&s.slice(i).length===0)return [c,i];if(n==="remainder"){for(;i<s.length;){let[d,_]=e.read(s,i);i=_,c.push(d);}return [c,i]}let[u,I]=typeof n=="number"?[n,i]:n.read(s,i);i=I;for(let d=0;d<u;d+=1){let[_,E]=e.read(s,i);i=E,c.push(_);}return [c,i]}})}function tt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function ae(){return A({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function nt(e){let t=w(e.map(re)),n=w(e.map(oe))??void 0;return A({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let a=[];return e.forEach(s=>{let[i,c]=s.read(r,o);a.push(i),o=c;}),[a,o]}})}function rt(e){let t=e.map(([,o])=>o),n=w(t.map(re)),r=w(t.map(oe))??void 0;return A({...n===null?{maxSize:r}:{fixedSize:n},read:(o,a)=>{let s={};return e.forEach(([i,c])=>{let[u,I]=c.read(o,a);a=I,s[i]=u;}),[s,a]}})}var mi=0,ot=128;function it(){return A({maxSize:1,read:(e,t)=>{let n=e[t];if((n&ot)===0)return ["legacy",t];{let r=n^ot;if(r>mi)throw new l($,{unsupportedVersion:r});return [r,t+1]}}})}function at(){return v(rt([["signatures",ie(h(ae(),64),{size:te()})],["messageBytes",ae()]]),pi)}function pi(e){let{messageBytes:t,signatures:n}=e,r=nt([it(),Ge(ne(),2),ie(je(),{size:te()})]),[o,a,s]=r.decode(t),i=s.slice(0,a);if(i.length!==n.length)throw new l(K,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:i});let c={};return i.forEach((u,I)=>{let d=n[I];d.every(_=>_===0)?c[u]=null:c[u]=d;}),{messageBytes:t,signatures:Object.freeze(c)}}function st(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,a,s,i;if(r)o=t,a=n,s=0,i=0;else {let u=window.screenLeft??window.screenX??0,I=window.screenTop??window.screenY??0,d=window.innerWidth??document.documentElement.clientWidth??window.screen.width,_=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,a=600,i=Math.round(u+(d-o)/2),s=Math.round(I+(_-a)/2);}let c=["popup=yes",`width=${o}`,`height=${a}`,`top=${s}`,`left=${i}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e??"","_blank",c)}function ct(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[Rn]:"No signature verification implementation could be found.",[Tn]:"No key generation implementation could be found.",[gn]:"No signing implementation could be found.",[Dn]:"No key export implementation could be found.",[Pt]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[_o]:"Transaction processing left an account with an outstanding borrowed reference",[jr]:"Account in use",[qr]:"Account loaded twice",[Jr]:"Attempt to debit an account but found no record of a prior credit.",[Do]:"Transaction loads an address table account that doesn't exist",[no]:"This transaction has already been processed",[ro]:"Blockhash not found",[oo]:"Loader call chain is too deep",[Io]:"Transactions are currently disabled due to cluster maintenance",[po]:"Transaction contains a duplicate instruction ($index) that is not allowed",[eo]:"Insufficient funds for fee",[ho]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[to]:"This account may not be used to pay transaction fees",[ao]:"Transaction contains an invalid account reference",[So]:"Transaction loads an address table account with invalid data",[Co]:"Transaction address table lookup uses an invalid index",[No]:"Transaction loads an address table account with an invalid owner",[Lo]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[co]:"This program may not be used for executing instructions",[Oo]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Eo]:"Transaction loads a writable account that cannot be written",[Mo]:"Transaction exceeded max loaded accounts data size cap",[io]:"Transaction requires a fee but has no signature present",[Qr]:"Attempt to load a program that does not exist",[Uo]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[yo]:"ResanitizationNeeded",[uo]:"Transaction failed to sanitize accounts offsets correctly",[so]:"Transaction did not pass signature verification",[go]:"Transaction locked too many accounts",[bo]:"Sum of account balances before and after transaction do not match",[Zr]:"The transaction failed with the error `$errorName`",[lo]:"Transaction version is unsupported",[To]:"Transaction would exceed account data limit within the block",[mo]:"Transaction would exceed total account data limit",[Ro]:"Transaction would exceed max account limit within the block",[Ao]:"Transaction would exceed max Block Cost Limit",[fo]:"Transaction would exceed max Vote Cost Limit",[Le]:"Attempted to sign a transaction with an address that is not a signer for it",[Gr]:"Transaction is missing an address at index: $index.",[ye]:"Transaction has no expected signers therefore it cannot be encoded",[Ue]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[K]:"Transaction does not have a blockhash lifetime",[$]:"Transaction is not a durable nonce transaction",[Oe]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[fe]:"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",[pe]:"No fee payer set in CompiledTransaction",[me]:"Could not find program address at index $index",[Yr]:"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",[Xr]:"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",[Hr]:"Transaction is missing a fee payer.",[Me]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[$r]:"Transaction first instruction is not advance nonce account instruction.",[Kr]:"Transaction with no instructions cannot be durable nonce transaction.",[Ne]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Se]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Y]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[he]:"Transaction is missing signatures for addresses: $addresses.",[Ce]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[X]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[be]:"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",T="t";function _i(e,t={}){let n=Ii[e];if(n.length===0)return "";let r;function o(i){if(r[T]===2){let s=n.slice(r[D]+1,i);a.push(s in t?`${t[s]}`:`$${s}`);}else r[T]===1&&a.push(n.slice(r[D],i));}let a=[];return n.split("").forEach((i,s)=>{if(s===0){r={[D]:0,[T]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[T]){case 0:c={[D]:s,[T]:1};break;case 1:i==="\\"?c={[D]:s,[T]:0}:i==="$"&&(c={[D]:s,[T]:2});break;case 2:i==="\\"?c={[D]:s,[T]:0}:i==="$"?c={[D]:s,[T]:2}:i.match(/\w/)||(c={[D]:s,[T]:1});break}c&&(r!==c&&o(s),r=c);}),o(),a.join("")}function Ai(e,t={}){if(process.env.NODE_ENV!=="production")return _i(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${di(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=Ai(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function li(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Ei=(e,t)=>li(e.length<=t?e:e.slice(0,t),t);function Ge(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function N(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Ge(t,e));return e.write(t,n,0),n}})}function A(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function p(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Ri(e){return !p(e)}function He(e,t,n=0){if(t.length-n<=0)throw new l(Z,{codecDescription:e})}function B(e,t,n,r=0){let o=n.length-r;if(o<t)throw new l(j,{bytesLength:o,codecDescription:e,expected:t})}function Ve(e,t,n){if(t<0||t>n)throw new l(Q,{bytesLength:n,codecDescription:e,offset:t})}function U(e,t){return N({fixedSize:t,write:(n,r,o)=>{let a=e.encode(n),i=a.length>t?a.slice(0,t):a;return r.set(i,o),o+t}})}function h(e,t){return A({fixedSize:t,read:(n,r)=>{B("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),p(e)&&(n=Ei(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function Ti(e,t){return A({...e,read:(n,r)=>{let o=d=>gi(d,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;Ve("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 Ve("offsetDecoder",c,n.length),[i,c]}})}function gi(e,t){return t===0?0:(e%t+t)%t}function Di(e,t){if(p(e)){let n=t(e.fixedSize);if(n<0)throw new l(J,{bytesLength:n,codecDescription:"resizeDecoder"});return A({...e,fixedSize:n})}return e}function Ke(e,t){return Ti(Di(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function b(e,t){return N({...Ri(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function z(e,t){return A({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function Xe(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new l(v,{alphabet:e,base:e.length,value:n})}var Ni=e=>N({getSizeFromValue:t=>{let[n,r]=$e(t,e[0]);if(!r)return t.length;let o=Ye(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Xe(e,t),t==="")return r;let[o,a]=$e(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=Ye(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}}),Si=e=>A({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,d)=>c*256n+BigInt(d),0n),s=Ci(i,e);return [a+s,t.length]}});function $e(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Ye(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Ci(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Ze="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",je=()=>Ni(Ze),w=()=>Si(Ze);var Oi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",k=()=>N({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){Xe(Oi,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),S=()=>A({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var ee,te;function qe(){return ee||(ee=je()),ee}function fi(){return te||(te=w()),te}function mi(e){if(e.length<32||e.length>44)throw new l(H,{actualLength:e.length});let r=qe().encode(e).byteLength;if(r!==32)throw new l(G,{actualLength:r})}function M(e){return mi(e),e}function ne(){return b(U(qe(),32),e=>M(e))}function Je(){return h(fi(),32)}function pi(e,t,n,r){if(r<t||r>n)throw new l(q,{codecDescription:e,max:n,min:t,value:r})}function Qe(e){return e?.endian!==1}function hi(e){return N({fixedSize:e.size,write(t,n,r){e.range&&pi(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,Qe(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function et(e){return A({fixedSize:e.size,read(t,n=0){He(e.name,t,n),B(e.name,e.size,t,n);let r=new DataView(Mi(t,n,e.size));return [e.get(r,Qe(e.config)),n+e.size]}})}function Mi(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var re=()=>A({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 tt=(e={})=>et({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var nt=(e={})=>hi({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8});var oe=()=>et({get:e=>e.getUint8(0),name:"u8",size:1});function x(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function ie(e){return p(e)?e.fixedSize:null}function ae(e){return p(e)?e.fixedSize:e.maxSize??null}function se(e,t={}){let n=t.size??tt(),r=ie(e),o=rt(n,r),a=rt(n,ae(e))??void 0;return A({...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[u,I]=e.read(i,s);s=I,c.push(u);}return [c,s]}let[d,_]=typeof n=="number"?[n,s]:n.read(i,s);s=_;for(let u=0;u<d;u+=1){let[I,E]=e.read(i,s);s=E,c.push(I);}return [c,s]}})}function rt(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function ce(){return A({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function ot(e){let t=x(e.map(ie)),n=x(e.map(ae))??void 0;return A({...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 it(e){let t=e.map(([,o])=>o),n=x(t.map(ie)),r=x(t.map(ae))??void 0;return A({...n===null?{maxSize:r}:{fixedSize:n},read:(o,a)=>{let i={};return e.forEach(([s,c])=>{let[d,_]=c.read(o,a);a=_,i[s]=d;}),[i,a]}})}var Li=0,at=128;function st(){return A({maxSize:1,read:(e,t)=>{let n=e[t];if((n&at)===0)return ["legacy",t];{let r=n^at;if(r>Li)throw new l(X,{unsupportedVersion:r});return [r,t+1]}}})}function ct(){return z(it([["signatures",se(h(ce(),64),{size:re()})],["messageBytes",ce()]]),yi)}function yi(e){let{messageBytes:t,signatures:n}=e,r=ot([st(),Ke(oe(),2),se(Je(),{size:re()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new l(Y,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((d,_)=>{let u=n[_];u.every(I=>I===0)?c[d]=null:c[d]=u;}),{messageBytes:t,signatures:Object.freeze(c)}}function ut(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,a,i,s;if(r)o=t,a=n,i=0,s=0;else {let d=window.screenLeft??window.screenX??0,_=window.screenTop??window.screenY??0,u=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,a=600,s=Math.round(d+(u-o)/2),i=Math.round(_+(I-a)/2);}let c=["popup=yes",`width=${o}`,`height=${a}`,`top=${i}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e??"","_blank",c)}function dt(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
6
6
 
7
7
  ${n.join(`
8
- `)}`:t}async function $a(e){let{rid:t,redirectOrigin:n}=e.createNewPopup();await new Promise(a=>setTimeout(a,0));let r={phase:"start",rid:t,validTill:Date.now()+6e5,data:{type:"message",payload:ct({domain:n,nonce:S().decode(crypto.getRandomValues(new Uint8Array(16)))})},redirectOrigin:n},o=new AbortController;return e.sendPayloadToProvider({rid:t,signal:o.signal}).catch(a=>o.abort(a)),await e.onClientAuthorizationCallback(r,o.signal)}async function qa(e,t){let{redirectOrigin:n,rid:r}=e.createNewPopup();await new Promise(E=>setTimeout(E,0));let{instructions:o,signer:a,addressesByLookupTableAddress:s,hasTxManager:i=true}=t,c=core.prepareTransactionMessage({payer:M(a.walletAddress),instructions:o,addressesByLookupTableAddress:s}),u=await core.getSettingsFromIndex(a.settingsIndexWithAddress.index),I={transactionMessageBytes:S().decode(c),transactionAddress:u,transactionActionType:i?"execute":"create_with_preauthorized_execution"},d={phase:"start",rid:r,validTill:Date.now()+6e5,data:{type:"transaction",payload:I,sendTx:true,additionalSigners:t.additionalSigners},redirectOrigin:n,signer:a.publicKey},_=new AbortController;return e.sendPayloadToProvider({rid:r,signal:_.signal}).catch(E=>_.abort(E)),await e.onClientAuthorizationCallback(d,_.signal)}var k="11111111111111111111111111111111";var ut=0,dt=1,It=2,_t=3,At=4,lt=5,Et=6,Rt=7,Tt=8;process.env.NODE_ENV!=="production"&&({[ut]:"an account with the same address already exists",[lt]:"provided address does not match addressed derived from seed",[_t]:"cannot allocate account data of this length",[It]:"cannot assign account to this program id",[At]:"length of requested seed is too long",[Rt]:"stored nonce is still in recent_blockhashes",[Et]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[Tt]:"specified nonce does not match stored nonce",[dt]:"account does not have enough SOL to perform the operation"});var se="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";async function Om(e,t){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{rid:n,redirectOrigin:r}=e.createNewPopup();await new Promise(_=>setTimeout(_,0));let{mint:o,tokenProgram:a=se,amount:s,destination:i,signer:c}=t,u={transactionActionType:"transfer_intent",transactionAddress:o?a:k,transactionMessageBytes:S().decode(new Uint8Array([...et().encode(s),...ee().encode(M(i)),...ee().encode(M(o??k))]))},I={phase:"start",rid:n,validTill:Date.now()+6e5,data:{type:"transaction",payload:u,sendTx:true},redirectOrigin:r,signer:c?.publicKey},d=new AbortController;return e.sendPayloadToProvider({rid:n,signal:d.signal}).catch(_=>d.abort(_)),await e.onClientAuthorizationCallback(I,d.signal)}var C="https://auth.revibase.com";var gt="revibase.com";var Dt=class{pending=new Map;onClientAuthorizationCallback;providerOrigin;popUp=null;constructor(t){this.onClientAuthorizationCallback=t.onClientAuthorizationCallback,this.providerOrigin=t.providerOrigin??C;}createNewPopup(){let t=window.origin,n=S().decode(crypto.getRandomValues(new Uint8Array(16))),r=new URL(this.providerOrigin);if(r.searchParams.set("rid",n),r.searchParams.set("redirectOrigin",t),this.popUp=st(r.toString()),!this.popUp)throw new Error("Popup blocked. Please enable popups.");return {rid:n,redirectOrigin:t}}async sendPayloadToProvider({rid:t,timeoutMs:n=6e5,signal:r}){if(typeof window>"u")throw new Error("Provider can only be used in a browser environment");if(this.pending.size>0)throw new Error("An authorization flow is already in progress");return new Promise((o,a)=>{let s=setTimeout(()=>{let i=this.pending.get(t);i&&(i.cancel?i.cancel(new Error("Authentication timed out")):(this.pending.delete(t),a(new Error("Authentication timed out"))));},n);if(!this.popUp||this.popUp.closed)throw new Error("Popup is not open. Call createNewPopup() first.");this.pending.set(t,{rid:t,resolve:o,reject:a,timeoutId:s}),this.attachTransport({popup:this.popUp,origin:new URL(this.providerOrigin).origin,rid:t,signal:r});})}attachTransport(t){let{popup:n,origin:r,rid:o,signal:a}=t,s=this.pending.get(o);if(!s)return;let i=null,c=false,u=()=>{d(new Error("Aborted"));},I=()=>{a.removeEventListener("abort",u),window.removeEventListener("message",f);try{i?.close();}catch{}i=null;try{n&&!n.closed&&n.close();}catch{}this.popUp=null,clearInterval(E);},d=R=>{c||(c=true,clearTimeout(s.timeoutId),this.pending.delete(o),I(),s.reject(R));},_=()=>{c||(c=true,clearTimeout(s.timeoutId),this.pending.delete(o),I(),s.resolve({rid:o}));};if(s.cancel=d,a.aborted){d(new Error("Aborted"));return}a.addEventListener("abort",u);let E=setInterval(()=>{n?.closed&&d(new Error("Popup was closed by the user"));},2e3),f=R=>{if(R.origin!==r||R.source!==n)return;let L=R.data;!L||L.type!=="popup-connect"||L.rid!==o||R.ports?.[0]&&(i=R.ports[0],i.start(),i.postMessage({type:"popup-init"}),i.onmessage=m=>{switch(m.data.type){case "popup-complete":_();break;case "popup-error":d(new Error(m.data.error));break;case "popup-closed":{d(new Error("Lost connection with the popup."));break}}},window.removeEventListener("message",f));};window.addEventListener("message",f);}};async function zm(e,t){let n=new Array(e.transactions.length);for(let r=0;r<e.transactions.length;r++){let{messageBytes:o}=at().decode(z().encode(e.transactions[r])),a=await crypto.subtle.sign({name:"Ed25519"},t.keyPair.privateKey,new Uint8Array(o));n[r]=B().decode(new Uint8Array(a));}return {signatures:n}}async function Nt({rid:e,privateKey:t,providerOrigin:n=C,signal:r}){let o=core.convertBase64StringToJWK(t);if(!o.alg)throw new Error("Property alg in JWK is missing.");let a=await new jose.CompactSign(z().encode(e)).setProtectedHeader({alg:o.alg}).sign(o),s=await fetch(`${n}/api/getResult`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({rid:e,signature:a}),signal:r});if(!s.ok)throw new Error((await s.json()).error);let i=s.body?.getReader();if(!i)throw new Error("Response body is not a stream");let c=new TextDecoder,u="";return new Promise((I,d)=>{let _=async()=>{try{let{done:E,value:f}=await i.read();f&&(u+=c.decode(f,{stream:!E}));let R=u.split(`
8
+ `)}`:t}async function Qa(e){let{rid:t,redirectOrigin:n}=e.createNewPopup();await new Promise(a=>setTimeout(a,0));let r={phase:"start",rid:t,validTill:Date.now()+6e5,data:{type:"message",payload:dt({domain:n,nonce:S().decode(crypto.getRandomValues(new Uint8Array(16)))})},redirectOrigin:n},o=new AbortController;return e.channelId||e.sendPayloadToProvider({rid:t,signal:o.signal}).catch(a=>o.abort(a)),await e.onClientAuthorizationCallback(r,o.signal,await e.getDeviceSignature(),e.channelId)}async function os(e,t){let{redirectOrigin:n,rid:r}=e.createNewPopup();await new Promise(E=>setTimeout(E,0));let{instructions:o,signer:a,addressesByLookupTableAddress:i,hasTxManager:s=true}=t,c=core.prepareTransactionMessage({payer:M(a.walletAddress),instructions:o,addressesByLookupTableAddress:i}),d=await core.getSettingsFromIndex(a.settingsIndexWithAddress.index),_={transactionMessageBytes:S().decode(c),transactionAddress:d,transactionActionType:s?"execute":"create_with_preauthorized_execution"},u={phase:"start",rid:r,validTill:Date.now()+6e5,data:{type:"transaction",payload:_,sendTx:true,additionalSigners:t.additionalSigners},redirectOrigin:n,signer:a.publicKey},I=new AbortController;return e.channelId||e.sendPayloadToProvider({rid:r,signal:I.signal}).catch(E=>I.abort(E)),await e.onClientAuthorizationCallback(u,I.signal,await e.getDeviceSignature(),e.channelId)}var W="11111111111111111111111111111111";var It=0,_t=1,At=2,lt=3,Et=4,Rt=5,Tt=6,gt=7,Dt=8;process.env.NODE_ENV!=="production"&&({[It]:"an account with the same address already exists",[Rt]:"provided address does not match addressed derived from seed",[lt]:"cannot allocate account data of this length",[At]:"cannot assign account to this program id",[Et]:"length of requested seed is too long",[gt]:"stored nonce is still in recent_blockhashes",[Tt]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[Dt]:"specified nonce does not match stored nonce",[_t]:"account does not have enough SOL to perform the operation"});var ue="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";async function ym(e,t){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{rid:n,redirectOrigin:r}=e.createNewPopup();await new Promise(I=>setTimeout(I,0));let{mint:o,tokenProgram:a=ue,amount:i,destination:s,signer:c}=t,d={transactionActionType:"transfer_intent",transactionAddress:o?a:W,transactionMessageBytes:S().decode(new Uint8Array([...nt().encode(i),...ne().encode(M(s)),...ne().encode(M(o??W))]))},_={phase:"start",rid:n,validTill:Date.now()+6e5,data:{type:"transaction",payload:d,sendTx:true},redirectOrigin:r,signer:c?.publicKey},u=new AbortController;return e.channelId||e.sendPayloadToProvider({rid:n,signal:u.signal}).catch(I=>u.abort(I)),await e.onClientAuthorizationCallback(_,u.signal,await e.getDeviceSignature(),e.channelId)}var C="https://auth.revibase.com";var Nt="revibase.com";var wi="device-keys",L="ed25519-keys",St="private-key",Ct="public-key",P=class e{static openDB(){return new Promise((t,n)=>{let r=indexedDB.open(wi,1);r.onupgradeneeded=()=>{let o=r.result;o.objectStoreNames.contains(L)||o.createObjectStore(L);},r.onsuccess=()=>t(r.result),r.onerror=()=>n(r.error);})}static async saveToDB(t,n){let r=await e.openDB();return new Promise((o,a)=>{let i=r.transaction(L,"readwrite");i.objectStore(L).put(n,t),i.oncomplete=()=>o(),i.onerror=()=>a(i.error);})}static async loadFromDB(t){let n=await e.openDB();return new Promise((r,o)=>{let i=n.transaction(L,"readonly").objectStore(L).get(t);i.onsuccess=()=>r(i.result),i.onerror=()=>o(i.error);})}static async create(){let t=await crypto.subtle.generateKey({name:"Ed25519"},false,["sign","verify"]),n=await crypto.subtle.exportKey("jwk",t.publicKey),r=core.convertJWKToBase64String({...n,alg:"EdDSA"});try{await e.saveToDB(St,t.privateKey);}catch(o){throw o instanceof DOMException&&o.name==="DataCloneError"?new Error("Storing device key in this browser is not supported. Try Chrome or ensure you are in a secure context."):o}return await e.saveToDB(Ct,r),r}static async getOrCreateDevicePublickey(){let t=await e.loadFromDB(Ct);return t||(t=await e.create()),{publicKey:t}}static async sign(t){let n=await e.loadFromDB(St);if(!n)throw new Error("Device key not found. Call DeviceKeyManager.create() first.");return await new jose.CompactSign(t).setProtectedHeader({alg:"EdDSA"}).sign(n)}};var Ot=class{pending=new Map;onClientAuthorizationCallback;providerOrigin;popUp=null;channelId=void 0;constructor(t){this.onClientAuthorizationCallback=t.onClientAuthorizationCallback,this.providerOrigin=t.providerOrigin??C,this.channelId=t.channelId;}async getDeviceSignature(){if(this.channelId)return {jwk:(await P.getOrCreateDevicePublickey()).publicKey,jws:await P.sign(new TextEncoder().encode(this.channelId))}}createNewPopup(){let t=window.origin,n=S().decode(crypto.getRandomValues(new Uint8Array(16))),r=new URL(this.providerOrigin);if(r.searchParams.set("rid",n),r.searchParams.set("redirectOrigin",t),this.popUp=ut(r.toString()),!this.popUp)throw new Error("Popup blocked. Please enable popups.");return {rid:n,redirectOrigin:t}}async sendPayloadToProvider({rid:t,timeoutMs:n=6e5,signal:r}){if(typeof window>"u")throw new Error("Provider can only be used in a browser environment");if(this.pending.size>0)throw new Error("An authorization flow is already in progress");return new Promise((o,a)=>{let i=setTimeout(()=>{let s=this.pending.get(t);s&&(s.cancel?s.cancel(new Error("Authentication timed out")):(this.pending.delete(t),a(new Error("Authentication timed out"))));},n);if(!this.popUp||this.popUp.closed)throw new Error("Popup is not open. Call createNewPopup() first.");this.pending.set(t,{rid:t,resolve:o,reject:a,timeoutId:i}),this.attachTransport({popup:this.popUp,origin:new URL(this.providerOrigin).origin,rid:t,signal:r});})}attachTransport(t){let{popup:n,origin:r,rid:o,signal:a}=t,i=this.pending.get(o);if(!i)return;let s=null,c=false,d=()=>{u(new Error("Aborted"));},_=()=>{a.removeEventListener("abort",d),window.removeEventListener("message",f);try{s?.close();}catch{}s=null;try{n&&!n.closed&&n.close();}catch{}this.popUp=null,clearInterval(E);},u=R=>{c||(c=true,clearTimeout(i.timeoutId),this.pending.delete(o),_(),i.reject(R));},I=()=>{c||(c=true,clearTimeout(i.timeoutId),this.pending.delete(o),_(),i.resolve({rid:o}));};if(i.cancel=u,a.aborted){u(new Error("Aborted"));return}a.addEventListener("abort",d);let E=setInterval(()=>{n?.closed&&u(new Error("Popup was closed by the user"));},2e3),f=R=>{if(R.origin!==r||R.source!==n)return;let y=R.data;!y||y.type!=="popup-connect"||y.rid!==o||R.ports?.[0]&&(s=R.ports[0],s.start(),s.postMessage({type:"popup-init"}),s.onmessage=m=>{switch(m.data.type){case "popup-complete":I();break;case "popup-error":u(new Error(m.data.error));break;case "popup-closed":{u(new Error("Lost connection with the popup."));break}}},window.removeEventListener("message",f));};window.addEventListener("message",f);}};async function Xm(e,t){let n=new Array(e.transactions.length);for(let r=0;r<e.transactions.length;r++){let{messageBytes:o}=ct().decode(k().encode(e.transactions[r])),a=await crypto.subtle.sign({name:"Ed25519"},t.keyPair.privateKey,new Uint8Array(o));n[r]=w().decode(new Uint8Array(a));}return {signatures:n}}async function ft({rid:e,privateKey:t,providerOrigin:n=C,signal:r}){let o=core.convertBase64StringToJWK(t);if(!o.alg)throw new Error("Property alg in JWK is missing.");let a=await new jose.CompactSign(k().encode(e)).setProtectedHeader({alg:o.alg}).sign(o),i=await fetch(`${n}/api/getResult`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream"},body:JSON.stringify({rid:e,signature:a}),signal:r});if(!i.ok)throw new Error((await i.json()).error);let s=i.body?.getReader();if(!s)throw new Error("Response body is not a stream");let c=new TextDecoder,d="";return new Promise((_,u)=>{let I=async()=>{try{let{done:E,value:f}=await s.read();f&&(d+=c.decode(f,{stream:!E}));let R=d.split(`
9
9
 
10
- `);u=E?"":R.pop()??"";for(let L of R){let m="message",x="";for(let O of L.split(`
11
- `))O.startsWith("event:")?m=O.slice(6).trim():O.startsWith("data:")&&(x=O.slice(5).trim());if(x)try{let O=JSON.parse(x);if(m==="result"){I(O);return}if(m==="error"){d(new Error(O?.error??"Unknown error"));return}}catch{}}if(E){d(new Error("Stream ended without complete result"));return}_();}catch(E){d(E instanceof Error?E:new Error(String(E)));}};_();})}async function St(e,t=C,n=gt){let{payload:r}=e.data;if(r.startRequest.data.type!=="message")throw new Error("Invalid request type.");let o=r.startRequest.data.payload,a=core.createMessageChallenge(o,r.client.clientOrigin,r.device.jwk,r.startRequest.rid),{verified:s}=await server.verifyAuthenticationResponse({response:r.authResponse,expectedChallenge:core.bufferToBase64URLString(a),expectedRPID:n,expectedOrigin:t,requireUserVerification:false,credential:{counter:0,id:r.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(r.signer)}});if(!s)throw new Error("WebAuthn message verification failed");let i=r.additionalInfo?.settingsIndexWithAddress;if(!i)throw new Error("User is not delegated");let c=await core.getWalletAddressFromIndex(i.index);return core.UserInfoSchema.parse({publicKey:r.signer,walletAddress:c,settingsIndexWithAddress:i,...r.additionalInfo})}async function ce({privateKey:e,request:t,providerOrigin:n=C,signal:r}){let o=core.convertBase64StringToJWK(e);if(!o.alg)throw new Error("Property alg in JWK is missing.");let a=await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge(t)).setProtectedHeader({alg:o.alg}).sign(o),s=await fetch(`${n}/api/startRequest`,{method:"POST",body:JSON.stringify({signature:a,request:t}),signal:r});if(!s.ok)throw new Error((await s.json()).error);return await s.json()}async function op({request:e,privateKey:t,providerOrigin:n,rpId:r,signal:o}){let a=$i__default.default.union([core.StartMessageRequestSchema,core.StartTransactionRequestSchema]).parse(e),{data:s,signer:i,redirectOrigin:c,rid:u}=a;s.type==="message"?await ce({request:{phase:"start",redirectOrigin:c,signer:i,rid:u,validTill:Date.now()+6e5,data:{type:"message",payload:s.payload}},privateKey:t,providerOrigin:n,signal:o}):await ce({request:{phase:"start",redirectOrigin:c,signer:i,rid:u,validTill:Date.now()+6e5,data:{type:"transaction",payload:s.payload,sendTx:true,additionalSigners:s.additionalSigners}},providerOrigin:n,privateKey:t,signal:o});let I=await Nt({rid:u,providerOrigin:n,privateKey:t,signal:o});return I.data.type==="message"?{user:await St({data:I.data},n,r)}:{txSig:I.data.payload.txSig,user:I.data.payload.user}}exports.RevibaseProvider=Dt;exports.createTransactionSigner=zm;exports.executeTransaction=qa;exports.processClientAuthCallback=op;exports.signIn=$a;exports.transferTokens=Om;//# sourceMappingURL=index.cjs.map
10
+ `);d=E?"":R.pop()??"";for(let y of R){let m="message",V="";for(let O of y.split(`
11
+ `))O.startsWith("event:")?m=O.slice(6).trim():O.startsWith("data:")&&(V=O.slice(5).trim());if(V)try{let O=JSON.parse(V);if(m==="result"){_(O);return}if(m==="error"){u(new Error(O?.error??"Unknown error"));return}}catch{}}if(E){u(new Error("Stream ended without complete result"));return}I();}catch(E){u(E instanceof Error?E:new Error(String(E)));}};I();})}async function mt(e,t=C,n=Nt){let{payload:r}=e.data;if(r.startRequest.data.type!=="message")throw new Error("Invalid request type.");let o=r.startRequest.data.payload,a=core.createMessageChallenge(o,r.client.clientOrigin,r.device.jwk,r.startRequest.rid),{verified:i}=await server.verifyAuthenticationResponse({response:r.authResponse,expectedChallenge:core.bufferToBase64URLString(a),expectedRPID:n,expectedOrigin:t,requireUserVerification:false,credential:{counter:0,id:r.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(r.signer)}});if(!i)throw new Error("WebAuthn message verification failed");let s=r.additionalInfo?.settingsIndexWithAddress;if(!s)throw new Error("User is not delegated");let c=await core.getWalletAddressFromIndex(s.index);return core.UserInfoSchema.parse({publicKey:r.signer,walletAddress:c,settingsIndexWithAddress:s,...r.additionalInfo})}async function de({privateKey:e,request:t,providerOrigin:n=C,signal:r,device:o,channelId:a}){let i=core.convertBase64StringToJWK(e);if(!i.alg)throw new Error("Property alg in JWK is missing.");let s=await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge(t)).setProtectedHeader({alg:i.alg}).sign(i),c=await fetch(`${n}/api/startRequest`,{method:"POST",body:JSON.stringify({signature:s,request:t,device:o,channelId:a}),signal:r});if(!c.ok)throw new Error((await c.json()).error);return await c.json()}async function Ep({request:e,privateKey:t,providerOrigin:n,rpId:r,signal:o,device:a,channelId:i}){let s=Qi__default.default.union([core.StartMessageRequestSchema,core.StartTransactionRequestSchema]).parse(e),{data:c,signer:d,redirectOrigin:_,rid:u}=s;c.type==="message"?await de({request:{phase:"start",redirectOrigin:_,signer:d,rid:u,validTill:Date.now()+6e5,data:{type:"message",payload:c.payload}},privateKey:t,providerOrigin:n,signal:o,device:a,channelId:i}):await de({request:{phase:"start",redirectOrigin:_,signer:d,rid:u,validTill:Date.now()+6e5,data:{type:"transaction",payload:c.payload,sendTx:true,additionalSigners:c.additionalSigners}},providerOrigin:n,privateKey:t,signal:o,device:a,channelId:i});let I=await ft({rid:u,providerOrigin:n,privateKey:t,signal:o});return I.data.type==="message"?{user:await mt({data:I.data},n,r)}:{txSig:I.data.payload.txSig,user:I.data.payload.user}}exports.RevibaseProvider=Ot;exports.createTransactionSigner=Xm;exports.executeTransaction=os;exports.processClientAuthCallback=Ep;exports.signIn=Qa;exports.transferTokens=ym;//# sourceMappingURL=index.cjs.map
12
12
  //# sourceMappingURL=index.cjs.map