botshield-sdk 1.2.3 → 1.3.1

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 (93) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +47 -13
  3. package/client.d.mts +23 -5
  4. package/client.d.mts.map +1 -1
  5. package/client.d.ts +23 -5
  6. package/client.d.ts.map +1 -1
  7. package/client.js +26 -17
  8. package/client.js.map +1 -1
  9. package/client.mjs +26 -17
  10. package/client.mjs.map +1 -1
  11. package/internal/utils/query.d.mts +5 -0
  12. package/internal/utils/query.d.mts.map +1 -0
  13. package/internal/utils/query.d.ts +5 -0
  14. package/internal/utils/query.d.ts.map +1 -0
  15. package/internal/utils/query.js +23 -0
  16. package/internal/utils/query.js.map +1 -0
  17. package/internal/utils/query.mjs +20 -0
  18. package/internal/utils/query.mjs.map +1 -0
  19. package/internal/utils.d.mts +1 -0
  20. package/internal/utils.d.ts +1 -0
  21. package/internal/utils.js +1 -0
  22. package/internal/utils.js.map +1 -1
  23. package/internal/utils.mjs +1 -0
  24. package/package.json +7 -1
  25. package/resources/devices.d.mts +3 -0
  26. package/resources/devices.d.mts.map +1 -1
  27. package/resources/devices.d.ts +3 -0
  28. package/resources/devices.d.ts.map +1 -1
  29. package/resources/devices.js +3 -0
  30. package/resources/devices.js.map +1 -1
  31. package/resources/devices.mjs +3 -0
  32. package/resources/devices.mjs.map +1 -1
  33. package/resources/index.d.mts +2 -2
  34. package/resources/index.d.mts.map +1 -1
  35. package/resources/index.d.ts +2 -2
  36. package/resources/index.d.ts.map +1 -1
  37. package/resources/index.js.map +1 -1
  38. package/resources/index.mjs.map +1 -1
  39. package/resources/organizations.d.mts +3 -0
  40. package/resources/organizations.d.mts.map +1 -1
  41. package/resources/organizations.d.ts +3 -0
  42. package/resources/organizations.d.ts.map +1 -1
  43. package/resources/organizations.js +3 -0
  44. package/resources/organizations.js.map +1 -1
  45. package/resources/organizations.mjs +3 -0
  46. package/resources/organizations.mjs.map +1 -1
  47. package/resources/pass.d.mts +3 -0
  48. package/resources/pass.d.mts.map +1 -1
  49. package/resources/pass.d.ts +3 -0
  50. package/resources/pass.d.ts.map +1 -1
  51. package/resources/pass.js +3 -0
  52. package/resources/pass.js.map +1 -1
  53. package/resources/pass.mjs +3 -0
  54. package/resources/pass.mjs.map +1 -1
  55. package/resources/sdk.d.mts +151 -7
  56. package/resources/sdk.d.mts.map +1 -1
  57. package/resources/sdk.d.ts +151 -7
  58. package/resources/sdk.d.ts.map +1 -1
  59. package/resources/sdk.js +20 -3
  60. package/resources/sdk.js.map +1 -1
  61. package/resources/sdk.mjs +20 -3
  62. package/resources/sdk.mjs.map +1 -1
  63. package/resources/users.d.mts +3 -0
  64. package/resources/users.d.mts.map +1 -1
  65. package/resources/users.d.ts +3 -0
  66. package/resources/users.d.ts.map +1 -1
  67. package/resources/users.js +3 -0
  68. package/resources/users.js.map +1 -1
  69. package/resources/users.mjs +3 -0
  70. package/resources/users.mjs.map +1 -1
  71. package/resources/verification.d.mts +68 -7
  72. package/resources/verification.d.mts.map +1 -1
  73. package/resources/verification.d.ts +68 -7
  74. package/resources/verification.d.ts.map +1 -1
  75. package/resources/verification.js +11 -6
  76. package/resources/verification.js.map +1 -1
  77. package/resources/verification.mjs +11 -6
  78. package/resources/verification.mjs.map +1 -1
  79. package/src/client.ts +41 -22
  80. package/src/internal/utils/query.ts +23 -0
  81. package/src/internal/utils.ts +1 -0
  82. package/src/resources/devices.ts +3 -0
  83. package/src/resources/index.ts +6 -0
  84. package/src/resources/organizations.ts +3 -0
  85. package/src/resources/pass.ts +3 -0
  86. package/src/resources/sdk.ts +216 -9
  87. package/src/resources/users.ts +3 -0
  88. package/src/resources/verification.ts +97 -8
  89. package/src/version.ts +1 -1
  90. package/version.d.mts +1 -1
  91. package/version.d.ts +1 -1
  92. package/version.js +1 -1
  93. package/version.mjs +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"verification.d.mts","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,6BAA6B,CAAC;IAI9E;;OAEG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qCAAqC,CAAC;CAG/F;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,OAAO,EACL,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,qCAAqC,IAAI,qCAAqC,GACpF,CAAC;CACH"}
