@solana/kora 0.2.0 → 0.3.0-beta.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/dist/src/client.d.ts +201 -7
- package/dist/src/client.js +223 -18
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/kit/executor.js +18 -5
- package/dist/src/kit/index.d.ts +4 -1
- package/dist/src/kit/index.js +10 -2
- package/dist/src/kit/payment.js +3 -2
- package/dist/src/plugin.d.ts +85 -0
- package/dist/src/{kit/plugin.js → plugin.js} +88 -18
- package/dist/src/types/index.d.ts +173 -78
- package/dist/test/auth-setup.js +4 -4
- package/dist/test/integration.test.js +168 -291
- package/dist/test/kit-client.test.js +18 -0
- package/dist/test/plugin.test.js +126 -71
- package/dist/test/setup.d.ts +8 -15
- package/dist/test/setup.js +52 -152
- package/dist/test/unit.test.js +318 -166
- package/package.json +8 -16
- package/dist/src/kit/plugin.d.ts +0 -31
|
@@ -1,22 +1,7 @@
|
|
|
1
|
-
import { Instruction, TransactionSigner } from '@solana/kit';
|
|
1
|
+
import { Instruction, type MicroLamports, type TransactionSigner } from '@solana/kit';
|
|
2
2
|
/**
|
|
3
3
|
* Request Types
|
|
4
4
|
*/
|
|
5
|
-
/**
|
|
6
|
-
* Parameters for creating a token transfer transaction.
|
|
7
|
-
*/
|
|
8
|
-
export interface TransferTransactionRequest {
|
|
9
|
-
/** Amount to transfer in the token's smallest unit (e.g., lamports for SOL) */
|
|
10
|
-
amount: number;
|
|
11
|
-
/** Public key of the destination wallet (not token account) */
|
|
12
|
-
destination: string;
|
|
13
|
-
/** Optional signer address for the transaction */
|
|
14
|
-
signer_key?: string;
|
|
15
|
-
/** Public key of the source wallet (not token account) */
|
|
16
|
-
source: string;
|
|
17
|
-
/** Mint address of the token to transfer */
|
|
18
|
-
token: string;
|
|
19
|
-
}
|
|
20
5
|
/**
|
|
21
6
|
* Parameters for signing a transaction.
|
|
22
7
|
*/
|
|
@@ -27,6 +12,8 @@ export interface SignTransactionRequest {
|
|
|
27
12
|
signer_key?: string;
|
|
28
13
|
/** Base64-encoded transaction to sign */
|
|
29
14
|
transaction: string;
|
|
15
|
+
/** Optional user ID for usage tracking (required when pricing is free and usage tracking is enabled) */
|
|
16
|
+
user_id?: string;
|
|
30
17
|
}
|
|
31
18
|
/**
|
|
32
19
|
* Parameters for signing and sending a transaction.
|
|
@@ -38,13 +25,45 @@ export interface SignAndSendTransactionRequest {
|
|
|
38
25
|
signer_key?: string;
|
|
39
26
|
/** Base64-encoded transaction to sign and send */
|
|
40
27
|
transaction: string;
|
|
28
|
+
/** Optional user ID for usage tracking (required when pricing is free and usage tracking is enabled) */
|
|
29
|
+
user_id?: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Parameters for signing a bundle of transactions.
|
|
33
|
+
*/
|
|
34
|
+
export interface SignBundleRequest {
|
|
35
|
+
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
36
|
+
sig_verify?: boolean;
|
|
37
|
+
/** Optional indices of transactions to sign (defaults to all if not specified) */
|
|
38
|
+
sign_only_indices?: number[];
|
|
39
|
+
/** Optional signer address for the transactions */
|
|
40
|
+
signer_key?: string;
|
|
41
|
+
/** Array of base64-encoded transactions to sign */
|
|
42
|
+
transactions: string[];
|
|
43
|
+
/** Optional user ID for usage tracking (required when pricing is free and usage tracking is enabled) */
|
|
44
|
+
user_id?: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Parameters for signing and sending a bundle of transactions via Jito.
|
|
48
|
+
*/
|
|
49
|
+
export interface SignAndSendBundleRequest {
|
|
50
|
+
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
51
|
+
sig_verify?: boolean;
|
|
52
|
+
/** Optional indices of transactions to sign (defaults to all if not specified) */
|
|
53
|
+
sign_only_indices?: number[];
|
|
54
|
+
/** Optional signer address for the transactions */
|
|
55
|
+
signer_key?: string;
|
|
56
|
+
/** Array of base64-encoded transactions to sign and send */
|
|
57
|
+
transactions: string[];
|
|
58
|
+
/** Optional user ID for usage tracking (required when pricing is free and usage tracking is enabled) */
|
|
59
|
+
user_id?: string;
|
|
41
60
|
}
|
|
42
61
|
/**
|
|
43
62
|
* Parameters for estimating transaction fees.
|
|
44
63
|
*/
|
|
45
64
|
export interface EstimateTransactionFeeRequest {
|
|
46
65
|
/** Mint address of the token to calculate fees in */
|
|
47
|
-
fee_token
|
|
66
|
+
fee_token?: string;
|
|
48
67
|
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
49
68
|
sig_verify?: boolean;
|
|
50
69
|
/** Optional signer address for the transaction */
|
|
@@ -52,6 +71,21 @@ export interface EstimateTransactionFeeRequest {
|
|
|
52
71
|
/** Base64-encoded transaction to estimate fees for */
|
|
53
72
|
transaction: string;
|
|
54
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Parameters for estimating bundle fees.
|
|
76
|
+
*/
|
|
77
|
+
export interface EstimateBundleFeeRequest {
|
|
78
|
+
/** Mint address of the token to calculate fees in */
|
|
79
|
+
fee_token?: string;
|
|
80
|
+
/** Optional signer verification during transaction simulation (defaults to false) */
|
|
81
|
+
sig_verify?: boolean;
|
|
82
|
+
/** Optional indices of transactions to estimate fees for (defaults to all if not specified) */
|
|
83
|
+
sign_only_indices?: number[];
|
|
84
|
+
/** Optional signer address for the transactions */
|
|
85
|
+
signer_key?: string;
|
|
86
|
+
/** Array of base64-encoded transactions to estimate fees for */
|
|
87
|
+
transactions: string[];
|
|
88
|
+
}
|
|
55
89
|
/**
|
|
56
90
|
* Parameters for getting a payment instruction.
|
|
57
91
|
*/
|
|
@@ -62,8 +96,11 @@ export interface GetPaymentInstructionRequest {
|
|
|
62
96
|
sig_verify?: boolean;
|
|
63
97
|
/** Optional signer address for the transaction */
|
|
64
98
|
signer_key?: string;
|
|
65
|
-
/** The wallet owner
|
|
66
|
-
|
|
99
|
+
/** The wallet owner that will be making the token payment.
|
|
100
|
+
* Accepts a plain address string or a TransactionSigner. When a TransactionSigner is provided,
|
|
101
|
+
* it is used as the transfer authority on the payment instruction, preserving signer identity
|
|
102
|
+
* and avoiding conflicts with other instructions that reference the same address. */
|
|
103
|
+
source_wallet: TransactionSigner | string;
|
|
67
104
|
/** The token program id to use for the payment (defaults to TOKEN_PROGRAM_ID) */
|
|
68
105
|
token_program_id?: string;
|
|
69
106
|
/** Base64-encoded transaction to estimate fees for */
|
|
@@ -72,21 +109,6 @@ export interface GetPaymentInstructionRequest {
|
|
|
72
109
|
/**
|
|
73
110
|
* Response Types
|
|
74
111
|
*/
|
|
75
|
-
/**
|
|
76
|
-
* Response from creating a transfer transaction.
|
|
77
|
-
*/
|
|
78
|
-
export interface TransferTransactionResponse {
|
|
79
|
-
/** Recent blockhash used in the transaction */
|
|
80
|
-
blockhash: string;
|
|
81
|
-
/** Parsed instructions from the transaction message */
|
|
82
|
-
instructions: Instruction[];
|
|
83
|
-
/** Base64-encoded message */
|
|
84
|
-
message: string;
|
|
85
|
-
/** Public key of the signer used to send the transaction */
|
|
86
|
-
signer_pubkey: string;
|
|
87
|
-
/** Base64-encoded signed transaction */
|
|
88
|
-
transaction: string;
|
|
89
|
-
}
|
|
90
112
|
/**
|
|
91
113
|
* Response from signing a transaction.
|
|
92
114
|
*/
|
|
@@ -107,6 +129,26 @@ export interface SignAndSendTransactionResponse {
|
|
|
107
129
|
/** Public key of the signer used to send the transaction */
|
|
108
130
|
signer_pubkey: string;
|
|
109
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Response from signing a bundle of transactions.
|
|
134
|
+
*/
|
|
135
|
+
export interface SignBundleResponse {
|
|
136
|
+
/** Array of base64-encoded signed transactions */
|
|
137
|
+
signed_transactions: string[];
|
|
138
|
+
/** Public key of the signer used to sign the transactions */
|
|
139
|
+
signer_pubkey: string;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Response from signing and sending a bundle of transactions via Jito.
|
|
143
|
+
*/
|
|
144
|
+
export interface SignAndSendBundleResponse {
|
|
145
|
+
/** UUID of the submitted Jito bundle */
|
|
146
|
+
bundle_uuid: string;
|
|
147
|
+
/** Array of base64-encoded signed transactions */
|
|
148
|
+
signed_transactions: string[];
|
|
149
|
+
/** Public key of the signer used to sign the transactions */
|
|
150
|
+
signer_pubkey: string;
|
|
151
|
+
}
|
|
110
152
|
/**
|
|
111
153
|
* Response containing the latest blockhash.
|
|
112
154
|
*/
|
|
@@ -114,6 +156,13 @@ export interface GetBlockhashResponse {
|
|
|
114
156
|
/** Base58-encoded blockhash */
|
|
115
157
|
blockhash: string;
|
|
116
158
|
}
|
|
159
|
+
/**
|
|
160
|
+
* Response containing the server version.
|
|
161
|
+
*/
|
|
162
|
+
export interface GetVersionResponse {
|
|
163
|
+
/** Server version string */
|
|
164
|
+
version: string;
|
|
165
|
+
}
|
|
117
166
|
/**
|
|
118
167
|
* Response containing supported token mint addresses.
|
|
119
168
|
*/
|
|
@@ -130,7 +179,22 @@ export interface EstimateTransactionFeeResponse {
|
|
|
130
179
|
/**
|
|
131
180
|
* Transaction fee in the requested token (in decimals value of the token, e.g. 10^6 for USDC)
|
|
132
181
|
*/
|
|
133
|
-
fee_in_token
|
|
182
|
+
fee_in_token?: number;
|
|
183
|
+
/** Public key of the payment destination */
|
|
184
|
+
payment_address: string;
|
|
185
|
+
/** Public key of the signer used to estimate the fee */
|
|
186
|
+
signer_pubkey: string;
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Response containing estimated bundle fees.
|
|
190
|
+
*/
|
|
191
|
+
export interface EstimateBundleFeeResponse {
|
|
192
|
+
/** Total bundle fee in lamports across all transactions */
|
|
193
|
+
fee_in_lamports: number;
|
|
194
|
+
/**
|
|
195
|
+
* Total bundle fee in the requested token (in decimals value of the token, e.g. 10^6 for USDC)
|
|
196
|
+
*/
|
|
197
|
+
fee_in_token?: number;
|
|
134
198
|
/** Public key of the payment destination */
|
|
135
199
|
payment_address: string;
|
|
136
200
|
/** Public key of the signer used to estimate the fee */
|
|
@@ -159,8 +223,6 @@ export interface GetPaymentInstructionResponse {
|
|
|
159
223
|
payment_instruction: Instruction;
|
|
160
224
|
/** Mint address of the token used for payment */
|
|
161
225
|
payment_token: string;
|
|
162
|
-
/** NoopSigner for the source wallet authority — reuse this in your transaction to avoid duplicate signer conflicts */
|
|
163
|
-
signer: TransactionSigner;
|
|
164
226
|
/** Public key of the payer signer */
|
|
165
227
|
signer_address: string;
|
|
166
228
|
}
|
|
@@ -224,18 +286,28 @@ export type PriceConfig = PriceModel;
|
|
|
224
286
|
* Enabled status for methods for the Kora server.
|
|
225
287
|
*/
|
|
226
288
|
export interface EnabledMethods {
|
|
289
|
+
/** Whether the estimate_bundle_fee method is enabled (requires bundle.enabled = true) */
|
|
290
|
+
estimate_bundle_fee: boolean;
|
|
227
291
|
/** Whether the estimate_transaction_fee method is enabled */
|
|
228
292
|
estimate_transaction_fee: boolean;
|
|
229
293
|
/** Whether the get_blockhash method is enabled */
|
|
230
294
|
get_blockhash: boolean;
|
|
231
295
|
/** Whether the get_config method is enabled */
|
|
232
296
|
get_config: boolean;
|
|
297
|
+
/** Whether the get_payer_signer method is enabled */
|
|
298
|
+
get_payer_signer: boolean;
|
|
233
299
|
/** Whether the get_supported_tokens method is enabled */
|
|
234
300
|
get_supported_tokens: boolean;
|
|
301
|
+
/** Whether the get_version method is enabled */
|
|
302
|
+
get_version: boolean;
|
|
235
303
|
/** Whether the liveness method is enabled */
|
|
236
304
|
liveness: boolean;
|
|
305
|
+
/** Whether the sign_and_send_bundle method is enabled (requires bundle.enabled = true) */
|
|
306
|
+
sign_and_send_bundle: boolean;
|
|
237
307
|
/** Whether the sign_and_send_transaction method is enabled */
|
|
238
308
|
sign_and_send_transaction: boolean;
|
|
309
|
+
/** Whether the sign_bundle method is enabled (requires bundle.enabled = true) */
|
|
310
|
+
sign_bundle: boolean;
|
|
239
311
|
/** Whether the sign_transaction method is enabled */
|
|
240
312
|
sign_transaction: boolean;
|
|
241
313
|
/** Whether the transfer_transaction method is enabled */
|
|
@@ -292,6 +364,12 @@ export interface SplTokenInstructionPolicy {
|
|
|
292
364
|
allow_close_account: boolean;
|
|
293
365
|
/** Allow fee payer to freeze SPL token accounts */
|
|
294
366
|
allow_freeze_account: boolean;
|
|
367
|
+
/** Allow fee payer to initialize SPL token accounts */
|
|
368
|
+
allow_initialize_account: boolean;
|
|
369
|
+
/** Allow fee payer to initialize SPL token mints */
|
|
370
|
+
allow_initialize_mint: boolean;
|
|
371
|
+
/** Allow fee payer to initialize SPL multisig accounts */
|
|
372
|
+
allow_initialize_multisig: boolean;
|
|
295
373
|
/** Allow fee payer to mint SPL tokens */
|
|
296
374
|
allow_mint_to: boolean;
|
|
297
375
|
/** Allow fee payer to revoke SPL token delegates */
|
|
@@ -315,6 +393,12 @@ export interface Token2022InstructionPolicy {
|
|
|
315
393
|
allow_close_account: boolean;
|
|
316
394
|
/** Allow fee payer to freeze Token2022 accounts */
|
|
317
395
|
allow_freeze_account: boolean;
|
|
396
|
+
/** Allow fee payer to initialize Token2022 accounts */
|
|
397
|
+
allow_initialize_account: boolean;
|
|
398
|
+
/** Allow fee payer to initialize Token2022 mints */
|
|
399
|
+
allow_initialize_mint: boolean;
|
|
400
|
+
/** Allow fee payer to initialize Token2022 multisig accounts */
|
|
401
|
+
allow_initialize_multisig: boolean;
|
|
318
402
|
/** Allow fee payer to mint Token2022 tokens */
|
|
319
403
|
allow_mint_to: boolean;
|
|
320
404
|
/** Allow fee payer to revoke Token2022 delegates */
|
|
@@ -371,6 +455,8 @@ export interface AuthenticationHeaders {
|
|
|
371
455
|
'x-api-key'?: string;
|
|
372
456
|
/** HMAC SHA256 signature of timestamp + body */
|
|
373
457
|
'x-hmac-signature'?: string;
|
|
458
|
+
/** reCAPTCHA v3 token for bot protection */
|
|
459
|
+
'x-recaptcha-token'?: string;
|
|
374
460
|
/** Unix timestamp for HMAC authentication */
|
|
375
461
|
'x-timestamp'?: string;
|
|
376
462
|
}
|
|
@@ -380,6 +466,13 @@ export interface AuthenticationHeaders {
|
|
|
380
466
|
export interface KoraClientOptions {
|
|
381
467
|
/** Optional API key for authentication */
|
|
382
468
|
apiKey?: string;
|
|
469
|
+
/**
|
|
470
|
+
* Optional callback to get a reCAPTCHA v3 token for bot protection.
|
|
471
|
+
* Called for every request when provided; server determines which methods require it.
|
|
472
|
+
* @example Browser: `() => grecaptcha.execute('site-key', { action: 'sign' })`
|
|
473
|
+
* @example Testing: `() => 'test-token'`
|
|
474
|
+
*/
|
|
475
|
+
getRecaptchaToken?: () => Promise<string> | string;
|
|
383
476
|
/** Optional HMAC secret for signature-based authentication */
|
|
384
477
|
hmacSecret?: string;
|
|
385
478
|
/** URL of the Kora RPC server */
|
|
@@ -388,15 +481,25 @@ export interface KoraClientOptions {
|
|
|
388
481
|
/**
|
|
389
482
|
* Plugin Types - Kit-typed responses for the Kora plugin
|
|
390
483
|
*/
|
|
391
|
-
import type { Address, Base64EncodedWireTransaction, Blockhash, Instruction as KitInstruction,
|
|
484
|
+
import type { Address, Base64EncodedWireTransaction, Blockhash, Instruction as KitInstruction, Signature } from '@solana/kit';
|
|
485
|
+
import { KoraClient } from '../client.js';
|
|
392
486
|
/** Configuration options for the Kora Kit plugin */
|
|
393
487
|
export interface KoraPluginConfig {
|
|
394
488
|
/** Optional API key for authentication */
|
|
395
489
|
apiKey?: string;
|
|
396
490
|
/** Kora RPC endpoint URL */
|
|
397
491
|
endpoint: string;
|
|
492
|
+
/**
|
|
493
|
+
* Optional callback to get a reCAPTCHA v3 token for bot protection.
|
|
494
|
+
* Called for every request when provided; server determines which methods require it.
|
|
495
|
+
* @example Browser: `() => grecaptcha.execute('site-key', { action: 'sign' })`
|
|
496
|
+
* @example Testing: `() => 'test-token'`
|
|
497
|
+
*/
|
|
498
|
+
getRecaptchaToken?: () => Promise<string> | string;
|
|
398
499
|
/** Optional HMAC secret for signature-based authentication */
|
|
399
500
|
hmacSecret?: string;
|
|
501
|
+
/** Existing Kora Client for reusing existing instance */
|
|
502
|
+
koraClient?: KoraClient;
|
|
400
503
|
}
|
|
401
504
|
/** Plugin response for getPayerSigner with Kit Address types */
|
|
402
505
|
export interface KitPayerSignerResponse {
|
|
@@ -420,7 +523,7 @@ export interface KitEstimateFeeResponse {
|
|
|
420
523
|
/** Transaction fee in lamports */
|
|
421
524
|
fee_in_lamports: number;
|
|
422
525
|
/** Transaction fee in the requested token */
|
|
423
|
-
fee_in_token
|
|
526
|
+
fee_in_token?: number;
|
|
424
527
|
/** Public key of the payment destination */
|
|
425
528
|
payment_address: Address;
|
|
426
529
|
/** Public key of the signer used to estimate the fee */
|
|
@@ -442,19 +545,6 @@ export interface KitSignAndSendTransactionResponse {
|
|
|
442
545
|
/** Public key of the signer used to send the transaction */
|
|
443
546
|
signer_pubkey: Address;
|
|
444
547
|
}
|
|
445
|
-
/** Plugin response for transferTransaction with Kit types */
|
|
446
|
-
export interface KitTransferTransactionResponse {
|
|
447
|
-
/** Recent blockhash used in the transaction */
|
|
448
|
-
blockhash: Blockhash;
|
|
449
|
-
/** Parsed instructions from the transaction message */
|
|
450
|
-
instructions: KitInstruction[];
|
|
451
|
-
/** Base64-encoded message */
|
|
452
|
-
message: string;
|
|
453
|
-
/** Public key of the signer used to send the transaction */
|
|
454
|
-
signer_pubkey: Address;
|
|
455
|
-
/** Base64-encoded signed transaction */
|
|
456
|
-
transaction: Base64EncodedWireTransaction;
|
|
457
|
-
}
|
|
458
548
|
/** Plugin response for getPaymentInstruction with Kit types */
|
|
459
549
|
export interface KitPaymentInstructionResponse {
|
|
460
550
|
/** Base64-encoded original transaction */
|
|
@@ -479,6 +569,33 @@ export interface KitConfigResponse {
|
|
|
479
569
|
/** Validation rules and constraints */
|
|
480
570
|
validation_config: KitValidationConfig;
|
|
481
571
|
}
|
|
572
|
+
/** Plugin response for estimateBundleFee with Kit types */
|
|
573
|
+
export interface KitEstimateBundleFeeResponse {
|
|
574
|
+
/** Total bundle fee in lamports across all transactions */
|
|
575
|
+
fee_in_lamports: number;
|
|
576
|
+
/** Total bundle fee in the requested token */
|
|
577
|
+
fee_in_token?: number;
|
|
578
|
+
/** Public key of the payment destination */
|
|
579
|
+
payment_address: Address;
|
|
580
|
+
/** Public key of the signer used to estimate the fee */
|
|
581
|
+
signer_pubkey: Address;
|
|
582
|
+
}
|
|
583
|
+
/** Plugin response for signBundle with Kit types */
|
|
584
|
+
export interface KitSignBundleResponse {
|
|
585
|
+
/** Array of base64-encoded signed transactions */
|
|
586
|
+
signed_transactions: Base64EncodedWireTransaction[];
|
|
587
|
+
/** Public key of the signer used to sign the transactions */
|
|
588
|
+
signer_pubkey: Address;
|
|
589
|
+
}
|
|
590
|
+
/** Plugin response for signAndSendBundle with Kit types */
|
|
591
|
+
export interface KitSignAndSendBundleResponse {
|
|
592
|
+
/** UUID of the submitted Jito bundle */
|
|
593
|
+
bundle_uuid: string;
|
|
594
|
+
/** Array of base64-encoded signed transactions */
|
|
595
|
+
signed_transactions: Base64EncodedWireTransaction[];
|
|
596
|
+
/** Public key of the signer used to sign the transactions */
|
|
597
|
+
signer_pubkey: Address;
|
|
598
|
+
}
|
|
482
599
|
/** Plugin validation config with Kit Address types */
|
|
483
600
|
export interface KitValidationConfig {
|
|
484
601
|
/** List of allowed Solana program IDs */
|
|
@@ -503,41 +620,19 @@ export interface KitValidationConfig {
|
|
|
503
620
|
token2022: Token2022Config;
|
|
504
621
|
}
|
|
505
622
|
/**
|
|
506
|
-
*
|
|
507
|
-
*
|
|
508
|
-
* @example
|
|
509
|
-
* ```ts
|
|
510
|
-
* const client = await createKitKoraClient({
|
|
511
|
-
* endpoint: 'https://kora.example.com',
|
|
512
|
-
* rpcUrl: 'https://api.mainnet-beta.solana.com',
|
|
513
|
-
* feeToken: address('EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'),
|
|
514
|
-
* feePayerWallet: myWalletSigner, // TransactionSigner that authorizes SPL fee payment
|
|
515
|
-
* });
|
|
516
|
-
* ```
|
|
623
|
+
* Kit Client Types
|
|
517
624
|
*/
|
|
625
|
+
/** Configuration for {@link createKitKoraClient}. */
|
|
518
626
|
export interface KoraKitClientConfig {
|
|
519
|
-
/** Optional API key for authentication */
|
|
520
627
|
readonly apiKey?: string;
|
|
521
|
-
/** Optional compute unit limit (uses provisory/simulation if not set) */
|
|
522
628
|
readonly computeUnitLimit?: number;
|
|
523
|
-
/** Optional priority fee in micro-lamports */
|
|
524
629
|
readonly computeUnitPrice?: MicroLamports;
|
|
525
|
-
/** Kora RPC endpoint URL */
|
|
526
630
|
readonly endpoint: string;
|
|
527
|
-
/** Wallet signer paying SPL fees (must be a real signer so the payment transfer is authorized) */
|
|
528
631
|
readonly feePayerWallet: TransactionSigner;
|
|
529
|
-
/** SPL mint address for fee payment */
|
|
530
632
|
readonly feeToken: Address;
|
|
531
|
-
|
|
633
|
+
readonly getRecaptchaToken?: () => Promise<string> | string;
|
|
532
634
|
readonly hmacSecret?: string;
|
|
533
|
-
/**
|
|
534
|
-
* Solana RPC URL used for compute unit estimation and program plugin compatibility.
|
|
535
|
-
* The client simulates transactions against this RPC node to determine optimal
|
|
536
|
-
* compute unit limits (resulting in lower fees), and exposes it as `ClientWithRpc`
|
|
537
|
-
* so Kit program plugins like `tokenProgram()` work out of the box.
|
|
538
|
-
* This must be a direct Solana RPC URL (not the Kora endpoint).
|
|
539
|
-
*/
|
|
540
635
|
readonly rpcUrl: string;
|
|
541
|
-
/** Token program ID for fee payment (defaults to TOKEN_PROGRAM_ADDRESS; use TOKEN_2022_PROGRAM_ADDRESS for Token-2022) */
|
|
542
636
|
readonly tokenProgramId?: Address;
|
|
637
|
+
readonly userId?: string;
|
|
543
638
|
}
|
package/dist/test/auth-setup.js
CHANGED
|
@@ -5,34 +5,34 @@ export function runAuthenticationTests() {
|
|
|
5
5
|
describe('Authentication', () => {
|
|
6
6
|
it('should fail with incorrect API key', async () => {
|
|
7
7
|
const client = new KoraClient({
|
|
8
|
-
rpcUrl: koraRpcUrl,
|
|
9
8
|
apiKey: 'WRONG-API-KEY',
|
|
9
|
+
rpcUrl: koraRpcUrl,
|
|
10
10
|
});
|
|
11
11
|
// Auth failure should result in an error (empty response body causes JSON parse error)
|
|
12
12
|
await expect(client.getConfig()).rejects.toThrow();
|
|
13
13
|
});
|
|
14
14
|
it('should fail with incorrect HMAC secret', async () => {
|
|
15
15
|
const client = new KoraClient({
|
|
16
|
-
rpcUrl: koraRpcUrl,
|
|
17
16
|
hmacSecret: 'WRONG-HMAC-SECRET',
|
|
17
|
+
rpcUrl: koraRpcUrl,
|
|
18
18
|
});
|
|
19
19
|
// Auth failure should result in an error
|
|
20
20
|
await expect(client.getConfig()).rejects.toThrow();
|
|
21
21
|
});
|
|
22
22
|
it('should fail with both incorrect credentials', async () => {
|
|
23
23
|
const client = new KoraClient({
|
|
24
|
-
rpcUrl: koraRpcUrl,
|
|
25
24
|
apiKey: 'WRONG-API-KEY',
|
|
26
25
|
hmacSecret: 'WRONG-HMAC-SECRET',
|
|
26
|
+
rpcUrl: koraRpcUrl,
|
|
27
27
|
});
|
|
28
28
|
// Auth failure should result in an error
|
|
29
29
|
await expect(client.getConfig()).rejects.toThrow();
|
|
30
30
|
});
|
|
31
31
|
it('should succeed with correct credentials', async () => {
|
|
32
32
|
const client = new KoraClient({
|
|
33
|
-
rpcUrl: koraRpcUrl,
|
|
34
33
|
apiKey: 'test-api-key-123',
|
|
35
34
|
hmacSecret: 'test-hmac-secret-456',
|
|
35
|
+
rpcUrl: koraRpcUrl,
|
|
36
36
|
});
|
|
37
37
|
const config = await client.getConfig();
|
|
38
38
|
expect(config).toBeDefined();
|