@revyl/verify 0.0.0-stage → 0.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/CHANGELOG.md +15 -0
- package/LICENSE +201 -0
- package/README.md +100 -2
- package/SECURITY.md +13 -0
- package/dist/api/client.d.ts +63 -0
- package/dist/api/client.js +201 -0
- package/dist/api/types.d.ts +216 -0
- package/dist/api/types.js +1 -0
- package/dist/auth.d.ts +17 -0
- package/dist/auth.js +65 -0
- package/dist/cleanup.d.ts +13 -0
- package/dist/cleanup.js +72 -0
- package/dist/cli/init.d.ts +14 -0
- package/dist/cli/init.js +116 -0
- package/dist/cli/main.d.ts +3 -0
- package/dist/cli/main.js +127 -0
- package/dist/computer-session.d.ts +37 -0
- package/dist/computer-session.js +322 -0
- package/dist/config.d.ts +88 -0
- package/dist/config.js +212 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.js +14 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.js +3 -0
- package/dist/open.d.ts +13 -0
- package/dist/open.js +36 -0
- package/dist/session.d.ts +144 -0
- package/dist/session.js +411 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +6 -0
- package/docs/README.md +18 -0
- package/docs/agents.md +38 -0
- package/docs/api.md +108 -0
- package/docs/ci.md +70 -0
- package/docs/computers.md +73 -0
- package/docs/configuration.md +91 -0
- package/docs/errors.md +38 -0
- package/docs/getting-started.md +79 -0
- package/docs/linux-computers-contract.md +107 -0
- package/docs/llms.txt +18 -0
- package/docs/mobile.md +43 -0
- package/docs/web.md +43 -0
- package/package.json +68 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## 0.1.0
|
|
4
|
+
|
|
5
|
+
Initial release preparation; this entry does not mean the package has been published.
|
|
6
|
+
|
|
7
|
+
- Open Revyl cloud web browsers, iOS simulators, and Android emulators from TypeScript.
|
|
8
|
+
- Run natural-language instruction and validation steps, with typed failures and optional soft validation results.
|
|
9
|
+
- Save screenshots, share session links, and close sessions explicitly or during best-effort process cleanup.
|
|
10
|
+
- Configure named targets and initialize a script with the `verify` or `revyl-verify` command.
|
|
11
|
+
- Use environment credentials or an existing Revyl CLI login, with documentation included in the package.
|
|
12
|
+
- Include **early-access Mac computers, not yet available in Revyl production**, for commands, binary files, process handles, screenshots, and confirmed-release cleanup. Mac works only on Revyl staging for enabled organizations through the optional `REVYL_BACKEND_URL` override and matching credentials; ask support@revyl.ai about access.
|
|
13
|
+
- Reserve Linux target types and document the future contract; opening Linux is not available in this release.
|
|
14
|
+
|
|
15
|
+
Requires Node.js 22.18 or later and a Revyl account. There is no bundled test runner or step replay. Mac operations remain covered by source-aligned fake-API tests; a production start never reached active, so it did not prove any operation or confirmed cleanup.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright [yyyy] [name of copyright owner]
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Verify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Open cloud browsers and mobile devices for Revyl's agent, or a Mac computer for commands and files, from TypeScript.**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
import { open } from '@revyl/verify';
|
|
7
|
+
|
|
8
|
+
const session = await open('ios');
|
|
9
|
+
await session.instruction('Add the first product to the cart and open the cart');
|
|
10
|
+
await session.validation('The cart lists one item with a price');
|
|
11
|
+
await session.close();
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npx @revyl/verify init # writes verify.config.ts and verify/example.ts
|
|
16
|
+
node verify/example.ts # opens the session, prints a link to watch it live, runs the steps
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Verify is a small TypeScript library on top of [Revyl](https://revyl.com). Open a browser or mobile device for **instruction** and **validation** steps, or a Mac computer for commands, files, processes, and screenshots. It has no test framework of its own, so you call it from wherever you already write code:
|
|
20
|
+
|
|
21
|
+
- **A plain script.** A failed validation throws, the script exits non-zero, and Verify closes the session on the way out.
|
|
22
|
+
- **A coding agent.** An agent can check its own change on a real device in five lines, then read a one-line outcome per step and a link to the recording.
|
|
23
|
+
- **CI.** Run the script in a job. The browsers and devices run in Revyl's cloud, so the runner needs nothing but Node and an API key.
|
|
24
|
+
- **Your test runner.** Call it inside node:test, Vitest, Jest, or Playwright Test, next to the tests you already have.
|
|
25
|
+
|
|
26
|
+
## Quick start
|
|
27
|
+
|
|
28
|
+
You need Node.js 22.18 or later and a Revyl account.
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npx @revyl/verify init
|
|
32
|
+
npm install --save-dev @revyl/verify
|
|
33
|
+
export REVYL_API_KEY=... # or sign in with the Revyl CLI: revyl auth login
|
|
34
|
+
node verify/example.ts
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
Full walkthrough: [getting started](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/getting-started.md).
|
|
38
|
+
|
|
39
|
+
## The API
|
|
40
|
+
|
|
41
|
+
| Call | What it does |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| `open(target)` | Starts a Revyl cloud browser, device, or Mac computer, from a target name in `verify.config.ts` or a target object, and waits until it is ready |
|
|
44
|
+
| `session.exec(argv, options?)` | Runs structured argv on a Mac computer; returns `{ exitCode, stdout, stderr }` |
|
|
45
|
+
| `session.readFile(path)`, `writeFile(path, data)`, `stat(path)` | Reads a `Buffer`, writes a string or bytes, or returns `{ kind, size }` on a computer |
|
|
46
|
+
| `session.processes()`, `terminate(id)` | Lists run-owned process handles or terminates one on a computer |
|
|
47
|
+
| `session.instruction(text)` | Revyl's agent does what the text says. Throws `INSTRUCTION_FAILED` if it cannot. |
|
|
48
|
+
| `session.validation(text)` | Revyl's agent checks that the text holds on screen. Throws `VALIDATION_FAILED` if it does not, or returns the result with `{ soft: true }`. |
|
|
49
|
+
| `session.screenshot({ path })` | A PNG of the screen |
|
|
50
|
+
| `session.viewerUrl` | The session in Revyl: live while it runs, its recording after |
|
|
51
|
+
| `session.close()` | Stops the session. Verify also closes open sessions on Ctrl+C, on an uncaught error, and when a script ends without closing. |
|
|
52
|
+
|
|
53
|
+
Revyl failures are `VerifyError`s with a stable code, a safe reason, and the session link when one exists.
|
|
54
|
+
|
|
55
|
+
## Platforms
|
|
56
|
+
|
|
57
|
+
| | Web | iOS | Android | Mac | Linux |
|
|
58
|
+
| --- | --- | --- | --- | --- | --- |
|
|
59
|
+
| Runs on | Revyl cloud browser | Revyl iOS simulator | Revyl Android emulator | Revyl macOS computer | Contract only; open unavailable |
|
|
60
|
+
| Opens | A public URL, or a web build in Revyl | A build in Revyl, a build URL, or an installed app | A build in Revyl, a build URL, or an installed app | A workspace, no app id | Nothing in this release |
|
|
61
|
+
| `instruction`, `validation` | Yes | Yes | Yes | Unavailable | Unavailable |
|
|
62
|
+
| Commands, files, processes | Unavailable | Unavailable | Unavailable | Early access on staging only for enabled organizations; not yet available in Revyl production | Contract only |
|
|
63
|
+
| `screenshot`, `viewerUrl` | Yes | Yes | Yes | Yes | Unconfirmed |
|
|
64
|
+
|
|
65
|
+
Steps on web go through the same Revyl API as on mobile. Production is the default; optional environment overrides are documented in [web.md](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/web.md). A backend without web-step support returns `NOT_AVAILABLE_ON_PLATFORM`.
|
|
66
|
+
|
|
67
|
+
Each step runs Revyl's agent on the live session every time. Verify does not cache or replay steps, and Revyl does not carry values from one step to the next.
|
|
68
|
+
|
|
69
|
+
For a Mac workspace, run `npx @revyl/verify init --platform mac`; it generates a command and file-round-trip script with no app id or agent steps. Mac computers are early access and not yet available in Revyl production. They work only on Revyl staging for enabled organizations using the optional `REVYL_BACKEND_URL` override and matching credentials. Linux targets are typed but `open()` rejects them with `NOT_AVAILABLE_ON_PLATFORM` before credentials or network access. See [computers](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#availability-and-errors) and the [Linux contract](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/linux-computers-contract.md).
|
|
70
|
+
|
|
71
|
+
## Docs
|
|
72
|
+
|
|
73
|
+
- [Getting started](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/getting-started.md) and [API](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/api.md)
|
|
74
|
+
- [Configuration and CLI](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/configuration.md)
|
|
75
|
+
- [Web](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/web.md) and [iOS and Android](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/mobile.md)
|
|
76
|
+
- [Mac computers](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md) and the [deferred Linux contract](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/linux-computers-contract.md)
|
|
77
|
+
- [CI and test runners](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/ci.md) and [error codes](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/errors.md)
|
|
78
|
+
- [For coding agents](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/agents.md)
|
|
79
|
+
|
|
80
|
+
Examples: [web store](https://github.com/RevylAI/verify/tree/main/examples/web-store), [mobile settings](https://github.com/RevylAI/verify/tree/main/examples/mobile-settings), and [Mac workspace](https://github.com/RevylAI/verify/tree/main/examples/mac-workspace).
|
|
81
|
+
|
|
82
|
+
## How it works
|
|
83
|
+
|
|
84
|
+
Verify is a client for [Revyl's public API](https://docs.revyl.com). `open()` starts a device session (registering a web URL as a build first when needed) and waits until it is ready. Each instruction or validation runs as a live step on the session: Verify submits it, polls its status until Revyl reports a result, and cancels it on Revyl if it runs past its timeout. `close()` stops the session. Requests identify themselves with `X-Revyl-Client: verify` and a `revyl-verify/<version>` user agent.
|
|
85
|
+
|
|
86
|
+
For computers, `open()` creates a computer run and waits for its report to become active. Commands use request UUIDs and async operation polling without resubmitting mutations; `close()` stops the run. See [the computer transport](https://github.com/RevylAI/verify/blob/main/packages/verify/docs/computers.md#lifecycle-and-transport).
|
|
87
|
+
|
|
88
|
+
## Develop
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npm install
|
|
92
|
+
npm run build
|
|
93
|
+
npm test # unit tests against a mocked Revyl API; no account needed
|
|
94
|
+
npm run typecheck
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
The library lives in [`packages/verify`](https://github.com/RevylAI/verify/tree/main/packages/verify) and the examples in [`examples/`](https://github.com/RevylAI/verify/tree/main/examples). Read [Contributing](https://github.com/RevylAI/verify/blob/main/CONTRIBUTING.md), [Security](https://github.com/RevylAI/verify/blob/main/SECURITY.md), and [Releasing](https://github.com/RevylAI/verify/blob/main/RELEASING.md) before changing or publishing the package.
|
|
98
|
+
|
|
99
|
+
## License
|
|
100
|
+
|
|
101
|
+
[Apache 2.0](https://github.com/RevylAI/verify/blob/main/LICENSE)
|
package/SECURITY.md
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Security
|
|
2
|
+
|
|
3
|
+
## Reporting a vulnerability
|
|
4
|
+
|
|
5
|
+
Email **support@revyl.ai** with the subject “Verify security report”. Do not open a public issue for a vulnerability or include API keys, session tokens, customer data, or screenshots containing sensitive information. Share a minimal reproduction with placeholders and affected versions; arrange a private channel before sending sensitive evidence.
|
|
6
|
+
|
|
7
|
+
The maintainers review reports and coordinate fixes and disclosure. No response-time commitment is promised. Before the first release, report against the current source revision; afterward, security fixes target the latest published version.
|
|
8
|
+
|
|
9
|
+
## Safe use
|
|
10
|
+
|
|
11
|
+
Verify starts paid remote sessions and can act on your application. Use test accounts and non-production data, explicitly authorize each workload, and close sessions in `finally`. Automatic shutdown is best effort and cannot run after a forced kill. Keep credentials in environment variables or the Revyl CLI credential store, not in source or config. Step descriptions are sent to Revyl and printed to stderr by default; do not embed private credentials or customer data in them. Treat screenshots and session reports as potentially sensitive.
|
|
12
|
+
|
|
13
|
+
Only install the package name documented in the README. The unscoped npm package named `verify` is unrelated; outside an installation, use `npx @revyl/verify`, not `npx verify`.
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { VerifyError } from '../errors.js';
|
|
2
|
+
import type { AppResponse, BuildResponse, DeviceSessionDetail, DeviceSessionStopResponse, StartDeviceRequest, StartDeviceResponse, WhoAmI, WorkerConnection } from './types.js';
|
|
3
|
+
export declare const DEFAULT_BACKEND_URL = "https://backend.revyl.ai";
|
|
4
|
+
export declare const DEFAULT_APP_URL = "https://app.revyl.ai";
|
|
5
|
+
/** Sent on every request so Revyl can attribute sessions that Verify starts. */
|
|
6
|
+
export declare const CLIENT_HEADER_VALUE = "verify";
|
|
7
|
+
export interface RevylClientOptions {
|
|
8
|
+
token: string;
|
|
9
|
+
backendUrl?: string;
|
|
10
|
+
fetch?: typeof fetch;
|
|
11
|
+
requestTimeoutMs?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface RequestOptions {
|
|
14
|
+
body?: unknown;
|
|
15
|
+
query?: Record<string, string | string[] | undefined>;
|
|
16
|
+
timeoutMs?: number;
|
|
17
|
+
retry?: boolean;
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
headers?: Record<string, string>;
|
|
20
|
+
}
|
|
21
|
+
export interface RawResponse {
|
|
22
|
+
status: number;
|
|
23
|
+
headers: Headers;
|
|
24
|
+
body: Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
export declare class RevylClient {
|
|
27
|
+
readonly backendUrl: string;
|
|
28
|
+
private readonly token;
|
|
29
|
+
private readonly fetchImpl;
|
|
30
|
+
private readonly requestTimeoutMs;
|
|
31
|
+
constructor(options: RevylClientOptions);
|
|
32
|
+
send(method: 'GET' | 'POST', path: string, options?: RequestOptions): Promise<RawResponse>;
|
|
33
|
+
json<T>(method: 'GET' | 'POST', path: string, options?: RequestOptions): Promise<T>;
|
|
34
|
+
startDevice(request: StartDeviceRequest, signal?: AbortSignal): Promise<StartDeviceResponse>;
|
|
35
|
+
getDeviceSession(sessionId: string, signal?: AbortSignal): Promise<DeviceSessionDetail>;
|
|
36
|
+
getWorkerConnection(workflowRunId: string, signal?: AbortSignal): Promise<WorkerConnection>;
|
|
37
|
+
stopDeviceSession(sessionId: string): Promise<DeviceSessionStopResponse>;
|
|
38
|
+
cancelDevice(workflowRunId: string): Promise<unknown>;
|
|
39
|
+
getApp(appId: string, signal?: AbortSignal): Promise<AppResponse>;
|
|
40
|
+
registerWebUrlBuild(appId: string, request: {
|
|
41
|
+
url: string;
|
|
42
|
+
branch_name?: string;
|
|
43
|
+
}, signal?: AbortSignal): Promise<BuildResponse>;
|
|
44
|
+
latestWebBuild(appId: string, branch: {
|
|
45
|
+
branchId?: string;
|
|
46
|
+
branchName?: string;
|
|
47
|
+
}, signal?: AbortSignal): Promise<BuildResponse | undefined>;
|
|
48
|
+
whoAmI(): Promise<WhoAmI>;
|
|
49
|
+
worker(workflowRunId: string, action: string, options: {
|
|
50
|
+
method: 'GET' | 'POST';
|
|
51
|
+
body?: unknown;
|
|
52
|
+
timeoutMs?: number;
|
|
53
|
+
signal?: AbortSignal;
|
|
54
|
+
retry?: boolean;
|
|
55
|
+
}): Promise<RawResponse>;
|
|
56
|
+
private sendOnce;
|
|
57
|
+
}
|
|
58
|
+
export declare function appUrl(): string;
|
|
59
|
+
export declare function sessionViewerUrl(sessionId: string, kind?: 'computer'): string;
|
|
60
|
+
export declare function parseJson<T>(response: RawResponse, what: string): T;
|
|
61
|
+
export declare function responseDetail(response: RawResponse): string | undefined;
|
|
62
|
+
export declare function responseErrorCode(response: RawResponse): string | undefined;
|
|
63
|
+
export declare function apiError(method: string, path: string, response: RawResponse): VerifyError;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import { setTimeout as delay } from 'node:timers/promises';
|
|
2
|
+
import { VerifyError, errorMessage } from '../errors.js';
|
|
3
|
+
import { VERSION } from '../version.js';
|
|
4
|
+
export const DEFAULT_BACKEND_URL = 'https://backend.revyl.ai';
|
|
5
|
+
export const DEFAULT_APP_URL = 'https://app.revyl.ai';
|
|
6
|
+
/** Sent on every request so Revyl can attribute sessions that Verify starts. */
|
|
7
|
+
export const CLIENT_HEADER_VALUE = 'verify';
|
|
8
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 30_000;
|
|
9
|
+
const RETRY_DELAYS_MS = [500, 1500];
|
|
10
|
+
const RETRYABLE_STATUSES = new Set([502, 503, 504]);
|
|
11
|
+
export class RevylClient {
|
|
12
|
+
backendUrl;
|
|
13
|
+
token;
|
|
14
|
+
fetchImpl;
|
|
15
|
+
requestTimeoutMs;
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.token = options.token;
|
|
18
|
+
this.backendUrl = validateBackendUrl(options.backendUrl ?? process.env.REVYL_BACKEND_URL ?? DEFAULT_BACKEND_URL);
|
|
19
|
+
this.fetchImpl = options.fetch ?? fetch;
|
|
20
|
+
this.requestTimeoutMs = options.requestTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
|
|
21
|
+
}
|
|
22
|
+
async send(method, path, options = {}) {
|
|
23
|
+
const url = new URL(path, this.backendUrl);
|
|
24
|
+
for (const [key, value] of Object.entries(options.query ?? {})) {
|
|
25
|
+
if (value === undefined)
|
|
26
|
+
continue;
|
|
27
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
28
|
+
url.searchParams.append(key, item);
|
|
29
|
+
}
|
|
30
|
+
const retry = options.retry ?? method === 'GET';
|
|
31
|
+
const attempts = retry ? RETRY_DELAYS_MS.length + 1 : 1;
|
|
32
|
+
for (let attempt = 1;; attempt += 1) {
|
|
33
|
+
const outcome = await this.sendOnce(method, url, options);
|
|
34
|
+
const retryable = outcome instanceof Error || RETRYABLE_STATUSES.has(outcome.status);
|
|
35
|
+
if (!retryable || attempt >= attempts || options.signal?.aborted) {
|
|
36
|
+
if (outcome instanceof Error)
|
|
37
|
+
throw outcome;
|
|
38
|
+
return outcome;
|
|
39
|
+
}
|
|
40
|
+
await delay(RETRY_DELAYS_MS[attempt - 1] ?? 1500, undefined, { signal: options.signal }).catch(() => undefined);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
async json(method, path, options = {}) {
|
|
44
|
+
const response = await this.send(method, path, options);
|
|
45
|
+
if (response.status < 200 || response.status >= 300)
|
|
46
|
+
throw apiError(method, path, response);
|
|
47
|
+
return parseJson(response, `${method} ${path}`);
|
|
48
|
+
}
|
|
49
|
+
startDevice(request, signal) {
|
|
50
|
+
return this.json('POST', '/api/v1/execution/start_device', { body: request, retry: false, timeoutMs: 120_000, signal });
|
|
51
|
+
}
|
|
52
|
+
getDeviceSession(sessionId, signal) {
|
|
53
|
+
return this.json('GET', `/api/v1/execution/device-sessions/${encodeURIComponent(sessionId)}`, { signal });
|
|
54
|
+
}
|
|
55
|
+
getWorkerConnection(workflowRunId, signal) {
|
|
56
|
+
return this.json('GET', `/api/v1/execution/streaming/worker-connection/${encodeURIComponent(workflowRunId)}`, { signal });
|
|
57
|
+
}
|
|
58
|
+
stopDeviceSession(sessionId) {
|
|
59
|
+
return this.json('POST', `/api/v1/execution/device/sessions/${encodeURIComponent(sessionId)}/stop`, { retry: true });
|
|
60
|
+
}
|
|
61
|
+
cancelDevice(workflowRunId) {
|
|
62
|
+
return this.json('POST', `/api/v1/execution/device/status/cancel/${encodeURIComponent(workflowRunId)}`, { retry: true });
|
|
63
|
+
}
|
|
64
|
+
getApp(appId, signal) {
|
|
65
|
+
return this.json('GET', `/api/v1/apps/${encodeURIComponent(appId)}`, { signal });
|
|
66
|
+
}
|
|
67
|
+
registerWebUrlBuild(appId, request, signal) {
|
|
68
|
+
return this.json('POST', `/api/v1/apps/${encodeURIComponent(appId)}/builds/external`, { body: request, retry: true, signal });
|
|
69
|
+
}
|
|
70
|
+
async latestWebBuild(appId, branch, signal) {
|
|
71
|
+
const page = await this.json('GET', `/api/v1/apps/${encodeURIComponent(appId)}/builds`, {
|
|
72
|
+
query: {
|
|
73
|
+
artifact_kinds: ['web_external', 'web_bundle'],
|
|
74
|
+
branch_id: branch.branchId,
|
|
75
|
+
branch_name: branch.branchName,
|
|
76
|
+
include_jobs: 'false',
|
|
77
|
+
page: '1',
|
|
78
|
+
page_size: '1',
|
|
79
|
+
},
|
|
80
|
+
signal,
|
|
81
|
+
});
|
|
82
|
+
return page.items[0];
|
|
83
|
+
}
|
|
84
|
+
whoAmI() {
|
|
85
|
+
return this.json('GET', '/api/v1/entity/users/get_user_uuid');
|
|
86
|
+
}
|
|
87
|
+
worker(workflowRunId, action, options) {
|
|
88
|
+
const path = `/api/v1/execution/device-proxy/${encodeURIComponent(workflowRunId)}/${action}`;
|
|
89
|
+
return this.send(options.method, path, {
|
|
90
|
+
body: options.body,
|
|
91
|
+
timeoutMs: options.timeoutMs,
|
|
92
|
+
signal: options.signal,
|
|
93
|
+
retry: options.retry ?? false,
|
|
94
|
+
headers: { 'X-Revyl-Agent': 'Verify' },
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
async sendOnce(method, url, options) {
|
|
98
|
+
const timeout = AbortSignal.timeout(options.timeoutMs ?? this.requestTimeoutMs);
|
|
99
|
+
const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
|
|
100
|
+
const headers = {
|
|
101
|
+
Authorization: `Bearer ${this.token}`,
|
|
102
|
+
'User-Agent': `revyl-verify/${VERSION} node/${process.versions.node}`,
|
|
103
|
+
'X-Revyl-Client': CLIENT_HEADER_VALUE,
|
|
104
|
+
Accept: 'application/json',
|
|
105
|
+
...options.headers,
|
|
106
|
+
};
|
|
107
|
+
if (options.body !== undefined)
|
|
108
|
+
headers['Content-Type'] = 'application/json';
|
|
109
|
+
try {
|
|
110
|
+
const response = await this.fetchImpl(url, {
|
|
111
|
+
method,
|
|
112
|
+
headers,
|
|
113
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
114
|
+
redirect: 'error',
|
|
115
|
+
signal,
|
|
116
|
+
});
|
|
117
|
+
return { status: response.status, headers: response.headers, body: new Uint8Array(await response.arrayBuffer()) };
|
|
118
|
+
}
|
|
119
|
+
catch (error) {
|
|
120
|
+
if (options.signal?.aborted) {
|
|
121
|
+
return new VerifyError('TIMEOUT', `Revyl request ${method} ${url.pathname} ran past its caller's deadline.`, { cause: error });
|
|
122
|
+
}
|
|
123
|
+
if (timeout.aborted) {
|
|
124
|
+
return new VerifyError('TIMEOUT', `Revyl request ${method} ${url.pathname} got no response within ${options.timeoutMs ?? this.requestTimeoutMs} ms.`, { cause: error });
|
|
125
|
+
}
|
|
126
|
+
return new VerifyError('API_ERROR', `Could not reach Revyl at ${url.origin}: ${errorMessage(error)}`, { cause: error });
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
export function appUrl() {
|
|
131
|
+
return (process.env.REVYL_APP_URL ?? DEFAULT_APP_URL).replace(/\/+$/, '');
|
|
132
|
+
}
|
|
133
|
+
export function sessionViewerUrl(sessionId, kind) {
|
|
134
|
+
return `${appUrl()}/sessions/${encodeURIComponent(sessionId)}${kind ? `?kind=${kind}` : ''}`;
|
|
135
|
+
}
|
|
136
|
+
export function parseJson(response, what) {
|
|
137
|
+
try {
|
|
138
|
+
return JSON.parse(new TextDecoder().decode(response.body));
|
|
139
|
+
}
|
|
140
|
+
catch (error) {
|
|
141
|
+
throw new VerifyError('API_ERROR', `Revyl returned a response to ${what} that is not JSON (HTTP ${response.status}).`, {
|
|
142
|
+
cause: error,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
export function responseDetail(response) {
|
|
147
|
+
let parsed;
|
|
148
|
+
try {
|
|
149
|
+
parsed = JSON.parse(new TextDecoder().decode(response.body));
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
return undefined;
|
|
153
|
+
}
|
|
154
|
+
if (typeof parsed !== 'object' || parsed === null)
|
|
155
|
+
return undefined;
|
|
156
|
+
const record = parsed;
|
|
157
|
+
const detail = record.detail ?? record.message ?? record.error;
|
|
158
|
+
if (typeof detail === 'string')
|
|
159
|
+
return detail.slice(0, 500);
|
|
160
|
+
if (Array.isArray(detail)) {
|
|
161
|
+
return detail
|
|
162
|
+
.map((item) => (typeof item === 'object' && item !== null && 'msg' in item ? String(item.msg) : String(item)))
|
|
163
|
+
.join('; ')
|
|
164
|
+
.slice(0, 500);
|
|
165
|
+
}
|
|
166
|
+
return undefined;
|
|
167
|
+
}
|
|
168
|
+
export function responseErrorCode(response) {
|
|
169
|
+
try {
|
|
170
|
+
const parsed = JSON.parse(new TextDecoder().decode(response.body));
|
|
171
|
+
return typeof parsed.error === 'string' ? parsed.error : undefined;
|
|
172
|
+
}
|
|
173
|
+
catch {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
export function apiError(method, path, response) {
|
|
178
|
+
const detail = responseDetail(response);
|
|
179
|
+
const suffix = detail ? `: ${detail}` : '';
|
|
180
|
+
if (response.status === 401 || response.status === 403) {
|
|
181
|
+
return new VerifyError('AUTH_REJECTED', `Revyl rejected the request ${method} ${path} (HTTP ${response.status})${suffix}. Check REVYL_API_KEY or run 'revyl auth login'.`);
|
|
182
|
+
}
|
|
183
|
+
return new VerifyError('API_ERROR', `Revyl request ${method} ${path} failed with HTTP ${response.status}${suffix}`);
|
|
184
|
+
}
|
|
185
|
+
function validateBackendUrl(raw) {
|
|
186
|
+
let url;
|
|
187
|
+
try {
|
|
188
|
+
url = new URL(raw);
|
|
189
|
+
}
|
|
190
|
+
catch {
|
|
191
|
+
throw new VerifyError('CONFIG_INVALID', 'REVYL_BACKEND_URL is not a valid URL.');
|
|
192
|
+
}
|
|
193
|
+
const loopback = ['localhost', '127.0.0.1', '[::1]'].includes(url.hostname);
|
|
194
|
+
if (url.protocol !== 'https:' && !(loopback && url.protocol === 'http:')) {
|
|
195
|
+
throw new VerifyError('CONFIG_INVALID', 'REVYL_BACKEND_URL must use HTTPS (plain HTTP is allowed only on loopback).');
|
|
196
|
+
}
|
|
197
|
+
if (url.username || url.password || url.search || url.hash) {
|
|
198
|
+
throw new VerifyError('CONFIG_INVALID', 'REVYL_BACKEND_URL must be an origin without credentials, query, or fragment.');
|
|
199
|
+
}
|
|
200
|
+
return url.origin;
|
|
201
|
+
}
|