@fourt/sdk 0.5.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +281 -192
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +97 -60
- package/dist/index.d.ts +97 -60
- package/dist/index.js +271 -192
- package/dist/index.js.map +1 -1
- package/package.json +10 -8
package/dist/index.js
CHANGED
|
@@ -1,57 +1,3 @@
|
|
|
1
|
-
// src/signer/web.ts
|
|
2
|
-
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
|
|
3
|
-
import { IframeStamper } from "@turnkey/iframe-stamper";
|
|
4
|
-
|
|
5
|
-
// src/signer/index.ts
|
|
6
|
-
import { TurnkeyClient } from "@turnkey/http";
|
|
7
|
-
|
|
8
|
-
// src/errors/SDKError.ts
|
|
9
|
-
var SDKError = class extends Error {
|
|
10
|
-
_props;
|
|
11
|
-
constructor(message, props) {
|
|
12
|
-
super(message);
|
|
13
|
-
this._props = props;
|
|
14
|
-
}
|
|
15
|
-
get message() {
|
|
16
|
-
return this._props.message;
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
// src/errors/UnauthorizedError.ts
|
|
21
|
-
var UnauthorizedError = class _UnauthorizedError extends SDKError {
|
|
22
|
-
constructor(props) {
|
|
23
|
-
super(_UnauthorizedError.name, props);
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
// src/errors/NotFoundError.ts
|
|
28
|
-
var NotFoundError = class _NotFoundError extends SDKError {
|
|
29
|
-
constructor(props) {
|
|
30
|
-
super(_NotFoundError.name, props);
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
// src/errors/GenericError.ts
|
|
35
|
-
var GenericError = class _GenericError extends SDKError {
|
|
36
|
-
constructor(props) {
|
|
37
|
-
super(_GenericError.name, props);
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
// src/errors/UnauthenticatedError.ts
|
|
42
|
-
var UnauthenticatedError = class _UnauthenticatedError extends SDKError {
|
|
43
|
-
constructor(props) {
|
|
44
|
-
super(_UnauthenticatedError.name, props);
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
// src/errors/BadRequestError.ts
|
|
49
|
-
var BadRequestError = class _BadRequestError extends SDKError {
|
|
50
|
-
constructor(props) {
|
|
51
|
-
super(_BadRequestError.name, props);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
1
|
// src/session/index.ts
|
|
56
2
|
import { createStore } from "zustand";
|
|
57
3
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
@@ -175,6 +121,255 @@ var SessionStore = class {
|
|
|
175
121
|
}
|
|
176
122
|
};
|
|
177
123
|
|
|
124
|
+
// src/modules/auth/email.ts
|
|
125
|
+
var EmailModule = class {
|
|
126
|
+
constructor(_webSignerClient) {
|
|
127
|
+
this._webSignerClient = _webSignerClient;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Initialize user authentication process using email.
|
|
131
|
+
*
|
|
132
|
+
* @param params {EmailInitializeAuthParams} params to initialize the user authentication process.
|
|
133
|
+
* @returns {Promise<void>} promise that resolves to the result of the authentication process.
|
|
134
|
+
*/
|
|
135
|
+
async initialize(params) {
|
|
136
|
+
return this._webSignerClient.emailAuth(params);
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
|
|
140
|
+
*
|
|
141
|
+
* @param params {CompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
|
|
142
|
+
* @returns {Promise<void>} promise that completes the authentication process.
|
|
143
|
+
*/
|
|
144
|
+
async complete(params) {
|
|
145
|
+
return this._webSignerClient.completeAuthWithBundle({
|
|
146
|
+
...params,
|
|
147
|
+
sessionType: "email" /* Email */
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
// src/modules/auth/passkeys.ts
|
|
153
|
+
var PasskeysModule = class {
|
|
154
|
+
constructor(_webSignerClient) {
|
|
155
|
+
this._webSignerClient = _webSignerClient;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Signs in a user using Passkeys.
|
|
159
|
+
*
|
|
160
|
+
* @param params {WebauthnSignInParams} params for the sign-in process.
|
|
161
|
+
* @returns {Promise<void>} promise that resolves to the result of the sign-in process.
|
|
162
|
+
*/
|
|
163
|
+
async signIn(params) {
|
|
164
|
+
return this._webSignerClient.webauthnSignIn(params);
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
// src/modules/auth/oauth/google.ts
|
|
169
|
+
import * as jose from "jose";
|
|
170
|
+
import { sha256 } from "sha.js";
|
|
171
|
+
|
|
172
|
+
// src/errors/SDKError.ts
|
|
173
|
+
var SDKError = class extends Error {
|
|
174
|
+
_props;
|
|
175
|
+
constructor(message, props) {
|
|
176
|
+
super(message);
|
|
177
|
+
this._props = props;
|
|
178
|
+
}
|
|
179
|
+
get message() {
|
|
180
|
+
return this._props.message;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
// src/errors/BadRequestError.ts
|
|
185
|
+
var BadRequestError = class _BadRequestError extends SDKError {
|
|
186
|
+
constructor(props) {
|
|
187
|
+
super(_BadRequestError.name, props);
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
// src/modules/auth/oauth/google.ts
|
|
192
|
+
var GoogleModule = class {
|
|
193
|
+
constructor(_webSignerClient) {
|
|
194
|
+
this._webSignerClient = _webSignerClient;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
*
|
|
198
|
+
* @returns
|
|
199
|
+
*/
|
|
200
|
+
async init() {
|
|
201
|
+
if (!this._webSignerClient.oauthConfiguration?.google) {
|
|
202
|
+
throw new BadRequestError({ message: "Google OAuth is not configured" });
|
|
203
|
+
}
|
|
204
|
+
const url = new URL("https://accounts.google.com/o/oauth2/v2/auth");
|
|
205
|
+
url.searchParams.set(
|
|
206
|
+
"client_id",
|
|
207
|
+
this._webSignerClient.oauthConfiguration?.google?.clientId
|
|
208
|
+
);
|
|
209
|
+
url.searchParams.set("response_type", "code");
|
|
210
|
+
url.searchParams.set("scope", "openid email");
|
|
211
|
+
const internalUrl = new URL(
|
|
212
|
+
"v1/oauth",
|
|
213
|
+
this._webSignerClient.configuration.apiUrl
|
|
214
|
+
).href;
|
|
215
|
+
url.searchParams.set("redirect_uri", internalUrl);
|
|
216
|
+
const publicKey = await this._webSignerClient.getIframePublicKey();
|
|
217
|
+
const nonce = new sha256().update(publicKey).digest("hex");
|
|
218
|
+
url.searchParams.set("nonce", nonce);
|
|
219
|
+
const state = new jose.UnsecuredJWT({
|
|
220
|
+
apiKey: this._webSignerClient.configuration.apiKey,
|
|
221
|
+
redirectUrl: this._webSignerClient.oauthConfiguration.common.redirectUrl,
|
|
222
|
+
targetPublicKey: publicKey,
|
|
223
|
+
internalUrl,
|
|
224
|
+
origin: window.location.origin
|
|
225
|
+
}).encode();
|
|
226
|
+
url.searchParams.set("state", state);
|
|
227
|
+
return url.toString();
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// src/modules/auth/oauth.ts
|
|
232
|
+
var OAuthModule = class {
|
|
233
|
+
constructor(_webSignerClient) {
|
|
234
|
+
this._webSignerClient = _webSignerClient;
|
|
235
|
+
this._googleModule = new GoogleModule(this._webSignerClient);
|
|
236
|
+
}
|
|
237
|
+
_googleModule;
|
|
238
|
+
get google() {
|
|
239
|
+
return this._googleModule;
|
|
240
|
+
}
|
|
241
|
+
async complete({ bundle, subOrgId }) {
|
|
242
|
+
await this._webSignerClient.completeAuthWithBundle({
|
|
243
|
+
bundle,
|
|
244
|
+
subOrgId,
|
|
245
|
+
sessionType: "oauth" /* OAuth */
|
|
246
|
+
});
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
// src/modules/auth/index.ts
|
|
251
|
+
var AuthModule = class {
|
|
252
|
+
/**
|
|
253
|
+
* Initializes a new instance of the `AuthModule` class.
|
|
254
|
+
*
|
|
255
|
+
* @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.
|
|
256
|
+
*/
|
|
257
|
+
constructor(_webSignerClient) {
|
|
258
|
+
this._webSignerClient = _webSignerClient;
|
|
259
|
+
this._passkeys = new PasskeysModule(this._webSignerClient);
|
|
260
|
+
this._email = new EmailModule(this._webSignerClient);
|
|
261
|
+
this._oauth = new OAuthModule(this._webSignerClient);
|
|
262
|
+
}
|
|
263
|
+
_passkeys;
|
|
264
|
+
_email;
|
|
265
|
+
_oauth;
|
|
266
|
+
/**
|
|
267
|
+
* A module for interacting with the Passkeys authentication methods.
|
|
268
|
+
*/
|
|
269
|
+
get passkeys() {
|
|
270
|
+
return this._passkeys;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A module for interacting with the Passkeys authentication methods.
|
|
274
|
+
*/
|
|
275
|
+
get email() {
|
|
276
|
+
return this._email;
|
|
277
|
+
}
|
|
278
|
+
get oauth() {
|
|
279
|
+
return this._oauth;
|
|
280
|
+
}
|
|
281
|
+
};
|
|
282
|
+
|
|
283
|
+
// src/modules/user/index.ts
|
|
284
|
+
var UserModule = class {
|
|
285
|
+
/**
|
|
286
|
+
* Initializes a new instance of the `UserModule` class.
|
|
287
|
+
*
|
|
288
|
+
* @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.
|
|
289
|
+
*/
|
|
290
|
+
constructor(_webSignerClient) {
|
|
291
|
+
this._webSignerClient = _webSignerClient;
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* Gets the user information.
|
|
295
|
+
*
|
|
296
|
+
* @returns {User | undefined} user information.
|
|
297
|
+
*/
|
|
298
|
+
get info() {
|
|
299
|
+
return this._webSignerClient.user;
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Logs out the user.
|
|
303
|
+
*
|
|
304
|
+
* @returns {void}
|
|
305
|
+
*/
|
|
306
|
+
logout() {
|
|
307
|
+
return this._webSignerClient.logout();
|
|
308
|
+
}
|
|
309
|
+
};
|
|
310
|
+
|
|
311
|
+
// src/signer/web.ts
|
|
312
|
+
import { getWebAuthnAttestation } from "@turnkey/http";
|
|
313
|
+
import { IframeStamper } from "@turnkey/iframe-stamper";
|
|
314
|
+
import { WebauthnStamper } from "@turnkey/webauthn-stamper";
|
|
315
|
+
|
|
316
|
+
// src/lib/base64.ts
|
|
317
|
+
import { Buffer } from "buffer";
|
|
318
|
+
var LibBase64 = class {
|
|
319
|
+
static fromBuffer(buffer) {
|
|
320
|
+
return Buffer.from(buffer).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
321
|
+
}
|
|
322
|
+
static toBuffer(base64) {
|
|
323
|
+
return Buffer.from(base64, "base64");
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
|
|
327
|
+
// src/lib/bytes.ts
|
|
328
|
+
var LibBytes = class {
|
|
329
|
+
static generateRandomBuffer = () => {
|
|
330
|
+
const arr = new Uint8Array(32);
|
|
331
|
+
crypto.getRandomValues(arr);
|
|
332
|
+
return arr.buffer;
|
|
333
|
+
};
|
|
334
|
+
static takeBytes = (bytes, params = {}) => {
|
|
335
|
+
const { offset, count } = params;
|
|
336
|
+
const start = (offset ? offset * 2 : 0) + 2;
|
|
337
|
+
const end = count ? start + count * 2 : void 0;
|
|
338
|
+
return `0x${bytes.slice(start, end)}`;
|
|
339
|
+
};
|
|
340
|
+
};
|
|
341
|
+
|
|
342
|
+
// src/signer/index.ts
|
|
343
|
+
import { TurnkeyClient } from "@turnkey/http";
|
|
344
|
+
|
|
345
|
+
// src/errors/UnauthorizedError.ts
|
|
346
|
+
var UnauthorizedError = class _UnauthorizedError extends SDKError {
|
|
347
|
+
constructor(props) {
|
|
348
|
+
super(_UnauthorizedError.name, props);
|
|
349
|
+
}
|
|
350
|
+
};
|
|
351
|
+
|
|
352
|
+
// src/errors/NotFoundError.ts
|
|
353
|
+
var NotFoundError = class _NotFoundError extends SDKError {
|
|
354
|
+
constructor(props) {
|
|
355
|
+
super(_NotFoundError.name, props);
|
|
356
|
+
}
|
|
357
|
+
};
|
|
358
|
+
|
|
359
|
+
// src/errors/GenericError.ts
|
|
360
|
+
var GenericError = class _GenericError extends SDKError {
|
|
361
|
+
constructor(props) {
|
|
362
|
+
super(_GenericError.name, props);
|
|
363
|
+
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
// src/errors/UnauthenticatedError.ts
|
|
367
|
+
var UnauthenticatedError = class _UnauthenticatedError extends SDKError {
|
|
368
|
+
constructor(props) {
|
|
369
|
+
super(_UnauthenticatedError.name, props);
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
178
373
|
// src/types/Routes.ts
|
|
179
374
|
var ROUTE_METHOD_MAP = {
|
|
180
375
|
"/v1/signup": "POST",
|
|
@@ -202,8 +397,8 @@ var SignerClient = class {
|
|
|
202
397
|
);
|
|
203
398
|
this._configuration = {
|
|
204
399
|
...requiredConfiguration,
|
|
205
|
-
apiUrl: apiUrl ?? "https://auth.api.
|
|
206
|
-
paymasterRpcUrl: paymasterRpcUrl ?? "https://management.api.
|
|
400
|
+
apiUrl: apiUrl ?? "https://auth.api.fourt.io/",
|
|
401
|
+
paymasterRpcUrl: paymasterRpcUrl ?? "https://management.api.fourt.io/"
|
|
207
402
|
};
|
|
208
403
|
this._sessionStore = new SessionStore();
|
|
209
404
|
}
|
|
@@ -340,36 +535,10 @@ var SignerClient = class {
|
|
|
340
535
|
}
|
|
341
536
|
};
|
|
342
537
|
|
|
343
|
-
// src/lib/base64.ts
|
|
344
|
-
import { Buffer } from "buffer";
|
|
345
|
-
var LibBase64 = class {
|
|
346
|
-
static fromBuffer(buffer) {
|
|
347
|
-
return Buffer.from(buffer).toString("base64").replace(/\+/g, "-").replace(/\//g, "_").replace(/=/g, "");
|
|
348
|
-
}
|
|
349
|
-
static toBuffer(base64) {
|
|
350
|
-
return Buffer.from(base64, "base64");
|
|
351
|
-
}
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
// src/lib/bytes.ts
|
|
355
|
-
var LibBytes = class {
|
|
356
|
-
static generateRandomBuffer = () => {
|
|
357
|
-
const arr = new Uint8Array(32);
|
|
358
|
-
crypto.getRandomValues(arr);
|
|
359
|
-
return arr.buffer;
|
|
360
|
-
};
|
|
361
|
-
static takeBytes = (bytes, params = {}) => {
|
|
362
|
-
const { offset, count } = params;
|
|
363
|
-
const start = (offset ? offset * 2 : 0) + 2;
|
|
364
|
-
const end = count ? start + count * 2 : void 0;
|
|
365
|
-
return `0x${bytes.slice(start, end)}`;
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
|
|
369
538
|
// src/signer/web.ts
|
|
370
|
-
import { getWebAuthnAttestation } from "@turnkey/http";
|
|
371
539
|
var WebSignerClient = class extends SignerClient {
|
|
372
540
|
_stampers;
|
|
541
|
+
oauthConfiguration;
|
|
373
542
|
/**
|
|
374
543
|
* Initializes a new instance of the `WebSignerClient` class.
|
|
375
544
|
*
|
|
@@ -378,7 +547,8 @@ var WebSignerClient = class extends SignerClient {
|
|
|
378
547
|
constructor({
|
|
379
548
|
configuration,
|
|
380
549
|
webauthn,
|
|
381
|
-
iframe
|
|
550
|
+
iframe,
|
|
551
|
+
oauth
|
|
382
552
|
}) {
|
|
383
553
|
const iframeContainerId = iframe?.iframeContainerId ?? "fourt-signer-iframe-container";
|
|
384
554
|
const iframeContainer = document.createElement("div");
|
|
@@ -400,6 +570,7 @@ var WebSignerClient = class extends SignerClient {
|
|
|
400
570
|
webauthn: webauthnStamper,
|
|
401
571
|
iframe: iframeStamper
|
|
402
572
|
};
|
|
573
|
+
this.oauthConfiguration = oauth;
|
|
403
574
|
}
|
|
404
575
|
async signRawMessage(msg) {
|
|
405
576
|
await this.updateStamper();
|
|
@@ -415,7 +586,7 @@ var WebSignerClient = class extends SignerClient {
|
|
|
415
586
|
*
|
|
416
587
|
*/
|
|
417
588
|
async updateStamper() {
|
|
418
|
-
if (this._sessionStore.type === void 0
|
|
589
|
+
if (this._sessionStore.type === void 0 && (this._sessionStore.bundle === void 0 || this._sessionStore.token === void 0))
|
|
419
590
|
return;
|
|
420
591
|
if (this._sessionStore.type === "passkeys" /* Passkeys */) {
|
|
421
592
|
this.stamper = this._stampers.webauthn;
|
|
@@ -423,7 +594,8 @@ var WebSignerClient = class extends SignerClient {
|
|
|
423
594
|
this.stamper = this._stampers.iframe;
|
|
424
595
|
await this.completeAuthWithBundle({
|
|
425
596
|
bundle: this._sessionStore.bundle,
|
|
426
|
-
subOrgId: this.user?.subOrgId
|
|
597
|
+
subOrgId: this.user?.subOrgId,
|
|
598
|
+
sessionType: this._sessionStore.type
|
|
427
599
|
});
|
|
428
600
|
}
|
|
429
601
|
}
|
|
@@ -465,6 +637,9 @@ var WebSignerClient = class extends SignerClient {
|
|
|
465
637
|
await this._signInWithEmail(params);
|
|
466
638
|
}
|
|
467
639
|
}
|
|
640
|
+
async getIframePublicKey() {
|
|
641
|
+
return await this._initIframeStamper();
|
|
642
|
+
}
|
|
468
643
|
/**
|
|
469
644
|
* Signs in a user with email.
|
|
470
645
|
*
|
|
@@ -475,10 +650,9 @@ var WebSignerClient = class extends SignerClient {
|
|
|
475
650
|
expirationSeconds,
|
|
476
651
|
redirectUrl
|
|
477
652
|
}) {
|
|
478
|
-
const publicKey = await this._initIframeStamper();
|
|
479
653
|
return this.request("/v1/email-auth", {
|
|
480
654
|
email,
|
|
481
|
-
targetPublicKey:
|
|
655
|
+
targetPublicKey: await this.getIframePublicKey(),
|
|
482
656
|
expirationSeconds,
|
|
483
657
|
redirectUrl: redirectUrl.toString()
|
|
484
658
|
});
|
|
@@ -486,11 +660,12 @@ var WebSignerClient = class extends SignerClient {
|
|
|
486
660
|
/**
|
|
487
661
|
* Completes the authentication process with a credential bundle.
|
|
488
662
|
*
|
|
489
|
-
* @param {
|
|
663
|
+
* @param {CompleteAuthWithBundleParams} params params for the completion of the auth process
|
|
490
664
|
*/
|
|
491
665
|
async completeAuthWithBundle({
|
|
492
666
|
bundle,
|
|
493
|
-
subOrgId
|
|
667
|
+
subOrgId,
|
|
668
|
+
sessionType
|
|
494
669
|
}) {
|
|
495
670
|
await this._initIframeStamper();
|
|
496
671
|
const result = await this._stampers.iframe.injectCredentialBundle(bundle);
|
|
@@ -498,7 +673,7 @@ var WebSignerClient = class extends SignerClient {
|
|
|
498
673
|
throw new Error("Failed to inject credential bundle");
|
|
499
674
|
}
|
|
500
675
|
await this.whoAmI(subOrgId);
|
|
501
|
-
this._sessionStore.type =
|
|
676
|
+
this._sessionStore.type = sessionType;
|
|
502
677
|
this._sessionStore.bundle = bundle;
|
|
503
678
|
}
|
|
504
679
|
/**
|
|
@@ -529,6 +704,7 @@ var WebSignerClient = class extends SignerClient {
|
|
|
529
704
|
smartAccountAddress,
|
|
530
705
|
credentialId: attestation.credentialId
|
|
531
706
|
};
|
|
707
|
+
this._sessionStore.user = this.user;
|
|
532
708
|
this._sessionStore.type = "passkeys" /* Passkeys */;
|
|
533
709
|
this._sessionStore.token = token;
|
|
534
710
|
}
|
|
@@ -539,11 +715,10 @@ var WebSignerClient = class extends SignerClient {
|
|
|
539
715
|
*/
|
|
540
716
|
async _createEmailAccount(params) {
|
|
541
717
|
const { email, expirationSeconds, redirectUrl } = params;
|
|
542
|
-
const publicKey = await this._initIframeStamper();
|
|
543
718
|
const response = await this.request("/v1/signup", {
|
|
544
719
|
email,
|
|
545
720
|
iframe: {
|
|
546
|
-
targetPublicKey:
|
|
721
|
+
targetPublicKey: await this.getIframePublicKey(),
|
|
547
722
|
expirationSeconds,
|
|
548
723
|
redirectUrl: redirectUrl.toString()
|
|
549
724
|
}
|
|
@@ -694,103 +869,6 @@ var ViemModule = class {
|
|
|
694
869
|
}
|
|
695
870
|
};
|
|
696
871
|
|
|
697
|
-
// src/modules/auth/email.ts
|
|
698
|
-
var EmailModule = class {
|
|
699
|
-
constructor(_webSignerClient) {
|
|
700
|
-
this._webSignerClient = _webSignerClient;
|
|
701
|
-
}
|
|
702
|
-
/**
|
|
703
|
-
* Initialize user authentication process using email.
|
|
704
|
-
*
|
|
705
|
-
* @param params {EmailInitializeAuthParams} params to initialize the user authentication process.
|
|
706
|
-
* @returns {Promise<void>} promise that resolves to the result of the authentication process.
|
|
707
|
-
*/
|
|
708
|
-
async initialize(params) {
|
|
709
|
-
return this._webSignerClient.emailAuth(params);
|
|
710
|
-
}
|
|
711
|
-
/**
|
|
712
|
-
* Completes authentication with bundle after user receives the bundle and subOrgId as URL params.
|
|
713
|
-
*
|
|
714
|
-
* @param params {EmailCompleteAuthWithBundleParams} params received as URL params necessary to complete authentication process.
|
|
715
|
-
* @returns {Promise<void>} promise that completes the authentication process.
|
|
716
|
-
*/
|
|
717
|
-
async complete(params) {
|
|
718
|
-
return this._webSignerClient.completeAuthWithBundle(params);
|
|
719
|
-
}
|
|
720
|
-
};
|
|
721
|
-
|
|
722
|
-
// src/modules/auth/passkeys.ts
|
|
723
|
-
var PasskeysModule = class {
|
|
724
|
-
constructor(_webSignerClient) {
|
|
725
|
-
this._webSignerClient = _webSignerClient;
|
|
726
|
-
}
|
|
727
|
-
/**
|
|
728
|
-
* Signs in a user using Passkeys.
|
|
729
|
-
*
|
|
730
|
-
* @param params {WebauthnSignInParams} params for the sign-in process.
|
|
731
|
-
* @returns {Promise<void>} promise that resolves to the result of the sign-in process.
|
|
732
|
-
*/
|
|
733
|
-
async signIn(params) {
|
|
734
|
-
return this._webSignerClient.webauthnSignIn(params);
|
|
735
|
-
}
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
// src/modules/auth/index.ts
|
|
739
|
-
var AuthModule = class {
|
|
740
|
-
/**
|
|
741
|
-
* Initializes a new instance of the `AuthModule` class.
|
|
742
|
-
*
|
|
743
|
-
* @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.
|
|
744
|
-
*/
|
|
745
|
-
constructor(_webSignerClient) {
|
|
746
|
-
this._webSignerClient = _webSignerClient;
|
|
747
|
-
this._passkeys = new PasskeysModule(this._webSignerClient);
|
|
748
|
-
this._email = new EmailModule(this._webSignerClient);
|
|
749
|
-
}
|
|
750
|
-
_passkeys;
|
|
751
|
-
_email;
|
|
752
|
-
/**
|
|
753
|
-
* A module for interacting with the Passkeys authentication methods.
|
|
754
|
-
*/
|
|
755
|
-
get passkeys() {
|
|
756
|
-
return this._passkeys;
|
|
757
|
-
}
|
|
758
|
-
/**
|
|
759
|
-
* A module for interacting with the Passkeys authentication methods.
|
|
760
|
-
*/
|
|
761
|
-
get email() {
|
|
762
|
-
return this._email;
|
|
763
|
-
}
|
|
764
|
-
};
|
|
765
|
-
|
|
766
|
-
// src/modules/user/index.ts
|
|
767
|
-
var UserModule = class {
|
|
768
|
-
/**
|
|
769
|
-
* Initializes a new instance of the `UserModule` class.
|
|
770
|
-
*
|
|
771
|
-
* @param {WebSignerClient} _webSignerClient underlying WebSigner client instance.
|
|
772
|
-
*/
|
|
773
|
-
constructor(_webSignerClient) {
|
|
774
|
-
this._webSignerClient = _webSignerClient;
|
|
775
|
-
}
|
|
776
|
-
/**
|
|
777
|
-
* Gets the user information.
|
|
778
|
-
*
|
|
779
|
-
* @returns {User | undefined} user information.
|
|
780
|
-
*/
|
|
781
|
-
get info() {
|
|
782
|
-
return this._webSignerClient.user;
|
|
783
|
-
}
|
|
784
|
-
/**
|
|
785
|
-
* Logs out the user.
|
|
786
|
-
*
|
|
787
|
-
* @returns {void}
|
|
788
|
-
*/
|
|
789
|
-
logout() {
|
|
790
|
-
return this._webSignerClient.logout();
|
|
791
|
-
}
|
|
792
|
-
};
|
|
793
|
-
|
|
794
872
|
// src/index.ts
|
|
795
873
|
var FourtWebSigner = class {
|
|
796
874
|
_webSignerClient;
|
|
@@ -818,12 +896,13 @@ var FourtWebSigner = class {
|
|
|
818
896
|
*/
|
|
819
897
|
constructor({
|
|
820
898
|
configuration,
|
|
821
|
-
auth: { webauthn, iframe }
|
|
899
|
+
auth: { webauthn, iframe, oauth }
|
|
822
900
|
}) {
|
|
823
901
|
this._webSignerClient = new WebSignerClient({
|
|
824
902
|
configuration,
|
|
825
903
|
webauthn,
|
|
826
|
-
iframe
|
|
904
|
+
iframe,
|
|
905
|
+
oauth
|
|
827
906
|
});
|
|
828
907
|
this._modules = {
|
|
829
908
|
viem: new ViemModule(this._webSignerClient),
|