@apifuse/provider-sdk 2.1.0-beta.11 → 2.1.0-beta.13

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.
package/src/types.ts CHANGED
@@ -1244,6 +1244,45 @@ export interface BrowserFrame {
1244
1244
  locator(selector: string): BrowserLocator;
1245
1245
  }
1246
1246
 
1247
+ export type BrowserResourceMethod = "GET" | "HEAD";
1248
+
1249
+ export type BrowserResourceRequest = {
1250
+ readonly url: string;
1251
+ readonly method: BrowserResourceMethod;
1252
+ readonly resourceType?: string;
1253
+ readonly headers: Readonly<Record<string, string>>;
1254
+ };
1255
+
1256
+ export type BrowserResourceBody = Buffer | Uint8Array | ArrayBuffer | string;
1257
+
1258
+ export type BrowserResourceDecision =
1259
+ | {
1260
+ readonly action: "fulfill";
1261
+ readonly status?: number;
1262
+ readonly headers?: Readonly<Record<string, string>>;
1263
+ readonly body?: BrowserResourceBody;
1264
+ }
1265
+ | {
1266
+ readonly action: "block";
1267
+ readonly reason?: string;
1268
+ };
1269
+
1270
+ export type BrowserResourceRoute = {
1271
+ readonly match:
1272
+ | string
1273
+ | RegExp
1274
+ | ((request: BrowserResourceRequest) => boolean);
1275
+ readonly handle: (
1276
+ request: BrowserResourceRequest,
1277
+ ) => Promise<BrowserResourceDecision> | BrowserResourceDecision;
1278
+ };
1279
+
1280
+ export type BrowserResourcePolicy = {
1281
+ readonly defaultAction?: "block";
1282
+ readonly allowedMethods?: readonly BrowserResourceMethod[];
1283
+ readonly routes: readonly BrowserResourceRoute[];
1284
+ };
1285
+
1247
1286
  export interface BrowserPage extends BrowserFrame {
1248
1287
  close(): Promise<void>;
1249
1288
  fill(selector: string, text: string): Promise<void>;
@@ -1257,6 +1296,10 @@ export interface BrowserPage extends BrowserFrame {
1257
1296
  options?: { timeout?: number },
1258
1297
  ): Promise<void>;
1259
1298
  frames(): Promise<BrowserFrame[]>;
1299
+ withResourcePolicy<T>(
1300
+ policy: BrowserResourcePolicy,
1301
+ run: () => Promise<T>,
1302
+ ): Promise<T>;
1260
1303
  }
1261
1304
 
1262
1305
  export type BrowserChallengeRequest = {
@@ -1435,6 +1478,84 @@ export interface ContextScratchpad {
1435
1478
 
1436
1479
  export type FlowContextStore = ContextScratchpad;
1437
1480
 
1481
+ export type AuthSafeJson =
1482
+ | string
1483
+ | number
1484
+ | boolean
1485
+ | null
1486
+ | readonly AuthSafeJson[]
1487
+ | { readonly [key: string]: AuthSafeJson };
1488
+
1489
+ export type AuthSafeData = { readonly [key: string]: AuthSafeJson };
1490
+
1491
+ export type AuthAbortRetry = "never" | "retry" | "after_user_action";
1492
+
1493
+ export type AuthAbortData = Record<string, unknown> & {
1494
+ readonly code: string;
1495
+ readonly message?: string;
1496
+ readonly retry?: AuthAbortRetry;
1497
+ readonly actionHint?: AuthSafeJson;
1498
+ readonly fieldErrors?: { readonly [field: string]: string };
1499
+ readonly details?: AuthSafeData;
1500
+ };
1501
+
1502
+ export interface AuthFlowTerminalContext {
1503
+ readonly signal?: AbortSignal;
1504
+ readonly deadline?: string;
1505
+ complete<TCredential extends Record<string, string>>(options: {
1506
+ readonly credential: TCredential;
1507
+ readonly metadata?: AuthSafeData;
1508
+ readonly data?: AuthSafeData;
1509
+ readonly turnId?: string;
1510
+ readonly expiresAt?: string;
1511
+ }): AuthTurn;
1512
+ abort(options: {
1513
+ readonly code: string;
1514
+ readonly message?: string;
1515
+ readonly retry?: AuthAbortRetry;
1516
+ readonly actionHint?: AuthSafeJson;
1517
+ readonly fieldErrors?: { readonly [field: string]: string };
1518
+ readonly data?: AuthSafeData;
1519
+ readonly turnId?: string;
1520
+ readonly expiresAt?: string;
1521
+ }): AuthTurn;
1522
+ nextForm(
1523
+ options: {
1524
+ readonly hintKey?: ProviderLocaleKeyInput;
1525
+ readonly data?: AuthSafeData;
1526
+ readonly turnId?: string;
1527
+ readonly expiresAt?: string;
1528
+ readonly timing?: AuthTurn["timing"];
1529
+ } & (
1530
+ | {
1531
+ readonly fields: Record<
1532
+ string,
1533
+ {
1534
+ readonly type?: "string" | "email" | "password" | "otp";
1535
+ readonly labelKey?: ProviderLocaleKeyInput;
1536
+ readonly descriptionKey?: ProviderLocaleKeyInput;
1537
+ readonly placeholderKey?: ProviderLocaleKeyInput;
1538
+ readonly required?: boolean;
1539
+ readonly sensitive?: boolean;
1540
+ }
1541
+ >;
1542
+ readonly expectedInput?: never;
1543
+ }
1544
+ | {
1545
+ readonly expectedInput: Record<string, unknown>;
1546
+ readonly fields?: never;
1547
+ }
1548
+ ),
1549
+ ): AuthTurn;
1550
+ nextPoll(options?: {
1551
+ readonly hintKey?: ProviderLocaleKeyInput;
1552
+ readonly data?: AuthSafeData;
1553
+ readonly turnId?: string;
1554
+ readonly expiresAt?: string;
1555
+ readonly timing?: AuthTurn["timing"];
1556
+ }): AuthTurn;
1557
+ }
1558
+
1438
1559
  export interface FlowContext {
1439
1560
  connectionId?: string;
1440
1561
  externalRef?: string;
@@ -1446,6 +1567,7 @@ export interface FlowContext {
1446
1567
  credential?: CredentialContext;
1447
1568
  context: ContextScratchpad;
1448
1569
  stt: SttContext;
1570
+ auth: AuthFlowTerminalContext;
1449
1571
  }
1450
1572
 
1451
1573
  export interface AuthTurn {