testdriverai 5.5.3 → 5.5.5

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.
Files changed (3) hide show
  1. package/lib/sdk.js +35 -30
  2. package/package.json +1 -1
  3. package/schema.json +3 -5
package/lib/sdk.js CHANGED
@@ -9,7 +9,7 @@ const axios = require('axios');
9
9
 
10
10
  const { logger } = require('./logger');
11
11
 
12
- // let token = null;
12
+ let token = null;
13
13
 
14
14
  const outputError = async (error) => {
15
15
  logger.info(chalk.red(error.status), chalk.red(error.statusText));
@@ -62,29 +62,32 @@ const parseBody = async (response, body) => {
62
62
  };
63
63
 
64
64
  let auth = async () => {
65
- // data.apiKey = process.env.DASHCAM_API_KEY; @todo add-auth
66
65
 
67
- // if (!data.apiKey) {
68
- // logger.info(chalk.red('API key not found. Set DASHCAM_API_KEY in your environment.'));
69
- // process.exit(1);
70
- // }
71
-
72
- const url = [root, "auth/exchange-api-key"].join("/");
73
- const config = {
74
- method: "post",
75
- headers: {
76
- "Content-Type": "application/json",
77
- },
78
- // data
79
- };
80
-
81
- try {
82
- await axios(url, config);
83
- // token = res.data.token;
84
- } catch (error) {
85
- await outputError(error);
86
- process.exit(1);
66
+ if (config["TD_API_KEY"]) {
67
+
68
+ const url = [root, "auth/exchange-api-key"].join("/");
69
+ const c = {
70
+ method: "post",
71
+ headers: {
72
+ "Content-Type": "application/json",
73
+ },
74
+ data: {
75
+ apiKey: config["TD_API_KEY"],
76
+ version
77
+ }
78
+ };
79
+
80
+ try {
81
+ let res = await axios(url, c);
82
+
83
+ token = res.data.token;
84
+ return token;
85
+ } catch (error) {
86
+ await outputError(error);
87
+ process.exit(1);
88
+ }
87
89
  }
90
+
88
91
  };
89
92
 
90
93
  const req = async (path, data, onChunk) => {
@@ -98,17 +101,19 @@ const req = async (path, data, onChunk) => {
98
101
  const url = path.startsWith("/api")
99
102
  ? [root, path].join("")
100
103
  : [root, "api", version, "testdriver", path].join("/");
101
-
102
- const config = {
103
- method: "post",
104
- headers: { "Content-Type": "application/json" },
105
- responseType: typeof onChunk === "function" ? "stream" : "json",
106
- data: {
104
+ const config = {
105
+ method: "post",
106
+ headers: {
107
+ "Content-Type": "application/json",
108
+ ...(token && { "Authorization": `Bearer ${token}` }) // Add the authorization bearer token only if token is set
109
+ },
110
+ responseType: typeof onChunk === "function" ? "stream" : "json",
111
+ data: {
107
112
  ...data,
108
113
  session: session.get(),
109
114
  stream: typeof onChunk === "function",
110
- },
111
- };
115
+ },
116
+ };
112
117
 
113
118
  try {
114
119
  let response;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "testdriverai",
3
- "version": "5.5.3",
3
+ "version": "5.5.5",
4
4
  "description": "Next generation autonomous AI agent for end-to-end testing of web & desktop",
5
5
  "main": "index.js",
6
6
  "bin": {
package/schema.json CHANGED
@@ -69,10 +69,9 @@
69
69
  "properties": {
70
70
  "keys": {
71
71
  "type": "array",
72
- "items": {
72
+ "contains": {
73
73
  "type": "string",
74
74
  "enum": [
75
- [
76
75
  "backspace", "delete", "enter", "tab", "escape", "up", "down", "right", "left",
77
76
  "home", "end", "pageup", "pagedown", "f1", "f2", "f3", "f4", "f5", "f6", "f7",
78
77
  "f8", "f9", "f10", "f11", "f12", "f13", "f14", "f15", "f16", "f17", "f18", "f19",
@@ -87,7 +86,6 @@
87
86
  "lights_kbd_toggle", "lights_kbd_up", "lights_kbd_down", "a", "b", "c", "d", "e",
88
87
  "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u",
89
88
  "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
90
- ]
91
89
  ]
92
90
  }
93
91
  }
@@ -415,8 +413,8 @@
415
413
  "method": {
416
414
  "type": "string",
417
415
  "enum": [
418
- "ai",
419
- "turbo"
416
+ "keyboard",
417
+ "mouse"
420
418
  ]
421
419
  }
422
420
  },