arcadible 1.0.51 → 1.0.53
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/dist/action/secret/tool.js +18 -5
- package/dist/command/function/secret/set.js +14 -2
- package/dist/config/code.js +1 -0
- package/dist/phrase/function.js +8 -0
- package/dist/serve/wires.js +6 -3
- package/dist/wires/room.js +23 -14
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
|
@@ -3,12 +3,13 @@
|
|
|
3
3
|
// channel, by the name the manifest declares (function.secrets), set by the
|
|
4
4
|
// game's owner, and never shown again. Nothing here keeps one.
|
|
5
5
|
import { deleteGameFunctionSecret, gameFunctionSecrets, putGameFunctionSecret, } from "../../api.js";
|
|
6
|
-
import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND, SECRET_TOO_LARGE, } from "../../config/code.js";
|
|
6
|
+
import { ARGUMENT_INVALID, GAME_NOT_FOUND, SECRET_QUOTA_FULL, SECRET_NOT_FOUND, SECRET_TOO_LARGE, WARNING, } from "../../config/code.js";
|
|
7
7
|
import { SECRET_NAME } from "../../config/limit.js";
|
|
8
8
|
import { ArcError } from "../../util/error.js";
|
|
9
9
|
import { channelOf, gameOf, headersOf, isRefused, REFUSED, needOf, ownedRead, } from "../game.js";
|
|
10
10
|
import { iso } from "../../util/time.js";
|
|
11
|
-
import {
|
|
11
|
+
import { given } from "../../parser/given.js";
|
|
12
|
+
import { gameNotOwned, secretQuotaFull, secretNameInvalid, secretNotFound, secretTooLarge, secretUndeclared, secretValueInvalid, } from "../../phrase/index.js";
|
|
12
13
|
// [declare]
|
|
13
14
|
const VALUE_MAX = 4096;
|
|
14
15
|
// [function]
|
|
@@ -21,11 +22,23 @@ function nameOf(name) {
|
|
|
21
22
|
}
|
|
22
23
|
// [function]
|
|
23
24
|
// sets a secret, as `{ name, channel }`. `value()` resolves with its value,
|
|
24
|
-
// asked for only once the rest holds, so nothing is typed for a refusal.
|
|
25
|
-
|
|
25
|
+
// asked for only once the rest holds, so nothing is typed for a refusal. A
|
|
26
|
+
// name the manifest's `function.secrets` doesn't declare is set all the
|
|
27
|
+
// same, since a later release may declare it, and warned of: until one
|
|
28
|
+
// does, the function can't read it, as only declared secrets are sealed
|
|
29
|
+
// into a build.
|
|
30
|
+
export async function set(current, { channel, name, onWarning, value, ...conf }) {
|
|
26
31
|
const named = nameOf(name);
|
|
27
32
|
const where = needOf(channel);
|
|
28
|
-
const
|
|
33
|
+
const parsed = await given(conf);
|
|
34
|
+
const id = await gameOf({ ...conf, project: parsed });
|
|
35
|
+
const declared = parsed.function?.secrets;
|
|
36
|
+
if (!(Array.isArray(declared) && declared.includes(named)) && onWarning) {
|
|
37
|
+
onWarning({
|
|
38
|
+
code: WARNING.SECRET_UNDECLARED,
|
|
39
|
+
message: secretUndeclared(named),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
29
42
|
const headers = headersOf(current);
|
|
30
43
|
const secret = await value();
|
|
31
44
|
if (typeof secret !== "string" || secret === "") {
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
import { defineCommand } from "../../../cli/command.js";
|
|
4
4
|
import { password } from "../../../cli/prompt.js";
|
|
5
5
|
import { secretPrompt, secretSet } from "../../../phrase/index.js";
|
|
6
|
-
import { p } from "../../../util/log.js";
|
|
6
|
+
import { p, pw } from "../../../util/log.js";
|
|
7
|
+
import { warning } from "../../../util/output.js";
|
|
7
8
|
import { NAME } from "./name.js";
|
|
8
9
|
import { CHANNEL, CWD, JSON_OUTPUT, QUIET } from "../../../cli/options.js";
|
|
9
10
|
import { run } from "./run.js";
|
|
@@ -36,11 +37,22 @@ export default defineCommand({
|
|
|
36
37
|
options: { ...CHANNEL, json: JSON_OUTPUT, quiet: QUIET, cwd: CWD },
|
|
37
38
|
positionals: { name: NAME },
|
|
38
39
|
run(argv, aborting) {
|
|
40
|
+
// what --json lists under `warnings`, beside the result or the error:
|
|
41
|
+
// a name the manifest doesn't declare (secret_undeclared), printed at
|
|
42
|
+
// once otherwise, before the value is asked for.
|
|
43
|
+
const warnings = [];
|
|
44
|
+
aborting.data = { warnings };
|
|
39
45
|
return run(argv, aborting, (current, conf) => set(current, {
|
|
40
46
|
...conf,
|
|
41
47
|
name: argv.name,
|
|
48
|
+
onWarning({ code, message }) {
|
|
49
|
+
warnings.push(warning(code, message));
|
|
50
|
+
if (!argv.json && !argv.quiet) {
|
|
51
|
+
pw(message);
|
|
52
|
+
}
|
|
53
|
+
},
|
|
42
54
|
value: () => valueOf(argv.name, argv.json),
|
|
43
|
-
}), (kept) => {
|
|
55
|
+
}).then((kept) => ({ ...kept, warnings })), (kept) => {
|
|
44
56
|
p(secretSet(kept));
|
|
45
57
|
}, `arc function secret set ${argv.name}`);
|
|
46
58
|
},
|
package/dist/config/code.js
CHANGED
|
@@ -136,6 +136,7 @@ export const WARNING = {
|
|
|
136
136
|
PACKAGE_FILE_PRIVATE: "package_file_private",
|
|
137
137
|
SCREENSHOT_NAME_INVALID: "screenshot_name_invalid",
|
|
138
138
|
SDK_SCRIPT_PATH: "sdk_script_path",
|
|
139
|
+
SECRET_UNDECLARED: "secret_undeclared",
|
|
139
140
|
SECRET_UNSET: "secret_unset",
|
|
140
141
|
VERSION_UNCHECKED: "version_unchecked",
|
|
141
142
|
};
|
package/dist/phrase/function.js
CHANGED
|
@@ -114,6 +114,14 @@ export function secretSet({ channel, name, }) {
|
|
|
114
114
|
return `Set ${name} for ${channel}.\nThe game's function has it within a minute.`;
|
|
115
115
|
}
|
|
116
116
|
// [function]
|
|
117
|
+
// a secret set by a name the project's manifest doesn't declare, which
|
|
118
|
+
// `arc function secret set` warns of (secret_undeclared): only declared
|
|
119
|
+
// secrets are sealed into a build, so no release reads it until one
|
|
120
|
+
// declares it.
|
|
121
|
+
export function secretUndeclared(name) {
|
|
122
|
+
return `Secret ${name} isn't in the manifest's [function] secrets.\nThe game's function reads it once a release declares it there.`;
|
|
123
|
+
}
|
|
124
|
+
// [function]
|
|
117
125
|
// a secret a build declares that has no value on the channel it goes to,
|
|
118
126
|
// which `arc deploy` warns of (action/predeploy/secrets.ts).
|
|
119
127
|
export function secretUnset({ channel, name, }) {
|
package/dist/serve/wires.js
CHANGED
|
@@ -203,10 +203,13 @@ export function wires({ drop = null, game, origin, tickets, }) {
|
|
|
203
203
|
return;
|
|
204
204
|
}
|
|
205
205
|
// the wires a player is on, counted here as Arcadible counts
|
|
206
|
-
// them
|
|
207
|
-
//
|
|
206
|
+
// them, a connection unheard for too long not among them, as the
|
|
207
|
+
// sweep would drop it: past them a wire is full (`too_many` in
|
|
208
|
+
// the first protocol)
|
|
209
|
+
const at = Date.now();
|
|
208
210
|
const theirs = [...running].filter(([other, { on: those }]) => other !== id &&
|
|
209
|
-
[...those.values()].some((each) => each.member.id === who.member.id
|
|
211
|
+
[...those.values()].some((each) => each.member.id === who.member.id &&
|
|
212
|
+
at - each.heard <= LIMITS.idle)).length;
|
|
210
213
|
if (theirs >= LIMITS.wires) {
|
|
211
214
|
refuse(protocol === 2 ? "full" : "too_many");
|
|
212
215
|
return;
|
package/dist/wires/room.js
CHANGED
|
@@ -129,19 +129,18 @@ export function closeOf(code, protocol = 1) {
|
|
|
129
129
|
const said = code === "too_many" ? "full" : code;
|
|
130
130
|
return [CLOSED_V2[said], `${said} ${RETRIES[said]}`];
|
|
131
131
|
}
|
|
132
|
-
// [function]
|
|
133
|
-
// tokens that refill at `rate` a second, up to `burst`: whether one is
|
|
134
|
-
// there to take, at `at`.
|
|
135
132
|
function bucket(rate, burst) {
|
|
136
133
|
let tokens = burst;
|
|
137
134
|
let last = 0;
|
|
138
|
-
return
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
return
|
|
143
|
-
|
|
144
|
-
|
|
135
|
+
return {
|
|
136
|
+
has(at) {
|
|
137
|
+
tokens = Math.min(burst, tokens + ((at - last) / 1000) * rate);
|
|
138
|
+
last = at;
|
|
139
|
+
return tokens >= 1;
|
|
140
|
+
},
|
|
141
|
+
take() {
|
|
142
|
+
tokens -= 1;
|
|
143
|
+
},
|
|
145
144
|
};
|
|
146
145
|
}
|
|
147
146
|
// [function]
|
|
@@ -235,14 +234,21 @@ export function createRoom(options) {
|
|
|
235
234
|
};
|
|
236
235
|
return {
|
|
237
236
|
admit(member, protocol = 1) {
|
|
238
|
-
|
|
237
|
+
// a connection unheard for too long holds no place, though the sweep
|
|
238
|
+
// hasn't dropped it yet: windows that died free their member's 8,
|
|
239
|
+
// and a crashed member their seat, by the sweep's rule
|
|
240
|
+
const at = now();
|
|
241
|
+
const on = options
|
|
242
|
+
.list()
|
|
243
|
+
.filter((each) => at - each.heard <= LIMITS.idle);
|
|
239
244
|
const theirs = on.filter((each) => each.member.id === member.id).length;
|
|
240
245
|
// a thing that's full is `full` in the second protocol, and the
|
|
241
246
|
// first's `too_many` in the first
|
|
242
247
|
const full = protocol === 2 ? "full" : "too_many";
|
|
243
248
|
if (theirs >= LIMITS.connections)
|
|
244
249
|
return full;
|
|
245
|
-
|
|
250
|
+
const others = new Set(on.map((each) => each.member.id)).size;
|
|
251
|
+
if (theirs === 0 && others >= LIMITS.members)
|
|
246
252
|
return full;
|
|
247
253
|
return null;
|
|
248
254
|
},
|
|
@@ -309,11 +315,14 @@ export function createRoom(options) {
|
|
|
309
315
|
sends.set(mine.member.id, take);
|
|
310
316
|
}
|
|
311
317
|
// past a member's rate, or the wire's, a message is dropped, and its
|
|
312
|
-
// sender told
|
|
313
|
-
|
|
318
|
+
// sender told; it takes from neither, so one the wire refuses never
|
|
319
|
+
// spends the member's own, nor one past the member's the wire's
|
|
320
|
+
if (!take.has(at) || !wire.has(at)) {
|
|
314
321
|
refuse("busy");
|
|
315
322
|
return;
|
|
316
323
|
}
|
|
324
|
+
take.take();
|
|
325
|
+
wire.take();
|
|
317
326
|
message(second ? frame : frame.send, mine.member);
|
|
318
327
|
},
|
|
319
328
|
server(data) {
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"license": "Apache-2.0",
|
|
44
44
|
"name": "arcadible",
|
|
45
|
-
"version": "1.0.
|
|
45
|
+
"version": "1.0.53"
|
|
46
46
|
},
|
|
47
47
|
"node_modules/@cacheable/memory": {
|
|
48
48
|
"dependencies": {
|
|
@@ -2433,5 +2433,5 @@
|
|
|
2433
2433
|
}
|
|
2434
2434
|
},
|
|
2435
2435
|
"requires": true,
|
|
2436
|
-
"version": "1.0.
|
|
2436
|
+
"version": "1.0.53"
|
|
2437
2437
|
}
|
package/package.json
CHANGED