@capybara-hq/kernel 0.1.0-rc.67 → 0.1.0-rc.69
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/bootstrap.json +9 -1
- package/dist/admin/admin.module.js +2 -0
- package/dist/admin/health.service.d.ts +11 -4
- package/dist/admin/health.service.js +33 -17
- package/dist/background/poll.job.js +2 -2
- package/dist/background/tasks.service.d.ts +5 -5
- package/dist/background/tasks.service.js +9 -8
- package/dist/catalog/credential-key.d.ts +10 -0
- package/dist/catalog/credential-key.js +28 -0
- package/dist/catalog/marketplaces.service.d.ts +1 -1
- package/dist/catalog/plugin-upgrade.js +1 -19
- package/dist/catalog/requests.service.js +1 -1
- package/dist/config/schema.d.ts +1 -1
- package/dist/config/schema.js +9 -9
- package/dist/conversations/conversations.controller.d.ts +8 -3
- package/dist/conversations/conversations.controller.js +8 -3
- package/dist/conversations/conversations.service.d.ts +33 -15
- package/dist/conversations/conversations.service.js +60 -10
- package/dist/conversations/events.d.ts +21 -41
- package/dist/conversations/events.js +57 -31
- package/dist/conversations/permission-profiles.controller.d.ts +6 -4
- package/dist/conversations/permission-profiles.service.d.ts +6 -4
- package/dist/ctx/create-ctx.d.ts +20 -1
- package/dist/ctx/create-ctx.js +77 -6
- package/dist/ctx/device-provider-check.d.ts +6 -2
- package/dist/ctx/device-provider-check.js +17 -2
- package/dist/db/kernel-schema.d.ts +10 -48
- package/dist/devices/access.d.ts +3 -4
- package/dist/devices/access.js +3 -4
- package/dist/devices/conversation-devices.d.ts +1 -3
- package/dist/devices/conversation-devices.js +2 -7
- package/dist/devices/device-projects.service.js +24 -29
- package/dist/devices/device-provider-selection.d.ts +5 -6
- package/dist/devices/device-provider-selection.js +8 -9
- package/dist/devices/devices.controller.d.ts +8 -21
- package/dist/devices/devices.controller.js +9 -34
- package/dist/devices/devices.module.js +6 -4
- package/dist/devices/devices.schemas.d.ts +1 -5
- package/dist/devices/devices.schemas.js +1 -5
- package/dist/devices/devices.service.d.ts +84 -147
- package/dist/devices/devices.service.js +134 -229
- package/dist/devices/dto.d.ts +5 -32
- package/dist/devices/dto.js +5 -37
- package/dist/devices/errors.d.ts +6 -5
- package/dist/devices/errors.js +7 -8
- package/dist/devices/project-rules.d.ts +9 -11
- package/dist/devices/project-rules.js +7 -7
- package/dist/devices/working-root.d.ts +3 -6
- package/dist/devices/working-root.js +3 -8
- package/dist/dial-in/access.d.ts +23 -0
- package/dist/dial-in/access.js +64 -0
- package/dist/{local-devices/device-auth.controller.d.ts → dial-in/auth.controller.d.ts} +12 -6
- package/dist/{local-devices/device-auth.controller.js → dial-in/auth.controller.js} +30 -15
- package/dist/dial-in/auth.module.d.ts +7 -0
- package/dist/dial-in/auth.module.js +27 -0
- package/dist/{local-devices/device-auth.d.ts → dial-in/auth.service.d.ts} +42 -13
- package/dist/{local-devices/device-auth.js → dial-in/auth.service.js} +83 -32
- package/dist/dial-in/dial-in.module.d.ts +9 -0
- package/dist/dial-in/dial-in.module.js +37 -0
- package/dist/{local-devices → dial-in}/dto.d.ts +17 -2
- package/dist/{local-devices → dial-in}/dto.js +14 -2
- package/dist/dial-in/envelope.d.ts +95 -0
- package/dist/dial-in/envelope.js +89 -0
- package/dist/dial-in/gateway.d.ts +214 -0
- package/dist/{local-devices/local-device-gateway.js → dial-in/gateway.js} +337 -181
- package/dist/dial-in/handlers.d.ts +47 -0
- package/dist/dial-in/handlers.js +84 -0
- package/dist/dial-in/machines.d.ts +155 -0
- package/dist/dial-in/machines.js +383 -0
- package/dist/dial-in/relay.d.ts +135 -0
- package/dist/dial-in/relay.js +444 -0
- package/dist/dial-in/relay.module.d.ts +7 -0
- package/dist/dial-in/relay.module.js +24 -0
- package/dist/{local-devices/device-routes.d.ts → dial-in/routes.d.ts} +19 -11
- package/dist/{local-devices/device-routes.js → dial-in/routes.js} +45 -25
- package/dist/{local-devices → dial-in}/targets.d.ts +3 -18
- package/dist/{local-devices → dial-in}/targets.js +3 -48
- package/dist/errors.d.ts +8 -27
- package/dist/errors.js +8 -27
- package/dist/extensions/bootstrap.d.ts +5 -0
- package/dist/extensions/bootstrap.js +10 -1
- package/dist/extensions/extensions.module.js +6 -0
- package/dist/extensions/host.d.ts +6 -0
- package/dist/extensions/host.js +12 -2
- package/dist/extensions/permission-set.d.ts +15 -1
- package/dist/extensions/permission-set.js +11 -1
- package/dist/extensions/permission-view.d.ts +1 -1
- package/dist/extensions/permission-view.js +4 -1
- package/dist/http/api.module.js +4 -4
- package/dist/http/gateway-routes.d.ts +1 -1
- package/dist/http/gateway-routes.js +1 -1
- package/dist/http/meta.controller.js +1 -1
- package/dist/identity/settings.d.ts +1 -1
- package/dist/identity/settings.js +6 -8
- package/dist/infra/config/kernel-config.service.js +2 -2
- package/dist/infra/outbox/registry.d.ts +0 -14
- package/dist/infra/outbox/registry.js +0 -15
- package/dist/infra/throttler/named-throttlers.d.ts +1 -1
- package/dist/infra/throttler/named-throttlers.js +1 -1
- package/dist/kernel.module.js +0 -3
- package/dist/orgs/settings.service.js +5 -10
- package/dist/overrides.d.ts +0 -4
- package/dist/overrides.js +0 -2
- package/dist/platform/exclusions.js +5 -5
- package/dist/platform/ops/admin.ops.js +1 -1
- package/dist/platform/ops/conversations.ops.js +5 -2
- package/dist/platform/ops/devices.ops.js +11 -24
- package/dist/platform/ops/inbox.ops.js +1 -1
- package/dist/roles/gateway-role.d.ts +3 -3
- package/dist/roles/gateway-role.js +4 -4
- package/dist/roles/gateway.module.d.ts +1 -1
- package/dist/roles/gateway.module.js +5 -5
- package/dist/runtime/context/device-paths.d.ts +4 -1
- package/dist/runtime/context/permission-profile.js +5 -5
- package/dist/runtime/maintenance.d.ts +2 -5
- package/dist/runtime/maintenance.js +9 -19
- package/dist/runtime/project/knowledge.js +4 -5
- package/dist/runtime/project/knowledge.service.js +2 -1
- package/dist/sandbox/cloud-permission-snapshot.d.ts +1 -1
- package/dist/sandbox/cloud-permission-snapshot.js +1 -3
- package/dist/sandbox/device-reports.d.ts +74 -14
- package/dist/sandbox/device-reports.js +190 -33
- package/dist/sandbox/device-reports.module.d.ts +7 -0
- package/dist/sandbox/device-reports.module.js +25 -0
- package/dist/sandbox/device-sandbox.d.ts +39 -41
- package/dist/sandbox/device-sandbox.js +44 -83
- package/dist/sandbox/kernel-read.d.ts +2 -2
- package/dist/sandbox/legacy-retirement.d.ts +11 -59
- package/dist/sandbox/legacy-retirement.js +34 -186
- package/dist/sandbox/legacy-retirement.module.d.ts +2 -2
- package/dist/sandbox/legacy-retirement.module.js +2 -2
- package/dist/sandbox/managed-device-context.d.ts +16 -4
- package/dist/sandbox/managed-device-context.js +25 -8
- package/dist/sandbox/managed-device-context.module.js +4 -0
- package/dist/sandbox/modes.d.ts +3 -12
- package/dist/sandbox/modes.js +2 -14
- package/dist/{local-devices → sandbox}/network-grants.d.ts +2 -21
- package/dist/{local-devices → sandbox}/network-grants.js +4 -49
- package/dist/sandbox/operation-authority-types.d.ts +2 -1
- package/dist/sandbox/operation-authority.d.ts +6 -20
- package/dist/sandbox/operation-authority.js +43 -104
- package/dist/sandbox/operation-authority.module.js +1 -1
- package/dist/sandbox/operation-intents.d.ts +4 -1
- package/dist/sandbox/operation-intents.js +11 -2
- package/dist/sandbox/operation-reconcile.job.js +2 -4
- package/dist/sandbox/permission-availability.d.ts +6 -7
- package/dist/sandbox/permission-availability.js +7 -10
- package/dist/sandbox/permission-call-grants.d.ts +2 -1
- package/dist/sandbox/permission-call-grants.js +1 -7
- package/dist/sandbox/permission-call-types.d.ts +4 -4
- package/dist/sandbox/permission-ceiling-writes.d.ts +7 -23
- package/dist/sandbox/permission-ceiling-writes.js +8 -35
- package/dist/sandbox/permission-config-publication.d.ts +9 -1
- package/dist/sandbox/permission-config-publication.js +29 -21
- package/dist/sandbox/permission-context-types.d.ts +17 -10
- package/dist/sandbox/permission-facts.d.ts +98 -95
- package/dist/sandbox/permission-facts.js +160 -314
- package/dist/sandbox/permission-instance-writes.d.ts +23 -37
- package/dist/sandbox/permission-instance-writes.js +44 -121
- package/dist/sandbox/permission-runtime-reports.d.ts +38 -30
- package/dist/sandbox/permission-runtime-reports.js +105 -122
- package/dist/sandbox/providers.d.ts +26 -38
- package/dist/sandbox/providers.js +36 -18
- package/dist/sandbox/request-not-sent.d.ts +2 -13
- package/dist/sandbox/request-not-sent.js +2 -13
- package/dist/sandbox/review/permission-candidate.d.ts +13 -8
- package/dist/sandbox/review/permission-candidate.js +38 -48
- package/dist/sandbox/sandbox.module.js +7 -3
- package/dist/sandbox/sandbox.service.d.ts +49 -59
- package/dist/sandbox/sandbox.service.js +139 -259
- package/dist/schedules/fire.d.ts +15 -6
- package/dist/schedules/fire.js +27 -13
- package/dist/schedules/grant-rules.js +1 -1
- package/dist/schedules/scheduled-tasks.service.d.ts +0 -7
- package/dist/schedules/scheduled-tasks.service.js +1 -4
- package/dist/schedules/schedules.module.js +5 -3
- package/dist/skills/invoke.d.ts +1 -1
- package/dist/skills/invoke.js +2 -3
- package/dist/tools/approvals.service.d.ts +8 -5
- package/dist/tools/approvals.service.js +5 -5
- package/dist/tools/builtins/sandbox/bash.js +1 -2
- package/dist/tools/builtins/sandbox/common.d.ts +15 -9
- package/dist/tools/builtins/sandbox/common.js +37 -38
- package/dist/tools/connectors.controller.d.ts +2 -0
- package/dist/tools/connectors.schemas.d.ts +2 -0
- package/dist/tools/credentials.d.ts +2 -0
- package/dist/tools/network-asks.d.ts +19 -22
- package/dist/tools/network-asks.js +15 -21
- package/dist/tools/oauth/authorization-params.d.ts +7 -0
- package/dist/tools/oauth/authorization-params.js +19 -0
- package/dist/tools/oauth/flow.js +7 -0
- package/dist/tools/oauth/tokens.js +2 -1
- package/dist/tools/pipeline.d.ts +6 -7
- package/dist/tools/pipeline.js +17 -21
- package/dist/tools/tools.module.js +3 -7
- package/package.json +3 -4
- package/src/migrations/0177_dial_in_contract.sql +32 -0
- package/dist/local-devices/device-auth.module.d.ts +0 -7
- package/dist/local-devices/device-auth.module.js +0 -25
- package/dist/local-devices/device-policy.service.d.ts +0 -213
- package/dist/local-devices/device-policy.service.js +0 -605
- package/dist/local-devices/instance-bindings.d.ts +0 -82
- package/dist/local-devices/instance-bindings.js +0 -307
- package/dist/local-devices/local-device-gateway.d.ts +0 -153
- package/dist/local-devices/local-device-provider.d.ts +0 -122
- package/dist/local-devices/local-device-provider.js +0 -326
- package/dist/local-devices/local-devices.module.d.ts +0 -31
- package/dist/local-devices/local-devices.module.js +0 -100
- package/dist/local-devices/machines.d.ts +0 -211
- package/dist/local-devices/machines.js +0 -766
- package/dist/local-devices/owner-report.d.ts +0 -81
- package/dist/local-devices/owner-report.js +0 -150
- package/dist/local-devices/owner-reports.d.ts +0 -48
- package/dist/local-devices/owner-reports.js +0 -208
- package/dist/local-devices/policy-op-jobs.d.ts +0 -15
- package/dist/local-devices/policy-op-jobs.js +0 -12
- package/dist/local-devices/policy-summary.d.ts +0 -102
- package/dist/local-devices/policy-summary.js +0 -155
- package/dist/local-devices/relay.d.ts +0 -166
- package/dist/local-devices/relay.js +0 -559
- package/dist/tools/device-op-resolver.d.ts +0 -34
- package/dist/tools/device-op-resolver.js +0 -120
- /package/dist/{local-devices → dial-in}/keys.d.ts +0 -0
- /package/dist/{local-devices → dial-in}/keys.js +0 -0
- /package/dist/{local-devices → sandbox}/network-grants.module.d.ts +0 -0
- /package/dist/{local-devices → sandbox}/network-grants.module.js +0 -0
package/dist/devices/dto.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export declare const DeviceParams: z.ZodObject<{
|
|
|
16
16
|
id: z.ZodString;
|
|
17
17
|
}, z.core.$strip>;
|
|
18
18
|
/**
|
|
19
|
-
* A
|
|
19
|
+
* A device's sandbox network (approval-only profiles design, "Settings model"): `open` (the
|
|
20
20
|
* public internet), `allowlist` (its org's hosts, narrowed to `hosts` when given: a device list
|
|
21
21
|
* never adds a host, and an empty one follows the org's), `none` (closed), or `null` to follow its
|
|
22
22
|
* org again. `hosts` only with `allowlist`.
|
|
@@ -30,11 +30,10 @@ export declare const DeviceNetworkBody: z.ZodObject<{
|
|
|
30
30
|
hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
31
|
}, z.core.$strict>;
|
|
32
32
|
/**
|
|
33
|
-
* `PATCH /devices/:id`: a new name, and
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* Platform tool (`devices.set-network`) the network may only narrow.
|
|
33
|
+
* `PATCH /devices/:id`: a new name, and the device's sandbox `network` ({@link DeviceNetworkBody}),
|
|
34
|
+
* within its org's and the platform's ceilings (`device.network_not_allowed` above them), the
|
|
35
|
+
* same for every provider. Through an API token or the Platform tool (`devices.set-network`) the
|
|
36
|
+
* network may only narrow.
|
|
38
37
|
*/
|
|
39
38
|
export declare const DevicePatchBody: z.ZodObject<{
|
|
40
39
|
name: z.ZodOptional<z.ZodString>;
|
|
@@ -47,22 +46,6 @@ export declare const DevicePatchBody: z.ZodObject<{
|
|
|
47
46
|
hosts: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
47
|
}, z.core.$strict>>;
|
|
49
48
|
}, z.core.$strict>;
|
|
50
|
-
/**
|
|
51
|
-
* `POST /devices/:id/policy` (approval-only profiles design, "Settings model"): the device owner
|
|
52
|
-
* narrows the local machine's sandbox from the web: `remove` hosts from its allowlist, and narrow
|
|
53
|
-
* its owner ceiling (`outsideSandbox: false`, `network: "allowlist"`, `restrictedProjectReach:
|
|
54
|
-
* "workspace"`). The web never widens it: the owner adds hosts, opens the network or allows
|
|
55
|
-
* running outside the sandbox on the machine (`capybara-device policy add allowedDomains`,
|
|
56
|
-
* `capybara-device ceiling set`).
|
|
57
|
-
*/
|
|
58
|
-
export declare const DevicePolicyBody: z.ZodObject<{
|
|
59
|
-
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
60
|
-
ownerCeiling: z.ZodOptional<z.ZodObject<{
|
|
61
|
-
outsideSandbox: z.ZodOptional<z.ZodLiteral<false>>;
|
|
62
|
-
network: z.ZodOptional<z.ZodLiteral<"allowlist">>;
|
|
63
|
-
restrictedProjectReach: z.ZodOptional<z.ZodLiteral<"workspace">>;
|
|
64
|
-
}, z.core.$strict>>;
|
|
65
|
-
}, z.core.$strict>;
|
|
66
49
|
/**
|
|
67
50
|
* A project's name (project root §4.1, `isDeviceProjectName`): 1-64 UTF-16 code units, not `.` or
|
|
68
51
|
* `..`, no `/`, no control characters, no leading or trailing whitespace; unique on its device.
|
|
@@ -106,16 +89,6 @@ declare const DeviceParamsDto_base: import("../infra/validation/create-zod-dto.j
|
|
|
106
89
|
}, z.core.$strip>>;
|
|
107
90
|
export declare class DeviceParamsDto extends DeviceParamsDto_base {
|
|
108
91
|
}
|
|
109
|
-
declare const DevicePolicyBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
110
|
-
remove: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
111
|
-
ownerCeiling: z.ZodOptional<z.ZodObject<{
|
|
112
|
-
outsideSandbox: z.ZodOptional<z.ZodLiteral<false>>;
|
|
113
|
-
network: z.ZodOptional<z.ZodLiteral<"allowlist">>;
|
|
114
|
-
restrictedProjectReach: z.ZodOptional<z.ZodLiteral<"workspace">>;
|
|
115
|
-
}, z.core.$strict>>;
|
|
116
|
-
}, z.core.$strict>>;
|
|
117
|
-
export declare class DevicePolicyBodyDto extends DevicePolicyBodyDto_base {
|
|
118
|
-
}
|
|
119
92
|
declare const DeviceProjectAddBodyDto_base: import("../infra/validation/create-zod-dto.js").ZodDtoClass<z.ZodObject<{
|
|
120
93
|
path: z.ZodString;
|
|
121
94
|
name: z.ZodOptional<z.ZodString & z.ZodType<string, string, z.core.$ZodTypeInternals<string, string>>>;
|
package/dist/devices/dto.js
CHANGED
|
@@ -27,7 +27,7 @@ const PolicyHost = z
|
|
|
27
27
|
ctx.addIssue({ code: "custom", message });
|
|
28
28
|
});
|
|
29
29
|
/**
|
|
30
|
-
* A
|
|
30
|
+
* A device's sandbox network (approval-only profiles design, "Settings model"): `open` (the
|
|
31
31
|
* public internet), `allowlist` (its org's hosts, narrowed to `hosts` when given: a device list
|
|
32
32
|
* never adds a host, and an empty one follows the org's), `none` (closed), or `null` to follow its
|
|
33
33
|
* org again. `hosts` only with `allowlist`.
|
|
@@ -42,11 +42,10 @@ export const DeviceNetworkBody = z
|
|
|
42
42
|
message: "Give hosts only with the allowlist network",
|
|
43
43
|
});
|
|
44
44
|
/**
|
|
45
|
-
* `PATCH /devices/:id`: a new name, and
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* Platform tool (`devices.set-network`) the network may only narrow.
|
|
45
|
+
* `PATCH /devices/:id`: a new name, and the device's sandbox `network` ({@link DeviceNetworkBody}),
|
|
46
|
+
* within its org's and the platform's ceilings (`device.network_not_allowed` above them), the
|
|
47
|
+
* same for every provider. Through an API token or the Platform tool (`devices.set-network`) the
|
|
48
|
+
* network may only narrow.
|
|
50
49
|
*/
|
|
51
50
|
export const DevicePatchBody = z
|
|
52
51
|
.object({
|
|
@@ -57,35 +56,6 @@ export const DevicePatchBody = z
|
|
|
57
56
|
.refine((b) => b.name !== undefined || b.network !== undefined, {
|
|
58
57
|
message: "Give at least one of name or network",
|
|
59
58
|
});
|
|
60
|
-
/**
|
|
61
|
-
* `POST /devices/:id/policy` (approval-only profiles design, "Settings model"): the device owner
|
|
62
|
-
* narrows the local machine's sandbox from the web: `remove` hosts from its allowlist, and narrow
|
|
63
|
-
* its owner ceiling (`outsideSandbox: false`, `network: "allowlist"`, `restrictedProjectReach:
|
|
64
|
-
* "workspace"`). The web never widens it: the owner adds hosts, opens the network or allows
|
|
65
|
-
* running outside the sandbox on the machine (`capybara-device policy add allowedDomains`,
|
|
66
|
-
* `capybara-device ceiling set`).
|
|
67
|
-
*/
|
|
68
|
-
export const DevicePolicyBody = z
|
|
69
|
-
.object({
|
|
70
|
-
remove: z.array(PolicyHost).min(1).max(100).optional(),
|
|
71
|
-
ownerCeiling: z
|
|
72
|
-
.object({
|
|
73
|
-
outsideSandbox: z.literal(false).optional(),
|
|
74
|
-
network: z.literal("allowlist").optional(),
|
|
75
|
-
restrictedProjectReach: z.literal("workspace").optional(),
|
|
76
|
-
})
|
|
77
|
-
.strict()
|
|
78
|
-
.refine((c) => c.outsideSandbox !== undefined ||
|
|
79
|
-
c.network !== undefined ||
|
|
80
|
-
c.restrictedProjectReach !== undefined, {
|
|
81
|
-
message: "Give outsideSandbox: false, network: allowlist or restrictedProjectReach: workspace",
|
|
82
|
-
})
|
|
83
|
-
.optional(),
|
|
84
|
-
})
|
|
85
|
-
.strict()
|
|
86
|
-
.refine((b) => b.remove !== undefined || b.ownerCeiling !== undefined, {
|
|
87
|
-
message: "Give at least one of remove or ownerCeiling",
|
|
88
|
-
});
|
|
89
59
|
/**
|
|
90
60
|
* A project's name (project root §4.1, `isDeviceProjectName`): 1-64 UTF-16 code units, not `.` or
|
|
91
61
|
* `..`, no `/`, no control characters, no leading or trailing whitespace; unique on its device.
|
|
@@ -125,8 +95,6 @@ export class DevicePatchBodyDto extends createZodDto(DevicePatchBody, "DevicePat
|
|
|
125
95
|
}
|
|
126
96
|
export class DeviceParamsDto extends createZodDto(DeviceParams, "DeviceParams") {
|
|
127
97
|
}
|
|
128
|
-
export class DevicePolicyBodyDto extends createZodDto(DevicePolicyBody, "DevicePolicyBody") {
|
|
129
|
-
}
|
|
130
98
|
export class DeviceProjectAddBodyDto extends createZodDto(DeviceProjectAddBody, "DeviceProjectAddBody") {
|
|
131
99
|
}
|
|
132
100
|
export class DeviceProjectParamsDto extends createZodDto(DeviceProjectParams, "DeviceProjectParams") {
|
package/dist/devices/errors.d.ts
CHANGED
|
@@ -2,12 +2,13 @@ import { ApiError } from "../errors.js";
|
|
|
2
2
|
/** The device is missing, deleted, or not in the caller's org (404; ids cannot be probed). */
|
|
3
3
|
export declare const deviceNotFound: () => ApiError;
|
|
4
4
|
/**
|
|
5
|
-
* The device
|
|
6
|
-
* with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model
|
|
5
|
+
* The machine serving a dial-in device was disconnected (revoked, signed out): 403
|
|
6
|
+
* `device.forbidden` with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model
|
|
7
|
+
* what to ask for.
|
|
7
8
|
*/
|
|
8
9
|
export declare const machineRevoked: () => ApiError;
|
|
9
10
|
/**
|
|
10
|
-
* The device offers no projects (project root §4.1):
|
|
11
|
-
*
|
|
11
|
+
* The device offers no projects (project root §4.1): its provider does not implement `list`
|
|
12
|
+
* (or `scan`).
|
|
12
13
|
*/
|
|
13
|
-
export declare const projectsUnsupported: (
|
|
14
|
+
export declare const projectsUnsupported: () => ApiError;
|
package/dist/devices/errors.js
CHANGED
|
@@ -2,14 +2,13 @@ import { ApiError } from "../errors.js";
|
|
|
2
2
|
/** The device is missing, deleted, or not in the caller's org (404; ids cannot be probed). */
|
|
3
3
|
export const deviceNotFound = () => new ApiError("device.not_found", "This device does not exist or was deleted.");
|
|
4
4
|
/**
|
|
5
|
-
* The device
|
|
6
|
-
* with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model
|
|
5
|
+
* The machine serving a dial-in device was disconnected (revoked, signed out): 403
|
|
6
|
+
* `device.forbidden` with `details: [{ reason: "machine_revoked" }]`, so the tools tell the model
|
|
7
|
+
* what to ask for.
|
|
7
8
|
*/
|
|
8
|
-
export const machineRevoked = () => new ApiError("device.forbidden", "The machine
|
|
9
|
+
export const machineRevoked = () => new ApiError("device.forbidden", "The machine serving this device was disconnected. Sign that machine in to this device again, or pick another device.", [{ reason: "machine_revoked" }]);
|
|
9
10
|
/**
|
|
10
|
-
* The device offers no projects (project root §4.1):
|
|
11
|
-
*
|
|
11
|
+
* The device offers no projects (project root §4.1): its provider does not implement `list`
|
|
12
|
+
* (or `scan`).
|
|
12
13
|
*/
|
|
13
|
-
export const projectsUnsupported = (
|
|
14
|
-
? "This device's capybara-device does not support projects; update capybara-device on that machine and reconnect it."
|
|
15
|
-
: "This device's sandbox provider does not support projects; its conversations work without one.");
|
|
14
|
+
export const projectsUnsupported = () => new ApiError("device.projects_unsupported", "This device's provider does not support projects; its conversations work without one.");
|
|
@@ -2,24 +2,23 @@ import { ApiError } from "../errors.js";
|
|
|
2
2
|
import type { SandboxMode } from "../sandbox/modes.js";
|
|
3
3
|
/** What a project's scope is read from: the device's mode now and the bases it gives. */
|
|
4
4
|
export interface DeviceProjectScope {
|
|
5
|
-
source: "cloud" | "local";
|
|
6
5
|
mode: SandboxMode;
|
|
6
|
+
/** The workspace root as last known (the held instance's handle). */
|
|
7
|
+
workspace: string;
|
|
7
8
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
9
|
+
* The home its provider last reported (`devices.report.home`): projects are relative to it and
|
|
10
|
+
* the kernel narrows no path below it (where a project may lie is the provider's rule); null
|
|
11
|
+
* when the provider reports none, and projects stay in the workspace.
|
|
10
12
|
*/
|
|
11
|
-
reach: "workspace" | "os-user";
|
|
12
|
-
/** The workspace root as last known (a machine's hello, a cloud instance's handle). */
|
|
13
|
-
workspace: string;
|
|
14
|
-
/** The owner's home a local machine reported; null when unknown (and for a cloud device). */
|
|
15
13
|
home: string | null;
|
|
16
14
|
supported: boolean;
|
|
17
15
|
}
|
|
18
16
|
type Scope = DeviceProjectScope;
|
|
19
|
-
/** The base a relative path
|
|
20
|
-
export declare const baseOf: (s: Scope, workspace?: string) => string
|
|
17
|
+
/** The base a relative path resolves against (project root §4.2): the home, else the workspace. */
|
|
18
|
+
export declare const baseOf: (s: Scope, workspace?: string) => string;
|
|
21
19
|
/**
|
|
22
|
-
* `path` lies inside what the scope's
|
|
20
|
+
* `path` lies inside what the kernel lets the scope's projects reach: anywhere when the provider
|
|
21
|
+
* reports a home (the provider refuses what it will not serve), else inside the workspace (as the
|
|
23
22
|
* held instance reports it when given).
|
|
24
23
|
*/
|
|
25
24
|
export declare const withinMode: (s: Scope, path: string, workspace?: string) => boolean;
|
|
@@ -28,7 +27,6 @@ export declare const nameTaken: (name: string) => ApiError;
|
|
|
28
27
|
export declare const projectNotFound: (name: string) => ApiError;
|
|
29
28
|
export declare const outsideMode: (path: string, mode: SandboxMode) => ApiError;
|
|
30
29
|
export declare const tooBroad: (path: string) => ApiError;
|
|
31
|
-
export declare const homeUnknown: () => ApiError;
|
|
32
30
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
33
31
|
export declare function clipped(s: string, max?: number): string;
|
|
34
32
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { ApiError } from "../errors.js";
|
|
2
|
-
/**
|
|
3
|
-
const
|
|
4
|
-
/** The base a relative path is resolved against in the scope's mode (project root §4.2). */
|
|
5
|
-
export const baseOf = (s, workspace = s.workspace) => homeBased(s) ? s.home : workspace;
|
|
2
|
+
/** The base a relative path resolves against (project root §4.2): the home, else the workspace. */
|
|
3
|
+
export const baseOf = (s, workspace = s.workspace) => s.home ?? workspace;
|
|
6
4
|
/**
|
|
7
|
-
* `path` lies inside what the scope's
|
|
5
|
+
* `path` lies inside what the kernel lets the scope's projects reach: anywhere when the provider
|
|
6
|
+
* reports a home (the provider refuses what it will not serve), else inside the workspace (as the
|
|
8
7
|
* held instance reports it when given).
|
|
9
8
|
*/
|
|
10
|
-
export const withinMode = (s, path, workspace = s.workspace) =>
|
|
9
|
+
export const withinMode = (s, path, workspace = s.workspace) => s.home !== null ||
|
|
10
|
+
path === workspace ||
|
|
11
|
+
path.startsWith(workspace === "/" ? "/" : `${workspace}/`);
|
|
11
12
|
export const nameInvalid = (name) => new ApiError("device.project_name_invalid", `"${clipped(name)}" is not a valid project name: use 1-64 characters, not . or .., without / or control characters, and without leading or trailing spaces`);
|
|
12
13
|
export const nameTaken = (name) => new ApiError("device.project_name_taken", `This device already has a project named "${clipped(name)}"; pick another name`);
|
|
13
14
|
export const projectNotFound = (name) => new ApiError("device.project_not_found", `This device has no project named "${clipped(name)}"`);
|
|
@@ -15,7 +16,6 @@ export const outsideMode = (path, mode) => new ApiError("device.project_outside_
|
|
|
15
16
|
? `${clipped(path)} is outside the device's workspace, the only directory it can read in sandbox mode`
|
|
16
17
|
: `${clipped(path)} is outside the device's workspace, the only directory a cloud device can read`);
|
|
17
18
|
export const tooBroad = (path) => new ApiError("device.project_path_too_broad", `${clipped(path)} holds the owner's home directory (or other people's): pick the project's own directory, the home or below it`);
|
|
18
|
-
export const homeUnknown = () => new ApiError("device.project_home_unknown", "In auto mode a project's path is relative to the owner's home directory, which this device has not reported; update capybara-device on that machine and reconnect it");
|
|
19
19
|
/** A device-supplied or person-supplied string inside a message, bounded. */
|
|
20
20
|
export function clipped(s, max = 200) {
|
|
21
21
|
return s.length <= max ? s : `${s.slice(0, max)}…`;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { SandboxMode } from "../sandbox/modes.js";
|
|
2
1
|
/**
|
|
3
2
|
* What decides a conversation's working root (project root spec §4.3): the latest `project_root`
|
|
4
3
|
* event of its root conversation (sub-agents inherit their root's binding), or the bound root
|
|
@@ -24,15 +23,13 @@ export declare function aboveHome(root: string, home: string | null | undefined)
|
|
|
24
23
|
* `Glob` and `Grep` search by default, what a relative file-tool path resolves against, and the
|
|
25
24
|
* command review's `workspace` fact. It is the project's root when the latest snapshot is usable,
|
|
26
25
|
* else the device's `workspace` (free mode). It never widens anything: a root that is not a clean
|
|
27
|
-
* absolute path, one the run cannot use
|
|
28
|
-
*
|
|
29
|
-
*
|
|
26
|
+
* absolute path, one the run cannot use and one above the owner's home ({@link aboveHome}) all
|
|
27
|
+
* fall back to the device's workspace. Where a project may lie is its device provider's rule
|
|
28
|
+
* (device-provider spec §6.1), checked when the project was added.
|
|
30
29
|
*/
|
|
31
30
|
export declare function workingRootOf(project: WorkingProject | null | undefined, device: {
|
|
32
|
-
mode: SandboxMode;
|
|
33
31
|
workspace: string;
|
|
34
32
|
home?: string | null;
|
|
35
|
-
reach?: "workspace" | "os-user" | undefined;
|
|
36
33
|
}): string;
|
|
37
34
|
/**
|
|
38
35
|
* A root in the one form two roots are compared in (B-18): POSIX-normalized (`.` and doubled `/`
|
|
@@ -21,9 +21,9 @@ const isInside = (path, dir) => path === dir || path.startsWith(dir === "/" ? "/
|
|
|
21
21
|
* `Glob` and `Grep` search by default, what a relative file-tool path resolves against, and the
|
|
22
22
|
* command review's `workspace` fact. It is the project's root when the latest snapshot is usable,
|
|
23
23
|
* else the device's `workspace` (free mode). It never widens anything: a root that is not a clean
|
|
24
|
-
* absolute path, one the run cannot use
|
|
25
|
-
*
|
|
26
|
-
*
|
|
24
|
+
* absolute path, one the run cannot use and one above the owner's home ({@link aboveHome}) all
|
|
25
|
+
* fall back to the device's workspace. Where a project may lie is its device provider's rule
|
|
26
|
+
* (device-provider spec §6.1), checked when the project was added.
|
|
27
27
|
*/
|
|
28
28
|
export function workingRootOf(project, device) {
|
|
29
29
|
if (project == null || project.unavailable)
|
|
@@ -33,11 +33,6 @@ export function workingRootOf(project, device) {
|
|
|
33
33
|
: project.root;
|
|
34
34
|
if (validateSandboxPathShape(root).length > 0)
|
|
35
35
|
return device.workspace;
|
|
36
|
-
// B2: a root outside the workspace needs the wider restricted reach (`reach`, given apart from
|
|
37
|
-
// the Full mode); without it, the protocol 2 encoding (`mode: auto` was that reach)
|
|
38
|
-
const wide = device.reach !== undefined ? device.reach === "os-user" : device.mode === "auto";
|
|
39
|
-
if (!wide && !isInside(root, device.workspace))
|
|
40
|
-
return device.workspace;
|
|
41
36
|
if (aboveHome(root, device.home))
|
|
42
37
|
return device.workspace;
|
|
43
38
|
return root;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
2
|
+
import { DialInRelay, type DialInRequestOptions } from "./relay.js";
|
|
3
|
+
/**
|
|
4
|
+
* What `ctx.dialIn` is built from (`ctx/create-ctx.ts`): the relay, and the check that a device is
|
|
5
|
+
* served by the calling extension. Kept below the extension host (its module imports nothing but
|
|
6
|
+
* the global infrastructure), so the host can build every extension's `ctx` from it.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DialInAccess {
|
|
9
|
+
private readonly kdb;
|
|
10
|
+
private readonly relay;
|
|
11
|
+
constructor(kdb: KernelDb, relay: Pick<DialInRelay, "request" | "online" | "stop">);
|
|
12
|
+
/**
|
|
13
|
+
* Whether `deviceId` is a live device (in a live org) whose `devices.provider` is `plugin`, and
|
|
14
|
+
* `plugin` is enabled in the device's org. Read from PG at every call. The full availability
|
|
15
|
+
* check (valid org and effective config, `DeviceProviderSelection.isOnInOrg`) runs at the
|
|
16
|
+
* machine's hello; this one stays below the extension host's module.
|
|
17
|
+
*/
|
|
18
|
+
serves(plugin: string, deviceId: string): Promise<boolean>;
|
|
19
|
+
/** {@link DialInRelay.request} with only the options an extension may pass. */
|
|
20
|
+
request(deviceId: string, body: unknown, opts: Pick<DialInRequestOptions, "timeoutMs" | "signal">): Promise<unknown>;
|
|
21
|
+
online(deviceId: string): Promise<boolean>;
|
|
22
|
+
stop(deviceId: string, reason: "drain" | "stop"): Promise<void>;
|
|
23
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
8
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
9
|
+
};
|
|
10
|
+
import { Inject, Injectable } from "@nestjs/common";
|
|
11
|
+
import { isExtensionEnabled } from "../extensions/enabled.js";
|
|
12
|
+
import { KernelDb } from "../infra/database/kernel-db.js";
|
|
13
|
+
import { DialInRelay } from "./relay.js";
|
|
14
|
+
/**
|
|
15
|
+
* What `ctx.dialIn` is built from (`ctx/create-ctx.ts`): the relay, and the check that a device is
|
|
16
|
+
* served by the calling extension. Kept below the extension host (its module imports nothing but
|
|
17
|
+
* the global infrastructure), so the host can build every extension's `ctx` from it.
|
|
18
|
+
*/
|
|
19
|
+
let DialInAccess = class DialInAccess {
|
|
20
|
+
kdb;
|
|
21
|
+
relay;
|
|
22
|
+
constructor(kdb, relay) {
|
|
23
|
+
this.kdb = kdb;
|
|
24
|
+
this.relay = relay;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Whether `deviceId` is a live device (in a live org) whose `devices.provider` is `plugin`, and
|
|
28
|
+
* `plugin` is enabled in the device's org. Read from PG at every call. The full availability
|
|
29
|
+
* check (valid org and effective config, `DeviceProviderSelection.isOnInOrg`) runs at the
|
|
30
|
+
* machine's hello; this one stays below the extension host's module.
|
|
31
|
+
*/
|
|
32
|
+
async serves(plugin, deviceId) {
|
|
33
|
+
const row = await this.kdb.db
|
|
34
|
+
.selectFrom("devices as d")
|
|
35
|
+
.innerJoin("orgs as o", "o.id", "d.org_id")
|
|
36
|
+
.select(["d.org_id", "d.provider"])
|
|
37
|
+
.where("d.id", "=", deviceId)
|
|
38
|
+
.where("d.deleted_at", "is", null)
|
|
39
|
+
.where("o.deleted_at", "is", null)
|
|
40
|
+
.executeTakeFirst();
|
|
41
|
+
if (!row || row.provider !== plugin)
|
|
42
|
+
return false;
|
|
43
|
+
return isExtensionEnabled(this.kdb.db, row.org_id, plugin);
|
|
44
|
+
}
|
|
45
|
+
/** {@link DialInRelay.request} with only the options an extension may pass. */
|
|
46
|
+
request(deviceId, body, opts) {
|
|
47
|
+
return this.relay.request(deviceId, body, {
|
|
48
|
+
timeoutMs: opts.timeoutMs,
|
|
49
|
+
...(opts.signal !== undefined && { signal: opts.signal }),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
online(deviceId) {
|
|
53
|
+
return this.relay.online(deviceId);
|
|
54
|
+
}
|
|
55
|
+
stop(deviceId, reason) {
|
|
56
|
+
return this.relay.stop(deviceId, reason);
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
DialInAccess = __decorate([
|
|
60
|
+
Injectable(),
|
|
61
|
+
__param(0, Inject(KernelDb)),
|
|
62
|
+
__param(1, Inject(DialInRelay))
|
|
63
|
+
], DialInAccess);
|
|
64
|
+
export { DialInAccess };
|
|
@@ -2,14 +2,14 @@ import type { FastifyReply, FastifyRequest } from "fastify";
|
|
|
2
2
|
import type { z } from "zod";
|
|
3
3
|
import { type Principal } from "../identity/principal.js";
|
|
4
4
|
import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
|
|
5
|
-
import { type DeviceAuthorization,
|
|
6
|
-
import { type DeviceAuthorizeBody, type DeviceConfirmBody, type DeviceTokenBody, type DeviceUserCodeBody, type DeviceUserCodeParams } from "./dto.js";
|
|
5
|
+
import { type DeviceAuthorization, type DeviceGrant, type DeviceMachineInfo, DialInAuthService, type DialInProviderChoice } from "./auth.service.js";
|
|
6
|
+
import { type DeviceAuthorizeBody, type DeviceConfirmBody, type DeviceProvidersQuery, type DeviceTokenBody, type DeviceUserCodeBody, type DeviceUserCodeParams } from "./dto.js";
|
|
7
7
|
/**
|
|
8
8
|
* Device sign-in (`/api/v1/device`, environments spec §13.3; the shape of RFC 8628).
|
|
9
9
|
*
|
|
10
10
|
* The program's routes are public (it has no credential yet); like every public unsafe route
|
|
11
11
|
* they need `X-Capybara-Csrf: 1`, which `capybara-device` sends:
|
|
12
|
-
* - `POST /authorize { name, os, arch, programVersion }` → `{ deviceCode, userCode,
|
|
12
|
+
* - `POST /authorize { name, os, arch, programVersion, protocol }` → `{ deviceCode, userCode,
|
|
13
13
|
* verificationUri, verificationUriComplete, interval, expiresIn }` (`device-authorize-ip`);
|
|
14
14
|
* - `POST /token { deviceCode }` → `{ credential, orgId, deviceId, connectUrl,
|
|
15
15
|
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
@@ -18,21 +18,27 @@ import { type DeviceAuthorizeBody, type DeviceConfirmBody, type DeviceTokenBody,
|
|
|
18
18
|
* The person's routes need a web session (the confirmation page `/device`); each try of a user
|
|
19
19
|
* code counts on `device-code-account` (refunded on success):
|
|
20
20
|
* - `GET /pending/:userCode` → `{ machine, expiresAt }`;
|
|
21
|
-
* - `
|
|
21
|
+
* - `GET /providers?orgId&userCode` → `{ providers: [{ plugin, displayName, devices }] }`: the
|
|
22
|
+
* dial-in providers on in the org that speak the program's protocol, each with the person's
|
|
23
|
+
* devices of it (`agents.use` in the org);
|
|
24
|
+
* - `POST /confirm { userCode, orgId, provider, deviceId | name }` → `{ deviceId }`
|
|
22
25
|
* (`device_sign_in.expired` / `device_sign_in.unavailable` when the credential could not be handed over: the
|
|
23
26
|
* machine is revoked again and the person runs login again);
|
|
24
27
|
* - `POST /deny { userCode }` → 204.
|
|
25
28
|
*/
|
|
26
|
-
export declare class
|
|
29
|
+
export declare class DialInAuthController {
|
|
27
30
|
private readonly auth;
|
|
28
31
|
private readonly throttler;
|
|
29
|
-
constructor(auth:
|
|
32
|
+
constructor(auth: DialInAuthService, throttler: CredentialThrottler);
|
|
30
33
|
authorize(body: z.infer<typeof DeviceAuthorizeBody>): Promise<DeviceAuthorization>;
|
|
31
34
|
token(body: z.infer<typeof DeviceTokenBody>): Promise<DeviceGrant>;
|
|
32
35
|
pending(principal: Principal, params: z.infer<typeof DeviceUserCodeParams>, req: FastifyRequest, reply: FastifyReply): Promise<{
|
|
33
36
|
machine: DeviceMachineInfo;
|
|
34
37
|
expiresAt: string;
|
|
35
38
|
}>;
|
|
39
|
+
providers(principal: Principal, query: z.infer<typeof DeviceProvidersQuery>, req: FastifyRequest, reply: FastifyReply): Promise<{
|
|
40
|
+
providers: DialInProviderChoice[];
|
|
41
|
+
}>;
|
|
36
42
|
confirm(principal: Principal, body: z.infer<typeof DeviceConfirmBody>, req: FastifyRequest, reply: FastifyReply): Promise<{
|
|
37
43
|
deviceId: string;
|
|
38
44
|
}>;
|
|
@@ -11,9 +11,9 @@ import { Controller, Get, HttpCode, Inject, Post, Req, Res } from "@nestjs/commo
|
|
|
11
11
|
import { CurrentPrincipal, Public, requireUser, SessionOnly, } from "../identity/principal.js";
|
|
12
12
|
import { CredentialThrottler } from "../infra/throttler/credential-throttler.js";
|
|
13
13
|
import { Throttled } from "../infra/throttler/throttler.guard.js";
|
|
14
|
-
import { ZBody, ZParam } from "../infra/validation/zod-params.js";
|
|
15
|
-
import {
|
|
16
|
-
import { DeviceAuthorizeBodyDto, DeviceConfirmBodyDto, DeviceTokenBodyDto, DeviceUserCodeBodyDto, DeviceUserCodeParamsDto, } from "./dto.js";
|
|
14
|
+
import { ZBody, ZParam, ZQuery } from "../infra/validation/zod-params.js";
|
|
15
|
+
import { DialInAuthService, } from "./auth.service.js";
|
|
16
|
+
import { DeviceAuthorizeBodyDto, DeviceConfirmBodyDto, DeviceProvidersQueryDto, DeviceTokenBodyDto, DeviceUserCodeBodyDto, DeviceUserCodeParamsDto, } from "./dto.js";
|
|
17
17
|
/** The throttler of every route that takes a user code (guessing another machine's code). */
|
|
18
18
|
const CODE_THROTTLER = ["device-code-account"];
|
|
19
19
|
/**
|
|
@@ -21,7 +21,7 @@ const CODE_THROTTLER = ["device-code-account"];
|
|
|
21
21
|
*
|
|
22
22
|
* The program's routes are public (it has no credential yet); like every public unsafe route
|
|
23
23
|
* they need `X-Capybara-Csrf: 1`, which `capybara-device` sends:
|
|
24
|
-
* - `POST /authorize { name, os, arch, programVersion }` → `{ deviceCode, userCode,
|
|
24
|
+
* - `POST /authorize { name, os, arch, programVersion, protocol }` → `{ deviceCode, userCode,
|
|
25
25
|
* verificationUri, verificationUriComplete, interval, expiresIn }` (`device-authorize-ip`);
|
|
26
26
|
* - `POST /token { deviceCode }` → `{ credential, orgId, deviceId, connectUrl,
|
|
27
27
|
* reconnectGraceSeconds, maxFrameBytes, outsideSandbox }` once, else `device_sign_in.authorization_pending` / `device_sign_in.slow_down` /
|
|
@@ -30,12 +30,15 @@ const CODE_THROTTLER = ["device-code-account"];
|
|
|
30
30
|
* The person's routes need a web session (the confirmation page `/device`); each try of a user
|
|
31
31
|
* code counts on `device-code-account` (refunded on success):
|
|
32
32
|
* - `GET /pending/:userCode` → `{ machine, expiresAt }`;
|
|
33
|
-
* - `
|
|
33
|
+
* - `GET /providers?orgId&userCode` → `{ providers: [{ plugin, displayName, devices }] }`: the
|
|
34
|
+
* dial-in providers on in the org that speak the program's protocol, each with the person's
|
|
35
|
+
* devices of it (`agents.use` in the org);
|
|
36
|
+
* - `POST /confirm { userCode, orgId, provider, deviceId | name }` → `{ deviceId }`
|
|
34
37
|
* (`device_sign_in.expired` / `device_sign_in.unavailable` when the credential could not be handed over: the
|
|
35
38
|
* machine is revoked again and the person runs login again);
|
|
36
39
|
* - `POST /deny { userCode }` → 204.
|
|
37
40
|
*/
|
|
38
|
-
let
|
|
41
|
+
let DialInAuthController = class DialInAuthController {
|
|
39
42
|
auth;
|
|
40
43
|
throttler;
|
|
41
44
|
constructor(auth, throttler) {
|
|
@@ -52,6 +55,10 @@ let DeviceAuthController = class DeviceAuthController {
|
|
|
52
55
|
requireUser(principal);
|
|
53
56
|
return this.counted(req, reply, () => this.auth.pending(params.userCode));
|
|
54
57
|
}
|
|
58
|
+
async providers(principal, query, req, reply) {
|
|
59
|
+
const p = requireUser(principal);
|
|
60
|
+
return this.counted(req, reply, () => this.auth.providers(p, query));
|
|
61
|
+
}
|
|
55
62
|
async confirm(principal, body, req, reply) {
|
|
56
63
|
const p = requireUser(principal);
|
|
57
64
|
return this.counted(req, reply, () => this.auth.confirm(p, body));
|
|
@@ -74,14 +81,14 @@ __decorate([
|
|
|
74
81
|
HttpCode(200),
|
|
75
82
|
Throttled("device-authorize-ip"),
|
|
76
83
|
__param(0, ZBody(DeviceAuthorizeBodyDto))
|
|
77
|
-
],
|
|
84
|
+
], DialInAuthController.prototype, "authorize", null);
|
|
78
85
|
__decorate([
|
|
79
86
|
Post("token"),
|
|
80
87
|
Public(),
|
|
81
88
|
HttpCode(200),
|
|
82
89
|
Throttled("device-token-ip"),
|
|
83
90
|
__param(0, ZBody(DeviceTokenBodyDto))
|
|
84
|
-
],
|
|
91
|
+
], DialInAuthController.prototype, "token", null);
|
|
85
92
|
__decorate([
|
|
86
93
|
Get("pending/:userCode"),
|
|
87
94
|
SessionOnly(),
|
|
@@ -89,7 +96,15 @@ __decorate([
|
|
|
89
96
|
__param(1, ZParam(DeviceUserCodeParamsDto)),
|
|
90
97
|
__param(2, Req()),
|
|
91
98
|
__param(3, Res({ passthrough: true }))
|
|
92
|
-
],
|
|
99
|
+
], DialInAuthController.prototype, "pending", null);
|
|
100
|
+
__decorate([
|
|
101
|
+
Get("providers"),
|
|
102
|
+
SessionOnly(),
|
|
103
|
+
__param(0, CurrentPrincipal()),
|
|
104
|
+
__param(1, ZQuery(DeviceProvidersQueryDto)),
|
|
105
|
+
__param(2, Req()),
|
|
106
|
+
__param(3, Res({ passthrough: true }))
|
|
107
|
+
], DialInAuthController.prototype, "providers", null);
|
|
93
108
|
__decorate([
|
|
94
109
|
Post("confirm"),
|
|
95
110
|
SessionOnly(),
|
|
@@ -98,7 +113,7 @@ __decorate([
|
|
|
98
113
|
__param(1, ZBody(DeviceConfirmBodyDto)),
|
|
99
114
|
__param(2, Req()),
|
|
100
115
|
__param(3, Res({ passthrough: true }))
|
|
101
|
-
],
|
|
116
|
+
], DialInAuthController.prototype, "confirm", null);
|
|
102
117
|
__decorate([
|
|
103
118
|
Post("deny"),
|
|
104
119
|
SessionOnly(),
|
|
@@ -107,10 +122,10 @@ __decorate([
|
|
|
107
122
|
__param(1, ZBody(DeviceUserCodeBodyDto)),
|
|
108
123
|
__param(2, Req()),
|
|
109
124
|
__param(3, Res({ passthrough: true }))
|
|
110
|
-
],
|
|
111
|
-
|
|
125
|
+
], DialInAuthController.prototype, "deny", null);
|
|
126
|
+
DialInAuthController = __decorate([
|
|
112
127
|
Controller("api/v1/device"),
|
|
113
|
-
__param(0, Inject(
|
|
128
|
+
__param(0, Inject(DialInAuthService)),
|
|
114
129
|
__param(1, Inject(CredentialThrottler))
|
|
115
|
-
],
|
|
116
|
-
export {
|
|
130
|
+
], DialInAuthController);
|
|
131
|
+
export { DialInAuthController };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device sign-in (environments spec §13.3): {@link DialInAuthService} behind
|
|
3
|
+
* `DialInAuthController`. Kept apart from {@link DialInModule}, which `DevicesModule` imports
|
|
4
|
+
* (through the local devices: deleting a device revokes its machine), while sign-in needs both.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DialInAuthModule {
|
|
7
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { Module } from "@nestjs/common";
|
|
8
|
+
import { DevicesModule } from "../devices/devices.module.js";
|
|
9
|
+
import { ExtensionsModule } from "../extensions/extensions.module.js";
|
|
10
|
+
import { DialInAuthService } from "./auth.service.js";
|
|
11
|
+
import { DialInModule } from "./dial-in.module.js";
|
|
12
|
+
/**
|
|
13
|
+
* Device sign-in (environments spec §13.3): {@link DialInAuthService} behind
|
|
14
|
+
* `DialInAuthController`. Kept apart from {@link DialInModule}, which `DevicesModule` imports
|
|
15
|
+
* (through the local devices: deleting a device revokes its machine), while sign-in needs both.
|
|
16
|
+
*/
|
|
17
|
+
let DialInAuthModule = class DialInAuthModule {
|
|
18
|
+
};
|
|
19
|
+
DialInAuthModule = __decorate([
|
|
20
|
+
Module({
|
|
21
|
+
// ExtensionsModule: the providers' display names on the sign-in page
|
|
22
|
+
imports: [DialInModule, DevicesModule, ExtensionsModule],
|
|
23
|
+
providers: [DialInAuthService],
|
|
24
|
+
exports: [DialInAuthService],
|
|
25
|
+
})
|
|
26
|
+
], DialInAuthModule);
|
|
27
|
+
export { DialInAuthModule };
|