botshield-sdk 4.0.0 → 4.0.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 (203) hide show
  1. package/README.md +14 -0
  2. package/bin/mcp-server.js +385 -14
  3. package/bin/mcp-server.js.map +22 -18
  4. package/dist/commonjs/funcs/census-verify-token.d.ts +1 -1
  5. package/dist/commonjs/funcs/census-verify-token.js +1 -1
  6. package/dist/commonjs/funcs/recovery-exchange.d.ts +18 -0
  7. package/dist/commonjs/funcs/recovery-exchange.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/recovery-exchange.js +123 -0
  9. package/dist/commonjs/funcs/recovery-exchange.js.map +1 -0
  10. package/dist/commonjs/funcs/recovery-other-route.d.ts +18 -0
  11. package/dist/commonjs/funcs/recovery-other-route.d.ts.map +1 -0
  12. package/dist/commonjs/funcs/recovery-other-route.js +123 -0
  13. package/dist/commonjs/funcs/recovery-other-route.js.map +1 -0
  14. package/dist/commonjs/funcs/sign-in-confirm.d.ts +18 -0
  15. package/dist/commonjs/funcs/sign-in-confirm.d.ts.map +1 -0
  16. package/dist/commonjs/funcs/sign-in-confirm.js +123 -0
  17. package/dist/commonjs/funcs/sign-in-confirm.js.map +1 -0
  18. package/dist/commonjs/funcs/sign-in-request.d.ts +18 -0
  19. package/dist/commonjs/funcs/sign-in-request.d.ts.map +1 -0
  20. package/dist/commonjs/funcs/sign-in-request.js +123 -0
  21. package/dist/commonjs/funcs/sign-in-request.js.map +1 -0
  22. package/dist/commonjs/funcs/verification-get-status.d.ts +1 -1
  23. package/dist/commonjs/funcs/verification-get-status.js +2 -1
  24. package/dist/commonjs/funcs/verification-get-status.js.map +1 -1
  25. package/dist/commonjs/lib/config.d.ts +2 -2
  26. package/dist/commonjs/lib/config.js +2 -2
  27. package/dist/commonjs/mcp-server/mcp-server.js +1 -1
  28. package/dist/commonjs/mcp-server/server.js +1 -1
  29. package/dist/commonjs/models/bot-shield-action.d.ts +36 -0
  30. package/dist/commonjs/models/bot-shield-action.d.ts.map +1 -1
  31. package/dist/commonjs/models/bot-shield-action.js +28 -1
  32. package/dist/commonjs/models/bot-shield-action.js.map +1 -1
  33. package/dist/commonjs/models/error-body.d.ts +1 -1
  34. package/dist/commonjs/models/operations/gates-api-actions-create.d.ts +1 -1
  35. package/dist/commonjs/models/operations/gates-api-actions-list.d.ts +1 -1
  36. package/dist/commonjs/models/operations/gates-api-actions-request.d.ts +1 -1
  37. package/dist/commonjs/models/operations/gates-api-actions-set-state.d.ts +1 -1
  38. package/dist/commonjs/models/operations/gates-api-actions-update.d.ts +1 -1
  39. package/dist/commonjs/models/operations/index.d.ts +4 -0
  40. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  41. package/dist/commonjs/models/operations/index.js +4 -0
  42. package/dist/commonjs/models/operations/index.js.map +1 -1
  43. package/dist/commonjs/models/operations/recovery-exchange.d.ts +114 -0
  44. package/dist/commonjs/models/operations/recovery-exchange.d.ts.map +1 -0
  45. package/dist/commonjs/models/operations/recovery-exchange.js +164 -0
  46. package/dist/commonjs/models/operations/recovery-exchange.js.map +1 -0
  47. package/dist/commonjs/models/operations/recovery-other-route.d.ts +86 -0
  48. package/dist/commonjs/models/operations/recovery-other-route.d.ts.map +1 -0
  49. package/dist/commonjs/models/operations/recovery-other-route.js +145 -0
  50. package/dist/commonjs/models/operations/recovery-other-route.js.map +1 -0
  51. package/dist/commonjs/models/operations/sdk-create-verification-link.d.ts +6 -1
  52. package/dist/commonjs/models/operations/sdk-create-verification-link.d.ts.map +1 -1
  53. package/dist/commonjs/models/operations/sdk-create-verification-link.js +4 -0
  54. package/dist/commonjs/models/operations/sdk-create-verification-link.js.map +1 -1
  55. package/dist/commonjs/models/operations/sdk-send-by-number.d.ts +1 -1
  56. package/dist/commonjs/models/operations/sdk-verify-token.d.ts +15 -0
  57. package/dist/commonjs/models/operations/sdk-verify-token.d.ts.map +1 -1
  58. package/dist/commonjs/models/operations/sdk-verify-token.js +10 -0
  59. package/dist/commonjs/models/operations/sdk-verify-token.js.map +1 -1
  60. package/dist/commonjs/models/operations/signin-confirm.d.ts +148 -0
  61. package/dist/commonjs/models/operations/signin-confirm.d.ts.map +1 -0
  62. package/dist/commonjs/models/operations/signin-confirm.js +202 -0
  63. package/dist/commonjs/models/operations/signin-confirm.js.map +1 -0
  64. package/dist/commonjs/models/operations/signin-request.d.ts +115 -0
  65. package/dist/commonjs/models/operations/signin-request.d.ts.map +1 -0
  66. package/dist/commonjs/models/operations/signin-request.js +174 -0
  67. package/dist/commonjs/models/operations/signin-request.js.map +1 -0
  68. package/dist/commonjs/models/operations/verification-get-status.d.ts +5 -0
  69. package/dist/commonjs/models/operations/verification-get-status.d.ts.map +1 -1
  70. package/dist/commonjs/models/operations/verification-get-status.js +4 -0
  71. package/dist/commonjs/models/operations/verification-get-status.js.map +1 -1
  72. package/dist/commonjs/sdk/census.d.ts +1 -1
  73. package/dist/commonjs/sdk/census.js +1 -1
  74. package/dist/commonjs/sdk/recovery.d.ts +19 -0
  75. package/dist/commonjs/sdk/recovery.d.ts.map +1 -0
  76. package/dist/commonjs/sdk/recovery.js +32 -0
  77. package/dist/commonjs/sdk/recovery.js.map +1 -0
  78. package/dist/commonjs/sdk/sdk.d.ts +6 -0
  79. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  80. package/dist/commonjs/sdk/sdk.js +10 -0
  81. package/dist/commonjs/sdk/sdk.js.map +1 -1
  82. package/dist/commonjs/sdk/sign-in.d.ts +19 -0
  83. package/dist/commonjs/sdk/sign-in.d.ts.map +1 -0
  84. package/dist/commonjs/sdk/sign-in.js +32 -0
  85. package/dist/commonjs/sdk/sign-in.js.map +1 -0
  86. package/dist/commonjs/sdk/verification.d.ts +1 -1
  87. package/dist/commonjs/sdk/verification.js +1 -1
  88. package/dist/esm/funcs/census-verify-token.d.ts +1 -1
  89. package/dist/esm/funcs/census-verify-token.js +1 -1
  90. package/dist/esm/funcs/recovery-exchange.d.ts +18 -0
  91. package/dist/esm/funcs/recovery-exchange.d.ts.map +1 -0
  92. package/dist/esm/funcs/recovery-exchange.js +87 -0
  93. package/dist/esm/funcs/recovery-exchange.js.map +1 -0
  94. package/dist/esm/funcs/recovery-other-route.d.ts +18 -0
  95. package/dist/esm/funcs/recovery-other-route.d.ts.map +1 -0
  96. package/dist/esm/funcs/recovery-other-route.js +87 -0
  97. package/dist/esm/funcs/recovery-other-route.js.map +1 -0
  98. package/dist/esm/funcs/sign-in-confirm.d.ts +18 -0
  99. package/dist/esm/funcs/sign-in-confirm.d.ts.map +1 -0
  100. package/dist/esm/funcs/sign-in-confirm.js +87 -0
  101. package/dist/esm/funcs/sign-in-confirm.js.map +1 -0
  102. package/dist/esm/funcs/sign-in-request.d.ts +18 -0
  103. package/dist/esm/funcs/sign-in-request.d.ts.map +1 -0
  104. package/dist/esm/funcs/sign-in-request.js +87 -0
  105. package/dist/esm/funcs/sign-in-request.js.map +1 -0
  106. package/dist/esm/funcs/verification-get-status.d.ts +1 -1
  107. package/dist/esm/funcs/verification-get-status.js +3 -2
  108. package/dist/esm/funcs/verification-get-status.js.map +1 -1
  109. package/dist/esm/lib/config.d.ts +2 -2
  110. package/dist/esm/lib/config.js +2 -2
  111. package/dist/esm/mcp-server/mcp-server.js +1 -1
  112. package/dist/esm/mcp-server/server.js +1 -1
  113. package/dist/esm/models/bot-shield-action.d.ts +36 -0
  114. package/dist/esm/models/bot-shield-action.d.ts.map +1 -1
  115. package/dist/esm/models/bot-shield-action.js +27 -0
  116. package/dist/esm/models/bot-shield-action.js.map +1 -1
  117. package/dist/esm/models/error-body.d.ts +1 -1
  118. package/dist/esm/models/operations/gates-api-actions-create.d.ts +1 -1
  119. package/dist/esm/models/operations/gates-api-actions-list.d.ts +1 -1
  120. package/dist/esm/models/operations/gates-api-actions-request.d.ts +1 -1
  121. package/dist/esm/models/operations/gates-api-actions-set-state.d.ts +1 -1
  122. package/dist/esm/models/operations/gates-api-actions-update.d.ts +1 -1
  123. package/dist/esm/models/operations/index.d.ts +4 -0
  124. package/dist/esm/models/operations/index.d.ts.map +1 -1
  125. package/dist/esm/models/operations/index.js +4 -0
  126. package/dist/esm/models/operations/index.js.map +1 -1
  127. package/dist/esm/models/operations/recovery-exchange.d.ts +114 -0
  128. package/dist/esm/models/operations/recovery-exchange.d.ts.map +1 -0
  129. package/dist/esm/models/operations/recovery-exchange.js +118 -0
  130. package/dist/esm/models/operations/recovery-exchange.js.map +1 -0
  131. package/dist/esm/models/operations/recovery-other-route.d.ts +86 -0
  132. package/dist/esm/models/operations/recovery-other-route.d.ts.map +1 -0
  133. package/dist/esm/models/operations/recovery-other-route.js +99 -0
  134. package/dist/esm/models/operations/recovery-other-route.js.map +1 -0
  135. package/dist/esm/models/operations/sdk-create-verification-link.d.ts +6 -1
  136. package/dist/esm/models/operations/sdk-create-verification-link.d.ts.map +1 -1
  137. package/dist/esm/models/operations/sdk-create-verification-link.js +4 -0
  138. package/dist/esm/models/operations/sdk-create-verification-link.js.map +1 -1
  139. package/dist/esm/models/operations/sdk-send-by-number.d.ts +1 -1
  140. package/dist/esm/models/operations/sdk-verify-token.d.ts +15 -0
  141. package/dist/esm/models/operations/sdk-verify-token.d.ts.map +1 -1
  142. package/dist/esm/models/operations/sdk-verify-token.js +10 -0
  143. package/dist/esm/models/operations/sdk-verify-token.js.map +1 -1
  144. package/dist/esm/models/operations/signin-confirm.d.ts +148 -0
  145. package/dist/esm/models/operations/signin-confirm.d.ts.map +1 -0
  146. package/dist/esm/models/operations/signin-confirm.js +156 -0
  147. package/dist/esm/models/operations/signin-confirm.js.map +1 -0
  148. package/dist/esm/models/operations/signin-request.d.ts +115 -0
  149. package/dist/esm/models/operations/signin-request.d.ts.map +1 -0
  150. package/dist/esm/models/operations/signin-request.js +128 -0
  151. package/dist/esm/models/operations/signin-request.js.map +1 -0
  152. package/dist/esm/models/operations/verification-get-status.d.ts +5 -0
  153. package/dist/esm/models/operations/verification-get-status.d.ts.map +1 -1
  154. package/dist/esm/models/operations/verification-get-status.js +4 -0
  155. package/dist/esm/models/operations/verification-get-status.js.map +1 -1
  156. package/dist/esm/sdk/census.d.ts +1 -1
  157. package/dist/esm/sdk/census.js +1 -1
  158. package/dist/esm/sdk/recovery.d.ts +19 -0
  159. package/dist/esm/sdk/recovery.d.ts.map +1 -0
  160. package/dist/esm/sdk/recovery.js +28 -0
  161. package/dist/esm/sdk/recovery.js.map +1 -0
  162. package/dist/esm/sdk/sdk.d.ts +6 -0
  163. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  164. package/dist/esm/sdk/sdk.js +10 -0
  165. package/dist/esm/sdk/sdk.js.map +1 -1
  166. package/dist/esm/sdk/sign-in.d.ts +19 -0
  167. package/dist/esm/sdk/sign-in.d.ts.map +1 -0
  168. package/dist/esm/sdk/sign-in.js +28 -0
  169. package/dist/esm/sdk/sign-in.js.map +1 -0
  170. package/dist/esm/sdk/verification.d.ts +1 -1
  171. package/dist/esm/sdk/verification.js +1 -1
  172. package/jsr.json +1 -1
  173. package/package.json +1 -1
  174. package/src/funcs/census-verify-token.ts +1 -1
  175. package/src/funcs/recovery-exchange.ts +184 -0
  176. package/src/funcs/recovery-other-route.ts +184 -0
  177. package/src/funcs/sign-in-confirm.ts +184 -0
  178. package/src/funcs/sign-in-request.ts +184 -0
  179. package/src/funcs/verification-get-status.ts +7 -2
  180. package/src/lib/config.ts +2 -2
  181. package/src/mcp-server/mcp-server.ts +1 -1
  182. package/src/mcp-server/server.ts +1 -1
  183. package/src/models/bot-shield-action.ts +61 -0
  184. package/src/models/error-body.ts +1 -1
  185. package/src/models/operations/gates-api-actions-create.ts +1 -1
  186. package/src/models/operations/gates-api-actions-list.ts +1 -1
  187. package/src/models/operations/gates-api-actions-request.ts +1 -1
  188. package/src/models/operations/gates-api-actions-set-state.ts +1 -1
  189. package/src/models/operations/gates-api-actions-update.ts +1 -1
  190. package/src/models/operations/index.ts +4 -0
  191. package/src/models/operations/recovery-exchange.ts +308 -0
  192. package/src/models/operations/recovery-other-route.ts +262 -0
  193. package/src/models/operations/sdk-create-verification-link.ts +10 -1
  194. package/src/models/operations/sdk-send-by-number.ts +1 -1
  195. package/src/models/operations/sdk-verify-token.ts +25 -0
  196. package/src/models/operations/signin-confirm.ts +383 -0
  197. package/src/models/operations/signin-request.ts +319 -0
  198. package/src/models/operations/verification-get-status.ts +9 -0
  199. package/src/sdk/census.ts +1 -1
  200. package/src/sdk/recovery.ts +49 -0
  201. package/src/sdk/sdk.ts +12 -0
  202. package/src/sdk/sign-in.ts +49 -0
  203. package/src/sdk/verification.ts +1 -1
