@seamapi/http 0.1.0 → 0.2.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 (122) hide show
  1. package/dist/connect.cjs +752 -366
  2. package/dist/connect.cjs.map +1 -1
  3. package/dist/connect.d.cts +186 -142
  4. package/lib/params-serializer.d.ts +5 -0
  5. package/lib/params-serializer.js +42 -0
  6. package/lib/params-serializer.js.map +1 -0
  7. package/lib/seam/connect/auth.d.ts +3 -2
  8. package/lib/seam/connect/auth.js +55 -4
  9. package/lib/seam/connect/auth.js.map +1 -1
  10. package/lib/seam/connect/client.d.ts +10 -22
  11. package/lib/seam/connect/client.js +17 -77
  12. package/lib/seam/connect/client.js.map +1 -1
  13. package/lib/seam/connect/index.d.ts +2 -1
  14. package/lib/seam/connect/index.js +2 -1
  15. package/lib/seam/connect/index.js.map +1 -1
  16. package/lib/seam/connect/{client-options.d.ts → options.d.ts} +7 -7
  17. package/lib/seam/connect/{client-options.js → options.js} +5 -10
  18. package/lib/seam/connect/options.js.map +1 -0
  19. package/lib/seam/connect/parse-options.d.ts +6 -2
  20. package/lib/seam/connect/parse-options.js +34 -16
  21. package/lib/seam/connect/parse-options.js.map +1 -1
  22. package/lib/seam/connect/routes/access-codes-unmanaged.d.ts +10 -9
  23. package/lib/seam/connect/routes/access-codes-unmanaged.js +26 -14
  24. package/lib/seam/connect/routes/access-codes-unmanaged.js.map +1 -1
  25. package/lib/seam/connect/routes/access-codes.d.ts +15 -14
  26. package/lib/seam/connect/routes/access-codes.js +29 -17
  27. package/lib/seam/connect/routes/access-codes.js.map +1 -1
  28. package/lib/seam/connect/routes/acs-access-groups.d.ts +13 -12
  29. package/lib/seam/connect/routes/acs-access-groups.js +26 -14
  30. package/lib/seam/connect/routes/acs-access-groups.js.map +1 -1
  31. package/lib/seam/connect/routes/acs-credentials.d.ts +9 -8
  32. package/lib/seam/connect/routes/acs-credentials.js +26 -14
  33. package/lib/seam/connect/routes/acs-credentials.js.map +1 -1
  34. package/lib/seam/connect/routes/acs-systems.d.ts +9 -8
  35. package/lib/seam/connect/routes/acs-systems.js +29 -17
  36. package/lib/seam/connect/routes/acs-systems.js.map +1 -1
  37. package/lib/seam/connect/routes/acs-users.d.ts +18 -11
  38. package/lib/seam/connect/routes/acs-users.js +40 -14
  39. package/lib/seam/connect/routes/acs-users.js.map +1 -1
  40. package/lib/seam/connect/routes/acs.d.ts +5 -4
  41. package/lib/seam/connect/routes/acs.js +26 -14
  42. package/lib/seam/connect/routes/acs.js.map +1 -1
  43. package/lib/seam/connect/routes/action-attempts.d.ts +7 -6
  44. package/lib/seam/connect/routes/action-attempts.js +26 -14
  45. package/lib/seam/connect/routes/action-attempts.js.map +1 -1
  46. package/lib/seam/connect/routes/client-sessions.d.ts +13 -9
  47. package/lib/seam/connect/routes/client-sessions.js +33 -14
  48. package/lib/seam/connect/routes/client-sessions.js.map +1 -1
  49. package/lib/seam/connect/routes/connect-webviews.d.ts +11 -10
  50. package/lib/seam/connect/routes/connect-webviews.js +29 -17
  51. package/lib/seam/connect/routes/connect-webviews.js.map +1 -1
  52. package/lib/seam/connect/routes/connected-accounts.d.ts +8 -7
  53. package/lib/seam/connect/routes/connected-accounts.js +26 -14
  54. package/lib/seam/connect/routes/connected-accounts.js.map +1 -1
  55. package/lib/seam/connect/routes/devices-unmanaged.d.ts +8 -7
  56. package/lib/seam/connect/routes/devices-unmanaged.js +26 -14
  57. package/lib/seam/connect/routes/devices-unmanaged.js.map +1 -1
  58. package/lib/seam/connect/routes/devices.d.ts +10 -9
  59. package/lib/seam/connect/routes/devices.js +26 -14
  60. package/lib/seam/connect/routes/devices.js.map +1 -1
  61. package/lib/seam/connect/routes/events.d.ts +7 -6
  62. package/lib/seam/connect/routes/events.js +26 -14
  63. package/lib/seam/connect/routes/events.js.map +1 -1
  64. package/lib/seam/connect/routes/locks.d.ts +9 -8
  65. package/lib/seam/connect/routes/locks.js +26 -14
  66. package/lib/seam/connect/routes/locks.js.map +1 -1
  67. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.d.ts +10 -9
  68. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js +26 -14
  69. package/lib/seam/connect/routes/noise-sensors-noise-thresholds.js.map +1 -1
  70. package/lib/seam/connect/routes/noise-sensors.d.ts +5 -4
  71. package/lib/seam/connect/routes/noise-sensors.js +26 -14
  72. package/lib/seam/connect/routes/noise-sensors.js.map +1 -1
  73. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.d.ts +10 -9
  74. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js +26 -14
  75. package/lib/seam/connect/routes/thermostats-climate-setting-schedules.js.map +1 -1
  76. package/lib/seam/connect/routes/thermostats.d.ts +13 -12
  77. package/lib/seam/connect/routes/thermostats.js +26 -14
  78. package/lib/seam/connect/routes/thermostats.js.map +1 -1
  79. package/lib/seam/connect/routes/webhooks.d.ts +9 -8
  80. package/lib/seam/connect/routes/webhooks.js +26 -14
  81. package/lib/seam/connect/routes/webhooks.js.map +1 -1
  82. package/lib/seam/connect/routes/workspaces.d.ts +8 -7
  83. package/lib/seam/connect/routes/workspaces.js +26 -14
  84. package/lib/seam/connect/routes/workspaces.js.map +1 -1
  85. package/lib/seam/connect/seam-http.d.ts +24 -0
  86. package/lib/seam/connect/seam-http.js +82 -0
  87. package/lib/seam/connect/seam-http.js.map +1 -0
  88. package/package.json +7 -4
  89. package/src/lib/params-serializer.ts +55 -0
  90. package/src/lib/seam/connect/auth.ts +94 -6
  91. package/src/lib/seam/connect/client.ts +22 -127
  92. package/src/lib/seam/connect/env.d.ts +11 -0
  93. package/src/lib/seam/connect/index.ts +2 -1
  94. package/src/lib/seam/connect/{client-options.ts → options.ts} +13 -19
  95. package/src/lib/seam/connect/parse-options.ts +50 -23
  96. package/src/lib/seam/connect/routes/access-codes-unmanaged.ts +44 -31
  97. package/src/lib/seam/connect/routes/access-codes.ts +48 -48
  98. package/src/lib/seam/connect/routes/acs-access-groups.ts +49 -40
  99. package/src/lib/seam/connect/routes/acs-credentials.ts +40 -28
  100. package/src/lib/seam/connect/routes/acs-systems.ts +40 -30
  101. package/src/lib/seam/connect/routes/acs-users.ts +70 -36
  102. package/src/lib/seam/connect/routes/acs.ts +33 -17
  103. package/src/lib/seam/connect/routes/action-attempts.ts +36 -22
  104. package/src/lib/seam/connect/routes/client-sessions.ts +58 -30
  105. package/src/lib/seam/connect/routes/connect-webviews.ts +45 -34
  106. package/src/lib/seam/connect/routes/connected-accounts.ts +40 -25
  107. package/src/lib/seam/connect/routes/devices-unmanaged.ts +39 -25
  108. package/src/lib/seam/connect/routes/devices.ts +39 -31
  109. package/src/lib/seam/connect/routes/events.ts +36 -22
  110. package/src/lib/seam/connect/routes/locks.ts +38 -28
  111. package/src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts +47 -31
  112. package/src/lib/seam/connect/routes/noise-sensors.ts +33 -17
  113. package/src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts +47 -31
  114. package/src/lib/seam/connect/routes/thermostats.ts +42 -40
  115. package/src/lib/seam/connect/routes/webhooks.ts +38 -28
  116. package/src/lib/seam/connect/routes/workspaces.ts +38 -25
  117. package/src/lib/seam/connect/seam-http.ts +141 -0
  118. package/lib/seam/connect/axios.d.ts +0 -3
  119. package/lib/seam/connect/axios.js +0 -19
  120. package/lib/seam/connect/axios.js.map +0 -1
  121. package/lib/seam/connect/client-options.js.map +0 -1
  122. package/src/lib/seam/connect/axios.ts +0 -25
package/dist/connect.cjs CHANGED
@@ -1,25 +1,23 @@
1
1
  'use strict';
2
2
 
3
3
  var axios = require('axios');
4
+ var axiosRetry = require('axios-retry');
4
5
 
5
6
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
7
 
7
8
  var axios__default = /*#__PURE__*/_interopDefault(axios);
9
+ var axiosRetry__default = /*#__PURE__*/_interopDefault(axiosRetry);
8
10
 
