phonesinc 2.0.1 → 2.1.0

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/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Phones Inc public SDK
2
+
3
+ `phonesinc@2.0.2` lets a member login or organization API key manage its organization's virtual phones without naming a Mac: `provider` is optional in `virtualPhones.get`, `create`, `start` and `stop`. Calls that pass `provider` work as in 2.0.1. Public SDK source was restored from the published 2.0.0 source commit `f4565a2433497d77255193411d5f85c70602eb07` before the 2.0.1 change.
4
+
5
+ ```ts
6
+ import { PhonesInc } from "phonesinc";
7
+ const api = new PhonesInc({ token: process.env.PHONESINC_LOGIN_TOKEN! });
8
+ const created = await api.virtualPhones.create({
9
+ name: "My iPhone", idempotencyKey: "one-stable-request-key",
10
+ });
11
+ const inventory = await api.virtualPhones.get();
12
+ // Wait for state=running before starting an ordinary control session.
13
+ const session = await api.session.start({ phoneIds: ["<returned phone id>"] });
14
+ await api.key({ phoneIds: ["<returned phone id>"], key: "home" });
15
+ await api.session.end({ phoneIds: ["<returned phone id>"] });
16
+ await api.virtualPhones.stop({ phoneId: "<returned phone id>" });
17
+ await api.virtualPhones.start({ phoneId: "<returned phone id>" });
18
+ ```
19
+
20
+ An administrator login can also list the Macs and name one:
21
+
22
+ ```ts
23
+ const hosts = await api.virtualPhones.hosts();
24
+ const onMac = await api.virtualPhones.get({ provider: "VPhoneMacT0432" });
25
+ ```
26
+
27
+ Every call returns `{ok:true,data}` or `{ok:false,error}`. Check this before using `data`. Creation and start return durable operation state; poll inventory until `running` or `error`. Reuse the same creation key after an uncertain response: the phone keeps its organization, and the retry returns it. A key reused with another name fails. Mutations are never automatically replayed.
28
+
29
+ Virtual phones belong to an organization. A member login or organization API key lists, creates, starts and stops only its own organizations' virtual phones. A new phone belongs to the caller's organization. A member of several organizations selects one with the `organizationId` client or request option. Creation keys are separate per organization: the same key in two organizations makes two phones. An administrator's new phone belongs to the default organization. Listing hosts requires an administrator login. Ordinary sessions, screenshots, touch, text and key calls retain their existing organization and session-holder checks. End the active session before starting or stopping a phone. The Mac admits one running VM and preserves stopped phones.
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { VirtualPhone, VirtualPhoneHost, VirtualPhoneTarget, ApiResponse, App, AppiumRequest, AppRequest, ClientOptions, Endpoint, FileExport, Identity, KeyRequest, Media, MediaImported, MediaImportFailed, MediaImporting, MediaImportStatusRequest, MediaSource, MediaUploadRequest, OptionalEndpoint, Phone, PhoneFile, PhoneResult, PhoneSelection, PhoneTargets, RequestOptions, ScreenRequest, Screenshot, Session, Stream, TouchRequest, TypeRequest } from "./types.js";
1
+ import type { VirtualPhone, VirtualPhoneHost, VirtualPhoneTarget, ApiResponse, App, AppiumRequest, AppRequest, AuthenticatorAddRequest, AuthenticatorCode, AuthenticatorEntry, AuthenticatorUpdateRequest, ClientOptions, Endpoint, FileExport, Identity, KeyRequest, Media, MediaImported, MediaImportFailed, MediaImporting, MediaImportStatusRequest, MediaSource, MediaUploadRequest, OptionalEndpoint, Phone, PhoneFile, PhoneResult, PhoneSelection, PhoneTargets, Rental, RentRequest, RequestOptions, ScreenRequest, Screenshot, Session, Stream, TouchRequest, TypeRequest, VerificationService } from "./types.js";
2
2
  export type * from "./types.js";
3
3
  /** Public phone operations. A request is sent once; actions are never replayed. */
