@nuxtjp/local-runtime 0.0.0-stage → 0.1.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.
Files changed (47) hide show
  1. package/LICENSE +202 -0
  2. package/LICENSE-PREVIOUS +21 -0
  3. package/NOTICE +4 -0
  4. package/README.ja.md +71 -0
  5. package/README.md +70 -2
  6. package/dist/module.d.mts +10 -0
  7. package/dist/module.json +12 -0
  8. package/dist/module.mjs +33 -0
  9. package/dist/runtime/app/assets/local-runtime.css +1 -0
  10. package/dist/runtime/app/components/LocalRuntimeStatus.d.vue.ts +8 -0
  11. package/dist/runtime/app/components/LocalRuntimeStatus.vue +25 -0
  12. package/dist/runtime/app/components/LocalRuntimeStatus.vue.d.ts +8 -0
  13. package/dist/runtime/app/composables/useLocalRuntime.d.ts +92 -0
  14. package/dist/runtime/app/composables/useLocalRuntime.js +51 -0
  15. package/dist/runtime/client/client.d.ts +22 -0
  16. package/dist/runtime/client/client.js +117 -0
  17. package/dist/runtime/client/endpoint.d.ts +5 -0
  18. package/dist/runtime/client/endpoint.js +14 -0
  19. package/dist/runtime/client/index.d.ts +6 -0
  20. package/dist/runtime/client/index.js +4 -0
  21. package/dist/runtime/client/request.d.ts +5 -0
  22. package/dist/runtime/client/request.js +22 -0
  23. package/dist/runtime/client/response.d.ts +1 -0
  24. package/dist/runtime/client/response.js +36 -0
  25. package/dist/runtime/client/transport.d.ts +1 -0
  26. package/dist/runtime/client/transport.js +11 -0
  27. package/dist/runtime/shared/guards/manifest.d.ts +2 -0
  28. package/dist/runtime/shared/guards/manifest.js +71 -0
  29. package/dist/runtime/shared/guards/payload.d.ts +3 -0
  30. package/dist/runtime/shared/guards/payload.js +29 -0
  31. package/dist/runtime/shared/guards/primitives.d.ts +5 -0
  32. package/dist/runtime/shared/guards/primitives.js +16 -0
  33. package/dist/runtime/shared/guards/session.d.ts +2 -0
  34. package/dist/runtime/shared/guards/session.js +27 -0
  35. package/dist/runtime/shared/guards/view.d.ts +2 -0
  36. package/dist/runtime/shared/guards/view.js +22 -0
  37. package/dist/runtime/shared/guards.d.ts +4 -0
  38. package/dist/runtime/shared/guards.js +4 -0
  39. package/dist/runtime/shared/nuxt-imports.d.ts +9 -0
  40. package/dist/runtime/shared/security.d.ts +7 -0
  41. package/dist/runtime/shared/security.js +13 -0
  42. package/dist/runtime/shared/types.d.ts +95 -0
  43. package/dist/runtime/shared/types.js +0 -0
  44. package/dist/types.d.mts +3 -0
  45. package/package.json +75 -3
  46. package/schemas/local-runtime-v1.schema.json +332 -0
  47. package/src/runtime/shared/types.ts +126 -0
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@nuxtjp/local-runtime",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.1",
4
+ "description": "Fail-closed Nuxt client for a loopback local runtime",
5
+ "type": "module",
6
+ "license": "Apache-2.0",
7
+ "engines": {
8
+ "node": "^22.19.0 || ^24.11.0",
9
+ "pnpm": ">=10 <11"
10
+ },
11
+ "files": [
12
+ "dist",
13
+ "schemas",
14
+ "src/runtime/shared/types.ts",
15
+ "LICENSE",
16
+ "README.md",
17
+ "NOTICE",
18
+ "LICENSE-PREVIOUS",
19
+ "README.ja.md"
20
+ ],
21
+ "main": "./dist/module.mjs",
22
+ "types": "./dist/types.d.mts",
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/types.d.mts",
26
+ "import": "./dist/module.mjs"
27
+ },
28
+ "./client": {
29
+ "types": "./dist/runtime/client/index.d.ts",
30
+ "import": "./dist/runtime/client/index.js"
31
+ },
32
+ "./guards": {
33
+ "types": "./dist/runtime/shared/guards.d.ts",
34
+ "import": "./dist/runtime/shared/guards.js"
35
+ },
36
+ "./types": {
37
+ "types": "./src/runtime/shared/types.ts",
38
+ "default": "./src/runtime/shared/types.ts"
39
+ },
40
+ "./schema": "./schemas/local-runtime-v1.schema.json"
41
+ },
42
+ "peerDependencies": {
43
+ "nuxt": "^4.5.1",
44
+ "vue": "^3.5.40"
45
+ },
46
+ "dependencies": {
47
+ "@nuxt/kit": "4.5.1",
48
+ "@nuxt/schema": "4.5.1"
49
+ },
50
+ "devDependencies": {
51
+ "@nuxt/module-builder": "1.0.2",
52
+ "@types/node": "24.12.0",
53
+ "ajv": "8.20.0",
54
+ "nuxt": "4.5.1",
55
+ "typescript": "5.9.3",
56
+ "vitest": "4.1.11",
57
+ "vue": "3.5.43",
58
+ "vue-tsc": "3.2.8"
59
+ },
60
+ "repository": {
61
+ "type": "git",
62
+ "url": "git+https://github.com/nuxtjp/nuxt-local-runtime.git"
63
+ },
64
+ "homepage": "https://github.com/nuxtjp/nuxt-local-runtime#readme",
65
+ "bugs": {
66
+ "url": "https://github.com/nuxtjp/nuxt-local-runtime/issues"
67
+ },
68
+ "publishConfig": {
69
+ "access": "public",
70
+ "registry": "https://registry.npmjs.org",
71
+ "provenance": true
72
+ },
73
+ "scripts": {
74
+ "build": "nuxt-module-build build && nuxt build playground",
75
+ "typecheck": "vue-tsc --noEmit --project tsconfig.json",
76
+ "test": "vitest run"
77
+ }
6
78
  }
