@loginid/websdk3 3.1.0 → 3.2.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/dist/index.d.cts DELETED
@@ -1,1927 +0,0 @@
1
- type ApiRequestOptions = {
2
- readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
3
- readonly url: string;
4
- readonly path?: Record<string, any>;
5
- readonly cookies?: Record<string, any>;
6
- readonly headers?: Record<string, any>;
7
- readonly query?: Record<string, any>;
8
- readonly formData?: Record<string, any>;
9
- readonly body?: any;
10
- readonly mediaType?: string;
11
- readonly responseHeader?: string;
12
- readonly errors?: Record<number, string>;
13
- };
14
-
15
- declare class CancelError extends Error {
16
- constructor(message: string);
17
- get isCancelled(): boolean;
18
- }
19
- interface OnCancel {
20
- readonly isResolved: boolean;
21
- readonly isRejected: boolean;
22
- readonly isCancelled: boolean;
23
- (cancelHandler: () => void): void;
24
- }
25
- declare class CancelablePromise<T> implements Promise<T> {
26
- #private;
27
- constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
28
- get [Symbol.toStringTag](): string;
29
- then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
30
- catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
31
- finally(onFinally?: (() => void) | null): Promise<T>;
32
- cancel(): void;
33
- get isCancelled(): boolean;
34
- }
35
-
36
- type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
37
- type Headers = Record<string, string>;
38
- type OpenAPIConfig = {
39
- BASE: string;
40
- VERSION: string;
41
- WITH_CREDENTIALS: boolean;
42
- CREDENTIALS: 'include' | 'omit' | 'same-origin';
43
- TOKEN?: string | Resolver<string> | undefined;
44
- USERNAME?: string | Resolver<string> | undefined;
45
- PASSWORD?: string | Resolver<string> | undefined;
46
- HEADERS?: Headers | Resolver<Headers> | undefined;
47
- ENCODE_PATH?: ((path: string) => string) | undefined;
48
- };
49
- declare const OpenAPI: OpenAPIConfig;
50
-
51
- declare abstract class BaseHttpRequest {
52
- readonly config: OpenAPIConfig;
53
- constructor(config: OpenAPIConfig);
54
- abstract request<T>(options: ApiRequestOptions): CancelablePromise<T>;
55
- }
56
-
57
- /**
58
- * Code generation result
59
- */
60
- type AuthCode = {
61
- /**
62
- * Generated code
63
- */
64
- code: string;
65
- /**
66
- * Expiration time of the code
67
- */
68
- expiresAt: string;
69
- };
70
-
71
- type UserLogin = {
72
- /**
73
- * Username
74
- */
75
- username: string;
76
- /**
77
- * Username type
78
- */
79
- usernameType?: 'email' | 'phone' | 'other';
80
- };
81
-
82
- type AuthCodeRequestSMSRequestBody = {
83
- user: UserLogin;
84
- };
85
-
86
- type AuthCodeVerifyRequestBody = {
87
- /**
88
- * Authentication code
89
- */
90
- authCode: string;
91
- user: UserLogin;
92
- };
93
-
94
- type AuthenticatorAssertionResponse = {
95
- /**
96
- * A base64 encoded authenticator data structure encodes contextual bindings
97
- * made by the authenticator.
98
- */
99
- authenticatorData: string;
100
- /**
101
- * Base64 encoded byte array which is a JSON-compatible serialization of client data
102
- * passed to the authenticator by the client in order to generate this assertion.
103
- * The exact JSON serialization MUST be preserved, as the hash of the serialized
104
- * client data has been computed over it.
105
- */
106
- clientDataJSON: string;
107
- /**
108
- * A base64 encoded byte sequence identifying a public key credential
109
- * source and its authentication assertions.
110
- */
111
- credentialId: string;
112
- /**
113
- * Base64 encoded the raw signature returned from the authenticator.
114
- */
115
- signature: string;
116
- /**
117
- * User handle returned from the authenticator, or null if the authenticator did not return a user handle.
118
- */
119
- userHandle?: string;
120
- };
121
-
122
- type AuthCompleteRequestBody = {
123
- assertionResult: AuthenticatorAssertionResponse;
124
- /**
125
- * An opaque object containing session data.
126
- */
127
- session: string;
128
- };
129
-
130
- type PubKeyCredentialDescriptor = {
131
- /**
132
- * Base64 encoded byte array of the public key identifier.
133
- */
134
- id: string;
135
- transports?: Array<'usb' | 'nfc' | 'ble' | 'internal' | 'hybrid' | 'cable' | 'smart-card'>;
136
- /**
137
- * The valid credential types.
138
- */
139
- type: 'public-key';
140
- };
141
-
142
- type PublicKeyCredentialRequestOptions = {
143
- /**
144
- * A list of PublicKeyCredentialDescriptor objects representing public key
145
- * credentials acceptable to the caller, in descending order of the caller’s
146
- * preference (the first item in the list is the most preferred credential,
147
- * and so on down the list).
148
- */
149
- allowCredentials?: Array<PubKeyCredentialDescriptor>;
150
- /**
151
- * This base64 encoded byte array represents a challenge that the selected
152
- * authenticator signs, along with other data, when producing an authentication
153
- * assertion.
154
- */
155
- challenge: string;
156
- /**
157
- * Additional parameters requesting additional processing by the client and
158
- * authenticator. For example, if transaction confirmation is sought from the
159
- * user, then the prompt string might be included as an extension.
160
- */
161
- extensions?: Record<string, any>;
162
- /**
163
- * The relying party identifier claimed by the caller. If omitted, its value will
164
- * be the CredentialsContainer object’s relevant settings object's origin's
165
- * effective domain.
166
- */
167
- rpId?: string;
168
- /**
169
- * Specifies a time, in milliseconds, that the caller is willing
170
- * to wait for the call to complete. The value is treated as a
171
- * hint, and MAY be overridden by the client.
172
- */
173
- timeout?: number;
174
- /**
175
- * User verification requirement
176
- */
177
- userVerification?: 'required' | 'preferred' | 'discouraged';
178
- };
179
-
180
- /**
181
- * FIDO2 authentication response
182
- */
183
- type AuthInit = {
184
- /**
185
- * An action to be performed by the front-end to complete the authentication flow.
186
- */
187
- action: 'proceed' | 'crossAuth' | 'fallback';
188
- assertionOptions: PublicKeyCredentialRequestOptions;
189
- /**
190
- * List of cross authentication methods in the order of preference
191
- */
192
- crossAuthMethods: Array<'otp' | 'otp:sms' | 'otp:email'>;
193
- /**
194
- * The list contains available fallback methods in the order of preference. The
195
- * list is dynamic and shall not be cached. The default fallback mechanism is
196
- * the one provided by CIAM but our system may provide additional ones as well.
197
- * These methods may be enabled by customer via application configuration but
198
- * they are disabled by default. The list may be empty which means no fallback
199
- * is available and authentication flow shall terminate at this point.
200
- */
201
- fallbackMethods: Array<'ciam'>;
202
- /**
203
- * Type of passkey supported by the client.
204
- */
205
- passkeyType?: string;
206
- /**
207
- * An opaque object containing session data.
208
- */
209
- session: string;
210
- };
211
-
212
- /**
213
- * Application making the request. It contains additional info about the caller
214
- * to distinguish between tenants.
215
- */
216
- type Application = {
217
- /**
218
- * Unique application id
219
- */
220
- id: string;
221
- /**
222
- * App authorization token signed with application key.
223
- */
224
- token?: string;
225
- };
226
-
227
- /**
228
- * Information about the device. All of these attributes are optional and should
229
- * be provided on best effort basis. If provide, they will be taken into
230
- * consideration in order to improve user experience.
231
- */
232
- type DeviceInfo = {
233
- /**
234
- * Client name
235
- */
236
- clientName?: string;
237
- /**
238
- * Client type.
239
- */
240
- clientType?: 'browser' | 'other';
241
- /**
242
- * Client version
243
- */
244
- clientVersion?: string;
245
- /**
246
- * An unique device identifier
247
- */
248
- deviceId?: string;
249
- /**
250
- * Last use timestamp in rfc3339 format
251
- */
252
- lastUsedAt?: string;
253
- /**
254
- * OS architecture
255
- */
256
- osArch?: string;
257
- /**
258
- * OS name
259
- */
260
- osName?: string;
261
- /**
262
- * OS version
263
- */
264
- osVersion?: string;
265
- /**
266
- * Screen height in pixels
267
- */
268
- screenHeight?: number;
269
- /**
270
- * Screen width in pixels
271
- */
272
- screenWidth?: number;
273
- };
274
-
275
- type AuthInitRequestBody = {
276
- app: Application;
277
- deviceInfo: DeviceInfo;
278
- trustInfo?: string;
279
- user?: UserLogin;
280
- };
281
-
282
- type JWT = {
283
- /**
284
- * Device ID
285
- */
286
- deviceId?: string;
287
- /**
288
- * JWT access token
289
- */
290
- jwtAccess: string;
291
- /**
292
- * Passkey ID
293
- */
294
- passkeyId?: string;
295
- /**
296
- * User ID
297
- */
298
- userId: string;
299
- };
300
-
301
- declare class AuthService {
302
- readonly httpRequest: BaseHttpRequest;
303
- constructor(httpRequest: BaseHttpRequest);
304
- /**
305
- * Complete WebAuthn authentication
306
- * @returns JWT OK response.
307
- * @throws ApiError
308
- */
309
- authAuthComplete({ requestBody, }: {
310
- requestBody: AuthCompleteRequestBody;
311
- }): CancelablePromise<JWT>;
312
- /**
313
- * Start WebAuthn authentication flow
314
- * @returns AuthInit OK response.
315
- * @throws ApiError
316
- */
317
- authAuthInit({ requestBody, userAgent, }: {
318
- requestBody: AuthInitRequestBody;
319
- /**
320
- * Raw user-agent header as set by a browser
321
- */
322
- userAgent?: string;
323
- }): CancelablePromise<AuthInit>;
324
- /**
325
- * Request OTP code by an authenticated user
326
- * An authenticated user can request an authentication code directly using this
327
- * method. The code can be used for authentication from another device.
328
- * @returns AuthCode OK response.
329
- * @throws ApiError
330
- */
331
- authAuthCodeRequest({ authorization, }: {
332
- /**
333
- * JWT Authorization header
334
- */
335
- authorization?: string;
336
- }): CancelablePromise<AuthCode>;
337
- /**
338
- * Request OTP code to be sent via email.
339
- * Send authentication code to the provided email. The SMS will only be sent
340
- * if the email address is known to the application, however, this method will
341
- * return success regardless.
342
- * @returns void
343
- * @throws ApiError
344
- */
345
- authAuthCodeRequestEmail({ requestBody, }: {
346
- requestBody: AuthCodeRequestSMSRequestBody;
347
- }): CancelablePromise<void>;
348
- /**
349
- * Request OTP code to be sent via SMS.
350
- * Send authentication code to the provided phone number. The SMS will only be
351
- * sent if the phone is registered with the application, however, it will return
352
- * success regardless.
353
- * @returns void
354
- * @throws ApiError
355
- */
356
- authAuthCodeRequestSms({ requestBody, }: {
357
- requestBody: AuthCodeRequestSMSRequestBody;
358
- }): CancelablePromise<void>;
359
- /**
360
- * Verify authentication code and return JWT access token with appropriate scopes
361
- * @returns JWT OK response.
362
- * @throws ApiError
363
- */
364
- authAuthCodeVerify({ requestBody, }: {
365
- requestBody: AuthCodeVerifyRequestBody;
366
- }): CancelablePromise<JWT>;
367
- }
368
-
369
- type Aaguid = {
370
- /**
371
- * Dark Icon of the AAGUID Vendor
372
- */
373
- iconDark: string;
374
- /**
375
- * Light Icon of the AAGUID Vendor
376
- */
377
- iconLight: string;
378
- /**
379
- * AAGUID
380
- */
381
- id: string;
382
- /**
383
- * Name of the AAGUID Vendor
384
- */
385
- name: string;
386
- };
387
-
388
- type Passkey = {
389
- /**
390
- * AAGUID of passkey provider
391
- */
392
- aaguid: string;
393
- /**
394
- * Timestamp in RFC3339 format.
395
- */
396
- createdAt: string;
397
- /**
398
- * Credential available on multiple devices
399
- */
400
- credentialSynced?: boolean;
401
- /**
402
- * Internal passkey ID that uniquely identifies a passkey
403
- */
404
- id: string;
405
- /**
406
- * Last use timestamp in rfc3339 format
407
- */
408
- lastUsedAt?: string;
409
- lastUsedFromDevice?: DeviceInfo;
410
- /**
411
- * Name of the passkey
412
- */
413
- name: string;
414
- /**
415
- * Name of the passkey provider
416
- */
417
- providerName?: string;
418
- };
419
-
420
- type PasskeyCollection = Array<Passkey>;
421
-
422
- type PasskeyRenameRequestBody = {
423
- /**
424
- * Internal passkey identifier
425
- */
426
- name: string;
427
- };
428
-
429
- declare class PasskeysService {
430
- readonly httpRequest: BaseHttpRequest;
431
- constructor(httpRequest: BaseHttpRequest);
432
- /**
433
- * List passkeys of the user
434
- * @returns PasskeyCollection OK response.
435
- * @throws ApiError
436
- */
437
- passkeysPasskeysList({ authorization, }: {
438
- /**
439
- * JWT Authorization header
440
- */
441
- authorization?: string;
442
- }): CancelablePromise<PasskeyCollection>;
443
- /**
444
- * Delete passkey
445
- * @returns void
446
- * @throws ApiError
447
- */
448
- passkeysPasskeyDelete({ id, authorization, }: {
449
- /**
450
- * Internal passkey identifier
451
- */
452
- id: string;
453
- /**
454
- * JWT Authorization header
455
- */
456
- authorization?: string;
457
- }): CancelablePromise<void>;
458
- /**
459
- * Rename passkey
460
- * @returns void
461
- * @throws ApiError
462
- */
463
- passkeysPasskeyRename({ id, requestBody, authorization, }: {
464
- /**
465
- * Internal passkey identifier
466
- */
467
- id: string;
468
- requestBody: PasskeyRenameRequestBody;
469
- /**
470
- * JWT Authorization header
471
- */
472
- authorization?: string;
473
- }): CancelablePromise<void>;
474
- /**
475
- * Get AAGUID Metadata
476
- * @returns Aaguid OK response.
477
- * @throws ApiError
478
- */
479
- passkeysAaguidMetadata({ aaguid, authorization, }: {
480
- /**
481
- * AAGUID identifier
482
- */
483
- aaguid: string;
484
- /**
485
- * JWT Authorization header
486
- */
487
- authorization?: string;
488
- }): CancelablePromise<Aaguid>;
489
- }
490
-
491
- type CreationResult = {
492
- /**
493
- * Base64 encoded byte array containing an attestation object, which is opaque to,
494
- * and cryptographically protected against tampering by, the client.
495
- */
496
- attestationObject: string;
497
- /**
498
- * A base64 encoded authenticator data structure encodes contextual bindings
499
- * made by the authenticator.
500
- */
501
- authenticatorData?: string;
502
- /**
503
- * Base64 encoded byte array which is a JSON-compatible serialization of client data
504
- * passed to the authenticator by the client in order to generate this credential.
505
- * The exact JSON serialization MUST be preserved, as the hash of the serialized
506
- * client data has been computed over it.
507
- */
508
- clientDataJSON: string;
509
- /**
510
- * A base64 encoded byte sequence identifying a public key credential
511
- * source and its authentication assertions.
512
- */
513
- credentialId: string;
514
- /**
515
- * Base64 encoded DER SubjectPublicKeyInfo of the new credential, or null if this is
516
- * not available.
517
- */
518
- publicKey?: string;
519
- publicKeyAlgorithm?: number;
520
- /**
521
- * These values are the transports that the authenticator is believed to support,
522
- * or an empty sequence if the information is unavailable.
523
- */
524
- transports?: Array<'usb' | 'nfc' | 'ble' | 'internal' | 'hybrid' | 'cable' | 'smart-card'>;
525
- };
526
-
527
- type RegCompleteRequestBody = {
528
- creationResult: CreationResult;
529
- /**
530
- * An opaque object containing session data.
531
- */
532
- session: string;
533
- };
534
-
535
- type AuthenticatorSelectionCriteria = {
536
- /**
537
- * Authenticator attachment modality
538
- */
539
- authenticatorAttachment?: 'platform' | 'cross-platform';
540
- /**
541
- * Resident key requirement
542
- */
543
- requireResidentKey?: boolean;
544
- /**
545
- * Resident key requirement
546
- */
547
- residentKey?: 'discouraged' | 'preferred' | 'required';
548
- /**
549
- * User verification requirement
550
- */
551
- userVerification?: 'required' | 'preferred' | 'discouraged';
552
- };
553
-
554
- /**
555
- * Additional parameters when creating a new credential.
556
- */
557
- type PublicKeyCredentialParameters = {
558
- /**
559
- * A cryptographic signature algorithm with which the newly generated credential
560
- * will be used, and thus also the type of asymmetric key pair to be generated,
561
- * e.g., RSA or Elliptic Curve.
562
- */
563
- alg?: -7 | -35 | -36 | -257 | -8;
564
- /**
565
- * The valid credential types.
566
- */
567
- type?: 'public-key';
568
- };
569
-
570
- /**
571
- * Data about the Relying Party responsible for the request.
572
- */
573
- type PublicKeyCredentialRpEntity = {
574
- /**
575
- * A unique identifier for the Relying Party entity, which sets the RP ID.
576
- */
577
- id?: string;
578
- /**
579
- * Relaying party name
580
- */
581
- name: string;
582
- };
583
-
584
- /**
585
- * Data about the user account for which the Relying Party is requesting attestation
586
- */
587
- type PublicKeyCredentialUserEntity = {
588
- displayName: string;
589
- id: string;
590
- name: string;
591
- };
592
-
593
- type PublicKeyCredentialCreationOptions = {
594
- attestation?: 'none' | 'indirect' | 'direct' | 'enterprise';
595
- authenticatorSelection?: AuthenticatorSelectionCriteria;
596
- /**
597
- * This base64 encoded byte array represents a challenge that
598
- * the selected authenticator signs, along with other data, when
599
- * producing an authentication assertion.
600
- */
601
- challenge: string;
602
- /**
603
- * List of credentials to limit the creation of multiple credentials for the same
604
- * account on a single authenticator. The client is requested to return an error
605
- * if the new credential would be created on an authenticator that also contains
606
- * one of the credentials enumerated in this parameter.
607
- */
608
- excludeCredentials?: Array<PubKeyCredentialDescriptor>;
609
- /**
610
- * Additional parameters requesting processing by the client and authenticator.
611
- */
612
- extensions?: Record<string, any>;
613
- /**
614
- * This member contains information about the desired properties of the credential
615
- * to be created. The sequence is ordered from most preferred to least preferred.
616
- * The client makes a best-effort to create the most preferred credential that it
617
- * can.
618
- */
619
- pubKeyCredParams: Array<PublicKeyCredentialParameters>;
620
- rp: PublicKeyCredentialRpEntity;
621
- /**
622
- * This OPTIONAL member specifies a time, in milliseconds,
623
- * that the caller is willing to wait for the call to complete. The
624
- * value is treated as a hint, and MAY be overridden by the client.
625
- */
626
- timeout?: number;
627
- user: PublicKeyCredentialUserEntity;
628
- };
629
-
630
- /**
631
- * FIDO2 registration response
632
- */
633
- type RegInit = {
634
- /**
635
- * An action to be performed by the front-end to complete the registration flow.
636
- */
637
- action: 'proceed' | 'signIn' | 'fail';
638
- registrationRequestOptions: PublicKeyCredentialCreationOptions;
639
- /**
640
- * An opaque object containing session data.
641
- */
642
- session: string;
643
- };
644
-
645
- type PasskeyOptions$1 = {
646
- /**
647
- * Flag to allow conditional creation
648
- */
649
- conditionalCreate: boolean;
650
- };
651
-
652
- type User = {
653
- /**
654
- * Display Name
655
- */
656
- displayName?: string;
657
- /**
658
- * Username
659
- */
660
- username: string;
661
- /**
662
- * Username type
663
- */
664
- usernameType: 'email' | 'phone' | 'other';
665
- };
666
-
667
- type RegInitRequestBody = {
668
- app: Application;
669
- deviceInfo: DeviceInfo;
670
- passkeyOptions?: PasskeyOptions$1;
671
- trustInfo?: string;
672
- user?: User;
673
- };
674
-
675
- declare class RegService {
676
- readonly httpRequest: BaseHttpRequest;
677
- constructor(httpRequest: BaseHttpRequest);
678
- /**
679
- * Complete WebAuthn registration flow
680
- * @returns JWT OK response.
681
- * @throws ApiError
682
- */
683
- regRegComplete({ requestBody, }: {
684
- requestBody: RegCompleteRequestBody;
685
- }): CancelablePromise<JWT>;
686
- /**
687
- * Start WebAuthn registration flow
688
- * @returns RegInit OK response.
689
- * @throws ApiError
690
- */
691
- regRegInit({ requestBody, userAgent, authorization, }: {
692
- requestBody: RegInitRequestBody;
693
- /**
694
- * Raw user-agent header as set by a browser
695
- */
696
- userAgent?: string;
697
- /**
698
- * JWT Authorization header
699
- */
700
- authorization?: string;
701
- }): CancelablePromise<RegInit>;
702
- }
703
-
704
- /**
705
- * Transaction Confirmation Complete response
706
- */
707
- type TxComplete = {
708
- authCred?: Passkey;
709
- /**
710
- * Internal passkey identifier
711
- */
712
- credentialId: string;
713
- /**
714
- * Authorization token
715
- */
716
- token: string;
717
- };
718
-
719
- type TxCompleteRequestBody = {
720
- /**
721
- * This attribute contains the authenticator data returned by the authenticator.
722
- */
723
- authenticatorData: string;
724
- /**
725
- * Base64 encoded byte array which is a JSON-compatible serialization of client data
726
- * passed to the authenticator by the client in order to generate this assertion.
727
- * The exact JSON serialization MUST be preserved, as the hash of the serialized
728
- * client data has been computed over it.
729
- */
730
- clientData: string;
731
- /**
732
- * Identified of the passkey credential.
733
- */
734
- keyHandle: string;
735
- /**
736
- * An opaque object containing session data.
737
- */
738
- session: string;
739
- /**
740
- * Base64 encoded the raw signature returned from the authenticator.
741
- */
742
- signature: string;
743
- };
744
-
745
- /**
746
- * Transaction Confirmation Init response
747
- */
748
- type TxInit = {
749
- assertionOptions: PublicKeyCredentialRequestOptions;
750
- /**
751
- * An opaque object containing session data.
752
- */
753
- session: string;
754
- /**
755
- * Internal transaction identifier
756
- */
757
- txId: string;
758
- };
759
-
760
- type TxInitRequestBody = {
761
- /**
762
- * Random string
763
- */
764
- nonce: string;
765
- /**
766
- * Payload of transaction
767
- */
768
- txPayload: string;
769
- /**
770
- * Type of transaction
771
- */
772
- txType: string;
773
- /**
774
- * Username of user
775
- */
776
- username: string;
777
- };
778
-
779
- declare class TxService {
780
- readonly httpRequest: BaseHttpRequest;
781
- constructor(httpRequest: BaseHttpRequest);
782
- /**
783
- * Complete transaction confirmation
784
- * @returns TxComplete OK response.
785
- * @throws ApiError
786
- */
787
- txTxComplete({ requestBody, }: {
788
- requestBody: TxCompleteRequestBody;
789
- }): CancelablePromise<TxComplete>;
790
- /**
791
- * Start transaction confirmation flow
792
- * @returns TxInit OK response.
793
- * @throws ApiError
794
- */
795
- txTxInit({ requestBody, }: {
796
- requestBody: TxInitRequestBody;
797
- }): CancelablePromise<TxInit>;
798
- }
799
-
800
- type HttpRequestConstructor = new (config: OpenAPIConfig) => BaseHttpRequest;
801
- declare class LoginIDService {
802
- readonly auth: AuthService;
803
- readonly passkeys: PasskeysService;
804
- readonly reg: RegService;
805
- readonly tx: TxService;
806
- readonly request: BaseHttpRequest;
807
- constructor(config?: Partial<OpenAPIConfig>, HttpRequest?: HttpRequestConstructor);
808
- }
809
-
810
- type ApiResult = {
811
- readonly url: string;
812
- readonly ok: boolean;
813
- readonly status: number;
814
- readonly statusText: string;
815
- readonly body: any;
816
- };
817
-
818
- declare class ApiError extends Error {
819
- readonly url: string;
820
- readonly status: number;
821
- readonly statusText: string;
822
- readonly body: any;
823
- readonly request: ApiRequestOptions;
824
- constructor(request: ApiRequestOptions, response: ApiResult, message: string);
825
- }
826
-
827
- type AppError = {
828
- msg: string;
829
- /**
830
- * Message code
831
- */
832
- msgCode: 'bad_request' | 'unauthorized' | 'forbidden' | 'not_found' | 'internal_error';
833
- };
834
-
835
- type index_Aaguid = Aaguid;
836
- type index_ApiError = ApiError;
837
- declare const index_ApiError: typeof ApiError;
838
- type index_AppError = AppError;
839
- type index_Application = Application;
840
- type index_AuthCode = AuthCode;
841
- type index_AuthCodeRequestSMSRequestBody = AuthCodeRequestSMSRequestBody;
842
- type index_AuthCodeVerifyRequestBody = AuthCodeVerifyRequestBody;
843
- type index_AuthCompleteRequestBody = AuthCompleteRequestBody;
844
- type index_AuthInit = AuthInit;
845
- type index_AuthInitRequestBody = AuthInitRequestBody;
846
- type index_AuthService = AuthService;
847
- declare const index_AuthService: typeof AuthService;
848
- type index_AuthenticatorAssertionResponse = AuthenticatorAssertionResponse;
849
- type index_AuthenticatorSelectionCriteria = AuthenticatorSelectionCriteria;
850
- type index_BaseHttpRequest = BaseHttpRequest;
851
- declare const index_BaseHttpRequest: typeof BaseHttpRequest;
852
- type index_CancelError = CancelError;
853
- declare const index_CancelError: typeof CancelError;
854
- type index_CancelablePromise<T> = CancelablePromise<T>;
855
- declare const index_CancelablePromise: typeof CancelablePromise;
856
- type index_CreationResult = CreationResult;
857
- type index_DeviceInfo = DeviceInfo;
858
- type index_JWT = JWT;
859
- type index_LoginIDService = LoginIDService;
860
- declare const index_LoginIDService: typeof LoginIDService;
861
- declare const index_OpenAPI: typeof OpenAPI;
862
- type index_OpenAPIConfig = OpenAPIConfig;
863
- type index_Passkey = Passkey;
864
- type index_PasskeyCollection = PasskeyCollection;
865
- type index_PasskeyRenameRequestBody = PasskeyRenameRequestBody;
866
- type index_PasskeysService = PasskeysService;
867
- declare const index_PasskeysService: typeof PasskeysService;
868
- type index_PubKeyCredentialDescriptor = PubKeyCredentialDescriptor;
869
- type index_PublicKeyCredentialCreationOptions = PublicKeyCredentialCreationOptions;
870
- type index_PublicKeyCredentialParameters = PublicKeyCredentialParameters;
871
- type index_PublicKeyCredentialRequestOptions = PublicKeyCredentialRequestOptions;
872
- type index_PublicKeyCredentialRpEntity = PublicKeyCredentialRpEntity;
873
- type index_PublicKeyCredentialUserEntity = PublicKeyCredentialUserEntity;
874
- type index_RegCompleteRequestBody = RegCompleteRequestBody;
875
- type index_RegInit = RegInit;
876
- type index_RegInitRequestBody = RegInitRequestBody;
877
- type index_RegService = RegService;
878
- declare const index_RegService: typeof RegService;
879
- type index_TxComplete = TxComplete;
880
- type index_TxCompleteRequestBody = TxCompleteRequestBody;
881
- type index_TxInit = TxInit;
882
- type index_TxInitRequestBody = TxInitRequestBody;
883
- type index_TxService = TxService;
884
- declare const index_TxService: typeof TxService;
885
- type index_User = User;
886
- type index_UserLogin = UserLogin;
887
- declare namespace index {
888
- export { type index_Aaguid as Aaguid, index_ApiError as ApiError, type index_AppError as AppError, type index_Application as Application, type index_AuthCode as AuthCode, type index_AuthCodeRequestSMSRequestBody as AuthCodeRequestSMSRequestBody, type index_AuthCodeVerifyRequestBody as AuthCodeVerifyRequestBody, type index_AuthCompleteRequestBody as AuthCompleteRequestBody, type index_AuthInit as AuthInit, type index_AuthInitRequestBody as AuthInitRequestBody, index_AuthService as AuthService, type index_AuthenticatorAssertionResponse as AuthenticatorAssertionResponse, type index_AuthenticatorSelectionCriteria as AuthenticatorSelectionCriteria, index_BaseHttpRequest as BaseHttpRequest, index_CancelError as CancelError, index_CancelablePromise as CancelablePromise, type index_CreationResult as CreationResult, type index_DeviceInfo as DeviceInfo, type index_JWT as JWT, index_LoginIDService as LoginIDService, index_OpenAPI as OpenAPI, type index_OpenAPIConfig as OpenAPIConfig, type index_Passkey as Passkey, type index_PasskeyCollection as PasskeyCollection, type PasskeyOptions$1 as PasskeyOptions, type index_PasskeyRenameRequestBody as PasskeyRenameRequestBody, index_PasskeysService as PasskeysService, type index_PubKeyCredentialDescriptor as PubKeyCredentialDescriptor, type index_PublicKeyCredentialCreationOptions as PublicKeyCredentialCreationOptions, type index_PublicKeyCredentialParameters as PublicKeyCredentialParameters, type index_PublicKeyCredentialRequestOptions as PublicKeyCredentialRequestOptions, type index_PublicKeyCredentialRpEntity as PublicKeyCredentialRpEntity, type index_PublicKeyCredentialUserEntity as PublicKeyCredentialUserEntity, type index_RegCompleteRequestBody as RegCompleteRequestBody, type index_RegInit as RegInit, type index_RegInitRequestBody as RegInitRequestBody, index_RegService as RegService, type index_TxComplete as TxComplete, type index_TxCompleteRequestBody as TxCompleteRequestBody, type index_TxInit as TxInit, type index_TxInitRequestBody as TxInitRequestBody, index_TxService as TxService, type index_User as User, type index_UserLogin as UserLogin };
889
- }
890
-
891
- type Complete<T> = {
892
- [P in keyof T]-?: T[P];
893
- };
894
- type UsernameType = User['usernameType'];
895
- type DeviceInfoRequestBody = DeviceInfo;
896
- type Transports = CreationResult['transports'];
897
- type Message = 'email' | 'sms';
898
- type FallbackOptions = string[];
899
- type FallbackCallback = (username: string, options: FallbackOptions) => Promise<void>;
900
- type SuccessCallback = (result: AuthResult) => Promise<void>;
901
- interface Callbacks {
902
- onFallback?: FallbackCallback;
903
- onSuccess?: SuccessCallback;
904
- }
905
- interface AllOptions {
906
- authzToken?: string;
907
- usernameType?: UsernameType;
908
- displayName?: string;
909
- callbacks?: Callbacks;
910
- }
911
- /**
912
- * Configuration for LoginID FIDO service.
913
- */
914
- interface LoginIDConfig {
915
- /**
916
- * The base URL for LoginID FIDO service which can be obtained on the [dashboard](https://dashboard.loginid.io).
917
- */
918
- baseUrl: string;
919
- /**
920
- * The optional app ID for specific application.
921
- */
922
- appId?: string;
923
- }
924
- /**
925
- * The base interface for passkey options.
926
- */
927
- interface PasskeyOptions {
928
- /**
929
- * Authorization token used for accessing protected resources typically used for adding multiple passkeys to a user.
930
- */
931
- authzToken?: string;
932
- /**
933
- * Callback functions that can be triggered on various events during the authentication process.
934
- */
935
- callbacks?: Callbacks;
936
- /**
937
- * The type of username validation to be used. Defaults to **`other`**.
938
- */
939
- usernameType?: UsernameType;
940
- }
941
- /**
942
- * The base interface for passkey management options.
943
- */
944
- interface PasskeyManagementOptions {
945
- /**
946
- * Authorization token used for authorizing passkey management actions.
947
- */
948
- authzToken?: string;
949
- }
950
- /**
951
- * List passkeys options.
952
- */
953
- interface ListPasskeysOptions extends PasskeyManagementOptions {
954
- }
955
- /**
956
- * Rename passkeys options.
957
- */
958
- interface RenamePasskeyOptions extends PasskeyManagementOptions {
959
- }
960
- /**
961
- * Delete passkeys options.
962
- */
963
- interface DeletePasskeyOptions extends PasskeyManagementOptions {
964
- }
965
- /**
966
- * Authenticate with passkeys options.
967
- */
968
- interface AuthenticateWithPasskeysOptions extends PasskeyOptions {
969
- /**
970
- * When true it will enable passkeys on the browser autofill suggestions if supported (conditional UI). Username does not need to be set.
971
- */
972
- autoFill?: boolean;
973
- /**
974
- * This should be used with the **`options.autoFill`** option to trigger the cancellation of the passkey conditional UI.
975
- * Pass this if additional passkeys API calls may be anticipated on the current context page.
976
- */
977
- abortController?: AbortController;
978
- }
979
- /**
980
- * Authenticate with passkey autofill options.
981
- */
982
- interface AuthenticateWithPasskeyAutofillOptions extends AuthenticateWithPasskeysOptions {
983
- }
984
- /**
985
- * Create passkeys options interface.
986
- */
987
- interface CreatePasskeyOptions extends PasskeyOptions {
988
- /**
989
- * A human-palatable name for the user account, intended only for display on your passkeys and modals.
990
- */
991
- displayName?: string;
992
- }
993
- /**
994
- * Confirm transaction options.
995
- */
996
- interface ConfirmTransactionOptions extends PasskeyOptions {
997
- /**
998
- * Specify the type of transaction being confirmed for additional validation.
999
- */
1000
- txType?: string;
1001
- /**
1002
- * A unique nonce to ensure the transaction's integrity and prevent replay attacks
1003
- */
1004
- nonce?: string;
1005
- }
1006
- /**
1007
- * Request and send OTP options.
1008
- */
1009
- interface RequestAndSendOtpOptions {
1010
- /**
1011
- * The type of username validation to be used. Defaults to **`other`**.
1012
- */
1013
- usernameType?: UsernameType;
1014
- }
1015
- /**
1016
- * Request OTP options.
1017
- */
1018
- interface RequestOtpOptions extends AuthenticateWithPasskeyAutofillOptions {
1019
- }
1020
- /**
1021
- * Validate OTP options.
1022
- */
1023
- interface ValidateOtpOptions extends RequestAndSendOtpOptions {
1024
- }
1025
- /**
1026
- * The result after requesting an OTP with **`requestOtp`**.
1027
- */
1028
- interface Otp extends AuthCode {
1029
- }
1030
- /**
1031
- * The result after a successful authentication process either with passkeys or OTP.
1032
- */
1033
- interface AuthResult {
1034
- /**
1035
- * Indicates whether the user is authenticated. If **`false`**, a fallback options can be taken place if available on **`fallbackOptions`**.
1036
- */
1037
- isAuthenticated: boolean;
1038
- /**
1039
- * A short-lived authorization token is returned, allowing access to protected resources for the given user such as listing, renaming or deleting passkeys.
1040
- */
1041
- token: string;
1042
- /**
1043
- * The unique identifier of the authenticated user.
1044
- */
1045
- userId: string;
1046
- /**
1047
- * The identifier for the passkey used in authentication, if applicable.
1048
- */
1049
- passkeyId?: string;
1050
- /**
1051
- * An identifier for the device used in the authentication process. This property helps determine if supported authentications can be proceeded,
1052
- * allowing future authentications to identify the device correctly.
1053
- */
1054
- deviceID?: string;
1055
- /**
1056
- * If **`true`**, the authentication process should resort to a fallback method as specified in **`fallbackOptions`**.
1057
- */
1058
- isFallback: boolean;
1059
- /**
1060
- * This property will be returned if the LoginID indicates that the user is unlikely to proceed with passkey authentication.
1061
- * In this case, instead of prompting for passkey authentication, available cross-authentication options are listed as an alternative,
1062
- * providing suggested authentications to use instead.
1063
- */
1064
- fallbackOptions?: FallbackOptions;
1065
- }
1066
- /**
1067
- * General information about the current user session. Information is obtained from the stored authorization token.
1068
- */
1069
- interface SessionInfo {
1070
- /**
1071
- * Current authenticated user's username.
1072
- */
1073
- username: string;
1074
- /**
1075
- * Current authenticated user's ID.
1076
- */
1077
- id: string;
1078
- }
1079
- /**
1080
- * The result of verifying the application's configuration settings.
1081
- */
1082
- interface VerifyConfigResult {
1083
- /**
1084
- * Indicates whether the configuration is valid.
1085
- */
1086
- isValid: boolean;
1087
- /**
1088
- * Suggested solution to fix any configuration issues.
1089
- */
1090
- solution?: string;
1091
- /**
1092
- * A message describing the issue with the configuration, if any.
1093
- */
1094
- message?: string;
1095
- /**
1096
- * A code representing the error type.
1097
- */
1098
- code?: string;
1099
- }
1100
- /**
1101
- * Represents the claims included in a TrustID token.
1102
- */
1103
- interface TrustIDClaims {
1104
- /**
1105
- * Unique identifier for the Trust ID.
1106
- */
1107
- id: string;
1108
- /**
1109
- * Username associated with the token owner.
1110
- */
1111
- username: string;
1112
- /**
1113
- * Audience for which the token is intended. This is the app ID.
1114
- */
1115
- aud: string;
1116
- }
1117
- /**
1118
- * Represents a stored Trust ID record in the trust store database.
1119
- */
1120
- interface TrustIDRecord {
1121
- /**
1122
- * Unique identifier for the Trust ID, derived from the TrustID token.
1123
- */
1124
- id: string;
1125
- /**
1126
- * Username associated with the Trust ID.
1127
- */
1128
- username: string;
1129
- /**
1130
- * Cryptographic key pair used for signing and verification.
1131
- */
1132
- keyPair: CryptoKeyPair;
1133
- }
1134
-
1135
- declare class SessionManager {
1136
- /**
1137
- * Holds the configuration settings for the LoginID integration, including API base URL.
1138
- */
1139
- private config;
1140
- /**
1141
- * Initializes a new instance of SessionManager with the provided configuration.
1142
- *
1143
- * @param {LoginIDConfig} config Configuration object for LoginID.
1144
- */
1145
- constructor(config: LoginIDConfig);
1146
- /**
1147
- * Retrieves the authentication token from the provided options or from cookies if not available in options.
1148
- *
1149
- * @param {PasskeyOptions} options Options containing the token.
1150
- * @returns {string} The authentication token.
1151
- */
1152
- getToken(options: PasskeyOptions): string;
1153
- /**
1154
- * Retrieves the currently authenticated user's session information.
1155
- *
1156
- * @returns {LoginIDUser | null} The currently authenticated user's information, including username and id.
1157
- * It will return null if user is not authenticated
1158
- */
1159
- getSessionInfo(): SessionInfo | null;
1160
- /**
1161
- * Returns the dynamic Cookie name holding the authorization token for the given application.
1162
- *
1163
- * @returns {string} The name of the cookie
1164
- */
1165
- getJwtCookieName(): string;
1166
- /**
1167
- * Set jwt token to local Cookie
1168
- *
1169
- * @param {string} jwt Configuration object for LoginID API, including the base URL.
1170
- */
1171
- setJwtCookie(jwt: string): void;
1172
- /**
1173
- * Retrieves the JWT access token.
1174
- *
1175
- * @returns {string | undefined} The JWT access token.
1176
- */
1177
- getJwtCookie(): string | undefined;
1178
- /**
1179
- * Checks if the user is logged in.
1180
- *
1181
- * @returns {boolean}
1182
- */
1183
- isLoggedIn(): boolean;
1184
- /**
1185
- * Deletes the jwt cookie.
1186
- *
1187
- * @returns {boolean}
1188
- */
1189
- logout(): void;
1190
- }
1191
-
1192
- declare class LoginIDConfigValidator {
1193
- /**
1194
- * Holds the configuration settings for the LoginID integration, including API base URL and optional app ID.
1195
- */
1196
- private readonly config;
1197
- /**
1198
- * Constructs a new instance of the LoginIDConfigValidator class, initializing with the provided configuration.
1199
- * @param {LoginIDConfig} config Configuration object for LoginID API, including the base URL and optional app ID.
1200
- */
1201
- constructor(config: LoginIDConfig);
1202
- /**
1203
- * Retrieves the application ID from the configuration or extracts it from the base URL if not provided.
1204
- * @returns {string} The application ID.
1205
- * @throws {Error} If the app ID is not found in the configuration or the base URL, throws an error.
1206
- */
1207
- getAppId(): string;
1208
- }
1209
-
1210
- /**
1211
- * Provides a base class for integrating with the LoginID API services.
1212
- * This class initializes the common configuration and service needed for derived classes to interact with LoginID services.
1213
- */
1214
- declare class LoginIDBase {
1215
- /**
1216
- * Holds the configuration settings for the LoginID integration, including API base URL.
1217
- */
1218
- protected readonly config: LoginIDConfigValidator;
1219
- /**
1220
- * Instance of LoginIDService, providing access to the LoginID API methods.
1221
- */
1222
- protected readonly service: LoginIDService;
1223
- /**
1224
- * Instance of SessionManager, providing access to the session management methods.
1225
- */
1226
- readonly session: SessionManager;
1227
- /**
1228
- * Constructs a new instance of the LoginIDBase class, initializing the service with the provided configuration.
1229
- * @param {LoginIDConfig} config Configuration object for LoginID API, including the base URL.
1230
- */
1231
- constructor(config: LoginIDConfig);
1232
- }
1233
-
1234
- /**
1235
- * Extends LoginIDBase to support OTP methods.
1236
- */
1237
- declare class OTP extends LoginIDBase {
1238
- /**
1239
- * Initializes a new instance of OTP with the provided configuration.
1240
- *
1241
- * @param {LoginIDConfig} config Configuration object for LoginID.
1242
- */
1243
- constructor(config: LoginIDConfig);
1244
- /**
1245
- * This method verifies the OTP and returns an authorization token, which can be used with the `passkeyCreate()`
1246
- * method to create a new passkey. The authorization token has a short validity period and should be used immediately.
1247
- *
1248
- * @param {string} username Username to validate with.
1249
- * @param {string} otp OTP to validate.
1250
- * @param {ValidateOtpOptions} options Additional authentication options.
1251
- * @returns {Promise<AuthResult>} Result of the authentication operation.
1252
- * @example
1253
- * ```javascript
1254
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1255
- *
1256
- * // Obtain credentials from LoginID
1257
- * const BASE_URL = process.env.BASE_URL;
1258
- *
1259
- * // Initialize the SDK with your configuration
1260
- * const config = {
1261
- * baseUrl: BASE_URL,
1262
- * };
1263
- *
1264
- * // Use the SDK components for signup and signin
1265
- * const lid = new LoginIDWebSDK(config);
1266
- *
1267
- * // Button click handler to generate a code with passkey
1268
- * async function handleRequestOTPButtonClick() {
1269
- * const username = "billy@loginid.io";
1270
- *
1271
- * try {
1272
- * // Request OTP with passkey
1273
- * const result = await lid.requestOtp(username);
1274
- * // Extract the OTP from the response
1275
- * const otp = result.code;
1276
- *
1277
- * // Authenticate with the OTP
1278
- * // You can authenticate on another device with this OTP
1279
- * const authenticateResult = await lid.validateOtp(username, otp);
1280
- * // Handle the authentication result
1281
- * console.log("Authentication Result:", authenticateResult);
1282
- * } catch (error) {
1283
- * // Handle errors
1284
- * console.error("Error during authentication:", error);
1285
- * }
1286
- * }
1287
- *
1288
- * // Attach the click handler to a button
1289
- * const requestOtpButton = document.getElementById("requestOtpButton");
1290
- * requestOtpButton.addEventListener("click", handleRequestOTPButtonClick);
1291
- * ```
1292
- */
1293
- validateOtp(username: string, otp: string, options?: ValidateOtpOptions): Promise<AuthResult>;
1294
- /**
1295
- * This method requests an OTP from the backend to be sent via the selected method. The method of delivery should be based on
1296
- * the user's choice from the list of available options. This can be found in the result of `authenticateWithPasskey`
1297
- * method as `fallbackOptions`.
1298
- *
1299
- * @param {string} username Username to request and send the OTP to.
1300
- * @param {Message} method Method to send the code, either 'email' or 'sms'. Default is 'email'.
1301
- * @param {RequestAndSendOtpOptions} options Additional options for sending the OTP.
1302
- * @returns {Promise<void>} A promise that resolves when the operation completes successfully.
1303
- * @example
1304
- * ```javascript
1305
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1306
- *
1307
- * // Obtain credentials from LoginID
1308
- * const BASE_URL = process.env.BASE_URL;
1309
- *
1310
- * // Initialize the SDK with your configuration
1311
- * const config = {
1312
- * baseUrl: BASE_URL,
1313
- * };
1314
- *
1315
- * // Use the SDK components for signup and signin
1316
- * const lid = new LoginIDWebSDK(config);
1317
- *
1318
- * const username = "billy@loginid.io";
1319
- *
1320
- * async function sendUserOTPHandler() {
1321
- * try {
1322
- * // Send OTP to a user via email
1323
- * await lid.requestAndSendOtp(username, "email");
1324
- * console.log("OTP sent successfully.");
1325
- * } catch (error) {
1326
- * console.error("Error sending code:", error);
1327
- * }
1328
- * }
1329
- *
1330
- * const sendOtpButton = document.getElementById("button");
1331
- * sendOtpButton.addEventListener("click", sendUserOTPHandler);
1332
- * ```
1333
- */
1334
- requestAndSendOtp(username: string, method?: Message, options?: RequestAndSendOtpOptions): Promise<void>;
1335
- }
1336
-
1337
- declare class Utils extends LoginIDBase {
1338
- /**
1339
- * Initializes a new Utils instance with the provided configuration.
1340
- *
1341
- * @param {LoginIDConfig} config Configuration object for LoginID.
1342
- */
1343
- constructor(config: LoginIDConfig);
1344
- /**
1345
- * Validates the application's configuration settings and provides a suggested correction if any issues are detected.
1346
- *
1347
- * @returns {Promise<VerifyConfigResult>} The result of the verification process.
1348
- * @example
1349
- * ```javascript
1350
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1351
- *
1352
- * // Obtain credentials from LoginID
1353
- * const BASE_URL = process.env.BASE_URL;
1354
- *
1355
- * // Initialize the SDK with your configuration
1356
- * const config = {
1357
- * baseUrl: BASE_URL,
1358
- * };
1359
- *
1360
- * const lid = new LoginIDWebSDK(config);
1361
- *
1362
- * async function checkConfig() {
1363
- * const result = await lid.verifyConfigSettings();
1364
- *
1365
- * if (result.isValid) {
1366
- * console.log('Configuration is valid');
1367
- * } else {
1368
- * console.error(`Error: ${result.message} (Code: ${result.code})`);
1369
- * console.info(`Solution: ${result.solution}`);
1370
- * }
1371
- * }
1372
- *
1373
- * checkConfig();
1374
- *
1375
- * // Attach the click handler to a button
1376
- * const checkConfigButton = document.getElementById("button");
1377
- * checkConfigButton.addEventListener("click", checkConfig);
1378
- * ```
1379
- */
1380
- verifyConfigSettings(): Promise<VerifyConfigResult>;
1381
- /**
1382
- * Check whether the user of the current browser session is authenticated and returns user info.
1383
- * This info is retrieved locally and no requests to backend are made.
1384
- *
1385
- * @returns {SessionInfo | null} The currently authenticated user's information, including username and id.
1386
- * @example
1387
- * ```javascript
1388
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1389
- *
1390
- * // Obtain credentials from LoginID
1391
- * const BASE_URL = process.env.BASE_URL;
1392
- *
1393
- * // Initialize the SDK with your configuration
1394
- * const config = {
1395
- * baseUrl: BASE_URL,
1396
- * };
1397
- *
1398
- * // Use the SDK components for signup and signin
1399
- * const lid = new LoginIDWebSDK(config);
1400
- * const username = "billy@loginid.io";
1401
- *
1402
- * try {
1403
- * // Retrieve session information
1404
- * await lid.authenticateWithPasskey(username);
1405
- * const sessionInfo = lid.getSessionInfo();
1406
- * console.log("Session Information:", sessionInfo);
1407
- * } catch (error) {
1408
- * console.error("Error retrieving session information:", error);
1409
- * }
1410
- * ```
1411
- */
1412
- getSessionInfo(): SessionInfo | null;
1413
- /**
1414
- * Clears current user session. This method is executed locally and it just deletes authorization token from local Cookies.
1415
- *
1416
- * @returns {boolean}
1417
- * @example
1418
- * ```javascript
1419
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1420
- *
1421
- * // Obtain credentials from LoginID
1422
- * const BASE_URL = process.env.BASE_URL;
1423
- *
1424
- * // Initialize the SDK with your configuration
1425
- * const config = {
1426
- * baseUrl: BASE_URL,
1427
- * };
1428
- *
1429
- * // Use the SDK components for signup and signin
1430
- * const lid = new LoginIDWebSDK(config);
1431
- *
1432
- * try {
1433
- * // Retrieve user information
1434
- * await lid.authenticateWithPasskey(username);
1435
- * lid.logout();
1436
- * const info = lid.getSessionInfo();
1437
- * // false
1438
- * console.log("Is user signed in?", info !== null);
1439
- * } catch (error) {
1440
- * console.error("Error:", error);
1441
- * }
1442
- * ```
1443
- */
1444
- logout(): void;
1445
- }
1446
-
1447
- /**
1448
- * Extends LoginIDBase to support creation and authentication of passkeys.
1449
- */
1450
- declare class Passkeys extends OTP {
1451
- /**
1452
- * Initializes a new Passkeys instance with the provided configuration.
1453
- *
1454
- * @param {LoginIDConfig} config Configuration object for LoginID.
1455
- *
1456
- */
1457
- constructor(config: LoginIDConfig);
1458
- /**
1459
- * A helper function that creates a public-key credential using WebAuthn API. It is designed to be used with LoginID's
1460
- * passkey creation flow. The function takes a registration initialization response and returns a registration completion request body.
1461
- *
1462
- * @param {RegInit} regInitResponseBody The response body from registration initialization.
1463
- * @returns {Promise<RegRegCompleteRequestBody>} Completion request body for registration.
1464
- */
1465
- private createNavigatorCredential;
1466
- /**
1467
- * This method helps to create a passkey. The only required parameter is the username, but additional attributes can be provided in the options parameter.
1468
- * Note: While the authorization token is optional, it must always be used in a production environment. You can skip it during development by adjusting
1469
- * the app configuration in the LoginID dashboard.
1470
- *
1471
- * A short-lived authorization token is returned, allowing access to protected resources for the given user such as listing, renaming or deleting passkeys.
1472
- *
1473
- * @param {string} username Username to register.
1474
- * @param {string} authzToken Authorization token for passkey creation.
1475
- * @param {CreatePasskeyOptions} options Additional passkey creation options.
1476
- * @returns {Promise<AuthResult>} Result of the passkey creation operation.
1477
- * @example
1478
- * ```javascript
1479
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1480
- *
1481
- * // Obtain credentials from LoginID
1482
- * const BASE_URL = process.env.BASE_URL;
1483
- *
1484
- * // Initialize the SDK with your configuration
1485
- * const config = {
1486
- * baseUrl: BASE_URL,
1487
- * };
1488
- *
1489
- * // Use the SDK components for signup and signin
1490
- * const lid = new LoginIDWebSDK(config);
1491
- *
1492
- * // Button click handler
1493
- * async function handleSignupButtonClick() {
1494
- * const username = "billy@loginid.io";
1495
- *
1496
- * try {
1497
- * // Sign up with a passkey
1498
- * const signupResult = await lid.createPasskey(username);
1499
- * // Handle the signup result
1500
- * console.log("Signup Result:", signupResult);
1501
- * } catch (error) {
1502
- * // Handle errors
1503
- * console.error("Error during signup:", error);
1504
- * }
1505
- * }
1506
- *
1507
- * // Attach the click handler to a button
1508
- * const signinButton = document.getElementById("signinButton");
1509
- * signinButton.addEventListener("click", handleSigninButtonClick);
1510
- * ```
1511
- */
1512
- createPasskey(username: string, authzToken?: string, options?: CreatePasskeyOptions): Promise<AuthResult>;
1513
- /**
1514
- * A helper function that attempts public-key credential authentication using WebAuthn API. It is designed to be used with LoginID's
1515
- * passkey authentication flow. The function takes an authentication initialization response and returns an authentication completion request body.
1516
- *
1517
- * @param {AuthInit} authInitResponseBody The response body from authentication initialization.
1518
- * @param {AuthenticateWithPasskeysOptions} options Additional options for authentication.
1519
- * @returns {Promise<AuthAuthCompleteRequestBody>} Completion request body for authentication.
1520
- */
1521
- private getNavigatorCredential;
1522
- /**
1523
- * This method authenticates a user with a passkey and may trigger additional browser dialogs to guide the user through the process.
1524
- *
1525
- * A short-lived authorization token is returned, allowing access to protected resources for the given user such as listing, renaming or deleting passkeys.
1526
- *
1527
- * @param {string} username Username to authenticate. When empty, usernameless passkey authentication is performed.
1528
- * @param {AuthenticateWithPasskeysOptions} options Additional authentication options.
1529
- * @returns {Promise<AuthResult>} Result of the passkey authentication operation.
1530
- * @example
1531
- * ```javascript
1532
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1533
- *
1534
- * // Obtain credentials from LoginID
1535
- * const BASE_URL = process.env.BASE_URL;
1536
- *
1537
- * // Initialize the SDK with your configuration
1538
- * const config = {
1539
- * baseUrl: BASE_URL,
1540
- * };
1541
- *
1542
- * // Use the SDK components for signup and signin
1543
- * const lid = new LoginIDWebSDK(config);
1544
- *
1545
- * // Button click handler
1546
- * async function handleSignupButtonClick() {
1547
- * const username = "billy@loginid.io";
1548
- *
1549
- * try {
1550
- * // Sign in with a passkey
1551
- * const signinResult = await lid.authenticateWithPasskey(username);
1552
- * // Handle the signin result
1553
- * console.log("Signin Result:", signinResult);
1554
- * } catch (error) {
1555
- * // Handle errors
1556
- * console.error("Error during signin:", error);
1557
- * }
1558
- * }
1559
- *
1560
- * // Attach the click handler to a button
1561
- * const signinButton = document.getElementById("signinButton");
1562
- * signinButton.addEventListener("click", handleSigninButtonClick);
1563
- * ```
1564
- */
1565
- authenticateWithPasskey(username?: string, options?: AuthenticateWithPasskeysOptions): Promise<AuthResult>;
1566
- /**
1567
- * Authenticates a user by utilizing the browser's passkey autofill capabilities.
1568
- *
1569
- * A short-lived authorization token is returned, allowing access to protected resources for the given user such as listing, renaming or deleting passkeys.
1570
- *
1571
- * @param {AuthenticateWithPasskeyAutofillOptions} options Additional authentication options.
1572
- * @returns {Promise<AuthResult>} Result of the passkey authentication operation.
1573
- * @example
1574
- * * import { isConditionalUIAvailable, LoginIDWebSDK } from "@loginid/websdk3";
1575
- *
1576
- * // Obtain credentials from LoginID
1577
- * const BASE_URL = process.env.BASE_URL;
1578
- *
1579
- * // Initialize the SDK with your configuration
1580
- * const config = {
1581
- * baseUrl: BASE_URL,
1582
- * };
1583
- *
1584
- * // Use the SDK components for signup and signin
1585
- * const lid = new LoginIDWebSDK(config);
1586
- *
1587
- * window.addEventListener("load", async (event) => {
1588
- * try {
1589
- * const result = await isConditionalUIAvailable();
1590
- * if (!result) {
1591
- * // If conditional UI is not supported then continue without it or handle what to do
1592
- * // next here.
1593
- * return;
1594
- * }
1595
- *
1596
- * const result = await lid.authenticateWithPasskeyAutofill();
1597
- * console.log("Authentication Result:", result);
1598
- * } catch (error) {
1599
- * // Handle errors
1600
- * console.error("Error during authentication:", error);
1601
- * }
1602
- * });
1603
- */
1604
- authenticateWithPasskeyAutofill(options?: AuthenticateWithPasskeyAutofillOptions): Promise<AuthResult>;
1605
- /**
1606
- * This method returns a one-time OTP to be displayed on the current device. The user must be authenticated on this device.
1607
- * The OTP is meant for cross-authentication, where the user reads the OTP from the screen and enters it on the target device.
1608
- *
1609
- * @param {string} username The username used for passkey authentication and OTP request.
1610
- * @param {RequestOtpOptions} options Additional request OTP options.
1611
- * @returns {Promise<Otp>} Result of the request OTP operation returning an OTP and expiry time.
1612
- * @example
1613
- * ```javascript
1614
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1615
- *
1616
- * // Obtain credentials from LoginID
1617
- * const BASE_URL = process.env.BASE_URL;
1618
- *
1619
- * // Initialize the SDK with your configuration
1620
- * const config = {
1621
- * baseUrl: BASE_URL,
1622
- * };
1623
- *
1624
- * // Use the SDK components for signup and signin
1625
- * const lid = new LoginIDWebSDK(config);
1626
- *
1627
- * // Button click handler
1628
- * async function handleRequestOTPButtonClick() {
1629
- * const username = "billy@loginid.io";
1630
- *
1631
- * try {
1632
- * // Request OTP with passkey
1633
- * const result = await lid.requestOtp(username);
1634
- * const otp = result.code;
1635
- * console.log("The OTP is: ", otp);
1636
- * } catch (error) {
1637
- * // Handle errors
1638
- * console.error("Error during authentication:", error);
1639
- * }
1640
- * }
1641
- *
1642
- * // Attach the click handler to a button
1643
- * const requestOTPButton = document.getElementById("requestOTPButton");
1644
- * requestOTPButton.addEventListener("click", handleRequestOTPButtonClick);
1645
- * ```
1646
- */
1647
- requestOtp(username: string, options?: RequestOtpOptions): Promise<Otp>;
1648
- /**
1649
- * This method initiates a non-repudiation signature process by generating a transaction-specific challenge
1650
- * and then expects the client to provide an assertion response using a passkey.
1651
- *
1652
- * This method is useful for confirming actions such as payments
1653
- * or changes to sensitive account information, ensuring that the transaction is being authorized
1654
- * by the rightful owner of the passkey.
1655
- *
1656
- * For a more detailed guide click [here](https://docs.loginid.io/scenarios/transaction-confirmation).
1657
- *
1658
- * @param {string} username The username of the user confirming the transaction.
1659
- * @param {string} txPayload The transaction-specific payload, which could include details
1660
- * such as the transaction amount, recipient, and other metadata necessary for the transaction.
1661
- * @param {ConfirmTransactionOptions} options Optional parameters for transaction confirmation.
1662
- * @returns {Promise<TxComplete>} A promise that resolves with the result of the transaction confirmation operation.
1663
- * The result includes details about the transaction's details and includes a new JWT access token.
1664
- * @example
1665
- * ```javascript
1666
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1667
- *
1668
- * const config = {
1669
- * baseUrl: BASE_URL,
1670
- * };
1671
- *
1672
- * const lid = new LoginIDWebSDK(config);
1673
- *
1674
- * const username = "jane@securelogin.com";
1675
- * const txPayload = JSON.stringify({
1676
- * amount: 100,
1677
- * recipient: "bob@securepay.com",
1678
- * });
1679
- * // Unique transaction nonce
1680
- * const nonce = "f846bb01-492e-422b-944a-44b04adc441e";
1681
- *
1682
- * async function handleTransactionConfirmation() {
1683
- * try {
1684
- * // Confirm the transaction
1685
- * const confirmationResult = await lid.confirmTransaction(
1686
- * username,
1687
- * txPayload,
1688
- * nonce
1689
- * );
1690
- * // Handle the transaction confirmation result
1691
- * console.log("Transaction Confirmation Result:", confirmationResult);
1692
- *
1693
- * // Check nonce
1694
- * const { nonce: resultNonce } = confirmationResult;
1695
- * if (nonce !== resultNonce) {
1696
- * throw new Error("Nonce mismatch");
1697
- * }
1698
- * } catch (error) {
1699
- * // Handle errors
1700
- * console.error("Error during transaction confirmation:", error);
1701
- * }
1702
- * }
1703
- *
1704
- * // Attach the click handler to a button for transaction confirmation
1705
- * const confirmTransactionButton = document.getElementById(
1706
- * "confirmTransactionButton"
1707
- * );
1708
- * confirmTransactionButton.addEventListener(
1709
- * "click",
1710
- * handleTransactionConfirmation
1711
- * );
1712
- * ```
1713
- */
1714
- confirmTransaction(username: string, txPayload: string, options?: ConfirmTransactionOptions): Promise<TxComplete>;
1715
- }
1716
-
1717
- /**
1718
- * Extends LoginIDBase to manage Passkeys, including listing, renaming, and deleting passkeys.
1719
- */
1720
- declare class PasskeyManager extends LoginIDBase {
1721
- /**
1722
- * Initializes a new instance of PasskeyManager with the provided configuration.
1723
- *
1724
- * @param {LoginIDConfig} config Configuration object for LoginID.
1725
- */
1726
- constructor(config: LoginIDConfig);
1727
- /**
1728
- * This method returns list of passkeys associated with the current user. The user must be fully authorized for this call to succeed.
1729
- *
1730
- * @param {ListPasskeysOptions} options Additional options for listing passkeys.
1731
- * @returns {Promise<PasskeyCollection>} A collection of passkeys.
1732
- * @example
1733
- * ```javascript
1734
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1735
- *
1736
- * // Obtain credentials from LoginID
1737
- * const BASE_URL = process.env.BASE_URL;
1738
- *
1739
- * // Initialize the SDK with your configuration
1740
- * const config = {
1741
- * baseUrl: BASE_URL,
1742
- * };
1743
- *
1744
- * // Use the SDK components for signup and signin
1745
- * const lid = new LoginIDWebSDK(config);
1746
- *
1747
- * // Button click handler for signing in
1748
- * async function handleSigninButtonClick() {
1749
- * const username = "billy@loginid.io";
1750
- *
1751
- * try {
1752
- * // Sign in with a passkey
1753
- * await lid.authenticateWithPasskey(username);
1754
- *
1755
- * // List all user credentials
1756
- * const passkeys = await lid.listPasskeys();
1757
- * // Handle the sign-in result
1758
- * } catch (error) {
1759
- * // Handle errors
1760
- * console.error("Error during obtaining passkeys:", error);
1761
- * }
1762
- * }
1763
- *
1764
- * // Attach the click handler to a button
1765
- * const signinButton = document.getElementById("signinButton");
1766
- * signinButton.addEventListener("click", handleSigninButtonClick);
1767
- * ```
1768
- */
1769
- listPasskeys(options?: ListPasskeysOptions): Promise<PasskeyCollection>;
1770
- /**
1771
- * Renames a specified passkey by ID. The user must be fully authorized for this call to succeed.
1772
- *
1773
- * @param {string} id The ID of the passkey to rename.
1774
- * @param {string} name The new name for the passkey.
1775
- * @param {RenamePasskeyOptions} options Additional options for renaming the passkey.
1776
- * @returns {Promise<void>} A promise that resolves when the operation completes successfully.
1777
- * @example
1778
- * ```javascript
1779
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1780
- *
1781
- * // Obtain credentials from LoginID
1782
- * const BASE_URL = process.env.BASE_URL;
1783
- *
1784
- * // Initialize the SDK with your configuration
1785
- * const config = {
1786
- * baseUrl: BASE_URL,
1787
- * };
1788
- *
1789
- * // Use the SDK components for signup and signin
1790
- * const lid = new LoginIDWebSDK(config);
1791
- *
1792
- * const passkeyId = "abc123";
1793
- * const newCredName = "New Passkey Credential Name";
1794
- *
1795
- * // Rename the passkey user credential
1796
- * try {
1797
- * // Signin with passkey
1798
- * await lid.authenticateWithPasskey(username);
1799
- *
1800
- * // Find a way to retrieve passkey ID
1801
- * await lid.renamePasskey(passkeyId, newCredName);
1802
- * // Passkey credential successfully renamed
1803
- * } catch (error) {
1804
- * // Handle errors
1805
- * console.error("Error during passkey credential renaming:", error);
1806
- * }
1807
- * ```
1808
- */
1809
- renamePasskey(id: string, name: string, options?: RenamePasskeyOptions): Promise<void>;
1810
- /**
1811
- * Delete a specified passkey by ID from LoginID. The user must be fully authorized for this call to succeed.
1812
- *
1813
- * @param {string} id The ID of the passkey to delete.
1814
- * @param {DeletePasskeyOptions} options Additional options for deleting the passkey.
1815
- * @returns {Promise<void>} A promise that resolves when the operation completes successfully.
1816
- * @example
1817
- * ```javascript
1818
- * import { LoginIDWebSDK } from "@loginid/websdk3";
1819
- *
1820
- * // Obtain credentials from LoginID
1821
- * const BASE_URL = process.env.BASE_URL;
1822
- *
1823
- * // Initialize the SDK with your configuration
1824
- * const config = {
1825
- * baseUrl: BASE_URL,
1826
- * };
1827
- *
1828
- * // Use the SDK components for signup and signin
1829
- * const lid = new LoginIDWebSDK(config);
1830
- *
1831
- * const passkeyId = "abc123";
1832
- *
1833
- * // Delete the passkey user credential
1834
- * try {
1835
- * // Signin with passkey
1836
- * const signinResult = await lid.authenticateWithPasskey(username);
1837
- *
1838
- * // Find a way to retrieve passkey ID
1839
- * await lid.deletePasskey(passkeyId);
1840
- * // Passkey credential successfully deleted
1841
- * } catch (error) {
1842
- * // Handle errors
1843
- * console.error("Error deleting passkey:", error);
1844
- * }
1845
- * ```
1846
- */
1847
- deletePasskey(id: string, options?: DeletePasskeyOptions): Promise<void>;
1848
- }
1849
-
1850
- interface LoginIDWebSDK extends Passkeys, OTP, PasskeyManager, Utils {
1851
- }
1852
- declare class LoginIDWebSDK extends LoginIDBase {
1853
- constructor(config: LoginIDConfig);
1854
- }
1855
-
1856
- /**
1857
- * Error class for abort-related errors.
1858
- */
1859
- declare class AbortError extends Error {
1860
- /**
1861
- * Initializes a new instance of AbortError with the provided message.
1862
- *
1863
- * @type {Error}
1864
- * @memberof AbortError
1865
- */
1866
- constructor(message: string);
1867
- }
1868
-
1869
- type PasskeyErrorCode = 'ERROR_PASSKEY_ABORTED' | 'ERROR_DISCOVERABLE_CREDENTIALS_UNSUPPORTED' | 'ERROR_USER_VERIFICATION_UNSUPPORTED' | 'ERROR_PASSKEY_EXISTS' | 'ERROR_GENERAL_ERROR_SEE_CAUSE_FIELD' | 'ERROR_ALGORITHMS_UNSUPPORTED' | 'ERROR_DOMAIN_MISMATCH' | 'ERROR_AUTHENTICATOR_UNKNOWN_ERROR';
1870
-
1871
- /**
1872
- * Error class for passkey-related errors.
1873
- */
1874
- declare class PasskeyError extends Error {
1875
- readonly code: PasskeyErrorCode;
1876
- /**
1877
- * Initializes a new instance of PasskeyError with the provided message, code, and original error.
1878
- *
1879
- * @type {Error}
1880
- * @memberof PasskeyError
1881
- */
1882
- constructor(message: string, code: PasskeyErrorCode, originalError: Error);
1883
- }
1884
-
1885
- declare class WebAuthnHelper {
1886
- /**
1887
- * Retrieves a navigator credential for authentication.
1888
- * @param {AuthInit} authInitResponseBody The response body from authentication initialization.
1889
- * @param {AuthenticateWithPasskeysOptions} options Additional options for authentication.
1890
- * @returns {Promise<AuthAuthCompleteRequestBody>} Completion request body for authentication.
1891
- */
1892
- static getNavigatorCredential(authInitResponseBody: AuthInit, options?: AuthenticateWithPasskeysOptions): Promise<AuthCompleteRequestBody>;
1893
- /**
1894
- * Creates a navigator credential using WebAuthn.
1895
- * @param {RegInit} regInitResponseBody The response body from registration initialization.
1896
- * @returns {Promise<RegRegCompleteRequestBody>} Completion request body for registration.
1897
- */
1898
- static createNavigatorCredential(regInitResponseBody: RegInit): Promise<RegCompleteRequestBody>;
1899
- }
1900
-
1901
- /**
1902
- * Asynchronously creates a passkey credential using the provided registration response.
1903
- *
1904
- * @param {IRegisterPasskeyInitResponse} init - The registration initiation response.
1905
- * @returns {Promise<PublicKeyCredential>} A promise that resolves to the passkey credential.
1906
- * @throws {LoginIdError} If any errors occur during credential creation or if the credential type is invalid.
1907
- */
1908
- declare const createPasskeyCredential: (init: PublicKeyCredentialCreationOptions) => Promise<PublicKeyCredential>;
1909
- /**
1910
- * Asynchronously retrieves a passkey credential for authentication using the provided request options.
1911
- *
1912
- * @param {publicKeyCredentialRequestOptionsResponseBody} init - The authentication initiation response.
1913
- * @param {AuthenticateWithPasskeysOptions} options - Additional options for the authentication request.
1914
- * @returns {Promise<PublicKeyCredential>} A promise that resolves to the passkey credential.
1915
- */
1916
- declare const getPasskeyCredential: (init: PublicKeyCredentialRequestOptions, options?: AuthenticateWithPasskeysOptions) => Promise<PublicKeyCredential>;
1917
-
1918
- /**
1919
- * Checks if platform authenticator available
1920
- * */
1921
- declare function isPlatformAuthenticatorAvailable(): Promise<boolean>;
1922
- /**
1923
- * Checks if conditional UI is available
1924
- * */
1925
- declare function isConditionalUIAvailable(): Promise<boolean>;
1926
-
1927
- export { AbortError, type AllOptions, ApiError, type AuthResult, type AuthenticateWithPasskeyAutofillOptions, type AuthenticateWithPasskeysOptions, type Callbacks, type Complete, type ConfirmTransactionOptions, type CreatePasskeyOptions, type DeletePasskeyOptions, type DeviceInfoRequestBody, type FallbackCallback, type FallbackOptions, type ListPasskeysOptions, index as LoginIDAPI, type LoginIDConfig, LoginIDWebSDK, type Message, type Otp, type Passkey, type PasskeyCollection, PasskeyError, type PasskeyManagementOptions, type PasskeyOptions, type RenamePasskeyOptions, type RequestAndSendOtpOptions, type RequestOtpOptions, type SessionInfo, type SuccessCallback, type Transports, type TrustIDClaims, type TrustIDRecord, type UsernameType, type ValidateOtpOptions, type VerifyConfigResult, WebAuthnHelper, createPasskeyCredential, LoginIDWebSDK as default, getPasskeyCredential, isConditionalUIAvailable, isPlatformAuthenticatorAvailable };