@@ -0,0 +1,28 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+ import { signInConfirm } from "../funcs/sign-in-confirm.js";
5
+ import { signInRequest } from "../funcs/sign-in-request.js";
6
+ import { ClientSDK } from "../lib/sdks.js";
7
+ import { unwrapAsync } from "../types/fp.js";
8
+ export class SignIn extends ClientSDK {
9
+ /**
10
+ * Ask for a passkey sign-in
11
+ *
12
+ * @remarks
13
+ * Your SERVER asks for a sign-in for ONE of your accounts, after the password has passed or after the customer named their account. Hand the page only `request_id`. Answers only for an account that is already an active verified account here; otherwise `not_verified`, nothing is started, and you do not show the button. It never links an account. A paused account is refused (`account_paused`). The request lives 2 minutes. Needs a live Sign-on Action with your sign-in page's address (BotShield Console › Verified Accounts › BotShield Actions).
14
+ */
15
+ async request(security, request, options) {
16
+ return unwrapAsync(signInRequest(this, security, request, options));
17
+ }
18
+ /**
19
+ * Redeem a passkey sign-in
20
+ *
21
+ * @remarks
22
+ * Your SERVER redeems a sign-in with your secret key and the `request_id` IT made for this attempt: once, within 2 minutes of the passkey. The page's message from the frame is only a cue to call this. Send `partner_user_ref` to have a sign-in for any other account refused. The sign-in's token is not checked with verify-token (which refuses it), and verification/status never returns it.
23
+ */
24
+ async confirm(security, request, options) {
25
+ return unwrapAsync(signInConfirm(this, security, request, options));
26
+ }
27
+ }
28
+ //# sourceMappingURL=sign-in.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sign-in.js","sourceRoot":"","sources":["../../../src/sdk/sign-in.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,OAAO,MAAO,SAAQ,SAAS;IACnC;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CACX,QAA0C,EAC1C,OAAwC,EACxC,OAAwB,EACmB;QAC3C,OAAO,WAAW,CAAC,aAAa,CAC9B,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IAAA,CACJ;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CACX,QAA0C,EAC1C,OAAwC,EACxC,OAAwB,EACmB;QAC3C,OAAO,WAAW,CAAC,aAAa,CAC9B,IAAI,EACJ,QAAQ,EACR,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IAAA,CACJ;CACF"}
@@ -5,7 +5,7 @@ export declare class Verification extends ClientSDK {
5
5
  * Check verification status
6
6
  *
7
7
  * @remarks
8
- * Poll a verification request. Carries the signed attestation on completion and NO identity — no user_email, partner_user_id, auth_mode, or botshield_user_id ever cross this boundary. Called without a key, it is rate-limited per client address (a page polling every 2 seconds stays well inside it); over the limit the call is refused with HTTP 403 and `errors[0].code = "RATE_LIMITED"`.
8
+ * Poll a verification request. Carries the signed attestation on completion and NO identity — no user_email, partner_user_id, auth_mode, or botshield_user_id ever cross this boundary. Called without a key, it is rate-limited per client address (a page polling every 2 seconds stays well inside it); over the limit the call is refused with HTTP 403 and `errors[0].code = "RATE_LIMITED"`. 4.0: knowing the request id is not enough to read the finished tokens. A request started with a site key returns them only with its `read_secret` (`X-BotShield-Request-Secret`); a request your server started, only to your secret key. A passkey sign-in's tokens are never returned here.
9
9
  */
10
10
  getStatus(security: operations.VerificationGetStatusSecurity, request: operations.VerificationGetStatusRequest, options?: RequestOptions): Promise<operations.VerificationGetStatusResponse>;
11
11
  }
