@turnkey/sdk-browser 4.2.0 → 5.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/README.md +46 -0
  3. package/dist/__clients__/browser-clients.d.ts +32 -43
  4. package/dist/__clients__/browser-clients.d.ts.map +1 -1
  5. package/dist/__clients__/browser-clients.js +65 -182
  6. package/dist/__clients__/browser-clients.js.map +1 -1
  7. package/dist/__clients__/browser-clients.mjs +67 -185
  8. package/dist/__clients__/browser-clients.mjs.map +1 -1
  9. package/dist/__generated__/sdk-client-base.d.ts +10 -0
  10. package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
  11. package/dist/__generated__/sdk-client-base.js +367 -79
  12. package/dist/__generated__/sdk-client-base.js.map +1 -1
  13. package/dist/__generated__/sdk-client-base.mjs +367 -79
  14. package/dist/__generated__/sdk-client-base.mjs.map +1 -1
  15. package/dist/__generated__/sdk_api_types.d.ts +25 -0
  16. package/dist/__generated__/sdk_api_types.d.ts.map +1 -1
  17. package/dist/__generated__/version.d.ts +1 -1
  18. package/dist/__generated__/version.js +1 -1
  19. package/dist/__generated__/version.mjs +1 -1
  20. package/dist/__inputs__/public_api.types.d.ts +265 -9
  21. package/dist/__inputs__/public_api.types.d.ts.map +1 -1
  22. package/dist/__polyfills__/window.js.map +1 -1
  23. package/dist/__polyfills__/window.mjs.map +1 -1
  24. package/dist/__types__/base.d.ts +7 -66
  25. package/dist/__types__/base.d.ts.map +1 -1
  26. package/dist/__types__/base.js +1 -0
  27. package/dist/__types__/base.js.map +1 -1
  28. package/dist/__types__/base.mjs +1 -0
  29. package/dist/__types__/base.mjs.map +1 -1
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +1 -0
  33. package/dist/index.js.map +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/sdk-client.d.ts +8 -26
  36. package/dist/sdk-client.d.ts.map +1 -1
  37. package/dist/sdk-client.js +34 -92
  38. package/dist/sdk-client.js.map +1 -1
  39. package/dist/sdk-client.mjs +37 -95
  40. package/dist/sdk-client.mjs.map +1 -1
  41. package/dist/storage.d.ts +3 -20
  42. package/dist/storage.d.ts.map +1 -1
  43. package/dist/storage.js +0 -49
  44. package/dist/storage.js.map +1 -1
  45. package/dist/storage.mjs +1 -49
  46. package/dist/storage.mjs.map +1 -1
  47. package/dist/utils.d.ts +2 -0
  48. package/dist/utils.d.ts.map +1 -1
  49. package/dist/utils.js +27 -51
  50. package/dist/utils.js.map +1 -1
  51. package/dist/utils.mjs +27 -51
  52. package/dist/utils.mjs.map +1 -1
  53. package/package.json +10 -8
package/CHANGELOG.md CHANGED
@@ -1,5 +1,48 @@
1
1
  # @turnkey/sdk-browser
2
2
 
