@hyperbrowser/sdk 1.4.1 → 1.5.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.
@@ -2,6 +2,7 @@ import type { Blob } from "buffer";
2
2
  import type { ReadableStream } from "node:stream/web";
3
3
  import { SessionRegion } from "./constants";
4
4
  import { SessionLaunchState, SessionStatus } from "./session";
5
+ import type { VaultReference } from "./vault";
5
6
  export type SandboxStatus = SessionStatus;
6
7
  export interface SandboxNetworkPolicy {
7
8
  allowInternetAccess?: boolean | null;
@@ -73,23 +74,38 @@ export interface SandboxDetail extends Sandbox {
73
74
  }
74
75
  export type SandboxVolumeMountType = "rw" | "ro";
75
76
  /**
76
- * A stored secret to deliver as an environment variable: its name, or
77
- * `{ name, version }` to pin a version. The latest version is used otherwise.
77
+ * A stored secret by name, optionally pinned to a version. A
78
+ * customer-protected secret also carries `unwrapped`, the envelope the
79
+ * customer unwrapped, and must pin the version it came from;
80
+ * `secrets.unwrap()` returns one ready to pass.
78
81
  */
79
- export type SandboxSecretReference = string | {
82
+ export interface SandboxStoredSecretReference {
80
83
  name: string;
81
84
  version?: number | "latest";
82
- };
85
+ /** Customer-protected secrets only: the version's unwrapped inner envelope. */
86
+ unwrapped?: string;
87
+ }
88
+ /**
89
+ * A stored secret to deliver as an environment variable: its name, or
90
+ * `{ name, version }` to pin a version. The latest version is used otherwise.
91
+ */
92
+ export type SandboxSecretReference = string | SandboxStoredSecretReference;
83
93
  /** Environment variable name to secret, at most 32 per process or sandbox. */
84
94
  export type SandboxSecrets = Record<string, SandboxSecretReference>;
95
+ /**
96
+ * A vault whose entries become environment variables: its name, or, when it
97
+ * has customer-protected entries, the `VaultReference` from
98
+ * `vaults.unwrap()` with their unwrapped envelopes.
99
+ */
100
+ export type SandboxVaultSource = string | VaultReference;
85
101
  /**
86
102
  * Fields of one 1Password vault to deliver as environment variables, read
87
103
  * with a service account token kept as an `op_token` secret when the process
88
104
  * starts. Nothing about it is stored.
89
105
  */
90
106
  export interface SandboxOnePassword {
91
- /** The name of the `op_token` secret; its latest version is used. */
92
- token: string;
107
+ /** The `op_token` secret: its name (its latest version is used), or a reference. */
108
+ token: string | SandboxStoredSecretReference;
93
109
  /** The 1Password vault's name or ID. */
94
110
  vault: string;
95
111
  /**
@@ -193,11 +209,11 @@ export type CreateSandboxParams = (SandboxCreateCommonParams & {
193
209
  */
194
210
  secrets?: SandboxSecrets;
195
211
  /**
196
- * A vault, by name, whose entries become the startup command's
197
- * environment variables; `secrets` is merged over it and wins on a
198
- * clash. Same requirements as `secrets`.
212
+ * A vault whose entries become the startup command's environment
213
+ * variables; `secrets` is merged over it and wins on a clash. Same
214
+ * requirements as `secrets`.
199
215
  */
200
- vault?: string;
216
+ vault?: SandboxVaultSource;
201
217
  /** 1Password fields for the startup command. Same requirements as `secrets`. */
202
218
  onePassword?: SandboxOnePassword;
203
219
  });
