1 | |
2 | type Basistheory = { |
3 | apiKey: string; |
4 | }; |
5 | |
6 | * Three DS.Create Session |
7 | * Three DS.Create Session |
8 | */ |
9 | export async function main( |
10 | auth: Basistheory, |
11 | body: { |
12 | device?: string; |
13 | device_info?: { |
14 | browser_accept_header?: string; |
15 | browser_color_depth?: string; |
16 | browser_ip?: string; |
17 | browser_java_enabled?: string; |
18 | browser_javascript_enabled?: string; |
19 | browser_language?: string; |
20 | browser_screen_height?: string; |
21 | browser_screen_width?: string; |
22 | browser_tz?: string; |
23 | browser_user_agent?: string; |
24 | sdk_application_id?: string; |
25 | sdk_encryption_data?: string; |
26 | sdk_ephemeral_public_key?: string; |
27 | sdk_max_timeout?: string; |
28 | sdk_reference_number?: string; |
29 | sdk_render_options?: { sdk_interface?: string; sdk_ui_type?: string[] }; |
30 | sdk_transaction_id?: string; |
31 | }; |
32 | pan?: string; |
33 | token_id?: string; |
34 | token_intent_id?: string; |
35 | type?: string; |
36 | web_challenge_mode?: string; |
37 | }, |
38 | ) { |
39 | const url = new URL(`https://api.basistheory.com/3ds/sessions`); |
40 |
|
41 | const response = await fetch(url, { |
42 | method: "POST", |
43 | headers: { |
44 | "Content-Type": "application/json", |
45 | "BT-API-KEY": auth.apiKey, |
46 | }, |
47 | body: JSON.stringify(body), |
48 | }); |
49 | if (!response.ok) { |
50 | const text = await response.text(); |
51 | throw new Error(`${response.status} ${text}`); |
52 | } |
53 | return await response.json(); |
54 | } |
55 |
|