|
| 1 | +// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | + |
| 3 | +import { APIResource } from '../../../core/resource'; |
| 4 | +import * as RunsAPI from './runs'; |
| 5 | +import { RunDiscoverParams, RunExchangeParams, RunExchangeResponse, RunSubmitParams, Runs } from './runs'; |
| 6 | +import { APIPromise } from '../../../core/api-promise'; |
| 7 | +import { RequestOptions } from '../../../internal/request-options'; |
| 8 | + |
| 9 | +export class Auth extends APIResource { |
| 10 | + runs: RunsAPI.Runs = new RunsAPI.Runs(this._client); |
| 11 | + |
| 12 | + /** |
| 13 | + * Creates a browser session and returns a handoff code for the hosted flow. Uses |
| 14 | + * standard API key or JWT authentication (not the JWT returned by the exchange |
| 15 | + * endpoint). |
| 16 | + * |
| 17 | + * @example |
| 18 | + * ```ts |
| 19 | + * const agentAuthStartResponse = |
| 20 | + * await client.agents.auth.start({ |
| 21 | + * profile_name: 'auth-abc123', |
| 22 | + * target_domain: 'doordash.com', |
| 23 | + * }); |
| 24 | + * ``` |
| 25 | + */ |
| 26 | + start(body: AuthStartParams, options?: RequestOptions): APIPromise<AgentAuthStartResponse> { |
| 27 | + return this._client.post('/agents/auth/start', { body, ...options }); |
| 28 | + } |
| 29 | +} |
| 30 | + |
| 31 | +/** |
| 32 | + * Response from discover endpoint matching AuthBlueprint schema |
| 33 | + */ |
| 34 | +export interface AgentAuthDiscoverResponse { |
| 35 | + /** |
| 36 | + * Whether discovery succeeded |
| 37 | + */ |
| 38 | + success: boolean; |
| 39 | + |
| 40 | + /** |
| 41 | + * Error message if discovery failed |
| 42 | + */ |
| 43 | + error_message?: string; |
| 44 | + |
| 45 | + /** |
| 46 | + * Discovered form fields (present when success is true) |
| 47 | + */ |
| 48 | + fields?: Array<DiscoveredField>; |
| 49 | + |
| 50 | + /** |
| 51 | + * Whether user is already logged in |
| 52 | + */ |
| 53 | + logged_in?: boolean; |
| 54 | + |
| 55 | + /** |
| 56 | + * URL of the discovered login page |
| 57 | + */ |
| 58 | + login_url?: string; |
| 59 | + |
| 60 | + /** |
| 61 | + * Title of the login page |
| 62 | + */ |
| 63 | + page_title?: string; |
| 64 | +} |
| 65 | + |
| 66 | +/** |
| 67 | + * Response from get run endpoint |
| 68 | + */ |
| 69 | +export interface AgentAuthRunResponse { |
| 70 | + /** |
| 71 | + * App name (org name at time of run creation) |
| 72 | + */ |
| 73 | + app_name: string; |
| 74 | + |
| 75 | + /** |
| 76 | + * When the handoff code expires |
| 77 | + */ |
| 78 | + expires_at: string; |
| 79 | + |
| 80 | + /** |
| 81 | + * Run status |
| 82 | + */ |
| 83 | + status: 'ACTIVE' | 'ENDED' | 'EXPIRED' | 'CANCELED'; |
| 84 | + |
| 85 | + /** |
| 86 | + * Target domain for authentication |
| 87 | + */ |
| 88 | + target_domain: string; |
| 89 | +} |
| 90 | + |
| 91 | +/** |
| 92 | + * Response from starting an agent authentication run |
| 93 | + */ |
| 94 | +export interface AgentAuthStartResponse { |
| 95 | + /** |
| 96 | + * When the handoff code expires |
| 97 | + */ |
| 98 | + expires_at: string; |
| 99 | + |
| 100 | + /** |
| 101 | + * One-time code for handoff |
| 102 | + */ |
| 103 | + handoff_code: string; |
| 104 | + |
| 105 | + /** |
| 106 | + * URL to redirect user to |
| 107 | + */ |
| 108 | + hosted_url: string; |
| 109 | + |
| 110 | + /** |
| 111 | + * Unique identifier for the run |
| 112 | + */ |
| 113 | + run_id: string; |
| 114 | +} |
| 115 | + |
| 116 | +/** |
| 117 | + * Response from submit endpoint matching SubmitResult schema |
| 118 | + */ |
| 119 | +export interface AgentAuthSubmitResponse { |
| 120 | + /** |
| 121 | + * Whether submission succeeded |
| 122 | + */ |
| 123 | + success: boolean; |
| 124 | + |
| 125 | + /** |
| 126 | + * Additional fields needed (e.g., OTP) - present when needs_additional_auth is |
| 127 | + * true |
| 128 | + */ |
| 129 | + additional_fields?: Array<DiscoveredField>; |
| 130 | + |
| 131 | + /** |
| 132 | + * App name (only present when logged_in is true) |
| 133 | + */ |
| 134 | + app_name?: string; |
| 135 | + |
| 136 | + /** |
| 137 | + * Error message if submission failed |
| 138 | + */ |
| 139 | + error_message?: string; |
| 140 | + |
| 141 | + /** |
| 142 | + * Whether user is now logged in |
| 143 | + */ |
| 144 | + logged_in?: boolean; |
| 145 | + |
| 146 | + /** |
| 147 | + * Whether additional authentication fields are needed |
| 148 | + */ |
| 149 | + needs_additional_auth?: boolean; |
| 150 | + |
| 151 | + /** |
| 152 | + * Target domain (only present when logged_in is true) |
| 153 | + */ |
| 154 | + target_domain?: string; |
| 155 | +} |
| 156 | + |
| 157 | +/** |
| 158 | + * A discovered form field |
| 159 | + */ |
| 160 | +export interface DiscoveredField { |
| 161 | + /** |
| 162 | + * Field label |
| 163 | + */ |
| 164 | + label: string; |
| 165 | + |
| 166 | + /** |
| 167 | + * Field name |
| 168 | + */ |
| 169 | + name: string; |
| 170 | + |
| 171 | + /** |
| 172 | + * CSS selector for the field |
| 173 | + */ |
| 174 | + selector: string; |
| 175 | + |
| 176 | + /** |
| 177 | + * Field type |
| 178 | + */ |
| 179 | + type: 'text' | 'email' | 'password' | 'tel' | 'number' | 'url' | 'code' | 'checkbox'; |
| 180 | + |
| 181 | + /** |
| 182 | + * Field placeholder |
| 183 | + */ |
| 184 | + placeholder?: string; |
| 185 | + |
| 186 | + /** |
| 187 | + * Whether field is required |
| 188 | + */ |
| 189 | + required?: boolean; |
| 190 | +} |
| 191 | + |
| 192 | +export interface AuthStartParams { |
| 193 | + /** |
| 194 | + * Name of the profile to use for this flow |
| 195 | + */ |
| 196 | + profile_name: string; |
| 197 | + |
| 198 | + /** |
| 199 | + * Target domain for authentication |
| 200 | + */ |
| 201 | + target_domain: string; |
| 202 | + |
| 203 | + /** |
| 204 | + * Optional logo URL for the application |
| 205 | + */ |
| 206 | + app_logo_url?: string; |
| 207 | + |
| 208 | + /** |
| 209 | + * Optional proxy configuration |
| 210 | + */ |
| 211 | + proxy?: AuthStartParams.Proxy; |
| 212 | +} |
| 213 | + |
| 214 | +export namespace AuthStartParams { |
| 215 | + /** |
| 216 | + * Optional proxy configuration |
| 217 | + */ |
| 218 | + export interface Proxy { |
| 219 | + /** |
| 220 | + * ID of the proxy to use |
| 221 | + */ |
| 222 | + proxy_id?: string; |
| 223 | + } |
| 224 | +} |
| 225 | + |
| 226 | +Auth.Runs = Runs; |
| 227 | + |
| 228 | +export declare namespace Auth { |
| 229 | + export { |
| 230 | + type AgentAuthDiscoverResponse as AgentAuthDiscoverResponse, |
| 231 | + type AgentAuthRunResponse as AgentAuthRunResponse, |
| 232 | + type AgentAuthStartResponse as AgentAuthStartResponse, |
| 233 | + type AgentAuthSubmitResponse as AgentAuthSubmitResponse, |
| 234 | + type DiscoveredField as DiscoveredField, |
| 235 | + type AuthStartParams as AuthStartParams, |
| 236 | + }; |
| 237 | + |
| 238 | + export { |
| 239 | + Runs as Runs, |
| 240 | + type RunExchangeResponse as RunExchangeResponse, |
| 241 | + type RunDiscoverParams as RunDiscoverParams, |
| 242 | + type RunExchangeParams as RunExchangeParams, |
| 243 | + type RunSubmitParams as RunSubmitParams, |
| 244 | + }; |
| 245 | +} |
0 commit comments