4
4
  export declare class PhonesInc {
@@ -12,17 +12,22 @@ export declare class PhonesInc {
12
12
  private required;
13
13
  private optional;
14
14
  private custom;
15
- /** Requires an administrator login token. Creation is idempotent by key. */
15
+ /**
16
+ * An organization's virtual phones: a member login or organization API key
17
+ * lists, creates, starts and stops its own; `provider` may be omitted (the
18
+ * API picks the Mac). `hosts` requires an administrator login. Creation is
19
+ * idempotent by key within the organization.
20
+ */
16
21
  readonly virtualPhones: {
17
22
  hosts: OptionalEndpoint<Record<never, never>, VirtualPhoneHost[]>;
18
- get: Endpoint<{
19
- provider: string;
23
+ get: OptionalEndpoint<{
24
+ provider?: string;
20
25
  }, {
21
26
  machines: VirtualPhone[];
22
27
  runningLimit: number;
23
28
  }>;
24
29
  create: Endpoint<{
25
- provider: string;
30
+ provider?: string;
26
31
  name: string;
27
32
  idempotencyKey: string;
28
33
  }, VirtualPhone>;
@@ -126,6 +131,36 @@ export declare class PhonesInc {
126
131
  }, PhoneResult[]>;
127
132
  };
128
133
  readonly stream: OptionalEndpoint<PhoneSelection, Stream>;
134
+ /** The organization's 2FA codes. */
135
+ readonly authenticator: {
136
+ get: OptionalEndpoint<{
137
+ phone?: string;
138
+ }, AuthenticatorEntry[]>;
139
+ add: Endpoint<AuthenticatorAddRequest, AuthenticatorEntry>;
140
+ code: Endpoint<{
141
+ id: string;
142
+ }, AuthenticatorCode>;
143
+ update: Endpoint<AuthenticatorUpdateRequest, AuthenticatorEntry>;
144
+ delete: Endpoint<{
145
+ id: string;
146
+ }, {
147
+ id: string;
148
+ }>;
149
+ };
150
+ /** Rent an email address or phone number for a service and read the code sent to it. */
151
+ readonly verification: {
152
+ services: OptionalEndpoint<{
153
+ search?: string;
154
+ }, VerificationService[]>;
155
+ rent: Endpoint<RentRequest, Rental>;
156
+ rental: Endpoint<{
157
+ id: string;
158
+ }, Rental>;
159
+ rentals: OptionalEndpoint<Record<never, never>, Rental[]>;
160
+ cancel: Endpoint<{
161
+ id: string;
162
+ }, Rental>;
163
+ };
129
164
  /** Raw WebDriver responses, including WebDriver errors, are returned unchanged. */
130
165
  readonly appium: ((body: AppiumRequest, options?: RequestOptions) => Promise<Response>) & {
131
166
  readonly endpoint: string;
package/dist/index.js CHANGED
@@ -83,10 +83,15 @@ export class PhonesInc {
83
83
  custom(path, run) {
84
84
  return named(path, (body, options = {}) => run(path, body, options));
85
85
  }
86
- /** Requires an administrator login token. Creation is idempotent by key. */
86
+ /**
87
+ * An organization's virtual phones: a member login or organization API key
88
+ * lists, creates, starts and stops its own; `provider` may be omitted (the
89
+ * API picks the Mac). `hosts` requires an administrator login. Creation is
90
+ * idempotent by key within the organization.
91
+ */
87
92
  virtualPhones = {
88
93
  hosts: this.optional("/v1/virtual-phones/hosts"),
89
- get: this.required("/v1/virtual-phones"),
94
+ get: this.optional("/v1/virtual-phones"),
90
95
  create: this.required("/v1/virtual-phones/create"),
91
96
  start: this.required("/v1/virtual-phones/start"),
92
97
  stop: this.required("/v1/virtual-phones/stop"),
@@ -186,6 +191,22 @@ export class PhonesInc {
186
191
  set: this.required("/v1/clipboard/set"),
187
192
  };
188
193
  stream = this.optional("/v1/stream");
194
+ /** The organization's 2FA codes. */
195
+ authenticator = {
196
+ get: this.optional("/v1/authenticator"),
197
+ add: this.required("/v1/authenticator/add"),
198
+ code: this.required("/v1/authenticator/code"),
199
+ update: this.required("/v1/authenticator/update"),
200
+ delete: this.required("/v1/authenticator/delete"),
201
+ };
202
+ /** Rent an email address or phone number for a service and read the code sent to it. */
203
+ verification = {
204
+ services: this.optional("/v1/verification/services"),
205
+ rent: this.required("/v1/verification/rent"),
206
+ rental: this.required("/v1/verification/rental"),
207
+ rentals: this.optional("/v1/verification/rentals"),
208
+ cancel: this.required("/v1/verification/cancel"),
209
+ };
189
210
  /** Raw WebDriver responses, including WebDriver errors, are returned unchanged. */
190
211
  appium = this.custom("/v1/appium", async (path, request, options) => {
191
212
  const base = `${this.baseUrl}${path}`;
package/dist/types.d.ts CHANGED
@@ -60,6 +60,35 @@ export type Media = {
60
60
  url: string;
61
61
  createdAt: string;
62
62
  };
63
+ export type AuthenticatorApp = "tiktok" | "instagram";
64
+ /** A 2FA (TOTP) entry with its current code; the secret is never returned. */
65
+ export type AuthenticatorEntry = {
66
+ id: string;
67
+ app: AuthenticatorApp;
68
+ label: string;
69
+ phone: string | null;
70
+ code: string;
71
+ expiresAt: string;
72
+ createdAt: string;
73
+ };
74
+ export type AuthenticatorCode = {
75
+ code: string;
76
+ expiresAt: string;
77
+ };
78
+ /** `secret` is the setup key or an otpauth:// URI. */
79
+ export type AuthenticatorAddRequest = {
80
+ app: AuthenticatorApp;
81
+ label: string;
82
+ secret: string;
83
+ phone?: string;
84
+ };
85
+ /** `phone: null` unlinks the phone. */
86
+ export type AuthenticatorUpdateRequest = {
87
+ id: string;
88
+ label?: string;
89
+ app?: AuthenticatorApp;
90
+ phone?: string | null;
91
+ };
63
92
  export type Identity = {
64
93
  organization: {
65
94
  id: string;
@@ -95,6 +124,33 @@ export type Screenshot = {
95
124
  elements?: Element[];
96
125
  annotatedImageUrl?: string;
97
126
  };
127
+ /** A service you can rent an email address or phone number for. */
128
+ export type VerificationService = {
129
+ id: string;
130
+ name: string;
131
+ email: {
132
+ available: number;
133
+ };
134
+ phone: {
135
+ available: boolean;
136
+ };
137
+ };
138
+ /** A rented email address or phone number and the code sent to it. */
139
+ export type Rental = {
140
+ id: string;
141
+ type: "email" | "phone";
142
+ service: string;
143
+ address: string;
144
+ status: "active" | "completed" | "expired" | "cancelled";
145
+ code: string | null;
146
+ codeReceivedAt: string | null;
147
+ expiresAt: string;
148
+ createdAt: string;
149
+ };
150
+ export type RentRequest = {
151
+ type: "email" | "phone";
152
+ service: string;
153
+ };
98
154
  export type FileExport = {
99
155
  url: string;
100
156
  filename: string;
@@ -244,7 +300,7 @@ export type AppiumRequest = {
244
300
  path: string;
245
301
  body?: unknown;
246
302
  };
247
- /** Administrator-only Mac VM lifecycle; normal sessions authorize input. */
303
+ /** An organization's Mac VM; normal sessions authorize input. */
248
304
  export type VirtualPhone = {
249
305
  id: string;
250
306
  name: string;
@@ -253,8 +309,9 @@ export type VirtualPhone = {
253
309
  createdAt: number;
254
310
  updatedAt: number;
255
311
  };
312
+ /** `provider` is optional: the phone's own record names its Mac. */
256
313
  export type VirtualPhoneTarget = {
257
- provider: string;
314
+ provider?: string;
258
315
  phoneId: string;
259
316
  };
260
317
  export type VirtualPhoneHost = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phonesinc",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "description": "The public Phones Inc API client",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",