@seamapi/http 0.11.1 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -211,6 +211,18 @@ const seam = new SeamHttp({
211
211
  await seam.locks.unlockDoor({ device_id })
212
212
  ```
213
213
 
214
+ If you have already have an action attempt id
215
+ and want to wait for it to resolve, simply use
216
+
217
+ ```ts
218
+ await seam.actionAttempts.get(
219
+ { action_attempt_id },
220
+ {
221
+ waitForActionAttempt: true,
222
+ },
223
+ )
224
+ ```
225
+
214
226
  Using the `waitForActionAttempt` option:
215
227
 
216
228
  - Polls the action attempt up to the `timeout`
package/connect.d.ts CHANGED
@@ -1 +1,2 @@
1
1
  export * from './lib/seam/connect/index.js';
2
+ export * from '@seamapi/url-search-params-serializer';
package/connect.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './lib/seam/connect/index.js';
2
+ export * from '@seamapi/url-search-params-serializer';
2
3
  //# sourceMappingURL=connect.js.map
package/connect.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"connect.js","sourceRoot":"","sources":["src/connect.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA"}
1
+ {"version":3,"file":"connect.js","sourceRoot":"","sources":["src/connect.ts"],"names":[],"mappings":"AAAA,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uCAAuC,CAAA"}
package/dist/connect.cjs CHANGED
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  var axios = require('axios');
4
+ var urlSearchParamsSerializer = require('@seamapi/url-search-params-serializer');
4
5
  var axiosBetterStacktrace = require('axios-better-stacktrace');
5
6
  var axiosRetry = require('axios-retry');
6
7
 
@@ -229,6 +230,21 @@ var SeamHttpInvalidOptionsError = class extends Error {
229
230
  var SeamHttpMultiWorkspaceInvalidOptionsError = class extends SeamHttpInvalidOptionsError {
230
231
  };
231
232
 
233
+ // src/lib/seam/connect/token.ts
234
+ var tokenPrefix = "seam_";
235
+ var accessTokenPrefix = "seam_at";
236
+ var jwtPrefix = "ey";
237
+ var clientSessionTokenPrefix = "seam_cst";
238
+ var publishableKeyTokenPrefix = "seam_pk";
239
+ var isAccessToken = (token) => token.startsWith(accessTokenPrefix);
240
+ var isJwt = (token) => token.startsWith(jwtPrefix);
241
+ var isSeamToken = (token) => token.startsWith(tokenPrefix);
242
+ var isApiKey = (token) => !isClientSessionToken(token) && !isJwt(token) && !isAccessToken(token) && !isPublishableKey(token) && isSeamToken(token);
243
+ var isClientSessionToken = (token) => token.startsWith(clientSessionTokenPrefix);
244
+ var isPublishableKey = (token) => token.startsWith(publishableKeyTokenPrefix);
245
+ var isConsoleSessionToken = (token) => isJwt(token);
246
+ var isPersonalAccessToken = (token) => isAccessToken(token);
247
+
232
248
  // src/lib/seam/connect/auth.ts
233
249
  var getAuthHeaders = (options) => {
234
250
  if ("publishableKey" in options) {
@@ -253,7 +269,8 @@ var getAuthHeaders = (options) => {
253
269
  "clientSessionToken,",
254
270
  "publishableKey,",
255
271
  "consoleSessionToken",
256
- "or personalAccessToken"
272
+ "or personalAccessToken.",
273
+ "Attempted reading configuration from the environment, but the environment variable SEAM_API_KEY is not set."
257
274
  ].join(" ")
258
275
  );
259
276
  };
@@ -420,16 +437,6 @@ var warnOnInsecureuserIdentifierKey = (userIdentifierKey) => {
420
437
  );
421
438
  }
422
439
  };
423
- var tokenPrefix = "seam_";
424
- var accessTokenPrefix = "seam_at";
425
- var jwtPrefix = "ey";
426
- var clientSessionTokenPrefix = "seam_cst";
427
- var publishableKeyTokenPrefix = "seam_pk";
428
- var isClientSessionToken = (token) => token.startsWith(clientSessionTokenPrefix);
429
- var isAccessToken = (token) => token.startsWith(accessTokenPrefix);
430
- var isJwt = (token) => token.startsWith(jwtPrefix);
431
- var isSeamToken = (token) => token.startsWith(tokenPrefix);
432
- var isPublishableKey = (token) => token.startsWith(publishableKeyTokenPrefix);
433
440
  var isEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
434
441
 
435
442
  // src/lib/seam/connect/seam-http-error.ts
@@ -520,55 +527,9 @@ var getRequestId = (err) => {
520
527
  return "";
521
528
  return requestId;
522
529
  };
523
-
524
- // src/lib/params-serializer.ts
525
- var paramsSerializer = (params) => {
526
- const searchParams = new URLSearchParams();
527
- for (const [name, value] of Object.entries(params)) {
528
- if (value == null)
529
- continue;
530
- if (Array.isArray(value)) {
531
- if (value.length === 0)
532
- searchParams.set(name, "");
533
- if (value.length === 1 && value[0] === "") {
534
- throw new UnserializableParamError(
535
- name,
536
- `is a single element array containing the empty string which is unsupported because it serializes to the empty array`
537
- );
538
- }
539
- for (const v of value) {
540
- searchParams.append(name, serialize(name, v));
541
- }
542
- continue;
543
- }
544
- searchParams.set(name, serialize(name, value));
545
- }
546
- searchParams.sort();
547
- return searchParams.toString();
548
- };
549
- var serialize = (k, v) => {
550
- if (typeof v === "string")
551
- return v.toString();
552
- if (typeof v === "number")
553
- return v.toString();
554
- if (typeof v === "bigint")
555
- return v.toString();
556
- if (typeof v === "boolean")
557
- return v.toString();
558
- throw new UnserializableParamError(k, `is a ${typeof v}`);
559
- };
560
- var UnserializableParamError = class extends Error {
561
- constructor(name, message) {
562
- super(`Could not serialize parameter: '${name}' ${message}`);
563
- this.name = this.constructor.name;
564
- Error.captureStackTrace(this, this.constructor);
565
- }
566
- };
567
-
568
- // src/lib/seam/connect/client.ts
569
530
  var createClient = (options) => {
570
531
  const client = axios__default.default.create({
571
- paramsSerializer,
532
+ paramsSerializer: urlSearchParamsSerializer.serializeUrlSearchParams,
572
533
  ...options.axiosOptions
573
534
  });
574
535
  axiosBetterStacktrace__default.default(axios__default.default);
@@ -3349,9 +3310,13 @@ exports.SeamHttpUnauthorizedError = SeamHttpUnauthorizedError;
3349
3310
  exports.SeamHttpUserIdentities = SeamHttpUserIdentities;
3350
3311
  exports.SeamHttpWebhooks = SeamHttpWebhooks;
3351
3312
  exports.SeamHttpWorkspaces = SeamHttpWorkspaces;
3352
- exports.UnserializableParamError = UnserializableParamError;
3353
3313
  exports.errorInterceptor = errorInterceptor;
3354
3314
  exports.getOpenapiSchema = getOpenapiSchema;
3315
+ exports.isApiKey = isApiKey;
3316
+ exports.isClientSessionToken = isClientSessionToken;
3317
+ exports.isConsoleSessionToken = isConsoleSessionToken;
3318
+ exports.isPersonalAccessToken = isPersonalAccessToken;
3319
+ exports.isPublishableKey = isPublishableKey;
3355
3320
  exports.isSeamActionAttemptError = isSeamActionAttemptError;
3356
3321
  exports.isSeamActionAttemptFailedError = isSeamActionAttemptFailedError;
3357
3322
  exports.isSeamActionAttemptTimeoutError = isSeamActionAttemptTimeoutError;
@@ -3366,6 +3331,11 @@ exports.isSeamHttpOptionsWithClientSessionToken = isSeamHttpOptionsWithClientSes
3366
3331
  exports.isSeamHttpOptionsWithConsoleSessionToken = isSeamHttpOptionsWithConsoleSessionToken;
3367
3332
  exports.isSeamHttpOptionsWithPersonalAccessToken = isSeamHttpOptionsWithPersonalAccessToken;
3368
3333
  exports.isSeamHttpUnauthorizedError = isSeamHttpUnauthorizedError;
3369
- exports.paramsSerializer = paramsSerializer;
3334
+ Object.keys(urlSearchParamsSerializer).forEach(function (k) {
3335
+ if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
3336
+ enumerable: true,
3337
+ get: function () { return urlSearchParamsSerializer[k]; }
3338
+ });
3339
+ });
3370
3340
  //# sourceMappingURL=out.js.map
3371
3341
  //# sourceMappingURL=connect.cjs.map