1
+ {"version":3,"file":"verification.d.mts","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB;;GAEG;AACH,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;;OAGG;IACH,SAAS,CACP,KAAK,EAAE,2BAA2B,EAClC,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,6BAA6B,CAAC;IAI5C;;;OAGG;IACH,iBAAiB,CACf,KAAK,EAAE,mCAAmC,EAC1C,OAAO,CAAC,EAAE,cAAc,GACvB,UAAU,CAAC,qCAAqC,CAAC;CAGrD;AAED,MAAM,WAAW,6BAA6B;IAC5C,KAAK,EAAE,OAAO,CAAC;IAEf,MAAM,EAAE,SAAS,GAAG,WAAW,GAAG,SAAS,GAAG,QAAQ,GAAG,WAAW,CAAC;IAErE,SAAS,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;IAElC,UAAU,CAAC,EAAE,MAAM,CAAC;IAEpB,aA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;CACH"}
@@ -1,23 +1,84 @@
1
1
  import { APIResource } from "../core/resource.js";
2
2
  import { APIPromise } from "../core/api-promise.js";
3
3
  import { RequestOptions } from "../internal/request-options.js";
4
+ /**
5
+ * Verification status and lookup
6
+ */
4
7
  export declare class Verification extends APIResource {
5
8
  /**
6
- * Check verification status
9
+ * Poll for the current status of a verification request. Returns the full
10
+ * verification event including token on completion.
7
11
  */
8
- getStatus(options?: RequestOptions): APIPromise<VerificationGetStatusResponse>;
12
+ getStatus(query: VerificationGetStatusParams, options?: RequestOptions): APIPromise<VerificationGetStatusResponse>;
9
13
  /**
10
- * Look up user by email
14
+ * Check whether a user exists in BotShield and has a registered passkey before
15
+ * initiating verification.
11
16
  */
12
- lookupUserByEmail(options?: RequestOptions): APIPromise<VerificationLookupUserByEmailResponse>;
17
+ lookupUserByEmail(query: VerificationLookupUserByEmailParams, options?: RequestOptions): APIPromise<VerificationLookupUserByEmailResponse>;
13
18
  }
14
19
  export interface VerificationGetStatusResponse {
15
- data: unknown;
20
+ found: boolean;
21
+ status: 'pending' | 'completed' | 'expired' | 'failed' | 'not_found';
22
+ auth_mode?: 'email' | 'anonymous';
23
+ created_at?: string;
24
+ error_message?: string;
25
+ expires_at?: string;
26
+ metadata?: {
27
+ [key: string]: unknown;
28
+ };
29
+ organization_id?: string;
30
+ partner_user_id?: string;
31
+ presence_address?: string;
32
+ request_id?: string;
33
+ scope?: string;
34
+ sdk_type?: 'signal' | 'presence';
35
+ /**
36
+ * Signed JWT verification receipt (present when status=completed)
37
+ */
38
+ signed_token?: string;
39
+ user_email?: string;
40
+ /**
41
+ * Legacy alias for signed_token
42
+ */
43
+ verification_token?: string;
44
+ verified_at?: string;
16
45
  }
