dsh-plugin-dshm 0.0.0-stage → 0.1.0

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.
Files changed (80) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/LICENSE +21 -0
  3. package/README.md +228 -2
  4. package/README.zh-CN.md +190 -0
  5. package/cordis.patch.yml +7 -0
  6. package/lib/auth/signature.d.ts +4 -0
  7. package/lib/auth/signature.js +24 -0
  8. package/lib/cli/index.d.ts +4 -0
  9. package/lib/cli/index.js +41 -0
  10. package/lib/client.js +419 -0
  11. package/lib/config.d.ts +10 -0
  12. package/lib/config.js +27 -0
  13. package/lib/discovery/advertiser.d.ts +45 -0
  14. package/lib/discovery/advertiser.js +141 -0
  15. package/lib/discovery/interfaces.d.ts +5 -0
  16. package/lib/discovery/interfaces.js +24 -0
  17. package/lib/errors.d.ts +5 -0
  18. package/lib/errors.js +10 -0
  19. package/lib/host/local.d.ts +5 -0
  20. package/lib/host/local.js +122 -0
  21. package/lib/host/tailscale.d.ts +43 -0
  22. package/lib/host/tailscale.js +137 -0
  23. package/lib/host/types.d.ts +40 -0
  24. package/lib/host/types.js +1 -0
  25. package/lib/index.d.ts +30 -0
  26. package/lib/index.js +98 -0
  27. package/lib/methods/index.d.ts +9 -0
  28. package/lib/methods/index.js +206 -0
  29. package/lib/pairing/state.d.ts +26 -0
  30. package/lib/pairing/state.js +89 -0
  31. package/lib/pairing/window.d.ts +18 -0
  32. package/lib/pairing/window.js +57 -0
  33. package/lib/projection/client.d.mts +2 -0
  34. package/lib/projection/client.mjs +11 -0
  35. package/lib/projection/files.d.ts +33 -0
  36. package/lib/projection/files.js +278 -0
  37. package/lib/projection/fold-recording.d.mts +50 -0
  38. package/lib/projection/fold-recording.mjs +440 -0
  39. package/lib/projection/host.d.ts +6 -0
  40. package/lib/projection/host.js +86 -0
  41. package/lib/projection/ids.d.mts +1 -0
  42. package/lib/projection/ids.mjs +1 -0
  43. package/lib/projection/index.d.ts +2 -0
  44. package/lib/projection/index.js +2 -0
  45. package/lib/projection/interactions.d.ts +10 -0
  46. package/lib/projection/interactions.js +73 -0
  47. package/lib/projection/native.d.ts +114 -0
  48. package/lib/projection/native.js +903 -0
  49. package/lib/protocol/THIRD_PARTY_LICENSES.txt +135 -0
  50. package/lib/protocol/dmp.d.ts +402 -0
  51. package/lib/protocol/dmp.js +1 -0
  52. package/lib/protocol/schema/dmp-v1/common.schema.json +88 -0
  53. package/lib/protocol/schema/dmp-v1/events.schema.json +107 -0
  54. package/lib/protocol/schema/dmp-v1/frames.schema.json +280 -0
  55. package/lib/protocol/schema/dmp-v1/methods.schema.json +584 -0
  56. package/lib/protocol/schema/dmp-v1/models.schema.json +674 -0
  57. package/lib/protocol/scripts/contract.mjs +8106 -0
  58. package/lib/push/controller.d.ts +64 -0
  59. package/lib/push/controller.js +290 -0
  60. package/lib/push/observer.d.ts +51 -0
  61. package/lib/push/observer.js +266 -0
  62. package/lib/push/payload.d.ts +15 -0
  63. package/lib/push/payload.js +18 -0
  64. package/lib/push/store.d.ts +17 -0
  65. package/lib/push/store.js +75 -0
  66. package/lib/server/index.d.ts +30 -0
  67. package/lib/server/index.js +500 -0
  68. package/lib/server/rate-limit.d.ts +7 -0
  69. package/lib/server/rate-limit.js +19 -0
  70. package/lib/server/uploads.d.ts +21 -0
  71. package/lib/server/uploads.js +74 -0
  72. package/lib/types.d.ts +92 -0
  73. package/lib/types.js +1 -0
  74. package/lib/ui/card.d.mts +3 -0
  75. package/lib/ui/card.mjs +59 -0
  76. package/lib/ui/copy.d.mts +146 -0
  77. package/lib/ui/copy.mjs +106 -0
  78. package/lib/ui/remote-setup.d.mts +81 -0
  79. package/lib/ui/remote-setup.mjs +75 -0
  80. package/package.json +67 -4
