kentucky-signer-viem 0.1.1 → 0.1.3
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 +195 -218
- package/dist/index.d.mts +802 -7
- package/dist/index.d.ts +802 -7
- package/dist/index.js +964 -37
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +955 -37
- package/dist/index.mjs.map +1 -1
- package/dist/react/index.d.mts +61 -3
- package/dist/react/index.d.ts +61 -3
- package/dist/react/index.js +1286 -173
- package/dist/react/index.js.map +1 -1
- package/dist/react/index.mjs +1288 -174
- package/dist/react/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/account.ts +111 -22
- package/src/auth.ts +16 -6
- package/src/client.ts +438 -18
- package/src/ephemeral.ts +407 -0
- package/src/index.ts +56 -0
- package/src/react/context.tsx +360 -45
- package/src/react/hooks.ts +11 -0
- package/src/react/index.ts +1 -0
- package/src/secure-client.ts +417 -0
- package/src/types.ts +332 -0
package/src/types.ts
CHANGED
|
@@ -129,6 +129,8 @@ export interface PasskeyAuthOptions {
|
|
|
129
129
|
rpId?: string
|
|
130
130
|
/** Credential IDs to allow (if known) */
|
|
131
131
|
allowCredentials?: string[]
|
|
132
|
+
/** Optional ephemeral public key for secure mode binding (base64url encoded) */
|
|
133
|
+
ephemeralPublicKey?: string
|
|
132
134
|
}
|
|
133
135
|
|
|
134
136
|
/**
|
|
@@ -202,6 +204,8 @@ export interface PasswordAuthOptions {
|
|
|
202
204
|
accountId: string
|
|
203
205
|
/** Password for authentication */
|
|
204
206
|
password: string
|
|
207
|
+
/** Optional ephemeral public key for secure mode binding (base64url encoded) */
|
|
208
|
+
ephemeralPublicKey?: string
|
|
205
209
|
}
|
|
206
210
|
|
|
207
211
|
/**
|
|
@@ -235,3 +239,331 @@ export interface PasswordAuthRequest {
|
|
|
235
239
|
/** Password */
|
|
236
240
|
password: string
|
|
237
241
|
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Add password request
|
|
245
|
+
*/
|
|
246
|
+
export interface AddPasswordRequest {
|
|
247
|
+
/** Password for the account (8-128 characters) */
|
|
248
|
+
password: string
|
|
249
|
+
/** Password confirmation (must match password) */
|
|
250
|
+
confirmation: string
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Add password response
|
|
255
|
+
*/
|
|
256
|
+
export interface AddPasswordResponse {
|
|
257
|
+
success: boolean
|
|
258
|
+
message: string
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
/**
|
|
262
|
+
* Add passkey request (using attestation object - simpler)
|
|
263
|
+
*/
|
|
264
|
+
export interface AddPasskeyRequest {
|
|
265
|
+
/** WebAuthn attestation object (base64url) - server extracts COSE key automatically */
|
|
266
|
+
attestation_object: string
|
|
267
|
+
/** User-friendly label for the passkey */
|
|
268
|
+
label?: string
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Add passkey response
|
|
273
|
+
*/
|
|
274
|
+
export interface AddPasskeyResponse {
|
|
275
|
+
success: boolean
|
|
276
|
+
message: string
|
|
277
|
+
label: string
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Remove passkey response
|
|
282
|
+
*/
|
|
283
|
+
export interface RemovePasskeyResponse {
|
|
284
|
+
success: boolean
|
|
285
|
+
message: string
|
|
286
|
+
passkey_index: number
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/**
|
|
290
|
+
* Extended authentication response with ephemeral key binding
|
|
291
|
+
*/
|
|
292
|
+
export interface AuthResponseWithEphemeral extends AuthResponse {
|
|
293
|
+
/** Whether ephemeral key was bound to the token */
|
|
294
|
+
ephemeral_bound: boolean
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
/**
|
|
298
|
+
* Auth configuration from account info
|
|
299
|
+
*/
|
|
300
|
+
export interface AuthConfig {
|
|
301
|
+
passkey: boolean
|
|
302
|
+
password: boolean
|
|
303
|
+
pin_4: boolean
|
|
304
|
+
pin_6: boolean
|
|
305
|
+
totp: boolean
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* Extended account info response with auth config
|
|
310
|
+
*/
|
|
311
|
+
export interface AccountInfoExtendedResponse {
|
|
312
|
+
success: boolean
|
|
313
|
+
account_id: string
|
|
314
|
+
addresses: {
|
|
315
|
+
evm: string
|
|
316
|
+
bitcoin: string
|
|
317
|
+
solana: string
|
|
318
|
+
}
|
|
319
|
+
auth_config: AuthConfig
|
|
320
|
+
passkey_count: number
|
|
321
|
+
guardian_count?: number
|
|
322
|
+
recovery_active?: boolean
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// ============================================================================
|
|
326
|
+
// Guardian Management Types
|
|
327
|
+
// ============================================================================
|
|
328
|
+
|
|
329
|
+
/**
|
|
330
|
+
* Guardian info
|
|
331
|
+
*/
|
|
332
|
+
export interface GuardianInfo {
|
|
333
|
+
index: number
|
|
334
|
+
label: string
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/**
|
|
338
|
+
* Add guardian request
|
|
339
|
+
*/
|
|
340
|
+
export interface AddGuardianRequest {
|
|
341
|
+
/** WebAuthn attestation object (base64url) */
|
|
342
|
+
attestation_object: string
|
|
343
|
+
/** User-friendly label for the guardian */
|
|
344
|
+
label?: string
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
/**
|
|
348
|
+
* Add guardian response
|
|
349
|
+
*/
|
|
350
|
+
export interface AddGuardianResponse {
|
|
351
|
+
success: boolean
|
|
352
|
+
guardian_index: number
|
|
353
|
+
guardian_count: number
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Remove guardian response
|
|
358
|
+
*/
|
|
359
|
+
export interface RemoveGuardianResponse {
|
|
360
|
+
success: boolean
|
|
361
|
+
guardian_count: number
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Get guardians response
|
|
366
|
+
*/
|
|
367
|
+
export interface GetGuardiansResponse {
|
|
368
|
+
success: boolean
|
|
369
|
+
guardian_count: number
|
|
370
|
+
guardians: GuardianInfo[]
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// ============================================================================
|
|
374
|
+
// Account Recovery Types
|
|
375
|
+
// ============================================================================
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Initiate recovery request
|
|
379
|
+
*/
|
|
380
|
+
export interface InitiateRecoveryRequest {
|
|
381
|
+
/** Account ID to recover */
|
|
382
|
+
account_id: string
|
|
383
|
+
/** WebAuthn attestation object for new owner passkey (base64url) */
|
|
384
|
+
attestation_object: string
|
|
385
|
+
/** Label for new owner passkey */
|
|
386
|
+
label?: string
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* Initiate recovery response
|
|
391
|
+
*/
|
|
392
|
+
export interface InitiateRecoveryResponse {
|
|
393
|
+
success: boolean
|
|
394
|
+
/** Challenges for each guardian to sign (base64url) */
|
|
395
|
+
challenges: string[]
|
|
396
|
+
/** Number of guardians registered */
|
|
397
|
+
guardian_count: number
|
|
398
|
+
/** Number of guardian signatures required */
|
|
399
|
+
threshold: number
|
|
400
|
+
/** Seconds to wait after threshold reached before completion */
|
|
401
|
+
timelock_seconds: number
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Verify guardian signature request
|
|
406
|
+
*/
|
|
407
|
+
export interface VerifyGuardianRequest {
|
|
408
|
+
/** Account ID being recovered */
|
|
409
|
+
account_id: string
|
|
410
|
+
/** Index of guardian (1-3) */
|
|
411
|
+
guardian_index: number
|
|
412
|
+
/** WebAuthn authenticator data (base64url) */
|
|
413
|
+
authenticator_data: string
|
|
414
|
+
/** WebAuthn client data JSON (base64url) */
|
|
415
|
+
client_data_json: string
|
|
416
|
+
/** WebAuthn signature (base64url) */
|
|
417
|
+
signature: string
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
/**
|
|
421
|
+
* Verify guardian response
|
|
422
|
+
*/
|
|
423
|
+
export interface VerifyGuardianResponse {
|
|
424
|
+
success: boolean
|
|
425
|
+
/** Number of guardians who have verified */
|
|
426
|
+
verified_count: number
|
|
427
|
+
/** Number of guardians required */
|
|
428
|
+
threshold: number
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Recovery status request
|
|
433
|
+
*/
|
|
434
|
+
export interface RecoveryStatusRequest {
|
|
435
|
+
/** Account ID to check */
|
|
436
|
+
account_id: string
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/**
|
|
440
|
+
* Recovery status response
|
|
441
|
+
*/
|
|
442
|
+
export interface RecoveryStatusResponse {
|
|
443
|
+
success: boolean
|
|
444
|
+
/** Whether recovery is in progress */
|
|
445
|
+
recovery_active: boolean
|
|
446
|
+
/** Number of guardians who have verified */
|
|
447
|
+
verified_count: number
|
|
448
|
+
/** Number of guardians required */
|
|
449
|
+
threshold: number
|
|
450
|
+
/** Whether recovery can be completed now */
|
|
451
|
+
can_complete: boolean
|
|
452
|
+
/** Seconds remaining until timelock expires (0 if expired) */
|
|
453
|
+
timelock_remaining: number
|
|
454
|
+
/** Number of guardians on this account */
|
|
455
|
+
guardian_count: number
|
|
456
|
+
/** Challenge for each guardian to sign (base64url encoded) */
|
|
457
|
+
guardian_challenges: string[]
|
|
458
|
+
/** Indices of guardians who have verified */
|
|
459
|
+
verified_guardians: number[]
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
/**
|
|
463
|
+
* Complete recovery request
|
|
464
|
+
*/
|
|
465
|
+
export interface CompleteRecoveryRequest {
|
|
466
|
+
/** Account ID to complete recovery for */
|
|
467
|
+
account_id: string
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
/**
|
|
471
|
+
* Complete recovery response
|
|
472
|
+
*/
|
|
473
|
+
export interface CompleteRecoveryResponse {
|
|
474
|
+
success: boolean
|
|
475
|
+
message: string
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* Cancel recovery response
|
|
480
|
+
*/
|
|
481
|
+
export interface CancelRecoveryResponse {
|
|
482
|
+
success: boolean
|
|
483
|
+
message: string
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
// ============================================================================
|
|
487
|
+
// Two-Factor Authentication (2FA)
|
|
488
|
+
// ============================================================================
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* 2FA status response
|
|
492
|
+
*/
|
|
493
|
+
export interface TwoFactorStatusResponse {
|
|
494
|
+
success: boolean
|
|
495
|
+
/** Whether TOTP is enabled */
|
|
496
|
+
totp_enabled: boolean
|
|
497
|
+
/** Whether PIN is enabled */
|
|
498
|
+
pin_enabled: boolean
|
|
499
|
+
/** PIN length if enabled (4 or 6), 0 if not enabled */
|
|
500
|
+
pin_length: number
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
/**
|
|
504
|
+
* TOTP setup response
|
|
505
|
+
*/
|
|
506
|
+
export interface TotpSetupResponse {
|
|
507
|
+
success: boolean
|
|
508
|
+
/** otpauth:// URI for QR code generation */
|
|
509
|
+
uri: string
|
|
510
|
+
/** Base32 encoded secret for manual entry */
|
|
511
|
+
secret: string
|
|
512
|
+
/** Instructions for the user */
|
|
513
|
+
message: string
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
/**
|
|
517
|
+
* TOTP enable request
|
|
518
|
+
*/
|
|
519
|
+
export interface TotpEnableRequest {
|
|
520
|
+
/** 6-digit TOTP code from authenticator app */
|
|
521
|
+
code: string
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/**
|
|
525
|
+
* Generic 2FA response
|
|
526
|
+
*/
|
|
527
|
+
export interface TwoFactorResponse {
|
|
528
|
+
success: boolean
|
|
529
|
+
message: string
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/**
|
|
533
|
+
* TOTP/PIN verify response
|
|
534
|
+
*/
|
|
535
|
+
export interface TwoFactorVerifyResponse {
|
|
536
|
+
success: boolean
|
|
537
|
+
/** Whether the code/pin was valid */
|
|
538
|
+
valid: boolean
|
|
539
|
+
/** Optional message if invalid */
|
|
540
|
+
message?: string
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* PIN setup request
|
|
545
|
+
*/
|
|
546
|
+
export interface PinSetupRequest {
|
|
547
|
+
/** PIN (4 or 6 digits) */
|
|
548
|
+
pin: string
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* PIN setup response
|
|
553
|
+
*/
|
|
554
|
+
export interface PinSetupResponse {
|
|
555
|
+
success: boolean
|
|
556
|
+
message: string
|
|
557
|
+
/** Length of the PIN that was set */
|
|
558
|
+
pin_length: number
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
/**
|
|
562
|
+
* Sign request with optional 2FA codes
|
|
563
|
+
*/
|
|
564
|
+
export interface SignEvmRequestWith2FA extends SignEvmRequest {
|
|
565
|
+
/** TOTP code (required if TOTP is enabled) */
|
|
566
|
+
totp_code?: string
|
|
567
|
+
/** PIN (required if PIN is enabled) */
|
|
568
|
+
pin?: string
|
|
569
|
+
}
|