arcadible 0.1.17 → 0.1.18
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/package.json +1 -1
- package/src/action/login/flow.js +6 -6
- package/src/action/predeploy/ac.js +1 -1
- package/src/api.js +12 -12
- package/src/prompt/template.js +1 -1
- package/src/util/progress.js +1 -1
- package/src/util/request.js +22 -15
- package/src/util/s3.js +2 -2
package/package.json
CHANGED
package/src/action/login/flow.js
CHANGED
|
@@ -31,16 +31,16 @@ const POLL = {
|
|
|
31
31
|
|
|
32
32
|
const postFlow = function ({ expiresAt, secret, type }) {
|
|
33
33
|
const form = new FormData();
|
|
34
|
-
form.append("expires_at", expiresAt.toISOString());
|
|
35
34
|
form.append("secret", secret);
|
|
36
35
|
form.append("type", type);
|
|
36
|
+
form.append("expires_at", expiresAt.toISOString());
|
|
37
37
|
return api.postFlow(form);
|
|
38
38
|
};
|
|
39
39
|
|
|
40
40
|
// [function]
|
|
41
41
|
|
|
42
|
-
const
|
|
43
|
-
return api.
|
|
42
|
+
const flow = function ({ id, secret: token }) {
|
|
43
|
+
return api.flow(id, { token });
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
// [function]
|
|
@@ -56,8 +56,8 @@ const createFlow = function ({ expiresAt, secret, type }, onLoginCreated) {
|
|
|
56
56
|
|
|
57
57
|
// [function]
|
|
58
58
|
|
|
59
|
-
const pollFlow = function (
|
|
60
|
-
return
|
|
59
|
+
const pollFlow = function (value, onLoginPoll) {
|
|
60
|
+
return flow(value).then(({ data, status }) => {
|
|
61
61
|
if (onLoginPoll) {
|
|
62
62
|
onLoginPoll({ status });
|
|
63
63
|
}
|
|
@@ -89,7 +89,7 @@ const main = function ({ onLoginCreated, onLoginPoll }) {
|
|
|
89
89
|
).then(({ id }) => {
|
|
90
90
|
const timeout = Math.max(0, expiresAt.getTime() - Date.now() - time.s(15));
|
|
91
91
|
return poll(
|
|
92
|
-
(
|
|
92
|
+
(value) => pollFlow(value, onLoginPoll),
|
|
93
93
|
{ id, secret },
|
|
94
94
|
{ ...POLL, timeout },
|
|
95
95
|
);
|
|
@@ -31,7 +31,7 @@ const uploadBuild = function (
|
|
|
31
31
|
|
|
32
32
|
const ensureVersion = function (session, { id, version }, cb) {
|
|
33
33
|
const token = session?.access_token;
|
|
34
|
-
return api.
|
|
34
|
+
return api.gameBuild(id, version, { token }).then(
|
|
35
35
|
() => cb(new Error(phrase.versionExists(version))),
|
|
36
36
|
(err) => {
|
|
37
37
|
if (err.status === 404) {
|
package/src/api.js
CHANGED
|
@@ -18,39 +18,39 @@ const endpoint = function (path) {
|
|
|
18
18
|
|
|
19
19
|
// [function]
|
|
20
20
|
|
|
21
|
-
const postAuthRefresh = function (form,
|
|
22
|
-
return request.post(endpoint("/auth/refresh"), form,
|
|
21
|
+
const postAuthRefresh = function (form, opts) {
|
|
22
|
+
return request.post(endpoint("/auth/refresh"), form, opts);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
// [function]
|
|
26
26
|
|
|
27
|
-
const postFlow = function (form,
|
|
28
|
-
return request.post(endpoint("/flows"), form,
|
|
27
|
+
const postFlow = function (form, opts) {
|
|
28
|
+
return request.post(endpoint("/flows"), form, opts);
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// [function]
|
|
32
32
|
|
|
33
|
-
const
|
|
34
|
-
return request.get(endpoint(`/flows/${
|
|
33
|
+
const flow = function (id, opts) {
|
|
34
|
+
return request.get(endpoint(`/flows/${id}`), opts);
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
// [function]
|
|
38
38
|
|
|
39
|
-
const postUpload = function (form,
|
|
40
|
-
return request.post(endpoint("/uploads"), form,
|
|
39
|
+
const postUpload = function (form, opts) {
|
|
40
|
+
return request.post(endpoint("/uploads"), form, opts);
|
|
41
41
|
};
|
|
42
42
|
|
|
43
43
|
// [function]
|
|
44
44
|
|
|
45
|
-
const
|
|
46
|
-
return request.get(endpoint(`/games/${
|
|
45
|
+
const gameBuild = function (id, version, opts) {
|
|
46
|
+
return request.get(endpoint(`/games/${id}/builds/${version}`), opts);
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
// [export]
|
|
50
50
|
|
|
51
51
|
module.exports = {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
flow,
|
|
53
|
+
gameBuild,
|
|
54
54
|
postAuthRefresh,
|
|
55
55
|
postFlow,
|
|
56
56
|
postUpload,
|
package/src/prompt/template.js
CHANGED
package/src/util/progress.js
CHANGED
package/src/util/request.js
CHANGED
|
@@ -27,39 +27,46 @@ const parse = function (resp) {
|
|
|
27
27
|
|
|
28
28
|
// [function]
|
|
29
29
|
|
|
30
|
-
const send = function (method, url,
|
|
31
|
-
const headers =
|
|
32
|
-
"X-
|
|
33
|
-
"X-
|
|
34
|
-
|
|
30
|
+
const send = function (method, url, form, { token } = {}) {
|
|
31
|
+
const headers = [
|
|
32
|
+
["X-Arcadible-Client-Id", CLIENT_ID],
|
|
33
|
+
["X-Arcadible-Client-Version", CLIENT_VERSION],
|
|
34
|
+
];
|
|
35
35
|
if (token) {
|
|
36
|
-
headers.
|
|
36
|
+
headers.push(["Authorization", `Bearer ${token}`]);
|
|
37
37
|
}
|
|
38
|
-
|
|
38
|
+
if (form) {
|
|
39
|
+
headers.push(["Content-Type", "application/json"]);
|
|
40
|
+
}
|
|
41
|
+
return fetch(url, {
|
|
42
|
+
body: form ? JSON.stringify(Object.fromEntries(form)) : null,
|
|
43
|
+
headers,
|
|
44
|
+
method,
|
|
45
|
+
}).then(parse);
|
|
39
46
|
};
|
|
40
47
|
|
|
41
48
|
// [function]
|
|
42
49
|
|
|
43
|
-
const get = function (url,
|
|
44
|
-
return send("GET", url, null,
|
|
50
|
+
const get = function (url, opts) {
|
|
51
|
+
return send("GET", url, null, opts);
|
|
45
52
|
};
|
|
46
53
|
|
|
47
54
|
// [function]
|
|
48
55
|
|
|
49
|
-
const post = function (url,
|
|
50
|
-
return send("POST", url,
|
|
56
|
+
const post = function (url, form, opts) {
|
|
57
|
+
return send("POST", url, form, opts);
|
|
51
58
|
};
|
|
52
59
|
|
|
53
60
|
// [function]
|
|
54
61
|
|
|
55
|
-
const patch = function (url,
|
|
56
|
-
return send("PATCH", url,
|
|
62
|
+
const patch = function (url, form, opts) {
|
|
63
|
+
return send("PATCH", url, form, opts);
|
|
57
64
|
};
|
|
58
65
|
|
|
59
66
|
// [function]
|
|
60
67
|
|
|
61
|
-
const del = function (url,
|
|
62
|
-
return send("DELETE", url, null,
|
|
68
|
+
const del = function (url, opts) {
|
|
69
|
+
return send("DELETE", url, null, opts);
|
|
63
70
|
};
|
|
64
71
|
|
|
65
72
|
// [export]
|
package/src/util/s3.js
CHANGED
|
@@ -16,7 +16,7 @@ const request = https.request;
|
|
|
16
16
|
|
|
17
17
|
// [function]
|
|
18
18
|
|
|
19
|
-
const
|
|
19
|
+
const requestOpts = function (size) {
|
|
20
20
|
return {
|
|
21
21
|
headers: {
|
|
22
22
|
"Content-Length": size,
|
|
@@ -29,7 +29,7 @@ const requestOptions = function (size) {
|
|
|
29
29
|
// [function]
|
|
30
30
|
|
|
31
31
|
const upload = function (url, { path, size }, onProgress, cb) {
|
|
32
|
-
const req = request(url,
|
|
32
|
+
const req = request(url, requestOpts(size), (resp) => {
|
|
33
33
|
resp.resume();
|
|
34
34
|
const status = resp.statusCode;
|
|
35
35
|
if (status >= 200 && status < 300) {
|