@@ -9,7 +9,7 @@ export class Verification extends ClientSDK {
9
9
  * Check verification status
10
10
  *
11
11
  * @remarks
12
- * Poll a verification request. Carries the signed attestation on completion and NO identity — no user_email, partner_user_id, auth_mode, or botshield_user_id ever cross this boundary. Called without a key, it is rate-limited per client address (a page polling every 2 seconds stays well inside it); over the limit the call is refused with HTTP 403 and `errors[0].code = "RATE_LIMITED"`.
12
+ * Poll a verification request. Carries the signed attestation on completion and NO identity — no user_email, partner_user_id, auth_mode, or botshield_user_id ever cross this boundary. Called without a key, it is rate-limited per client address (a page polling every 2 seconds stays well inside it); over the limit the call is refused with HTTP 403 and `errors[0].code = "RATE_LIMITED"`. 4.0: knowing the request id is not enough to read the finished tokens. A request started with a site key returns them only with its `read_secret` (`X-BotShield-Request-Secret`); a request your server started, only to your secret key. A passkey sign-in's tokens are never returned here.
13
13
  */
14
14
  async getStatus(security, request, options) {
15
15
  return unwrapAsync(verificationGetStatus(this, security, request, options));
package/jsr.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  {
4
4
  "name": "botshield-sdk",
5
- "version": "4.0.0",
5
+ "version": "4.0.1",
6
6
  "exports": {
7
7
  ".": "./src/index.ts",
8
8
  "./models/errors": "./src/models/errors/index.ts",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "botshield-sdk",
3
- "version": "4.0.0",
3
+ "version": "4.0.1",
4
4
  "author": "BotShield",
5
5
  "description": "Official TypeScript SDK for BotShield — privacy-first human verification (passkeys, no PII) and Agents Ask approvals",
6
6
  "homepage": "https://docs.botshield.ai",
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
30
30
  * Validate a verification token
31
31
  *
32
32
  * @remarks
33
- * Validates a BotShield attestation JWT — the primary server-side check. Attestations are ES256-signed; the public key is published at /.well-known/jwks.json (kid in the header), so you may also verify locally with any JWT library. Claims are anonymous by construction: the token attests the event, never the person. Each attestation is for one organization (aud = its organization_id; pass `audience` to enforce it) and one check: a repeat check is refused (`valid: false`, `replayed: true`). Check it once, on your server. Each token names its `kind` (`verification` or `action`) and the `environment` it was issued in. A token of any other kind is refused, and when you call with your secret key (`Authorization: Bearer bs_…`) a token from the other environment is refused (a development token never passes a production check). A refused token is not spent.
33
+ * Validates a BotShield attestation JWT — the primary server-side check. Attestations are ES256-signed; the public key is published at /.well-known/jwks.json (kid in the header), so you may also verify locally with any JWT library. Claims are anonymous by construction: the token attests the event, never the person. Each attestation is for one organization (aud = its organization_id; pass `audience` to enforce it) and one check: a repeat check is refused (`valid: false`, `replayed: true`). Check it once, on your server. Each token names its `kind` (`verification` or `action`) and the `environment` it was issued in. A token of any other kind is refused, and when you call with your secret key (`Authorization: Bearer bs_…`) a token from the other environment is refused (a development token never passes a production check). A refused token is not spent. 4.0: the check needs your secret key (`Authorization: Bearer bs_…`); without it the answer is `valid: false, code: secret_key_required` and the token is not spent. Send `expected_request_id` (the request your server made) and a token for any other request is refused (`code: request_mismatch`), unspent. A passkey sign-in's token is refused here: redeem a sign-in with signin/confirm.
34
34
  */
35
35
  export function censusVerifyToken(
36
36
  client: BotShieldCore,
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { BotShieldCore } from "../core.js";
6
+ import { encodeJSON } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { resolveSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import { BotShieldError } from "../models/errors/bot-shield-error.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/http-client-errors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
24
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Redeem a recovery code
31
+ *
32
+ * @remarks
33
+ * Your landing page received `?botshield_recovery_code=…` from the BotShield app. Your SERVER sends the code, your secret key, and the secret it set in that browser's cookie before the tap (the button carried its challenge: SHA-256 of the secret, base64url). BotShield answers only when the secret matches. The first call destroys the code whether or not it matched, so a landing page with no secret must still call this. A second call, a call after 2 minutes, a call with another company's key or the wrong secret all read the same: `recovery_code_invalid`. On success, sign the customer in to the account named by `handle` (the per-company handle given when the account was verified, as on `account.secured`); BotShield tells the person and sends `account.recovered` to your webhook endpoints.
34
+ */
35
+ export function recoveryExchange(
36
+ client: BotShieldCore,
37
+ security: operations.RecoveryExchangeSecurity,
38
+ request: operations.RecoveryExchangeRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ operations.RecoveryExchangeResponse,
43
+ | errors.InvalidInputError
44
+ | errors.ErrorResponse
45
+ | BotShieldError
46
+ | ResponseValidationError
47
+ | ConnectionError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | InvalidRequestError
51
+ | UnexpectedClientError
52
+ | SDKValidationError
53
+ >
54
+ > {
55
+ return new APIPromise($do(
56
+ client,
57
+ security,
58
+ request,
59
+ options,
60
+ ));
61
+ }
62
+
63
+ async function $do(
64
+ client: BotShieldCore,
65
+ security: operations.RecoveryExchangeSecurity,
66
+ request: operations.RecoveryExchangeRequest,
67
+ options?: RequestOptions,
68
+ ): Promise<
69
+ [
70
+ Result<
71
+ operations.RecoveryExchangeResponse,
72
+ | errors.InvalidInputError
73
+ | errors.ErrorResponse
74
+ | BotShieldError
75
+ | ResponseValidationError
76
+ | ConnectionError
77
+ | RequestAbortedError
78
+ | RequestTimeoutError
79
+ | InvalidRequestError
80
+ | UnexpectedClientError
81
+ | SDKValidationError
82
+ >,
83
+ APICall,
84
+ ]
85
+ > {
86
+ const parsed = safeParse(
87
+ request,
88
+ (value) => operations.RecoveryExchangeRequest$outboundSchema.parse(value),
89
+ "Input validation failed",
90
+ );
91
+ if (!parsed.ok) {
92
+ return [parsed, { status: "invalid" }];
93
+ }
94
+ const payload = parsed.value;
95
+ const body = encodeJSON("body", payload, { explode: true });
96
+
97
+ const path = pathToFunc("/recovery/exchange")();
98
+
99
+ const headers = new Headers(compactMap({
100
+ "Content-Type": "application/json",
101
+ Accept: "application/json",
102
+ }));
103
+
104
+ const requestSecurity = resolveSecurity(
105
+ [
106
+ {
107
+ fieldName: "Authorization",
108
+ type: "apiKey:header",
109
+ value: security?.apiKeyAuth,
110
+ },
111
+ ],
112
+ );
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "RecoveryExchange",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: requestSecurity,
121
+
122
+ securitySource: security,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "POST",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ isErrorStatusCode: (statusCode: number) =>
147
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ operations.RecoveryExchangeResponse,
162
+ | errors.InvalidInputError
163
+ | errors.ErrorResponse
164
+ | BotShieldError
165
+ | ResponseValidationError
166
+ | ConnectionError
167
+ | RequestAbortedError
168
+ | RequestTimeoutError
169
+ | InvalidRequestError
170
+ | UnexpectedClientError
171
+ | SDKValidationError
172
+ >(
173
+ M.json(200, operations.RecoveryExchangeResponse$inboundSchema),
174
+ M.jsonErr(400, errors.InvalidInputError$inboundSchema),
175
+ M.jsonErr(500, errors.ErrorResponse$inboundSchema),
176
+ M.fail("4XX"),
177
+ M.fail("5XX"),
178
+ )(response, req, { extraFields: responseFields });
179
+ if (!result.ok) {
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
182
+
183
+ return [result, { status: "complete", request: req, response }];
184
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { BotShieldCore } from "../core.js";
6
+ import { encodeJSON } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { resolveSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import { BotShieldError } from "../models/errors/bot-shield-error.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/http-client-errors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
24
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Report another sign-in reset
31
+ *
32
+ * @remarks
33
+ * Tell BotShield that your other way to reset sign-in (a link by email, a code by text) was started for a verified account, by its handle. BotShield tells the person ("<Company> sign-in reset by email · It works from <day>. Not you? Open BotShield."), at most once per account in 6 hours. The answer is the same whether or not the handle is a live verified account.
34
+ */
35
+ export function recoveryOtherRoute(
36
+ client: BotShieldCore,
37
+ security: operations.RecoveryOtherRouteSecurity,
38
+ request: operations.RecoveryOtherRouteRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ operations.RecoveryOtherRouteResponse,
43
+ | errors.InvalidInputError
44
+ | errors.ErrorResponse
45
+ | BotShieldError
46
+ | ResponseValidationError
47
+ | ConnectionError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | InvalidRequestError
51
+ | UnexpectedClientError
52
+ | SDKValidationError
53
+ >
54
+ > {
55
+ return new APIPromise($do(
56
+ client,
57
+ security,
58
+ request,
59
+ options,
60
+ ));
61
+ }
62
+
63
+ async function $do(
64
+ client: BotShieldCore,
65
+ security: operations.RecoveryOtherRouteSecurity,
66
+ request: operations.RecoveryOtherRouteRequest,
67
+ options?: RequestOptions,
68
+ ): Promise<
69
+ [
70
+ Result<
71
+ operations.RecoveryOtherRouteResponse,
72
+ | errors.InvalidInputError
73
+ | errors.ErrorResponse
74
+ | BotShieldError
75
+ | ResponseValidationError
76
+ | ConnectionError
77
+ | RequestAbortedError
78
+ | RequestTimeoutError
79
+ | InvalidRequestError
80
+ | UnexpectedClientError
81
+ | SDKValidationError
82
+ >,
83
+ APICall,
84
+ ]
85
+ > {
86
+ const parsed = safeParse(
87
+ request,
88
+ (value) => operations.RecoveryOtherRouteRequest$outboundSchema.parse(value),
89
+ "Input validation failed",
90
+ );
91
+ if (!parsed.ok) {
92
+ return [parsed, { status: "invalid" }];
93
+ }
94
+ const payload = parsed.value;
95
+ const body = encodeJSON("body", payload, { explode: true });
96
+
97
+ const path = pathToFunc("/recovery/other-route")();
98
+
99
+ const headers = new Headers(compactMap({
100
+ "Content-Type": "application/json",
101
+ Accept: "application/json",
102
+ }));
103
+
104
+ const requestSecurity = resolveSecurity(
105
+ [
106
+ {
107
+ fieldName: "Authorization",
108
+ type: "apiKey:header",
109
+ value: security?.apiKeyAuth,
110
+ },
111
+ ],
112
+ );
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "RecoveryOtherRoute",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: requestSecurity,
121
+
122
+ securitySource: security,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "POST",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ isErrorStatusCode: (statusCode: number) =>
147
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ operations.RecoveryOtherRouteResponse,
162
+ | errors.InvalidInputError
163
+ | errors.ErrorResponse
164
+ | BotShieldError
165
+ | ResponseValidationError
166
+ | ConnectionError
167
+ | RequestAbortedError
168
+ | RequestTimeoutError
169
+ | InvalidRequestError
170
+ | UnexpectedClientError
171
+ | SDKValidationError
172
+ >(
173
+ M.json(200, operations.RecoveryOtherRouteResponse$inboundSchema),
174
+ M.jsonErr(400, errors.InvalidInputError$inboundSchema),
175
+ M.jsonErr(500, errors.ErrorResponse$inboundSchema),
176
+ M.fail("4XX"),
177
+ M.fail("5XX"),
178
+ )(response, req, { extraFields: responseFields });
179
+ if (!result.ok) {
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
182
+
183
+ return [result, { status: "complete", request: req, response }];
184
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { BotShieldCore } from "../core.js";
6
+ import { encodeJSON } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { resolveSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import { BotShieldError } from "../models/errors/bot-shield-error.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/http-client-errors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/response-validation-error.js";
24
+ import { SDKValidationError } from "../models/errors/sdk-validation-error.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Redeem a passkey sign-in
31
+ *
32
+ * @remarks
33
+ * Your SERVER redeems a sign-in with your secret key and the `request_id` IT made for this attempt: once, within 2 minutes of the passkey. The page's message from the frame is only a cue to call this. Send `partner_user_ref` to have a sign-in for any other account refused. The sign-in's token is not checked with verify-token (which refuses it), and verification/status never returns it.
34
+ */
35
+ export function signInConfirm(
36
+ client: BotShieldCore,
37
+ security: operations.SigninConfirmSecurity,
38
+ request: operations.SigninConfirmRequest,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ operations.SigninConfirmResponse,
43
+ | errors.InvalidInputError
44
+ | errors.ErrorResponse
45
+ | BotShieldError
46
+ | ResponseValidationError
47
+ | ConnectionError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | InvalidRequestError
51
+ | UnexpectedClientError
52
+ | SDKValidationError
53
+ >
54
+ > {
55
+ return new APIPromise($do(
56
+ client,
57
+ security,
58
+ request,
59
+ options,
60
+ ));
61
+ }
62
+
63
+ async function $do(
64
+ client: BotShieldCore,
65
+ security: operations.SigninConfirmSecurity,
66
+ request: operations.SigninConfirmRequest,
67
+ options?: RequestOptions,
68
+ ): Promise<
69
+ [
70
+ Result<
71
+ operations.SigninConfirmResponse,
72
+ | errors.InvalidInputError
73
+ | errors.ErrorResponse
74
+ | BotShieldError
75
+ | ResponseValidationError
76
+ | ConnectionError
77
+ | RequestAbortedError
78
+ | RequestTimeoutError
79
+ | InvalidRequestError
80
+ | UnexpectedClientError
81
+ | SDKValidationError
82
+ >,
83
+ APICall,
84
+ ]
85
+ > {
86
+ const parsed = safeParse(
87
+ request,
88
+ (value) => operations.SigninConfirmRequest$outboundSchema.parse(value),
89
+ "Input validation failed",
90
+ );
91
+ if (!parsed.ok) {
92
+ return [parsed, { status: "invalid" }];
93
+ }
94
+ const payload = parsed.value;
95
+ const body = encodeJSON("body", payload, { explode: true });
96
+
97
+ const path = pathToFunc("/signin/confirm")();
98
+
99
+ const headers = new Headers(compactMap({
100
+ "Content-Type": "application/json",
101
+ Accept: "application/json",
102
+ }));
103
+
104
+ const requestSecurity = resolveSecurity(
105
+ [
106
+ {
107
+ fieldName: "Authorization",
108
+ type: "apiKey:header",
109
+ value: security?.apiKeyAuth,
110
+ },
111
+ ],
112
+ );
113
+
114
+ const context = {
115
+ options: client._options,
116
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
117
+ operationID: "SigninConfirm",
118
+ oAuth2Scopes: null,
119
+
120
+ resolvedSecurity: requestSecurity,
121
+
122
+ securitySource: security,
123
+ retryConfig: options?.retries
124
+ || client._options.retryConfig
125
+ || { strategy: "none" },
126
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
127
+ };
128
+
129
+ const requestRes = client._createRequest(context, {
130
+ security: requestSecurity,
131
+ method: "POST",
132
+ baseURL: options?.serverURL,
133
+ path: path,
134
+ headers: headers,
135
+ body: body,
136
+ userAgent: client._options.userAgent,
137
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
138
+ }, options);
139
+ if (!requestRes.ok) {
140
+ return [requestRes, { status: "invalid" }];
141
+ }
142
+ const req = requestRes.value;
143
+
144
+ const doResult = await client._do(req, {
145
+ context,
146
+ isErrorStatusCode: (statusCode: number) =>
147
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
148
+ retryConfig: context.retryConfig,
149
+ retryCodes: context.retryCodes,
150
+ });
151
+ if (!doResult.ok) {
152
+ return [doResult, { status: "request-error", request: req }];
153
+ }
154
+ const response = doResult.value;
155
+
156
+ const responseFields = {
157
+ HttpMeta: { Response: response, Request: req },
158
+ };
159
+
160
+ const [result] = await M.match<
161
+ operations.SigninConfirmResponse,
162
+ | errors.InvalidInputError
163
+ | errors.ErrorResponse
164
+ | BotShieldError
165
+ | ResponseValidationError
166
+ | ConnectionError
167
+ | RequestAbortedError
168
+ | RequestTimeoutError
169
+ | InvalidRequestError
170
+ | UnexpectedClientError
171
+ | SDKValidationError
172
+ >(
173
+ M.json(200, operations.SigninConfirmResponse$inboundSchema),
174
+ M.jsonErr(400, errors.InvalidInputError$inboundSchema),
175
+ M.jsonErr(500, errors.ErrorResponse$inboundSchema),
176
+ M.fail("4XX"),
177
+ M.fail("5XX"),
178
+ )(response, req, { extraFields: responseFields });
179
+ if (!result.ok) {
180
+ return [result, { status: "complete", request: req, response }];
181
+ }
182
+
183
+ return [result, { status: "complete", request: req, response }];
184
+ }