@@ -0,0 +1,107 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "dmp://v1/events.schema.json",
4
+ "title": "DMP v1 subscription events",
5
+ "description": "'ev.data' by 'ev.kind'. 'x-dmp-events' maps each kind to the watch method that emits it.",
6
+ "x-dmp-events": {
7
+ "workspace.upsert": { "watch": "sessions.watch" },
8
+ "workspace.remove": { "watch": "sessions.watch" },
9
+ "session.upsert": { "watch": "sessions.watch" },
10
+ "session.remove": { "watch": "sessions.watch" },
11
+ "timeline.upsert": { "watch": "session.watch" },
12
+ "timeline.remove": { "watch": "session.watch" },
13
+ "timeline.delta": { "watch": "session.watch", "cap": "timeline.stream" },
14
+ "session.update": { "watch": "session.watch" },
15
+ "interaction.open": { "watch": "session.watch" },
16
+ "interaction.close": { "watch": "session.watch" },
17
+ "queue.update": { "watch": "session.watch" },
18
+ "session.reset": { "watch": "session.watch" },
19
+ "jobs.replace": { "watch": "jobs.watch" },
20
+ "job.output": { "watch": "job.watch" },
21
+ "job.status": { "watch": "job.watch" },
22
+ "devices.replace": { "watch": "devices.watch" }
23
+ },
24
+ "$defs": {
25
+ "workspace.upsert": {
26
+ "type": "object", "additionalProperties": false, "required": ["workspace"],
27
+ "properties": { "workspace": { "$ref": "models.schema.json#/$defs/Workspace" } }
28
+ },
29
+ "workspace.remove": {
30
+ "type": "object", "additionalProperties": false, "required": ["workspaceId"],
31
+ "properties": { "workspaceId": { "$ref": "common.schema.json#/$defs/Id" } }
32
+ },
33
+ "session.upsert": {
34
+ "type": "object", "additionalProperties": false, "required": ["session"],
35
+ "properties": { "session": { "$ref": "models.schema.json#/$defs/SessionSummary" } }
36
+ },
37
+ "session.remove": {
38
+ "type": "object", "additionalProperties": false, "required": ["sessionId"],
39
+ "properties": { "sessionId": { "$ref": "common.schema.json#/$defs/Id" } }
40
+ },
41
+ "timeline.upsert": {
42
+ "type": "object", "additionalProperties": false, "required": ["item", "throughSeq"],
43
+ "properties": {
44
+ "item": { "$ref": "models.schema.json#/$defs/TimelineItem" },
45
+ "throughSeq": { "description": "Fully delivered checkpoint. Hold the previous watermark until the final projected change of a native sequence; item.seq may be higher meanwhile.", "$ref": "common.schema.json#/$defs/Seq" }
46
+ }
47
+ },
48
+ "timeline.remove": {
49
+ "type": "object", "additionalProperties": false, "required": ["itemId", "throughSeq"],
50
+ "properties": {
51
+ "itemId": { "$ref": "common.schema.json#/$defs/Id" },
52
+ "throughSeq": { "description": "Fully delivered checkpoint; advance only after every projected change through this sequence has been sent.", "$ref": "common.schema.json#/$defs/Seq" }
53
+ }
54
+ },
55
+ "timeline.delta": {
56
+ "description": "Ephemeral streaming text; does not advance throughSeq.",
57
+ "type": "object", "additionalProperties": false, "required": ["itemId", "field", "append"],
58
+ "properties": {
59
+ "itemId": { "$ref": "common.schema.json#/$defs/Id" },
60
+ "field": { "const": "text" },
61
+ "append": { "type": "string" }
62
+ }
63
+ },
64
+ "session.update": {
65
+ "type": "object", "additionalProperties": false, "required": ["session"],
66
+ "properties": { "session": { "$ref": "models.schema.json#/$defs/SessionDetail" } }
67
+ },
68
+ "interaction.open": {
69
+ "type": "object", "additionalProperties": false, "required": ["interaction"],
70
+ "properties": { "interaction": { "$ref": "models.schema.json#/$defs/Interaction" } }
71
+ },
72
+ "interaction.close": {
73
+ "type": "object", "additionalProperties": false, "required": ["interactionId", "reason"],
74
+ "properties": {
75
+ "interactionId": { "$ref": "common.schema.json#/$defs/Id" },
76
+ "reason": { "enum": ["answered", "cancelled", "expired"] }
77
+ }
78
+ },
79
+ "queue.update": {
80
+ "type": "object", "additionalProperties": false, "required": ["queue"],
81
+ "properties": { "queue": { "type": "array", "items": { "$ref": "models.schema.json#/$defs/QueueItem" } } }
82
+ },
83
+ "session.reset": {
84
+ "type": "object", "additionalProperties": false, "required": ["reason"],
85
+ "properties": { "reason": { "x-dmp-open-enum": true, "enum": ["rewritten", "removed", "dsh-restarted"] } }
86
+ },
87
+ "jobs.replace": {
88
+ "type": "object", "additionalProperties": false, "required": ["jobs"],
89
+ "properties": { "jobs": { "type": "array", "items": { "$ref": "models.schema.json#/$defs/Job" } } }
90
+ },
91
+ "job.output": {
92
+ "type": "object", "additionalProperties": false, "required": ["chunks", "next"],
93
+ "properties": {
94
+ "chunks": { "type": "array", "items": { "$ref": "models.schema.json#/$defs/JobChunk" } },
95
+ "next": { "description": "Byte offset after the last chunk.", "type": "integer", "minimum": 0 }
96
+ }
97
+ },
98
+ "job.status": {
99
+ "type": "object", "additionalProperties": false, "required": ["job"],
100
+ "properties": { "job": { "$ref": "models.schema.json#/$defs/Job" } }
101
+ },
102
+ "devices.replace": {
103
+ "type": "object", "additionalProperties": false, "required": ["devices"],
104
+ "properties": { "devices": { "type": "array", "items": { "$ref": "models.schema.json#/$defs/Device" } } }
105
+ }
106
+ }
107
+ }
@@ -0,0 +1,280 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "dmp://v1/frames.schema.json",
4
+ "title": "DMP v1 text frames",
5
+ "description": "Every JSON WebSocket frame, split by direction (both directions use t='hello'). 'req.params', 'res.result' and 'ev.data' are further validated against methods/events schemas by method name or event kind.",
6
+ "$defs": {
7
+ "ServerFrame": {
8
+ "description": "Bridge → phone.",
9
+ "type": "object",
10
+ "required": ["t"],
11
+ "properties": { "t": { "type": "string" } },
12
+ "discriminator": { "propertyName": "t" },
13
+ "oneOf": [
14
+ { "$ref": "#/$defs/ServerHello" },
15
+ { "$ref": "#/$defs/AuthChallenge" },
16
+ { "$ref": "#/$defs/PairResult" },
17
+ { "$ref": "#/$defs/AuthOk" },
18
+ { "$ref": "#/$defs/Res" },
19
+ { "$ref": "#/$defs/Ev" },
20
+ { "$ref": "#/$defs/Err" },
21
+ { "$ref": "#/$defs/StreamAck" },
22
+ { "$ref": "#/$defs/StreamAbort" },
23
+ { "$ref": "#/$defs/Ping" },
24
+ { "$ref": "#/$defs/Pong" }
25
+ ]
26
+ },
27
+
28
+ "ClientFrame": {
29
+ "description": "Phone → bridge.",
30
+ "type": "object",
31
+ "required": ["t"],
32
+ "properties": { "t": { "type": "string" } },
33
+ "discriminator": { "propertyName": "t" },
34
+ "oneOf": [
35
+ { "$ref": "#/$defs/ClientHello" },
36
+ { "$ref": "#/$defs/PairRequest" },
37
+ { "$ref": "#/$defs/AuthResponse" },
38
+ { "$ref": "#/$defs/Req" },
39
+ { "$ref": "#/$defs/Cancel" },
40
+ { "$ref": "#/$defs/StreamAck" },
41
+ { "$ref": "#/$defs/StreamAbort" },
42
+ { "$ref": "#/$defs/Ping" },
43
+ { "$ref": "#/$defs/Pong" }
44
+ ]
45
+ },
46
+
47
+ "ServerHello": {
48
+ "description": "Bridge → phone, first frame after TLS.",
49
+ "type": "object",
50
+ "additionalProperties": false,
51
+ "required": ["t", "v", "host", "bridge", "dsh", "caps", "limits"],
52
+ "properties": {
53
+ "t": { "const": "hello" },
54
+ "v": { "type": "array", "minItems": 1, "items": { "type": "integer", "minimum": 1 } },
55
+ "host": { "$ref": "models.schema.json#/$defs/HostInfo" },
56
+ "bridge": {
57
+ "type": "object",
58
+ "additionalProperties": false,
59
+ "required": ["version", "instanceId"],
60
+ "properties": {
61
+ "version": { "type": "string" },
62
+ "instanceId": { "description": "Random id of this bridge process; changes on every restart. Lets the app tell whether in-memory state such as the creation ledger survived a reconnect.", "$ref": "common.schema.json#/$defs/Id" }
63
+ }
64
+ },
65
+ "dsh": {
66
+ "type": "object",
67
+ "additionalProperties": false,
68
+ "required": ["status"],
69
+ "properties": {
70
+ "version": { "type": "string" },
71
+ "status": { "enum": ["ok", "incompatible", "unavailable"] }
72
+ }
73
+ },
74
+ "caps": { "type": "array", "uniqueItems": true, "items": { "$ref": "common.schema.json#/$defs/Capability" } },
75
+ "limits": {
76
+ "type": "object",
77
+ "additionalProperties": false,
78
+ "required": ["maxTextFrameBytes", "maxChunkBytes", "streamWindowBytes"],
79
+ "properties": {
80
+ "maxTextFrameBytes": { "type": "integer", "minimum": 65536 },
81
+ "maxChunkBytes": { "type": "integer", "minimum": 4096 },
82
+ "streamWindowBytes": { "type": "integer", "minimum": 65536 }
83
+ }
84
+ }
85
+ }
86
+ },
87
+
88
+ "ClientHello": {
89
+ "type": "object",
90
+ "additionalProperties": false,
91
+ "required": ["t", "v", "app"],
92
+ "properties": {
93
+ "t": { "const": "hello" },
94
+ "v": { "type": "integer", "minimum": 1 },
95
+ "app": {
96
+ "type": "object",
97
+ "additionalProperties": false,
98
+ "required": ["version", "build", "platform"],
99
+ "properties": {
100
+ "version": { "type": "string" },
101
+ "build": { "type": "string" },
102
+ "platform": { "enum": ["ios", "ipados"] }
103
+ }
104
+ },
105
+ "caps": { "type": "array", "items": { "type": "string" } }
106
+ }
107
+ },
108
+
109
+ "AuthChallenge": {
110
+ "type": "object",
111
+ "additionalProperties": false,
112
+ "required": ["t", "nonce"],
113
+ "properties": {
114
+ "t": { "const": "auth.challenge" },
115
+ "nonce": { "description": "32 random bytes, base64url.", "$ref": "common.schema.json#/$defs/Base64Url" }
116
+ }
117
+ },
118
+
119
+ "PairRequest": {
120
+ "type": "object",
121
+ "additionalProperties": false,
122
+ "required": ["t", "otp", "devicePublicKey", "deviceName", "deviceModel", "secureEnclave"],
123
+ "properties": {
124
+ "t": { "const": "pair.request" },
125
+ "otp": { "$ref": "common.schema.json#/$defs/Base64Url" },
126
+ "devicePublicKey": { "description": "P-256 public key, SPKI DER, base64.", "$ref": "common.schema.json#/$defs/Base64" },
127
+ "deviceName": { "type": "string", "maxLength": 128 },
128
+ "deviceModel": { "type": "string", "maxLength": 64 },
129
+ "secureEnclave": { "type": "boolean" }
130
+ }
131
+ },
132
+
133
+ "PairResult": {
134
+ "type": "object",
135
+ "additionalProperties": false,
136
+ "required": ["t", "deviceId", "hostId"],
137
+ "properties": {
138
+ "t": { "const": "pair.result" },
139
+ "deviceId": { "$ref": "common.schema.json#/$defs/Id" },
140
+ "hostId": { "$ref": "common.schema.json#/$defs/Id" }
141
+ }
142
+ },
143
+
144
+ "AuthResponse": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": ["t", "deviceId", "sig"],
148
+ "properties": {
149
+ "t": { "const": "auth.response" },
150
+ "deviceId": { "$ref": "common.schema.json#/$defs/Id" },
151
+ "sig": { "description": "ECDSA P-256 SHA-256, DER, base64. See dmp-v1.md §2.", "$ref": "common.schema.json#/$defs/Base64" }
152
+ }
153
+ },
154
+
155
+ "AuthOk": {
156
+ "type": "object",
157
+ "additionalProperties": false,
158
+ "required": ["t", "deviceId", "connectionId", "via"],
159
+ "properties": {
160
+ "t": { "const": "auth.ok" },
161
+ "deviceId": { "$ref": "common.schema.json#/$defs/Id" },
162
+ "connectionId": { "$ref": "common.schema.json#/$defs/Id" },
163
+ "via": { "enum": ["lan", "tailscale", "other"] }
164
+ }
165
+ },
166
+
167
+ "Req": {
168
+ "type": "object",
169
+ "additionalProperties": false,
170
+ "required": ["t", "id", "method", "params"],
171
+ "properties": {
172
+ "t": { "const": "req" },
173
+ "id": { "type": "integer", "minimum": 1 },
174
+ "method": { "type": "string", "pattern": "^[a-z]+(\\.[a-zA-Z]+)*$" },
175
+ "params": { "type": "object" }
176
+ }
177
+ },
178
+
179
+ "Res": {
180
+ "type": "object",
181
+ "required": ["t"],
182
+ "oneOf": [
183
+ {
184
+ "type": "object",
185
+ "additionalProperties": false,
186
+ "required": ["t", "id", "ok", "result"],
187
+ "properties": {
188
+ "t": { "const": "res" },
189
+ "id": { "type": "integer", "minimum": 1 },
190
+ "ok": { "const": true },
191
+ "result": { "type": "object" }
192
+ }
193
+ },
194
+ {
195
+ "type": "object",
196
+ "additionalProperties": false,
197
+ "required": ["t", "id", "ok", "error"],
198
+ "properties": {
199
+ "t": { "const": "res" },
200
+ "id": { "type": "integer", "minimum": 1 },
201
+ "ok": { "const": false },
202
+ "error": { "$ref": "common.schema.json#/$defs/Error" }
203
+ }
204
+ }
205
+ ],
206
+ "properties": { "t": { "const": "res" } }
207
+ },
208
+
209
+ "Cancel": {
210
+ "type": "object",
211
+ "additionalProperties": false,
212
+ "required": ["t", "id"],
213
+ "properties": {
214
+ "t": { "const": "cancel" },
215
+ "id": { "type": "integer", "minimum": 1 }
216
+ }
217
+ },
218
+
219
+ "Ev": {
220
+ "type": "object",
221
+ "additionalProperties": false,
222
+ "required": ["t", "sub", "kind", "data"],
223
+ "properties": {
224
+ "t": { "const": "ev" },
225
+ "sub": { "$ref": "common.schema.json#/$defs/Id" },
226
+ "kind": { "type": "string", "pattern": "^[a-z]+\\.[a-z]+$" },
227
+ "data": { "type": "object" }
228
+ }
229
+ },
230
+
231
+ "Err": {
232
+ "description": "Connection-level error, sent before closing (e.g. during handshake). Request errors use res.ok=false instead.",
233
+ "type": "object",
234
+ "additionalProperties": false,
235
+ "required": ["t", "code", "message", "retryable"],
236
+ "properties": {
237
+ "t": { "const": "err" },
238
+ "code": { "$ref": "common.schema.json#/$defs/ErrorCode" },
239
+ "message": { "type": "string" },
240
+ "retryable": { "type": "boolean" }
241
+ }
242
+ },
243
+
244
+ "StreamAck": {
245
+ "type": "object",
246
+ "additionalProperties": false,
247
+ "required": ["t", "streamId", "bytes"],
248
+ "properties": {
249
+ "t": { "const": "stream.ack" },
250
+ "streamId": { "type": "integer", "minimum": 1, "maximum": 4294967295 },
251
+ "bytes": { "description": "Cumulative bytes received.", "type": "integer", "minimum": 0 }
252
+ }
253
+ },
254
+
255
+ "StreamAbort": {
256
+ "type": "object",
257
+ "additionalProperties": false,
258
+ "required": ["t", "streamId", "code"],
259
+ "properties": {
260
+ "t": { "const": "stream.abort" },
261
+ "streamId": { "type": "integer", "minimum": 1, "maximum": 4294967295 },
262
+ "code": { "$ref": "common.schema.json#/$defs/ErrorCode" }
263
+ }
264
+ },
265
+
266
+ "Ping": {
267
+ "type": "object",
268
+ "additionalProperties": false,
269
+ "required": ["t"],
270
+ "properties": { "t": { "const": "ping" } }
271
+ },
272
+
273
+ "Pong": {
274
+ "type": "object",
275
+ "additionalProperties": false,
276
+ "required": ["t"],
277
+ "properties": { "t": { "const": "pong" } }
278
+ }
279
+ }
280
+ }