3
+ ## 5.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [#601](https://github.com/tkhq/sdk/pull/601) [`07dfd33`](https://github.com/tkhq/sdk/commit/07dfd3397472687092e1c73b1d68714f421b9ca0) Author [@moe-dev](https://github.com/moe-dev)
8
+
9
+ This release introduces the new `indexedDbClient`, leveraging the `indexedDbStamper` to securely store cryptographic keys directly in IndexedDB. It provides persistent, secure, non-extractable authentication, replacing legacy iframe-based flows for OTP, passkey, external wallet, and OAuth authentications.
10
+
11
+ ### Key Changes:
12
+
13
+ - **IndexedDB Client (`indexedDbClient`)**:
14
+
15
+ - Offers persistent, tamper-resistant authentication using P-256 keys stored securely in IndexedDB.
16
+ - Eliminates the need for credential injection via iframes, significantly improving the DevEx and UX of session management.
17
+ - Provides human-readable sessions through `getSession()`.
18
+
19
+ - **Deprecation Notice**:
20
+ - Authentication via the `iframeClient` (e.g., `auth.turnkey.com`) is deprecated. Developers should migrate authentication flows to the new IndexedDB-based client.
21
+ - Existing iframe-based wallet flows (Email Recovery, Import, and Export) remain supported.
22
+
23
+ These enhancements simplify integrations, improve UX, and deliver a more robust client-side experience.
24
+
25
+ ### Patch Changes
26
+
27
+ - Updated dependencies [[`07dfd33`](https://github.com/tkhq/sdk/commit/07dfd3397472687092e1c73b1d68714f421b9ca0)]:
28
+ - @turnkey/indexed-db-stamper@1.0.0
29
+ - @turnkey/http@3.4.0
30
+ - @turnkey/crypto@2.3.1
31
+ - @turnkey/wallet-stamper@1.0.3
32
+
33
+ ## 4.3.0
34
+
35
+ ### Minor Changes
36
+
37
+ - 25ca339: Adding replyToEmailAddress field for specifying reply-to when using a customer sender
38
+
39
+ ### Patch Changes
40
+
41
+ - Updated dependencies [25ca339]
42
+ - @turnkey/http@3.3.0
43
+ - @turnkey/crypto@2.3.1
44
+ - @turnkey/wallet-stamper@1.0.3
45
+
3
46
  ## 4.2.0
4
47
 
5
48
  ### Minor Changes
package/README.md CHANGED
@@ -104,3 +104,49 @@ const walletsResponse = await walletClient.getWallets();
104
104
  ## Helpers
105
105
 
106
106
  `@turnkey/sdk-browser` provides `TurnkeySDKBrowserClient`, which offers wrappers around commonly used Turnkey activities, such as creating new wallets and wallet accounts.
107
+
108
+ ### IndexedDB Sessions (Recommended)
109
+
110
+ Turnkey now supports persistent, **secure, non-extractable authentication** using P-256 passkeys stored in **IndexedDB**. This replaces legacy iframe-based flows for otp, passkey, and OAuth authentication.
111
+
112
+ The [`TurnkeyIndexedDbClient`](https://github.com/tkhq/sdk/blob/main/packages/sdk-browser/src/__clients__/browser-clients.ts) provides a long-lived session mechanism where the private key never leaves the browser and is scoped per sub-organization. This client handles login, session persistence, and API request signing entirely on the client side — without requiring iframes or sensitive credential injection.
113
+
114
+ ```ts
115
+ import { Turnkey } from "@turnkey/sdk-browser";
116
+
117
+ const turnkey = new Turnkey({
118
+ apiBaseUrl: "https://api.turnkey.com",
119
+ defaultOrganizationId: "<YOUR_PARENT_ORG_ID>",
120
+ rpId: "<YOUR_WEBAUTHN_RELYING_PARTY_ID>",
121
+ });
122
+
123
+ const client = turnkey.indexedDbClient();
124
+ const passkeyClient = turnkey.passkeyClient();
125
+ // Create authenticated session
126
+ const pubKey = await indexedDbClient!.getPublicKey();
127
+ await passkeyClient?.loginWithPasskey({
128
+ sessionType: SessionType.READ_WRITE,
129
+ publicKey: pubKey!,
130
+ expirationSeconds: "3600",
131
+ });
132
+
133
+ // Now the client is authenticated and ready to interact with Turnkey API
134
+ const wallets = await client.getWallets();
135
+ ```
136
+
137
+ > 💡 **Why IndexedDB?**
138
+ > Keys are stored using the [Web Crypto API](https://developer.mozilla.org/en-US/docs/Web/API/CryptoKey), marked as `nonExtractable`, and survive page reloads — offering persistent, tamper-resistant authentication without ever exposing the raw key material.
139
+
140
+ ---
141
+
142
+ ### ⚠️ Deprecated: iframeClient for Auth
143
+
144
+ Authentication via `iframeClient()` and injected credentials (e.g., from `https://auth.turnkey.com`) is now considered **deprecated** for new integrations. These flows required sensitive credential bundles to be delivered via email or OAuth and injected into a sandboxed iframe — a pattern with limited persistence and higher complexity.
145
+
146
+ Developers are encouraged to migrate to `indexedDbClient()` for:
147
+
148
+ - Seamless passkey authentication
149
+ - Improved security model (no credential injection)
150
+ - Long-lived, resumable sessions
151
+
152
+ Existing iframe use cases like **Email Recovery**, **Wallet Import**, and **Wallet Export** are still supported but should be isolated from authentication logic.
@@ -2,7 +2,7 @@ import type { WalletInterface } from "@turnkey/wallet-stamper";
2
2
  import type { KeyFormat } from "@turnkey/iframe-stamper";
3
3
  import type * as SdkApiTypes from "../__generated__/sdk_api_types";
4
4
  import { TurnkeyBaseClient } from "../__clients__/base-client";
5
- import { Session, AuthClient, TurnkeySDKClientConfig, TurnkeyWalletClientConfig, ReadWriteSession, LoginWithBundleParams, LoginWithPasskeyParams, LoginWithWalletParams, RefreshSessionParams } from "@types";
5
+ import { AuthClient, TurnkeySDKClientConfig, TurnkeyWalletClientConfig, LoginWithBundleParams, LoginWithPasskeyParams, LoginWithWalletParams, RefreshSessionParams } from "@types";
6
6
  import type { Passkey } from "@models";
7
7
  export interface OauthProvider {
8
8
  providerName: string;
@@ -59,16 +59,29 @@ interface AddUserAuthParams {
59
59
  }
60
60
  export declare class TurnkeyBrowserClient extends TurnkeyBaseClient {
61
61
  constructor(config: TurnkeySDKClientConfig, authClient?: AuthClient);
62
+ /**
63
+ * @deprecated
64
+ * This method is deprecated and only creates a READ_ONLY session using an API key.
65
+ * Use one of the following methods instead, depending on your context:
66
+ *
67
+ * - `loginWithPasskey()` for WebAuthn-based sessions using IndexedDB
68
+ * - `loginWithWallet()` for EVM or Solana wallet-based sessions
69
+ * - `loginWithSession()` if the session string is already available (e.g. from server actions)
70
+ * - `loginWithBundle()` for iframe-based sessions (e.g. for email-auth non otp based login)
71
+ *
72
+ * @param config Optional configuration containing an organization ID
73
+ * @returns A Promise resolving to the created read-only session
74
+ */
62
75
  login: (config?: {
63
76
  organizationId?: string;
64
77
  }) => Promise<SdkApiTypes.TCreateReadOnlySessionResponse>;
65
78
  /**
66
79
  * Attempts to refresh an existing Session. This method infers the current user's organization ID and target userId.
67
- * This will use a passkeyStamper for `READ_ONLY` sessions or an `iframeStamper` for `READ_WRITE` sessions.
80
+ * This will use a passkeyStamper for `READ_ONLY` sessions or an `indexedDbStamper` for `READ_WRITE` sessions.
68
81
  *
69
82
  * @param RefreshSessionParams
70
83
  * @param params.sessionType - The type of session that is being refreshed
71
- * @param params.targetPublicKey - The public key of the target client
84
+ * @param params.publicKey - The public key of the indexedDb client
72
85
  * @param params.expirationSeconds - Specify how long to extend the session. Defaults to 900 seconds or 15 minutes.
73
86
  * @returns {Promise<void>}
74
87
  */
@@ -84,21 +97,20 @@ export declare class TurnkeyBrowserClient extends TurnkeyBaseClient {
84
97
  */
85
98
  loginWithBundle: (params: LoginWithBundleParams) => Promise<void>;
86
99
  /**
87
- * Log in with a session object. This method uses a session object from server actions and stores it and the active client in local storage
88
- * To be used in conjunction with an `iframeStamper`.
100
+ * Log in with a session returns from Turnkey. This method uses a session from server actions and stores it and the active client in local storage
101
+ * To be used in conjunction with an `indexeDbStamper`.
89
102
  *
90
103
  * @param session
91
104
  * @returns {Promise<void>}
92
105
  */
93
- loginWithSession: (session: Session) => Promise<void>;
106
+ loginWithSession: (session: string) => Promise<void>;
94
107
  /**
95
108
  * Log in with a passkey.
96
109
  * To be used in conjunction with a `passkeyStamper`
97
110
  *
98
111
  * @param LoginWithPasskeyParams
99
112
  * @param params.sessionType - The type of session to create
100
- * @param params.iframeClient - The iframe client to use to inject the credential bundle
101
- * @param params.targetPublicKey - The public key of the target client
113
+ * @param params.publicKey - The public key of indexedDb
102
114
  * @param params.expirationSeconds - Expiration time for the session in seconds. Defaults to 900 seconds or 15 minutes.
103
115
  * @returns {Promise<void>}
104
116
  */
@@ -108,31 +120,11 @@ export declare class TurnkeyBrowserClient extends TurnkeyBaseClient {
108
120
  *
109
121
  * @param LoginWithWalletParams
110
122
  * @param params.sessionType - The type of session to create
111
- * @param params.iframeClient - The iframe client to use to inject the credential bundle
112
- * @param params.targetPublicKey - The public key of the target iframe
123
+ * @param params.publicKey - The public key of indexedDb
113
124
  * @param params.expirationSeconds - The expiration time for the session in seconds
114
125
  * @returns {Promise<void>}
115
126
  */
116
127
  loginWithWallet: (params: LoginWithWalletParams) => Promise<void>;
117
- /**
118
- * Creates a read-write session. This method infers the current user's organization ID and target userId.
119
- * To be used in conjunction with an `iframeStamper`: the resulting session's credential bundle can be
120
- * injected into an iframeStamper to create a session that enables both read and write requests.
121
- *
122
- * @param targetEmbeddedKey
123
- * @param expirationSeconds
124
- * @param userId
125
- * @returns {Promise<SdkApiTypes.TCreateReadWriteSessionResponse>}
126
- */
127
- loginWithReadWriteSession: (targetEmbeddedKey: string, expirationSeconds?: string, userId?: string) => Promise<SdkApiTypes.TCreateReadWriteSessionResponse>;
128
- /**
129
- * Logs in with an existing auth bundle. this bundle enables both read and write requests.
130
- *
131
- * @param credentialBundle
132
- * @param expirationSeconds
133
- * @returns {Promise<boolean>}
134
- */
135
- loginWithAuthBundle: (credentialBundle: string, expirationSeconds?: string) => Promise<boolean>;
136
128
  /**
137
129
  * Removes authentication factors from an end user.
138
130
  *
@@ -210,20 +202,6 @@ export declare class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
210
202
  * @returns {Promise<Passkey>}
211
203
  */
212
204
  createUserPasskey: (config?: Record<any, any>) => Promise<Passkey>;
213
- /**
214
- * Uses passkey authentication to create a read-write session, via an embedded API key,
215
- * and stores + returns the resulting auth bundle that contains the encrypted API key.
216
- * This auth bundle (also referred to as a credential bundle) can be injected into an `iframeStamper`,
217
- * resulting in a touch-free authenticator. Unlike `loginWithReadWriteSession`, this method
218
- * assumes the end-user's organization ID (i.e. the sub-organization ID) is already known.
219
- *
220
- * @param userId
221
- * @param targetEmbeddedKey
222
- * @param expirationSeconds
223
- * @param curveType
224
- * @returns {Promise<ReadWriteSession>}
225
- */
226
- createPasskeySession: (userId: string, targetEmbeddedKey: string, expirationSeconds?: string, organizationId?: string) => Promise<ReadWriteSession>;
227
205
  }
228
206
  /**
229
207
  * TurnkeyIframeClient is a client that uses an iframe to interact with the Turnkey API.
@@ -250,5 +228,16 @@ export declare class TurnkeyWalletClient extends TurnkeyBrowserClient {
250
228
  getPublicKey(): Promise<string>;
251
229
  getWalletInterface(): WalletInterface;
252
230
  }
231
+ /**
232
+ * TurnkeyIndexedDbClient is a client that uses IndexedDb to interact with the Turnkey API.
233
+ * @extends TurnkeyBrowserClient
234
+ */
235
+ export declare class TurnkeyIndexedDbClient extends TurnkeyBrowserClient {
236
+ constructor(config: TurnkeySDKClientConfig);
237
+ clear: () => Promise<void>;
238
+ getPublicKey: () => Promise<string | null>;
239
+ init: () => Promise<void>;
240
+ resetKeyPair: () => Promise<void>;
241
+ }
253
242
  export {};
254
243
  //# sourceMappingURL=browser-clients.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-clients.d.ts","sourceRoot":"","sources":["../../src/__clients__/browser-clients.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAiB,SAAS,EAAE,MAAM,yBAAyB,CAAC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IAAI,CAAC,CAEpC;CACH"}
@@ -10,6 +10,19 @@ var constants = require('../constants.js');
10
10
  class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
11
11
  constructor(config, authClient) {
12
12
  super(config, authClient);
13
+ /**
14
+ * @deprecated
15
+ * This method is deprecated and only creates a READ_ONLY session using an API key.
16
+ * Use one of the following methods instead, depending on your context:
17
+ *
18
+ * - `loginWithPasskey()` for WebAuthn-based sessions using IndexedDB
19
+ * - `loginWithWallet()` for EVM or Solana wallet-based sessions
20
+ * - `loginWithSession()` if the session string is already available (e.g. from server actions)
21
+ * - `loginWithBundle()` for iframe-based sessions (e.g. for email-auth non otp based login)
22
+ *
23
+ * @param config Optional configuration containing an organization ID
24
+ * @returns A Promise resolving to the created read-only session
25
+ */
13
26
  this.login = async (config) => {
14
27
  const readOnlySessionResult = await this.createReadOnlySession(config || {});
15
28
  const session = {
@@ -24,16 +37,16 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
24
37
  };
25
38
  /**
26
39
  * Attempts to refresh an existing Session. This method infers the current user's organization ID and target userId.
27
- * This will use a passkeyStamper for `READ_ONLY` sessions or an `iframeStamper` for `READ_WRITE` sessions.
40
+ * This will use a passkeyStamper for `READ_ONLY` sessions or an `indexedDbStamper` for `READ_WRITE` sessions.
28
41
  *
29
42
  * @param RefreshSessionParams
30
43
  * @param params.sessionType - The type of session that is being refreshed
31
- * @param params.targetPublicKey - The public key of the target client
44
+ * @param params.publicKey - The public key of the indexedDb client
32
45
  * @param params.expirationSeconds - Specify how long to extend the session. Defaults to 900 seconds or 15 minutes.
33
46
  * @returns {Promise<void>}
34
47
  */
35
48
  this.refreshSession = async (params) => {
36
- const { sessionType = base.SessionType.READ_WRITE, targetPublicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
49
+ const { sessionType = base.SessionType.READ_WRITE, publicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
37
50
  try {
38
51
  if (sessionType === base.SessionType.READ_ONLY) {
39
52
  if (this instanceof TurnkeyPasskeyClient) {
@@ -50,29 +63,14 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
50
63
  await storage.storeSession(session, base.AuthClient.Passkey);
51
64
  }
52
65
  else if (sessionType === base.SessionType.READ_WRITE) {
53
- if (!targetPublicKey) {
54
- throw new Error("You must provide a targetPublicKey to refresh a read-write session.");
66
+ if (!publicKey) {
67
+ throw new Error("You must provide a publicKey to refresh a read-write session.");
55
68
  }
56
- const readWriteSessionResult = await this.createReadWriteSession({
57
- targetPublicKey,
69
+ const sessionResponse = await this.stampLogin({
70
+ publicKey: publicKey,
58
71
  expirationSeconds,
59
- invalidateExisting: true,
60
72
  });
61
- const session = {
62
- sessionType: base.SessionType.READ_WRITE,
63
- userId: readWriteSessionResult.userId,
64
- organizationId: readWriteSessionResult.organizationId,
65
- expiry: Date.now() + Number(expirationSeconds) * 1000,
66
- token: readWriteSessionResult.credentialBundle,
67
- };
68
- if (this instanceof TurnkeyIframeClient) {
69
- await this.injectCredentialBundle(session.token);
70
- }
71
- else {
72
- // Throw an error if the client is not an iframe client
73
- throw new Error("You must use an iframe client to refresh a read-write session");
74
- }
75
- await storage.storeSession(session, base.AuthClient.Iframe);
73
+ await storage.storeSession(sessionResponse.session, base.AuthClient.IndexedDb);
76
74
  }
77
75
  else {
78
76
  throw new Error(`Invalid session type passed: ${sessionType}`);
@@ -111,21 +109,20 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
111
109
  await storage.storeSession(session, base.AuthClient.Iframe);
112
110
  };
113
111
  /**
114
- * Log in with a session object. This method uses a session object from server actions and stores it and the active client in local storage
115
- * To be used in conjunction with an `iframeStamper`.
112
+ * Log in with a session returns from Turnkey. This method uses a session from server actions and stores it and the active client in local storage
113
+ * To be used in conjunction with an `indexeDbStamper`.
116
114
  *
117
115
  * @param session
118
116
  * @returns {Promise<void>}
119
117
  */
120
118
  this.loginWithSession = async (session) => {
121
- if (this instanceof TurnkeyIframeClient) {
122
- await this.injectCredentialBundle(session.token);
119
+ if (this instanceof TurnkeyIndexedDbClient) {
120
+ await storage.storeSession(session, base.AuthClient.IndexedDb);
123
121
  }
124
122
  else {
125
- // Throw an error if the client is not an iframe client
126
- throw new Error("You must use an iframe client to log in with a session."); //should we default to a "localStorage" client?
123
+ // Throw an error if the client is not an indexedDb client
124
+ throw new Error("You must use an indexedDb client to log in with a session.");
127
125
  }
128
- await storage.storeSession(session, base.AuthClient.Iframe);
129
126
  };
130
127
  /**
131
128
  * Log in with a passkey.
@@ -133,14 +130,13 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
133
130
  *
134
131
  * @param LoginWithPasskeyParams
135
132
  * @param params.sessionType - The type of session to create
136
- * @param params.iframeClient - The iframe client to use to inject the credential bundle
137
- * @param params.targetPublicKey - The public key of the target client
133
+ * @param params.publicKey - The public key of indexedDb
138
134
  * @param params.expirationSeconds - Expiration time for the session in seconds. Defaults to 900 seconds or 15 minutes.
139
135
  * @returns {Promise<void>}
140
136
  */
141
137
  this.loginWithPasskey = async (params) => {
142
138
  try {
143
- const { sessionType = base.SessionType.READ_WRITE, iframeClient, targetPublicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
139
+ const { sessionType = base.SessionType.READ_WRITE, publicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
144
140
  // Create a read-only session
145
141
  if (sessionType === base.SessionType.READ_ONLY) {
146
142
  const readOnlySessionResult = await this.createReadOnlySession({});
@@ -149,31 +145,20 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
149
145
  userId: readOnlySessionResult.userId,
150
146
  organizationId: readOnlySessionResult.organizationId,
151
147
  expiry: Number(readOnlySessionResult.sessionExpiry),
152
- token: readOnlySessionResult.session,
148
+ token: readOnlySessionResult.session, // Once we have api key session scopes this can change
153
149
  };
154
150
  await storage.storeSession(session, base.AuthClient.Passkey);
155
151
  // Create a read-write session
156
152
  }
157
153
  else if (sessionType === base.SessionType.READ_WRITE) {
158
- if (!targetPublicKey) {
159
- throw new Error("You must provide a targetPublicKey to create a read-write session.");
154
+ if (!publicKey) {
155
+ throw new Error("You must provide a publicKey to create a passkey read write session.");
160
156
  }
161
- const readWriteSessionResult = await this.createReadWriteSession({
162
- targetPublicKey,
157
+ const sessionResponse = await this.stampLogin({
158
+ publicKey,
163
159
  expirationSeconds,
164
160
  });
165
- const session = {
166
- sessionType: base.SessionType.READ_WRITE,
167
- userId: readWriteSessionResult.userId,
168
- organizationId: readWriteSessionResult.organizationId,
169
- expiry: Date.now() + Number(expirationSeconds) * 1000,
170
- token: readWriteSessionResult.credentialBundle,
171
- };
172
- if (!iframeClient) {
173
- throw new Error("You must provide an iframe client to log in with a passkey.");
174
- }
175
- await iframeClient.injectCredentialBundle(session.token);
176
- await storage.storeSession(session, base.AuthClient.Iframe);
161
+ await storage.storeSession(sessionResponse.session, base.AuthClient.IndexedDb);
177
162
  }
178
163
  else {
179
164
  throw new Error(`Invalid session type passed: ${sessionType}`);
@@ -188,15 +173,13 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
188
173
  *
189
174
  * @param LoginWithWalletParams
190
175
  * @param params.sessionType - The type of session to create
191
- * @param params.iframeClient - The iframe client to use to inject the credential bundle
192
- * @param params.targetPublicKey - The public key of the target iframe
176
+ * @param params.publicKey - The public key of indexedDb
193
177
  * @param params.expirationSeconds - The expiration time for the session in seconds
194
178
  * @returns {Promise<void>}
195
179
  */
196
180
  this.loginWithWallet = async (params) => {
197
181
  try {
198
- const { sessionType = base.SessionType.READ_WRITE, iframeClient, targetPublicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
199
- // Create a read-only session
182
+ const { sessionType = base.SessionType.READ_WRITE, publicKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, } = params;
200
183
  if (sessionType === base.SessionType.READ_ONLY) {
201
184
  const readOnlySessionResult = await this.createReadOnlySession({});
202
185
  const session = {
@@ -207,28 +190,16 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
207
190
  token: readOnlySessionResult.session,
208
191
  };
209
192
  await storage.storeSession(session, base.AuthClient.Wallet);
210
- // Create a read-write session
211
193
  }
212
194
  else if (sessionType === base.SessionType.READ_WRITE) {
213
- if (!targetPublicKey) {
214
- throw new Error("You must provide a targetPublicKey to create a read-write session.");
195
+ if (!publicKey) {
196
+ throw new Error("You must provide a publicKey to create a read-write session.");
215
197
  }
216
- const readWriteSessionResult = await this.createReadWriteSession({
217
- targetPublicKey,
198
+ const sessionResponse = await this.stampLogin({
199
+ publicKey: publicKey,
218
200
  expirationSeconds,
219
201
  });
220
- const session = {
221
- sessionType: base.SessionType.READ_WRITE,
222
- userId: readWriteSessionResult.userId,
223
- organizationId: readWriteSessionResult.organizationId,
224
- expiry: Date.now() + Number(expirationSeconds) * 1000,
225
- token: readWriteSessionResult.credentialBundle,
226
- };
227
- if (!iframeClient) {
228
- throw new Error("You must provide an iframe client to log in with a wallet.");
229
- }
230
- await iframeClient.injectCredentialBundle(session.token);
231
- await storage.storeSession(session, base.AuthClient.Iframe);
202
+ await storage.storeSession(sessionResponse.session, base.AuthClient.IndexedDb);
232
203
  }
233
204
  else {
234
205
  throw new Error(`Invalid session type passed: ${sessionType}`);
@@ -238,59 +209,6 @@ class TurnkeyBrowserClient extends baseClient.TurnkeyBaseClient {
238
209
  throw new Error(`Unable to log in with the provided wallet: ${error}`);
239
210
  }
240
211
  };
241
- /**
242
- * Creates a read-write session. This method infers the current user's organization ID and target userId.
243
- * To be used in conjunction with an `iframeStamper`: the resulting session's credential bundle can be
244
- * injected into an iframeStamper to create a session that enables both read and write requests.
245
- *
246
- * @param targetEmbeddedKey
247
- * @param expirationSeconds
248
- * @param userId
249
- * @returns {Promise<SdkApiTypes.TCreateReadWriteSessionResponse>}
250
- */
251
- this.loginWithReadWriteSession = async (targetEmbeddedKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, userId) => {
252
- try {
253
- const readWriteSessionResult = await this.createReadWriteSession({
254
- targetPublicKey: targetEmbeddedKey,
255
- expirationSeconds,
256
- userId: userId,
257
- });
258
- // Ensure session and sessionExpiry are included in the object
259
- const readWriteSessionResultWithSession = {
260
- ...readWriteSessionResult,
261
- credentialBundle: readWriteSessionResult.credentialBundle,
262
- sessionExpiry: Date.now() + Number(expirationSeconds) * 1000,
263
- };
264
- // store auth bundle in local storage
265
- await storage.saveSession(readWriteSessionResultWithSession, this.authClient);
266
- return readWriteSessionResultWithSession;
267
- }
268
- catch (error) {
269
- throw new Error(`Unable to log in with the provided read-write session: ${error}`);
270
- }
271
- };
272
- /**
273
- * Logs in with an existing auth bundle. this bundle enables both read and write requests.
274
- *
275
- * @param credentialBundle
276
- * @param expirationSeconds
277
- * @returns {Promise<boolean>}
278
- */
279
- this.loginWithAuthBundle = async (credentialBundle, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS) => {
280
- try {
281
- const whoAmIResult = await this.getWhoami();
282
- const readWriteSessionResultWithSession = {
283
- ...whoAmIResult,
284
- credentialBundle: credentialBundle,
285
- sessionExpiry: Date.now() + Number(expirationSeconds) * 1000,
286
- };
287
- await storage.saveSession(readWriteSessionResultWithSession, this.authClient);
288
- return true;
289
- }
290
- catch (error) {
291
- throw new Error(`Unable to log in with the provided auth bundle: ${error}`);
292
- }
293
- };
294
212
  /**
295
213
  * Removes authentication factors from an end user.
296
214
  *
@@ -530,7 +448,7 @@ class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
530
448
  },
531
449
  authenticatorSelection: {
532
450
  authenticatorAttachment: config.publicKey?.authenticatorSelection?.authenticatorAttachment ??
533
- undefined,
451
+ undefined, // default to empty
534
452
  requireResidentKey: config.publicKey?.authenticatorSelection?.requireResidentKey ??
535
453
  true,
536
454
  residentKey: config.publicKey?.authenticatorSelection?.residentKey ?? "required",
@@ -547,63 +465,6 @@ class TurnkeyPasskeyClient extends TurnkeyBrowserClient {
547
465
  attestation,
548
466
  };
549
467
  };
550
- /**
551
- * Uses passkey authentication to create a read-write session, via an embedded API key,
552
- * and stores + returns the resulting auth bundle that contains the encrypted API key.
553
- * This auth bundle (also referred to as a credential bundle) can be injected into an `iframeStamper`,
554
- * resulting in a touch-free authenticator. Unlike `loginWithReadWriteSession`, this method
555
- * assumes the end-user's organization ID (i.e. the sub-organization ID) is already known.
556
- *
557
- * @param userId
558
- * @param targetEmbeddedKey
559
- * @param expirationSeconds
560
- * @param curveType
561
- * @returns {Promise<ReadWriteSession>}
562
- */
563
- this.createPasskeySession = async (userId, targetEmbeddedKey, expirationSeconds = constants.DEFAULT_SESSION_EXPIRATION_IN_SECONDS, organizationId) => {
564
- try {
565
- const session = await storage.getStorageValue(storage.StorageKeys.Session);
566
- organizationId = organizationId ?? session?.organizationId;
567
- userId = userId ?? session?.userId;
568
- if (!organizationId) {
569
- throw new Error("Error creating passkey session: Organization ID is required");
570
- }
571
- if (!userId) {
572
- throw new Error("Error creating passkey session: User ID is required");
573
- }
574
- const { authBundle: credentialBundle, publicKey } = await utils.createEmbeddedAPIKey(targetEmbeddedKey);
575
- // add API key to Turnkey User
576
- await this.createApiKeys({
577
- organizationId,
578
- userId,
579
- apiKeys: [
580
- {
581
- apiKeyName: `Session Key ${String(Date.now())}`,
582
- publicKey,
583
- expirationSeconds,
584
- curveType: "API_KEY_CURVE_P256",
585
- },
586
- ],
587
- });
588
- const whoAmI = await this.getWhoami();
589
- const expiry = Date.now() + Number(expirationSeconds) * 1000;
590
- await storage.saveSession({
591
- organizationId,
592
- organizationName: whoAmI?.organizationName ?? "",
593
- userId,
594
- username: whoAmI?.username ?? "",
595
- credentialBundle,
596
- sessionExpiry: expiry,
597
- }, this.authClient);
598
- return {
599
- credentialBundle,
600
- expiry,
601
- };
602
- }
603
- catch (error) {
604
- throw new Error("Unable to create passkey session.");
605
- }
606
- };
607
468
  this.rpId = this.stamper.rpId;
608
469
  }
609
470
  }
@@ -658,9 +519,31 @@ class TurnkeyWalletClient extends TurnkeyBrowserClient {
658
519
  return this.wallet;
659
520
  }
660
521
  }
522
+ /**
523
+ * TurnkeyIndexedDbClient is a client that uses IndexedDb to interact with the Turnkey API.
524
+ * @extends TurnkeyBrowserClient
525
+ */
526
+ class TurnkeyIndexedDbClient extends TurnkeyBrowserClient {
527
+ constructor(config) {
528
+ super(config, base.AuthClient.IndexedDb);
529
+ this.clear = async () => {
530
+ return await this.stamper.clear();
531
+ };
532
+ this.getPublicKey = async () => {
533
+ return await this.stamper.getPublicKey();
534
+ };
535
+ this.init = async () => {
536
+ return await this.stamper.init();
537
+ };
538
+ this.resetKeyPair = async () => {
539
+ return await this.stamper.resetKeyPair();
540
+ };
541
+ }
542
+ }
661
543
 
662
544
  exports.TurnkeyBrowserClient = TurnkeyBrowserClient;
663
545
  exports.TurnkeyIframeClient = TurnkeyIframeClient;
546
+ exports.TurnkeyIndexedDbClient = TurnkeyIndexedDbClient;
664
547
  exports.TurnkeyPasskeyClient = TurnkeyPasskeyClient;
665
548
  exports.TurnkeyWalletClient = TurnkeyWalletClient;
666
549
  //# sourceMappingURL=browser-clients.js.map