17
46
  export interface VerificationLookupUserByEmailResponse {
18
- data: unknown;
47
+ data: VerificationLookupUserByEmailResponse.Data;
48
+ }
49
+ export declare namespace VerificationLookupUserByEmailResponse {
50
+ interface Data {
51
+ /**
52
+ * Whether a user with this email exists in Clerk
53
+ */
54
+ found: boolean;
55
+ /**
56
+ * Whether the user has registered passkeys
57
+ */
58
+ has_passkey: boolean;
59
+ /**
60
+ * Whether the user account is active (not banned/deleted)
61
+ */
62
+ is_active: boolean;
63
+ /**
64
+ * Clerk user ID (only present if found)
65
+ */
66
+ clerk_user_id?: string;
67
+ }
68
+ }
69
+ export interface VerificationGetStatusParams {
70
+ /**
71
+ * The verification request ID from create-verification-link
72
+ */
73
+ request_id: string;
74
+ }
75
+ export interface VerificationLookupUserByEmailParams {
76
+ /**
77
+ * The user's email address
78
+ */
79
+ email: string;
19
80
  }
20
81
  export declare namespace Verification {
21
- export { type VerificationGetStatusResponse as VerificationGetStatusResponse, type VerificationLookupUserByEmailResponse as VerificationLookupUserByEmailResponse, };
82
+ export { type VerificationGetStatusResponse as VerificationGetStatusResponse, type VerificationLookupUserByEmailResponse as VerificationLookupUserByEmailResponse, type VerificationGetStatusParams as VerificationGetStatusParams, type VerificationLookupUserByEmailParams as VerificationLookupUserByEmailParams, };
22
83
  }
23
84
  //# sourceMappingURL=verification.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"verification.d.ts","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":"OAEO,EAAE,WAAW,EAAE;OACf,EAAE,UAAU,EAAE;OACd,EAAE,cAAc,EAAE;AAEzB,qBAAa,YAAa,SAAQ,WAAW;IAC3C;;OAEG;IACH,SAAS,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,6BAA6B,CAAC;IAI9E;;OAEG;IACH,iBAAiB,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,UAAU,CAAC,qCAAqC,CAAC;CAG/F;AAED,MAAM,WAAW,6BAA6B;IAC5C,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,OAAO,CAAC;CACf;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,OAAO,EACL,KAAK,6BAA6B,IAAI,6BAA6B,EAC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AAC;IAE5B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qCAAqC;IACpD,IAAI,EAAE,qCAAqC,CAAC,IAAI,CAAC;CAClD;AAED,yBAAiB,qCAAqC,CAAC;IACrD,UAAiB,IAAI;QACnB;;WAEG;QACH,KAAK,EAAE,OAAO,CAAC;QAEf;;WAEG;QACH,WAAW,EAAE,OAAO,CAAC;QAErB;;WAEG;QACH,SAAS,EAAE,OAAO,CAAC;QAEnB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACxB;CACF;AAED,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mCAAmC;IAClD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,CAAC,OAAO,WAAW,YAAY,CAAC;IACpC,OAAO,EACL,KAAK,6BAA6B,IAAI,6BAA6B,EACnE,KAAK,qCAAqC,IAAI,qCAAqC,EACnF,KAAK,2BAA2B,IAAI,2BAA2B,EAC/D,KAAK,mCAAmC,IAAI,mCAAmC,GAChF,CAAC;CACH"}
@@ -3,18 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  exports.Verification = void 0;
5
5
  const resource_1 = require("../core/resource.js");
