@turnkey/sdk-browser 1.16.0 → 2.0.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/CHANGELOG.md +53 -0
- package/dist/__clients__/base-client.d.ts +7 -0
- package/dist/__clients__/base-client.d.ts.map +1 -0
- package/dist/__clients__/base-client.js +13 -0
- package/dist/__clients__/base-client.js.map +1 -0
- package/dist/__clients__/base-client.mjs +11 -0
- package/dist/__clients__/base-client.mjs.map +1 -0
- package/dist/__clients__/browser-clients.d.ts +243 -0
- package/dist/__clients__/browser-clients.d.ts.map +1 -0
- package/dist/__clients__/browser-clients.js +633 -0
- package/dist/__clients__/browser-clients.js.map +1 -0
- package/dist/__clients__/browser-clients.mjs +628 -0
- package/dist/__clients__/browser-clients.mjs.map +1 -0
- package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
- package/dist/__generated__/sdk-client-base.js +106 -110
- package/dist/__generated__/sdk-client-base.js.map +1 -1
- package/dist/__generated__/sdk-client-base.mjs +106 -110
- package/dist/__generated__/sdk-client-base.mjs.map +1 -1
- package/dist/__generated__/version.d.ts +1 -1
- package/dist/__generated__/version.d.ts.map +1 -1
- package/dist/__generated__/version.js +1 -1
- package/dist/__generated__/version.mjs +1 -1
- package/dist/__types__/base.d.ts +12 -0
- package/dist/__types__/base.d.ts.map +1 -1
- package/dist/__types__/base.js +5 -0
- package/dist/__types__/base.js.map +1 -1
- package/dist/__types__/base.mjs +6 -1
- package/dist/__types__/base.mjs.map +1 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +6 -0
- package/dist/constants.js.map +1 -0
- package/dist/constants.mjs +4 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +3 -2
- package/dist/index.mjs.map +1 -1
- package/dist/models.d.ts +1 -1
- package/dist/models.d.ts.map +1 -1
- package/dist/sdk-client.d.ts +14 -186
- package/dist/sdk-client.d.ts.map +1 -1
- package/dist/sdk-client.js +75 -437
- package/dist/sdk-client.js.map +1 -1
- package/dist/sdk-client.mjs +69 -431
- package/dist/sdk-client.mjs.map +1 -1
- package/dist/storage.d.ts +23 -3
- package/dist/storage.d.ts.map +1 -1
- package/dist/storage.js +17 -0
- package/dist/storage.js.map +1 -1
- package/dist/storage.mjs +17 -1
- package/dist/storage.mjs.map +1 -1
- package/package.json +6 -5
package/dist/sdk-client.mjs
CHANGED
|
@@ -1,35 +1,33 @@
|
|
|
1
|
-
import { WebauthnStamper } from '@turnkey/webauthn-stamper';
|
|
2
|
-
import { IframeStamper } from '@turnkey/iframe-stamper';
|
|
3
|
-
import { getWebAuthnAttestation } from '@turnkey/http';
|
|
4
1
|
import { WalletStamper } from '@turnkey/wallet-stamper';
|
|
5
|
-
import {
|
|
2
|
+
import { IframeStamper } from '@turnkey/iframe-stamper';
|
|
3
|
+
import { WebauthnStamper } from '@turnkey/webauthn-stamper';
|
|
6
4
|
import WindowWrapper from './__polyfills__/window.mjs';
|
|
7
|
-
import { TurnkeyRequestError,
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
5
|
+
import { TurnkeyRequestError, SessionType } from './__types__/base.mjs';
|
|
6
|
+
import { getStorageValue, StorageKeys, removeStorageValue } from './storage.mjs';
|
|
7
|
+
import { TurnkeyPasskeyClient, TurnkeyIframeClient, TurnkeyWalletClient, TurnkeyBrowserClient } from './__clients__/browser-clients.mjs';
|
|
8
|
+
import { VERSION } from './__generated__/version.mjs';
|
|
11
9
|
|
|
12
|
-
const DEFAULT_SESSION_EXPIRATION = "900"; // default to 15 minutes
|
|
13
10
|
class TurnkeyBrowserSDK {
|
|
14
11
|
constructor(config) {
|
|
15
12
|
/**
|
|
16
|
-
* Creates a passkey client. The parameters
|
|
17
|
-
* @param
|
|
18
|
-
* @param timeout optional timeout (defaults to 5mins)
|
|
19
|
-
* @param userVerification optional UV flag (defaults to "preferred")
|
|
20
|
-
* @param allowCredentials optional allowCredentials array (defaults to empty array)
|
|
13
|
+
* Creates a passkey client. The parameters override the default values passed to the underlying Turnkey `WebauthnStamper`
|
|
14
|
+
* @param PasskeyClientParams
|
|
21
15
|
* @returns new TurnkeyPasskeyClient
|
|
22
16
|
*/
|
|
23
|
-
this.passkeyClient = (
|
|
24
|
-
const targetRpId = rpId ?? this.config.rpId ?? WindowWrapper.location.hostname;
|
|
17
|
+
this.passkeyClient = (params) => {
|
|
18
|
+
const targetRpId = params?.rpId ?? this.config.rpId ?? WindowWrapper.location.hostname;
|
|
25
19
|
if (!targetRpId) {
|
|
26
20
|
throw new Error("Tried to initialize a passkey client with no rpId defined");
|
|
27
21
|
}
|
|
28
22
|
this.stamper = new WebauthnStamper({
|
|
29
23
|
rpId: targetRpId,
|
|
30
|
-
...(timeout !== undefined && { timeout }),
|
|
31
|
-
...(userVerification !== undefined && {
|
|
32
|
-
|
|
24
|
+
...(params?.timeout !== undefined && { timeout: params?.timeout }),
|
|
25
|
+
...(params?.userVerification !== undefined && {
|
|
26
|
+
userVerification: params?.userVerification,
|
|
27
|
+
}),
|
|
28
|
+
...(params?.allowCredentials !== undefined && {
|
|
29
|
+
allowCredentials: params?.allowCredentials,
|
|
30
|
+
}),
|
|
33
31
|
});
|
|
34
32
|
return new TurnkeyPasskeyClient({
|
|
35
33
|
stamper: this.stamper,
|
|
@@ -47,7 +45,7 @@ class TurnkeyBrowserSDK {
|
|
|
47
45
|
iframeUrl: params.iframeUrl,
|
|
48
46
|
iframeElementId: TurnkeyIframeElementId,
|
|
49
47
|
});
|
|
50
|
-
await this.stamper.init();
|
|
48
|
+
await this.stamper.init(params.dangerouslyOverrideIframeKeyTtl ?? undefined);
|
|
51
49
|
return new TurnkeyIframeClient({
|
|
52
50
|
stamper: this.stamper,
|
|
53
51
|
apiBaseUrl: this.config.apiBaseUrl,
|
|
@@ -112,13 +110,13 @@ class TurnkeyBrowserSDK {
|
|
|
112
110
|
});
|
|
113
111
|
}
|
|
114
112
|
else {
|
|
115
|
-
this.
|
|
113
|
+
await this.logout();
|
|
116
114
|
}
|
|
117
115
|
return;
|
|
118
116
|
};
|
|
119
117
|
/**
|
|
120
118
|
* If there is a valid, current read-session, this will return an auth bundle and its expiration. This auth bundle can be used in conjunction with an iframeStamper to create a read + write session.
|
|
121
|
-
*
|
|
119
|
+
* @deprecated use `getSession` instead
|
|
122
120
|
* @returns {Promise<ReadWriteSession | undefined>}
|
|
123
121
|
*/
|
|
124
122
|
this.getReadWriteSession = async () => {
|
|
@@ -134,14 +132,21 @@ class TurnkeyBrowserSDK {
|
|
|
134
132
|
return;
|
|
135
133
|
};
|
|
136
134
|
/**
|
|
137
|
-
*
|
|
138
|
-
* It has been replaced by the `getReadWriteSession` method.
|
|
139
|
-
* Fetches an auth bundle stored in local storage.
|
|
135
|
+
* If there is a valid, active READ_WRITE session, this will return it
|
|
140
136
|
*
|
|
141
|
-
* @returns {Promise<
|
|
137
|
+
* @returns {Promise<Session | undefined>}
|
|
142
138
|
*/
|
|
143
|
-
this.
|
|
144
|
-
|
|
139
|
+
this.getSession = async () => {
|
|
140
|
+
const currentSession = await getStorageValue(StorageKeys.Session);
|
|
141
|
+
if (currentSession?.sessionType === SessionType.READ_WRITE) {
|
|
142
|
+
if (currentSession?.expiry > Date.now()) {
|
|
143
|
+
return currentSession;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
await removeStorageValue(StorageKeys.Session);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
145
150
|
};
|
|
146
151
|
/**
|
|
147
152
|
* Fetches the current user's organization details.
|
|
@@ -158,421 +163,54 @@ class TurnkeyBrowserSDK {
|
|
|
158
163
|
* @returns {Promise<User | undefined>}
|
|
159
164
|
*/
|
|
160
165
|
this.getCurrentUser = async () => {
|
|
161
|
-
return await getStorageValue(StorageKeys.UserSession);
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Clears out all data pertaining to a user session.
|
|
165
|
-
*
|
|
166
|
-
* @returns {Promise<boolean>}
|
|
167
|
-
*/
|
|
168
|
-
this.logoutUser = async () => {
|
|
169
|
-
await removeStorageValue(StorageKeys.AuthBundle); // DEPRECATED
|
|
170
|
-
await removeStorageValue(StorageKeys.CurrentUser);
|
|
171
|
-
await removeStorageValue(StorageKeys.UserSession);
|
|
172
|
-
await removeStorageValue(StorageKeys.ReadWriteSession);
|
|
173
|
-
return true;
|
|
174
|
-
};
|
|
175
|
-
this.config = config;
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
class TurnkeyBrowserClient extends TurnkeySDKClientBase {
|
|
179
|
-
constructor(config, authClient) {
|
|
180
|
-
super(config);
|
|
181
|
-
this.login = async (config) => {
|
|
182
|
-
const readOnlySessionResult = await this.createReadOnlySession(config || {});
|
|
183
|
-
await saveSession(readOnlySessionResult, this.authClient);
|
|
184
|
-
return readOnlySessionResult;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Creates a read-write session. This method infers the current user's organization ID and target userId.
|
|
188
|
-
* To be used in conjunction with an `iframeStamper`: the resulting session's credential bundle can be
|
|
189
|
-
* injected into an iframeStamper to create a session that enables both read and write requests.
|
|
190
|
-
*
|
|
191
|
-
* @param targetEmbeddedKey
|
|
192
|
-
* @param expirationSeconds
|
|
193
|
-
* @param userId
|
|
194
|
-
* @returns {Promise<SdkApiTypes.TCreateReadWriteSessionResponse>}
|
|
195
|
-
*/
|
|
196
|
-
this.loginWithReadWriteSession = async (targetEmbeddedKey, expirationSeconds = DEFAULT_SESSION_EXPIRATION, userId) => {
|
|
197
|
-
const readWriteSessionResult = await this.createReadWriteSession({
|
|
198
|
-
targetPublicKey: targetEmbeddedKey,
|
|
199
|
-
expirationSeconds,
|
|
200
|
-
userId: userId,
|
|
201
|
-
});
|
|
202
|
-
// Ensure session and sessionExpiry are included in the object
|
|
203
|
-
const readWriteSessionResultWithSession = {
|
|
204
|
-
...readWriteSessionResult,
|
|
205
|
-
credentialBundle: readWriteSessionResult.credentialBundle,
|
|
206
|
-
sessionExpiry: Date.now() + Number(expirationSeconds) * 1000,
|
|
207
|
-
};
|
|
208
|
-
// store auth bundle in local storage
|
|
209
|
-
await saveSession(readWriteSessionResultWithSession, this.authClient);
|
|
210
|
-
return readWriteSessionResultWithSession;
|
|
211
|
-
};
|
|
212
|
-
/**
|
|
213
|
-
* Logs in with an existing auth bundle. this bundle enables both read and write requests.
|
|
214
|
-
*
|
|
215
|
-
* @param credentialBundle
|
|
216
|
-
* @param expirationSeconds
|
|
217
|
-
* @returns {Promise<boolean>}
|
|
218
|
-
*/
|
|
219
|
-
this.loginWithAuthBundle = async (credentialBundle, expirationSeconds = DEFAULT_SESSION_EXPIRATION) => {
|
|
220
|
-
try {
|
|
221
|
-
const whoAmIResult = await this.getWhoami();
|
|
222
|
-
const readWriteSessionResultWithSession = {
|
|
223
|
-
...whoAmIResult,
|
|
224
|
-
credentialBundle: credentialBundle,
|
|
225
|
-
sessionExpiry: Date.now() + Number(expirationSeconds) * 1000,
|
|
226
|
-
};
|
|
227
|
-
await saveSession(readWriteSessionResultWithSession, this.authClient);
|
|
228
|
-
return true;
|
|
229
|
-
}
|
|
230
|
-
catch {
|
|
231
|
-
return false;
|
|
232
|
-
}
|
|
233
|
-
};
|
|
234
|
-
/**
|
|
235
|
-
* Removes authentication factors from an end user.
|
|
236
|
-
*
|
|
237
|
-
* This function allows selectively removing:
|
|
238
|
-
* - Phone number
|
|
239
|
-
* - Email
|
|
240
|
-
* - Authenticators (by ID)
|
|
241
|
-
* - OAuth providers (by ID)
|
|
242
|
-
* - API keys (by ID)
|
|
243
|
-
*
|
|
244
|
-
* All removal operations are executed in parallel if multiple
|
|
245
|
-
* parameters are provided.
|
|
246
|
-
*
|
|
247
|
-
* @param params - A structured object containing all the removal parameters
|
|
248
|
-
* @param params.userId - Unique identifier of the user
|
|
249
|
-
* @param params.phoneNumber - true to remove the phone number
|
|
250
|
-
* @param params.email - true to remove the email
|
|
251
|
-
* @param params.authenticatorIds - Array of authenticator IDs to remove
|
|
252
|
-
* @param params.oauthProviderIds - Array of OAuth provider IDs to remove
|
|
253
|
-
* @param params.apiKeyIds - Array of API key IDs to remove
|
|
254
|
-
* @returns A promise that resolves to an array of results from each removal operation
|
|
255
|
-
*/
|
|
256
|
-
this.deleteUserAuth = async (params) => {
|
|
257
166
|
try {
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
167
|
+
const session = await getStorageValue(StorageKeys.Session);
|
|
168
|
+
if (session?.userId && session?.organizationId) {
|
|
169
|
+
return {
|
|
170
|
+
userId: session.userId,
|
|
171
|
+
organization: {
|
|
172
|
+
organizationId: session.organizationId,
|
|
173
|
+
organizationName: "",
|
|
174
|
+
},
|
|
175
|
+
session: {
|
|
176
|
+
...(session.sessionType === SessionType.READ_ONLY && {
|
|
177
|
+
read: {
|
|
178
|
+
token: session.token,
|
|
179
|
+
expiry: session.expiry,
|
|
180
|
+
},
|
|
181
|
+
}),
|
|
182
|
+
...(session.sessionType === SessionType.READ_WRITE && {
|
|
183
|
+
write: {
|
|
184
|
+
credentialBundle: session.token,
|
|
185
|
+
expiry: session.expiry,
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
},
|
|
189
|
+
};
|
|
271
190
|
}
|
|
272
|
-
|
|
273
|
-
|
|
191
|
+
else {
|
|
192
|
+
return undefined;
|
|
274
193
|
}
|
|
275
|
-
// Execute all removal operations in parallel
|
|
276
|
-
return await Promise.all(promises);
|
|
277
194
|
}
|
|
278
195
|
catch (error) {
|
|
279
|
-
|
|
280
|
-
throw error;
|
|
196
|
+
return;
|
|
281
197
|
}
|
|
282
198
|
};
|
|
283
199
|
/**
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
* This function allows selectively adding:
|
|
287
|
-
* - Phone number
|
|
288
|
-
* - Email
|
|
289
|
-
* - Authenticators
|
|
290
|
-
* - OAuth providers
|
|
291
|
-
* - API keys
|
|
200
|
+
* Clears out all data pertaining to an end user session.
|
|
292
201
|
*
|
|
293
|
-
*
|
|
294
|
-
* parameters are provided.
|
|
295
|
-
*
|
|
296
|
-
* @param params - A structured object containing all the addition/update parameters
|
|
297
|
-
* @param params.userId - Unique identifier of the user
|
|
298
|
-
* @param params.phoneNumber - New phone number for the user
|
|
299
|
-
* @param params.email - New email address for the user
|
|
300
|
-
* @param params.authenticators - Array of authenticator objects to create
|
|
301
|
-
* @param params.oauthProviders - Array of OAuth provider objects to create
|
|
302
|
-
* @param params.apiKeys - Array of API key objects to create
|
|
303
|
-
* @returns A promise that resolves to an array of results from each addition or update
|
|
202
|
+
* @returns {Promise<boolean>}
|
|
304
203
|
*/
|
|
305
|
-
this.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
userPhoneNumber: phoneNumber,
|
|
313
|
-
userTagIds: [],
|
|
314
|
-
}));
|
|
315
|
-
}
|
|
316
|
-
if (email) {
|
|
317
|
-
promises.push(this.updateUser({ userId, userEmail: email, userTagIds: [] }));
|
|
318
|
-
}
|
|
319
|
-
if (authenticators && authenticators.length > 0) {
|
|
320
|
-
promises.push(this.createAuthenticators({ userId, authenticators }));
|
|
321
|
-
}
|
|
322
|
-
if (oauthProviders && oauthProviders.length > 0) {
|
|
323
|
-
promises.push(this.createOauthProviders({ userId, oauthProviders }));
|
|
324
|
-
}
|
|
325
|
-
if (apiKeys && apiKeys.length > 0) {
|
|
326
|
-
promises.push(this.createApiKeys({ userId, apiKeys }));
|
|
327
|
-
}
|
|
328
|
-
// Execute all additions/updates operations in parallel
|
|
329
|
-
return await Promise.all(promises);
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
// Surface error
|
|
333
|
-
throw error;
|
|
334
|
-
}
|
|
335
|
-
};
|
|
336
|
-
this.authClient = authClient;
|
|
337
|
-
}
|
|
338
|
-
/**
|
|
339
|
-
* Comprehensive authentication update for an end user.
|
|
340
|
-
* Combines add/update and delete operations into a single call.
|
|
341
|
-
*
|
|
342
|
-
* The behavior is driven by whether values are set to:
|
|
343
|
-
* - A string/array (to create or update)
|
|
344
|
-
* - `null` or an array of IDs (to remove)
|
|
345
|
-
*
|
|
346
|
-
* All operations are executed in parallel where applicable.
|
|
347
|
-
*
|
|
348
|
-
* @param params - A structured object containing all the update parameters
|
|
349
|
-
* @param params.userId - Unique identifier of the user
|
|
350
|
-
* @param params.phoneNumber - String to set (new phone) or `null` to remove
|
|
351
|
-
* @param params.email - String to set (new email) or `null` to remove
|
|
352
|
-
* @param params.authenticators - Object describing authenticators to add or remove
|
|
353
|
-
* @param params.oauthProviders - Object describing OAuth providers to add or remove
|
|
354
|
-
* @param params.apiKeys - Object describing API keys to add or remove
|
|
355
|
-
*
|
|
356
|
-
* @returns A promise that resolves to a boolean indicating overall success
|
|
357
|
-
*/
|
|
358
|
-
async updateUserAuth(params) {
|
|
359
|
-
try {
|
|
360
|
-
const { userId, phoneNumber, email, authenticators, oauthProviders, apiKeys, } = params;
|
|
361
|
-
const promises = [];
|
|
362
|
-
// Handle phone/email in a single updateUser call if both are changing,
|
|
363
|
-
// or separate calls if only one is changing.
|
|
364
|
-
const userUpdates = {};
|
|
365
|
-
if (phoneNumber !== undefined) {
|
|
366
|
-
userUpdates.userPhoneNumber = phoneNumber === null ? "" : phoneNumber;
|
|
367
|
-
}
|
|
368
|
-
if (email !== undefined) {
|
|
369
|
-
userUpdates.userEmail = email === null ? "" : email;
|
|
370
|
-
}
|
|
371
|
-
if (Object.keys(userUpdates).length > 0) {
|
|
372
|
-
promises.push(this.updateUser({ userId, ...userUpdates, userTagIds: [] }));
|
|
373
|
-
}
|
|
374
|
-
// Handle authenticators
|
|
375
|
-
if (authenticators) {
|
|
376
|
-
if (authenticators.add?.length) {
|
|
377
|
-
promises.push(this.createAuthenticators({
|
|
378
|
-
userId,
|
|
379
|
-
authenticators: authenticators.add,
|
|
380
|
-
}));
|
|
381
|
-
}
|
|
382
|
-
if (authenticators.deleteIds?.length) {
|
|
383
|
-
promises.push(this.deleteAuthenticators({
|
|
384
|
-
userId,
|
|
385
|
-
authenticatorIds: authenticators.deleteIds,
|
|
386
|
-
}));
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
// Handle OAuth providers
|
|
390
|
-
if (oauthProviders) {
|
|
391
|
-
if (oauthProviders.add?.length) {
|
|
392
|
-
promises.push(this.createOauthProviders({
|
|
393
|
-
userId,
|
|
394
|
-
oauthProviders: oauthProviders.add,
|
|
395
|
-
}));
|
|
396
|
-
}
|
|
397
|
-
if (oauthProviders.deleteIds?.length) {
|
|
398
|
-
promises.push(this.deleteOauthProviders({
|
|
399
|
-
userId,
|
|
400
|
-
providerIds: oauthProviders.deleteIds,
|
|
401
|
-
}));
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
|
-
// Handle API keys
|
|
405
|
-
if (apiKeys) {
|
|
406
|
-
if (apiKeys.add?.length) {
|
|
407
|
-
promises.push(this.createApiKeys({
|
|
408
|
-
userId,
|
|
409
|
-
apiKeys: apiKeys.add,
|
|
410
|
-
}));
|
|
411
|
-
}
|
|
412
|
-
if (apiKeys.deleteIds?.length) {
|
|
413
|
-
promises.push(this.deleteApiKeys({
|
|
414
|
-
userId,
|
|
415
|
-
apiKeyIds: apiKeys.deleteIds,
|
|
416
|
-
}));
|
|
417
|
-
}
|
|
418
|
-
}
|
|
419
|
-
// Execute all requested operations in parallel
|
|
420
|
-
await Promise.all(promises);
|
|
204
|
+
this.logout = async () => {
|
|
205
|
+
await removeStorageValue(StorageKeys.AuthBundle); // DEPRECATED
|
|
206
|
+
await removeStorageValue(StorageKeys.CurrentUser);
|
|
207
|
+
await removeStorageValue(StorageKeys.UserSession);
|
|
208
|
+
await removeStorageValue(StorageKeys.ReadWriteSession);
|
|
209
|
+
await removeStorageValue(StorageKeys.Client);
|
|
210
|
+
await removeStorageValue(StorageKeys.Session);
|
|
421
211
|
return true;
|
|
422
|
-
}
|
|
423
|
-
catch (error) {
|
|
424
|
-
// Surface error
|
|
425
|
-
throw error;
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
|
|
430
|
-
constructor(config) {
|
|
431
|
-
super(config, AuthClient.Passkey);
|
|
432
|
-
/**
|
|
433
|
-
* Create a passkey for an end-user, taking care of various lower-level details.
|
|
434
|
-
*
|
|
435
|
-
* @returns {Promise<Passkey>}
|
|
436
|
-
*/
|
|
437
|
-
this.createUserPasskey = async (config = {}) => {
|
|
438
|
-
const challenge = generateRandomBuffer();
|
|
439
|
-
const encodedChallenge = base64UrlEncode(challenge);
|
|
440
|
-
const authenticatorUserId = generateRandomBuffer();
|
|
441
|
-
// WebAuthn credential options options can be found here:
|
|
442
|
-
// https://www.w3.org/TR/webauthn-2/#sctn-sample-registration
|
|
443
|
-
//
|
|
444
|
-
// All pubkey algorithms can be found here: https://www.iana.org/assignments/cose/cose.xhtml#algorithms
|
|
445
|
-
// Turnkey only supports ES256 (-7) and RS256 (-257)
|
|
446
|
-
//
|
|
447
|
-
// The pubkey type only supports one value, "public-key"
|
|
448
|
-
// See https://www.w3.org/TR/webauthn-2/#enumdef-publickeycredentialtype for more details
|
|
449
|
-
// TODO: consider un-nesting these config params
|
|
450
|
-
const webauthnConfig = {
|
|
451
|
-
publicKey: {
|
|
452
|
-
rp: {
|
|
453
|
-
id: config.publicKey?.rp?.id ?? this.rpId,
|
|
454
|
-
name: config.publicKey?.rp?.name ?? "",
|
|
455
|
-
},
|
|
456
|
-
challenge: config.publicKey?.challenge ?? challenge,
|
|
457
|
-
pubKeyCredParams: config.publicKey?.pubKeyCredParams ?? [
|
|
458
|
-
{
|
|
459
|
-
type: "public-key",
|
|
460
|
-
alg: -7,
|
|
461
|
-
},
|
|
462
|
-
{
|
|
463
|
-
type: "public-key",
|
|
464
|
-
alg: -257,
|
|
465
|
-
},
|
|
466
|
-
],
|
|
467
|
-
user: {
|
|
468
|
-
id: config.publicKey?.user?.id ?? authenticatorUserId,
|
|
469
|
-
name: config.publicKey?.user?.name ?? "Default User",
|
|
470
|
-
displayName: config.publicKey?.user?.displayName ?? "Default User",
|
|
471
|
-
},
|
|
472
|
-
authenticatorSelection: {
|
|
473
|
-
authenticatorAttachment: config.publicKey?.authenticatorSelection?.authenticatorAttachment ??
|
|
474
|
-
undefined,
|
|
475
|
-
requireResidentKey: config.publicKey?.authenticatorSelection?.requireResidentKey ??
|
|
476
|
-
true,
|
|
477
|
-
residentKey: config.publicKey?.authenticatorSelection?.residentKey ?? "required",
|
|
478
|
-
userVerification: config.publicKey?.authenticatorSelection?.userVerification ??
|
|
479
|
-
"preferred",
|
|
480
|
-
},
|
|
481
|
-
},
|
|
482
|
-
};
|
|
483
|
-
const attestation = await getWebAuthnAttestation(webauthnConfig);
|
|
484
|
-
return {
|
|
485
|
-
encodedChallenge: config.publicKey?.challenge
|
|
486
|
-
? base64UrlEncode(config.publicKey?.challenge)
|
|
487
|
-
: encodedChallenge,
|
|
488
|
-
attestation,
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
|
-
/**
|
|
492
|
-
* Uses passkey authentication to create a read-write session, via an embedded API key,
|
|
493
|
-
* and stores + returns the resulting auth bundle that contains the encrypted API key.
|
|
494
|
-
* This auth bundle (also referred to as a credential bundle) can be injected into an `iframeStamper`,
|
|
495
|
-
* resulting in a touch-free authenticator. Unlike `loginWithReadWriteSession`, this method
|
|
496
|
-
* assumes the end-user's organization ID (i.e. the sub-organization ID) is already known.
|
|
497
|
-
*
|
|
498
|
-
* @param userId
|
|
499
|
-
* @param targetEmbeddedKey
|
|
500
|
-
* @param expirationSeconds
|
|
501
|
-
* @param curveType
|
|
502
|
-
* @returns {Promise<ReadWriteSession>}
|
|
503
|
-
*/
|
|
504
|
-
this.createPasskeySession = async (userId, targetEmbeddedKey, expirationSeconds = DEFAULT_SESSION_EXPIRATION, organizationId) => {
|
|
505
|
-
const user = await getStorageValue(StorageKeys.UserSession);
|
|
506
|
-
organizationId = organizationId ?? user?.organization.organizationId;
|
|
507
|
-
if (!organizationId) {
|
|
508
|
-
throw new Error("Error creating passkey session: Organization ID is required");
|
|
509
|
-
}
|
|
510
|
-
userId = userId ?? user?.userId;
|
|
511
|
-
const { authBundle: credentialBundle, publicKey } = await createEmbeddedAPIKey(targetEmbeddedKey);
|
|
512
|
-
// add API key to Turnkey User
|
|
513
|
-
await this.createApiKeys({
|
|
514
|
-
organizationId,
|
|
515
|
-
userId,
|
|
516
|
-
apiKeys: [
|
|
517
|
-
{
|
|
518
|
-
apiKeyName: `Session Key ${String(Date.now())}`,
|
|
519
|
-
publicKey,
|
|
520
|
-
expirationSeconds,
|
|
521
|
-
curveType: "API_KEY_CURVE_P256",
|
|
522
|
-
},
|
|
523
|
-
],
|
|
524
|
-
});
|
|
525
|
-
const expiry = Date.now() + Number(expirationSeconds) * 1000;
|
|
526
|
-
await saveSession({
|
|
527
|
-
organizationId,
|
|
528
|
-
organizationName: user?.organization.organizationName ?? "",
|
|
529
|
-
userId,
|
|
530
|
-
username: user?.username ?? "",
|
|
531
|
-
credentialBundle,
|
|
532
|
-
sessionExpiry: expiry,
|
|
533
|
-
}, this.authClient);
|
|
534
|
-
return {
|
|
535
|
-
credentialBundle,
|
|
536
|
-
expiry,
|
|
537
|
-
};
|
|
538
|
-
};
|
|
539
|
-
this.rpId = this.stamper.rpId;
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
class TurnkeyIframeClient extends TurnkeyBrowserClient {
|
|
543
|
-
constructor(config) {
|
|
544
|
-
super(config, AuthClient.Iframe);
|
|
545
|
-
this.injectCredentialBundle = async (credentialBundle) => {
|
|
546
|
-
return await this.stamper.injectCredentialBundle(credentialBundle);
|
|
547
|
-
};
|
|
548
|
-
this.injectWalletExportBundle = async (credentialBundle, organizationId) => {
|
|
549
|
-
return await this.stamper.injectWalletExportBundle(credentialBundle, organizationId);
|
|
550
|
-
};
|
|
551
|
-
this.injectKeyExportBundle = async (credentialBundle, organizationId, keyFormat) => {
|
|
552
|
-
return await this.stamper.injectKeyExportBundle(credentialBundle, organizationId, keyFormat);
|
|
553
|
-
};
|
|
554
|
-
this.injectImportBundle = async (bundle, organizationId, userId) => {
|
|
555
|
-
return await this.stamper.injectImportBundle(bundle, organizationId, userId);
|
|
556
|
-
};
|
|
557
|
-
this.extractWalletEncryptedBundle = async () => {
|
|
558
|
-
return await this.stamper.extractWalletEncryptedBundle();
|
|
559
212
|
};
|
|
560
|
-
this.
|
|
561
|
-
return await this.stamper.extractKeyEncryptedBundle();
|
|
562
|
-
};
|
|
563
|
-
this.iframePublicKey = this.stamper.iframePublicKey;
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
class TurnkeyWalletClient extends TurnkeyBrowserClient {
|
|
567
|
-
constructor(config) {
|
|
568
|
-
super(config, AuthClient.Wallet);
|
|
569
|
-
this.wallet = config.wallet;
|
|
570
|
-
}
|
|
571
|
-
async getPublicKey() {
|
|
572
|
-
return this.wallet.getPublicKey();
|
|
573
|
-
}
|
|
574
|
-
getWalletInterface() {
|
|
575
|
-
return this.wallet;
|
|
213
|
+
this.config = config;
|
|
576
214
|
}
|
|
577
215
|
}
|
|
578
216
|
|
package/dist/sdk-client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk-client.mjs","sources":["../src/sdk-client.ts"],"sourcesContent":[null],"names":[],"mappings":";;;;;;;;;;;AAwCA,MAAM,0BAA0B,GAAG,KAAK,CAAC;MAqE5B,iBAAiB,CAAA;AAK5B,IAAA,WAAA,CAAY,MAA+B,EAAA;AAI3C;;;;;;;AAOG;QACH,IAAa,CAAA,aAAA,GAAG,CACd,IAAa,EACb,OAAgB,EAChB,gBAA8C,EAC9C,gB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EAAE;4BACP,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,SAAS,IAAI;AACnD,gCAAA,IAAI,EAAE;oCACJ,KAAK,EAAE,OAAO,CAAC,KAAK;oCACpB,MAAM,EAAE,OAAO,CAAC,MAAM;AACvB,iCAAA;6BACF,CAAC;4BACF,IAAI,OAAO,CAAC,WAAW,KAAK,WAAW,CAAC,UAAU,IAAI;AACpD,gCAAA,KAAK,EAAE;oCACL,gBAAgB,EAAE,OAAO,CAAC,KAAK;oCAC/B,MAAM,EAAE,OAAO,CAAC,MAAM;AACvB,iCAAA;6BACF,CAAC;AACH,yBAAA;qBACM,CAAC;AACX,iBAAA;AAAM,qBAAA;AACL,oBAAA,OAAO,SAAS,CAAC;AAClB,iBAAA;AACF,aAAA;AAAC,YAAA,OAAO,KAAK,EAAE;gBACd,OAAO;AACR,aAAA;AACH,SAAC,CAAC;AAEF;;;;AAIG;QACH,IAAM,CAAA,MAAA,GAAG,YAA6B;YACpC,MAAM,kBAAkB,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;AACjD,YAAA,MAAM,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAClD,YAAA,MAAM,kBAAkB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;AAClD,YAAA,MAAM,kBAAkB,CAAC,WAAW,CAAC,gBAAgB,CAAC,CAAC;AACvD,YAAA,MAAM,kBAAkB,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AAC7C,YAAA,MAAM,kBAAkB,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;AAC9C,YAAA,OAAO,IAAI,CAAC;AACd,SAAC,CAAC;AApPA,QAAA,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;KACtB;AAoPF;;;;"}
|
package/dist/storage.d.ts
CHANGED
|
@@ -1,20 +1,40 @@
|
|
|
1
|
-
import type { User, ReadWriteSession } from "
|
|
2
|
-
import type { AuthClient, TSessionResponse } from "
|
|
1
|
+
import type { User, ReadWriteSession } from "@models";
|
|
2
|
+
import type { AuthClient, SessionType, TSessionResponse } from "@types";
|
|
3
3
|
export declare enum StorageKeys {
|
|
4
4
|
AuthBundle = "@turnkey/auth_bundle",
|
|
5
5
|
CurrentUser = "@turnkey/current_user",
|
|
6
6
|
UserSession = "@turnkey/session/v1",
|
|
7
|
-
ReadWriteSession = "@turnkey/read_write_session"
|
|
7
|
+
ReadWriteSession = "@turnkey/read_write_session",
|
|
8
|
+
Session = "@turnkey/session/v2",
|
|
9
|
+
Client = "@turnkey/client"
|
|
8
10
|
}
|
|
11
|
+
export type Session = {
|
|
12
|
+
sessionType: SessionType;
|
|
13
|
+
userId: string;
|
|
14
|
+
organizationId: string;
|
|
15
|
+
expiry: number;
|
|
16
|
+
token: string;
|
|
17
|
+
};
|
|
9
18
|
interface StorageValue {
|
|
10
19
|
[StorageKeys.AuthBundle]: string;
|
|
11
20
|
[StorageKeys.CurrentUser]: User;
|
|
12
21
|
[StorageKeys.UserSession]: User;
|
|
13
22
|
[StorageKeys.ReadWriteSession]: ReadWriteSession;
|
|
23
|
+
[StorageKeys.Session]: Session;
|
|
24
|
+
[StorageKeys.Client]: AuthClient;
|
|
14
25
|
}
|
|
15
26
|
export declare const getStorageValue: <K extends StorageKeys>(storageKey: K) => Promise<StorageValue[K] | undefined>;
|
|
16
27
|
export declare const setStorageValue: <K extends StorageKeys>(storageKey: K, storageValue: StorageValue[K]) => Promise<any>;
|
|
17
28
|
export declare const removeStorageValue: <K extends StorageKeys>(storageKey: K) => Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Saves a session and client to storage.
|
|
31
|
+
*
|
|
32
|
+
* @param {Session} session - The session response containing session details.
|
|
33
|
+
* @param {AuthClient} authClient - The authentication client used for the session.
|
|
34
|
+
* @throws Will throw an error if the authentication client is not set.
|
|
35
|
+
* @returns {Promise<void>} A promise that resolves when the session is saved.
|
|
36
|
+
*/
|
|
37
|
+
export declare const storeSession: (session: Session, client: AuthClient) => Promise<void>;
|
|
18
38
|
/**
|
|
19
39
|
* Saves a user session to storage.
|
|
20
40
|
*
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,QAAQ,CAAC;AAExE,oBAAY,WAAW;IACrB,UAAU,yBAAyB;IACnC,WAAW,0BAA0B;IACrC,WAAW,wBAAwB;IACnC,gBAAgB,gCAAgC;IAChD,OAAO,wBAAwB;IAC/B,MAAM,oBAAoB;CAC3B;AAED,MAAM,MAAM,OAAO,GAAG;IACpB,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,UAAU,YAAY;IACpB,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IACjC,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAChC,CAAC,WAAW,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC;IAChC,CAAC,WAAW,CAAC,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACjD,CAAC,WAAW,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC/B,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC;CAClC;AAuBD,eAAO,MAAM,eAAe,gFAO3B,CAAC;AAEF,eAAO,MAAM,eAAe,2EAGzB,QAAQ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