@@ -0,0 +1,332 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://nuxt.jp/schemas/local-runtime-v1.schema.json",
4
+ "title": "NuxtJP local runtime contracts",
5
+ "oneOf": [
6
+ { "$ref": "#/$defs/manifest" },
7
+ { "$ref": "#/$defs/sessionRequest" },
8
+ { "$ref": "#/$defs/sessionGrant" },
9
+ { "$ref": "#/$defs/viewRequest" },
10
+ { "$ref": "#/$defs/view" }
11
+ ],
12
+ "$defs": {
13
+ "text": {
14
+ "type": "string",
15
+ "minLength": 1,
16
+ "maxLength": 4096
17
+ },
18
+ "count": {
19
+ "type": "integer",
20
+ "minimum": 0,
21
+ "maximum": 9007199254740991
22
+ },
23
+ "payloadField": {
24
+ "type": "object",
25
+ "additionalProperties": false,
26
+ "required": ["name", "kind"],
27
+ "properties": {
28
+ "name": {
29
+ "type": "string",
30
+ "pattern": "^[a-z][a-z0-9_]{0,63}$"
31
+ },
32
+ "kind": { "enum": ["text", "count", "boolean"] }
33
+ }
34
+ },
35
+ "payloadSchema": {
36
+ "type": "object",
37
+ "additionalProperties": false,
38
+ "required": ["id", "fields"],
39
+ "properties": {
40
+ "id": {
41
+ "type": "string",
42
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$"
43
+ },
44
+ "fields": {
45
+ "type": "array",
46
+ "minItems": 1,
47
+ "maxItems": 32,
48
+ "items": { "$ref": "#/$defs/payloadField" }
49
+ }
50
+ }
51
+ },
52
+ "limits": {
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "required": [
56
+ "max_request_bytes",
57
+ "max_response_bytes",
58
+ "max_messages_per_minute",
59
+ "max_bytes_per_minute",
60
+ "session_ttl_seconds"
61
+ ],
62
+ "properties": {
63
+ "max_request_bytes": {
64
+ "type": "integer",
65
+ "minimum": 1,
66
+ "maximum": 1048576
67
+ },
68
+ "max_response_bytes": {
69
+ "type": "integer",
70
+ "minimum": 1,
71
+ "maximum": 8388608
72
+ },
73
+ "max_messages_per_minute": {
74
+ "type": "integer",
75
+ "minimum": 1,
76
+ "maximum": 600
77
+ },
78
+ "max_bytes_per_minute": {
79
+ "type": "integer",
80
+ "minimum": 1,
81
+ "maximum": 67108864
82
+ },
83
+ "session_ttl_seconds": {
84
+ "type": "integer",
85
+ "minimum": 1,
86
+ "maximum": 3600
87
+ }
88
+ }
89
+ },
90
+ "engine": {
91
+ "type": "object",
92
+ "additionalProperties": false,
93
+ "required": [
94
+ "kind",
95
+ "status",
96
+ "isolation",
97
+ "arbitrary_network",
98
+ "arbitrary_filesystem"
99
+ ],
100
+ "properties": {
101
+ "kind": { "const": "rust-v8" },
102
+ "status": { "enum": ["disabled", "simulated", "ready"] },
103
+ "isolation": {
104
+ "enum": ["in-process-simulation", "process"]
105
+ },
106
+ "arbitrary_network": { "const": false },
107
+ "arbitrary_filesystem": { "const": false }
108
+ },
109
+ "allOf": [
110
+ {
111
+ "if": {
112
+ "properties": { "status": { "const": "ready" } },
113
+ "required": ["status"]
114
+ },
115
+ "then": {
116
+ "properties": { "isolation": { "const": "process" } }
117
+ },
118
+ "else": {
119
+ "properties": {
120
+ "isolation": { "const": "in-process-simulation" }
121
+ }
122
+ }
123
+ }
124
+ ]
125
+ },
126
+ "capability": {
127
+ "type": "object",
128
+ "additionalProperties": false,
129
+ "required": [
130
+ "id",
131
+ "service_id",
132
+ "description",
133
+ "output_band",
134
+ "payload_schema"
135
+ ],
136
+ "properties": {
137
+ "id": { "$ref": "#/$defs/text" },
138
+ "service_id": { "$ref": "#/$defs/text" },
139
+ "description": { "$ref": "#/$defs/text" },
140
+ "output_band": { "enum": ["session", "public"] },
141
+ "payload_schema": { "$ref": "#/$defs/payloadSchema" }
142
+ }
143
+ },
144
+ "security": {
145
+ "type": "object",
146
+ "additionalProperties": false,
147
+ "required": [
148
+ "default_band",
149
+ "external_egress",
150
+ "allowed_origins",
151
+ "limits"
152
+ ],
153
+ "properties": {
154
+ "default_band": { "const": "sealed" },
155
+ "external_egress": { "const": "deny" },
156
+ "allowed_origins": {
157
+ "type": "array",
158
+ "minItems": 1,
159
+ "maxItems": 16,
160
+ "uniqueItems": true,
161
+ "items": {
162
+ "type": "string",
163
+ "pattern": "^https?://[^/]+$"
164
+ }
165
+ },
166
+ "limits": { "$ref": "#/$defs/limits" }
167
+ }
168
+ },
169
+ "manifest": {
170
+ "type": "object",
171
+ "additionalProperties": false,
172
+ "required": [
173
+ "schema",
174
+ "runtime_id",
175
+ "protocol_version",
176
+ "mode",
177
+ "external_actions",
178
+ "engine",
179
+ "security",
180
+ "capabilities"
181
+ ],
182
+ "properties": {
183
+ "schema": { "const": "nuxtjp://local-runtime/manifest/v1" },
184
+ "runtime_id": { "$ref": "#/$defs/text" },
185
+ "protocol_version": { "const": "1" },
186
+ "mode": { "enum": ["local-simulation", "local-production"] },
187
+ "external_actions": { "const": false },
188
+ "engine": { "$ref": "#/$defs/engine" },
189
+ "security": { "$ref": "#/$defs/security" },
190
+ "capabilities": {
191
+ "type": "array",
192
+ "maxItems": 64,
193
+ "items": { "$ref": "#/$defs/capability" }
194
+ }
195
+ }
196
+ },
197
+ "budget": {
198
+ "type": "object",
199
+ "additionalProperties": false,
200
+ "required": ["max_messages", "max_bytes"],
201
+ "properties": {
202
+ "max_messages": { "$ref": "#/$defs/count" },
203
+ "max_bytes": { "$ref": "#/$defs/count" }
204
+ }
205
+ },
206
+ "sessionRequest": {
207
+ "type": "object",
208
+ "additionalProperties": false,
209
+ "required": [
210
+ "schema",
211
+ "origin",
212
+ "audience",
213
+ "client_nonce",
214
+ "requested_capabilities"
215
+ ],
216
+ "properties": {
217
+ "schema": { "const": "nuxtjp://local-runtime/session-request/v1" },
218
+ "origin": {
219
+ "type": "string",
220
+ "pattern": "^https?://[^/]+$"
221
+ },
222
+ "audience": {
223
+ "type": "string",
224
+ "pattern": "^https?://[^/]+$"
225
+ },
226
+ "client_nonce": {
227
+ "type": "string",
228
+ "minLength": 8,
229
+ "maxLength": 128
230
+ },
231
+ "requested_capabilities": {
232
+ "type": "array",
233
+ "maxItems": 64,
234
+ "uniqueItems": true,
235
+ "items": { "$ref": "#/$defs/text" }
236
+ }
237
+ }
238
+ },
239
+ "sessionGrant": {
240
+ "type": "object",
241
+ "additionalProperties": false,
242
+ "required": [
243
+ "schema",
244
+ "session_id",
245
+ "token",
246
+ "subject_id",
247
+ "audience",
248
+ "expires_at_unix_seconds",
249
+ "granted_capabilities",
250
+ "classification_ceiling",
251
+ "budget",
252
+ "external_actions"
253
+ ],
254
+ "properties": {
255
+ "schema": { "const": "nuxtjp://local-runtime/session-grant/v1" },
256
+ "session_id": { "$ref": "#/$defs/text" },
257
+ "token": { "$ref": "#/$defs/text" },
258
+ "subject_id": { "$ref": "#/$defs/text" },
259
+ "audience": { "$ref": "#/$defs/text" },
260
+ "expires_at_unix_seconds": { "$ref": "#/$defs/count" },
261
+ "granted_capabilities": {
262
+ "type": "array",
263
+ "maxItems": 64,
264
+ "uniqueItems": true,
265
+ "items": { "$ref": "#/$defs/text" }
266
+ },
267
+ "classification_ceiling": { "const": "session" },
268
+ "budget": { "$ref": "#/$defs/budget" },
269
+ "external_actions": { "const": false }
270
+ }
271
+ },
272
+ "viewRequest": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": [
276
+ "schema",
277
+ "capability_id",
278
+ "view_id",
279
+ "request_nonce"
280
+ ],
281
+ "properties": {
282
+ "schema": { "const": "nuxtjp://local-runtime/view-request/v1" },
283
+ "capability_id": { "$ref": "#/$defs/text" },
284
+ "view_id": { "$ref": "#/$defs/text" },
285
+ "request_nonce": {
286
+ "type": "string",
287
+ "minLength": 8,
288
+ "maxLength": 128
289
+ }
290
+ }
291
+ },
292
+ "view": {
293
+ "type": "object",
294
+ "additionalProperties": false,
295
+ "required": [
296
+ "schema",
297
+ "capability_id",
298
+ "view_id",
299
+ "payload_schema_id",
300
+ "band",
301
+ "generated_at_unix_seconds",
302
+ "expires_at_unix_seconds",
303
+ "external_actions",
304
+ "payload"
305
+ ],
306
+ "properties": {
307
+ "schema": { "const": "nuxtjp://local-runtime/view/v1" },
308
+ "capability_id": { "$ref": "#/$defs/text" },
309
+ "view_id": { "$ref": "#/$defs/text" },
310
+ "payload_schema_id": { "$ref": "#/$defs/text" },
311
+ "band": { "enum": ["session", "public"] },
312
+ "generated_at_unix_seconds": { "$ref": "#/$defs/count" },
313
+ "expires_at_unix_seconds": { "$ref": "#/$defs/count" },
314
+ "external_actions": { "const": false },
315
+ "payload": {
316
+ "type": "object",
317
+ "maxProperties": 32,
318
+ "propertyNames": {
319
+ "pattern": "^[a-z][a-z0-9_]{0,63}$"
320
+ },
321
+ "additionalProperties": {
322
+ "oneOf": [
323
+ { "type": "string", "minLength": 1, "maxLength": 4096 },
324
+ { "$ref": "#/$defs/count" },
325
+ { "type": "boolean" }
326
+ ]
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ }
@@ -0,0 +1,126 @@
1
+ export type InformationBand =
2
+ | 'sealed'
3
+ | 'local'
4
+ | 'session'
5
+ | 'control'
6
+ | 'public'
7
+
8
+ export type BoundaryTarget =
9
+ | 'none'
10
+ | 'local-mesh'
11
+ | 'loopback-browser'
12
+ | 'external-control'
13
+ | 'public-network'
14
+
15
+ export interface RuntimeEngine {
16
+ kind: 'rust-v8'
17
+ status: 'disabled' | 'simulated' | 'ready'
18
+ isolation: 'in-process-simulation' | 'process'
19
+ arbitrary_network: false
20
+ arbitrary_filesystem: false
21
+ }
22
+
23
+ export interface RuntimeLimits {
24
+ max_request_bytes: number
25
+ max_response_bytes: number
26
+ max_messages_per_minute: number
27
+ max_bytes_per_minute: number
28
+ session_ttl_seconds: number
29
+ }
30
+
31
+ export interface RuntimeSecurity {
32
+ default_band: 'sealed'
33
+ external_egress: 'deny'
34
+ allowed_origins: string[]
35
+ limits: RuntimeLimits
36
+ }
37
+
38
+ export type PayloadValueKind = 'text' | 'count' | 'boolean'
39
+ export type PayloadScalar = string | number | boolean
40
+
41
+ export interface RuntimePayloadField {
42
+ name: string
43
+ kind: PayloadValueKind
44
+ }
45
+
46
+ export interface RuntimePayloadSchema {
47
+ id: string
48
+ fields: RuntimePayloadField[]
49
+ }
50
+
51
+ export interface RuntimeCapability {
52
+ id: string
53
+ service_id: string
54
+ description: string
55
+ output_band: 'session' | 'public'
56
+ payload_schema: RuntimePayloadSchema
57
+ }
58
+
59
+ export interface LocalRuntimeManifest {
60
+ schema: 'nuxtjp://local-runtime/manifest/v1'
61
+ runtime_id: string
62
+ protocol_version: '1'
63
+ mode: 'local-simulation' | 'local-production'
64
+ external_actions: false
65
+ engine: RuntimeEngine
66
+ security: RuntimeSecurity
67
+ capabilities: RuntimeCapability[]
68
+ }
69
+
70
+ export interface SessionRequest {
71
+ schema: 'nuxtjp://local-runtime/session-request/v1'
72
+ origin: string
73
+ audience: string
74
+ client_nonce: string
75
+ requested_capabilities: string[]
76
+ }
77
+
78
+ export interface SessionBudget {
79
+ max_messages: number
80
+ max_bytes: number
81
+ }
82
+
83
+ export interface SessionGrant {
84
+ schema: 'nuxtjp://local-runtime/session-grant/v1'
85
+ session_id: string
86
+ token: string
87
+ subject_id: string
88
+ audience: string
89
+ expires_at_unix_seconds: number
90
+ granted_capabilities: string[]
91
+ classification_ceiling: 'session'
92
+ budget: SessionBudget
93
+ external_actions: false
94
+ }
95
+
96
+ export interface ViewRequest {
97
+ schema: 'nuxtjp://local-runtime/view-request/v1'
98
+ capability_id: string
99
+ view_id: string
100
+ request_nonce: string
101
+ }
102
+
103
+ export interface ViewEnvelope {
104
+ schema: 'nuxtjp://local-runtime/view/v1'
105
+ capability_id: string
106
+ view_id: string
107
+ payload_schema_id: string
108
+ band: 'session' | 'public'
109
+ generated_at_unix_seconds: number
110
+ expires_at_unix_seconds: number
111
+ external_actions: false
112
+ payload: Record<string, PayloadScalar>
113
+ }
114
+
115
+ export type ConnectionPhase =
116
+ | 'idle'
117
+ | 'connecting'
118
+ | 'connected'
119
+ | 'denied'
120
+ | 'unavailable'
121
+
122
+ export interface LocalRuntimeState {
123
+ phase: ConnectionPhase
124
+ manifest: LocalRuntimeManifest | null
125
+ error: string | null
126
+ }