6
+ /**
7
+ * Verification status and lookup
8
+ */
6
9
  class Verification extends resource_1.APIResource {
7
10
  /**
8
- * Check verification status
11
+ * Poll for the current status of a verification request. Returns the full
12
+ * verification event including token on completion.
9
13
  */
10
- getStatus(options) {
11
- return this._client.get('/verification/status', options);
14
+ getStatus(query, options) {
15
+ return this._client.get('/verification/status', { query, ...options });
12
16
  }
13
17
  /**
14
- * Look up user by email
18
+ * Check whether a user exists in BotShield and has a registered passkey before
19
+ * initiating verification.
15
20
  */
16
- lookupUserByEmail(options) {
17
- return this._client.get('/verification/lookup-user-by-email', options);
21
+ lookupUserByEmail(query, options) {
22
+ return this._client.get('/verification/lookup-user-by-email', { query, ...options });
18
23
  }
19
24
  }
20
25
  exports.Verification = Verification;
@@ -1 +1 @@
1
- {"version":3,"file":"verification.js","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C,MAAa,YAAa,SAAQ,sBAAW;IAC3C;;OAEG;IACH,SAAS,CAAC,OAAwB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,OAAwB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;CACF;AAdD,oCAcC"}
1
+ {"version":3,"file":"verification.js","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;AAEtF,kDAA+C;AAI/C;;GAEG;AACH,MAAa,YAAa,SAAQ,sBAAW;IAC3C;;;OAGG;IACH,SAAS,CACP,KAAkC,EAClC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,iBAAiB,CACf,KAA0C,EAC1C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvF,CAAC;CACF;AAtBD,oCAsBC"}
@@ -1,17 +1,22 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
  import { APIResource } from "../core/resource.mjs";
3
+ /**
4
+ * Verification status and lookup
5
+ */
3
6
  export class Verification extends APIResource {
4
7
  /**
5
- * Check verification status
8
+ * Poll for the current status of a verification request. Returns the full
9
+ * verification event including token on completion.
6
10
  */
7
- getStatus(options) {
8
- return this._client.get('/verification/status', options);
11
+ getStatus(query, options) {
12
+ return this._client.get('/verification/status', { query, ...options });
9
13
  }
10
14
  /**
11
- * Look up user by email
15
+ * Check whether a user exists in BotShield and has a registered passkey before
16
+ * initiating verification.
12
17
  */
13
- lookupUserByEmail(options) {
14
- return this._client.get('/verification/lookup-user-by-email', options);
18
+ lookupUserByEmail(query, options) {
19
+ return this._client.get('/verification/lookup-user-by-email', { query, ...options });
15
20
  }
16
21
  }
17
22
  //# sourceMappingURL=verification.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"verification.mjs","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;OAEG;IACH,SAAS,CAAC,OAAwB;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,OAAO,CAAC,CAAC;IAC3D,CAAC;IAED;;OAEG;IACH,iBAAiB,CAAC,OAAwB;QACxC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,OAAO,CAAC,CAAC;IACzE,CAAC;CACF"}
1
+ {"version":3,"file":"verification.mjs","sourceRoot":"","sources":["../src/resources/verification.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;AAItB;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,WAAW;IAC3C;;;OAGG;IACH,SAAS,CACP,KAAkC,EAClC,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACzE,CAAC;IAED;;;OAGG;IACH,iBAAiB,CACf,KAA0C,EAC1C,OAAwB;QAExB,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACvF,CAAC;CACF"}
package/src/client.ts CHANGED
@@ -11,6 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
+ import { stringifyQuery } from './internal/utils/query';
14
15
  import { VERSION } from './version';
15
16
  import * as Errors from './core/error';
16
17
  import * as Uploads from './core/uploads';
@@ -31,11 +32,17 @@ import {
31
32
  SDKCreateVerificationLinkResponse,
32
33
  SDKLogoutParams,
33
34
  SDKLogoutResponse,
35
+ SDKRevokeVerificationParams,
36
+ SDKRevokeVerificationResponse,
37
+ SDKVerifyTokenParams,
38
+ SDKVerifyTokenResponse,
34
39
  } from './resources/sdk';
35
40
  import { UserUpdateMetadataParams, UserUpdateMetadataResponse, Users } from './resources/users';
36
41
  import {
37
42
  Verification,
43
+ VerificationGetStatusParams,
38
44
  VerificationGetStatusResponse,
45
+ VerificationLookupUserByEmailParams,
39
46
  VerificationLookupUserByEmailResponse,
40
47
  } from './resources/verification';
41
48
  import { type Fetch } from './internal/builtin-types';
@@ -264,21 +271,8 @@ export class BotShield {
264
271
  /**
265
272
  * Basic re-implementation of `qs.stringify` for primitive types.
266
273
  */
267
- protected stringifyQuery(query: Record<string, unknown>): string {
268
- return Object.entries(query)
269
- .filter(([_, value]) => typeof value !== 'undefined')
270
- .map(([key, value]) => {
271
- if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
272
- return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
273
- }
274
- if (value === null) {
275
- return `${encodeURIComponent(key)}=`;
276
- }
277
- throw new Errors.BotShieldError(
278
- `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
279
- );
280
- })
281
- .join('&');
274
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
275
+ return stringifyQuery(query);
282
276
  }
283
277
 
284
278
  private getUserAgent(): string {
@@ -310,12 +304,13 @@ export class BotShield {
310
304
  : new URL(baseURL + (baseURL.endsWith('/') && path.startsWith('/') ? path.slice(1) : path));
311
305
 
312
306
  const defaultQuery = this.defaultQuery();
313
- if (!isEmptyObj(defaultQuery)) {
314
- query = { ...defaultQuery, ...query };
307
+ const pathQuery = Object.fromEntries(url.searchParams);
308
+ if (!isEmptyObj(defaultQuery) || !isEmptyObj(pathQuery)) {
309
+ query = { ...pathQuery, ...defaultQuery, ...query };
315
310
  }
316
311
 
317
312
  if (typeof query === 'object' && query && !Array.isArray(query)) {
318
- url.search = this.stringifyQuery(query as Record<string, unknown>);
313
+ url.search = this.stringifyQuery(query);
319
314
  }
320
315
 
321
316
  return url.toString();
@@ -620,9 +615,9 @@ export class BotShield {
620
615
  }
621
616
  }
622
617
 
623
- // If the API asks us to wait a certain amount of time (and it's a reasonable amount),
624
- // just do what it says, but otherwise calculate a default
625
- if (!(timeoutMillis && 0 <= timeoutMillis && timeoutMillis < 60 * 1000)) {
618
+ // If the API asks us to wait a certain amount of time, just do what it
619
+ // says, but otherwise calculate a default
620
+ if (timeoutMillis === undefined) {
626
621
  const maxRetries = options.maxRetries ?? this.maxRetries;
627
622
  timeoutMillis = this.calculateDefaultRetryTimeoutMillis(retriesRemaining, maxRetries);
628
623
  }
@@ -754,7 +749,7 @@ export class BotShield {
754
749
  ) {
755
750
  return {
756
751
  bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
757
- body: this.stringifyQuery(body as Record<string, unknown>),
752
+ body: this.stringifyQuery(body),
758
753
  };
759
754
  } else {
760
755
  return this.#encoder({ body, headers });
@@ -780,11 +775,29 @@ export class BotShield {
780
775
 
781
776
  static toFile = Uploads.toFile;
782
777
 
778
+ /**
779
+ * SDK integration endpoints
780
+ */
783
781
  sdk: API.SDK = new API.SDK(this);
782
+ /**
783
+ * Verification status and lookup
784
+ */
784
785
  verification: API.Verification = new API.Verification(this);
786
+ /**
787
+ * Pass management
788
+ */
785
789
  pass: API.Pass = new API.Pass(this);
790
+ /**
791
+ * SDK integration endpoints
792
+ */
786
793
  users: API.Users = new API.Users(this);
794
+ /**
795
+ * Device management
796
+ */
787
797
  devices: API.Devices = new API.Devices(this);
798
+ /**
799
+ * SDK integration endpoints
800
+ */
788
801
  organizations: API.Organizations = new API.Organizations(this);
789
802
  }
790
803
 
@@ -803,15 +816,21 @@ export declare namespace BotShield {
803
816
  type SDKCreateSessionResponse as SDKCreateSessionResponse,
804
817
  type SDKCreateVerificationLinkResponse as SDKCreateVerificationLinkResponse,
805
818
  type SDKLogoutResponse as SDKLogoutResponse,
819
+ type SDKRevokeVerificationResponse as SDKRevokeVerificationResponse,
820
+ type SDKVerifyTokenResponse as SDKVerifyTokenResponse,
806
821
  type SDKCreateSessionParams as SDKCreateSessionParams,
807
822
  type SDKCreateVerificationLinkParams as SDKCreateVerificationLinkParams,
808
823
  type SDKLogoutParams as SDKLogoutParams,
824
+ type SDKRevokeVerificationParams as SDKRevokeVerificationParams,
825
+ type SDKVerifyTokenParams as SDKVerifyTokenParams,
809
826
  };
810
827
 
811
828
  export {
812
829
  Verification as Verification,
813
830
  type VerificationGetStatusResponse as VerificationGetStatusResponse,
814
831
  type VerificationLookupUserByEmailResponse as VerificationLookupUserByEmailResponse,
832
+ type VerificationGetStatusParams as VerificationGetStatusParams,
833
+ type VerificationLookupUserByEmailParams as VerificationLookupUserByEmailParams,
815
834
  };
816
835
 
817
836
  export {
@@ -0,0 +1,23 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { BotShieldError } from '../../core/error';
4
+
5
+ /**
6
+ * Basic re-implementation of `qs.stringify` for primitive types.
7
+ */
8
+ export function stringifyQuery(query: object | Record<string, unknown>) {
9
+ return Object.entries(query)
10
+ .filter(([_, value]) => typeof value !== 'undefined')
11
+ .map(([key, value]) => {
12
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
13
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
14
+ }
15
+ if (value === null) {
16
+ return `${encodeURIComponent(key)}=`;
17
+ }
18
+ throw new BotShieldError(
19
+ `Cannot stringify type ${typeof value}; Expected string, number, boolean, or null. If you need to pass nested query parameters, you can manually encode them, e.g. { query: { 'foo[key1]': value1, 'foo[key2]': value2 } }, and please open a GitHub issue requesting better support for your use case.`,
20
+ );
21
+ })
22
+ .join('&');
23
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * Device management
9
+ */
7
10
  export class Devices extends APIResource {
8
11
  /**
9
12
  * Remove device and associated passkeys
@@ -12,13 +12,19 @@ export {
12
12
  type SDKCreateSessionResponse,
13
13
  type SDKCreateVerificationLinkResponse,
14
14
  type SDKLogoutResponse,
15
+ type SDKRevokeVerificationResponse,
16
+ type SDKVerifyTokenResponse,
15
17
  type SDKCreateSessionParams,
16
18
  type SDKCreateVerificationLinkParams,
17
19
  type SDKLogoutParams,
20
+ type SDKRevokeVerificationParams,
21
+ type SDKVerifyTokenParams,
18
22
  } from './sdk';
19
23
  export { Users, type UserUpdateMetadataResponse, type UserUpdateMetadataParams } from './users';
20
24
  export {
21
25
  Verification,
22
26
  type VerificationGetStatusResponse,
23
27
  type VerificationLookupUserByEmailResponse,
28
+ type VerificationGetStatusParams,
29
+ type VerificationLookupUserByEmailParams,
24
30
  } from './verification';
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * SDK integration endpoints
9
+ */
7
10
  export class Organizations extends APIResource {
8
11
  /**
9
12
  * POST /organizations/add-member
@@ -4,6 +4,9 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * Pass management
9
+ */
7
10
  export class Pass extends APIResource {
8
11
  /**
9
12
  * Create a new BotShield pass
@@ -4,9 +4,12 @@ import { APIResource } from '../core/resource';
4
4
  import { APIPromise } from '../core/api-promise';
5
5
  import { RequestOptions } from '../internal/request-options';
6
6
 
7
+ /**
8
+ * SDK integration endpoints
9
+ */
7
10
  export class SDK extends APIResource {
8
11
  /**
9
- * Create a verification session
12
+ * Create an Anchor Grant Window (legacy: session token)
10
13
  */
11
14
  createSession(
12
15
  body: SDKCreateSessionParams,
@@ -16,7 +19,7 @@ export class SDK extends APIResource {
16
19
  }
17
20
 
18
21
  /**
19
- * Create a verification link
22
+ * Create a verification request (scope/action-scoped)
20
23
  */
21
24
  createVerificationLink(
22
25
  body: SDKCreateVerificationLinkParams,
@@ -26,38 +29,242 @@ export class SDK extends APIResource {
26
29
  }
27
30
 
28
31
  /**
29
- * Logout and invalidate a session token
32
+ * Revoke an Anchor Grant Window token (legacy: logout session)
30
33
  */
31
34
  logout(body: SDKLogoutParams, options?: RequestOptions): APIPromise<SDKLogoutResponse> {
32
35
  return this._client.post('/sdk/logout', { body, ...options });
33
36
  }
37
+
38
+ /**
39
+ * Soft-expires an active or pending verification for a given scope and user. Use
40
+ * this when a 409 conflict from create-verification-link indicates an existing
41
+ * pending verification is blocking a new request.
42
+ */
43
+ revokeVerification(
44
+ body: SDKRevokeVerificationParams,
45
+ options?: RequestOptions,
46
+ ): APIPromise<SDKRevokeVerificationResponse> {
47
+ return this._client.post('/sdk/revoke-verification', { body, ...options });
48
+ }
49
+
50
+ /**
51
+ * Validate a verification receipt (JWT) and return its claims
52
+ */
53
+ verifyToken(body: SDKVerifyTokenParams, options?: RequestOptions): APIPromise<SDKVerifyTokenResponse> {
54
+ return this._client.post('/sdk/verify-token', { body, ...options });
55
+ }
34
56
  }
35
57
 
36
58
  export interface SDKCreateSessionResponse {
37
- data: unknown;
59
+ data: SDKCreateSessionResponse.Data;
60
+ }
61
+
62
+ export namespace SDKCreateSessionResponse {
63
+ export interface Data {
64
+ anchor_grant_expires_at: string;
65
+
66
+ anchor_grant_expires_in_seconds: number;
67
+
68
+ /**
69
+ * Canonical grant token (Bearer bss\_\*). Not an auth session.
70
+ */
71
+ anchor_grant_token: string;
72
+
73
+ expires_at: string;
74
+
75
+ expires_in_seconds: number;
76
+
77
+ organization: Data.Organization;
78
+
79
+ /**
80
+ * Legacy alias of anchor_grant_token (kept for backward compatibility).
81
+ */
82
+ session_token: string;
83
+ }
84
+
85
+ export namespace Data {
86
+ export interface Organization {
87
+ /**
88
+ * Clerk Organization ID (partner)
89
+ */
90
+ id: string;
91
+
92
+ environment: string;
93
+ }
94
+ }
38
95
  }
39
96
 
40
97
  export interface SDKCreateVerificationLinkResponse {
41
- data: unknown;
98
+ data: SDKCreateVerificationLinkResponse.Data;
99
+ }
100
+
101
+ export namespace SDKCreateVerificationLinkResponse {
102
+ export interface Data {
103
+ deep_link: string;
104
+
105
+ expires_at: string;
106
+
107
+ organization: Data.Organization;
108
+
109
+ qr_code_url: string;
110
+
111
+ request_id: string;
112
+
113
+ web_url: string;
114
+
115
+ /**
116
+ * Auth mode used for this verification
117
+ */
118
+ auth_mode?: 'email' | 'anonymous';
119
+
120
+ /**
121
+ * Explicit action scope. Evaluated at action time.
122
+ */
123
+ scope?: string;
124
+
125
+ sdk_type?: 'signal' | 'presence';
126
+ }
127
+
128
+ export namespace Data {
129
+ export interface Organization {
130
+ id: string;
131
+ }
132
+ }
42
133
  }
43
134
 
44
135
  export interface SDKLogoutResponse {
45
- data: unknown;
136
+ success: boolean;
137
+
138
+ message?: string;
139
+
140
+ revoked_at?: string;
141
+
142
+ token_found?: boolean;
143
+ }
144
+
145
+ export interface SDKRevokeVerificationResponse {
146
+ data: SDKRevokeVerificationResponse.Data;
46
147
  }
47
148
 
48
- export interface SDKCreateSessionParams {}
149
+ export namespace SDKRevokeVerificationResponse {
150
+ export interface Data {
151
+ /**
152
+ * Number of pending verifications that were revoked
153
+ */
154
+ revoked_count: number;
155
+
156
+ success: boolean;
49
157
 
50
- export interface SDKCreateVerificationLinkParams {}
158
+ message?: string;
159
+ }
160
+ }
161
+
162
+ export interface SDKVerifyTokenResponse {
163
+ claims?: SDKVerifyTokenResponse.Claims;
164
+
165
+ reason?: string;
166
+
167
+ valid?: boolean;
168
+ }
51
169
 
52
- export interface SDKLogoutParams {}
170
+ export namespace SDKVerifyTokenResponse {
171
+ export interface Claims {
172
+ auth_mode?: 'email' | 'anonymous';
173
+
174
+ botshield_user_id?: string;
175
+
176
+ expires_at?: number;
177
+
178
+ issued_at?: number;
179
+
180
+ organization_id?: string;
181
+
182
+ partner_user_id?: string;
183
+
184
+ request_id?: string;
185
+
186
+ timestamp?: string;
187
+
188
+ user_email?: string;
189
+
190
+ verified?: boolean;
191
+ }
192
+ }
193
+
194
+ export interface SDKCreateSessionParams {
195
+ metadata?: { [key: string]: unknown };
196
+
197
+ partner_user_id?: string;
198
+ }
199
+
200
+ export interface SDKCreateVerificationLinkParams {
201
+ /**
202
+ * Returning anonymous user: pass back the botshield_user_id from a previous
203
+ * verification to skip onboarding
204
+ */
205
+ botshield_user_id?: string;
206
+
207
+ metadata?: { [key: string]: unknown };
208
+
209
+ /**
210
+ * Auth mode: email = Clerk OAuth+passkey, anonymous = direct WebAuthn (no PII)
211
+ */
212
+ mode?: 'email' | 'anonymous';
213
+
214
+ return_url?: string;
215
+
216
+ scope?: string;
217
+
218
+ sdk_type?: 'signal' | 'presence';
219
+
220
+ user_email?: string;
221
+
222
+ webhook_url?: string;
223
+ }
224
+
225
+ export interface SDKLogoutParams {
226
+ /**
227
+ * Legacy field name. Provide the anchor grant token (bss\_\*).
228
+ */
229
+ session_token: string;
230
+ }
231
+
232
+ export interface SDKRevokeVerificationParams {
233
+ /**
234
+ * The scope/action name to revoke pending verifications for
235
+ */
236
+ scope: string;
237
+
238
+ /**
239
+ * Partner user ID to match. At least one of user_email or partner_user_id is
240
+ * required.
241
+ */
242
+ partner_user_id?: string;
243
+
244
+ /**
245
+ * User email to match. At least one of user_email or partner_user_id is required.
246
+ */
247
+ user_email?: string;
248
+ }
249
+
250
+ export interface SDKVerifyTokenParams {
251
+ /**
252
+ * The JWT verification receipt to validate
253
+ */
254
+ token: string;
255
+ }
53
256
 
54
257
  export declare namespace SDK {
55
258
  export {
56
259
  type SDKCreateSessionResponse as SDKCreateSessionResponse,
57
260
  type SDKCreateVerificationLinkResponse as SDKCreateVerificationLinkResponse,
58
261
  type SDKLogoutResponse as SDKLogoutResponse,
262
+ type SDKRevokeVerificationResponse as SDKRevokeVerificationResponse,
263
+ type SDKVerifyTokenResponse as SDKVerifyTokenResponse,
59
264
  type SDKCreateSessionParams as SDKCreateSessionParams,
60
265
  type SDKCreateVerificationLinkParams as SDKCreateVerificationLinkParams,
61
266
  type SDKLogoutParams as SDKLogoutParams,
267
+ type SDKRevokeVerificationParams as SDKRevokeVerificationParams,
268
+ type SDKVerifyTokenParams as SDKVerifyTokenParams,
62
269
  };
63
270
  }