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,319 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { ClosedEnum } from "../../types/enums.js";
9
+ import { Result as SafeParseResult } from "../../types/fp.js";
10
+ import * as types from "../../types/primitives.js";
11
+ import { SDKValidationError } from "../errors/sdk-validation-error.js";
12
+ import * as models from "../index.js";
13
+
14
+ export type SigninRequestSecurity = {
15
+ apiKeyAuth: string;
16
+ };
17
+
18
+ export type SigninRequestRequest = {
19
+ /**
20
+ * Your own reference for the account (the same `partner_user_ref` it was verified with). Hashed server-side; never stored or returned.
21
+ */
22
+ partnerUserRef: string;
23
+ };
24
+
25
+ export const SigninRequestTier = {
26
+ One: 1,
27
+ } as const;
28
+ export type SigninRequestTier = ClosedEnum<typeof SigninRequestTier>;
29
+
30
+ export type SigninRequestDataData = {
31
+ /**
32
+ * The only value your page gets.
33
+ */
34
+ requestId: string;
35
+ /**
36
+ * 2 minutes from now.
37
+ */
38
+ expiresAt: Date;
39
+ tier: SigninRequestTier;
40
+ /**
41
+ * The one page origin BotShield's frame will run under: your Sign-on Action's address.
42
+ */
43
+ pageOrigin: string;
44
+ /**
45
+ * Whether BotShield's QR may finish this sign-in (your Sign-on Action's QR switch; default off).
46
+ */
47
+ qr: boolean;
48
+ /**
49
+ * BotShield's QR address for this request, only when `qr` is true.
50
+ */
51
+ qrUrl: string | null;
52
+ };
53
+
54
+ export type SigninRequestData = {
55
+ data?: SigninRequestDataData | undefined;
56
+ /**
57
+ * Handler error. Arrives inside `data.error` with HTTP 200. Check for it before reading the result.
58
+ */
59
+ error?: models.ErrorBody | undefined;
60
+ };
61
+
62
+ /**
63
+ * The sign-in request. NOTE: handler errors also arrive here (HTTP 200) as data.error — codes: `invalid_key` (401 — missing, malformed or inactive key; a site key `pk_…` is refused), `org_not_found` (404), `signin_not_set_up` (409 — no live Sign-on Action with a sign-in page here), `not_verified` (409 — not a verified account here; nothing was started), `account_paused` (409 — the customer's verified accounts are paused until they confirm again from a signed-in page), `unavailable` (503).
64
+ */
65
+ export type SigninRequestResponse = {
66
+ data: SigninRequestData;
67
+ };
68
+
69
+ /** @internal */
70
+ export const SigninRequestSecurity$inboundSchema: z.ZodType<
71
+ SigninRequestSecurity,
72
+ z.ZodTypeDef,
73
+ unknown
74
+ > = z.object({
75
+ ApiKeyAuth: types.string(),
76
+ }).transform((v) => {
77
+ return remap$(v, {
78
+ "ApiKeyAuth": "apiKeyAuth",
79
+ });
80
+ });
81
+ /** @internal */
82
+ export type SigninRequestSecurity$Outbound = {
83
+ ApiKeyAuth: string;
84
+ };
85
+
86
+ /** @internal */
87
+ export const SigninRequestSecurity$outboundSchema: z.ZodType<
88
+ SigninRequestSecurity$Outbound,
89
+ z.ZodTypeDef,
90
+ SigninRequestSecurity
91
+ > = z.object({
92
+ apiKeyAuth: z.string(),
93
+ }).transform((v) => {
94
+ return remap$(v, {
95
+ apiKeyAuth: "ApiKeyAuth",
96
+ });
97
+ });
98
+
99
+ export function signinRequestSecurityToJSON(
100
+ signinRequestSecurity: SigninRequestSecurity,
101
+ ): string {
102
+ return JSON.stringify(
103
+ SigninRequestSecurity$outboundSchema.parse(signinRequestSecurity),
104
+ );
105
+ }
106
+ export function signinRequestSecurityFromJSON(
107
+ jsonString: string,
108
+ ): SafeParseResult<SigninRequestSecurity, SDKValidationError> {
109
+ return safeParse(
110
+ jsonString,
111
+ (x) => SigninRequestSecurity$inboundSchema.parse(JSON.parse(x)),
112
+ `Failed to parse 'SigninRequestSecurity' from JSON`,
113
+ );
114
+ }
115
+
116
+ /** @internal */
117
+ export const SigninRequestRequest$inboundSchema: z.ZodType<
118
+ SigninRequestRequest,
119
+ z.ZodTypeDef,
120
+ unknown
121
+ > = z.object({
122
+ partner_user_ref: types.string(),
123
+ }).transform((v) => {
124
+ return remap$(v, {
125
+ "partner_user_ref": "partnerUserRef",
126
+ });
127
+ });
128
+ /** @internal */
129
+ export type SigninRequestRequest$Outbound = {
130
+ partner_user_ref: string;
131
+ };
132
+
133
+ /** @internal */
134
+ export const SigninRequestRequest$outboundSchema: z.ZodType<
135
+ SigninRequestRequest$Outbound,
136
+ z.ZodTypeDef,
137
+ SigninRequestRequest
138
+ > = z.object({
139
+ partnerUserRef: z.string(),
140
+ }).transform((v) => {
141
+ return remap$(v, {
142
+ partnerUserRef: "partner_user_ref",
143
+ });
144
+ });
145
+
146
+ export function signinRequestRequestToJSON(
147
+ signinRequestRequest: SigninRequestRequest,
148
+ ): string {
149
+ return JSON.stringify(
150
+ SigninRequestRequest$outboundSchema.parse(signinRequestRequest),
151
+ );
152
+ }
153
+ export function signinRequestRequestFromJSON(
154
+ jsonString: string,
155
+ ): SafeParseResult<SigninRequestRequest, SDKValidationError> {
156
+ return safeParse(
157
+ jsonString,
158
+ (x) => SigninRequestRequest$inboundSchema.parse(JSON.parse(x)),
159
+ `Failed to parse 'SigninRequestRequest' from JSON`,
160
+ );
161
+ }
162
+
163
+ /** @internal */
164
+ export const SigninRequestTier$inboundSchema: z.ZodNativeEnum<
165
+ typeof SigninRequestTier
166
+ > = z.nativeEnum(SigninRequestTier);
167
+ /** @internal */
168
+ export const SigninRequestTier$outboundSchema: z.ZodNativeEnum<
169
+ typeof SigninRequestTier
170
+ > = SigninRequestTier$inboundSchema;
171
+
172
+ /** @internal */
173
+ export const SigninRequestDataData$inboundSchema: z.ZodType<
174
+ SigninRequestDataData,
175
+ z.ZodTypeDef,
176
+ unknown
177
+ > = z.object({
178
+ request_id: types.string(),
179
+ expires_at: types.date(),
180
+ tier: SigninRequestTier$inboundSchema,
181
+ page_origin: types.string(),
182
+ qr: types.boolean(),
183
+ qr_url: types.nullable(types.string()),
184
+ }).transform((v) => {
185
+ return remap$(v, {
186
+ "request_id": "requestId",
187
+ "expires_at": "expiresAt",
188
+ "page_origin": "pageOrigin",
189
+ "qr_url": "qrUrl",
190
+ });
191
+ });
192
+ /** @internal */
193
+ export type SigninRequestDataData$Outbound = {
194
+ request_id: string;
195
+ expires_at: string;
196
+ tier: number;
197
+ page_origin: string;
198
+ qr: boolean;
199
+ qr_url: string | null;
200
+ };
201
+
202
+ /** @internal */
203
+ export const SigninRequestDataData$outboundSchema: z.ZodType<
204
+ SigninRequestDataData$Outbound,
205
+ z.ZodTypeDef,
206
+ SigninRequestDataData
207
+ > = z.object({
208
+ requestId: z.string(),
209
+ expiresAt: z.date().transform(v => v.toISOString()),
210
+ tier: SigninRequestTier$outboundSchema,
211
+ pageOrigin: z.string(),
212
+ qr: z.boolean(),
213
+ qrUrl: z.nullable(z.string()),
214
+ }).transform((v) => {
215
+ return remap$(v, {
216
+ requestId: "request_id",
217
+ expiresAt: "expires_at",
218
+ pageOrigin: "page_origin",
219
+ qrUrl: "qr_url",
220
+ });
221
+ });
222
+
223
+ export function signinRequestDataDataToJSON(
224
+ signinRequestDataData: SigninRequestDataData,
225
+ ): string {
226
+ return JSON.stringify(
227
+ SigninRequestDataData$outboundSchema.parse(signinRequestDataData),
228
+ );
229
+ }
230
+ export function signinRequestDataDataFromJSON(
231
+ jsonString: string,
232
+ ): SafeParseResult<SigninRequestDataData, SDKValidationError> {
233
+ return safeParse(
234
+ jsonString,
235
+ (x) => SigninRequestDataData$inboundSchema.parse(JSON.parse(x)),
236
+ `Failed to parse 'SigninRequestDataData' from JSON`,
237
+ );
238
+ }
239
+
240
+ /** @internal */
241
+ export const SigninRequestData$inboundSchema: z.ZodType<
242
+ SigninRequestData,
243
+ z.ZodTypeDef,
244
+ unknown
245
+ > = z.object({
246
+ data: types.optional(z.lazy(() => SigninRequestDataData$inboundSchema)),
247
+ error: types.optional(models.ErrorBody$inboundSchema),
248
+ });
249
+ /** @internal */
250
+ export type SigninRequestData$Outbound = {
251
+ data?: SigninRequestDataData$Outbound | undefined;
252
+ error?: models.ErrorBody$Outbound | undefined;
253
+ };
254
+
255
+ /** @internal */
256
+ export const SigninRequestData$outboundSchema: z.ZodType<
257
+ SigninRequestData$Outbound,
258
+ z.ZodTypeDef,
259
+ SigninRequestData
260
+ > = z.object({
261
+ data: z.lazy(() => SigninRequestDataData$outboundSchema).optional(),
262
+ error: models.ErrorBody$outboundSchema.optional(),
263
+ });
264
+
265
+ export function signinRequestDataToJSON(
266
+ signinRequestData: SigninRequestData,
267
+ ): string {
268
+ return JSON.stringify(
269
+ SigninRequestData$outboundSchema.parse(signinRequestData),
270
+ );
271
+ }
272
+ export function signinRequestDataFromJSON(
273
+ jsonString: string,
274
+ ): SafeParseResult<SigninRequestData, SDKValidationError> {
275
+ return safeParse(
276
+ jsonString,
277
+ (x) => SigninRequestData$inboundSchema.parse(JSON.parse(x)),
278
+ `Failed to parse 'SigninRequestData' from JSON`,
279
+ );
280
+ }
281
+
282
+ /** @internal */
283
+ export const SigninRequestResponse$inboundSchema: z.ZodType<
284
+ SigninRequestResponse,
285
+ z.ZodTypeDef,
286
+ unknown
287
+ > = z.object({
288
+ data: z.lazy(() => SigninRequestData$inboundSchema),
289
+ });
290
+ /** @internal */
291
+ export type SigninRequestResponse$Outbound = {
292
+ data: SigninRequestData$Outbound;
293
+ };
294
+
295
+ /** @internal */
296
+ export const SigninRequestResponse$outboundSchema: z.ZodType<
297
+ SigninRequestResponse$Outbound,
298
+ z.ZodTypeDef,
299
+ SigninRequestResponse
300
+ > = z.object({
301
+ data: z.lazy(() => SigninRequestData$outboundSchema),
302
+ });
303
+
304
+ export function signinRequestResponseToJSON(
305
+ signinRequestResponse: SigninRequestResponse,
306
+ ): string {
307
+ return JSON.stringify(
308
+ SigninRequestResponse$outboundSchema.parse(signinRequestResponse),
309
+ );
310
+ }
311
+ export function signinRequestResponseFromJSON(
312
+ jsonString: string,
313
+ ): SafeParseResult<SigninRequestResponse, SDKValidationError> {
314
+ return safeParse(
315
+ jsonString,
316
+ (x) => SigninRequestResponse$inboundSchema.parse(JSON.parse(x)),
317
+ `Failed to parse 'SigninRequestResponse' from JSON`,
318
+ );
319
+ }
@@ -19,6 +19,10 @@ export type VerificationGetStatusSecurity = {
19
19
 
20
20
  export type VerificationGetStatusRequest = {
21
21
  requestId: string;
22
+ /**
23
+ * 4.0: the `read_secret` create-verification-link returned for a request started with your site key. Without it such a request's `verification_token` / `signed_token` are never returned. A request your server started reads them with your secret key (`Authorization: Bearer bs_…`) instead. A passkey sign-in's answer is never returned here (use signin/confirm).
24
+ */
25
+ xBotShieldRequestSecret?: string | undefined;
22
26
  };
23
27
 
24
28
  /**
@@ -338,14 +342,17 @@ export const VerificationGetStatusRequest$inboundSchema: z.ZodType<
338
342
  unknown
339
343
  > = z.object({
340
344
  request_id: types.string(),
345
+ "X-BotShield-Request-Secret": types.optional(types.string()),
341
346
  }).transform((v) => {
342
347
  return remap$(v, {
343
348
  "request_id": "requestId",
349
+ "X-BotShield-Request-Secret": "xBotShieldRequestSecret",
344
350
  });
345
351
  });
346
352
  /** @internal */
347
353
  export type VerificationGetStatusRequest$Outbound = {
348
354
  request_id: string;
355
+ "X-BotShield-Request-Secret"?: string | undefined;
349
356
  };
350
357
 
351
358
  /** @internal */
@@ -355,9 +362,11 @@ export const VerificationGetStatusRequest$outboundSchema: z.ZodType<
355
362
  VerificationGetStatusRequest
356
363
  > = z.object({
357
364
  requestId: z.string(),
365
+ xBotShieldRequestSecret: z.string().optional(),
358
366
  }).transform((v) => {
359
367
  return remap$(v, {
360
368
  requestId: "request_id",
369
+ xBotShieldRequestSecret: "X-BotShield-Request-Secret",
361
370
  });
362
371
  });
363
372
 
package/src/sdk/census.ts CHANGED
@@ -61,7 +61,7 @@ export class Census extends ClientSDK {
61
61
  * Validate a verification token
62
62
  *
63
63
  * @remarks
64
- * 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.
64
+ * 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.
65
65
  */
66
66
  async verifyToken(
67
67
  security: operations.SDKVerifyTokenSecurity,
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { recoveryExchange } from "../funcs/recovery-exchange.js";
6
+ import { recoveryOtherRoute } from "../funcs/recovery-other-route.js";
7
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
8
+ import * as operations from "../models/operations/index.js";
9
+ import { unwrapAsync } from "../types/fp.js";
10
+
11
+ export class Recovery extends ClientSDK {
12
+ /**
13
+ * Redeem a recovery code
14
+ *
15
+ * @remarks
16
+ * 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.
17
+ */
18
+ async exchange(
19
+ security: operations.RecoveryExchangeSecurity,
20
+ request: operations.RecoveryExchangeRequest,
21
+ options?: RequestOptions,
22
+ ): Promise<operations.RecoveryExchangeResponse> {
23
+ return unwrapAsync(recoveryExchange(
24
+ this,
25
+ security,
26
+ request,
27
+ options,
28
+ ));
29
+ }
30
+
31
+ /**
32
+ * Report another sign-in reset
33
+ *
34
+ * @remarks
35
+ * 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.
36
+ */
37
+ async otherRoute(
38
+ security: operations.RecoveryOtherRouteSecurity,
39
+ request: operations.RecoveryOtherRouteRequest,
40
+ options?: RequestOptions,
41
+ ): Promise<operations.RecoveryOtherRouteResponse> {
42
+ return unwrapAsync(recoveryOtherRoute(
43
+ this,
44
+ security,
45
+ request,
46
+ options,
47
+ ));
48
+ }
49
+ }
package/src/sdk/sdk.ts CHANGED
@@ -7,7 +7,9 @@ import { Actions } from "./actions.js";
7
7
  import { Census } from "./census.js";
8
8
  import { Gates } from "./gates.js";
9
9
  import { InlinePasskey } from "./inline-passkey.js";
10
+ import { Recovery } from "./recovery.js";
10
11
  import { SecuredAccounts } from "./secured-accounts.js";
12
+ import { SignIn } from "./sign-in.js";
11
13
  import { Verification } from "./verification.js";
12
14
 
13
15
  export class BotShield extends ClientSDK {
@@ -40,4 +42,14 @@ export class BotShield extends ClientSDK {
40
42
  get inlinePasskey(): InlinePasskey {
41
43
  return (this._inlinePasskey ??= new InlinePasskey(this._options));
42
44
  }
45
+
46
+ private _recovery?: Recovery;
47
+ get recovery(): Recovery {
48
+ return (this._recovery ??= new Recovery(this._options));
49
+ }
50
+
51
+ private _signIn?: SignIn;
52
+ get signIn(): SignIn {
53
+ return (this._signIn ??= new SignIn(this._options));
54
+ }
43
55
  }
@@ -0,0 +1,49 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { signInConfirm } from "../funcs/sign-in-confirm.js";
6
+ import { signInRequest } from "../funcs/sign-in-request.js";
7
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
8
+ import * as operations from "../models/operations/index.js";
9
+ import { unwrapAsync } from "../types/fp.js";
10
+
11
+ export class SignIn extends ClientSDK {
12
+ /**
13
+ * Ask for a passkey sign-in
14
+ *
15
+ * @remarks
16
+ * 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).
17
+ */
18
+ async request(
19
+ security: operations.SigninRequestSecurity,
20
+ request: operations.SigninRequestRequest,
21
+ options?: RequestOptions,
22
+ ): Promise<operations.SigninRequestResponse> {
23
+ return unwrapAsync(signInRequest(
24
+ this,
25
+ security,
26
+ request,
27
+ options,
28
+ ));
29
+ }
30
+
31
+ /**
32
+ * Redeem a passkey sign-in
33
+ *
34
+ * @remarks
35
+ * 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.
36
+ */
37
+ async confirm(
38
+ security: operations.SigninConfirmSecurity,
39
+ request: operations.SigninConfirmRequest,
40
+ options?: RequestOptions,
41
+ ): Promise<operations.SigninConfirmResponse> {
42
+ return unwrapAsync(signInConfirm(
43
+ this,
44
+ security,
45
+ request,
46
+ options,
47
+ ));
48
+ }
49
+ }
@@ -12,7 +12,7 @@ export class Verification extends ClientSDK {
12
12
  * Check verification status
13
13
  *
14
14
  * @remarks
15
- * 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"`.
15
+ * 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.
16
16
  */
17
17
  async getStatus(
18
18
  security: operations.VerificationGetStatusSecurity,