@openllmsh/sdk 2.10.19-alpha.0 → 2.10.19-alpha.1
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/openapi/openapi.json +20 -20
- package/dist/openapi/operations.js +18 -18
- package/dist/protocol/daemon.d.ts +1 -1
- package/dist/protocol/daemon.js +1 -1
- package/dist/protocol/index.d.ts +1 -1
- package/dist/protocol/index.js +1 -1
- package/dist/protocol/local-device-control.d.ts +5 -5
- package/dist/protocol/local-device-control.js +5 -5
- package/dist/protocol/mux.js +1 -1
- package/dist/protocol/routebox.d.ts +7 -0
- package/dist/protocol/routebox.js +7 -0
- package/dist/vault/device-control.d.ts +1 -1
- package/dist/vault/device-control.js +1 -1
- package/dist/vault/routebox-key.d.ts +3 -0
- package/dist/vault/{routing-box-key.js → routebox-key.js} +5 -5
- package/dist/vault/{routing-box-seal.d.ts → routebox-seal.d.ts} +10 -10
- package/dist/vault/{routing-box-seal.js → routebox-seal.js} +11 -11
- package/package.json +1 -1
- package/dist/protocol/routing-box.d.ts +0 -7
- package/dist/protocol/routing-box.js +0 -7
- package/dist/vault/routing-box-key.d.ts +0 -3
|
@@ -23249,7 +23249,7 @@
|
|
|
23249
23249
|
"type": "string",
|
|
23250
23250
|
"enum": [
|
|
23251
23251
|
"user",
|
|
23252
|
-
"
|
|
23252
|
+
"routebox"
|
|
23253
23253
|
]
|
|
23254
23254
|
},
|
|
23255
23255
|
"usage": {
|
|
@@ -26371,7 +26371,7 @@
|
|
|
26371
26371
|
"type": "string",
|
|
26372
26372
|
"enum": [
|
|
26373
26373
|
"user",
|
|
26374
|
-
"
|
|
26374
|
+
"routebox"
|
|
26375
26375
|
]
|
|
26376
26376
|
},
|
|
26377
26377
|
"usage": {
|
|
@@ -26755,12 +26755,12 @@
|
|
|
26755
26755
|
}
|
|
26756
26756
|
}
|
|
26757
26757
|
},
|
|
26758
|
-
"/
|
|
26758
|
+
"/routebox": {
|
|
26759
26759
|
"get": {
|
|
26760
26760
|
"tags": [
|
|
26761
|
-
"
|
|
26761
|
+
"routebox"
|
|
26762
26762
|
],
|
|
26763
|
-
"operationId": "
|
|
26763
|
+
"operationId": "routebox.get",
|
|
26764
26764
|
"parameters": [],
|
|
26765
26765
|
"security": [],
|
|
26766
26766
|
"responses": {
|
|
@@ -27331,9 +27331,9 @@
|
|
|
27331
27331
|
},
|
|
27332
27332
|
"post": {
|
|
27333
27333
|
"tags": [
|
|
27334
|
-
"
|
|
27334
|
+
"routebox"
|
|
27335
27335
|
],
|
|
27336
|
-
"operationId": "
|
|
27336
|
+
"operationId": "routebox.create",
|
|
27337
27337
|
"parameters": [],
|
|
27338
27338
|
"security": [],
|
|
27339
27339
|
"responses": {
|
|
@@ -28082,12 +28082,12 @@
|
|
|
28082
28082
|
}
|
|
28083
28083
|
}
|
|
28084
28084
|
},
|
|
28085
|
-
"/
|
|
28085
|
+
"/routebox/{id}/restart": {
|
|
28086
28086
|
"post": {
|
|
28087
28087
|
"tags": [
|
|
28088
|
-
"
|
|
28088
|
+
"routebox"
|
|
28089
28089
|
],
|
|
28090
|
-
"operationId": "
|
|
28090
|
+
"operationId": "routebox.restart",
|
|
28091
28091
|
"parameters": [
|
|
28092
28092
|
{
|
|
28093
28093
|
"name": "id",
|
|
@@ -28666,12 +28666,12 @@
|
|
|
28666
28666
|
}
|
|
28667
28667
|
}
|
|
28668
28668
|
},
|
|
28669
|
-
"/
|
|
28669
|
+
"/routebox/{id}/reset": {
|
|
28670
28670
|
"post": {
|
|
28671
28671
|
"tags": [
|
|
28672
|
-
"
|
|
28672
|
+
"routebox"
|
|
28673
28673
|
],
|
|
28674
|
-
"operationId": "
|
|
28674
|
+
"operationId": "routebox.reset",
|
|
28675
28675
|
"parameters": [
|
|
28676
28676
|
{
|
|
28677
28677
|
"name": "id",
|
|
@@ -29250,12 +29250,12 @@
|
|
|
29250
29250
|
}
|
|
29251
29251
|
}
|
|
29252
29252
|
},
|
|
29253
|
-
"/
|
|
29253
|
+
"/routebox/{id}": {
|
|
29254
29254
|
"delete": {
|
|
29255
29255
|
"tags": [
|
|
29256
|
-
"
|
|
29256
|
+
"routebox"
|
|
29257
29257
|
],
|
|
29258
|
-
"operationId": "
|
|
29258
|
+
"operationId": "routebox.remove",
|
|
29259
29259
|
"parameters": [
|
|
29260
29260
|
{
|
|
29261
29261
|
"name": "id",
|
|
@@ -29834,12 +29834,12 @@
|
|
|
29834
29834
|
}
|
|
29835
29835
|
}
|
|
29836
29836
|
},
|
|
29837
|
-
"/
|
|
29837
|
+
"/routebox/{id}/unlock": {
|
|
29838
29838
|
"post": {
|
|
29839
29839
|
"tags": [
|
|
29840
|
-
"
|
|
29840
|
+
"routebox"
|
|
29841
29841
|
],
|
|
29842
|
-
"operationId": "
|
|
29842
|
+
"operationId": "routebox.unlock",
|
|
29843
29843
|
"parameters": [
|
|
29844
29844
|
{
|
|
29845
29845
|
"name": "id",
|
|
@@ -84107,7 +84107,7 @@
|
|
|
84107
84107
|
"name": "keys"
|
|
84108
84108
|
},
|
|
84109
84109
|
{
|
|
84110
|
-
"name": "
|
|
84110
|
+
"name": "routebox"
|
|
84111
84111
|
},
|
|
84112
84112
|
{
|
|
84113
84113
|
"name": "connect"
|
|
@@ -922,36 +922,36 @@ export const API_OPERATIONS = [
|
|
|
922
922
|
"hasBody": false
|
|
923
923
|
},
|
|
924
924
|
{
|
|
925
|
-
"id": "
|
|
925
|
+
"id": "routebox.get",
|
|
926
926
|
"method": "get",
|
|
927
|
-
"path": "/
|
|
927
|
+
"path": "/routebox",
|
|
928
928
|
"summary": "",
|
|
929
929
|
"tags": [
|
|
930
|
-
"
|
|
930
|
+
"routebox"
|
|
931
931
|
],
|
|
932
932
|
"pathParams": [],
|
|
933
933
|
"queryParams": [],
|
|
934
934
|
"hasBody": false
|
|
935
935
|
},
|
|
936
936
|
{
|
|
937
|
-
"id": "
|
|
937
|
+
"id": "routebox.create",
|
|
938
938
|
"method": "post",
|
|
939
|
-
"path": "/
|
|
939
|
+
"path": "/routebox",
|
|
940
940
|
"summary": "",
|
|
941
941
|
"tags": [
|
|
942
|
-
"
|
|
942
|
+
"routebox"
|
|
943
943
|
],
|
|
944
944
|
"pathParams": [],
|
|
945
945
|
"queryParams": [],
|
|
946
946
|
"hasBody": false
|
|
947
947
|
},
|
|
948
948
|
{
|
|
949
|
-
"id": "
|
|
949
|
+
"id": "routebox.remove",
|
|
950
950
|
"method": "delete",
|
|
951
|
-
"path": "/
|
|
951
|
+
"path": "/routebox/{id}",
|
|
952
952
|
"summary": "",
|
|
953
953
|
"tags": [
|
|
954
|
-
"
|
|
954
|
+
"routebox"
|
|
955
955
|
],
|
|
956
956
|
"pathParams": [
|
|
957
957
|
"id"
|
|
@@ -960,12 +960,12 @@ export const API_OPERATIONS = [
|
|
|
960
960
|
"hasBody": false
|
|
961
961
|
},
|
|
962
962
|
{
|
|
963
|
-
"id": "
|
|
963
|
+
"id": "routebox.reset",
|
|
964
964
|
"method": "post",
|
|
965
|
-
"path": "/
|
|
965
|
+
"path": "/routebox/{id}/reset",
|
|
966
966
|
"summary": "",
|
|
967
967
|
"tags": [
|
|
968
|
-
"
|
|
968
|
+
"routebox"
|
|
969
969
|
],
|
|
970
970
|
"pathParams": [
|
|
971
971
|
"id"
|
|
@@ -974,12 +974,12 @@ export const API_OPERATIONS = [
|
|
|
974
974
|
"hasBody": false
|
|
975
975
|
},
|
|
976
976
|
{
|
|
977
|
-
"id": "
|
|
977
|
+
"id": "routebox.restart",
|
|
978
978
|
"method": "post",
|
|
979
|
-
"path": "/
|
|
979
|
+
"path": "/routebox/{id}/restart",
|
|
980
980
|
"summary": "",
|
|
981
981
|
"tags": [
|
|
982
|
-
"
|
|
982
|
+
"routebox"
|
|
983
983
|
],
|
|
984
984
|
"pathParams": [
|
|
985
985
|
"id"
|
|
@@ -988,12 +988,12 @@ export const API_OPERATIONS = [
|
|
|
988
988
|
"hasBody": false
|
|
989
989
|
},
|
|
990
990
|
{
|
|
991
|
-
"id": "
|
|
991
|
+
"id": "routebox.unlock",
|
|
992
992
|
"method": "post",
|
|
993
|
-
"path": "/
|
|
993
|
+
"path": "/routebox/{id}/unlock",
|
|
994
994
|
"summary": "",
|
|
995
995
|
"tags": [
|
|
996
|
-
"
|
|
996
|
+
"routebox"
|
|
997
997
|
],
|
|
998
998
|
"pathParams": [
|
|
999
999
|
"id"
|
|
@@ -1632,7 +1632,7 @@ export declare const DaemonStatus: S.Struct<{
|
|
|
1632
1632
|
}>>;
|
|
1633
1633
|
/** Device sessions readiness + the dpk proof (`DeviceSessionsReport`).
|
|
1634
1634
|
* `enabled` == sessions on (anchor present, sessions flag not off, not a
|
|
1635
|
-
*
|
|
1635
|
+
* Routebox). Absent on daemons too old to report it — treat as off. */
|
|
1636
1636
|
readonly device_sessions: S.optional<S.Struct<{
|
|
1637
1637
|
readonly enabled: S.Boolean;
|
|
1638
1638
|
readonly dpk_proof: S.optional<S.String>;
|
package/dist/protocol/daemon.js
CHANGED
|
@@ -1099,7 +1099,7 @@ export const DaemonStatus = S.Struct({
|
|
|
1099
1099
|
device_access_pin: S.optional(DeviceAccessPinReport),
|
|
1100
1100
|
/** Device sessions readiness + the dpk proof (`DeviceSessionsReport`).
|
|
1101
1101
|
* `enabled` == sessions on (anchor present, sessions flag not off, not a
|
|
1102
|
-
*
|
|
1102
|
+
* Routebox). Absent on daemons too old to report it — treat as off. */
|
|
1103
1103
|
device_sessions: S.optional(DeviceSessionsReport),
|
|
1104
1104
|
/** The loopback port this daemon's `/v1/*` + `/whoami` surface listens on
|
|
1105
1105
|
* (`OPENLLM_DAEMON_PORT`, default 8787). Reported in `daemon_status_json`
|
package/dist/protocol/index.d.ts
CHANGED
|
@@ -56,7 +56,7 @@ export * from "./registry-pointer.js";
|
|
|
56
56
|
export * from "./relay.js";
|
|
57
57
|
export * from "./replay-session.js";
|
|
58
58
|
export * from "./responses.js";
|
|
59
|
-
export * from "./
|
|
59
|
+
export * from "./routebox.js";
|
|
60
60
|
export * from "./semver.js";
|
|
61
61
|
export * from "./setup-mode.js";
|
|
62
62
|
export * from "./stats.js";
|
package/dist/protocol/index.js
CHANGED
|
@@ -56,7 +56,7 @@ export * from "./registry-pointer.js";
|
|
|
56
56
|
export * from "./relay.js";
|
|
57
57
|
export * from "./replay-session.js";
|
|
58
58
|
export * from "./responses.js";
|
|
59
|
-
export * from "./
|
|
59
|
+
export * from "./routebox.js";
|
|
60
60
|
export * from "./semver.js";
|
|
61
61
|
export * from "./setup-mode.js";
|
|
62
62
|
export * from "./stats.js";
|
|
@@ -31,9 +31,9 @@ export type TDeviceAccessPinReport = S.Schema.Type<typeof DeviceAccessPinReport>
|
|
|
31
31
|
*
|
|
32
32
|
* - `enabled`: sessions on — the install/login/loopback trust anchor is
|
|
33
33
|
* present (agent-eligible pin), the `OPENLLM_DEVICE_SESSIONS` flag is not
|
|
34
|
-
* off, and this is not a
|
|
34
|
+
* off, and this is not a Routebox. False → agent sessions fail closed
|
|
35
35
|
* with `device_not_anchored` (no anchor) or `device_sessions_disabled`
|
|
36
|
-
* (flag off /
|
|
36
|
+
* (flag off / Routebox); offer local enable or re-install with sessions.
|
|
37
37
|
* - `dpk_proof`: `HMAC-SHA256(pair_secret, "openllm-dpk-proof-v1" ||
|
|
38
38
|
* key_id || pubkey)`, base64url. Verify with `@openllmsh/sdk/vault`
|
|
39
39
|
* `verifyDpkProof` BEFORE using `DaemonStatus.pubkey` as `dpk`. Absent when
|
|
@@ -78,7 +78,7 @@ export type TLocalDeviceControlRequest = S.Schema.Type<typeof LocalDeviceControl
|
|
|
78
78
|
* `key_id` is the key this daemon runs on, writes `OPENLLM_DEVICE_ANCHOR` with
|
|
79
79
|
* the same writer as `openllm daemon anchor`, turns sessions on, and
|
|
80
80
|
* re-derives its pin. `{ sessions: true|false }` sets `OPENLLM_DEVICE_SESSIONS`
|
|
81
|
-
* only — the anchor is never removed. Enable is refused on a
|
|
81
|
+
* only — the anchor is never removed. Enable is refused on a Routebox.
|
|
82
82
|
* The anchor is never logged or echoed back.
|
|
83
83
|
*/
|
|
84
84
|
export declare const DEVICE_ANCHOR_LOCAL_PATH = "/local/device-anchor";
|
|
@@ -96,7 +96,7 @@ export declare const LocalDeviceAnchorRequest: S.Union<readonly [S.Struct<{
|
|
|
96
96
|
}>]>;
|
|
97
97
|
export type TLocalDeviceAnchorRequest = S.Schema.Type<typeof LocalDeviceAnchorRequest>;
|
|
98
98
|
/** Why `POST /local/device-anchor` refused. */
|
|
99
|
-
export declare const LocalDeviceAnchorRefusal: S.Literals<readonly ["invalid_body", "body_too_large", "malformed_anchor", "key_id_mismatch", "persist_failed", "
|
|
99
|
+
export declare const LocalDeviceAnchorRefusal: S.Literals<readonly ["invalid_body", "body_too_large", "malformed_anchor", "key_id_mismatch", "persist_failed", "routebox"]>;
|
|
100
100
|
export type TLocalDeviceAnchorRefusal = S.Schema.Type<typeof LocalDeviceAnchorRefusal>;
|
|
101
101
|
/** `POST /local/device-anchor` response. */
|
|
102
102
|
export declare const LocalDeviceAnchorResponse: S.Union<readonly [S.Struct<{
|
|
@@ -107,6 +107,6 @@ export declare const LocalDeviceAnchorResponse: S.Union<readonly [S.Struct<{
|
|
|
107
107
|
}>;
|
|
108
108
|
}>, S.Struct<{
|
|
109
109
|
readonly ok: S.Literal<false>;
|
|
110
|
-
readonly error: S.Literals<readonly ["invalid_body", "body_too_large", "malformed_anchor", "key_id_mismatch", "persist_failed", "
|
|
110
|
+
readonly error: S.Literals<readonly ["invalid_body", "body_too_large", "malformed_anchor", "key_id_mismatch", "persist_failed", "routebox"]>;
|
|
111
111
|
}>]>;
|
|
112
112
|
export type TLocalDeviceAnchorResponse = S.Schema.Type<typeof LocalDeviceAnchorResponse>;
|
|
@@ -30,9 +30,9 @@ export const DeviceAccessPinReport = S.Struct({
|
|
|
30
30
|
*
|
|
31
31
|
* - `enabled`: sessions on — the install/login/loopback trust anchor is
|
|
32
32
|
* present (agent-eligible pin), the `OPENLLM_DEVICE_SESSIONS` flag is not
|
|
33
|
-
* off, and this is not a
|
|
33
|
+
* off, and this is not a Routebox. False → agent sessions fail closed
|
|
34
34
|
* with `device_not_anchored` (no anchor) or `device_sessions_disabled`
|
|
35
|
-
* (flag off /
|
|
35
|
+
* (flag off / Routebox); offer local enable or re-install with sessions.
|
|
36
36
|
* - `dpk_proof`: `HMAC-SHA256(pair_secret, "openllm-dpk-proof-v1" ||
|
|
37
37
|
* key_id || pubkey)`, base64url. Verify with `@openllmsh/sdk/vault`
|
|
38
38
|
* `verifyDpkProof` BEFORE using `DaemonStatus.pubkey` as `dpk`. Absent when
|
|
@@ -67,7 +67,7 @@ export const LocalDeviceControlRequest = S.Struct({
|
|
|
67
67
|
* `key_id` is the key this daemon runs on, writes `OPENLLM_DEVICE_ANCHOR` with
|
|
68
68
|
* the same writer as `openllm daemon anchor`, turns sessions on, and
|
|
69
69
|
* re-derives its pin. `{ sessions: true|false }` sets `OPENLLM_DEVICE_SESSIONS`
|
|
70
|
-
* only — the anchor is never removed. Enable is refused on a
|
|
70
|
+
* only — the anchor is never removed. Enable is refused on a Routebox.
|
|
71
71
|
* The anchor is never logged or echoed back.
|
|
72
72
|
*/
|
|
73
73
|
export const DEVICE_ANCHOR_LOCAL_PATH = "/local/device-anchor";
|
|
@@ -93,8 +93,8 @@ export const LocalDeviceAnchorRefusal = S.Literals([
|
|
|
93
93
|
"malformed_anchor",
|
|
94
94
|
"key_id_mismatch",
|
|
95
95
|
"persist_failed",
|
|
96
|
-
/** A
|
|
97
|
-
"
|
|
96
|
+
/** A Routebox never enables device sessions. */
|
|
97
|
+
"routebox",
|
|
98
98
|
]);
|
|
99
99
|
/** `POST /local/device-anchor` response. */
|
|
100
100
|
export const LocalDeviceAnchorResponse = S.Union([
|
package/dist/protocol/mux.js
CHANGED
|
@@ -581,7 +581,7 @@ export const StreamResetCode = S.Literals([
|
|
|
581
581
|
* no install anchor): agent sessions fail closed. Fix with "Set up device
|
|
582
582
|
* sessions" (`openllm login sk-llm-<key>.<anchor>`). */
|
|
583
583
|
"device_not_anchored",
|
|
584
|
-
/** Sessions flag off (`OPENLLM_DEVICE_SESSIONS=0`) or a
|
|
584
|
+
/** Sessions flag off (`OPENLLM_DEVICE_SESSIONS=0`) or a Routebox.
|
|
585
585
|
* Distinct from `device_not_anchored` (no trust anchor / ineligible pin). */
|
|
586
586
|
"device_sessions_disabled",
|
|
587
587
|
]);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a Routebox marks itself. The box's user-data writes this file;
|
|
3
|
+
* the daemon reads it to keep auto-update always on and to refuse device
|
|
4
|
+
* sessions (a Routebox is too small for them). Shared so the two sides
|
|
5
|
+
* can't drift. Plan: docs/plans/routebox.md.
|
|
6
|
+
*/
|
|
7
|
+
export declare const ROUTEBOX_MARKER_PATH = "/etc/openllm/routebox";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where a Routebox marks itself. The box's user-data writes this file;
|
|
3
|
+
* the daemon reads it to keep auto-update always on and to refuse device
|
|
4
|
+
* sessions (a Routebox is too small for them). Shared so the two sides
|
|
5
|
+
* can't drift. Plan: docs/plans/routebox.md.
|
|
6
|
+
*/
|
|
7
|
+
export const ROUTEBOX_MARKER_PATH = "/etc/openllm/routebox";
|
|
@@ -28,7 +28,7 @@ export declare const DEVICE_CONTROL_HKDF_INFO = "openllm-device-control-v1";
|
|
|
28
28
|
export declare const DEVICE_CONTROL_HKDF_SALT = "openllm-device-control-salt-v1";
|
|
29
29
|
/** HKDF info for the at-rest "control keep" outer wrap (under the DEK). */
|
|
30
30
|
export declare const DEVICE_CONTROL_KEEP_HKDF_INFO = "openllm-device-control-keep-v1";
|
|
31
|
-
/** Length of the device-control seed (and of the
|
|
31
|
+
/** Length of the device-control seed (and of the Routebox key's input). */
|
|
32
32
|
export declare const DEVICE_CONTROL_SEED_BYTES = 32;
|
|
33
33
|
/**
|
|
34
34
|
* `HKDF-SHA256(ikm = BIP39 entropy(phrase), salt = DEVICE_CONTROL_HKDF_SALT,
|
|
@@ -33,7 +33,7 @@ export const DEVICE_CONTROL_HKDF_INFO = "openllm-device-control-v1";
|
|
|
33
33
|
export const DEVICE_CONTROL_HKDF_SALT = "openllm-device-control-salt-v1";
|
|
34
34
|
/** HKDF info for the at-rest "control keep" outer wrap (under the DEK). */
|
|
35
35
|
export const DEVICE_CONTROL_KEEP_HKDF_INFO = "openllm-device-control-keep-v1";
|
|
36
|
-
/** Length of the device-control seed (and of the
|
|
36
|
+
/** Length of the device-control seed (and of the Routebox key's input). */
|
|
37
37
|
export const DEVICE_CONTROL_SEED_BYTES = 32;
|
|
38
38
|
const SEED_BYTES = DEVICE_CONTROL_SEED_BYTES;
|
|
39
39
|
/**
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The
|
|
2
|
+
* The Routebox's home key: what opens its encrypted home (LUKS).
|
|
3
3
|
*
|
|
4
4
|
* Derived from the box API key's DEVICE ANCHOR secret — the per-key pair
|
|
5
5
|
* secret `HKDF(device-control seed, key id)` (`device-anchor.ts`) that every
|
|
@@ -14,20 +14,20 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Deliberately NOT re-exported from `vault/index.ts`: the `openllm` binary
|
|
16
16
|
* imports that barrel, and a box only ever receives this key. Import it by
|
|
17
|
-
* subpath: `@openllmsh/sdk/vault/
|
|
17
|
+
* subpath: `@openllmsh/sdk/vault/routebox-key`.
|
|
18
18
|
*/
|
|
19
19
|
import { hkdfSha256, zero } from "./crypto.js";
|
|
20
20
|
import { deriveDevicePairSecret } from "./device-anchor.js";
|
|
21
21
|
import { DEVICE_CONTROL_SEED_BYTES } from "./device-control.js";
|
|
22
|
-
export const
|
|
22
|
+
export const ROUTEBOX_HOME_HKDF_INFO = "openllm-routebox-home-v1";
|
|
23
23
|
/** Derive the box's home key; the caller must zero the returned bytes. */
|
|
24
|
-
export const
|
|
24
|
+
export const deriveRouteboxHomeKey = async (controlSeed, keyId) => {
|
|
25
25
|
if (controlSeed.length !== DEVICE_CONTROL_SEED_BYTES) {
|
|
26
26
|
throw new Error("invalid device-control seed length");
|
|
27
27
|
}
|
|
28
28
|
const pairSecret = await deriveDevicePairSecret(controlSeed, keyId);
|
|
29
29
|
try {
|
|
30
|
-
return await hkdfSha256(pairSecret, new Uint8Array(0),
|
|
30
|
+
return await hkdfSha256(pairSecret, new Uint8Array(0), ROUTEBOX_HOME_HKDF_INFO, 32);
|
|
31
31
|
}
|
|
32
32
|
finally {
|
|
33
33
|
zero(pairSecret);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Seal a
|
|
2
|
+
* Seal a Routebox's unlock to the one-time token its current boot made.
|
|
3
3
|
*
|
|
4
4
|
* The box generates a fresh X25519 keypair on every boot and keeps the
|
|
5
5
|
* private half in RAM (`/run`, tmpfs). The browser seals to the public half:
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Deliberately NOT re-exported from `vault/index.ts` (the `openllm` binary
|
|
16
16
|
* imports that barrel). Import by subpath:
|
|
17
|
-
* `@openllmsh/sdk/vault/
|
|
17
|
+
* `@openllmsh/sdk/vault/routebox-seal`.
|
|
18
18
|
*
|
|
19
19
|
* The box side mirrors `open_unlock` in
|
|
20
|
-
* `packages/api/lib/
|
|
20
|
+
* `packages/api/lib/routebox/box-agent.ts` (Python).
|
|
21
21
|
*/
|
|
22
|
-
export declare const
|
|
23
|
-
export type
|
|
22
|
+
export declare const ROUTEBOX_SEAL_DOMAIN = "openllm-routebox-seal-v1";
|
|
23
|
+
export type TRouteboxSealBinding = {
|
|
24
24
|
readonly userId: string;
|
|
25
25
|
readonly boxId: string;
|
|
26
26
|
/** The box's API key; its home key derives from this key's anchor. */
|
|
@@ -31,7 +31,7 @@ export type TRoutingBoxSealBinding = {
|
|
|
31
31
|
/** The boot's 32-byte challenge, base64. */
|
|
32
32
|
readonly challengeB64: string;
|
|
33
33
|
};
|
|
34
|
-
export type
|
|
34
|
+
export type TRouteboxEnvelope = {
|
|
35
35
|
readonly v: 1;
|
|
36
36
|
/** Ephemeral X25519 public key, base64 of the raw 32 bytes. */
|
|
37
37
|
readonly epk: string;
|
|
@@ -44,13 +44,13 @@ export type TRoutingBoxEnvelope = {
|
|
|
44
44
|
* control key, which WebRTC needs). Sent every time, so a box that failed
|
|
45
45
|
* before installing it recovers on its next boot.
|
|
46
46
|
*/
|
|
47
|
-
export type
|
|
47
|
+
export type TRouteboxUnlock = {
|
|
48
48
|
readonly home_key: string;
|
|
49
49
|
readonly api_key: string;
|
|
50
50
|
};
|
|
51
51
|
/** Canonical associated data; the Python side builds the same bytes. */
|
|
52
|
-
export declare const
|
|
52
|
+
export declare const routeboxSealAad: (binding: TRouteboxSealBinding) => Uint8Array;
|
|
53
53
|
/** Seal `unlock` to the boot in `binding`. */
|
|
54
|
-
export declare const
|
|
54
|
+
export declare const sealRouteboxUnlock: (binding: TRouteboxSealBinding, unlock: TRouteboxUnlock) => Promise<TRouteboxEnvelope>;
|
|
55
55
|
/** Open an envelope with the boot's private key (tests; the box uses Python). */
|
|
56
|
-
export declare const
|
|
56
|
+
export declare const openRouteboxUnlock: (binding: TRouteboxSealBinding, envelope: TRouteboxEnvelope, bootPrivateKey: CryptoKey) => Promise<TRouteboxUnlock>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Seal a
|
|
2
|
+
* Seal a Routebox's unlock to the one-time token its current boot made.
|
|
3
3
|
*
|
|
4
4
|
* The box generates a fresh X25519 keypair on every boot and keeps the
|
|
5
5
|
* private half in RAM (`/run`, tmpfs). The browser seals to the public half:
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
*
|
|
15
15
|
* Deliberately NOT re-exported from `vault/index.ts` (the `openllm` binary
|
|
16
16
|
* imports that barrel). Import by subpath:
|
|
17
|
-
* `@openllmsh/sdk/vault/
|
|
17
|
+
* `@openllmsh/sdk/vault/routebox-seal`.
|
|
18
18
|
*
|
|
19
19
|
* The box side mirrors `open_unlock` in
|
|
20
|
-
* `packages/api/lib/
|
|
20
|
+
* `packages/api/lib/routebox/box-agent.ts` (Python).
|
|
21
21
|
*/
|
|
22
22
|
import { aesGcmDecrypt, aesGcmEncrypt, fromB64, hkdfSha256, randomBytes, toB64, zero, } from "./crypto.js";
|
|
23
|
-
export const
|
|
23
|
+
export const ROUTEBOX_SEAL_DOMAIN = "openllm-routebox-seal-v1";
|
|
24
24
|
const encoder = new TextEncoder();
|
|
25
25
|
/** Canonical associated data; the Python side builds the same bytes. */
|
|
26
|
-
export const
|
|
27
|
-
|
|
26
|
+
export const routeboxSealAad = (binding) => encoder.encode(JSON.stringify([
|
|
27
|
+
ROUTEBOX_SEAL_DOMAIN,
|
|
28
28
|
binding.userId,
|
|
29
29
|
binding.boxId,
|
|
30
30
|
binding.keyId,
|
|
@@ -43,14 +43,14 @@ const deriveKey = async (privateKey, peerRaw, epkB64, recipientB64) => {
|
|
|
43
43
|
const peer = await crypto.subtle.importKey("raw", peerRaw, { name: "X25519" }, false, []);
|
|
44
44
|
const shared = new Uint8Array(await crypto.subtle.deriveBits({ name: "X25519", public: peer }, privateKey, 256));
|
|
45
45
|
try {
|
|
46
|
-
return await hkdfSha256(shared, new Uint8Array(0), JSON.stringify([
|
|
46
|
+
return await hkdfSha256(shared, new Uint8Array(0), JSON.stringify([ROUTEBOX_SEAL_DOMAIN, epkB64, recipientB64]), 32);
|
|
47
47
|
}
|
|
48
48
|
finally {
|
|
49
49
|
zero(shared);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
/** Seal `unlock` to the boot in `binding`. */
|
|
53
|
-
export const
|
|
53
|
+
export const sealRouteboxUnlock = async (binding, unlock) => {
|
|
54
54
|
raw32(binding.challengeB64, "challenge");
|
|
55
55
|
const recipient = raw32(binding.bootPubkeyB64, "boot public key");
|
|
56
56
|
const eph = (await crypto.subtle.generateKey({ name: "X25519" }, true, [
|
|
@@ -65,7 +65,7 @@ export const sealRoutingBoxUnlock = async (binding, unlock) => {
|
|
|
65
65
|
v: 1,
|
|
66
66
|
epk: epkB64,
|
|
67
67
|
nonce: toB64(nonce),
|
|
68
|
-
ct: toB64(await aesGcmEncrypt(key, nonce, plaintext,
|
|
68
|
+
ct: toB64(await aesGcmEncrypt(key, nonce, plaintext, routeboxSealAad(binding))),
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
71
|
finally {
|
|
@@ -74,12 +74,12 @@ export const sealRoutingBoxUnlock = async (binding, unlock) => {
|
|
|
74
74
|
}
|
|
75
75
|
};
|
|
76
76
|
/** Open an envelope with the boot's private key (tests; the box uses Python). */
|
|
77
|
-
export const
|
|
77
|
+
export const openRouteboxUnlock = async (binding, envelope, bootPrivateKey) => {
|
|
78
78
|
if (envelope.v !== 1)
|
|
79
79
|
throw new Error("unknown envelope version");
|
|
80
80
|
const key = await deriveKey(bootPrivateKey, raw32(envelope.epk, "ephemeral key"), envelope.epk, binding.bootPubkeyB64);
|
|
81
81
|
try {
|
|
82
|
-
const plaintext = await aesGcmDecrypt(key, fromB64(envelope.nonce), fromB64(envelope.ct),
|
|
82
|
+
const plaintext = await aesGcmDecrypt(key, fromB64(envelope.nonce), fromB64(envelope.ct), routeboxSealAad(binding));
|
|
83
83
|
try {
|
|
84
84
|
return JSON.parse(new TextDecoder().decode(plaintext));
|
|
85
85
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openllmsh/sdk",
|
|
3
|
-
"version": "2.10.19-alpha.
|
|
3
|
+
"version": "2.10.19-alpha.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "The OpenLLM SDK: typed API contracts, wire-format adapters, the device tunnel, client-side vault crypto, the OpenAPI spec and MCP tools.",
|
|
6
6
|
"keywords": [
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where a routing box marks itself. The box's user-data writes this file;
|
|
3
|
-
* the daemon reads it to keep auto-update always on and to refuse device
|
|
4
|
-
* sessions (a routing box is too small for them). Shared so the two sides
|
|
5
|
-
* can't drift. Plan: docs/plans/routing-sandbox.md.
|
|
6
|
-
*/
|
|
7
|
-
export declare const ROUTING_BOX_MARKER_PATH = "/etc/openllm/routing-box";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Where a routing box marks itself. The box's user-data writes this file;
|
|
3
|
-
* the daemon reads it to keep auto-update always on and to refuse device
|
|
4
|
-
* sessions (a routing box is too small for them). Shared so the two sides
|
|
5
|
-
* can't drift. Plan: docs/plans/routing-sandbox.md.
|
|
6
|
-
*/
|
|
7
|
-
export const ROUTING_BOX_MARKER_PATH = "/etc/openllm/routing-box";
|