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