@mikrojs/registry 0.16.0-beta.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.
- package/README.md +54 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# @mikrojs/registry
|
|
2
|
+
|
|
3
|
+
Reference OTA update registry for [Mikro.js](https://mikrojs.dev): a portable fetch handler
|
|
4
|
+
implementing the [OTA Registry Spec](https://mikrojs.dev/registry-spec). Publish builds with
|
|
5
|
+
`mikro ota publish`, enroll devices with `mikro ota enroll`, and serve update offers to the
|
|
6
|
+
`mikro/ota` check-in flow, on Node, Bun, Deno, Cloudflare Workers, or behind any framework
|
|
7
|
+
that speaks fetch.
|
|
8
|
+
|
|
9
|
+
> **Scope.** This is built for a private network or a small hobby fleet: a few devices, one
|
|
10
|
+
> operator, a box you control. It is not built for scale or for serving strangers, and it
|
|
11
|
+
> leaves out much of what that would need — rate limiting that survives a reverse proxy,
|
|
12
|
+
> per-caller quotas, storage sturdier than flat files, backups, secret rotation, and any
|
|
13
|
+
> notion of tenants or orgs. Past that, build your own against the same spec; the `storage`,
|
|
14
|
+
> `verifyAdmin`, and `verifyDevice` seams are there for it.
|
|
15
|
+
>
|
|
16
|
+
> Whatever the scale, the admin token is publish and enrol for the whole fleet, and holding
|
|
17
|
+
> it means running code on every device. Generate one rather than choosing one, and put the
|
|
18
|
+
> registry behind TLS if it is reachable from anywhere you do not control.
|
|
19
|
+
|
|
20
|
+
```js
|
|
21
|
+
import {createRegistry, memoryStorage} from '@mikrojs/registry'
|
|
22
|
+
|
|
23
|
+
const registry = createRegistry({storage: memoryStorage(), token: 'choose-a-secret'})
|
|
24
|
+
// registry.fetch(request) => Promise<Response>
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
On Node, `@mikrojs/registry/node` adds file-backed storage and a plain `node:http` server:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
import {createRegistry} from '@mikrojs/registry'
|
|
31
|
+
import {fileStorage, serve} from '@mikrojs/registry/node'
|
|
32
|
+
|
|
33
|
+
serve(createRegistry({storage: fileStorage('./data'), token: 'choose-a-secret'}), {port: 4873})
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Both `storage` (a small interface over build blobs, device records, and minted tokens) and
|
|
37
|
+
auth (`verifyAdmin`, `verifyDevice`) are pluggable, so the same handler runs against
|
|
38
|
+
whatever backend you already operate. See `examples/ota` in the repo (its
|
|
39
|
+
`registry/server.ts`) for a runnable walkthrough with a real device.
|
|
40
|
+
|
|
41
|
+
Build downloads are capability URLs: the 256-bit checksum is the credential, and the
|
|
42
|
+
endpoint takes no auth. A checksum recovered from a device's flash therefore grants
|
|
43
|
+
access to that build indefinitely, including after the device's credential is re-minted.
|
|
44
|
+
Serve builds behind your own auth if that matters for your app.
|
|
45
|
+
|
|
46
|
+
## Browser login
|
|
47
|
+
|
|
48
|
+
With `token` auth, the registry also serves the spec's optional browser-login flow: a
|
|
49
|
+
client `POST`s `/api/v1/auth/sessions` (optionally with `{app}` context), sends the user to
|
|
50
|
+
the returned `loginUrl`, and polls for the result. The approve page authenticates with the
|
|
51
|
+
registry password (the `token` option), typed once in the browser, and mints a `tok_...`
|
|
52
|
+
scoped to publishing that app plus enrolling devices. Workstations then hold scoped minted
|
|
53
|
+
tokens; the password itself never leaves the operator. Registries using `verifyAdmin` answer
|
|
54
|
+
404 there (the spec's "not supported" signal) and wire their own login.
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mikrojs/registry",
|
|
3
|
+
"version": "0.16.0-beta.0",
|
|
4
|
+
"description": "Reference OTA update registry for Mikro.js: a portable fetch handler with pluggable storage and auth",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"esp32",
|
|
7
|
+
"mikrojs",
|
|
8
|
+
"ota",
|
|
9
|
+
"registry"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/mikrojs/mikro#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/mikrojs/mikro/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"author": "Bjørge Næss <bjoerge@gmail.com>",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/mikrojs/mikro.git"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"exports": {
|
|
27
|
+
".": {
|
|
28
|
+
"development": "./src/index.ts",
|
|
29
|
+
"import": "./dist/index.js"
|
|
30
|
+
},
|
|
31
|
+
"./node": {
|
|
32
|
+
"development": "./src/node.ts",
|
|
33
|
+
"import": "./dist/node.js"
|
|
34
|
+
},
|
|
35
|
+
"./package.json": "./package.json"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"exports": {
|
|
40
|
+
".": "./dist/index.js",
|
|
41
|
+
"./node": "./dist/node.js",
|
|
42
|
+
"./package.json": "./package.json"
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build:ts": "tsc -p tsconfig.build.json",
|
|
47
|
+
"publint": "publint",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"watch": "tsc -p tsconfig.build.json --watch --preserveWatchOutput"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"semver": "^7.7.4"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "catalog:node24",
|
|
56
|
+
"@types/semver": "^7.7.1"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=24.0.0"
|
|
60
|
+
}
|
|
61
|
+
}
|