@@ -526,12 +542,12 @@ export interface SandboxExecParams {
526
542
  */
527
543
  secrets?: SandboxSecrets;
528
544
  /**
529
- * A vault, by name, whose entries become environment variables of this
530
- * process, delivered like `secrets`. `secrets` is merged over it and wins
531
- * on a clash; `env` can't set a variable either of them sets. Together
532
- * they hold at most 32 variables.
545
+ * A vault whose entries become environment variables of this process,
546
+ * delivered like `secrets`. `secrets` is merged over it and wins on a
547
+ * clash; `env` can't set a variable either of them sets. Together they hold
548
+ * at most 32 variables.
533
549
  */
534
- vault?: string;
550
+ vault?: SandboxVaultSource;
535
551
  /**
536
552
  * Fields of a 1Password vault, read with an `op_token` secret when the
537
553
  * process starts and delivered like `secrets`. A variable set here can't
@@ -1,5 +1,12 @@
1
+ import type { CustomerKey } from "../customer-key";
1
2
  /** A secret value: a UTF-8 string or its raw bytes, used byte-for-byte. */
2
3
  export type SecretValue = string | Uint8Array;
4
+ /**
5
+ * Fixed at creation. `"customer"` secrets are also wrapped with your own
6
+ * `CustomerKey`, and each use passes what `secrets.unwrap()` or
7
+ * `vaults.unwrap()` returns; they can't be filled into browser pages.
8
+ */
9
+ export type SecretProtection = "platform" | "customer";
3
10
  /**
4
11
  * What a secret's value is, fixed at creation:
5
12
  * - `"secret"`: an opaque value. It can be a sandbox environment variable,
@@ -45,6 +52,11 @@ export interface Secret {
45
52
  */
46
53
  type: string;
47
54
  metadata: SecretMetadata;
55
+ /**
56
+ * A `SecretProtection`, typed as a string for values added later. Absent
57
+ * from API versions before customer protection, which means `"platform"`.
58
+ */
59
+ protection?: string;
48
60
  /** Bound into every envelope for this secret; the SDK uses it when encrypting. */
49
61
  encryptionContext: string;
50
62
  /** Null until a value is stored. */
@@ -54,9 +66,67 @@ export interface Secret {
54
66
  }
55
67
  export interface SecretVersion {
56
68
  version: number;
69
+ /** The platform key the (inner) envelope was encrypted to. */
57
70
  kid: string;
71
+ /** The customer key that wrapped this version; customer-protected secrets only. */
72
+ outerKid?: string;
73
+ /**
74
+ * When this version stops working because its platform key is retired.
75
+ * After then, uses fail with `SECRET_KEY_RETIRED`; add a new version and use
76
+ * that instead.
77
+ */
78
+ retiresAt?: string | null;
58
79
  createdAt: string;
59
80
  }
81
+ /** A customer-protected version as the API stores it, for the customer to unwrap. */
82
+ export interface WrappedSecretVersion {
83
+ version: number;
84
+ /** The platform key the inner envelope is encrypted to. */
85
+ kid: string;
86
+ retiresAt: string | null;
87
+ /** The customer key that wrapped it. */
88
+ outerKid: string;
89
+ /** Unpadded base64url SHA-256 of the inner envelope. */
90
+ innerDigest: string;
91
+ /** The outer envelope, which only the customer key can open. */
92
+ envelope: string;
93
+ }
94
+ /**
95
+ * A customer-protected secret ready to use: pass it as a sandbox or process
96
+ * `secrets` entry, or as a 1Password `token`. It is the version's inner
97
+ * envelope, which only the platform can open, but anyone holding it can use
98
+ * that version, so treat it like the secret itself.
99
+ */
100
+ export interface UnwrappedSecretReference {
101
+ name: string;
102
+ version: number;
103
+ unwrapped: string;
104
+ }
105
+ export interface UnwrapSecretOptions {
106
+ /** Defaults to the latest version. */
107
+ version?: number | "latest";
108
+ }
109
+ export interface AddSecretVersionOptions {
110
+ /** Required for customer-protected secrets, which it wraps the value with; not allowed otherwise. */
111
+ customerKey?: CustomerKey;
112
+ }
113
+ /** A new outer envelope for a version, wrapping the same inner envelope. */
114
+ export interface ReplaceSecretVersionWrappingParams {
115
+ envelope: string;
116
+ /** Must match the version's `innerDigest`: rewrapping can't change the value. */
117
+ innerDigest: string;
118
+ }
119
+ export interface RewrapSecretParams {
120
+ /** The key (or keys, picked by `kid`) the versions are wrapped with now. */
121
+ from: CustomerKey | readonly CustomerKey[];
122
+ /** The key to wrap them with instead. */
123
+ to: CustomerKey;
124
+ /**
125
+ * Versions to rewrap. Defaults to every version not already wrapped with
126
+ * `to`, so an interrupted rotation can be run again.
127
+ */
128
+ versions?: number[];
129
+ }
60
130
  export interface SecretDetail extends Secret {
61
131
  versions: SecretVersion[];
62
132
  }
@@ -87,6 +157,16 @@ export interface CreateSecretParams {
87
157
  * `["https://github.com"]`; 1-20 entries. Not for `"op_token"` secrets.
88
158
  */
89
159
  allowedOrigins?: string[];
160
+ /**
161
+ * Defaults to `"customer"` when `customerKey` is given and `"platform"`
162
+ * otherwise. Fixed at creation.
163
+ */
164
+ protection?: SecretProtection;
165
+ /**
166
+ * The customer's own key, which wraps every version of a
167
+ * customer-protected secret. Required to store `value` in one.
168
+ */
169
+ customerKey?: CustomerKey;
90
170
  }
91
171
  /**
92
172
  * Metadata members sent replace the stored ones, `null` removes a member, and
@@ -1,6 +1,6 @@
1
1
  import fs from "fs";
2
2
  import { Country, DownloadsStatus, ISO639_1, OperatingSystem, Platform, RecordingStatus, SessionEventLogType, SessionRegion, State } from "./constants";
3
- import { SessionCredential, SessionCredentialSource } from "./credential";
3
+ import { SessionCredential, SessionCredentialSource, SessionVault } from "./credential";
4
4
  export type SessionStatus = "active" | "closed" | "close-error" | "error";
5
5
  export type BrowserMemorySize = "small" | "medium" | "large";
6
6
  export interface BasicResponse {
@@ -9,6 +9,7 @@ export interface BasicResponse {
9
9
  export interface SessionProfile {
10
10
  id: string;
11
11
  persistChanges?: boolean;
12
+ persistNetworkCache?: boolean;
12
13
  }
13
14
  /** How a session signs its requests with Web Bot Auth. */
14
15
  export interface SessionWebBotAuth {
@@ -48,6 +49,8 @@ export interface SessionLaunchState {
48
49
  enableAlwaysOpenPdfExternally?: boolean;
49
50
  appendTimestampToDownloads?: boolean;
50
51
  disablePostQuantumKeyAgreement?: boolean;
52
+ /** @deprecated Discontinued: WebGL fingerprinting was removed from the browser, and the server ignores this option. Kept so existing code still type-checks. */
53
+ enableWebglFingerprinting?: boolean;
51
54
  }
52
55
  export interface SessionCreditBreakdown {
53
56
  creditsUsed: number | null;
@@ -66,6 +69,8 @@ export interface Session {
66
69
  launchState?: SessionLaunchState | null;
67
70
  creditsUsed: number | null;
68
71
  creditBreakdown: SessionCreditBreakdown;
72
+ duration?: number;
73
+ proxyDataConsumed?: string;
69
74
  }
70
75
  export interface SessionDetail extends Session {
71
76
  wsEndpoint: string;
@@ -76,6 +81,8 @@ export interface SessionDetail extends Session {
76
81
  token: string;
77
82
  /** The secrets attached at creation, when any were requested. */
78
83
  credentials?: SessionCredential[];
84
+ /** The vaults attached at creation, by reference, when credentials were requested. */
85
+ vaults?: SessionVault[];
79
86
  }
80
87
  export interface SessionGetParams {
81
88
  liveViewTtlSeconds?: number;
@@ -213,6 +220,7 @@ export interface CreateSessionParams {
213
220
  saveDownloads?: boolean;
214
221
  imageCaptchaParams?: Array<ImageCaptchaParam>;
215
222
  timeoutMinutes?: number;
223
+ /** @deprecated Discontinued: WebGL fingerprinting was removed from the browser, and the server ignores this option. Kept so existing code still type-checks. */
216
224
  enableWebglFingerprinting?: boolean;
217
225
  enableWindowManager?: boolean;
218
226
  enableWindowManagerTaskbar?: boolean;
@@ -230,13 +238,13 @@ export interface CreateSessionParams {
230
238
  startFromSnapshot?: StartSessionFromSnapshotParams;
231
239
  /**
232
240
  * Secrets that `sessions.credentials.fill` may type into pages, at most 20:
233
- * a secret's name (or `{ secret: name }`), `{ vault: name }` for the
234
- * secrets a vault's entries name when the session is created, or
241
+ * a secret's name (or `{ secret: name }`), `{ vault: name }` for a vault
242
+ * by reference, whose entries each fill reads as they are then, or
235
243
  * `{ onePassword: name }` for an `op_token` secret whose 1Password fields
236
244
  * fills may read.
237
- * Secrets need allowed origins to be filled. They can only be attached at
238
- * creation; the session runs on Firecracker with Chrome's password manager
239
- * off.
245
+ * Secrets need allowed origins to be filled, and customer-protected ones
246
+ * can't be filled. They can only be attached at creation; the session runs
247
+ * on Firecracker with Chrome's password manager off.
240
248
  */
241
249
  credentials?: SessionCredentialSource[];
242
250
  }
@@ -1,3 +1,4 @@
1
+ import type { WrappedSecretVersion } from "./secret";
1
2
  /** An entry of a vault: a stored secret. */
2
3
  export interface VaultEntry {
3
4
  /** The secret's name. */
@@ -5,6 +6,39 @@ export interface VaultEntry {
5
6
  secretId: string;
6
7
  /** A pinned version, or null to follow the secret's latest version. */
7
8
  version: number | null;
9
+ /**
10
+ * The secret's `SecretProtection`. With `"customer"`, each use of the vault
11
+ * passes this entry's unwrapped envelope (see `vaults.unwrap()`). Absent
12
+ * from API versions before customer protection.
13
+ */
14
+ protection?: string;
15
+ }
16
+ /** A customer-protected entry's wrapped envelope, at the version the entry resolves to now. */
17
+ export interface WrappedVaultEntry extends WrappedSecretVersion {
18
+ /** The secret's name. */
19
+ name: string;
20
+ secretId: string;
21
+ }
22
+ export interface WrappedVault {
23
+ id: string;
24
+ name: string;
25
+ /** Customer-protected entries only, by environment variable. */
26
+ entries: Record<string, WrappedVaultEntry>;
27
+ }
28
+ /** The envelope the customer unwrapped for one entry, and the version it is from. */
29
+ export interface VaultUnwrappedEntry {
30
+ version: number;
31
+ unwrapped: string;
32
+ }
33
+ /**
34
+ * A vault with its customer-protected entries unwrapped, as `vaults.unwrap()`
35
+ * returns it, for a sandbox's or process's `vault`. Anyone holding it can use
36
+ * those versions.
37
+ */
38
+ export interface VaultReference {
39
+ name: string;
40
+ /** Environment variable name to unwrapped envelope; at most 32. */
41
+ unwrapped: Record<string, VaultUnwrappedEntry>;
8
42
  }
9
43
  /** Named environment variables whose values come from stored secrets. A vault holds no values itself. */
10
44
  export interface Vault {
@@ -16,7 +50,10 @@ export interface Vault {
16
50
  createdAt: string;
17
51
  updatedAt: string;
18
52
  }
19
- /** A stored secret, following its latest version unless one is pinned. */
53
+ /**
54
+ * A stored secret, following its latest version unless one is pinned. It may
55
+ * be customer-protected; entries never hold unwrapped envelopes.
56
+ */
20
57
  export interface VaultEntryParams {
21
58
  /** The secret's name. */
22
59
  name: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hyperbrowser/sdk",
3
- "version": "1.4.1",
3
+ "version": "1.5.1",
4
4
  "description": "Node SDK for Hyperbrowser API",
5
5
  "author": "",
6
6
  "repository": {