@pinklemon8/better-auth-siws 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +183 -0
- package/dist/chunk-AUDIM6MZ.js +30 -0
- package/dist/chunk-AUDIM6MZ.js.map +1 -0
- package/dist/chunk-Q7TSFSYW.js +42 -0
- package/dist/chunk-Q7TSFSYW.js.map +1 -0
- package/dist/client.cjs +106 -0
- package/dist/client.cjs.map +1 -0
- package/dist/client.d.cts +86 -0
- package/dist/client.d.ts +86 -0
- package/dist/client.js +69 -0
- package/dist/client.js.map +1 -0
- package/dist/crypto-BQgenqov.d.cts +90 -0
- package/dist/crypto-BQgenqov.d.ts +90 -0
- package/dist/index.cjs +262 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +54 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +189 -0
- package/dist/index.js.map +1 -0
- package/dist/link.cjs +208 -0
- package/dist/link.cjs.map +1 -0
- package/dist/link.d.cts +46 -0
- package/dist/link.d.ts +46 -0
- package/dist/link.js +148 -0
- package/dist/link.js.map +1 -0
- package/dist/react/index.cjs +361 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.js +335 -0
- package/dist/react/index.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lymlight
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
# better-auth-siws
|
|
2
|
+
|
|
3
|
+
Sign In With Solana (SIWS) plugin for [Better Auth](https://www.better-auth.com/) — wallet authentication, linking, and ready-made React components.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Server plugin** — SIWS nonce generation + signature verification, session creation
|
|
8
|
+
- **Client plugin** — `signIn.solana()`, wallet management methods
|
|
9
|
+
- **Wallet linking** — Link/unlink Solana wallets to existing accounts
|
|
10
|
+
- **React components** — Drop-in `<SolanaSignInButton>` and `<SolanaLinkWallet>`
|
|
11
|
+
- **Anonymous mode** — Optionally allow sign-up with wallet only (no email required)
|
|
12
|
+
- Uses `@solana/wallet-standard-util` for cryptographic verification
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install better-auth-siws @solana/wallet-adapter-react @solana/wallet-adapter-react-ui @solana/wallet-standard-features @solana/wallet-standard-util @solana/web3.js
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
### 1. Server Setup
|
|
23
|
+
|
|
24
|
+
```ts
|
|
25
|
+
// auth.ts
|
|
26
|
+
import { betterAuth } from "better-auth";
|
|
27
|
+
import { siws } from "better-auth-siws";
|
|
28
|
+
import { siwsLink } from "better-auth-siws/link";
|
|
29
|
+
|
|
30
|
+
export const auth = betterAuth({
|
|
31
|
+
// ...your config
|
|
32
|
+
plugins: [
|
|
33
|
+
siws({
|
|
34
|
+
// All options are optional
|
|
35
|
+
statement: "Sign in to MyApp with your Solana wallet",
|
|
36
|
+
chainId: "mainnet",
|
|
37
|
+
nonceExpiryMs: 5 * 60 * 1000, // 5 minutes (default)
|
|
38
|
+
anonymous: false, // true = allow sign-up with wallet only
|
|
39
|
+
}),
|
|
40
|
+
siwsLink(), // adds /siws/link, /siws/unlink, /siws/wallets endpoints
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### 2. Client Setup
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
// auth-client.ts
|
|
49
|
+
import { createAuthClient } from "better-auth/react";
|
|
50
|
+
import { siwsClient } from "better-auth-siws/client";
|
|
51
|
+
|
|
52
|
+
export const authClient = createAuthClient({
|
|
53
|
+
plugins: [siwsClient()],
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### 3. React Components (Optional)
|
|
58
|
+
|
|
59
|
+
Drop-in sign-in button:
|
|
60
|
+
|
|
61
|
+
```tsx
|
|
62
|
+
import { SolanaSignInButton } from "better-auth-siws/react";
|
|
63
|
+
|
|
64
|
+
function LoginPage() {
|
|
65
|
+
return (
|
|
66
|
+
<SolanaSignInButton
|
|
67
|
+
onSuccess={(user) => {
|
|
68
|
+
console.log("Signed in:", user);
|
|
69
|
+
window.location.href = "/dashboard";
|
|
70
|
+
}}
|
|
71
|
+
onError={(err) => console.error(err)}
|
|
72
|
+
className="btn btn-primary"
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Wallet linking for settings pages:
|
|
79
|
+
|
|
80
|
+
```tsx
|
|
81
|
+
import { SolanaLinkWallet } from "better-auth-siws/react";
|
|
82
|
+
|
|
83
|
+
function WalletSettings() {
|
|
84
|
+
return (
|
|
85
|
+
<SolanaLinkWallet
|
|
86
|
+
onLink={(addr) => console.log("Linked:", addr)}
|
|
87
|
+
onUnlink={() => console.log("Unlinked")}
|
|
88
|
+
onError={(err) => console.error(err)}
|
|
89
|
+
className="btn"
|
|
90
|
+
unlinkClassName="btn btn-danger"
|
|
91
|
+
/>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Custom rendering for linked state:
|
|
97
|
+
|
|
98
|
+
```tsx
|
|
99
|
+
<SolanaLinkWallet
|
|
100
|
+
renderLinked={({ address, onUnlink }) => (
|
|
101
|
+
<div>
|
|
102
|
+
<code>{address}</code>
|
|
103
|
+
<button onClick={onUnlink}>Remove</button>
|
|
104
|
+
</div>
|
|
105
|
+
)}
|
|
106
|
+
/>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## API Reference
|
|
110
|
+
|
|
111
|
+
### Server Plugin: `siws(options?)`
|
|
112
|
+
|
|
113
|
+
Registers these Better Auth endpoints:
|
|
114
|
+
|
|
115
|
+
| Endpoint | Method | Description |
|
|
116
|
+
|---|---|---|
|
|
117
|
+
| `/siws/nonce` | POST | Generate a nonce for SIWS. Body: `{ walletAddress }` |
|
|
118
|
+
| `/siws/verify` | POST | Verify signature and create session. Body: `{ input, output }` |
|
|
119
|
+
|
|
120
|
+
**Options:**
|
|
121
|
+
|
|
122
|
+
| Option | Type | Default | Description |
|
|
123
|
+
|---|---|---|---|
|
|
124
|
+
| `statement` | `string` | Generic statement | Message shown in wallet |
|
|
125
|
+
| `chainId` | `string` | `"mainnet"` | Solana chain ID |
|
|
126
|
+
| `nonceExpiryMs` | `number` | `300000` (5 min) | Nonce TTL |
|
|
127
|
+
| `anonymous` | `boolean` | `false` | Allow sign-up without pre-existing account |
|
|
128
|
+
|
|
129
|
+
### Server Plugin: `siwsLink(options?)`
|
|
130
|
+
|
|
131
|
+
Registers wallet linking endpoints:
|
|
132
|
+
|
|
133
|
+
| Endpoint | Method | Description |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| `/siws/link` | POST | Link wallet to authenticated user |
|
|
136
|
+
| `/siws/unlink` | POST | Unlink wallet. Body: `{ walletAddress }` |
|
|
137
|
+
| `/siws/wallets` | GET | List linked wallets for current user |
|
|
138
|
+
|
|
139
|
+
### Client Plugin: `siwsClient()`
|
|
140
|
+
|
|
141
|
+
Adds these methods to your auth client:
|
|
142
|
+
|
|
143
|
+
```ts
|
|
144
|
+
// Sign in with Solana
|
|
145
|
+
authClient.signIn.solana({ input, output });
|
|
146
|
+
|
|
147
|
+
// Get nonce
|
|
148
|
+
authClient.solana.getNonce({ walletAddress });
|
|
149
|
+
|
|
150
|
+
// Link/unlink/list wallets
|
|
151
|
+
authClient.solana.linkWallet({ input, output });
|
|
152
|
+
authClient.solana.unlinkWallet({ walletAddress });
|
|
153
|
+
authClient.solana.getLinkedWallets();
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
### React Components
|
|
157
|
+
|
|
158
|
+
| Component | Props | Description |
|
|
159
|
+
|---|---|---|
|
|
160
|
+
| `SolanaProvider` | `cluster`, `endpoint`, `autoConnect` | Wraps Solana wallet adapter providers |
|
|
161
|
+
| `SolanaSignInButton` | `baseURL`, `onSuccess`, `onError`, `className`, `cluster`, `endpoint` | Complete sign-in button |
|
|
162
|
+
| `SolanaLinkWallet` | `baseURL`, `onLink`, `onUnlink`, `onError`, `className`, `cluster`, `endpoint`, `renderLinked` | Wallet link/unlink component |
|
|
163
|
+
|
|
164
|
+
## How It Works
|
|
165
|
+
|
|
166
|
+
1. User clicks sign-in button, wallet modal opens (Phantom, Solflare, etc.)
|
|
167
|
+
2. Plugin generates a nonce stored in Better Auth's verification table
|
|
168
|
+
3. Wallet signs the SIWS message using `adapter.signIn(input)` (Wallet Standard)
|
|
169
|
+
4. Plugin verifies the signature using `@solana/wallet-standard-util`
|
|
170
|
+
5. Looks up the wallet address in the `account` table (`providerId: "solana"`)
|
|
171
|
+
6. Creates a session and sets the cookie
|
|
172
|
+
|
|
173
|
+
**Wallet linking** uses the same SIWS verification but associates the wallet with the currently authenticated user instead of creating a new session.
|
|
174
|
+
|
|
175
|
+
## Requirements
|
|
176
|
+
|
|
177
|
+
- Better Auth >= 1.2.0
|
|
178
|
+
- A Solana wallet that supports SIWS (e.g., Phantom v23.11.0+, Solflare)
|
|
179
|
+
- Node.js 18+ (uses `crypto.getRandomValues`)
|
|
180
|
+
|
|
181
|
+
## License
|
|
182
|
+
|
|
183
|
+
MIT
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// src/types.ts
|
|
2
|
+
function serializeOutput(output) {
|
|
3
|
+
return {
|
|
4
|
+
account: {
|
|
5
|
+
address: output.account.address,
|
|
6
|
+
publicKey: Array.from(output.account.publicKey)
|
|
7
|
+
},
|
|
8
|
+
signature: Array.from(output.signature),
|
|
9
|
+
signedMessage: Array.from(output.signedMessage),
|
|
10
|
+
signatureType: output.signatureType
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function deserializeOutput(data) {
|
|
14
|
+
return {
|
|
15
|
+
account: {
|
|
16
|
+
address: data.account.address,
|
|
17
|
+
publicKey: new Uint8Array(data.account.publicKey),
|
|
18
|
+
chains: [],
|
|
19
|
+
features: []
|
|
20
|
+
},
|
|
21
|
+
signature: new Uint8Array(data.signature),
|
|
22
|
+
signedMessage: new Uint8Array(data.signedMessage)
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
serializeOutput,
|
|
28
|
+
deserializeOutput
|
|
29
|
+
};
|
|
30
|
+
//# sourceMappingURL=chunk-AUDIM6MZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["import type { SolanaSignInInput, SolanaSignInOutput } from \"@solana/wallet-standard-features\";\n\nexport type { SolanaSignInInput, SolanaSignInOutput };\n\nexport interface SiwsPluginOptions {\n statement?: string;\n chainId?: string;\n nonceExpiryMs?: number;\n anonymous?: boolean;\n}\n\nexport interface SiwsNonceResponse {\n nonce: string;\n domain: string;\n uri: string;\n statement: string;\n chainId: string;\n issuedAt: string;\n}\n\nexport interface SiwsVerifyRequest {\n output: {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n };\n input: {\n domain: string;\n address?: string;\n statement?: string;\n uri?: string;\n version?: string;\n chainId?: string;\n nonce?: string;\n issuedAt?: string;\n expirationTime?: string;\n notBefore?: string;\n requestId?: string;\n resources?: string[];\n };\n}\n\nexport interface SiwsVerifyResponse {\n success: boolean;\n user: {\n id: string;\n name: string;\n email: string;\n };\n}\n\nexport interface SiwsLinkRequest {\n input: SolanaSignInInput;\n output: {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n };\n}\n\nexport interface SiwsLinkedWallet {\n walletAddress: string;\n createdAt: Date;\n}\n\nexport interface SerializedSolanaOutput {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n signatureType?: string;\n}\n\nexport function serializeOutput(output: SolanaSignInOutput): SerializedSolanaOutput {\n return {\n account: {\n address: output.account.address,\n publicKey: Array.from(output.account.publicKey),\n },\n signature: Array.from(output.signature),\n signedMessage: Array.from(output.signedMessage),\n signatureType: (output as any).signatureType,\n };\n}\n\nexport function deserializeOutput(data: SerializedSolanaOutput): SolanaSignInOutput {\n return {\n account: {\n address: data.account.address,\n publicKey: new Uint8Array(data.account.publicKey),\n chains: [],\n features: [],\n },\n signature: new Uint8Array(data.signature),\n signedMessage: new Uint8Array(data.signedMessage),\n };\n}\n"],"mappings":";AAiFO,SAAS,gBAAgB,QAAoD;AAClF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAAS,OAAO,QAAQ;AAAA,MACxB,WAAW,MAAM,KAAK,OAAO,QAAQ,SAAS;AAAA,IAChD;AAAA,IACA,WAAW,MAAM,KAAK,OAAO,SAAS;AAAA,IACtC,eAAe,MAAM,KAAK,OAAO,aAAa;AAAA,IAC9C,eAAgB,OAAe;AAAA,EACjC;AACF;AAEO,SAAS,kBAAkB,MAAkD;AAClF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAAS,KAAK,QAAQ;AAAA,MACtB,WAAW,IAAI,WAAW,KAAK,QAAQ,SAAS;AAAA,MAChD,QAAQ,CAAC;AAAA,MACT,UAAU,CAAC;AAAA,IACb;AAAA,IACA,WAAW,IAAI,WAAW,KAAK,SAAS;AAAA,IACxC,eAAe,IAAI,WAAW,KAAK,aAAa;AAAA,EAClD;AACF;","names":[]}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// src/crypto.ts
|
|
2
|
+
import { verifySignIn } from "@solana/wallet-standard-util";
|
|
3
|
+
function generateNonce() {
|
|
4
|
+
const array = new Uint8Array(16);
|
|
5
|
+
crypto.getRandomValues(array);
|
|
6
|
+
return Array.from(array, (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
7
|
+
}
|
|
8
|
+
function createSignInInput(domain, nonce, options) {
|
|
9
|
+
return {
|
|
10
|
+
domain,
|
|
11
|
+
statement: options?.statement ?? "Sign in with your Solana wallet. This will not trigger a blockchain transaction or cost any gas fee.",
|
|
12
|
+
version: "1",
|
|
13
|
+
nonce,
|
|
14
|
+
chainId: options?.chainId ?? "mainnet",
|
|
15
|
+
issuedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function verifySIWS(input, output) {
|
|
19
|
+
try {
|
|
20
|
+
const reconstructed = {
|
|
21
|
+
account: {
|
|
22
|
+
...output.account,
|
|
23
|
+
publicKey: output.account.publicKey instanceof Uint8Array ? output.account.publicKey : new Uint8Array(output.account.publicKey),
|
|
24
|
+
chains: output.account.chains ?? [],
|
|
25
|
+
features: output.account.features ?? []
|
|
26
|
+
},
|
|
27
|
+
signature: output.signature instanceof Uint8Array ? output.signature : new Uint8Array(output.signature),
|
|
28
|
+
signedMessage: output.signedMessage instanceof Uint8Array ? output.signedMessage : new Uint8Array(output.signedMessage)
|
|
29
|
+
};
|
|
30
|
+
return verifySignIn(input, reconstructed);
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error("SIWS verification error:", error);
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export {
|
|
38
|
+
generateNonce,
|
|
39
|
+
createSignInInput,
|
|
40
|
+
verifySIWS
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=chunk-Q7TSFSYW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/crypto.ts"],"sourcesContent":["import type { SolanaSignInInput, SolanaSignInOutput } from \"@solana/wallet-standard-features\";\nimport { verifySignIn } from \"@solana/wallet-standard-util\";\n\nexport function generateNonce(): string {\n const array = new Uint8Array(16);\n crypto.getRandomValues(array);\n return Array.from(array, (byte) => byte.toString(16).padStart(2, \"0\")).join(\"\");\n}\n\nexport function createSignInInput(\n domain: string,\n nonce: string,\n options?: { statement?: string; chainId?: string }\n): SolanaSignInInput {\n return {\n domain,\n statement:\n options?.statement ??\n \"Sign in with your Solana wallet. This will not trigger a blockchain transaction or cost any gas fee.\",\n version: \"1\",\n nonce,\n chainId: options?.chainId ?? \"mainnet\",\n issuedAt: new Date().toISOString(),\n };\n}\n\nexport function verifySIWS(\n input: SolanaSignInInput,\n output: SolanaSignInOutput | { account: { publicKey: number[] | Uint8Array; address: string }; signature: number[] | Uint8Array; signedMessage: number[] | Uint8Array }\n): boolean {\n try {\n const reconstructed: SolanaSignInOutput = {\n account: {\n ...output.account,\n publicKey:\n output.account.publicKey instanceof Uint8Array\n ? output.account.publicKey\n : new Uint8Array(output.account.publicKey),\n chains: (output.account as any).chains ?? [],\n features: (output.account as any).features ?? [],\n },\n signature:\n output.signature instanceof Uint8Array\n ? output.signature\n : new Uint8Array(output.signature),\n signedMessage:\n output.signedMessage instanceof Uint8Array\n ? output.signedMessage\n : new Uint8Array(output.signedMessage),\n };\n return verifySignIn(input, reconstructed);\n } catch (error) {\n console.error(\"SIWS verification error:\", error);\n return false;\n }\n}\n"],"mappings":";AACA,SAAS,oBAAoB;AAEtB,SAAS,gBAAwB;AACtC,QAAM,QAAQ,IAAI,WAAW,EAAE;AAC/B,SAAO,gBAAgB,KAAK;AAC5B,SAAO,MAAM,KAAK,OAAO,CAAC,SAAS,KAAK,SAAS,EAAE,EAAE,SAAS,GAAG,GAAG,CAAC,EAAE,KAAK,EAAE;AAChF;AAEO,SAAS,kBACd,QACA,OACA,SACmB;AACnB,SAAO;AAAA,IACL;AAAA,IACA,WACE,SAAS,aACT;AAAA,IACF,SAAS;AAAA,IACT;AAAA,IACA,SAAS,SAAS,WAAW;AAAA,IAC7B,WAAU,oBAAI,KAAK,GAAE,YAAY;AAAA,EACnC;AACF;AAEO,SAAS,WACd,OACA,QACS;AACT,MAAI;AACF,UAAM,gBAAoC;AAAA,MACxC,SAAS;AAAA,QACP,GAAG,OAAO;AAAA,QACV,WACE,OAAO,QAAQ,qBAAqB,aAChC,OAAO,QAAQ,YACf,IAAI,WAAW,OAAO,QAAQ,SAAS;AAAA,QAC7C,QAAS,OAAO,QAAgB,UAAU,CAAC;AAAA,QAC3C,UAAW,OAAO,QAAgB,YAAY,CAAC;AAAA,MACjD;AAAA,MACA,WACE,OAAO,qBAAqB,aACxB,OAAO,YACP,IAAI,WAAW,OAAO,SAAS;AAAA,MACrC,eACE,OAAO,yBAAyB,aAC5B,OAAO,gBACP,IAAI,WAAW,OAAO,aAAa;AAAA,IAC3C;AACA,WAAO,aAAa,OAAO,aAAa;AAAA,EAC1C,SAAS,OAAO;AACd,YAAQ,MAAM,4BAA4B,KAAK;AAC/C,WAAO;AAAA,EACT;AACF;","names":[]}
|
package/dist/client.cjs
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/client.ts
|
|
21
|
+
var client_exports = {};
|
|
22
|
+
__export(client_exports, {
|
|
23
|
+
serializeOutput: () => serializeOutput,
|
|
24
|
+
siwsClient: () => siwsClient
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(client_exports);
|
|
27
|
+
|
|
28
|
+
// src/types.ts
|
|
29
|
+
function serializeOutput(output) {
|
|
30
|
+
return {
|
|
31
|
+
account: {
|
|
32
|
+
address: output.account.address,
|
|
33
|
+
publicKey: Array.from(output.account.publicKey)
|
|
34
|
+
},
|
|
35
|
+
signature: Array.from(output.signature),
|
|
36
|
+
signedMessage: Array.from(output.signedMessage),
|
|
37
|
+
signatureType: output.signatureType
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// src/client.ts
|
|
42
|
+
var siwsClient = () => {
|
|
43
|
+
return {
|
|
44
|
+
id: "siws",
|
|
45
|
+
$InferServerPlugin: {},
|
|
46
|
+
getActions: ($fetch) => ({
|
|
47
|
+
signIn: {
|
|
48
|
+
solana: async (params) => {
|
|
49
|
+
return $fetch("/siws/verify", {
|
|
50
|
+
method: "POST",
|
|
51
|
+
body: {
|
|
52
|
+
input: params.input,
|
|
53
|
+
output: params.output
|
|
54
|
+
},
|
|
55
|
+
...params.fetchOptions
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
solana: {
|
|
60
|
+
getNonce: async (params) => {
|
|
61
|
+
const res = await $fetch("/siws/nonce", {
|
|
62
|
+
method: "POST",
|
|
63
|
+
body: { walletAddress: params.walletAddress },
|
|
64
|
+
...params.fetchOptions
|
|
65
|
+
});
|
|
66
|
+
return res.data;
|
|
67
|
+
},
|
|
68
|
+
linkWallet: async (params) => {
|
|
69
|
+
return $fetch("/siws/link", {
|
|
70
|
+
method: "POST",
|
|
71
|
+
body: {
|
|
72
|
+
input: params.input,
|
|
73
|
+
output: params.output
|
|
74
|
+
},
|
|
75
|
+
...params.fetchOptions
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
unlinkWallet: async (params) => {
|
|
79
|
+
return $fetch("/siws/unlink", {
|
|
80
|
+
method: "POST",
|
|
81
|
+
body: { walletAddress: params.walletAddress },
|
|
82
|
+
...params.fetchOptions
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
getLinkedWallets: async (params) => {
|
|
86
|
+
return $fetch("/siws/wallets", {
|
|
87
|
+
method: "GET",
|
|
88
|
+
...params?.fetchOptions
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}),
|
|
93
|
+
atomListeners: [
|
|
94
|
+
{
|
|
95
|
+
matcher: (path) => path.startsWith("/siws/"),
|
|
96
|
+
signal: "$sessionSignal"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
102
|
+
0 && (module.exports = {
|
|
103
|
+
serializeOutput,
|
|
104
|
+
siwsClient
|
|
105
|
+
});
|
|
106
|
+
//# sourceMappingURL=client.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/types.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"@better-auth/core\";\nimport type { BetterFetch } from \"@better-fetch/fetch\";\nimport type { SolanaSignInInput } from \"@solana/wallet-standard-features\";\nimport type { SerializedSolanaOutput, SiwsNonceResponse } from \"./types\";\n\nexport type { SiwsNonceResponse, SerializedSolanaOutput };\nexport { serializeOutput } from \"./types\";\nexport type { SolanaSignInInput } from \"@solana/wallet-standard-features\";\n\nexport const siwsClient = () => {\n return {\n id: \"siws\",\n $InferServerPlugin: {} as ReturnType<typeof import(\"./index\").siws>,\n\n getActions: ($fetch: BetterFetch) => ({\n signIn: {\n solana: async (params: {\n input: SolanaSignInInput;\n output: SerializedSolanaOutput;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/verify\", {\n method: \"POST\",\n body: {\n input: params.input,\n output: params.output,\n },\n ...params.fetchOptions,\n });\n },\n },\n\n solana: {\n getNonce: async (params: {\n walletAddress: string;\n fetchOptions?: RequestInit;\n }): Promise<SiwsNonceResponse> => {\n const res = await $fetch(\"/siws/nonce\", {\n method: \"POST\",\n body: { walletAddress: params.walletAddress },\n ...params.fetchOptions,\n });\n return res.data as SiwsNonceResponse;\n },\n\n linkWallet: async (params: {\n input: SolanaSignInInput;\n output: SerializedSolanaOutput;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/link\", {\n method: \"POST\",\n body: {\n input: params.input,\n output: params.output,\n },\n ...params.fetchOptions,\n });\n },\n\n unlinkWallet: async (params: {\n walletAddress: string;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/unlink\", {\n method: \"POST\",\n body: { walletAddress: params.walletAddress },\n ...params.fetchOptions,\n });\n },\n\n getLinkedWallets: async (params?: {\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/wallets\", {\n method: \"GET\",\n ...params?.fetchOptions,\n });\n },\n },\n }),\n\n atomListeners: [\n {\n matcher: (path: string) => path.startsWith(\"/siws/\"),\n signal: \"$sessionSignal\",\n },\n ],\n } satisfies BetterAuthClientPlugin;\n};\n","import type { SolanaSignInInput, SolanaSignInOutput } from \"@solana/wallet-standard-features\";\n\nexport type { SolanaSignInInput, SolanaSignInOutput };\n\nexport interface SiwsPluginOptions {\n statement?: string;\n chainId?: string;\n nonceExpiryMs?: number;\n anonymous?: boolean;\n}\n\nexport interface SiwsNonceResponse {\n nonce: string;\n domain: string;\n uri: string;\n statement: string;\n chainId: string;\n issuedAt: string;\n}\n\nexport interface SiwsVerifyRequest {\n output: {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n };\n input: {\n domain: string;\n address?: string;\n statement?: string;\n uri?: string;\n version?: string;\n chainId?: string;\n nonce?: string;\n issuedAt?: string;\n expirationTime?: string;\n notBefore?: string;\n requestId?: string;\n resources?: string[];\n };\n}\n\nexport interface SiwsVerifyResponse {\n success: boolean;\n user: {\n id: string;\n name: string;\n email: string;\n };\n}\n\nexport interface SiwsLinkRequest {\n input: SolanaSignInInput;\n output: {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n };\n}\n\nexport interface SiwsLinkedWallet {\n walletAddress: string;\n createdAt: Date;\n}\n\nexport interface SerializedSolanaOutput {\n account: {\n address: string;\n publicKey: number[];\n };\n signature: number[];\n signedMessage: number[];\n signatureType?: string;\n}\n\nexport function serializeOutput(output: SolanaSignInOutput): SerializedSolanaOutput {\n return {\n account: {\n address: output.account.address,\n publicKey: Array.from(output.account.publicKey),\n },\n signature: Array.from(output.signature),\n signedMessage: Array.from(output.signedMessage),\n signatureType: (output as any).signatureType,\n };\n}\n\nexport function deserializeOutput(data: SerializedSolanaOutput): SolanaSignInOutput {\n return {\n account: {\n address: data.account.address,\n publicKey: new Uint8Array(data.account.publicKey),\n chains: [],\n features: [],\n },\n signature: new Uint8Array(data.signature),\n signedMessage: new Uint8Array(data.signedMessage),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiFO,SAAS,gBAAgB,QAAoD;AAClF,SAAO;AAAA,IACL,SAAS;AAAA,MACP,SAAS,OAAO,QAAQ;AAAA,MACxB,WAAW,MAAM,KAAK,OAAO,QAAQ,SAAS;AAAA,IAChD;AAAA,IACA,WAAW,MAAM,KAAK,OAAO,SAAS;AAAA,IACtC,eAAe,MAAM,KAAK,OAAO,aAAa;AAAA,IAC9C,eAAgB,OAAe;AAAA,EACjC;AACF;;;ADlFO,IAAM,aAAa,MAAM;AAC9B,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,oBAAoB,CAAC;AAAA,IAErB,YAAY,CAAC,YAAyB;AAAA,MACpC,QAAQ;AAAA,QACN,QAAQ,OAAO,WAIT;AACJ,iBAAO,OAAO,gBAAgB;AAAA,YAC5B,QAAQ;AAAA,YACR,MAAM;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,YACjB;AAAA,YACA,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF;AAAA,MAEA,QAAQ;AAAA,QACN,UAAU,OAAO,WAGiB;AAChC,gBAAM,MAAM,MAAM,OAAO,eAAe;AAAA,YACtC,QAAQ;AAAA,YACR,MAAM,EAAE,eAAe,OAAO,cAAc;AAAA,YAC5C,GAAG,OAAO;AAAA,UACZ,CAAC;AACD,iBAAO,IAAI;AAAA,QACb;AAAA,QAEA,YAAY,OAAO,WAIb;AACJ,iBAAO,OAAO,cAAc;AAAA,YAC1B,QAAQ;AAAA,YACR,MAAM;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,YACjB;AAAA,YACA,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,QAEA,cAAc,OAAO,WAGf;AACJ,iBAAO,OAAO,gBAAgB;AAAA,YAC5B,QAAQ;AAAA,YACR,MAAM,EAAE,eAAe,OAAO,cAAc;AAAA,YAC5C,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,QAEA,kBAAkB,OAAO,WAEnB;AACJ,iBAAO,OAAO,iBAAiB;AAAA,YAC7B,QAAQ;AAAA,YACR,GAAG,QAAQ;AAAA,UACb,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IAEA,eAAe;AAAA,MACb;AAAA,QACE,SAAS,CAAC,SAAiB,KAAK,WAAW,QAAQ;AAAA,QACnD,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { siws } from './index.cjs';
|
|
2
|
+
import { BetterFetch } from '@better-fetch/fetch';
|
|
3
|
+
import { SolanaSignInInput } from '@solana/wallet-standard-features';
|
|
4
|
+
export { SolanaSignInInput } from '@solana/wallet-standard-features';
|
|
5
|
+
import { S as SerializedSolanaOutput, a as SiwsNonceResponse } from './crypto-BQgenqov.cjs';
|
|
6
|
+
export { s as serializeOutput } from './crypto-BQgenqov.cjs';
|
|
7
|
+
import 'better-call';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
declare const siwsClient: () => {
|
|
11
|
+
id: "siws";
|
|
12
|
+
$InferServerPlugin: ReturnType<typeof siws>;
|
|
13
|
+
getActions: ($fetch: BetterFetch) => {
|
|
14
|
+
signIn: {
|
|
15
|
+
solana: (params: {
|
|
16
|
+
input: SolanaSignInInput;
|
|
17
|
+
output: SerializedSolanaOutput;
|
|
18
|
+
fetchOptions?: RequestInit;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
data: unknown;
|
|
21
|
+
error: null;
|
|
22
|
+
} | {
|
|
23
|
+
data: null;
|
|
24
|
+
error: {
|
|
25
|
+
message?: string | undefined;
|
|
26
|
+
status: number;
|
|
27
|
+
statusText: string;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
solana: {
|
|
32
|
+
getNonce: (params: {
|
|
33
|
+
walletAddress: string;
|
|
34
|
+
fetchOptions?: RequestInit;
|
|
35
|
+
}) => Promise<SiwsNonceResponse>;
|
|
36
|
+
linkWallet: (params: {
|
|
37
|
+
input: SolanaSignInInput;
|
|
38
|
+
output: SerializedSolanaOutput;
|
|
39
|
+
fetchOptions?: RequestInit;
|
|
40
|
+
}) => Promise<{
|
|
41
|
+
data: unknown;
|
|
42
|
+
error: null;
|
|
43
|
+
} | {
|
|
44
|
+
data: null;
|
|
45
|
+
error: {
|
|
46
|
+
message?: string | undefined;
|
|
47
|
+
status: number;
|
|
48
|
+
statusText: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
unlinkWallet: (params: {
|
|
52
|
+
walletAddress: string;
|
|
53
|
+
fetchOptions?: RequestInit;
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
data: unknown;
|
|
56
|
+
error: null;
|
|
57
|
+
} | {
|
|
58
|
+
data: null;
|
|
59
|
+
error: {
|
|
60
|
+
message?: string | undefined;
|
|
61
|
+
status: number;
|
|
62
|
+
statusText: string;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
getLinkedWallets: (params?: {
|
|
66
|
+
fetchOptions?: RequestInit;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
data: unknown;
|
|
69
|
+
error: null;
|
|
70
|
+
} | {
|
|
71
|
+
data: null;
|
|
72
|
+
error: {
|
|
73
|
+
message?: string | undefined;
|
|
74
|
+
status: number;
|
|
75
|
+
statusText: string;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
atomListeners: {
|
|
81
|
+
matcher: (path: string) => boolean;
|
|
82
|
+
signal: "$sessionSignal";
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { SerializedSolanaOutput, SiwsNonceResponse, siwsClient };
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { siws } from './index.js';
|
|
2
|
+
import { BetterFetch } from '@better-fetch/fetch';
|
|
3
|
+
import { SolanaSignInInput } from '@solana/wallet-standard-features';
|
|
4
|
+
export { SolanaSignInInput } from '@solana/wallet-standard-features';
|
|
5
|
+
import { S as SerializedSolanaOutput, a as SiwsNonceResponse } from './crypto-BQgenqov.js';
|
|
6
|
+
export { s as serializeOutput } from './crypto-BQgenqov.js';
|
|
7
|
+
import 'better-call';
|
|
8
|
+
import 'zod';
|
|
9
|
+
|
|
10
|
+
declare const siwsClient: () => {
|
|
11
|
+
id: "siws";
|
|
12
|
+
$InferServerPlugin: ReturnType<typeof siws>;
|
|
13
|
+
getActions: ($fetch: BetterFetch) => {
|
|
14
|
+
signIn: {
|
|
15
|
+
solana: (params: {
|
|
16
|
+
input: SolanaSignInInput;
|
|
17
|
+
output: SerializedSolanaOutput;
|
|
18
|
+
fetchOptions?: RequestInit;
|
|
19
|
+
}) => Promise<{
|
|
20
|
+
data: unknown;
|
|
21
|
+
error: null;
|
|
22
|
+
} | {
|
|
23
|
+
data: null;
|
|
24
|
+
error: {
|
|
25
|
+
message?: string | undefined;
|
|
26
|
+
status: number;
|
|
27
|
+
statusText: string;
|
|
28
|
+
};
|
|
29
|
+
}>;
|
|
30
|
+
};
|
|
31
|
+
solana: {
|
|
32
|
+
getNonce: (params: {
|
|
33
|
+
walletAddress: string;
|
|
34
|
+
fetchOptions?: RequestInit;
|
|
35
|
+
}) => Promise<SiwsNonceResponse>;
|
|
36
|
+
linkWallet: (params: {
|
|
37
|
+
input: SolanaSignInInput;
|
|
38
|
+
output: SerializedSolanaOutput;
|
|
39
|
+
fetchOptions?: RequestInit;
|
|
40
|
+
}) => Promise<{
|
|
41
|
+
data: unknown;
|
|
42
|
+
error: null;
|
|
43
|
+
} | {
|
|
44
|
+
data: null;
|
|
45
|
+
error: {
|
|
46
|
+
message?: string | undefined;
|
|
47
|
+
status: number;
|
|
48
|
+
statusText: string;
|
|
49
|
+
};
|
|
50
|
+
}>;
|
|
51
|
+
unlinkWallet: (params: {
|
|
52
|
+
walletAddress: string;
|
|
53
|
+
fetchOptions?: RequestInit;
|
|
54
|
+
}) => Promise<{
|
|
55
|
+
data: unknown;
|
|
56
|
+
error: null;
|
|
57
|
+
} | {
|
|
58
|
+
data: null;
|
|
59
|
+
error: {
|
|
60
|
+
message?: string | undefined;
|
|
61
|
+
status: number;
|
|
62
|
+
statusText: string;
|
|
63
|
+
};
|
|
64
|
+
}>;
|
|
65
|
+
getLinkedWallets: (params?: {
|
|
66
|
+
fetchOptions?: RequestInit;
|
|
67
|
+
}) => Promise<{
|
|
68
|
+
data: unknown;
|
|
69
|
+
error: null;
|
|
70
|
+
} | {
|
|
71
|
+
data: null;
|
|
72
|
+
error: {
|
|
73
|
+
message?: string | undefined;
|
|
74
|
+
status: number;
|
|
75
|
+
statusText: string;
|
|
76
|
+
};
|
|
77
|
+
}>;
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
atomListeners: {
|
|
81
|
+
matcher: (path: string) => boolean;
|
|
82
|
+
signal: "$sessionSignal";
|
|
83
|
+
}[];
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export { SerializedSolanaOutput, SiwsNonceResponse, siwsClient };
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
serializeOutput
|
|
3
|
+
} from "./chunk-AUDIM6MZ.js";
|
|
4
|
+
|
|
5
|
+
// src/client.ts
|
|
6
|
+
var siwsClient = () => {
|
|
7
|
+
return {
|
|
8
|
+
id: "siws",
|
|
9
|
+
$InferServerPlugin: {},
|
|
10
|
+
getActions: ($fetch) => ({
|
|
11
|
+
signIn: {
|
|
12
|
+
solana: async (params) => {
|
|
13
|
+
return $fetch("/siws/verify", {
|
|
14
|
+
method: "POST",
|
|
15
|
+
body: {
|
|
16
|
+
input: params.input,
|
|
17
|
+
output: params.output
|
|
18
|
+
},
|
|
19
|
+
...params.fetchOptions
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
solana: {
|
|
24
|
+
getNonce: async (params) => {
|
|
25
|
+
const res = await $fetch("/siws/nonce", {
|
|
26
|
+
method: "POST",
|
|
27
|
+
body: { walletAddress: params.walletAddress },
|
|
28
|
+
...params.fetchOptions
|
|
29
|
+
});
|
|
30
|
+
return res.data;
|
|
31
|
+
},
|
|
32
|
+
linkWallet: async (params) => {
|
|
33
|
+
return $fetch("/siws/link", {
|
|
34
|
+
method: "POST",
|
|
35
|
+
body: {
|
|
36
|
+
input: params.input,
|
|
37
|
+
output: params.output
|
|
38
|
+
},
|
|
39
|
+
...params.fetchOptions
|
|
40
|
+
});
|
|
41
|
+
},
|
|
42
|
+
unlinkWallet: async (params) => {
|
|
43
|
+
return $fetch("/siws/unlink", {
|
|
44
|
+
method: "POST",
|
|
45
|
+
body: { walletAddress: params.walletAddress },
|
|
46
|
+
...params.fetchOptions
|
|
47
|
+
});
|
|
48
|
+
},
|
|
49
|
+
getLinkedWallets: async (params) => {
|
|
50
|
+
return $fetch("/siws/wallets", {
|
|
51
|
+
method: "GET",
|
|
52
|
+
...params?.fetchOptions
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}),
|
|
57
|
+
atomListeners: [
|
|
58
|
+
{
|
|
59
|
+
matcher: (path) => path.startsWith("/siws/"),
|
|
60
|
+
signal: "$sessionSignal"
|
|
61
|
+
}
|
|
62
|
+
]
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
serializeOutput,
|
|
67
|
+
siwsClient
|
|
68
|
+
};
|
|
69
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/client.ts"],"sourcesContent":["import type { BetterAuthClientPlugin } from \"@better-auth/core\";\nimport type { BetterFetch } from \"@better-fetch/fetch\";\nimport type { SolanaSignInInput } from \"@solana/wallet-standard-features\";\nimport type { SerializedSolanaOutput, SiwsNonceResponse } from \"./types\";\n\nexport type { SiwsNonceResponse, SerializedSolanaOutput };\nexport { serializeOutput } from \"./types\";\nexport type { SolanaSignInInput } from \"@solana/wallet-standard-features\";\n\nexport const siwsClient = () => {\n return {\n id: \"siws\",\n $InferServerPlugin: {} as ReturnType<typeof import(\"./index\").siws>,\n\n getActions: ($fetch: BetterFetch) => ({\n signIn: {\n solana: async (params: {\n input: SolanaSignInInput;\n output: SerializedSolanaOutput;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/verify\", {\n method: \"POST\",\n body: {\n input: params.input,\n output: params.output,\n },\n ...params.fetchOptions,\n });\n },\n },\n\n solana: {\n getNonce: async (params: {\n walletAddress: string;\n fetchOptions?: RequestInit;\n }): Promise<SiwsNonceResponse> => {\n const res = await $fetch(\"/siws/nonce\", {\n method: \"POST\",\n body: { walletAddress: params.walletAddress },\n ...params.fetchOptions,\n });\n return res.data as SiwsNonceResponse;\n },\n\n linkWallet: async (params: {\n input: SolanaSignInInput;\n output: SerializedSolanaOutput;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/link\", {\n method: \"POST\",\n body: {\n input: params.input,\n output: params.output,\n },\n ...params.fetchOptions,\n });\n },\n\n unlinkWallet: async (params: {\n walletAddress: string;\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/unlink\", {\n method: \"POST\",\n body: { walletAddress: params.walletAddress },\n ...params.fetchOptions,\n });\n },\n\n getLinkedWallets: async (params?: {\n fetchOptions?: RequestInit;\n }) => {\n return $fetch(\"/siws/wallets\", {\n method: \"GET\",\n ...params?.fetchOptions,\n });\n },\n },\n }),\n\n atomListeners: [\n {\n matcher: (path: string) => path.startsWith(\"/siws/\"),\n signal: \"$sessionSignal\",\n },\n ],\n } satisfies BetterAuthClientPlugin;\n};\n"],"mappings":";;;;;AASO,IAAM,aAAa,MAAM;AAC9B,SAAO;AAAA,IACL,IAAI;AAAA,IACJ,oBAAoB,CAAC;AAAA,IAErB,YAAY,CAAC,YAAyB;AAAA,MACpC,QAAQ;AAAA,QACN,QAAQ,OAAO,WAIT;AACJ,iBAAO,OAAO,gBAAgB;AAAA,YAC5B,QAAQ;AAAA,YACR,MAAM;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,YACjB;AAAA,YACA,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,MACF;AAAA,MAEA,QAAQ;AAAA,QACN,UAAU,OAAO,WAGiB;AAChC,gBAAM,MAAM,MAAM,OAAO,eAAe;AAAA,YACtC,QAAQ;AAAA,YACR,MAAM,EAAE,eAAe,OAAO,cAAc;AAAA,YAC5C,GAAG,OAAO;AAAA,UACZ,CAAC;AACD,iBAAO,IAAI;AAAA,QACb;AAAA,QAEA,YAAY,OAAO,WAIb;AACJ,iBAAO,OAAO,cAAc;AAAA,YAC1B,QAAQ;AAAA,YACR,MAAM;AAAA,cACJ,OAAO,OAAO;AAAA,cACd,QAAQ,OAAO;AAAA,YACjB;AAAA,YACA,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,QAEA,cAAc,OAAO,WAGf;AACJ,iBAAO,OAAO,gBAAgB;AAAA,YAC5B,QAAQ;AAAA,YACR,MAAM,EAAE,eAAe,OAAO,cAAc;AAAA,YAC5C,GAAG,OAAO;AAAA,UACZ,CAAC;AAAA,QACH;AAAA,QAEA,kBAAkB,OAAO,WAEnB;AACJ,iBAAO,OAAO,iBAAiB;AAAA,YAC7B,QAAQ;AAAA,YACR,GAAG,QAAQ;AAAA,UACb,CAAC;AAAA,QACH;AAAA,MACF;AAAA,IACF;AAAA,IAEA,eAAe;AAAA,MACb;AAAA,QACE,SAAS,CAAC,SAAiB,KAAK,WAAW,QAAQ;AAAA,QACnD,QAAQ;AAAA,MACV;AAAA,IACF;AAAA,EACF;AACF;","names":[]}
|