9
- // src/lib/seam/connect/axios.ts
10
-
11
- // src/lib/seam/connect/client-options.ts
11
+ // src/lib/seam/connect/options.ts
12
12
  var isSeamHttpOptionsWithClient = (options) => {
13
13
  if (!("client" in options))
14
14
  return false;
15
15
  if (options.client == null)
16
16
  return false;
17
- const keys = Object.keys(options).filter(
18
- (k) => !["client", "enableLegacyMethodBehaivor"].includes(k)
19
- );
17
+ const keys = Object.keys(options).filter((k) => k !== "client");
20
18
  if (keys.length > 0) {
21
19
  throw new SeamHttpInvalidOptionsError(
22
- `The client option cannot be used with any other option except enableLegacyMethodBehaivor, but received: ${keys.join(
20
+ `The client option cannot be used with any other option, but received: ${keys.join(
23
21
  ", "
24
22
  )}`
25
23
  );
@@ -33,7 +31,7 @@ var isSeamHttpOptionsWithApiKey = (options) => {
33
31
  return false;
34
32
  if ("clientSessionToken" in options && options.clientSessionToken != null) {
35
33
  throw new SeamHttpInvalidOptionsError(
36
- "The clientSessionToken option cannot be used with the apiKey option."
34
+ "The clientSessionToken option cannot be used with the apiKey option"
37
35
  );
38
36
  }
39
37
  return true;
@@ -45,7 +43,7 @@ var isSeamHttpOptionsWithClientSessionToken = (options) => {
45
43
  return false;
46
44
  if ("apiKey" in options && options.apiKey != null) {
47
45
  throw new SeamHttpInvalidOptionsError(
48
- "The clientSessionToken option cannot be used with the apiKey option."
46
+ "The clientSessionToken option cannot be used with the apiKey option"
49
47
  );
50
48
  }
51
49
  return true;
@@ -60,6 +58,9 @@ var SeamHttpInvalidOptionsError = class extends Error {
60
58
 
61
59
  // src/lib/seam/connect/auth.ts
62
60
  var getAuthHeaders = (options) => {
61
+ if ("publishableKey" in options) {
62
+ return getAuthHeadersForPublishableKey(options.publishableKey);
63
+ }
63
64
  if (isSeamHttpOptionsWithApiKey(options)) {
64
65
  return getAuthHeadersForApiKey(options);
65
66
  }
@@ -67,7 +68,7 @@ var getAuthHeaders = (options) => {
67
68
  return getAuthHeadersForClientSessionToken(options);
68
69
  }
69
70
  throw new SeamHttpInvalidOptionsError(
70
- "Must specify an apiKey or clientSessionToken"
71
+ "Must specify an apiKey, clientSessionToken, or publishableKey"
71
72
  );
72
73
  };
73
74
  var getAuthHeadersForApiKey = ({
@@ -78,12 +79,20 @@ var getAuthHeadersForApiKey = ({
78
79
  "A Client Session Token cannot be used as an apiKey"
79
80
  );
80
81
  }
82
+ if (isJwt(apiKey)) {
83
+ throw new SeamHttpInvalidTokenError("A JWT cannot be used as an apiKey");
84
+ }
81
85
  if (isAccessToken(apiKey)) {
82
86
  throw new SeamHttpInvalidTokenError(
83
- "An access token cannot be used as an apiKey"
87
+ "An Access Token cannot be used as an apiKey"
84
88
  );
85
89
  }
86
- if (isJwt(apiKey) || !isSeamToken(apiKey)) {
90
+ if (isPublishableKey(apiKey)) {
91
+ throw new SeamHttpInvalidTokenError(
92
+ "A Publishable Key cannot be used as an apiKey"
93
+ );
94
+ }
95
+ if (!isSeamToken(apiKey)) {
87
96
  throw new SeamHttpInvalidTokenError(
88
97
  `Unknown or invalid apiKey format, expected token to start with ${tokenPrefix}`
89
98
  );
@@ -95,6 +104,21 @@ var getAuthHeadersForApiKey = ({
95
104
  var getAuthHeadersForClientSessionToken = ({
96
105
  clientSessionToken
97
106
  }) => {
107
+ if (isJwt(clientSessionToken)) {
108
+ throw new SeamHttpInvalidTokenError(
109
+ "A JWT cannot be used as a clientSessionToken"
110
+ );
111
+ }
112
+ if (isAccessToken(clientSessionToken)) {
113
+ throw new SeamHttpInvalidTokenError(
114
+ "An Access Token cannot be used as a clientSessionToken"
115
+ );
116
+ }
117
+ if (isPublishableKey(clientSessionToken)) {
118
+ throw new SeamHttpInvalidTokenError(
119
+ "A Publishable Key cannot be used as a clientSessionToken"
120
+ );
121
+ }
98
122
  if (!isClientSessionToken(clientSessionToken)) {
99
123
  throw new SeamHttpInvalidTokenError(
100
124
  `Unknown or invalid clientSessionToken format, expected token to start with ${clientSessionTokenPrefix}`
@@ -105,6 +129,31 @@ var getAuthHeadersForClientSessionToken = ({
105
129
  "client-session-token": clientSessionToken
106
130
  };
107
131
  };
132
+ var getAuthHeadersForPublishableKey = (publishableKey) => {
133
+ if (isJwt(publishableKey)) {
134
+ throw new SeamHttpInvalidTokenError(
135
+ "A JWT cannot be used as a publishableKey"
136
+ );
137
+ }
138
+ if (isAccessToken(publishableKey)) {
139
+ throw new SeamHttpInvalidTokenError(
140
+ "An Access Token cannot be used as a publishableKey"
141
+ );
142
+ }
143
+ if (isClientSessionToken(publishableKey)) {
144
+ throw new SeamHttpInvalidTokenError(
145
+ "A Client Session Token Key cannot be used as a publishableKey"
146
+ );
147
+ }
148
+ if (!isPublishableKey(publishableKey)) {
149
+ throw new SeamHttpInvalidTokenError(
150
+ `Unknown or invalid publishableKey format, expected token to start with ${publishableKeyTokenPrefix}`
151
+ );
152
+ }
153
+ return {
154
+ "seam-publishable-key": publishableKey
155
+ };
156
+ };
108
157
  var SeamHttpInvalidTokenError = class extends Error {
109
158
  constructor(message) {
110
159
  super(`SeamHttp received an invalid token: ${message}`);
@@ -112,75 +161,257 @@ var SeamHttpInvalidTokenError = class extends Error {
112
161
  Error.captureStackTrace(this, this.constructor);
113
162
  }
114
163
  };
164
+ var warnOnInsecureuserIdentifierKey = (userIdentifierKey) => {
165
+ if (isEmail(userIdentifierKey)) {
166
+ console.warn(
167
+ ...[
168
+ "Using an email for the userIdentifierKey is insecure and may return an error in the future!",
169
+ "This is insecure because an email is common knowledge or easily guessed.",
170
+ "Use something with sufficient entropy known only to the owner of the client session.",
171
+ "For help choosing a user identifier key see",
172
+ "https://docs.seam.co/latest/seam-components/overview/get-started-with-client-side-components#3-select-a-user-identifier-key"
173
+ ]
174
+ );
175
+ }
176
+ };
115
177
  var tokenPrefix = "seam_";
116
178
  var clientSessionTokenPrefix = "seam_cst";
179
+ var publishableKeyTokenPrefix = "seam_pk";
117
180
  var isClientSessionToken = (token) => token.startsWith(clientSessionTokenPrefix);
118
181
  var isAccessToken = (token) => token.startsWith("seam_at");
119
182
  var isJwt = (token) => token.startsWith("ey");
120
183
  var isSeamToken = (token) => token.startsWith(tokenPrefix);
184
+ var isPublishableKey = (token) => token.startsWith(publishableKeyTokenPrefix);
185
+ var isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
121
186
 
122
- // src/lib/seam/connect/axios.ts
123
- var createAxiosClient = (options) => {
124
- if (isSeamHttpOptionsWithClient(options))
125
- return options.client;
126
- return axios__default.default.create({
127
- baseURL: options.endpoint,
128
- withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
129
- ...options.axiosOptions,
130
- headers: {
131
- ...getAuthHeaders(options),
132
- ...options.axiosOptions.headers
133
- // TODO: User-Agent
187
+ // src/lib/params-serializer.ts
188
+ var paramsSerializer = (params) => {
189
+ const searchParams = new URLSearchParams();
190
+ for (const [name, value] of Object.entries(params)) {
191
+ if (value == null)
192
+ continue;
193
+ if (Array.isArray(value)) {
194
+ if (value.length === 0)
195
+ searchParams.set(name, "");
196
+ if (value.length === 1 && value[0] === "") {
197
+ throw new UnserializableParamError(
198
+ name,
199
+ `is a single element array containing the empty string which is unsupported because it serializes to the empty array`
200
+ );
201
+ }
202
+ for (const v of value) {
203
+ throwIfUnserializable(name, v);
204
+ searchParams.append(name, v);
205
+ }
206
+ continue;
134
207
  }
208
+ throwIfUnserializable(name, value);
209
+ searchParams.set(name, value);
210
+ }
211
+ searchParams.sort();
212
+ return searchParams.toString();
213
+ };
214
+ var throwIfUnserializable = (k, v) => {
215
+ if (v == null) {
216
+ throw new UnserializableParamError(k, `is ${v} or contains ${v}`);
217
+ }
218
+ if (typeof v === "function") {
219
+ throw new UnserializableParamError(
220
+ k,
221
+ "is a function or contains a function"
222
+ );
223
+ }
224
+ if (typeof v === "object") {
225
+ throw new UnserializableParamError(k, "is an object or contains an object");
226
+ }
227
+ };
228
+ var UnserializableParamError = class extends Error {
229
+ constructor(name, message) {
230
+ super(`Could not serialize parameter: '${name}' ${message}`);
231
+ this.name = this.constructor.name;
232
+ Error.captureStackTrace(this, this.constructor);
233
+ }
234
+ };
235
+
236
+ // src/lib/seam/connect/client.ts
237
+ var createClient = (options) => {
238
+ if (options.client != null)
239
+ return options.client;
240
+ const client = axios__default.default.create({
241
+ paramsSerializer,
242
+ ...options.axiosOptions
243
+ });
244
+ axiosRetry__default.default(client, {
245
+ retries: 2,
246
+ retryDelay: axiosRetry.exponentialDelay,
247
+ ...options.axiosRetryOptions
135
248
  });
249
+ return client;
136
250
  };
137
251
 
138
252
  // src/lib/seam/connect/parse-options.ts
139
- var enableLegacyMethodBehaivorDefault = true;
253
+ var defaultEndpoint = "https://connect.getseam.com";
140
254
  var parseOptions = (apiKeyOrOptions) => {
255
+ const options = getNormalizedOptions(apiKeyOrOptions);
256
+ if (isSeamHttpOptionsWithClient(options))
257
+ return options;
258
+ return {
259
+ axiosOptions: {
260
+ baseURL: options.endpoint ?? getEndpointFromEnv() ?? defaultEndpoint,
261
+ withCredentials: isSeamHttpOptionsWithClientSessionToken(options),
262
+ ...options.axiosOptions,
263
+ headers: {
264
+ ...getAuthHeaders(options),
265
+ ...options.axiosOptions?.headers
266
+ }
267
+ },
268
+ axiosRetryOptions: {
269
+ ...options.axiosRetryOptions
270
+ }
271
+ };
272
+ };
273
+ var getNormalizedOptions = (apiKeyOrOptions) => {
141
274
  const options = typeof apiKeyOrOptions === "string" ? { apiKey: apiKeyOrOptions } : apiKeyOrOptions;
142
275
  if (isSeamHttpOptionsWithClient(options))
143
- return {
144
- ...options,
145
- enableLegacyMethodBehaivor: options.enableLegacyMethodBehaivor ?? enableLegacyMethodBehaivorDefault
146
- };
147
- const endpoint = options.endpoint ?? globalThis.process?.env?.["SEAM_ENDPOINT"] ?? globalThis.process?.env?.["SEAM_API_URL"] ?? "https://connect.getseam.com";
148
- const apiKey = "apiKey" in options ? options.apiKey : globalThis.process?.env?.["SEAM_API_KEY"];
276
+ return options;
277
+ const apiKey = "apiKey" in options ? options.apiKey : getApiKeyFromEnv(options);
149
278
  return {
150
279
  ...options,
151
- ...apiKey != null ? { apiKey } : {},
152
- endpoint,
153
- axiosOptions: options.axiosOptions ?? {},
154
- enableLegacyMethodBehaivor: options.enableLegacyMethodBehaivor ?? enableLegacyMethodBehaivorDefault
280
+ ...apiKey != null ? { apiKey } : {}
155
281
  };
156
282
  };
283
+ var getApiKeyFromEnv = (options) => {
284
+ if ("clientSessionToken" in options && options.clientSessionToken != null) {
285
+ return null;
286
+ }
287
+ return globalThis.process?.env?.SEAM_API_KEY;
288
+ };
289
+ var getEndpointFromEnv = () => {
290
+ return globalThis.process?.env?.SEAM_ENDPOINT ?? globalThis.process?.env?.SEAM_API_URL;
291
+ };
292
+
293
+ // src/lib/seam/connect/routes/client-sessions.ts
294
+ var SeamHttpClientSessions = class _SeamHttpClientSessions {
295
+ constructor(apiKeyOrOptions = {}) {
296
+ const clientOptions = parseOptions(apiKeyOrOptions);
297
+ this.client = createClient(clientOptions);
298
+ }
299
+ static fromClient(client, options = {}) {
300
+ const constructorOptions = { ...options, client };
301
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
302
+ throw new SeamHttpInvalidOptionsError("Missing client");
303
+ }
304
+ return new _SeamHttpClientSessions(constructorOptions);
305
+ }
306
+ static fromApiKey(apiKey, options = {}) {
307
+ const constructorOptions = { ...options, apiKey };
308
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
309
+ throw new SeamHttpInvalidOptionsError("Missing apiKey");
310
+ }
311
+ return new _SeamHttpClientSessions(constructorOptions);
312
+ }
313
+ static fromClientSessionToken(clientSessionToken, options = {}) {
314
+ const constructorOptions = { ...options, clientSessionToken };
315
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
316
+ throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
317
+ }
318
+ return new _SeamHttpClientSessions(constructorOptions);
319
+ }
320
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
321
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
322
+ const clientOptions = parseOptions({ ...options, publishableKey });
323
+ const client = createClient(clientOptions);
324
+ const clientSessions = _SeamHttpClientSessions.fromClient(client);
325
+ const { token } = await clientSessions.getOrCreate({
326
+ user_identifier_key: userIdentifierKey
327
+ });
328
+ return _SeamHttpClientSessions.fromClientSessionToken(token, options);
329
+ }
330
+ async create(body) {
331
+ const { data } = await this.client.request({
332
+ url: "/client_sessions/create",
333
+ method: "post",
334
+ data: body
335
+ });
336
+ return data.client_session;
337
+ }
338
+ async delete(body) {
339
+ await this.client.request({
340
+ url: "/client_sessions/delete",
341
+ method: "post",
342
+ data: body
343
+ });
344
+ }
345
+ async get(body) {
346
+ const { data } = await this.client.request({
347
+ url: "/client_sessions/get",
348
+ method: "post",
349
+ data: body
350
+ });
351
+ return data.client_session;
352
+ }
353
+ async getOrCreate(body) {
354
+ const { data } = await this.client.request({
355
+ url: "/client_sessions/get_or_create",
356
+ method: "post",
357
+ data: body
358
+ });
359
+ return data.client_session;
360
+ }
361
+ async grantAccess(body) {
362
+ const { data } = await this.client.request({
363
+ url: "/client_sessions/grant_access",
364
+ method: "post",
365
+ data: body
366
+ });
367
+ return data.client_session;
368
+ }
369
+ async list(body) {
370
+ const { data } = await this.client.request({
371
+ url: "/client_sessions/list",
372
+ method: "post",
373
+ data: body
374
+ });
375
+ return data.client_sessions;
376
+ }
377
+ };
157
378
 
158
379
  // src/lib/seam/connect/routes/access-codes-unmanaged.ts
159
380
  var SeamHttpAccessCodesUnmanaged = class _SeamHttpAccessCodesUnmanaged {
160
- constructor(apiKeyOrOptions) {
161
- const options = parseOptions(apiKeyOrOptions);
162
- this.client = createAxiosClient(options);
381
+ constructor(apiKeyOrOptions = {}) {
382
+ const clientOptions = parseOptions(apiKeyOrOptions);
383
+ this.client = createClient(clientOptions);
163
384
  }
164
385
  static fromClient(client, options = {}) {
165
- const opts = { ...options, client };
166
- if (!isSeamHttpOptionsWithClient(opts)) {
386
+ const constructorOptions = { ...options, client };
387
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
167
388
  throw new SeamHttpInvalidOptionsError("Missing client");
168
389
  }
169
- return new _SeamHttpAccessCodesUnmanaged(opts);
390
+ return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
170
391
  }
171
392
  static fromApiKey(apiKey, options = {}) {
172
- const opts = { ...options, apiKey };
173
- if (!isSeamHttpOptionsWithApiKey(opts)) {
393
+ const constructorOptions = { ...options, apiKey };
394
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
174
395
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
175
396
  }
176
- return new _SeamHttpAccessCodesUnmanaged(opts);
397
+ return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
177
398
  }
178
399
  static fromClientSessionToken(clientSessionToken, options = {}) {
179
- const opts = { ...options, clientSessionToken };
180
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
400
+ const constructorOptions = { ...options, clientSessionToken };
401
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
181
402
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
182
403
  }
183
- return new _SeamHttpAccessCodesUnmanaged(opts);
404
+ return new _SeamHttpAccessCodesUnmanaged(constructorOptions);
405
+ }
406
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
407
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
408
+ const clientOptions = parseOptions({ ...options, publishableKey });
409
+ const client = createClient(clientOptions);
410
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
411
+ const { token } = await clientSessions.getOrCreate({
412
+ user_identifier_key: userIdentifierKey
413
+ });
414
+ return _SeamHttpAccessCodesUnmanaged.fromClientSessionToken(token, options);
184
415
  }
185
416
  async convertToManaged(body) {
186
417
  await this.client.request({
@@ -225,30 +456,40 @@ var SeamHttpAccessCodesUnmanaged = class _SeamHttpAccessCodesUnmanaged {
225
456
 
226
457
  // src/lib/seam/connect/routes/access-codes.ts
227
458
  var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
228
- constructor(apiKeyOrOptions) {
229
- const options = parseOptions(apiKeyOrOptions);
230
- this.client = createAxiosClient(options);
459
+ constructor(apiKeyOrOptions = {}) {
460
+ const clientOptions = parseOptions(apiKeyOrOptions);
461
+ this.client = createClient(clientOptions);
231
462
  }
232
463
  static fromClient(client, options = {}) {
233
- const opts = { ...options, client };
234
- if (!isSeamHttpOptionsWithClient(opts)) {
464
+ const constructorOptions = { ...options, client };
465
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
235
466
  throw new SeamHttpInvalidOptionsError("Missing client");
236
467
  }
237
- return new _SeamHttpAccessCodes(opts);
468
+ return new _SeamHttpAccessCodes(constructorOptions);
238
469
  }
239
470
  static fromApiKey(apiKey, options = {}) {
240
- const opts = { ...options, apiKey };
241
- if (!isSeamHttpOptionsWithApiKey(opts)) {
471
+ const constructorOptions = { ...options, apiKey };
472
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
242
473
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
243
474
  }
244
- return new _SeamHttpAccessCodes(opts);
475
+ return new _SeamHttpAccessCodes(constructorOptions);
245
476
  }
246
477
  static fromClientSessionToken(clientSessionToken, options = {}) {
247
- const opts = { ...options, clientSessionToken };
248
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
478
+ const constructorOptions = { ...options, clientSessionToken };
479
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
249
480
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
250
481
  }
251
- return new _SeamHttpAccessCodes(opts);
482
+ return new _SeamHttpAccessCodes(constructorOptions);
483
+ }
484
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
485
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
486
+ const clientOptions = parseOptions({ ...options, publishableKey });
487
+ const client = createClient(clientOptions);
488
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
489
+ const { token } = await clientSessions.getOrCreate({
490
+ user_identifier_key: userIdentifierKey
491
+ });
492
+ return _SeamHttpAccessCodes.fromClientSessionToken(token, options);
252
493
  }
253
494
  get unmanaged() {
254
495
  return SeamHttpAccessCodesUnmanaged.fromClient(this.client);
@@ -276,12 +517,12 @@ var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
276
517
  data: body
277
518
  });
278
519
  }
279
- async generateCode(params) {
520
+ async generateCode(body) {
280
521
  const { data } = await this.client.request(
281
522
  {
282
523
  url: "/access_codes/generate_code",
283
- method: "get",
284
- params
524
+ method: "post",
525
+ data: body
285
526
  }
286
527
  );
287
528
  return data.generated_code;
@@ -321,30 +562,40 @@ var SeamHttpAccessCodes = class _SeamHttpAccessCodes {
321
562
 
322
563
  // src/lib/seam/connect/routes/acs-access-groups.ts
323
564
  var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
324
- constructor(apiKeyOrOptions) {
325
- const options = parseOptions(apiKeyOrOptions);
326
- this.client = createAxiosClient(options);
565
+ constructor(apiKeyOrOptions = {}) {
566
+ const clientOptions = parseOptions(apiKeyOrOptions);
567
+ this.client = createClient(clientOptions);
327
568
  }
328
569
  static fromClient(client, options = {}) {
329
- const opts = { ...options, client };
330
- if (!isSeamHttpOptionsWithClient(opts)) {
570
+ const constructorOptions = { ...options, client };
571
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
331
572
  throw new SeamHttpInvalidOptionsError("Missing client");
332
573
  }
333
- return new _SeamHttpAcsAccessGroups(opts);
574
+ return new _SeamHttpAcsAccessGroups(constructorOptions);
334
575
  }
335
576
  static fromApiKey(apiKey, options = {}) {
336
- const opts = { ...options, apiKey };
337
- if (!isSeamHttpOptionsWithApiKey(opts)) {
577
+ const constructorOptions = { ...options, apiKey };
578
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
338
579
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
339
580
  }
340
- return new _SeamHttpAcsAccessGroups(opts);
581
+ return new _SeamHttpAcsAccessGroups(constructorOptions);
341
582
  }
342
583
  static fromClientSessionToken(clientSessionToken, options = {}) {
343
- const opts = { ...options, clientSessionToken };
344
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
584
+ const constructorOptions = { ...options, clientSessionToken };
585
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
345
586
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
346
587
  }
347
- return new _SeamHttpAcsAccessGroups(opts);
588
+ return new _SeamHttpAcsAccessGroups(constructorOptions);
589
+ }
590
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
591
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
592
+ const clientOptions = parseOptions({ ...options, publishableKey });
593
+ const client = createClient(clientOptions);
594
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
595
+ const { token } = await clientSessions.getOrCreate({
596
+ user_identifier_key: userIdentifierKey
597
+ });
598
+ return _SeamHttpAcsAccessGroups.fromClientSessionToken(token, options);
348
599
  }
349
600
  async addUser(body) {
350
601
  await this.client.request({
@@ -410,30 +661,40 @@ var SeamHttpAcsAccessGroups = class _SeamHttpAcsAccessGroups {
410
661
 
411
662
  // src/lib/seam/connect/routes/acs-credentials.ts
412
663
  var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
413
- constructor(apiKeyOrOptions) {
414
- const options = parseOptions(apiKeyOrOptions);
415
- this.client = createAxiosClient(options);
664
+ constructor(apiKeyOrOptions = {}) {
665
+ const clientOptions = parseOptions(apiKeyOrOptions);
666
+ this.client = createClient(clientOptions);
416
667
  }
417
668
  static fromClient(client, options = {}) {
418
- const opts = { ...options, client };
419
- if (!isSeamHttpOptionsWithClient(opts)) {
669
+ const constructorOptions = { ...options, client };
670
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
420
671
  throw new SeamHttpInvalidOptionsError("Missing client");
421
672
  }
422
- return new _SeamHttpAcsCredentials(opts);
673
+ return new _SeamHttpAcsCredentials(constructorOptions);
423
674
  }
424
675
  static fromApiKey(apiKey, options = {}) {
425
- const opts = { ...options, apiKey };
426
- if (!isSeamHttpOptionsWithApiKey(opts)) {
676
+ const constructorOptions = { ...options, apiKey };
677
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
427
678
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
428
679
  }
429
- return new _SeamHttpAcsCredentials(opts);
680
+ return new _SeamHttpAcsCredentials(constructorOptions);
430
681
  }
431
682
  static fromClientSessionToken(clientSessionToken, options = {}) {
432
- const opts = { ...options, clientSessionToken };
433
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
683
+ const constructorOptions = { ...options, clientSessionToken };
684
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
434
685
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
435
686
  }
436
- return new _SeamHttpAcsCredentials(opts);
687
+ return new _SeamHttpAcsCredentials(constructorOptions);
688
+ }
689
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
690
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
691
+ const clientOptions = parseOptions({ ...options, publishableKey });
692
+ const client = createClient(clientOptions);
693
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
694
+ const { token } = await clientSessions.getOrCreate({
695
+ user_identifier_key: userIdentifierKey
696
+ });
697
+ return _SeamHttpAcsCredentials.fromClientSessionToken(token, options);
437
698
  }
438
699
  async create(body) {
439
700
  const { data } = await this.client.request({
@@ -470,30 +731,40 @@ var SeamHttpAcsCredentials = class _SeamHttpAcsCredentials {
470
731
 
471
732
  // src/lib/seam/connect/routes/acs-systems.ts
472
733
  var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
473
- constructor(apiKeyOrOptions) {
474
- const options = parseOptions(apiKeyOrOptions);
475
- this.client = createAxiosClient(options);
734
+ constructor(apiKeyOrOptions = {}) {
735
+ const clientOptions = parseOptions(apiKeyOrOptions);
736
+ this.client = createClient(clientOptions);
476
737
  }
477
738
  static fromClient(client, options = {}) {
478
- const opts = { ...options, client };
479
- if (!isSeamHttpOptionsWithClient(opts)) {
739
+ const constructorOptions = { ...options, client };
740
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
480
741
  throw new SeamHttpInvalidOptionsError("Missing client");
481
742
  }
482
- return new _SeamHttpAcsSystems(opts);
743
+ return new _SeamHttpAcsSystems(constructorOptions);
483
744
  }
484
745
  static fromApiKey(apiKey, options = {}) {
485
- const opts = { ...options, apiKey };
486
- if (!isSeamHttpOptionsWithApiKey(opts)) {
746
+ const constructorOptions = { ...options, apiKey };
747
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
487
748
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
488
749
  }
489
- return new _SeamHttpAcsSystems(opts);
750
+ return new _SeamHttpAcsSystems(constructorOptions);
490
751
  }
491
752
  static fromClientSessionToken(clientSessionToken, options = {}) {
492
- const opts = { ...options, clientSessionToken };
493
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
753
+ const constructorOptions = { ...options, clientSessionToken };
754
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
494
755
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
495
756
  }
496
- return new _SeamHttpAcsSystems(opts);
757
+ return new _SeamHttpAcsSystems(constructorOptions);
758
+ }
759
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
760
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
761
+ const clientOptions = parseOptions({ ...options, publishableKey });
762
+ const client = createClient(clientOptions);
763
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
764
+ const { token } = await clientSessions.getOrCreate({
765
+ user_identifier_key: userIdentifierKey
766
+ });
767
+ return _SeamHttpAcsSystems.fromClientSessionToken(token, options);
497
768
  }
498
769
  async get(body) {
499
770
  const { data } = await this.client.request({
@@ -503,11 +774,11 @@ var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
503
774
  });
504
775
  return data.acs_system;
505
776
  }
506
- async list(params) {
777
+ async list(body) {
507
778
  const { data } = await this.client.request({
508
779
  url: "/acs/systems/list",
509
- method: "get",
510
- params
780
+ method: "post",
781
+ data: body
511
782
  });
512
783
  return data.acs_systems;
513
784
  }
@@ -515,30 +786,40 @@ var SeamHttpAcsSystems = class _SeamHttpAcsSystems {
515
786
 
516
787
  // src/lib/seam/connect/routes/acs-users.ts
517
788
  var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
518
- constructor(apiKeyOrOptions) {
519
- const options = parseOptions(apiKeyOrOptions);
520
- this.client = createAxiosClient(options);
789
+ constructor(apiKeyOrOptions = {}) {
790
+ const clientOptions = parseOptions(apiKeyOrOptions);
791
+ this.client = createClient(clientOptions);
521
792
  }
522
793
  static fromClient(client, options = {}) {
523
- const opts = { ...options, client };
524
- if (!isSeamHttpOptionsWithClient(opts)) {
794
+ const constructorOptions = { ...options, client };
795
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
525
796
  throw new SeamHttpInvalidOptionsError("Missing client");
526
797
  }
527
- return new _SeamHttpAcsUsers(opts);
798
+ return new _SeamHttpAcsUsers(constructorOptions);
528
799
  }
529
800
  static fromApiKey(apiKey, options = {}) {
530
- const opts = { ...options, apiKey };
531
- if (!isSeamHttpOptionsWithApiKey(opts)) {
801
+ const constructorOptions = { ...options, apiKey };
802
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
532
803
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
533
804
  }
534
- return new _SeamHttpAcsUsers(opts);
805
+ return new _SeamHttpAcsUsers(constructorOptions);
535
806
  }
536
807
  static fromClientSessionToken(clientSessionToken, options = {}) {
537
- const opts = { ...options, clientSessionToken };
538
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
808
+ const constructorOptions = { ...options, clientSessionToken };
809
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
539
810
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
540
811
  }
541
- return new _SeamHttpAcsUsers(opts);
812
+ return new _SeamHttpAcsUsers(constructorOptions);
813
+ }
814
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
815
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
816
+ const clientOptions = parseOptions({ ...options, publishableKey });
817
+ const client = createClient(clientOptions);
818
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
819
+ const { token } = await clientSessions.getOrCreate({
820
+ user_identifier_key: userIdentifierKey
821
+ });
822
+ return _SeamHttpAcsUsers.fromClientSessionToken(token, options);
542
823
  }
543
824
  async addToAccessGroup(body) {
544
825
  await this.client.request({
@@ -585,6 +866,20 @@ var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
585
866
  data: body
586
867
  });
587
868
  }
869
+ async suspend(body) {
870
+ await this.client.request({
871
+ url: "/acs/users/suspend",
872
+ method: "post",
873
+ data: body
874
+ });
875
+ }
876
+ async unsuspend(body) {
877
+ await this.client.request({
878
+ url: "/acs/users/unsuspend",
879
+ method: "post",
880
+ data: body
881
+ });
882
+ }
588
883
  async update(body) {
589
884
  await this.client.request({
590
885
  url: "/acs/users/update",
@@ -596,30 +891,40 @@ var SeamHttpAcsUsers = class _SeamHttpAcsUsers {
596
891
 
597
892
  // src/lib/seam/connect/routes/acs.ts
598
893
  var SeamHttpAcs = class _SeamHttpAcs {
599
- constructor(apiKeyOrOptions) {
600
- const options = parseOptions(apiKeyOrOptions);
601
- this.client = createAxiosClient(options);
894
+ constructor(apiKeyOrOptions = {}) {
895
+ const clientOptions = parseOptions(apiKeyOrOptions);
896
+ this.client = createClient(clientOptions);
602
897
  }
603
898
  static fromClient(client, options = {}) {
604
- const opts = { ...options, client };
605
- if (!isSeamHttpOptionsWithClient(opts)) {
899
+ const constructorOptions = { ...options, client };
900
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
606
901
  throw new SeamHttpInvalidOptionsError("Missing client");
607
902
  }
608
- return new _SeamHttpAcs(opts);
903
+ return new _SeamHttpAcs(constructorOptions);
609
904
  }
610
905
  static fromApiKey(apiKey, options = {}) {
611
- const opts = { ...options, apiKey };
612
- if (!isSeamHttpOptionsWithApiKey(opts)) {
906
+ const constructorOptions = { ...options, apiKey };
907
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
613
908
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
614
909
  }
615
- return new _SeamHttpAcs(opts);
910
+ return new _SeamHttpAcs(constructorOptions);
616
911
  }
617
912
  static fromClientSessionToken(clientSessionToken, options = {}) {
618
- const opts = { ...options, clientSessionToken };
619
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
913
+ const constructorOptions = { ...options, clientSessionToken };
914
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
620
915
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
621
916
  }
622
- return new _SeamHttpAcs(opts);
917
+ return new _SeamHttpAcs(constructorOptions);
918
+ }
919
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
920
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
921
+ const clientOptions = parseOptions({ ...options, publishableKey });
922
+ const client = createClient(clientOptions);
923
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
924
+ const { token } = await clientSessions.getOrCreate({
925
+ user_identifier_key: userIdentifierKey
926
+ });
927
+ return _SeamHttpAcs.fromClientSessionToken(token, options);
623
928
  }
624
929
  get accessGroups() {
625
930
  return SeamHttpAcsAccessGroups.fromClient(this.client);
@@ -637,30 +942,40 @@ var SeamHttpAcs = class _SeamHttpAcs {
637
942
 
638
943
  // src/lib/seam/connect/routes/action-attempts.ts
639
944
  var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
640
- constructor(apiKeyOrOptions) {
641
- const options = parseOptions(apiKeyOrOptions);
642
- this.client = createAxiosClient(options);
945
+ constructor(apiKeyOrOptions = {}) {
946
+ const clientOptions = parseOptions(apiKeyOrOptions);
947
+ this.client = createClient(clientOptions);
643
948
  }
644
949
  static fromClient(client, options = {}) {
645
- const opts = { ...options, client };
646
- if (!isSeamHttpOptionsWithClient(opts)) {
950
+ const constructorOptions = { ...options, client };
951
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
647
952
  throw new SeamHttpInvalidOptionsError("Missing client");
648
953
  }
649
- return new _SeamHttpActionAttempts(opts);
954
+ return new _SeamHttpActionAttempts(constructorOptions);
650
955
  }
651
956
  static fromApiKey(apiKey, options = {}) {
652
- const opts = { ...options, apiKey };
653
- if (!isSeamHttpOptionsWithApiKey(opts)) {
957
+ const constructorOptions = { ...options, apiKey };
958
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
654
959
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
655
960
  }
656
- return new _SeamHttpActionAttempts(opts);
961
+ return new _SeamHttpActionAttempts(constructorOptions);
657
962
  }
658
963
  static fromClientSessionToken(clientSessionToken, options = {}) {
659
- const opts = { ...options, clientSessionToken };
660
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
964
+ const constructorOptions = { ...options, clientSessionToken };
965
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
661
966
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
662
967
  }
663
- return new _SeamHttpActionAttempts(opts);
968
+ return new _SeamHttpActionAttempts(constructorOptions);
969
+ }
970
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
971
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
972
+ const clientOptions = parseOptions({ ...options, publishableKey });
973
+ const client = createClient(clientOptions);
974
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
975
+ const { token } = await clientSessions.getOrCreate({
976
+ user_identifier_key: userIdentifierKey
977
+ });
978
+ return _SeamHttpActionAttempts.fromClientSessionToken(token, options);
664
979
  }
665
980
  async get(body) {
666
981
  const { data } = await this.client.request({
@@ -680,100 +995,42 @@ var SeamHttpActionAttempts = class _SeamHttpActionAttempts {
680
995
  }
681
996
  };
682
997
 
683
- // src/lib/seam/connect/routes/client-sessions.ts
684
- var SeamHttpClientSessions = class _SeamHttpClientSessions {
685
- constructor(apiKeyOrOptions) {
686
- const options = parseOptions(apiKeyOrOptions);
687
- this.client = createAxiosClient(options);
688
- }
689
- static fromClient(client, options = {}) {
690
- const opts = { ...options, client };
691
- if (!isSeamHttpOptionsWithClient(opts)) {
692
- throw new SeamHttpInvalidOptionsError("Missing client");
693
- }
694
- return new _SeamHttpClientSessions(opts);
695
- }
696
- static fromApiKey(apiKey, options = {}) {
697
- const opts = { ...options, apiKey };
698
- if (!isSeamHttpOptionsWithApiKey(opts)) {
699
- throw new SeamHttpInvalidOptionsError("Missing apiKey");
700
- }
701
- return new _SeamHttpClientSessions(opts);
702
- }
703
- static fromClientSessionToken(clientSessionToken, options = {}) {
704
- const opts = { ...options, clientSessionToken };
705
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
706
- throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
707
- }
708
- return new _SeamHttpClientSessions(opts);
709
- }
710
- async create(body) {
711
- const { data } = await this.client.request({
712
- url: "/client_sessions/create",
713
- method: "post",
714
- data: body
715
- });
716
- return data.client_session;
717
- }
718
- async delete(body) {
719
- await this.client.request({
720
- url: "/client_sessions/delete",
721
- method: "post",
722
- data: body
723
- });
724
- }
725
- async get(body) {
726
- const { data } = await this.client.request({
727
- url: "/client_sessions/get",
728
- method: "post",
729
- data: body
730
- });
731
- return data.client_session;
732
- }
733
- async grantAccess(body) {
734
- const { data } = await this.client.request({
735
- url: "/client_sessions/grant_access",
736
- method: "post",
737
- data: body
738
- });
739
- return data.client_session;
740
- }
741
- async list(body) {
742
- const { data } = await this.client.request({
743
- url: "/client_sessions/list",
744
- method: "post",
745
- data: body
746
- });
747
- return data.client_sessions;
748
- }
749
- };
750
-
751
998
  // src/lib/seam/connect/routes/connect-webviews.ts
752
999
  var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
753
- constructor(apiKeyOrOptions) {
754
- const options = parseOptions(apiKeyOrOptions);
755
- this.client = createAxiosClient(options);
1000
+ constructor(apiKeyOrOptions = {}) {
1001
+ const clientOptions = parseOptions(apiKeyOrOptions);
1002
+ this.client = createClient(clientOptions);
756
1003
  }
757
1004
  static fromClient(client, options = {}) {
758
- const opts = { ...options, client };
759
- if (!isSeamHttpOptionsWithClient(opts)) {
1005
+ const constructorOptions = { ...options, client };
1006
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
760
1007
  throw new SeamHttpInvalidOptionsError("Missing client");
761
1008
  }
762
- return new _SeamHttpConnectWebviews(opts);
1009
+ return new _SeamHttpConnectWebviews(constructorOptions);
763
1010
  }
764
1011
  static fromApiKey(apiKey, options = {}) {
765
- const opts = { ...options, apiKey };
766
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1012
+ const constructorOptions = { ...options, apiKey };
1013
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
767
1014
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
768
1015
  }
769
- return new _SeamHttpConnectWebviews(opts);
1016
+ return new _SeamHttpConnectWebviews(constructorOptions);
770
1017
  }
771
1018
  static fromClientSessionToken(clientSessionToken, options = {}) {
772
- const opts = { ...options, clientSessionToken };
773
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1019
+ const constructorOptions = { ...options, clientSessionToken };
1020
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
774
1021
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
775
1022
  }
776
- return new _SeamHttpConnectWebviews(opts);
1023
+ return new _SeamHttpConnectWebviews(constructorOptions);
1024
+ }
1025
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1026
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1027
+ const clientOptions = parseOptions({ ...options, publishableKey });
1028
+ const client = createClient(clientOptions);
1029
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1030
+ const { token } = await clientSessions.getOrCreate({
1031
+ user_identifier_key: userIdentifierKey
1032
+ });
1033
+ return _SeamHttpConnectWebviews.fromClientSessionToken(token, options);
777
1034
  }
778
1035
  async create(body) {
779
1036
  const { data } = await this.client.request({
@@ -798,11 +1055,11 @@ var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
798
1055
  });
799
1056
  return data.connect_webview;
800
1057
  }
801
- async list(params) {
1058
+ async list(body) {
802
1059
  const { data } = await this.client.request({
803
1060
  url: "/connect_webviews/list",
804
- method: "get",
805
- params
1061
+ method: "post",
1062
+ data: body
806
1063
  });
807
1064
  return data.connect_webviews;
808
1065
  }
@@ -817,30 +1074,40 @@ var SeamHttpConnectWebviews = class _SeamHttpConnectWebviews {
817
1074
 
818
1075
  // src/lib/seam/connect/routes/connected-accounts.ts
819
1076
  var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
820
- constructor(apiKeyOrOptions) {
821
- const options = parseOptions(apiKeyOrOptions);
822
- this.client = createAxiosClient(options);
1077
+ constructor(apiKeyOrOptions = {}) {
1078
+ const clientOptions = parseOptions(apiKeyOrOptions);
1079
+ this.client = createClient(clientOptions);
823
1080
  }
824
1081
  static fromClient(client, options = {}) {
825
- const opts = { ...options, client };
826
- if (!isSeamHttpOptionsWithClient(opts)) {
1082
+ const constructorOptions = { ...options, client };
1083
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
827
1084
  throw new SeamHttpInvalidOptionsError("Missing client");
828
1085
  }
829
- return new _SeamHttpConnectedAccounts(opts);
1086
+ return new _SeamHttpConnectedAccounts(constructorOptions);
830
1087
  }
831
1088
  static fromApiKey(apiKey, options = {}) {
832
- const opts = { ...options, apiKey };
833
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1089
+ const constructorOptions = { ...options, apiKey };
1090
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
834
1091
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
835
1092
  }
836
- return new _SeamHttpConnectedAccounts(opts);
1093
+ return new _SeamHttpConnectedAccounts(constructorOptions);
837
1094
  }
838
1095
  static fromClientSessionToken(clientSessionToken, options = {}) {
839
- const opts = { ...options, clientSessionToken };
840
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1096
+ const constructorOptions = { ...options, clientSessionToken };
1097
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
841
1098
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
842
1099
  }
843
- return new _SeamHttpConnectedAccounts(opts);
1100
+ return new _SeamHttpConnectedAccounts(constructorOptions);
1101
+ }
1102
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1103
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1104
+ const clientOptions = parseOptions({ ...options, publishableKey });
1105
+ const client = createClient(clientOptions);
1106
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1107
+ const { token } = await clientSessions.getOrCreate({
1108
+ user_identifier_key: userIdentifierKey
1109
+ });
1110
+ return _SeamHttpConnectedAccounts.fromClientSessionToken(token, options);
844
1111
  }
845
1112
  async delete(body) {
846
1113
  await this.client.request({
@@ -869,30 +1136,40 @@ var SeamHttpConnectedAccounts = class _SeamHttpConnectedAccounts {
869
1136
 
870
1137
  // src/lib/seam/connect/routes/devices-unmanaged.ts
871
1138
  var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
872
- constructor(apiKeyOrOptions) {
873
- const options = parseOptions(apiKeyOrOptions);
874
- this.client = createAxiosClient(options);
1139
+ constructor(apiKeyOrOptions = {}) {
1140
+ const clientOptions = parseOptions(apiKeyOrOptions);
1141
+ this.client = createClient(clientOptions);
875
1142
  }
876
1143
  static fromClient(client, options = {}) {
877
- const opts = { ...options, client };
878
- if (!isSeamHttpOptionsWithClient(opts)) {
1144
+ const constructorOptions = { ...options, client };
1145
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
879
1146
  throw new SeamHttpInvalidOptionsError("Missing client");
880
1147
  }
881
- return new _SeamHttpDevicesUnmanaged(opts);
1148
+ return new _SeamHttpDevicesUnmanaged(constructorOptions);
882
1149
  }
883
1150
  static fromApiKey(apiKey, options = {}) {
884
- const opts = { ...options, apiKey };
885
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1151
+ const constructorOptions = { ...options, apiKey };
1152
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
886
1153
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
887
1154
  }
888
- return new _SeamHttpDevicesUnmanaged(opts);
1155
+ return new _SeamHttpDevicesUnmanaged(constructorOptions);
889
1156
  }
890
1157
  static fromClientSessionToken(clientSessionToken, options = {}) {
891
- const opts = { ...options, clientSessionToken };
892
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1158
+ const constructorOptions = { ...options, clientSessionToken };
1159
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
893
1160
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
894
1161
  }
895
- return new _SeamHttpDevicesUnmanaged(opts);
1162
+ return new _SeamHttpDevicesUnmanaged(constructorOptions);
1163
+ }
1164
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1165
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1166
+ const clientOptions = parseOptions({ ...options, publishableKey });
1167
+ const client = createClient(clientOptions);
1168
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1169
+ const { token } = await clientSessions.getOrCreate({
1170
+ user_identifier_key: userIdentifierKey
1171
+ });
1172
+ return _SeamHttpDevicesUnmanaged.fromClientSessionToken(token, options);
896
1173
  }
897
1174
  async get(body) {
898
1175
  const { data } = await this.client.request({
@@ -921,30 +1198,40 @@ var SeamHttpDevicesUnmanaged = class _SeamHttpDevicesUnmanaged {
921
1198
 
922
1199
  // src/lib/seam/connect/routes/devices.ts
923
1200
  var SeamHttpDevices = class _SeamHttpDevices {
924
- constructor(apiKeyOrOptions) {
925
- const options = parseOptions(apiKeyOrOptions);
926
- this.client = createAxiosClient(options);
1201
+ constructor(apiKeyOrOptions = {}) {
1202
+ const clientOptions = parseOptions(apiKeyOrOptions);
1203
+ this.client = createClient(clientOptions);
927
1204
  }
928
1205
  static fromClient(client, options = {}) {
929
- const opts = { ...options, client };
930
- if (!isSeamHttpOptionsWithClient(opts)) {
1206
+ const constructorOptions = { ...options, client };
1207
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
931
1208
  throw new SeamHttpInvalidOptionsError("Missing client");
932
1209
  }
933
- return new _SeamHttpDevices(opts);
1210
+ return new _SeamHttpDevices(constructorOptions);
934
1211
  }
935
1212
  static fromApiKey(apiKey, options = {}) {
936
- const opts = { ...options, apiKey };
937
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1213
+ const constructorOptions = { ...options, apiKey };
1214
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
938
1215
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
939
1216
  }
940
- return new _SeamHttpDevices(opts);
1217
+ return new _SeamHttpDevices(constructorOptions);
941
1218
  }
942
1219
  static fromClientSessionToken(clientSessionToken, options = {}) {
943
- const opts = { ...options, clientSessionToken };
944
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1220
+ const constructorOptions = { ...options, clientSessionToken };
1221
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
945
1222
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
946
1223
  }
947
- return new _SeamHttpDevices(opts);
1224
+ return new _SeamHttpDevices(constructorOptions);
1225
+ }
1226
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1227
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1228
+ const clientOptions = parseOptions({ ...options, publishableKey });
1229
+ const client = createClient(clientOptions);
1230
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1231
+ const { token } = await clientSessions.getOrCreate({
1232
+ user_identifier_key: userIdentifierKey
1233
+ });
1234
+ return _SeamHttpDevices.fromClientSessionToken(token, options);
948
1235
  }
949
1236
  get unmanaged() {
950
1237
  return SeamHttpDevicesUnmanaged.fromClient(this.client);
@@ -991,30 +1278,40 @@ var SeamHttpDevices = class _SeamHttpDevices {
991
1278
 
992
1279
  // src/lib/seam/connect/routes/events.ts
993
1280
  var SeamHttpEvents = class _SeamHttpEvents {
994
- constructor(apiKeyOrOptions) {
995
- const options = parseOptions(apiKeyOrOptions);
996
- this.client = createAxiosClient(options);
1281
+ constructor(apiKeyOrOptions = {}) {
1282
+ const clientOptions = parseOptions(apiKeyOrOptions);
1283
+ this.client = createClient(clientOptions);
997
1284
  }
998
1285
  static fromClient(client, options = {}) {
999
- const opts = { ...options, client };
1000
- if (!isSeamHttpOptionsWithClient(opts)) {
1286
+ const constructorOptions = { ...options, client };
1287
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1001
1288
  throw new SeamHttpInvalidOptionsError("Missing client");
1002
1289
  }
1003
- return new _SeamHttpEvents(opts);
1290
+ return new _SeamHttpEvents(constructorOptions);
1004
1291
  }
1005
1292
  static fromApiKey(apiKey, options = {}) {
1006
- const opts = { ...options, apiKey };
1007
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1293
+ const constructorOptions = { ...options, apiKey };
1294
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1008
1295
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1009
1296
  }
1010
- return new _SeamHttpEvents(opts);
1297
+ return new _SeamHttpEvents(constructorOptions);
1011
1298
  }
1012
1299
  static fromClientSessionToken(clientSessionToken, options = {}) {
1013
- const opts = { ...options, clientSessionToken };
1014
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1300
+ const constructorOptions = { ...options, clientSessionToken };
1301
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1015
1302
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1016
1303
  }
1017
- return new _SeamHttpEvents(opts);
1304
+ return new _SeamHttpEvents(constructorOptions);
1305
+ }
1306
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1307
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1308
+ const clientOptions = parseOptions({ ...options, publishableKey });
1309
+ const client = createClient(clientOptions);
1310
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1311
+ const { token } = await clientSessions.getOrCreate({
1312
+ user_identifier_key: userIdentifierKey
1313
+ });
1314
+ return _SeamHttpEvents.fromClientSessionToken(token, options);
1018
1315
  }
1019
1316
  async get(body) {
1020
1317
  const { data } = await this.client.request({
@@ -1036,30 +1333,40 @@ var SeamHttpEvents = class _SeamHttpEvents {
1036
1333
 
1037
1334
  // src/lib/seam/connect/routes/locks.ts
1038
1335
  var SeamHttpLocks = class _SeamHttpLocks {
1039
- constructor(apiKeyOrOptions) {
1040
- const options = parseOptions(apiKeyOrOptions);
1041
- this.client = createAxiosClient(options);
1336
+ constructor(apiKeyOrOptions = {}) {
1337
+ const clientOptions = parseOptions(apiKeyOrOptions);
1338
+ this.client = createClient(clientOptions);
1042
1339
  }
1043
1340
  static fromClient(client, options = {}) {
1044
- const opts = { ...options, client };
1045
- if (!isSeamHttpOptionsWithClient(opts)) {
1341
+ const constructorOptions = { ...options, client };
1342
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1046
1343
  throw new SeamHttpInvalidOptionsError("Missing client");
1047
1344
  }
1048
- return new _SeamHttpLocks(opts);
1345
+ return new _SeamHttpLocks(constructorOptions);
1049
1346
  }
1050
1347
  static fromApiKey(apiKey, options = {}) {
1051
- const opts = { ...options, apiKey };
1052
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1348
+ const constructorOptions = { ...options, apiKey };
1349
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1053
1350
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1054
1351
  }
1055
- return new _SeamHttpLocks(opts);
1352
+ return new _SeamHttpLocks(constructorOptions);
1056
1353
  }
1057
1354
  static fromClientSessionToken(clientSessionToken, options = {}) {
1058
- const opts = { ...options, clientSessionToken };
1059
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1355
+ const constructorOptions = { ...options, clientSessionToken };
1356
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1060
1357
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1061
1358
  }
1062
- return new _SeamHttpLocks(opts);
1359
+ return new _SeamHttpLocks(constructorOptions);
1360
+ }
1361
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1362
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1363
+ const clientOptions = parseOptions({ ...options, publishableKey });
1364
+ const client = createClient(clientOptions);
1365
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1366
+ const { token } = await clientSessions.getOrCreate({
1367
+ user_identifier_key: userIdentifierKey
1368
+ });
1369
+ return _SeamHttpLocks.fromClientSessionToken(token, options);
1063
1370
  }
1064
1371
  async get(body) {
1065
1372
  const { data } = await this.client.request({
@@ -1097,30 +1404,43 @@ var SeamHttpLocks = class _SeamHttpLocks {
1097
1404
 
1098
1405
  // src/lib/seam/connect/routes/noise-sensors-noise-thresholds.ts
1099
1406
  var SeamHttpNoiseSensorsNoiseThresholds = class _SeamHttpNoiseSensorsNoiseThresholds {
1100
- constructor(apiKeyOrOptions) {
1101
- const options = parseOptions(apiKeyOrOptions);
1102
- this.client = createAxiosClient(options);
1407
+ constructor(apiKeyOrOptions = {}) {
1408
+ const clientOptions = parseOptions(apiKeyOrOptions);
1409
+ this.client = createClient(clientOptions);
1103
1410
  }
1104
1411
  static fromClient(client, options = {}) {
1105
- const opts = { ...options, client };
1106
- if (!isSeamHttpOptionsWithClient(opts)) {
1412
+ const constructorOptions = { ...options, client };
1413
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1107
1414
  throw new SeamHttpInvalidOptionsError("Missing client");
1108
1415
  }
1109
- return new _SeamHttpNoiseSensorsNoiseThresholds(opts);
1416
+ return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
1110
1417
  }
1111
1418
  static fromApiKey(apiKey, options = {}) {
1112
- const opts = { ...options, apiKey };
1113
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1419
+ const constructorOptions = { ...options, apiKey };
1420
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1114
1421
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1115
1422
  }
1116
- return new _SeamHttpNoiseSensorsNoiseThresholds(opts);
1423
+ return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
1117
1424
  }
1118
1425
  static fromClientSessionToken(clientSessionToken, options = {}) {
1119
- const opts = { ...options, clientSessionToken };
1120
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1426
+ const constructorOptions = { ...options, clientSessionToken };
1427
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1121
1428
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1122
1429
  }
1123
- return new _SeamHttpNoiseSensorsNoiseThresholds(opts);
1430
+ return new _SeamHttpNoiseSensorsNoiseThresholds(constructorOptions);
1431
+ }
1432
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1433
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1434
+ const clientOptions = parseOptions({ ...options, publishableKey });
1435
+ const client = createClient(clientOptions);
1436
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1437
+ const { token } = await clientSessions.getOrCreate({
1438
+ user_identifier_key: userIdentifierKey
1439
+ });
1440
+ return _SeamHttpNoiseSensorsNoiseThresholds.fromClientSessionToken(
1441
+ token,
1442
+ options
1443
+ );
1124
1444
  }
1125
1445
  async create(body) {
1126
1446
  await this.client.request({
@@ -1163,30 +1483,40 @@ var SeamHttpNoiseSensorsNoiseThresholds = class _SeamHttpNoiseSensorsNoiseThresh
1163
1483
 
1164
1484
  // src/lib/seam/connect/routes/noise-sensors.ts
1165
1485
  var SeamHttpNoiseSensors = class _SeamHttpNoiseSensors {
1166
- constructor(apiKeyOrOptions) {
1167
- const options = parseOptions(apiKeyOrOptions);
1168
- this.client = createAxiosClient(options);
1486
+ constructor(apiKeyOrOptions = {}) {
1487
+ const clientOptions = parseOptions(apiKeyOrOptions);
1488
+ this.client = createClient(clientOptions);
1169
1489
  }
1170
1490
  static fromClient(client, options = {}) {
1171
- const opts = { ...options, client };
1172
- if (!isSeamHttpOptionsWithClient(opts)) {
1491
+ const constructorOptions = { ...options, client };
1492
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1173
1493
  throw new SeamHttpInvalidOptionsError("Missing client");
1174
1494
  }
1175
- return new _SeamHttpNoiseSensors(opts);
1495
+ return new _SeamHttpNoiseSensors(constructorOptions);
1176
1496
  }
1177
1497
  static fromApiKey(apiKey, options = {}) {
1178
- const opts = { ...options, apiKey };
1179
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1498
+ const constructorOptions = { ...options, apiKey };
1499
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1180
1500
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1181
1501
  }
1182
- return new _SeamHttpNoiseSensors(opts);
1502
+ return new _SeamHttpNoiseSensors(constructorOptions);
1183
1503
  }
1184
1504
  static fromClientSessionToken(clientSessionToken, options = {}) {
1185
- const opts = { ...options, clientSessionToken };
1186
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1505
+ const constructorOptions = { ...options, clientSessionToken };
1506
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1187
1507
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1188
1508
  }
1189
- return new _SeamHttpNoiseSensors(opts);
1509
+ return new _SeamHttpNoiseSensors(constructorOptions);
1510
+ }
1511
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1512
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1513
+ const clientOptions = parseOptions({ ...options, publishableKey });
1514
+ const client = createClient(clientOptions);
1515
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1516
+ const { token } = await clientSessions.getOrCreate({
1517
+ user_identifier_key: userIdentifierKey
1518
+ });
1519
+ return _SeamHttpNoiseSensors.fromClientSessionToken(token, options);
1190
1520
  }
1191
1521
  get noiseThresholds() {
1192
1522
  return SeamHttpNoiseSensorsNoiseThresholds.fromClient(this.client);
@@ -1195,30 +1525,43 @@ var SeamHttpNoiseSensors = class _SeamHttpNoiseSensors {
1195
1525
 
1196
1526
  // src/lib/seam/connect/routes/thermostats-climate-setting-schedules.ts
1197
1527
  var SeamHttpThermostatsClimateSettingSchedules = class _SeamHttpThermostatsClimateSettingSchedules {
1198
- constructor(apiKeyOrOptions) {
1199
- const options = parseOptions(apiKeyOrOptions);
1200
- this.client = createAxiosClient(options);
1528
+ constructor(apiKeyOrOptions = {}) {
1529
+ const clientOptions = parseOptions(apiKeyOrOptions);
1530
+ this.client = createClient(clientOptions);
1201
1531
  }
1202
1532
  static fromClient(client, options = {}) {
1203
- const opts = { ...options, client };
1204
- if (!isSeamHttpOptionsWithClient(opts)) {
1533
+ const constructorOptions = { ...options, client };
1534
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1205
1535
  throw new SeamHttpInvalidOptionsError("Missing client");
1206
1536
  }
1207
- return new _SeamHttpThermostatsClimateSettingSchedules(opts);
1537
+ return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
1208
1538
  }
1209
1539
  static fromApiKey(apiKey, options = {}) {
1210
- const opts = { ...options, apiKey };
1211
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1540
+ const constructorOptions = { ...options, apiKey };
1541
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1212
1542
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1213
1543
  }
1214
- return new _SeamHttpThermostatsClimateSettingSchedules(opts);
1544
+ return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
1215
1545
  }
1216
1546
  static fromClientSessionToken(clientSessionToken, options = {}) {
1217
- const opts = { ...options, clientSessionToken };
1218
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1547
+ const constructorOptions = { ...options, clientSessionToken };
1548
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1219
1549
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1220
1550
  }
1221
- return new _SeamHttpThermostatsClimateSettingSchedules(opts);
1551
+ return new _SeamHttpThermostatsClimateSettingSchedules(constructorOptions);
1552
+ }
1553
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1554
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1555
+ const clientOptions = parseOptions({ ...options, publishableKey });
1556
+ const client = createClient(clientOptions);
1557
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1558
+ const { token } = await clientSessions.getOrCreate({
1559
+ user_identifier_key: userIdentifierKey
1560
+ });
1561
+ return _SeamHttpThermostatsClimateSettingSchedules.fromClientSessionToken(
1562
+ token,
1563
+ options
1564
+ );
1222
1565
  }
1223
1566
  async create(body) {
1224
1567
  const { data } = await this.client.request(
@@ -1270,30 +1613,40 @@ var SeamHttpThermostatsClimateSettingSchedules = class _SeamHttpThermostatsClima
1270
1613
 
1271
1614
  // src/lib/seam/connect/routes/thermostats.ts
1272
1615
  var SeamHttpThermostats = class _SeamHttpThermostats {
1273
- constructor(apiKeyOrOptions) {
1274
- const options = parseOptions(apiKeyOrOptions);
1275
- this.client = createAxiosClient(options);
1616
+ constructor(apiKeyOrOptions = {}) {
1617
+ const clientOptions = parseOptions(apiKeyOrOptions);
1618
+ this.client = createClient(clientOptions);
1276
1619
  }
1277
1620
  static fromClient(client, options = {}) {
1278
- const opts = { ...options, client };
1279
- if (!isSeamHttpOptionsWithClient(opts)) {
1621
+ const constructorOptions = { ...options, client };
1622
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1280
1623
  throw new SeamHttpInvalidOptionsError("Missing client");
1281
1624
  }
1282
- return new _SeamHttpThermostats(opts);
1625
+ return new _SeamHttpThermostats(constructorOptions);
1283
1626
  }
1284
1627
  static fromApiKey(apiKey, options = {}) {
1285
- const opts = { ...options, apiKey };
1286
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1628
+ const constructorOptions = { ...options, apiKey };
1629
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1287
1630
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1288
1631
  }
1289
- return new _SeamHttpThermostats(opts);
1632
+ return new _SeamHttpThermostats(constructorOptions);
1290
1633
  }
1291
1634
  static fromClientSessionToken(clientSessionToken, options = {}) {
1292
- const opts = { ...options, clientSessionToken };
1293
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1635
+ const constructorOptions = { ...options, clientSessionToken };
1636
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1294
1637
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1295
1638
  }
1296
- return new _SeamHttpThermostats(opts);
1639
+ return new _SeamHttpThermostats(constructorOptions);
1640
+ }
1641
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1642
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1643
+ const clientOptions = parseOptions({ ...options, publishableKey });
1644
+ const client = createClient(clientOptions);
1645
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1646
+ const { token } = await clientSessions.getOrCreate({
1647
+ user_identifier_key: userIdentifierKey
1648
+ });
1649
+ return _SeamHttpThermostats.fromClientSessionToken(token, options);
1297
1650
  }
1298
1651
  get climateSettingSchedules() {
1299
1652
  return SeamHttpThermostatsClimateSettingSchedules.fromClient(this.client);
@@ -1360,30 +1713,40 @@ var SeamHttpThermostats = class _SeamHttpThermostats {
1360
1713
 
1361
1714
  // src/lib/seam/connect/routes/webhooks.ts
1362
1715
  var SeamHttpWebhooks = class _SeamHttpWebhooks {
1363
- constructor(apiKeyOrOptions) {
1364
- const options = parseOptions(apiKeyOrOptions);
1365
- this.client = createAxiosClient(options);
1716
+ constructor(apiKeyOrOptions = {}) {
1717
+ const clientOptions = parseOptions(apiKeyOrOptions);
1718
+ this.client = createClient(clientOptions);
1366
1719
  }
1367
1720
  static fromClient(client, options = {}) {
1368
- const opts = { ...options, client };
1369
- if (!isSeamHttpOptionsWithClient(opts)) {
1721
+ const constructorOptions = { ...options, client };
1722
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1370
1723
  throw new SeamHttpInvalidOptionsError("Missing client");
1371
1724
  }
1372
- return new _SeamHttpWebhooks(opts);
1725
+ return new _SeamHttpWebhooks(constructorOptions);
1373
1726
  }
1374
1727
  static fromApiKey(apiKey, options = {}) {
1375
- const opts = { ...options, apiKey };
1376
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1728
+ const constructorOptions = { ...options, apiKey };
1729
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1377
1730
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1378
1731
  }
1379
- return new _SeamHttpWebhooks(opts);
1732
+ return new _SeamHttpWebhooks(constructorOptions);
1380
1733
  }
1381
1734
  static fromClientSessionToken(clientSessionToken, options = {}) {
1382
- const opts = { ...options, clientSessionToken };
1383
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1735
+ const constructorOptions = { ...options, clientSessionToken };
1736
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1384
1737
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1385
1738
  }
1386
- return new _SeamHttpWebhooks(opts);
1739
+ return new _SeamHttpWebhooks(constructorOptions);
1740
+ }
1741
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1742
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1743
+ const clientOptions = parseOptions({ ...options, publishableKey });
1744
+ const client = createClient(clientOptions);
1745
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1746
+ const { token } = await clientSessions.getOrCreate({
1747
+ user_identifier_key: userIdentifierKey
1748
+ });
1749
+ return _SeamHttpWebhooks.fromClientSessionToken(token, options);
1387
1750
  }
1388
1751
  async create(body) {
1389
1752
  const { data } = await this.client.request({
@@ -1420,30 +1783,40 @@ var SeamHttpWebhooks = class _SeamHttpWebhooks {
1420
1783
 
1421
1784
  // src/lib/seam/connect/routes/workspaces.ts
1422
1785
  var SeamHttpWorkspaces = class _SeamHttpWorkspaces {
1423
- constructor(apiKeyOrOptions) {
1424
- const options = parseOptions(apiKeyOrOptions);
1425
- this.client = createAxiosClient(options);
1786
+ constructor(apiKeyOrOptions = {}) {
1787
+ const clientOptions = parseOptions(apiKeyOrOptions);
1788
+ this.client = createClient(clientOptions);
1426
1789
  }
1427
1790
  static fromClient(client, options = {}) {
1428
- const opts = { ...options, client };
1429
- if (!isSeamHttpOptionsWithClient(opts)) {
1791
+ const constructorOptions = { ...options, client };
1792
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1430
1793
  throw new SeamHttpInvalidOptionsError("Missing client");
1431
1794
  }
1432
- return new _SeamHttpWorkspaces(opts);
1795
+ return new _SeamHttpWorkspaces(constructorOptions);
1433
1796
  }
1434
1797
  static fromApiKey(apiKey, options = {}) {
1435
- const opts = { ...options, apiKey };
1436
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1798
+ const constructorOptions = { ...options, apiKey };
1799
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1437
1800
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1438
1801
  }
1439
- return new _SeamHttpWorkspaces(opts);
1802
+ return new _SeamHttpWorkspaces(constructorOptions);
1440
1803
  }
1441
1804
  static fromClientSessionToken(clientSessionToken, options = {}) {
1442
- const opts = { ...options, clientSessionToken };
1443
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1805
+ const constructorOptions = { ...options, clientSessionToken };
1806
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1444
1807
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1445
1808
  }
1446
- return new _SeamHttpWorkspaces(opts);
1809
+ return new _SeamHttpWorkspaces(constructorOptions);
1810
+ }
1811
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1812
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1813
+ const clientOptions = parseOptions({ ...options, publishableKey });
1814
+ const client = createClient(clientOptions);
1815
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1816
+ const { token } = await clientSessions.getOrCreate({
1817
+ user_identifier_key: userIdentifierKey
1818
+ });
1819
+ return _SeamHttpWorkspaces.fromClientSessionToken(token, options);
1447
1820
  }
1448
1821
  async get(params) {
1449
1822
  const { data } = await this.client.request({
@@ -1470,33 +1843,42 @@ var SeamHttpWorkspaces = class _SeamHttpWorkspaces {
1470
1843
  }
1471
1844
  };
1472
1845
 
1473
- // src/lib/seam/connect/client.ts
1846
+ // src/lib/seam/connect/seam-http.ts
1474
1847
  var SeamHttp = class _SeamHttp {
1475
- // #legacy: boolean
1476
- constructor(apiKeyOrOptions) {
1477
- const options = parseOptions(apiKeyOrOptions);
1478
- this.client = createAxiosClient(options);
1848
+ constructor(apiKeyOrOptions = {}) {
1849
+ const clientOptions = parseOptions(apiKeyOrOptions);
1850
+ this.client = createClient(clientOptions);
1479
1851
  }
1480
1852
  static fromClient(client, options = {}) {
1481
- const opts = { ...options, client };
1482
- if (!isSeamHttpOptionsWithClient(opts)) {
1853
+ const constructorOptions = { ...options, client };
1854
+ if (!isSeamHttpOptionsWithClient(constructorOptions)) {
1483
1855
  throw new SeamHttpInvalidOptionsError("Missing client");
1484
1856
  }
1485
- return new _SeamHttp(opts);
1857
+ return new _SeamHttp(constructorOptions);
1486
1858
  }
1487
1859
  static fromApiKey(apiKey, options = {}) {
1488
- const opts = { ...options, apiKey };
1489
- if (!isSeamHttpOptionsWithApiKey(opts)) {
1860
+ const constructorOptions = { ...options, apiKey };
1861
+ if (!isSeamHttpOptionsWithApiKey(constructorOptions)) {
1490
1862
  throw new SeamHttpInvalidOptionsError("Missing apiKey");
1491
1863
  }
1492
- return new _SeamHttp(opts);
1864
+ return new _SeamHttp(constructorOptions);
1493
1865
  }
1494
1866
  static fromClientSessionToken(clientSessionToken, options = {}) {
1495
- const opts = { ...options, clientSessionToken };
1496
- if (!isSeamHttpOptionsWithClientSessionToken(opts)) {
1867
+ const constructorOptions = { ...options, clientSessionToken };
1868
+ if (!isSeamHttpOptionsWithClientSessionToken(constructorOptions)) {
1497
1869
  throw new SeamHttpInvalidOptionsError("Missing clientSessionToken");
1498
1870
  }
1499
- return new _SeamHttp(opts);
1871
+ return new _SeamHttp(constructorOptions);
1872
+ }
1873
+ static async fromPublishableKey(publishableKey, userIdentifierKey, options = {}) {
1874
+ warnOnInsecureuserIdentifierKey(userIdentifierKey);
1875
+ const clientOptions = parseOptions({ ...options, publishableKey });
1876
+ const client = createClient(clientOptions);
1877
+ const clientSessions = SeamHttpClientSessions.fromClient(client);
1878
+ const { token } = await clientSessions.getOrCreate({
1879
+ user_identifier_key: userIdentifierKey
1880
+ });
1881
+ return _SeamHttp.fromClientSessionToken(token, options);
1500
1882
  }
1501
1883
  get accessCodes() {
1502
1884
  return SeamHttpAccessCodes.fromClient(this.client);
@@ -1540,5 +1922,9 @@ var SeamHttp = class _SeamHttp {
1540
1922
  };
1541
1923
 
1542
1924
  exports.SeamHttp = SeamHttp;
1925
+ exports.SeamHttpInvalidOptionsError = SeamHttpInvalidOptionsError;
1926
+ exports.isSeamHttpOptionsWithApiKey = isSeamHttpOptionsWithApiKey;
1927
+ exports.isSeamHttpOptionsWithClient = isSeamHttpOptionsWithClient;
1928
+ exports.isSeamHttpOptionsWithClientSessionToken = isSeamHttpOptionsWithClientSessionToken;
1543
1929
  //# sourceMappingURL=out.js.map
1544
1930
  //# sourceMappingURL=connect.cjs.map