better-near-auth 1.10.0 → 1.10.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +51 -60
- package/dist/client.js +11 -0
- package/dist/client.js.map +1 -1
- package/dist/index.d.ts +18 -29
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -33
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +26 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/client/SKILL.md +1 -1
- package/skills/relay/SKILL.md +40 -78
- package/skills/siwn/SKILL.md +1 -1
- package/skills/tanstack/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -51,38 +51,36 @@ npm install better-near-auth
|
|
|
51
51
|
});
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
```
|
|
54
|
+
**Relayer Configuration Options:**
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
// Ephemeral mode - omit accountId to auto-generate a keypair on first startup
|
|
58
|
+
relayer: {
|
|
59
|
+
whitelistedContracts: ["myapp.near"],
|
|
60
|
+
maxGasPerTransaction: "300000000000000",
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Explicit mode - provide accountId and privateKey
|
|
64
|
+
relayer: {
|
|
65
|
+
accountId: "relayer.myapp.near",
|
|
66
|
+
privateKey: process.env.RELAYER_PRIVATE_KEY,
|
|
67
|
+
whitelistedContracts: ["myapp.near"],
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// Per-network configuration
|
|
71
|
+
relayer: {
|
|
72
|
+
mainnet: {
|
|
73
|
+
accountId: "relayer.myapp.near",
|
|
74
|
+
privateKey: process.env.RELAYER_PRIVATE_KEY_MAINNET,
|
|
75
|
+
},
|
|
76
|
+
testnet: {
|
|
77
|
+
accountId: "relayer.myapp.testnet",
|
|
78
|
+
privateKey: process.env.RELAYER_PRIVATE_KEY_TESTNET,
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
If `accountId` is set but no `privateKey` is provided, the SIWN plugin logs a warning and falls back to ephemeral mode.
|
|
86
84
|
|
|
87
85
|
3. Generate the schema to add the necessary fields and tables to the database.
|
|
88
86
|
|
|
@@ -214,42 +212,30 @@ await authClient.near.disconnect();
|
|
|
214
212
|
|
|
215
213
|
#### Relayer Configuration
|
|
216
214
|
|
|
217
|
-
The relayer
|
|
218
|
-
|
|
219
|
-
| Value | Mode | Description |
|
|
220
|
-
|---|---|---|
|
|
221
|
-
| `true` | Ephemeral | Auto-generated ED25519 keypair (default) |
|
|
222
|
-
| `RelayerEphemeralConfig` | Ephemeral | Ephemeral with custom settings |
|
|
223
|
-
| `RelayerExplicitConfig` | Explicit | Bring your own key |
|
|
224
|
-
| `RelayerDualNetworkConfig` | Mixed | Per-network configuration |
|
|
225
|
-
|
|
226
|
-
**Ephemeral Config (`RelayerEphemeralConfig`):**
|
|
215
|
+
The relayer takes a single flat object (`RelayerConfig`) — `accountId` is the only runtime discriminator. If `accountId` is set, the relayer runs in explicit mode using the resolved `privateKey`. Otherwise, an ED25519 keypair is generated on first startup (ephemeral mode).
|
|
227
216
|
|
|
228
217
|
| Option | Type | Default | Description |
|
|
229
218
|
|---|---|---|---|
|
|
219
|
+
| `accountId` | `string` | — | Named relayer account. If set, the relayer runs in explicit mode using `privateKey`. |
|
|
220
|
+
| `privateKey` | `string` | — | Base64 / ed25519-format private key. Only used in explicit mode (`accountId` set). |
|
|
230
221
|
| `whitelistedContracts` | `string[]` | — | Restrict relay to these contracts |
|
|
231
222
|
| `maxGasPerTransaction` | `string` | — | Max gas per relayed tx |
|
|
232
223
|
| `maxDepositPerTransaction` | `string` | — | Max deposit per relayed tx |
|
|
233
224
|
|
|
234
|
-
|
|
225
|
+
To configure mainnet and testnet independently, pass a `RelayerDualNetworkConfig`:
|
|
235
226
|
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
**Dual Network Config (`RelayerDualNetworkConfig`):**
|
|
227
|
+
```ts
|
|
228
|
+
siwn({
|
|
229
|
+
relayer: {
|
|
230
|
+
mainnet: { accountId: "relayer.near" },
|
|
231
|
+
testnet: { accountId: "relayer.testnet" },
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
```
|
|
246
235
|
|
|
247
|
-
|
|
248
|
-
|---|---|---|---|
|
|
249
|
-
| `mainnet` | `RelayerEphemeralConfig \| RelayerExplicitConfig` | — | Mainnet relayer config |
|
|
250
|
-
| `testnet` | `RelayerEphemeralConfig \| RelayerExplicitConfig` | — | Testnet relayer config |
|
|
236
|
+
When `accountId` is not set, an ED25519 keypair is generated on first startup, the implicit account ID is derived from the public key, and the private key is encrypted with AES-256-GCM (using `BETTER_AUTH_SECRET` as KEK via HKDF-SHA256) and stored in the database. The same keypair is recovered on restart.
|
|
251
237
|
|
|
252
|
-
|
|
238
|
+
If `accountId` is set but no `privateKey` is provided, the SIWN plugin logs a warning and falls back to ephemeral mode.
|
|
253
239
|
|
|
254
240
|
### Client Options
|
|
255
241
|
|
|
@@ -393,7 +379,7 @@ export const auth = betterAuth({
|
|
|
393
379
|
// Ephemeral mode (simplest)
|
|
394
380
|
relayer: true,
|
|
395
381
|
|
|
396
|
-
// OR explicit mode
|
|
382
|
+
// OR explicit mode (privateKey provided directly)
|
|
397
383
|
relayer: {
|
|
398
384
|
accountId: "relayer.myapp.near",
|
|
399
385
|
privateKey: process.env.RELAYER_PRIVATE_KEY,
|
|
@@ -405,9 +391,13 @@ export const auth = betterAuth({
|
|
|
405
391
|
// OR per-network configuration
|
|
406
392
|
relayer: {
|
|
407
393
|
mainnet: {
|
|
394
|
+
accountId: "relayer.myapp.near",
|
|
395
|
+
privateKey: process.env.RELAYER_PRIVATE_KEY_MAINNET,
|
|
408
396
|
whitelistedContracts: ["myapp.near"],
|
|
409
397
|
},
|
|
410
398
|
testnet: {
|
|
399
|
+
accountId: "relayer.myapp.testnet",
|
|
400
|
+
privateKey: process.env.RELAYER_PRIVATE_KEY_TESTNET,
|
|
411
401
|
whitelistedContracts: ["myapp.testnet"],
|
|
412
402
|
maxGasPerTransaction: "100000000000000",
|
|
413
403
|
},
|
|
@@ -452,8 +442,9 @@ The plugin detects the network from the account ID:
|
|
|
452
442
|
| Relay fails with "insufficient balance" | Fund the relayer account with NEAR |
|
|
453
443
|
| Relay fails with "contract not whitelisted" | Add `receiverId` to `whitelistedContracts` |
|
|
454
444
|
| Relayer not initializing (ephemeral mode) | Ensure `BETTER_AUTH_SECRET` is set; check startup logs for `[siwn] Relayer initialized` |
|
|
455
|
-
| Empty `relayer_key` table | Relayer config not being passed;
|
|
445
|
+
| Empty `relayer_key` table | Relayer config not being passed; omit `accountId` to use ephemeral mode |
|
|
456
446
|
| "BETTER_AUTH_SECRET required" error | Required for ephemeral mode encryption; generate a secure random string |
|
|
447
|
+
| `accountId` set but mode shows `ephemeral` | Your `privateKey` was not passed to the SIWN plugin — provide it directly or via the host's per-network private key secret |
|
|
457
448
|
|
|
458
449
|
## Examples
|
|
459
450
|
|
package/dist/client.js
CHANGED
|
@@ -117,6 +117,17 @@ const RelayedTransactionSchema = z.object({
|
|
|
117
117
|
updatedAt: z.string().optional()
|
|
118
118
|
});
|
|
119
119
|
z.object({ transactions: z.array(RelayedTransactionSchema) });
|
|
120
|
+
const relayerConfigSchema = z.object({
|
|
121
|
+
accountId: z.string().optional(),
|
|
122
|
+
privateKey: z.string().optional(),
|
|
123
|
+
whitelistedContracts: z.array(z.string()).optional(),
|
|
124
|
+
maxGasPerTransaction: z.string().regex(/^\d+$/, "must be a non-negative integer string of gas units").optional(),
|
|
125
|
+
maxDepositPerTransaction: z.string().regex(/^\d+$/, "must be a non-negative integer string of yoctoNEAR").optional()
|
|
126
|
+
}).strict();
|
|
127
|
+
z.object({
|
|
128
|
+
mainnet: relayerConfigSchema.optional(),
|
|
129
|
+
testnet: relayerConfigSchema.optional()
|
|
130
|
+
}).strict();
|
|
120
131
|
z.object({ network: z.enum(["mainnet", "testnet"]).optional() });
|
|
121
132
|
const SUB_ACCOUNT_LABEL_REGEX = /^([a-z\d]+[-_])*[a-z\d]+$/;
|
|
122
133
|
const SubAccountNameSchema = z.string().min(2, "Sub-account name must be at least 2 characters").max(64, "Sub-account name must be at most 64 characters").regex(SUB_ACCOUNT_LABEL_REGEX, "Sub-account name must contain only lowercase alphanumeric characters, hyphens, and underscores (no leading/trailing hyphens or underscores)");
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":[],"sources":["../src/types.ts","../src/client.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AccountIdSchema, type AccountId } from \"near-kit/schemas\";\nimport type { AccountState, Near, TransactionBuilder } from \"near-kit\";\n\nexport type { AccountId };\n\nexport interface NearAccount {\n\tid: string;\n\tuserId: string;\n\taccountId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tpublicKey: string;\n\tisPrimary: boolean;\n\tcreatedAt: Date;\n}\n\nexport interface ListedNearAccount extends NearAccount {\n\tproviderId: \"siwn\";\n\tisActive: boolean;\n\tisAvailable: boolean;\n}\n\nexport interface ListAccountsResponseT {\n\taccounts: ListedNearAccount[];\n\tactiveAccount: ListedNearAccount | null;\n\tavailableAccounts: ListedNearAccount[];\n}\n\nexport interface SetPrimaryAccountResponseT extends ListAccountsResponseT {\n\tsuccess: boolean;\n\taccountId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tmessage: string;\n}\n\nexport const socialImageSchema = z.object({\n\turl: z.string().optional(),\n\tipfs_cid: z.string().optional(),\n});\n\nexport const profileSchema = z.object({\n\tname: z.string().optional(),\n\tdescription: z.string().optional(),\n\timage: socialImageSchema.optional(),\n\tbackgroundImage: socialImageSchema.optional(),\n\tlinktree: z.record(z.string(), z.string()).optional(),\n});\n\nexport type SocialImage = z.infer<typeof socialImageSchema>;\nexport type Profile = z.infer<typeof profileSchema>;\n\nconst signedMessageSchema = z.object({\n\taccountId: z.string(),\n\tpublicKey: z.string(),\n\tsignature: z.string(),\n\tstate: z.string().optional(),\n});\n\nexport const LinkAccountRequest = z.object({\n\tsignedMessage: signedMessageSchema,\n\tmessage: z.string(),\n\trecipient: z.string(),\n\tnonce: z.string(),\n\taccountId: AccountIdSchema,\n\tcallbackUrl: z.string().optional(),\n});\n\nexport const SetPrimaryAccountRequest = z.object({\n\taccountId: AccountIdSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\n\nexport const NonceRequest = z.object({\n\taccountId: AccountIdSchema,\n\tnetworkId: z.union([z.literal(\"mainnet\"), z.literal(\"testnet\")])\n});\n\nexport const VerifyRequest = z.object({\n\tsignedMessage: signedMessageSchema,\n\tmessage: z.string(),\n\trecipient: z.string(),\n\tnonce: z.string(),\n\taccountId: AccountIdSchema,\n\tcallbackUrl: z.string().optional(),\n});\n\nexport const RelayRequest = z.object({\n\tpayload: z.string(),\n});\nexport type RelayRequestT = z.infer<typeof RelayRequest>;\n\nexport const RelayResponse = z.object({\n\ttxHash: z.string(),\n\tstatus: z.enum([\"pending\", \"completed\", \"failed\"]),\n});\nexport type RelayResponseT = z.infer<typeof RelayResponse>;\n\nexport const RelayStatusResponse = z.object({\n\tstatus: z.enum([\"pending\", \"completed\", \"failed\"]),\n\tgasUsed: z.string().optional(),\n\toutcome: z.unknown().optional(),\n});\nexport type RelayStatusResponseT = z.infer<typeof RelayStatusResponse>;\n\nexport const ViewContractRequest = z.object({\n\tcontractId: z.string(),\n\tmethodName: z.string(),\n\targs: z.record(z.string(), z.any()).optional(),\n});\nexport type ViewContractRequestT = z.infer<typeof ViewContractRequest>;\n\nexport const NonceResponse = z.object({ nonce: z.string() });\nexport const VerifyResponse = z.object({\n\ttoken: z.string(),\n\tsuccess: z.literal(true),\n\tuser: z.object({\n\t\tid: z.string(),\n\t\taccountId: AccountIdSchema,\n\t\tnetwork: z.union([z.literal(\"mainnet\"), z.literal(\"testnet\")]),\n\t}),\n});\nexport const ProfileResponse = profileSchema.nullable();\nexport const ViewContractResponse = z.object({ result: z.unknown() });\n\nexport const ProfileRequest = z.object({\n\taccountId: AccountIdSchema.optional(),\n});\nexport type ProfileRequestT = z.infer<typeof ProfileRequest>;\n\nexport type NonceRequestT = z.infer<typeof NonceRequest>;\nexport type NonceResponseT = z.infer<typeof NonceResponse>;\nexport type SetPrimaryAccountRequestT = z.infer<typeof SetPrimaryAccountRequest>;\nexport type VerifyRequestT = z.infer<typeof VerifyRequest>;\nexport type VerifyResponseT = z.infer<typeof VerifyResponse>;\nexport type ProfileResponseT = z.infer<typeof ProfileResponse>;\nexport type ViewContractResponseT = z.infer<typeof ViewContractResponse>;\n\nexport const RelayedTransactionSchema = z.object({\n\tid: z.string(),\n\tuserId: z.string(),\n\ttxHash: z.string(),\n\tsenderId: z.string(),\n\treceiverId: z.string(),\n\tnetwork: z.string(),\n\tstatus: z.string(),\n\tgasUsed: z.string().optional(),\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string().optional(),\n});\nexport type RelayedTransactionT = z.infer<typeof RelayedTransactionSchema>;\n\nexport const RelayHistoryResponse = z.object({\n\ttransactions: z.array(RelayedTransactionSchema),\n});\nexport type RelayHistoryResponseT = z.infer<typeof RelayHistoryResponse>;\n\nexport interface RelayedTransactionRecord {\n\tid: string;\n\tuserId: string;\n\ttxHash: string;\n\tsenderId: string;\n\treceiverId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tstatus: string;\n\tgasUsed?: string;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n}\n\nexport interface RelayerInfo extends AccountState {\n\taccountId: string;\n\tmode: \"ephemeral\" | \"explicit\";\n\tnetwork: \"mainnet\" | \"testnet\";\n\tpublicKey: string;\n\thasKey: boolean;\n\tcreatedAt?: Date;\n\tlastUsedAt?: Date;\n\tparentAccount?: string;\n\tsubAccountAvailable?: boolean;\n}\n\nexport interface DualNetworkConfig<T> {\n\tmainnet: T;\n\ttestnet: T;\n}\n\nexport const GetRelayerInfoRequest = z.object({\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\nexport type GetRelayerInfoRequestT = z.infer<typeof GetRelayerInfoRequest>;\n\nexport interface SubAccountRelayerFCAKConfig {\n\treceiverId: string;\n\tmethodNames?: string[];\n\tallowance?: string;\n}\n\nexport interface SubAccountTxCtx {\n\tnewAccountId: string;\n\tparentAccount: string;\n\tuserPublicKey: string;\n\tuserAccountId: string;\n\tuserId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n}\n\nexport interface SubAccountLifecycleCtx extends SubAccountTxCtx {\n\tnear: Near;\n}\n\nexport interface SubAccountConfig {\n\tparentAccount?: string;\n\tminDeposit?: string;\n\tparentHasFullAccess?: boolean;\n\tdeploy?:\n\t\t| { wasm: Uint8Array }\n\t\t| { fromPublished: { accountId?: string; codeHash?: string } };\n\tinit?: {\n\t\tmethodName: string;\n\t\targs: object | ((ctx: SubAccountTxCtx) => object);\n\t};\n\textendTx?: (tx: TransactionBuilder, ctx: SubAccountTxCtx) => TransactionBuilder;\n\tonCreated?: (ctx: SubAccountLifecycleCtx) => Promise<void>;\n\tonRollback?: (ctx: SubAccountLifecycleCtx) => Promise<void>;\n\taddRelayerFCAK?: boolean;\n\trelayerFCAK?: SubAccountRelayerFCAKConfig;\n}\n\nexport const SUB_ACCOUNT_LABEL_REGEX = /^([a-z\\d]+[-_])*[a-z\\d]+$/;\n\nexport const SubAccountNameSchema = z\n\t.string()\n\t.min(2, \"Sub-account name must be at least 2 characters\")\n\t.max(64, \"Sub-account name must be at most 64 characters\")\n\t.regex(SUB_ACCOUNT_LABEL_REGEX, \"Sub-account name must contain only lowercase alphanumeric characters, hyphens, and underscores (no leading/trailing hyphens or underscores)\");\n\nexport const CreateSubAccountRequest = z.object({\n\tsubAccountName: SubAccountNameSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tpublicKey: z.string(),\n});\nexport type CreateSubAccountRequestT = z.infer<typeof CreateSubAccountRequest>;\n\nexport const CreateSubAccountResponse = z.object({\n\tsuccess: z.literal(true),\n\taccountId: z.string(),\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]),\n\tpublicKey: z.string(),\n\tmessage: z.string(),\n});\nexport type CreateSubAccountResponseT = z.infer<typeof CreateSubAccountResponse>;\n\nexport const CheckSubAccountAvailabilityRequest = z.object({\n\tsubAccountName: SubAccountNameSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\nexport type CheckSubAccountAvailabilityRequestT = z.infer<typeof CheckSubAccountAvailabilityRequest>;\n\nexport const CheckSubAccountAvailabilityResponse = z.object({\n\tavailable: z.boolean(),\n\taccountId: z.string(),\n\tparentAccount: z.string().optional(),\n\treason: z.enum([\"taken\", \"invalid\", \"too-long\", \"not-configured\"]).optional(),\n});\nexport type CheckSubAccountAvailabilityResponseT = z.infer<typeof CheckSubAccountAvailabilityResponse>;\n","import { Near, fromNearConnect, generateNonce, TransactionBuilder } from \"near-kit\";\nimport type { Near as NearType, SignedMessage } from \"near-kit\";\nimport type { EventMap } from \"@hot-labs/near-connect\";\nimport { hex } from \"@scure/base\";\nimport type { BetterFetch, BetterFetchOption, BetterFetchResponse, ClientStore } from \"better-auth/client\";\nimport { atom } from \"nanostores\";\nimport { type AccountId, type DualNetworkConfig, type NonceRequestT, type NonceResponseT, type ProfileResponseT, type VerifyRequestT, type VerifyResponseT, type RelayResponseT, type RelayStatusResponseT, type NearAccount, type ListAccountsResponseT, type SetPrimaryAccountRequestT, type SetPrimaryAccountResponseT, type ViewContractRequestT, type ViewContractResponseT, type RelayerInfo, type RelayHistoryResponseT, type GetRelayerInfoRequestT, type CreateSubAccountRequestT, type CreateSubAccountResponseT, type CheckSubAccountAvailabilityRequestT, type CheckSubAccountAvailabilityResponseT, SUB_ACCOUNT_LABEL_REGEX } from \"./types.js\";\n\nexport interface AuthCallbacks {\n\tonSuccess?: () => void;\n\tonError?: (error: Error & { status?: number; code?: string }) => void;\n}\n\nexport interface SIWNClientConfig {\n\trecipient?: string;\n\trecipients?: DualNetworkConfig<string>;\n\tnetworkId?: \"mainnet\" | \"testnet\";\n\tcspNonce?: string;\n}\n\ninterface SignWithWalletResult {\n\tsignedMessage: SignedMessage;\n\taccountId: string;\n\tpublicKey: string;\n\tnonceHex: string;\n}\n\nexport interface SIWNClientActions {\n\tnear: {\n\t\tnonce: (params: NonceRequestT) => Promise<BetterFetchResponse<NonceResponseT>>;\n\t\tverify: (params: VerifyRequestT) => Promise<BetterFetchResponse<VerifyResponseT>>;\n\t\tgetProfile: (accountId?: AccountId) => Promise<BetterFetchResponse<ProfileResponseT>>;\n\t\tview: (params: ViewContractRequestT) => Promise<BetterFetchResponse<ViewContractResponseT>>;\n\t\tgetAccountId: () => string | null;\n\t\tgetState: () => { accountId: string | null; publicKey: string | null; networkId: string } | null;\n\t\tisWalletConnected: () => boolean;\n\t\tdetectNearAccount: () => Promise<{ accountId: string; publicKey: string | null; networkId: string } | null>;\n\t\tensureConnected: () => Promise<boolean>;\n\t\tdisconnect: () => Promise<void>;\n\t\tlink: (callbacks?: AuthCallbacks) => Promise<void>;\n\t\tunlink: (params: { accountId: string; network?: \"mainnet\" | \"testnet\" }) => Promise<BetterFetchResponse<{ success: boolean; message: string }>>;\n\t\tlistAccounts: () => Promise<BetterFetchResponse<ListAccountsResponseT>>;\n\t\tsetPrimaryAccount: (params: SetPrimaryAccountRequestT) => Promise<BetterFetchResponse<SetPrimaryAccountResponseT>>;\n\t\tbuildSignedDelegateAction: (receiverId: string, buildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder) => Promise<string>;\n\t\trelayTransaction: (params: { payload: string }) => Promise<BetterFetchResponse<RelayResponseT>>;\n\t\tgetRelayStatus: (txHash: string) => Promise<BetterFetchResponse<RelayStatusResponseT>>;\n\t\tgetRelayerInfo: (params?: GetRelayerInfoRequestT) => Promise<BetterFetchResponse<RelayerInfo & { enabled: boolean }>>;\n\t\trelayHistory: () => Promise<BetterFetchResponse<RelayHistoryResponseT>>;\n\t\tcreateSubAccount: (params: CreateSubAccountRequestT) => Promise<BetterFetchResponse<CreateSubAccountResponseT>>;\n\t\tcheckSubAccountAvailability: (params: CheckSubAccountAvailabilityRequestT) => Promise<BetterFetchResponse<CheckSubAccountAvailabilityResponseT>>;\n\t\tsetNetwork: (network: \"mainnet\" | \"testnet\") => void;\n\t\tgetNetwork: () => \"mainnet\" | \"testnet\";\n\t\tgetSupportedNetworks: () => (\"mainnet\" | \"testnet\")[];\n\t\tgetRecipient: (network?: \"mainnet\" | \"testnet\") => string;\n\t\tgetNearClient: () => NearType;\n\t};\n\tsignIn: {\n\t\tnear: (callbacks?: AuthCallbacks) => Promise<void>;\n\t};\n}\n\ntype NearState = { accountId: string | null; publicKey: string | null; networkId: string } | null;\n\nexport const siwnClient = (config: SIWNClientConfig) => {\n\tconst nearState = atom<NearState>(null);\n\tconst walletConnected = atom<boolean>(false);\n\tconst activeNetwork = atom<\"mainnet\" | \"testnet\">(config.networkId || \"mainnet\");\n\n\tconst getRecipient = (network?: \"mainnet\" | \"testnet\"): string => {\n\t\tconst net = network || activeNetwork.get();\n\t\tif (config.recipients) return config.recipients[net];\n\t\treturn config.recipient ?? \"\";\n\t};\n\n\tconst getSupportedNetworks = (): (\"mainnet\" | \"testnet\")[] => {\n\t\tif (config.recipients) return [\"mainnet\", \"testnet\"];\n\t\tif (config.recipient) return [config.recipient.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\"];\n\t\treturn [\"mainnet\"];\n\t};\n\n\tlet connectors = new Map<\"mainnet\" | \"testnet\", InstanceType<typeof import(\"@hot-labs/near-connect\").NearConnector>>();\n\tlet nearClients = new Map<\"mainnet\" | \"testnet\", Near>();\n\tlet initializedNetworks = new Set<\"mainnet\" | \"testnet\">();\n\tlet connectorModulePromise: Promise<typeof import(\"@hot-labs/near-connect\")> | null = null;\n\tlet initPromises = new Map<\"mainnet\" | \"testnet\", Promise<boolean>>();\n\n\tconst loadConnector = async () => {\n\t\tconnectorModulePromise ??= import(\"@hot-labs/near-connect\");\n\t\tconst { NearConnector } = await connectorModulePromise;\n\t\treturn NearConnector;\n\t};\n\n\tconst handleAccountConnection = async (accountId: string, publicKey?: string | null, network?: \"mainnet\" | \"testnet\") => {\n\t\tif (!accountId) return;\n\t\tconst net = network || activeNetwork.get();\n\t\tnearState.set({\n\t\t\taccountId,\n\t\t\tpublicKey: publicKey || null,\n\t\t\tnetworkId: net,\n\t\t});\n\t\twalletConnected.set(true);\n\t};\n\n\tconst initClientForNetwork = async (network: \"mainnet\" | \"testnet\", $fetch?: BetterFetch): Promise<boolean> => {\n\t\tif (initializedNetworks.has(network)) return true;\n\t\tif (initPromises.has(network)) return initPromises.get(network)!;\n\t\tif (typeof (globalThis as any).window === \"undefined\") return false;\n\n\t\tconst initPromise = (async () => {\n\t\t\tconst NearConnector = await loadConnector();\n\t\t\tconst connector = new NearConnector({ network, cspNonce: config.cspNonce });\n\t\t\tconnectors.set(network, connector);\n\n\t\t\tconst near = new Near({\n\t\t\t\tnetwork,\n\t\t\t\twallet: fromNearConnect(connector),\n\t\t\t});\n\t\t\tnearClients.set(network, near);\n\n\t\t\tconnector.on(\"wallet:signIn\", async (data: EventMap[\"wallet:signIn\"]) => {\n\t\t\t\tconst accountId = data.accounts?.[0]?.accountId;\n\t\t\t\tconst publicKey = data.accounts?.[0]?.publicKey;\n\t\t\t\tif (accountId) {\n\t\t\t\t\tawait handleAccountConnection(accountId, publicKey, network);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconnector.on(\"wallet:signOut\", () => {\n\t\t\t\twalletConnected.set(false);\n\t\t\t\tconst state = nearState.get();\n\t\t\t\tif (state) {\n\t\t\t\t\tnearState.set({ accountId: state.accountId, publicKey: null, networkId: state.networkId });\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tvoid connector.getConnectedWallet().then(({ accounts }) => {\n\t\t\t\tconst account = accounts?.[0];\n\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\tif (account?.accountId && !nearState.get()) {\n\t\t\t\t\tnearState.set({\n\t\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\t\tpublicKey: account.publicKey ?? null,\n\t\t\t\t\t\tnetworkId: net,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (account?.accountId) {\n\t\t\t\t\twalletConnected.set(true);\n\t\t\t\t}\n\t\t\t}).catch(() => {});\n\n\t\t\tinitializedNetworks.add(network);\n\n\t\t\tif ($fetch) {\n\t\t\t\tvoid restoreFromSession($fetch);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tinitPromises.set(network, initPromise);\n\n\t\ttry {\n\t\t\treturn await initPromise;\n\t\t} finally {\n\t\t\tinitPromises.delete(network);\n\t\t}\n\t};\n\n\tconst initClient = async ($fetch?: BetterFetch): Promise<boolean> => {\n\t\tconst network = activeNetwork.get();\n\t\treturn initClientForNetwork(network, $fetch);\n\t};\n\n\tlet sessionRestored = false;\n\n\tconst restoreFromSession = async ($fetch: BetterFetch) => {\n\t\tif (sessionRestored) return;\n\t\tconst state = nearState.get();\n\t\tif (state?.accountId) {\n\t\t\tsessionRestored = true;\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst res = await $fetch<ListAccountsResponseT>(\"/near/list-accounts\", { method: \"GET\" });\n\t\t\tconst accounts = res.data?.accounts;\n\t\t\tif (accounts?.length) {\n\t\t\t\tconst primary = res.data?.activeAccount || accounts.find((a: NearAccount) => a.isPrimary) || accounts[0];\n\t\t\t\tif (primary) {\n\t\t\t\t\tnearState.set({\n\t\t\t\t\t\taccountId: primary.accountId,\n\t\t\t\t\t\tpublicKey: primary.publicKey ?? null,\n\t\t\t\t\t\tnetworkId: primary.network,\n\t\t\t\t\t});\n\t\t\t\t\tactiveNetwork.set(primary.network);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t\tsessionRestored = true;\n\t};\n\n\tconst requireConnector = async (network?: \"mainnet\" | \"testnet\") => {\n\t\tconst net = network || activeNetwork.get();\n\t\tawait initClientForNetwork(net);\n\t\tconst connector = connectors.get(net);\n\t\tif (!connector) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\treturn connector;\n\t};\n\n\tconst requireNear = (network?: \"mainnet\" | \"testnet\"): Near => {\n\t\tconst net = network || activeNetwork.get();\n\t\tconst client = nearClients.get(net);\n\t\tif (!client) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\treturn client;\n\t};\n\n\tconst ensureWalletConnected = async (network?: \"mainnet\" | \"testnet\"): Promise<boolean> => {\n\t\tconst net = network || activeNetwork.get();\n\t\tconst conn = await requireConnector(net);\n\t\tif (walletConnected.get()) {\n\t\t\ttry {\n\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\tif (accounts?.length) return true;\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst signInHandler = (data: EventMap[\"wallet:signIn\"]) => {\n\t\t\t\tconst accountId = data.accounts?.[0]?.accountId;\n\t\t\t\tconst publicKey = data.accounts?.[0]?.publicKey;\n\t\t\t\tif (accountId) {\n\t\t\t\t\thandleAccountConnection(accountId, publicKey, net);\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconn.on(\"wallet:signIn\", signInHandler);\n\n\t\t\tconn.connect().catch(() => {}).finally(() => {\n\t\t\t\tconn.off(\"wallet:signIn\", signInHandler);\n\t\t\t\tif (!walletConnected.get()) {\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n\n\tconst signWithWallet = async (): Promise<SignWithWalletResult> => {\n\t\tconst net = activeNetwork.get();\n\t\tconst conn = await requireConnector(net);\n\t\tconst nearClient = requireNear(net);\n\t\tconst recipient = getRecipient(net);\n\n\t\tconst nonceBytes = generateNonce();\n\t\tconst nonceHex = hex.encode(nonceBytes);\n\t\tconst message = `Sign in to ${recipient}`;\n\n\t\tlet connectedWallet: Awaited<ReturnType<typeof conn.getConnectedWallet>> | null = null;\n\t\ttry {\n\t\t\tconnectedWallet = await conn.getConnectedWallet();\n\t\t} catch {}\n\n\t\tif (connectedWallet?.accounts?.length) {\n\t\t\tconst accountId: string = connectedWallet.accounts[0]!.accountId;\n\t\t\tconst isTestnetAccount = accountId.endsWith(\".testnet\");\n\t\t\tconst isExpectedNetwork = (net === \"testnet\") === isTestnetAccount;\n\t\t\tif (!isExpectedNetwork) {\n\t\t\t\tconnectedWallet = null;\n\t\t\t}\n\t\t}\n\n\t\tif (connectedWallet?.accounts?.length) {\n\t\t\tconst signedMessage = await nearClient.signMessage({\n\t\t\t\tmessage,\n\t\t\t\trecipient,\n\t\t\t\tnonce: nonceBytes,\n\t\t\t});\n\n\t\t\tif (!signedMessage?.accountId) {\n\t\t\t\tthrow new Error(\"Wallet sign-in was cancelled or failed\");\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsignedMessage,\n\t\t\t\taccountId: signedMessage.accountId,\n\t\t\t\tpublicKey: signedMessage.publicKey,\n\t\t\t\tnonceHex,\n\t\t\t};\n\t\t}\n\n\t\tconst result: { value: { signedMessage: SignedMessage; accountId: string; publicKey: string } | null } = { value: null };\n\t\tconst handler = (data: EventMap[\"wallet:signInAndSignMessage\"]) => {\n\t\t\tconst account = data.accounts?.[0];\n\t\t\tif (account?.signedMessage) {\n\t\t\t\tresult.value = {\n\t\t\t\t\tsignedMessage: account.signedMessage,\n\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\tpublicKey: account.signedMessage.publicKey,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tconn.on(\"wallet:signInAndSignMessage\", handler);\n\n\t\ttry {\n\t\t\tawait conn.connect({\n\t\t\t\tsignMessageParams: {\n\t\t\t\t\tmessage,\n\t\t\t\t\trecipient,\n\t\t\t\t\tnonce: nonceBytes,\n\t\t\t\t},\n\t\t\t});\n\t\t} finally {\n\t\t\tconn.off(\"wallet:signInAndSignMessage\", handler);\n\t\t}\n\n\t\tif (!result.value) {\n\t\t\tthrow new Error(\"Wallet sign-in was cancelled or failed\");\n\t\t}\n\n\t\treturn {\n\t\t\tsignedMessage: result.value.signedMessage,\n\t\t\taccountId: result.value.accountId,\n\t\t\tpublicKey: result.value.publicKey,\n\t\t\tnonceHex,\n\t\t};\n\t};\n\n\tconst buildSignedDelegateActionInternal = async (\n\t\treceiverId: string,\n\t\tbuildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder,\n\t): Promise<string> => {\n\t\tconst net = activeNetwork.get();\n\t\tconst state = nearState.get();\n\t\tif (!state?.accountId) {\n\t\t\tthrow new Error(\"No NEAR account found — please sign in with your NEAR wallet\");\n\t\t}\n\n\t\tif (!walletConnected.get()) {\n\t\t\tconst reconnected = await ensureWalletConnected(net);\n\t\t\tif (!reconnected) {\n\t\t\t\tthrow new Error(\"Wallet connection required — please approve the connection to sign\");\n\t\t\t}\n\t\t}\n\n\t\tconst nearClient = requireNear(net);\n\t\tconst builder = buildActions(nearClient.transaction(state.accountId), receiverId);\n\n\t\tconst { payload } = await builder.delegate();\n\t\treturn payload;\n\t};\n\n\tconst plugin = {\n\t\tid: \"siwn\" as const,\n\t\t$InferServerPlugin: {},\n\n\t\tgetAtoms: (_$fetch: BetterFetch) => ({\n\t\t\tnearState,\n\t\t\twalletConnected,\n\t\t\tactiveNetwork,\n\t\t}),\n\n\t\tgetActions: ($fetch: BetterFetch, $store: ClientStore, _options: unknown): SIWNClientActions => {\n\t\t\tvoid initClient($fetch);\n\n\t\t\tconst sessionAtom = $store.atoms?.session;\n\t\t\tif (sessionAtom) {\n\t\t\t\tsessionAtom.subscribe(() => {\n\t\t\t\t\tconst sessionData = sessionAtom.get()?.data ?? null;\n\t\t\t\t\tif (sessionData === null) {\n\t\t\t\t\t\tfor (const [_net, conn] of connectors) {\n\t\t\t\t\t\t\tvoid conn?.disconnect().catch(() => {});\n\t\t\t\t\t\t}\n\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\tsessionRestored = false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tnear: {\n\t\t\t\t\tnonce: async (params: NonceRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/nonce\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tverify: async (params: VerifyRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/verify\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetProfile: async (accountId?: AccountId, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/profile\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { accountId },\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tview: async (params: ViewContractRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/view\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetAccountId: () => {\n\t\t\t\t\t\tconst state = nearState.get();\n\t\t\t\t\t\treturn state?.accountId || null;\n\t\t\t\t\t},\n\t\t\t\t\tgetState: () => nearState.get(),\n\t\t\t\t\tisWalletConnected: () => walletConnected.get(),\n\t\t\t\t\tdetectNearAccount: async () => {\n\t\t\t\t\t\tconst state = nearState.get();\n\t\t\t\t\t\tif (state?.accountId && walletConnected.get()) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\taccountId: state.accountId,\n\t\t\t\t\t\t\t\tpublicKey: state.publicKey ?? null,\n\t\t\t\t\t\t\t\tnetworkId: state.networkId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const network of getSupportedNetworks()) {\n\t\t\t\t\t\t\tconst initialized = await initClientForNetwork(network);\n\t\t\t\t\t\t\tif (!initialized) continue;\n\t\t\t\t\t\t\tconst conn = connectors.get(network);\n\t\t\t\t\t\t\tif (!conn) continue;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\t\t\t\t\tif (accounts?.length) {\n\t\t\t\t\t\t\t\t\tconst account = accounts[0]!;\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\t\t\t\t\t\tpublicKey: account.publicKey ?? null,\n\t\t\t\t\t\t\t\t\t\tnetworkId: network,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t},\n\t\t\t\t\tensureConnected: async () => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tif (!initializedNetworks.has(net)) {\n\t\t\t\t\t\t\tif (!(await initClientForNetwork(net))) return false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (walletConnected.get()) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst conn = connectors.get(net);\n\t\t\t\t\t\t\t\tif (conn) {\n\t\t\t\t\t\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\t\t\t\t\t\tif (accounts?.length) return true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsole.error(\"[siwn] restoreFromSession failed:\", err instanceof Error ? err.message : err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ensureWalletConnected(net);\n\t\t\t\t\t},\n\t\t\t\t\tdisconnect: async () => {\n\t\t\t\t\t\tfor (const [_net, conn] of connectors) {\n\t\t\t\t\t\t\tif (conn) {\n\t\t\t\t\t\t\t\ttry { await conn.disconnect(); } catch {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\tsessionRestored = false;\n\t\t\t\t\t},\n\t\t\t\t\tlink: async (callbacks?: AuthCallbacks) => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tconst recipient = getRecipient(net);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst { signedMessage, accountId, nonceHex } = await signWithWallet();\n\t\t\t\t\t\t\tconst message = `Sign in to ${recipient}`;\n\n\t\t\t\t\t\t\tawait handleAccountConnection(accountId, signedMessage.publicKey, net);\n\n\t\t\t\t\t\t\tconst linkResponse = await $fetch<{ success: boolean; accountId: string; network: string; message: string }>(\"/near/link-account\", {\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\tsignedMessage,\n\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\trecipient,\n\t\t\t\t\t\t\t\t\tnonce: nonceHex,\n\t\t\t\t\t\t\t\t\taccountId,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (linkResponse.error) {\n\t\t\t\t\t\t\t\tthrow new Error(linkResponse.error.message || \"Failed to link NEAR account\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!linkResponse?.data?.success) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Account linking failed\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcallbacks?.onSuccess?.();\n\t\t\t\t\t\t\t$store.notify(\"$sessionSignal\");\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\tcallbacks?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tunlink: async (\n\t\t\t\t\t\tparams: { accountId: string; network?: \"mainnet\" | \"testnet\" },\n\t\t\t\t\t\tfetchOptions?: BetterFetchOption\n\t\t\t\t\t) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/unlink-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tlistAccounts: async (): Promise<BetterFetchResponse<ListAccountsResponseT>> => {\n\t\t\t\t\t\treturn await $fetch(\"/near/list-accounts\", { method: \"GET\" });\n\t\t\t\t\t},\n\t\t\t\t\tsetPrimaryAccount: async (params: SetPrimaryAccountRequestT) => {\n\t\t\t\t\t\tconst response = await $fetch<SetPrimaryAccountResponseT>(\"/near/set-primary-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst activeAccount = response.data?.activeAccount;\n\t\t\t\t\t\tif (activeAccount) {\n\t\t\t\t\t\t\tnearState.set({\n\t\t\t\t\t\t\t\taccountId: activeAccount.accountId,\n\t\t\t\t\t\t\t\tpublicKey: activeAccount.publicKey ?? null,\n\t\t\t\t\t\t\t\tnetworkId: activeAccount.network,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tactiveNetwork.set(activeAccount.network);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t},\n\t\t\t\t\tbuildSignedDelegateAction: async (\n\t\t\t\t\t\treceiverId: string,\n\t\t\t\t\t\tbuildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder,\n\t\t\t\t\t): Promise<string> => {\n\t\t\t\t\t\treturn buildSignedDelegateActionInternal(receiverId, buildActions);\n\t\t\t\t\t},\n\t\t\t\t\trelayTransaction: async (params: { payload: string }) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relay\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetRelayStatus: async (txHash: string) => {\n\t\t\t\t\t\treturn await $fetch(`/near/relay-status/${txHash}`, {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetRelayerInfo: async (params?: GetRelayerInfoRequestT) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relayer-info\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { ...(params ?? {}), network: params?.network ?? activeNetwork.get() },\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\trelayHistory: async () => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relay-history\", {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tcreateSubAccount: async (params: CreateSubAccountRequestT) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/create-sub-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { ...params, network: params.network ?? activeNetwork.get() },\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\tcheckSubAccountAvailability: async (params: CheckSubAccountAvailabilityRequestT) => {\n\t\t\t\t\tif (!SUB_ACCOUNT_LABEL_REGEX.test(params.subAccountName) || params.subAccountName.length < 2) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tdata: { available: false, accountId: \"\", reason: \"invalid\" as const },\n\t\t\t\t\t\t\terror: null,\n\t\t\t\t\t\t} as BetterFetchResponse<CheckSubAccountAvailabilityResponseT>;\n\t\t\t\t\t}\n\t\t\t\t\treturn await $fetch(\"/near/check-sub-account-availability\", {\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: { ...params, network: params.network ?? activeNetwork.get() },\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t\tsetNetwork: (network: \"mainnet\" | \"testnet\") => {\n\t\t\t\t\t\tconst prev = activeNetwork.get();\n\t\t\t\t\t\tif (prev !== network) {\n\t\t\t\t\t\t\tconst oldConn = connectors.get(prev);\n\t\t\t\t\t\t\tif (oldConn) {\n\t\t\t\t\t\t\t\tvoid oldConn.disconnect().catch(() => {});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactiveNetwork.set(network);\n\t\t\t\t\t\tvoid initClientForNetwork(network);\n\t\t\t\t\t},\n\t\t\t\t\tgetNetwork: () => activeNetwork.get(),\n\t\t\t\t\tgetSupportedNetworks: () => getSupportedNetworks(),\n\t\t\t\t\tgetRecipient: (network?: \"mainnet\" | \"testnet\") => getRecipient(network),\n\t\t\t\t\tgetNearClient: (): NearType => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tconst client = nearClients.get(net);\n\t\t\t\t\t\tif (!client) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\t\t\t\t\treturn client;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tsignIn: {\n\t\t\t\t\tnear: async (callbacks?: AuthCallbacks) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst { signedMessage, accountId, nonceHex } = await signWithWallet();\n\t\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\t\tconst recipient = getRecipient(net);\n\t\t\t\t\t\t\tconst message = `Sign in to ${recipient}`;\n\n\t\t\t\t\t\t\tawait handleAccountConnection(accountId, signedMessage.publicKey, net);\n\n\t\t\t\t\t\t\tconst verifyResponse: BetterFetchResponse<VerifyResponseT> = await $fetch(\"/near/verify\", {\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\tsignedMessage,\n\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\trecipient,\n\t\t\t\t\t\t\t\t\tnonce: nonceHex,\n\t\t\t\t\t\t\t\t\taccountId,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (verifyResponse.error) {\n\t\t\t\t\t\t\t\tthrow new Error(verifyResponse.error.message || \"Failed to verify signature\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!verifyResponse?.data?.success) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Authentication verification failed\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcallbacks?.onSuccess?.();\n\t\t\t\t\t\t\t$store.notify(\"$sessionSignal\");\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\tcallbacks?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t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AI,GAAG;MAClC,IAAI,CAAC,QAAQ,MAAM,IAAI,MAAM,8BAA8B,IAAI,iDAAiD;MAChH,OAAO;KACR;IACD;IACA,QAAQ,EACP,MAAM,OAAO,cAA8B;KAC1C,IAAI;MACH,MAAM,EAAE,eAAe,WAAW,aAAa,MAAM,eAAe;MACpE,MAAM,MAAM,cAAc,IAAI;MAC9B,MAAM,YAAY,aAAa,GAAG;MAClC,MAAM,UAAU,cAAc;MAE9B,MAAM,wBAAwB,WAAW,cAAc,WAAW,GAAG;MAErE,MAAM,iBAAuD,MAAM,OAAO,gBAAgB;OACzF,QAAQ;OACR,MAAM;QACL;QACA;QACA;QACA,OAAO;QACP;OACD;MACD,CAAC;MAED,IAAI,eAAe,OAClB,MAAM,IAAI,MAAM,eAAe,MAAM,WAAW,4BAA4B;MAG7E,IAAI,CAAC,gBAAgB,MAAM,SAC1B,MAAM,IAAI,MAAM,oCAAoC;MAGrD,WAAW,YAAY;MACvB,OAAO,OAAO,gBAAgB;KAC/B,SAAS,OAAO;MACf,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;MACpE,WAAW,UAAU,GAAG;KACzB;IACD,EACD;GACD;EACD;CAGW;AACb"}
|
|
1
|
+
{"version":3,"file":"client.js","names":[],"sources":["../src/types.ts","../src/client.ts"],"sourcesContent":["import { z } from \"zod\";\nimport { AccountIdSchema, type AccountId } from \"near-kit/schemas\";\nimport type { AccountState, Near, TransactionBuilder } from \"near-kit\";\n\nexport type { AccountId };\n\nexport interface NearAccount {\n\tid: string;\n\tuserId: string;\n\taccountId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tpublicKey: string;\n\tisPrimary: boolean;\n\tcreatedAt: Date;\n}\n\nexport interface ListedNearAccount extends NearAccount {\n\tproviderId: \"siwn\";\n\tisActive: boolean;\n\tisAvailable: boolean;\n}\n\nexport interface ListAccountsResponseT {\n\taccounts: ListedNearAccount[];\n\tactiveAccount: ListedNearAccount | null;\n\tavailableAccounts: ListedNearAccount[];\n}\n\nexport interface SetPrimaryAccountResponseT extends ListAccountsResponseT {\n\tsuccess: boolean;\n\taccountId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tmessage: string;\n}\n\nexport const socialImageSchema = z.object({\n\turl: z.string().optional(),\n\tipfs_cid: z.string().optional(),\n});\n\nexport const profileSchema = z.object({\n\tname: z.string().optional(),\n\tdescription: z.string().optional(),\n\timage: socialImageSchema.optional(),\n\tbackgroundImage: socialImageSchema.optional(),\n\tlinktree: z.record(z.string(), z.string()).optional(),\n});\n\nexport type SocialImage = z.infer<typeof socialImageSchema>;\nexport type Profile = z.infer<typeof profileSchema>;\n\nconst signedMessageSchema = z.object({\n\taccountId: z.string(),\n\tpublicKey: z.string(),\n\tsignature: z.string(),\n\tstate: z.string().optional(),\n});\n\nexport const LinkAccountRequest = z.object({\n\tsignedMessage: signedMessageSchema,\n\tmessage: z.string(),\n\trecipient: z.string(),\n\tnonce: z.string(),\n\taccountId: AccountIdSchema,\n\tcallbackUrl: z.string().optional(),\n});\n\nexport const SetPrimaryAccountRequest = z.object({\n\taccountId: AccountIdSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\n\nexport const NonceRequest = z.object({\n\taccountId: AccountIdSchema,\n\tnetworkId: z.union([z.literal(\"mainnet\"), z.literal(\"testnet\")])\n});\n\nexport const VerifyRequest = z.object({\n\tsignedMessage: signedMessageSchema,\n\tmessage: z.string(),\n\trecipient: z.string(),\n\tnonce: z.string(),\n\taccountId: AccountIdSchema,\n\tcallbackUrl: z.string().optional(),\n});\n\nexport const RelayRequest = z.object({\n\tpayload: z.string(),\n});\nexport type RelayRequestT = z.infer<typeof RelayRequest>;\n\nexport const RelayResponse = z.object({\n\ttxHash: z.string(),\n\tstatus: z.enum([\"pending\", \"completed\", \"failed\"]),\n});\nexport type RelayResponseT = z.infer<typeof RelayResponse>;\n\nexport const RelayStatusResponse = z.object({\n\tstatus: z.enum([\"pending\", \"completed\", \"failed\"]),\n\tgasUsed: z.string().optional(),\n\toutcome: z.unknown().optional(),\n});\nexport type RelayStatusResponseT = z.infer<typeof RelayStatusResponse>;\n\nexport const ViewContractRequest = z.object({\n\tcontractId: z.string(),\n\tmethodName: z.string(),\n\targs: z.record(z.string(), z.any()).optional(),\n});\nexport type ViewContractRequestT = z.infer<typeof ViewContractRequest>;\n\nexport const NonceResponse = z.object({ nonce: z.string() });\nexport const VerifyResponse = z.object({\n\ttoken: z.string(),\n\tsuccess: z.literal(true),\n\tuser: z.object({\n\t\tid: z.string(),\n\t\taccountId: AccountIdSchema,\n\t\tnetwork: z.union([z.literal(\"mainnet\"), z.literal(\"testnet\")]),\n\t}),\n});\nexport const ProfileResponse = profileSchema.nullable();\nexport const ViewContractResponse = z.object({ result: z.unknown() });\n\nexport const ProfileRequest = z.object({\n\taccountId: AccountIdSchema.optional(),\n});\nexport type ProfileRequestT = z.infer<typeof ProfileRequest>;\n\nexport type NonceRequestT = z.infer<typeof NonceRequest>;\nexport type NonceResponseT = z.infer<typeof NonceResponse>;\nexport type SetPrimaryAccountRequestT = z.infer<typeof SetPrimaryAccountRequest>;\nexport type VerifyRequestT = z.infer<typeof VerifyRequest>;\nexport type VerifyResponseT = z.infer<typeof VerifyResponse>;\nexport type ProfileResponseT = z.infer<typeof ProfileResponse>;\nexport type ViewContractResponseT = z.infer<typeof ViewContractResponse>;\n\nexport const RelayedTransactionSchema = z.object({\n\tid: z.string(),\n\tuserId: z.string(),\n\ttxHash: z.string(),\n\tsenderId: z.string(),\n\treceiverId: z.string(),\n\tnetwork: z.string(),\n\tstatus: z.string(),\n\tgasUsed: z.string().optional(),\n\tcreatedAt: z.string(),\n\tupdatedAt: z.string().optional(),\n});\nexport type RelayedTransactionT = z.infer<typeof RelayedTransactionSchema>;\n\nexport const RelayHistoryResponse = z.object({\n\ttransactions: z.array(RelayedTransactionSchema),\n});\nexport type RelayHistoryResponseT = z.infer<typeof RelayHistoryResponse>;\n\nexport interface RelayedTransactionRecord {\n\tid: string;\n\tuserId: string;\n\ttxHash: string;\n\tsenderId: string;\n\treceiverId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n\tstatus: string;\n\tgasUsed?: string;\n\tcreatedAt: Date;\n\tupdatedAt: Date;\n}\n\nexport const relayerConfigSchema = z\n\t.object({\n\t\taccountId: z.string().optional(),\n\t\tprivateKey: z.string().optional(),\n\t\twhitelistedContracts: z.array(z.string()).optional(),\n\t\tmaxGasPerTransaction: z\n\t\t\t.string()\n\t\t\t.regex(/^\\d+$/, \"must be a non-negative integer string of gas units\")\n\t\t\t.optional(),\n\t\tmaxDepositPerTransaction: z\n\t\t\t.string()\n\t\t\t.regex(/^\\d+$/, \"must be a non-negative integer string of yoctoNEAR\")\n\t\t\t.optional(),\n\t})\n\t.strict();\n\nexport const relayerDualNetworkConfigSchema = z\n\t.object({\n\t\tmainnet: relayerConfigSchema.optional(),\n\t\ttestnet: relayerConfigSchema.optional(),\n\t})\n\t.strict();\n\nexport type RelayerConfig = z.infer<typeof relayerConfigSchema>;\nexport type RelayerDualNetworkConfig = z.infer<typeof relayerDualNetworkConfigSchema>;\n\nexport interface RelayerInfo extends AccountState {\n\taccountId: string;\n\tmode: \"ephemeral\" | \"explicit\";\n\tnetwork: \"mainnet\" | \"testnet\";\n\tpublicKey: string;\n\thasKey: boolean;\n\tcreatedAt?: Date;\n\tlastUsedAt?: Date;\n\tparentAccount?: string;\n\tsubAccountAvailable?: boolean;\n\terror?: string;\n}\n\nexport interface DualNetworkConfig<T> {\n\tmainnet: T;\n\ttestnet: T;\n}\n\nexport const GetRelayerInfoRequest = z.object({\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\nexport type GetRelayerInfoRequestT = z.infer<typeof GetRelayerInfoRequest>;\n\nexport interface SubAccountRelayerFCAKConfig {\n\treceiverId: string;\n\tmethodNames?: string[];\n\tallowance?: string;\n}\n\nexport interface SubAccountTxCtx {\n\tnewAccountId: string;\n\tparentAccount: string;\n\tuserPublicKey: string;\n\tuserAccountId: string;\n\tuserId: string;\n\tnetwork: \"mainnet\" | \"testnet\";\n}\n\nexport interface SubAccountLifecycleCtx extends SubAccountTxCtx {\n\tnear: Near;\n}\n\nexport interface SubAccountConfig {\n\tparentAccount?: string;\n\tminDeposit?: string;\n\tparentHasFullAccess?: boolean;\n\tdeploy?:\n\t\t| { wasm: Uint8Array }\n\t\t| { fromPublished: { accountId?: string; codeHash?: string } };\n\tinit?: {\n\t\tmethodName: string;\n\t\targs: object | ((ctx: SubAccountTxCtx) => object);\n\t};\n\textendTx?: (tx: TransactionBuilder, ctx: SubAccountTxCtx) => TransactionBuilder;\n\tonCreated?: (ctx: SubAccountLifecycleCtx) => Promise<void>;\n\tonRollback?: (ctx: SubAccountLifecycleCtx) => Promise<void>;\n\taddRelayerFCAK?: boolean;\n\trelayerFCAK?: SubAccountRelayerFCAKConfig;\n}\n\nexport const SUB_ACCOUNT_LABEL_REGEX = /^([a-z\\d]+[-_])*[a-z\\d]+$/;\n\nexport const SubAccountNameSchema = z\n\t.string()\n\t.min(2, \"Sub-account name must be at least 2 characters\")\n\t.max(64, \"Sub-account name must be at most 64 characters\")\n\t.regex(SUB_ACCOUNT_LABEL_REGEX, \"Sub-account name must contain only lowercase alphanumeric characters, hyphens, and underscores (no leading/trailing hyphens or underscores)\");\n\nexport const CreateSubAccountRequest = z.object({\n\tsubAccountName: SubAccountNameSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n\tpublicKey: z.string(),\n});\nexport type CreateSubAccountRequestT = z.infer<typeof CreateSubAccountRequest>;\n\nexport const CreateSubAccountResponse = z.object({\n\tsuccess: z.literal(true),\n\taccountId: z.string(),\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]),\n\tpublicKey: z.string(),\n\tmessage: z.string(),\n});\nexport type CreateSubAccountResponseT = z.infer<typeof CreateSubAccountResponse>;\n\nexport const CheckSubAccountAvailabilityRequest = z.object({\n\tsubAccountName: SubAccountNameSchema,\n\tnetwork: z.enum([\"mainnet\", \"testnet\"]).optional(),\n});\nexport type CheckSubAccountAvailabilityRequestT = z.infer<typeof CheckSubAccountAvailabilityRequest>;\n\nexport const CheckSubAccountAvailabilityResponse = z.object({\n\tavailable: z.boolean(),\n\taccountId: z.string(),\n\tparentAccount: z.string().optional(),\n\treason: z.enum([\"taken\", \"invalid\", \"too-long\", \"not-configured\"]).optional(),\n});\nexport type CheckSubAccountAvailabilityResponseT = z.infer<typeof CheckSubAccountAvailabilityResponse>;\n","import { Near, fromNearConnect, generateNonce, TransactionBuilder } from \"near-kit\";\nimport type { Near as NearType, SignedMessage } from \"near-kit\";\nimport type { EventMap } from \"@hot-labs/near-connect\";\nimport { hex } from \"@scure/base\";\nimport type { BetterFetch, BetterFetchOption, BetterFetchResponse, ClientStore } from \"better-auth/client\";\nimport { atom } from \"nanostores\";\nimport { type AccountId, type DualNetworkConfig, type NonceRequestT, type NonceResponseT, type ProfileResponseT, type VerifyRequestT, type VerifyResponseT, type RelayResponseT, type RelayStatusResponseT, type NearAccount, type ListAccountsResponseT, type SetPrimaryAccountRequestT, type SetPrimaryAccountResponseT, type ViewContractRequestT, type ViewContractResponseT, type RelayerInfo, type RelayHistoryResponseT, type GetRelayerInfoRequestT, type CreateSubAccountRequestT, type CreateSubAccountResponseT, type CheckSubAccountAvailabilityRequestT, type CheckSubAccountAvailabilityResponseT, SUB_ACCOUNT_LABEL_REGEX } from \"./types.js\";\n\nexport interface AuthCallbacks {\n\tonSuccess?: () => void;\n\tonError?: (error: Error & { status?: number; code?: string }) => void;\n}\n\nexport interface SIWNClientConfig {\n\trecipient?: string;\n\trecipients?: DualNetworkConfig<string>;\n\tnetworkId?: \"mainnet\" | \"testnet\";\n\tcspNonce?: string;\n}\n\ninterface SignWithWalletResult {\n\tsignedMessage: SignedMessage;\n\taccountId: string;\n\tpublicKey: string;\n\tnonceHex: string;\n}\n\nexport interface SIWNClientActions {\n\tnear: {\n\t\tnonce: (params: NonceRequestT) => Promise<BetterFetchResponse<NonceResponseT>>;\n\t\tverify: (params: VerifyRequestT) => Promise<BetterFetchResponse<VerifyResponseT>>;\n\t\tgetProfile: (accountId?: AccountId) => Promise<BetterFetchResponse<ProfileResponseT>>;\n\t\tview: (params: ViewContractRequestT) => Promise<BetterFetchResponse<ViewContractResponseT>>;\n\t\tgetAccountId: () => string | null;\n\t\tgetState: () => { accountId: string | null; publicKey: string | null; networkId: string } | null;\n\t\tisWalletConnected: () => boolean;\n\t\tdetectNearAccount: () => Promise<{ accountId: string; publicKey: string | null; networkId: string } | null>;\n\t\tensureConnected: () => Promise<boolean>;\n\t\tdisconnect: () => Promise<void>;\n\t\tlink: (callbacks?: AuthCallbacks) => Promise<void>;\n\t\tunlink: (params: { accountId: string; network?: \"mainnet\" | \"testnet\" }) => Promise<BetterFetchResponse<{ success: boolean; message: string }>>;\n\t\tlistAccounts: () => Promise<BetterFetchResponse<ListAccountsResponseT>>;\n\t\tsetPrimaryAccount: (params: SetPrimaryAccountRequestT) => Promise<BetterFetchResponse<SetPrimaryAccountResponseT>>;\n\t\tbuildSignedDelegateAction: (receiverId: string, buildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder) => Promise<string>;\n\t\trelayTransaction: (params: { payload: string }) => Promise<BetterFetchResponse<RelayResponseT>>;\n\t\tgetRelayStatus: (txHash: string) => Promise<BetterFetchResponse<RelayStatusResponseT>>;\n\t\tgetRelayerInfo: (params?: GetRelayerInfoRequestT) => Promise<BetterFetchResponse<RelayerInfo & { enabled: boolean }>>;\n\t\trelayHistory: () => Promise<BetterFetchResponse<RelayHistoryResponseT>>;\n\t\tcreateSubAccount: (params: CreateSubAccountRequestT) => Promise<BetterFetchResponse<CreateSubAccountResponseT>>;\n\t\tcheckSubAccountAvailability: (params: CheckSubAccountAvailabilityRequestT) => Promise<BetterFetchResponse<CheckSubAccountAvailabilityResponseT>>;\n\t\tsetNetwork: (network: \"mainnet\" | \"testnet\") => void;\n\t\tgetNetwork: () => \"mainnet\" | \"testnet\";\n\t\tgetSupportedNetworks: () => (\"mainnet\" | \"testnet\")[];\n\t\tgetRecipient: (network?: \"mainnet\" | \"testnet\") => string;\n\t\tgetNearClient: () => NearType;\n\t};\n\tsignIn: {\n\t\tnear: (callbacks?: AuthCallbacks) => Promise<void>;\n\t};\n}\n\ntype NearState = { accountId: string | null; publicKey: string | null; networkId: string } | null;\n\nexport const siwnClient = (config: SIWNClientConfig) => {\n\tconst nearState = atom<NearState>(null);\n\tconst walletConnected = atom<boolean>(false);\n\tconst activeNetwork = atom<\"mainnet\" | \"testnet\">(config.networkId || \"mainnet\");\n\n\tconst getRecipient = (network?: \"mainnet\" | \"testnet\"): string => {\n\t\tconst net = network || activeNetwork.get();\n\t\tif (config.recipients) return config.recipients[net];\n\t\treturn config.recipient ?? \"\";\n\t};\n\n\tconst getSupportedNetworks = (): (\"mainnet\" | \"testnet\")[] => {\n\t\tif (config.recipients) return [\"mainnet\", \"testnet\"];\n\t\tif (config.recipient) return [config.recipient.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\"];\n\t\treturn [\"mainnet\"];\n\t};\n\n\tlet connectors = new Map<\"mainnet\" | \"testnet\", InstanceType<typeof import(\"@hot-labs/near-connect\").NearConnector>>();\n\tlet nearClients = new Map<\"mainnet\" | \"testnet\", Near>();\n\tlet initializedNetworks = new Set<\"mainnet\" | \"testnet\">();\n\tlet connectorModulePromise: Promise<typeof import(\"@hot-labs/near-connect\")> | null = null;\n\tlet initPromises = new Map<\"mainnet\" | \"testnet\", Promise<boolean>>();\n\n\tconst loadConnector = async () => {\n\t\tconnectorModulePromise ??= import(\"@hot-labs/near-connect\");\n\t\tconst { NearConnector } = await connectorModulePromise;\n\t\treturn NearConnector;\n\t};\n\n\tconst handleAccountConnection = async (accountId: string, publicKey?: string | null, network?: \"mainnet\" | \"testnet\") => {\n\t\tif (!accountId) return;\n\t\tconst net = network || activeNetwork.get();\n\t\tnearState.set({\n\t\t\taccountId,\n\t\t\tpublicKey: publicKey || null,\n\t\t\tnetworkId: net,\n\t\t});\n\t\twalletConnected.set(true);\n\t};\n\n\tconst initClientForNetwork = async (network: \"mainnet\" | \"testnet\", $fetch?: BetterFetch): Promise<boolean> => {\n\t\tif (initializedNetworks.has(network)) return true;\n\t\tif (initPromises.has(network)) return initPromises.get(network)!;\n\t\tif (typeof (globalThis as any).window === \"undefined\") return false;\n\n\t\tconst initPromise = (async () => {\n\t\t\tconst NearConnector = await loadConnector();\n\t\t\tconst connector = new NearConnector({ network, cspNonce: config.cspNonce });\n\t\t\tconnectors.set(network, connector);\n\n\t\t\tconst near = new Near({\n\t\t\t\tnetwork,\n\t\t\t\twallet: fromNearConnect(connector),\n\t\t\t});\n\t\t\tnearClients.set(network, near);\n\n\t\t\tconnector.on(\"wallet:signIn\", async (data: EventMap[\"wallet:signIn\"]) => {\n\t\t\t\tconst accountId = data.accounts?.[0]?.accountId;\n\t\t\t\tconst publicKey = data.accounts?.[0]?.publicKey;\n\t\t\t\tif (accountId) {\n\t\t\t\t\tawait handleAccountConnection(accountId, publicKey, network);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tconnector.on(\"wallet:signOut\", () => {\n\t\t\t\twalletConnected.set(false);\n\t\t\t\tconst state = nearState.get();\n\t\t\t\tif (state) {\n\t\t\t\t\tnearState.set({ accountId: state.accountId, publicKey: null, networkId: state.networkId });\n\t\t\t\t}\n\t\t\t});\n\n\t\t\tvoid connector.getConnectedWallet().then(({ accounts }) => {\n\t\t\t\tconst account = accounts?.[0];\n\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\tif (account?.accountId && !nearState.get()) {\n\t\t\t\t\tnearState.set({\n\t\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\t\tpublicKey: account.publicKey ?? null,\n\t\t\t\t\t\tnetworkId: net,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (account?.accountId) {\n\t\t\t\t\twalletConnected.set(true);\n\t\t\t\t}\n\t\t\t}).catch(() => {});\n\n\t\t\tinitializedNetworks.add(network);\n\n\t\t\tif ($fetch) {\n\t\t\t\tvoid restoreFromSession($fetch);\n\t\t\t}\n\n\t\t\treturn true;\n\t\t})();\n\n\t\tinitPromises.set(network, initPromise);\n\n\t\ttry {\n\t\t\treturn await initPromise;\n\t\t} finally {\n\t\t\tinitPromises.delete(network);\n\t\t}\n\t};\n\n\tconst initClient = async ($fetch?: BetterFetch): Promise<boolean> => {\n\t\tconst network = activeNetwork.get();\n\t\treturn initClientForNetwork(network, $fetch);\n\t};\n\n\tlet sessionRestored = false;\n\n\tconst restoreFromSession = async ($fetch: BetterFetch) => {\n\t\tif (sessionRestored) return;\n\t\tconst state = nearState.get();\n\t\tif (state?.accountId) {\n\t\t\tsessionRestored = true;\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tconst res = await $fetch<ListAccountsResponseT>(\"/near/list-accounts\", { method: \"GET\" });\n\t\t\tconst accounts = res.data?.accounts;\n\t\t\tif (accounts?.length) {\n\t\t\t\tconst primary = res.data?.activeAccount || accounts.find((a: NearAccount) => a.isPrimary) || accounts[0];\n\t\t\t\tif (primary) {\n\t\t\t\t\tnearState.set({\n\t\t\t\t\t\taccountId: primary.accountId,\n\t\t\t\t\t\tpublicKey: primary.publicKey ?? null,\n\t\t\t\t\t\tnetworkId: primary.network,\n\t\t\t\t\t});\n\t\t\t\t\tactiveNetwork.set(primary.network);\n\t\t\t\t}\n\t\t\t}\n\t\t} catch {}\n\t\tsessionRestored = true;\n\t};\n\n\tconst requireConnector = async (network?: \"mainnet\" | \"testnet\") => {\n\t\tconst net = network || activeNetwork.get();\n\t\tawait initClientForNetwork(net);\n\t\tconst connector = connectors.get(net);\n\t\tif (!connector) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\treturn connector;\n\t};\n\n\tconst requireNear = (network?: \"mainnet\" | \"testnet\"): Near => {\n\t\tconst net = network || activeNetwork.get();\n\t\tconst client = nearClients.get(net);\n\t\tif (!client) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\treturn client;\n\t};\n\n\tconst ensureWalletConnected = async (network?: \"mainnet\" | \"testnet\"): Promise<boolean> => {\n\t\tconst net = network || activeNetwork.get();\n\t\tconst conn = await requireConnector(net);\n\t\tif (walletConnected.get()) {\n\t\t\ttry {\n\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\tif (accounts?.length) return true;\n\t\t\t} catch {}\n\t\t}\n\n\t\treturn new Promise<boolean>((resolve) => {\n\t\t\tconst signInHandler = (data: EventMap[\"wallet:signIn\"]) => {\n\t\t\t\tconst accountId = data.accounts?.[0]?.accountId;\n\t\t\t\tconst publicKey = data.accounts?.[0]?.publicKey;\n\t\t\t\tif (accountId) {\n\t\t\t\t\thandleAccountConnection(accountId, publicKey, net);\n\t\t\t\t\tresolve(true);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tconn.on(\"wallet:signIn\", signInHandler);\n\n\t\t\tconn.connect().catch(() => {}).finally(() => {\n\t\t\t\tconn.off(\"wallet:signIn\", signInHandler);\n\t\t\t\tif (!walletConnected.get()) {\n\t\t\t\t\tresolve(false);\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t};\n\n\tconst signWithWallet = async (): Promise<SignWithWalletResult> => {\n\t\tconst net = activeNetwork.get();\n\t\tconst conn = await requireConnector(net);\n\t\tconst nearClient = requireNear(net);\n\t\tconst recipient = getRecipient(net);\n\n\t\tconst nonceBytes = generateNonce();\n\t\tconst nonceHex = hex.encode(nonceBytes);\n\t\tconst message = `Sign in to ${recipient}`;\n\n\t\tlet connectedWallet: Awaited<ReturnType<typeof conn.getConnectedWallet>> | null = null;\n\t\ttry {\n\t\t\tconnectedWallet = await conn.getConnectedWallet();\n\t\t} catch {}\n\n\t\tif (connectedWallet?.accounts?.length) {\n\t\t\tconst accountId: string = connectedWallet.accounts[0]!.accountId;\n\t\t\tconst isTestnetAccount = accountId.endsWith(\".testnet\");\n\t\t\tconst isExpectedNetwork = (net === \"testnet\") === isTestnetAccount;\n\t\t\tif (!isExpectedNetwork) {\n\t\t\t\tconnectedWallet = null;\n\t\t\t}\n\t\t}\n\n\t\tif (connectedWallet?.accounts?.length) {\n\t\t\tconst signedMessage = await nearClient.signMessage({\n\t\t\t\tmessage,\n\t\t\t\trecipient,\n\t\t\t\tnonce: nonceBytes,\n\t\t\t});\n\n\t\t\tif (!signedMessage?.accountId) {\n\t\t\t\tthrow new Error(\"Wallet sign-in was cancelled or failed\");\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tsignedMessage,\n\t\t\t\taccountId: signedMessage.accountId,\n\t\t\t\tpublicKey: signedMessage.publicKey,\n\t\t\t\tnonceHex,\n\t\t\t};\n\t\t}\n\n\t\tconst result: { value: { signedMessage: SignedMessage; accountId: string; publicKey: string } | null } = { value: null };\n\t\tconst handler = (data: EventMap[\"wallet:signInAndSignMessage\"]) => {\n\t\t\tconst account = data.accounts?.[0];\n\t\t\tif (account?.signedMessage) {\n\t\t\t\tresult.value = {\n\t\t\t\t\tsignedMessage: account.signedMessage,\n\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\tpublicKey: account.signedMessage.publicKey,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tconn.on(\"wallet:signInAndSignMessage\", handler);\n\n\t\ttry {\n\t\t\tawait conn.connect({\n\t\t\t\tsignMessageParams: {\n\t\t\t\t\tmessage,\n\t\t\t\t\trecipient,\n\t\t\t\t\tnonce: nonceBytes,\n\t\t\t\t},\n\t\t\t});\n\t\t} finally {\n\t\t\tconn.off(\"wallet:signInAndSignMessage\", handler);\n\t\t}\n\n\t\tif (!result.value) {\n\t\t\tthrow new Error(\"Wallet sign-in was cancelled or failed\");\n\t\t}\n\n\t\treturn {\n\t\t\tsignedMessage: result.value.signedMessage,\n\t\t\taccountId: result.value.accountId,\n\t\t\tpublicKey: result.value.publicKey,\n\t\t\tnonceHex,\n\t\t};\n\t};\n\n\tconst buildSignedDelegateActionInternal = async (\n\t\treceiverId: string,\n\t\tbuildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder,\n\t): Promise<string> => {\n\t\tconst net = activeNetwork.get();\n\t\tconst state = nearState.get();\n\t\tif (!state?.accountId) {\n\t\t\tthrow new Error(\"No NEAR account found — please sign in with your NEAR wallet\");\n\t\t}\n\n\t\tif (!walletConnected.get()) {\n\t\t\tconst reconnected = await ensureWalletConnected(net);\n\t\t\tif (!reconnected) {\n\t\t\t\tthrow new Error(\"Wallet connection required — please approve the connection to sign\");\n\t\t\t}\n\t\t}\n\n\t\tconst nearClient = requireNear(net);\n\t\tconst builder = buildActions(nearClient.transaction(state.accountId), receiverId);\n\n\t\tconst { payload } = await builder.delegate();\n\t\treturn payload;\n\t};\n\n\tconst plugin = {\n\t\tid: \"siwn\" as const,\n\t\t$InferServerPlugin: {},\n\n\t\tgetAtoms: (_$fetch: BetterFetch) => ({\n\t\t\tnearState,\n\t\t\twalletConnected,\n\t\t\tactiveNetwork,\n\t\t}),\n\n\t\tgetActions: ($fetch: BetterFetch, $store: ClientStore, _options: unknown): SIWNClientActions => {\n\t\t\tvoid initClient($fetch);\n\n\t\t\tconst sessionAtom = $store.atoms?.session;\n\t\t\tif (sessionAtom) {\n\t\t\t\tsessionAtom.subscribe(() => {\n\t\t\t\t\tconst sessionData = sessionAtom.get()?.data ?? null;\n\t\t\t\t\tif (sessionData === null) {\n\t\t\t\t\t\tfor (const [_net, conn] of connectors) {\n\t\t\t\t\t\t\tvoid conn?.disconnect().catch(() => {});\n\t\t\t\t\t\t}\n\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\tsessionRestored = false;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tnear: {\n\t\t\t\t\tnonce: async (params: NonceRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/nonce\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tverify: async (params: VerifyRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/verify\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetProfile: async (accountId?: AccountId, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/profile\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { accountId },\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tview: async (params: ViewContractRequestT, fetchOptions?: BetterFetchOption) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/view\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetAccountId: () => {\n\t\t\t\t\t\tconst state = nearState.get();\n\t\t\t\t\t\treturn state?.accountId || null;\n\t\t\t\t\t},\n\t\t\t\t\tgetState: () => nearState.get(),\n\t\t\t\t\tisWalletConnected: () => walletConnected.get(),\n\t\t\t\t\tdetectNearAccount: async () => {\n\t\t\t\t\t\tconst state = nearState.get();\n\t\t\t\t\t\tif (state?.accountId && walletConnected.get()) {\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\taccountId: state.accountId,\n\t\t\t\t\t\t\t\tpublicKey: state.publicKey ?? null,\n\t\t\t\t\t\t\t\tnetworkId: state.networkId,\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t\tfor (const network of getSupportedNetworks()) {\n\t\t\t\t\t\t\tconst initialized = await initClientForNetwork(network);\n\t\t\t\t\t\t\tif (!initialized) continue;\n\t\t\t\t\t\t\tconst conn = connectors.get(network);\n\t\t\t\t\t\t\tif (!conn) continue;\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\t\t\t\t\tif (accounts?.length) {\n\t\t\t\t\t\t\t\t\tconst account = accounts[0]!;\n\t\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\t\taccountId: account.accountId,\n\t\t\t\t\t\t\t\t\t\tpublicKey: account.publicKey ?? null,\n\t\t\t\t\t\t\t\t\t\tnetworkId: network,\n\t\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch {}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t},\n\t\t\t\t\tensureConnected: async () => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tif (!initializedNetworks.has(net)) {\n\t\t\t\t\t\t\tif (!(await initClientForNetwork(net))) return false;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (walletConnected.get()) {\n\t\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\t\tconst conn = connectors.get(net);\n\t\t\t\t\t\t\t\tif (conn) {\n\t\t\t\t\t\t\t\t\tconst { accounts } = await conn.getConnectedWallet();\n\t\t\t\t\t\t\t\t\tif (accounts?.length) return true;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} catch (err) {\n\t\t\t\t\t\t\t\tconsole.error(\"[siwn] restoreFromSession failed:\", err instanceof Error ? err.message : err);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn ensureWalletConnected(net);\n\t\t\t\t\t},\n\t\t\t\t\tdisconnect: async () => {\n\t\t\t\t\t\tfor (const [_net, conn] of connectors) {\n\t\t\t\t\t\t\tif (conn) {\n\t\t\t\t\t\t\t\ttry { await conn.disconnect(); } catch {}\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\tsessionRestored = false;\n\t\t\t\t\t},\n\t\t\t\t\tlink: async (callbacks?: AuthCallbacks) => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tconst recipient = getRecipient(net);\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst { signedMessage, accountId, nonceHex } = await signWithWallet();\n\t\t\t\t\t\t\tconst message = `Sign in to ${recipient}`;\n\n\t\t\t\t\t\t\tawait handleAccountConnection(accountId, signedMessage.publicKey, net);\n\n\t\t\t\t\t\t\tconst linkResponse = await $fetch<{ success: boolean; accountId: string; network: string; message: string }>(\"/near/link-account\", {\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\tsignedMessage,\n\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\trecipient,\n\t\t\t\t\t\t\t\t\tnonce: nonceHex,\n\t\t\t\t\t\t\t\t\taccountId,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (linkResponse.error) {\n\t\t\t\t\t\t\t\tthrow new Error(linkResponse.error.message || \"Failed to link NEAR account\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!linkResponse?.data?.success) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Account linking failed\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcallbacks?.onSuccess?.();\n\t\t\t\t\t\t\t$store.notify(\"$sessionSignal\");\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\tcallbacks?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tunlink: async (\n\t\t\t\t\t\tparams: { accountId: string; network?: \"mainnet\" | \"testnet\" },\n\t\t\t\t\t\tfetchOptions?: BetterFetchOption\n\t\t\t\t\t) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/unlink-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t\t...fetchOptions\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tlistAccounts: async (): Promise<BetterFetchResponse<ListAccountsResponseT>> => {\n\t\t\t\t\t\treturn await $fetch(\"/near/list-accounts\", { method: \"GET\" });\n\t\t\t\t\t},\n\t\t\t\t\tsetPrimaryAccount: async (params: SetPrimaryAccountRequestT) => {\n\t\t\t\t\t\tconst response = await $fetch<SetPrimaryAccountResponseT>(\"/near/set-primary-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst activeAccount = response.data?.activeAccount;\n\t\t\t\t\t\tif (activeAccount) {\n\t\t\t\t\t\t\tnearState.set({\n\t\t\t\t\t\t\t\taccountId: activeAccount.accountId,\n\t\t\t\t\t\t\t\tpublicKey: activeAccount.publicKey ?? null,\n\t\t\t\t\t\t\t\tnetworkId: activeAccount.network,\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tactiveNetwork.set(activeAccount.network);\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn response;\n\t\t\t\t\t},\n\t\t\t\t\tbuildSignedDelegateAction: async (\n\t\t\t\t\t\treceiverId: string,\n\t\t\t\t\t\tbuildActions: (builder: TransactionBuilder, receiverId: string) => TransactionBuilder,\n\t\t\t\t\t): Promise<string> => {\n\t\t\t\t\t\treturn buildSignedDelegateActionInternal(receiverId, buildActions);\n\t\t\t\t\t},\n\t\t\t\t\trelayTransaction: async (params: { payload: string }) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relay\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: params,\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetRelayStatus: async (txHash: string) => {\n\t\t\t\t\t\treturn await $fetch(`/near/relay-status/${txHash}`, {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tgetRelayerInfo: async (params?: GetRelayerInfoRequestT) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relayer-info\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { ...(params ?? {}), network: params?.network ?? activeNetwork.get() },\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\trelayHistory: async () => {\n\t\t\t\t\t\treturn await $fetch(\"/near/relay-history\", {\n\t\t\t\t\t\t\tmethod: \"GET\",\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\t\tcreateSubAccount: async (params: CreateSubAccountRequestT) => {\n\t\t\t\t\t\treturn await $fetch(\"/near/create-sub-account\", {\n\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\tbody: { ...params, network: params.network ?? activeNetwork.get() },\n\t\t\t\t\t\t});\n\t\t\t\t\t},\n\t\t\t\tcheckSubAccountAvailability: async (params: CheckSubAccountAvailabilityRequestT) => {\n\t\t\t\t\tif (!SUB_ACCOUNT_LABEL_REGEX.test(params.subAccountName) || params.subAccountName.length < 2) {\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\tdata: { available: false, accountId: \"\", reason: \"invalid\" as const },\n\t\t\t\t\t\t\terror: null,\n\t\t\t\t\t\t} as BetterFetchResponse<CheckSubAccountAvailabilityResponseT>;\n\t\t\t\t\t}\n\t\t\t\t\treturn await $fetch(\"/near/check-sub-account-availability\", {\n\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\tbody: { ...params, network: params.network ?? activeNetwork.get() },\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t\tsetNetwork: (network: \"mainnet\" | \"testnet\") => {\n\t\t\t\t\t\tconst prev = activeNetwork.get();\n\t\t\t\t\t\tif (prev !== network) {\n\t\t\t\t\t\t\tconst oldConn = connectors.get(prev);\n\t\t\t\t\t\t\tif (oldConn) {\n\t\t\t\t\t\t\t\tvoid oldConn.disconnect().catch(() => {});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\twalletConnected.set(false);\n\t\t\t\t\t\t\tnearState.set(null);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tactiveNetwork.set(network);\n\t\t\t\t\t\tvoid initClientForNetwork(network);\n\t\t\t\t\t},\n\t\t\t\t\tgetNetwork: () => activeNetwork.get(),\n\t\t\t\t\tgetSupportedNetworks: () => getSupportedNetworks(),\n\t\t\t\t\tgetRecipient: (network?: \"mainnet\" | \"testnet\") => getRecipient(network),\n\t\t\t\t\tgetNearClient: (): NearType => {\n\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\tconst client = nearClients.get(net);\n\t\t\t\t\t\tif (!client) throw new Error(`Wallet not initialized for ${net} — this operation requires a browser environment`);\n\t\t\t\t\t\treturn client;\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tsignIn: {\n\t\t\t\t\tnear: async (callbacks?: AuthCallbacks) => {\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tconst { signedMessage, accountId, nonceHex } = await signWithWallet();\n\t\t\t\t\t\t\tconst net = activeNetwork.get();\n\t\t\t\t\t\t\tconst recipient = getRecipient(net);\n\t\t\t\t\t\t\tconst message = `Sign in to ${recipient}`;\n\n\t\t\t\t\t\t\tawait handleAccountConnection(accountId, signedMessage.publicKey, net);\n\n\t\t\t\t\t\t\tconst verifyResponse: BetterFetchResponse<VerifyResponseT> = await $fetch(\"/near/verify\", {\n\t\t\t\t\t\t\t\tmethod: \"POST\",\n\t\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\tsignedMessage,\n\t\t\t\t\t\t\t\t\tmessage,\n\t\t\t\t\t\t\t\t\trecipient,\n\t\t\t\t\t\t\t\t\tnonce: nonceHex,\n\t\t\t\t\t\t\t\t\taccountId,\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\n\t\t\t\t\t\t\tif (verifyResponse.error) {\n\t\t\t\t\t\t\t\tthrow new Error(verifyResponse.error.message || \"Failed to verify signature\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tif (!verifyResponse?.data?.success) {\n\t\t\t\t\t\t\t\tthrow new Error(\"Authentication verification failed\");\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tcallbacks?.onSuccess?.();\n\t\t\t\t\t\t\t$store.notify(\"$sessionSignal\");\n\t\t\t\t\t\t} catch (error) {\n\t\t\t\t\t\t\tconst err = error instanceof Error ? error : new Error(String(error));\n\t\t\t\t\t\t\tcallbacks?.onError?.(err);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t};\n\t\t}\n\t};\n\n\treturn plugin;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCA,MAAa,oBAAoB,EAAE,OAAO;CACzC,KAAK,EAAE,OAAO,EAAE,SAAS;CACzB,UAAU,EAAE,OAAO,EAAE,SAAS;AAC/B,CAAC;AAED,MAAa,gBAAgB,EAAE,OAAO;CACrC,MAAM,EAAE,OAAO,EAAE,SAAS;CAC1B,aAAa,EAAE,OAAO,EAAE,SAAS;CACjC,OAAO,kBAAkB,SAAS;CAClC,iBAAiB,kBAAkB,SAAS;CAC5C,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,EAAE,OAAO,CAAC,EAAE,SAAS;AACrD,CAAC;AAKD,MAAM,sBAAsB,EAAE,OAAO;CACpC,WAAW,EAAE,OAAO;CACpB,WAAW,EAAE,OAAO;CACpB,WAAW,EAAE,OAAO;CACpB,OAAO,EAAE,OAAO,EAAE,SAAS;AAC5B,CAAC;AAEiC,EAAE,OAAO;CAC1C,eAAe;CACf,SAAS,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,GAAG;MAClC,MAAM,UAAU,cAAc;MAE9B,MAAM,wBAAwB,WAAW,cAAc,WAAW,GAAG;MAErE,MAAM,iBAAuD,MAAM,OAAO,gBAAgB;OACzF,QAAQ;OACR,MAAM;QACL;QACA;QACA;QACA,OAAO;QACP;OACD;MACD,CAAC;MAED,IAAI,eAAe,OAClB,MAAM,IAAI,MAAM,eAAe,MAAM,WAAW,4BAA4B;MAG7E,IAAI,CAAC,gBAAgB,MAAM,SAC1B,MAAM,IAAI,MAAM,oCAAoC;MAGrD,WAAW,YAAY;MACvB,OAAO,OAAO,gBAAgB;KAC/B,SAAS,OAAO;MACf,MAAM,MAAM,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC;MACpE,WAAW,UAAU,GAAG;KACzB;IACD,EACD;GACD;EACD;CAGW;AACb"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,28 +1,16 @@
|
|
|
1
1
|
import type { DBAdapter } from "better-auth/types";
|
|
2
|
+
import type { AuthContext } from "@better-auth/core";
|
|
2
3
|
import z from "zod";
|
|
3
|
-
import { type AccountId, type DualNetworkConfig, type ListAccountsResponseT, type ListedNearAccount, type Profile, type SubAccountConfig } from "./types.js";
|
|
4
|
+
import { type AccountId, type DualNetworkConfig, type ListAccountsResponseT, type ListedNearAccount, type Profile, type RelayerConfig, type RelayerDualNetworkConfig, type SubAccountConfig } from "./types.js";
|
|
4
5
|
export * from "./types.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
interface RelayerExplicitConfig {
|
|
14
|
-
accountId: string;
|
|
15
|
-
privateKey: string;
|
|
16
|
-
privateKeys?: string[];
|
|
17
|
-
whitelistedContracts?: string[];
|
|
18
|
-
maxGasPerTransaction?: string;
|
|
19
|
-
maxDepositPerTransaction?: string;
|
|
20
|
-
}
|
|
21
|
-
interface RelayerDualNetworkConfig {
|
|
22
|
-
mainnet?: RelayerEphemeralConfig | RelayerExplicitConfig;
|
|
23
|
-
testnet?: RelayerEphemeralConfig | RelayerExplicitConfig;
|
|
24
|
-
}
|
|
25
|
-
export type RelayerConfig = true | RelayerEphemeralConfig | RelayerExplicitConfig | RelayerDualNetworkConfig;
|
|
6
|
+
type ParsedRelayerConfig = {
|
|
7
|
+
kind: "flat";
|
|
8
|
+
config: RelayerConfig;
|
|
9
|
+
} | {
|
|
10
|
+
kind: "dual";
|
|
11
|
+
config: RelayerDualNetworkConfig;
|
|
12
|
+
};
|
|
13
|
+
export declare function parseRelayerConfig(input: RelayerConfig | RelayerDualNetworkConfig | undefined): ParsedRelayerConfig | undefined;
|
|
26
14
|
export interface SIWNPluginOptions {
|
|
27
15
|
recipient?: string;
|
|
28
16
|
recipients?: DualNetworkConfig<string>;
|
|
@@ -36,7 +24,7 @@ export interface SIWNPluginOptions {
|
|
|
36
24
|
}) => Promise<boolean>;
|
|
37
25
|
apiKey?: string;
|
|
38
26
|
rpcUrl?: string | DualNetworkConfig<string>;
|
|
39
|
-
relayer?: RelayerConfig |
|
|
27
|
+
relayer?: RelayerConfig | RelayerDualNetworkConfig;
|
|
40
28
|
secrets?: {
|
|
41
29
|
parentKey?: string | DualNetworkConfig<string>;
|
|
42
30
|
};
|
|
@@ -150,6 +138,7 @@ export declare const siwn: (options: SIWNPluginOptions) => {
|
|
|
150
138
|
};
|
|
151
139
|
};
|
|
152
140
|
};
|
|
141
|
+
init: (ctx: AuthContext) => void;
|
|
153
142
|
hooks: {
|
|
154
143
|
after: {
|
|
155
144
|
matcher: (context: {
|
|
@@ -160,7 +149,7 @@ export declare const siwn: (options: SIWNPluginOptions) => {
|
|
|
160
149
|
context: import("better-call").MiddlewareContext<import("better-call").MiddlewareOptions, {
|
|
161
150
|
returned?: unknown | undefined;
|
|
162
151
|
responseHeaders?: Headers | undefined;
|
|
163
|
-
} & import("better-auth").PluginContext<import("better-auth/types").BetterAuthOptions> & import("better-auth").InfoContext & {
|
|
152
|
+
} & import("@better-auth/core").PluginContext<import("better-auth/types").BetterAuthOptions> & import("@better-auth/core").InfoContext & {
|
|
164
153
|
options: import("better-auth/types").BetterAuthOptions;
|
|
165
154
|
trustedOrigins: string[];
|
|
166
155
|
trustedProviders: string[];
|
|
@@ -244,10 +233,10 @@ export declare const siwn: (options: SIWNPluginOptions) => {
|
|
|
244
233
|
storage: "memory" | "database" | "secondary-storage";
|
|
245
234
|
} & Omit<import("better-auth/types").BetterAuthRateLimitOptions, "enabled" | "window" | "max" | "storage">;
|
|
246
235
|
adapter: DBAdapter<import("better-auth/types").BetterAuthOptions>;
|
|
247
|
-
internalAdapter: import("better-auth").InternalAdapter<import("better-auth/types").BetterAuthOptions>;
|
|
248
|
-
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("better-auth").BetterAuthCookie;
|
|
236
|
+
internalAdapter: import("@better-auth/core").InternalAdapter<import("better-auth/types").BetterAuthOptions>;
|
|
237
|
+
createAuthCookie: (cookieName: string, overrideAttributes?: Partial<import("better-call").CookieOptions> | undefined) => import("@better-auth/core").BetterAuthCookie;
|
|
249
238
|
secret: string;
|
|
250
|
-
secretConfig: string | import("better-auth").SecretConfig;
|
|
239
|
+
secretConfig: string | import("@better-auth/core").SecretConfig;
|
|
251
240
|
sessionConfig: {
|
|
252
241
|
updateAge: number;
|
|
253
242
|
expiresIn: number;
|
|
@@ -272,7 +261,7 @@ export declare const siwn: (options: SIWNPluginOptions) => {
|
|
|
272
261
|
minPasswordLength: number;
|
|
273
262
|
maxPasswordLength: number;
|
|
274
263
|
};
|
|
275
|
-
checkPassword: (userId: string, ctx: import("better-auth").GenericEndpointContext<import("better-auth/types").BetterAuthOptions>) => Promise<boolean>;
|
|
264
|
+
checkPassword: (userId: string, ctx: import("@better-auth/core").GenericEndpointContext<import("better-auth/types").BetterAuthOptions>) => Promise<boolean>;
|
|
276
265
|
};
|
|
277
266
|
tables: import("better-auth").BetterAuthDBSchema;
|
|
278
267
|
runMigrations: () => Promise<void>;
|
|
@@ -284,7 +273,7 @@ export declare const siwn: (options: SIWNPluginOptions) => {
|
|
|
284
273
|
skipOriginCheck: boolean | string[];
|
|
285
274
|
skipCSRFCheck: boolean;
|
|
286
275
|
runInBackground: (promise: Promise<unknown>) => void;
|
|
287
|
-
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("better-auth").Awaitable<unknown>;
|
|
276
|
+
runInBackgroundOrAwait: (promise: Promise<unknown> | void) => import("@better-auth/core").Awaitable<unknown>;
|
|
288
277
|
}>;
|
|
289
278
|
}>;
|
|
290
279
|
}[];
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAKlE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAMrD,OAAO,CAAC,MAAM,KAAK,CAAC;AAGpB,OAAO,EACN,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,qBAAqB,EAC1B,KAAK,iBAAiB,EAEtB,KAAK,OAAO,EAGZ,KAAK,aAAa,EAClB,KAAK,wBAAwB,EAC7B,KAAK,gBAAgB,EAuBrB,MAAM,YAAY,CAAC;AACpB,cAAc,YAAY,CAAC;AA2E3B,KAAK,mBAAmB,GACrB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,aAAa,CAAA;CAAE,GACvC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,wBAAwB,CAAA;CAAE,CAAC;AAEtD,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,aAAa,G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