@serverkgg/bridge 0.0.10 → 0.0.12
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 +3 -1
- package/src/blog/articleFrontmatter.test.ts +95 -0
- package/src/blog/articleFrontmatter.ts +99 -0
- package/src/blog/compile.test.ts +148 -0
- package/src/blog/compile.ts +172 -0
- package/src/blog/compiled.ts +22 -0
- package/src/blog/index.ts +3 -0
- package/src/cli/validate.test.ts +116 -1
- package/src/cli/validate.ts +57 -4
- package/src/context/bridgeContext.ts +20 -0
- package/src/guides/compile.ts +70 -54
- package/src/manifest/guide.ts +1 -0
- package/src/manifest/manifest.test.ts +33 -0
- package/src/panel/bridgeControl.ts +1 -0
- package/src/panel/bridgeDetail.ts +1 -0
- package/src/panel/bridgePanel.ts +2 -0
- package/src/probes/index.ts +9 -0
- package/src/probes/minecraftPing.test.ts +344 -0
- package/src/probes/minecraftPing.ts +283 -0
- package/src/probes/raknetPing.test.ts +197 -0
- package/src/probes/raknetPing.ts +228 -0
- package/src/protocol/bridgeLimits.ts +8 -0
- package/src/runtime/bridgeDriver.test.ts +240 -0
- package/src/runtime/bridgeDriver.ts +137 -0
- package/src/runtime/bridgeProbe.ts +13 -1
- package/src/runtime/bridgeSetup.test.ts +387 -1
- package/src/runtime/bridgeSetup.ts +247 -7
- package/src/runtime/bridgeSetupHandlers.test.ts +303 -0
- package/src/runtime/bridgeSetupHandlers.ts +71 -0
- package/src/runtime/serve.ts +8 -41
- package/src/wire/panel.test.ts +62 -0
- package/src/wire/panel.ts +3 -0
package/src/wire/panel.test.ts
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
BridgeAction,
|
|
6
6
|
BridgeConfirm,
|
|
7
7
|
BridgeControl,
|
|
8
|
+
type BridgeField,
|
|
8
9
|
BridgeFormTarget,
|
|
9
10
|
BridgeKind,
|
|
10
11
|
BridgeLayout,
|
|
@@ -457,6 +458,67 @@ describe("the upload mirror", () => {
|
|
|
457
458
|
});
|
|
458
459
|
});
|
|
459
460
|
|
|
461
|
+
const fieldManifest = (field: BridgeField): BridgeManifest => ({
|
|
462
|
+
version: "1.0.0",
|
|
463
|
+
panel: {
|
|
464
|
+
tabs: [
|
|
465
|
+
{
|
|
466
|
+
id: "license",
|
|
467
|
+
title: text("Licence"),
|
|
468
|
+
sections: [
|
|
469
|
+
{
|
|
470
|
+
layout: BridgeLayout.Form,
|
|
471
|
+
id: "license",
|
|
472
|
+
target: BridgeFormTarget.Variables,
|
|
473
|
+
fields: [
|
|
474
|
+
field,
|
|
475
|
+
],
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
},
|
|
479
|
+
],
|
|
480
|
+
},
|
|
481
|
+
terminal: null,
|
|
482
|
+
setup: null,
|
|
483
|
+
modules: [],
|
|
484
|
+
events: [],
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
describe("secret fields", () => {
|
|
488
|
+
test("carries a secret control with its pattern and hint through unchanged", () => {
|
|
489
|
+
const source = fieldManifest({
|
|
490
|
+
key: "LICENSE_KEY",
|
|
491
|
+
control: BridgeControl.Secret,
|
|
492
|
+
label: text("Licence key"),
|
|
493
|
+
pattern: "^cfxk_\\w{1,60}_\\w{1,20}$",
|
|
494
|
+
patternHint: text("A licence key starts with cfxk_"),
|
|
495
|
+
});
|
|
496
|
+
|
|
497
|
+
expect(bridgeManifestSchema.parse(source)).toEqual(source);
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
test("refuses a control the platform does not know", () => {
|
|
501
|
+
const source = fieldManifest({
|
|
502
|
+
key: "LICENSE_KEY",
|
|
503
|
+
control: "password" as BridgeControl,
|
|
504
|
+
label: text("Licence key"),
|
|
505
|
+
});
|
|
506
|
+
|
|
507
|
+
expect(bridgeManifestSchema.safeParse(source).success).toBe(false);
|
|
508
|
+
});
|
|
509
|
+
|
|
510
|
+
test("refuses a pattern longer than the platform takes", () => {
|
|
511
|
+
const source = fieldManifest({
|
|
512
|
+
key: "LICENSE_KEY",
|
|
513
|
+
control: BridgeControl.Secret,
|
|
514
|
+
label: text("Licence key"),
|
|
515
|
+
pattern: `^${"a".repeat(256)}$`,
|
|
516
|
+
});
|
|
517
|
+
|
|
518
|
+
expect(bridgeManifestSchema.safeParse(source).success).toBe(false);
|
|
519
|
+
});
|
|
520
|
+
});
|
|
521
|
+
|
|
460
522
|
const setupManifest = (setup: BridgeSetupManifest | null): BridgeManifest => ({
|
|
461
523
|
version: "1.0.0",
|
|
462
524
|
panel: null,
|
package/src/wire/panel.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { guideOpenTargetSchema } from "@serverkgg/bridge/guides";
|
|
|
2
2
|
import {
|
|
3
3
|
BRIDGE_ID_PATTERN,
|
|
4
4
|
BRIDGE_MODULE_ID_PATTERN,
|
|
5
|
+
BRIDGE_PATTERN_LENGTH_LIMIT,
|
|
5
6
|
BridgeAccess,
|
|
6
7
|
BridgeConfirm,
|
|
7
8
|
BridgeControl,
|
|
@@ -100,6 +101,8 @@ export const bridgeFieldSchema = z.object({
|
|
|
100
101
|
max: z.number().optional(),
|
|
101
102
|
step: z.number().optional(),
|
|
102
103
|
maxLength: z.int().positive().optional(),
|
|
104
|
+
pattern: z.string().max(BRIDGE_PATTERN_LENGTH_LIMIT).optional(),
|
|
105
|
+
patternHint: panelTextSchema.optional(),
|
|
103
106
|
options: z
|
|
104
107
|
.union([
|
|
105
108
|
z.array(bridgeOptionSchema).max(64),
|