@tide-ota/server 0.0.1 → 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.
- package/LICENSE +21 -0
- package/README.md +52 -1
- package/dist/core/analytics.d.ts +14 -0
- package/dist/core/analytics.js +40 -0
- package/dist/core/app.d.ts +15 -0
- package/dist/core/app.js +311 -0
- package/dist/core/s3.d.ts +9 -0
- package/dist/core/s3.js +47 -0
- package/dist/core/store.d.ts +24 -0
- package/dist/core/store.js +69 -0
- package/dist/node.d.ts +16 -0
- package/dist/node.js +95 -0
- package/dist/workers.d.ts +2 -0
- package/dist/workers.js +23 -0
- package/package.json +66 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 HashimTheArab
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
1
|
# @tide-ota/server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**A self-hosted Expo Updates server for Cloudflare Workers or any container.**
|
|
4
|
+
|
|
5
|
+
Serve over-the-air updates to React Native apps that use stock [`expo-updates`](https://docs.expo.dev/versions/latest/sdk/updates/),
|
|
6
|
+
from your own bucket:
|
|
7
|
+
|
|
8
|
+
- **No signing key on the server.** Updates are signed when you publish with [`@tide-ota/cli`](https://www.npmjs.com/package/@tide-ota/cli),
|
|
9
|
+
so a compromised server cannot make your apps run new code.
|
|
10
|
+
- **No database.** One R2 or S3-compatible bucket holds everything; the server only reads it.
|
|
11
|
+
- **Small downloads.** Bundle diffing, including from the bundle inside your store build.
|
|
12
|
+
- **Tested with real apps.** Release builds on expo-updates 55 and 58, on Android and iOS.
|
|
13
|
+
|
|
14
|
+
```sh
|
|
15
|
+
npm install @tide-ota/server
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Cloudflare Workers
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
// worker.ts
|
|
22
|
+
export { default } from "@tide-ota/server/workers";
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Bind the bucket as `BUCKET` (R2) and an Analytics Engine dataset as `ANALYTICS` in `wrangler.jsonc`, and set
|
|
26
|
+
`TIDE_APP_ID` if you want requests checked against your app. A complete project is in
|
|
27
|
+
[`examples/operator`](https://github.com/HashimTheArab/tide/tree/main/examples/operator).
|
|
28
|
+
|
|
29
|
+
## Node or a container
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
TIDE_DISK_DIR=/srv/tide-bucket node node_modules/@tide-ota/server/dist/node.js
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Use `TIDE_S3_ENDPOINT`, `TIDE_S3_REGION`, `TIDE_S3_BUCKET`, `TIDE_S3_ACCESS_KEY_ID` and `TIDE_S3_SECRET_ACCESS_KEY`
|
|
36
|
+
(read-only keys) instead of `TIDE_DISK_DIR` for an S3-compatible bucket. `PORT` defaults to 8787 and `GET /hc` is the
|
|
37
|
+
health check. The repository also has a [Dockerfile](https://github.com/HashimTheArab/tide/blob/main/packages/server/Dockerfile).
|
|
38
|
+
|
|
39
|
+
## Your app
|
|
40
|
+
|
|
41
|
+
```js
|
|
42
|
+
{
|
|
43
|
+
runtimeVersion: "1.0.0",
|
|
44
|
+
updates: {
|
|
45
|
+
url: "https://updates.example.com/manifest",
|
|
46
|
+
requestHeaders: { "expo-channel-name": "main" },
|
|
47
|
+
codeSigningCertificate: "./keys/certificate.pem",
|
|
48
|
+
codeSigningMetadata: { keyid: "main", alg: "rsa-v1_5-sha256" },
|
|
49
|
+
},
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Setup, domains and keys: [the deploy guide](https://github.com/HashimTheArab/tide/blob/main/docs/deploy.md). How Tide compares with EAS Update and other
|
|
54
|
+
servers: [the Tide README](https://github.com/HashimTheArab/tide#how-tide-compares).
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { StoredReply } from "@tide-ota/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* One `/manifest` request as a Workers Analytics Engine data point; the layout is in `docs/design.md`, Observability.
|
|
4
|
+
* Every value is bounded, so a point stays far inside Analytics Engine's limits whatever the client sends.
|
|
5
|
+
*/
|
|
6
|
+
export interface ManifestPoint {
|
|
7
|
+
indexes: [string];
|
|
8
|
+
blobs: string[];
|
|
9
|
+
doubles: number[];
|
|
10
|
+
}
|
|
11
|
+
/** Receives one point per `/manifest` request that reaches the reply decision; it is never awaited. */
|
|
12
|
+
export type AnalyticsSink = (point: ManifestPoint) => void;
|
|
13
|
+
/** `channel` and `runtime` must already match the reply key grammar; every other value is read raw from `header`. */
|
|
14
|
+
export declare function manifestPoint(reply: StoredReply["kind"] | "503", platform: "ios" | "android", channel: string, runtime: string, header: (name: string) => string | undefined): ManifestPoint;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { UUID } from "@tide-ota/protocol";
|
|
2
|
+
/** Stock clients list at most this many recently failed updates. */
|
|
3
|
+
const MAX_FAILED_IDS = 5;
|
|
4
|
+
const QUOTED_UUID = new RegExp(`^"(${UUID.source.slice(1, -1)})"$`, "i");
|
|
5
|
+
/** `channel` and `runtime` must already match the reply key grammar; every other value is read raw from `header`. */
|
|
6
|
+
export function manifestPoint(reply, platform, channel, runtime, header) {
|
|
7
|
+
return {
|
|
8
|
+
indexes: [channel],
|
|
9
|
+
blobs: [
|
|
10
|
+
reply,
|
|
11
|
+
platform,
|
|
12
|
+
runtime,
|
|
13
|
+
updateId(header("expo-current-update-id")),
|
|
14
|
+
updateId(header("expo-embedded-update-id")),
|
|
15
|
+
failedUpdateIds(header("expo-recent-failed-update-ids")),
|
|
16
|
+
],
|
|
17
|
+
// Only presence: the value is the client's error message, which may hold user data.
|
|
18
|
+
doubles: [header("expo-fatal-error") === undefined ? 0 : 1],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/** Returns `value` lowercased when it is a UUID, else empty. */
|
|
22
|
+
function updateId(value) {
|
|
23
|
+
const id = value?.toLowerCase() ?? "";
|
|
24
|
+
return UUID.test(id) ? id : "";
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Returns the UUIDs of an RFC 8941 list of strings, lowercased, comma-joined, in order and at most 5; every other
|
|
28
|
+
* member is dropped.
|
|
29
|
+
*/
|
|
30
|
+
function failedUpdateIds(value) {
|
|
31
|
+
const ids = [];
|
|
32
|
+
for (const member of value?.split(",") ?? []) {
|
|
33
|
+
const id = QUOTED_UUID.exec(member.trim())?.[1];
|
|
34
|
+
if (id !== undefined)
|
|
35
|
+
ids.push(id.toLowerCase());
|
|
36
|
+
if (ids.length === MAX_FAILED_IDS)
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
return ids.join(",");
|
|
40
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import type { AnalyticsSink } from "./analytics.ts";
|
|
3
|
+
import type { Store } from "./store.ts";
|
|
4
|
+
export interface AppOptions {
|
|
5
|
+
/** When set and not empty, a request whose `expo-app-id` is present and differs is rejected. */
|
|
6
|
+
readonly appId?: string | undefined;
|
|
7
|
+
/** Returns the one deadline covering every store read of a `/manifest` request. */
|
|
8
|
+
readonly replyDeadline?: () => AbortSignal;
|
|
9
|
+
/** Returns the deadline of a `/bundles` request's patch lookup; past it the full bundle is served. */
|
|
10
|
+
readonly patchDeadline?: () => AbortSignal;
|
|
11
|
+
/** Receives a data point per `/manifest` request that reaches the reply decision. */
|
|
12
|
+
readonly analytics?: AnalyticsSink | undefined;
|
|
13
|
+
}
|
|
14
|
+
/** Returns the Tide HTTP app; it uses only web-standard APIs, so every runtime serves the same app. */
|
|
15
|
+
export declare function createApp(store: Store, options?: AppOptions): Hono;
|
package/dist/core/app.js
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { HEADER_VALUE, MAX_BASE_BYTES, MAX_REPLY_BYTES, NO_UPDATE_KEY, ProtocolError, UUID, assetContentType, baseKey, contentKey, decodeBaseRecord, decodeStoredReply, patchKey, replyKey, } from "@tide-ota/protocol";
|
|
3
|
+
import { manifestPoint } from "./analytics.js";
|
|
4
|
+
import { abortable, discard, readBounded } from "./store.js";
|
|
5
|
+
// Only a 200 may be cached: a missing object can be uploaded later, and an outage must not stick.
|
|
6
|
+
const NO_STORE = { "cache-control": "no-store" };
|
|
7
|
+
const IMMUTABLE = "public, max-age=31536000, immutable";
|
|
8
|
+
// Every header the patch lookup reads, so a shared cache never answers a patch request with a cached full bundle.
|
|
9
|
+
const BUNDLE_VARY = "A-IM, Expo-Current-Update-ID, Expo-Requested-Update-ID";
|
|
10
|
+
const CONTENT_HEX = /^[0-9a-f]{64}$/; // A bundle key's SHA-256, as stored.
|
|
11
|
+
// Media-type parameters and q-values are ignored: stock clients send multipart/mixed, the only type Tide stores.
|
|
12
|
+
const ACCEPTS_MULTIPART = /multipart\/mixed|multipart\/\*|\*\/\*/;
|
|
13
|
+
const QVALUE = /^(?:0(?:\.[0-9]{0,3})?|1(?:\.0{0,3})?)$/; // RFC 9110 12.4.2.
|
|
14
|
+
const QUOTED = /"(?:[^"\\]|\\[\s\S]?)*(?:"|$)/g; // A quoted-string, to the end when unterminated.
|
|
15
|
+
const NO_PATCH = new Error("no patch"); // Thrown by a lookup that found nothing without a fault.
|
|
16
|
+
/** Returns the Tide HTTP app; it uses only web-standard APIs, so every runtime serves the same app. */
|
|
17
|
+
export function createApp(store, options = {}) {
|
|
18
|
+
// The patch deadline keeps the full-bundle fallback well inside Android's 10 s read timeout.
|
|
19
|
+
const { replyDeadline = () => AbortSignal.timeout(10_000), patchDeadline = () => AbortSignal.timeout(2_000), analytics = () => undefined, } = options;
|
|
20
|
+
const appId = options.appId === "" ? undefined : options.appId; // Empty is unset.
|
|
21
|
+
// A received header value never has edge whitespace, so such an app ID could never match.
|
|
22
|
+
if (appId !== undefined && !HEADER_VALUE.test(appId)) {
|
|
23
|
+
throw new Error("app ID must be printable ASCII without edge whitespace");
|
|
24
|
+
}
|
|
25
|
+
const app = new Hono();
|
|
26
|
+
app.get("/hc", (c) => c.text("ok"));
|
|
27
|
+
/** Returns the record at `key` read through `decode`, or undefined when there is none. */
|
|
28
|
+
const readRecord = async (key, limit, decode, signal) => {
|
|
29
|
+
try {
|
|
30
|
+
const object = await abortable(store.get(key, signal), signal);
|
|
31
|
+
if (object === undefined)
|
|
32
|
+
return undefined;
|
|
33
|
+
return decode(await readBounded(object, limit, signal));
|
|
34
|
+
}
|
|
35
|
+
catch (e) {
|
|
36
|
+
throw new Error(`reading ${key} failed`, { cause: e });
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
app.get("/manifest", async (c) => {
|
|
40
|
+
// An empty value is absent: workerd drops empty header values, and both runtimes must agree.
|
|
41
|
+
const header = (name) => {
|
|
42
|
+
const value = c.req.header(name);
|
|
43
|
+
return value === "" ? undefined : value;
|
|
44
|
+
};
|
|
45
|
+
const platform = header("expo-platform");
|
|
46
|
+
if (platform !== "ios" && platform !== "android") {
|
|
47
|
+
return c.text("expo-platform must be ios or android\n", 400, NO_STORE);
|
|
48
|
+
}
|
|
49
|
+
const requestAppId = header("expo-app-id");
|
|
50
|
+
if (appId !== undefined && requestAppId !== undefined && requestAppId !== appId) {
|
|
51
|
+
return c.text("expo-app-id does not match this server\n", 400, NO_STORE);
|
|
52
|
+
}
|
|
53
|
+
const version = header("expo-protocol-version");
|
|
54
|
+
if (version !== undefined && version !== "1") {
|
|
55
|
+
return c.text("expo-protocol-version must be 1\n", 406, NO_STORE);
|
|
56
|
+
}
|
|
57
|
+
const accept = header("accept");
|
|
58
|
+
if (accept !== undefined && !ACCEPTS_MULTIPART.test(accept.toLowerCase())) {
|
|
59
|
+
return c.text("accept must allow multipart/mixed\n", 406, NO_STORE);
|
|
60
|
+
}
|
|
61
|
+
// No default channel: a misconfigured app sees a 400 in its logs rather than a silent no-update.
|
|
62
|
+
const channel = header("expo-channel-name") ?? "";
|
|
63
|
+
const runtime = header("expo-runtime-version") ?? "";
|
|
64
|
+
let key;
|
|
65
|
+
try {
|
|
66
|
+
key = replyKey(channel, runtime, platform);
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
if (!(e instanceof ProtocolError))
|
|
70
|
+
throw e;
|
|
71
|
+
const name = e.field === "channel" ? "expo-channel-name" : "expo-runtime-version";
|
|
72
|
+
const value = e.field === "channel" ? channel : runtime;
|
|
73
|
+
const problem = value === "" ? "is missing" : "must be 1 to 64 of A-Z, a-z, 0-9, ., _, + and -";
|
|
74
|
+
return c.text(`${name} ${problem}\n`, 400, NO_STORE);
|
|
75
|
+
}
|
|
76
|
+
const signal = replyDeadline();
|
|
77
|
+
let reply;
|
|
78
|
+
try {
|
|
79
|
+
const pointer = await readRecord(key, MAX_REPLY_BYTES, decodeStoredReply, signal);
|
|
80
|
+
if (pointer?.kind === "noUpdateAvailable")
|
|
81
|
+
throw new Error(`${key} holds noUpdateAvailable`);
|
|
82
|
+
// A rollback is always served: the client applies it only when its commitTime is newer than what it runs.
|
|
83
|
+
const current = header("expo-current-update-id")?.toLowerCase();
|
|
84
|
+
if (pointer !== undefined && (pointer.kind !== "manifest" || current !== pointer.updateId)) {
|
|
85
|
+
reply = pointer;
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
const noUpdate = await readRecord(NO_UPDATE_KEY, MAX_REPLY_BYTES, decodeStoredReply, signal);
|
|
89
|
+
if (noUpdate === undefined)
|
|
90
|
+
throw new Error(`${NO_UPDATE_KEY} is missing`);
|
|
91
|
+
if (noUpdate.kind !== "noUpdateAvailable") {
|
|
92
|
+
throw new Error(`${NO_UPDATE_KEY} holds ${noUpdate.kind}`);
|
|
93
|
+
}
|
|
94
|
+
reply = noUpdate;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(`/manifest for ${key} failed`, e);
|
|
99
|
+
}
|
|
100
|
+
try {
|
|
101
|
+
const written = analytics(manifestPoint(reply?.kind ?? "503", platform, channel, runtime, header));
|
|
102
|
+
// An async sink still type-checks; its rejection is logged, never awaited.
|
|
103
|
+
Promise.resolve(written).catch(sinkFailed);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
sinkFailed(e);
|
|
107
|
+
}
|
|
108
|
+
if (reply === undefined)
|
|
109
|
+
return c.text("storage unavailable\n", 503, NO_STORE);
|
|
110
|
+
const headers = {
|
|
111
|
+
"content-type": `multipart/mixed; boundary=${reply.boundary}`,
|
|
112
|
+
"expo-protocol-version": "1",
|
|
113
|
+
"expo-sfv-version": "0",
|
|
114
|
+
"cache-control": "private, max-age=0",
|
|
115
|
+
};
|
|
116
|
+
// Sent even when empty: a client keeps earlier filters when the header is absent.
|
|
117
|
+
if (reply.kind === "manifest")
|
|
118
|
+
headers["expo-manifest-filters"] = reply.manifestFilters;
|
|
119
|
+
return new Response(reply.body, { headers });
|
|
120
|
+
});
|
|
121
|
+
/** Returns `object` as the reply; HEAD gets the headers only, and the stream is cancelled without waiting. */
|
|
122
|
+
const send = (c, object, status, headers) => {
|
|
123
|
+
headers["content-length"] = String(object.size);
|
|
124
|
+
// Hono answers HEAD through the GET handler and drops the body without cancelling it.
|
|
125
|
+
if (c.req.method === "HEAD") {
|
|
126
|
+
discard(object.body);
|
|
127
|
+
return new Response(null, { status, headers });
|
|
128
|
+
}
|
|
129
|
+
return new Response(object.body, { status, headers });
|
|
130
|
+
};
|
|
131
|
+
/** Serves the object at `key` as immutable `contentType`; only a 200 may be cached. */
|
|
132
|
+
const serveObject = async (c, key, contentType) => {
|
|
133
|
+
let object;
|
|
134
|
+
try {
|
|
135
|
+
object = await store.get(key);
|
|
136
|
+
}
|
|
137
|
+
catch (e) {
|
|
138
|
+
console.error(`store get ${key} failed`, e);
|
|
139
|
+
return c.text("storage unavailable\n", 503, NO_STORE);
|
|
140
|
+
}
|
|
141
|
+
if (object === undefined)
|
|
142
|
+
return c.text("not found\n", 404, NO_STORE);
|
|
143
|
+
return send(c, object, 200, { "content-type": contentType, "cache-control": IMMUTABLE });
|
|
144
|
+
};
|
|
145
|
+
/** Returns the base record for `updateId`, or undefined when there is none; a record of another ID rejects. */
|
|
146
|
+
const readBase = (updateId, signal) => readRecord(baseKey(updateId), MAX_BASE_BYTES, (bytes) => {
|
|
147
|
+
const record = decodeBaseRecord(bytes);
|
|
148
|
+
// The codec never sees the key, so only here can a record filed under another ID be caught.
|
|
149
|
+
if (record.updateId !== updateId)
|
|
150
|
+
throw new Error(`it holds update ${record.updateId}`);
|
|
151
|
+
return record;
|
|
152
|
+
}, signal);
|
|
153
|
+
/**
|
|
154
|
+
* Returns the object at `key`, or rejects once `signal` aborts first. The store gets a signal that `signal` aborts
|
|
155
|
+
* only until the get settles: an adapter may keep it on the body, and the deadline must not cut a patch on the wire.
|
|
156
|
+
*/
|
|
157
|
+
const getBeforeDeadline = async (key, signal) => {
|
|
158
|
+
const own = new AbortController();
|
|
159
|
+
const abort = () => {
|
|
160
|
+
own.abort(signal.reason);
|
|
161
|
+
};
|
|
162
|
+
if (signal.aborted)
|
|
163
|
+
abort();
|
|
164
|
+
else
|
|
165
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
166
|
+
const get = store.get(key, own.signal).finally(() => {
|
|
167
|
+
signal.removeEventListener("abort", abort);
|
|
168
|
+
});
|
|
169
|
+
try {
|
|
170
|
+
return await abortable(get, signal);
|
|
171
|
+
}
|
|
172
|
+
catch (e) {
|
|
173
|
+
throw new Error(`reading ${key} failed`, { cause: e });
|
|
174
|
+
}
|
|
175
|
+
};
|
|
176
|
+
/** Resolves the stored patch from `current`'s base to bundle `hex`, or undefined; never rejects. */
|
|
177
|
+
const findPatch = async (hex, { current, requested }, answered) => {
|
|
178
|
+
const settled = new AbortController(); // Ends a base read once its sibling has decided.
|
|
179
|
+
const signal = AbortSignal.any([patchDeadline(), answered, settled.signal]);
|
|
180
|
+
// Either base alone can rule a patch out, so neither waits on the other to say so.
|
|
181
|
+
const usable = async (read, ok) => {
|
|
182
|
+
const record = await read;
|
|
183
|
+
if (record === undefined || !ok(record))
|
|
184
|
+
throw NO_PATCH;
|
|
185
|
+
return record;
|
|
186
|
+
};
|
|
187
|
+
try {
|
|
188
|
+
const [from] = await Promise.all([
|
|
189
|
+
usable(readBase(current, signal), () => true),
|
|
190
|
+
usable(readBase(requested, signal), (r) => contentKey(r.launchAsset.hash) === hex),
|
|
191
|
+
]);
|
|
192
|
+
return await getBeforeDeadline(patchKey(contentKey(from.launchAsset.hash), hex), signal);
|
|
193
|
+
}
|
|
194
|
+
catch (e) {
|
|
195
|
+
// Every fault falls back to the full bundle, which is always correct; only a patch is lost.
|
|
196
|
+
if (e !== NO_PATCH && !answered.aborted) {
|
|
197
|
+
console.error(`patch lookup for bundles/${hex} failed`, e);
|
|
198
|
+
}
|
|
199
|
+
return undefined;
|
|
200
|
+
}
|
|
201
|
+
finally {
|
|
202
|
+
settled.abort();
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
// Every manifest's launch asset URL. The bundle read alone decides 404 and 503; a patch only replaces a 200.
|
|
206
|
+
app.get("/bundles/:hex", async (c) => {
|
|
207
|
+
const hex = c.req.param("hex");
|
|
208
|
+
if (!CONTENT_HEX.test(hex)) {
|
|
209
|
+
return c.text("the path must end in 64 lowercase hex characters\n", 400, NO_STORE);
|
|
210
|
+
}
|
|
211
|
+
const key = `bundles/${hex}`;
|
|
212
|
+
const read = store.get(key);
|
|
213
|
+
const request = patchRequest(c);
|
|
214
|
+
const answered = new AbortController();
|
|
215
|
+
const lookup = request === undefined ? Promise.resolve(undefined) : findPatch(hex, request, answered.signal);
|
|
216
|
+
/** Ends the lookup without waiting; a patch it already found is cancelled. */
|
|
217
|
+
const abandon = () => {
|
|
218
|
+
answered.abort();
|
|
219
|
+
void lookup.then((patch) => {
|
|
220
|
+
if (patch !== undefined)
|
|
221
|
+
discard(patch.body);
|
|
222
|
+
});
|
|
223
|
+
};
|
|
224
|
+
let object;
|
|
225
|
+
try {
|
|
226
|
+
object = await read;
|
|
227
|
+
}
|
|
228
|
+
catch (e) {
|
|
229
|
+
abandon();
|
|
230
|
+
console.error(`store get ${key} failed`, e);
|
|
231
|
+
return c.text("storage unavailable\n", 503, NO_STORE);
|
|
232
|
+
}
|
|
233
|
+
if (object === undefined) {
|
|
234
|
+
abandon();
|
|
235
|
+
return c.text("not found\n", 404, NO_STORE);
|
|
236
|
+
}
|
|
237
|
+
const patch = await lookup;
|
|
238
|
+
if (request === undefined || patch === undefined) {
|
|
239
|
+
return send(c, object, 200, {
|
|
240
|
+
"content-type": assetContentType("bundle"),
|
|
241
|
+
"cache-control": IMMUTABLE,
|
|
242
|
+
vary: BUNDLE_VARY,
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
discard(object.body);
|
|
246
|
+
// The body is a BSDIFF40 patch, not script; the client does not check its type.
|
|
247
|
+
return send(c, patch, 226, {
|
|
248
|
+
"content-type": "application/octet-stream",
|
|
249
|
+
im: "bsdiff",
|
|
250
|
+
"expo-base-update-id": request.current,
|
|
251
|
+
"cache-control": "private, no-store",
|
|
252
|
+
vary: BUNDLE_VARY,
|
|
253
|
+
});
|
|
254
|
+
});
|
|
255
|
+
// Serves URLs earlier servers put in signed manifests: `h` is the asset's unpadded base64url SHA-256.
|
|
256
|
+
app.get("/assets", async (c) => {
|
|
257
|
+
const h = c.req.queries("h");
|
|
258
|
+
let key;
|
|
259
|
+
try {
|
|
260
|
+
key = `assets/${contentKey(h?.length === 1 ? (h[0] ?? "") : "")}`;
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
return c.text("h must be one 43-character base64url SHA-256\n", 400, NO_STORE);
|
|
264
|
+
}
|
|
265
|
+
const ext = c.req.queries("ext");
|
|
266
|
+
return await serveObject(c, key, assetContentType(ext?.length === 1 ? (ext[0] ?? "") : ""));
|
|
267
|
+
});
|
|
268
|
+
app.notFound((c) => c.text("not found\n", 404, NO_STORE));
|
|
269
|
+
app.onError((e, c) => {
|
|
270
|
+
console.error(e);
|
|
271
|
+
return c.text("internal error\n", 500, NO_STORE);
|
|
272
|
+
});
|
|
273
|
+
return app;
|
|
274
|
+
}
|
|
275
|
+
/** Logs a failed analytics write by error name only: the point holds client values. */
|
|
276
|
+
function sinkFailed(e) {
|
|
277
|
+
console.error(`analytics sink failed: ${e instanceof Error ? e.name : typeof e}`);
|
|
278
|
+
}
|
|
279
|
+
/** Returns the update IDs of a request that accepts a bsdiff patch, or undefined. */
|
|
280
|
+
function patchRequest(c) {
|
|
281
|
+
if (!acceptsBsdiff(c.req.header("a-im") ?? ""))
|
|
282
|
+
return undefined;
|
|
283
|
+
// Clients send lowercase IDs; a repeated header arrives joined with ", " and fails the grammar.
|
|
284
|
+
const current = c.req.header("expo-current-update-id")?.toLowerCase() ?? "";
|
|
285
|
+
const requested = c.req.header("expo-requested-update-id")?.toLowerCase() ?? "";
|
|
286
|
+
if (!UUID.test(current) || !UUID.test(requested))
|
|
287
|
+
return undefined;
|
|
288
|
+
return { current, requested };
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Returns whether an `A-IM` value lists `bsdiff` with no q parameter or a valid one above zero (RFC 3229 10.5.3).
|
|
292
|
+
* Other parameters are ignored; a malformed q declines.
|
|
293
|
+
*/
|
|
294
|
+
function acceptsBsdiff(value) {
|
|
295
|
+
// Quoted strings are emptied first, so a quoted parameter cannot list an item.
|
|
296
|
+
return value
|
|
297
|
+
.replace(QUOTED, '""')
|
|
298
|
+
.split(",")
|
|
299
|
+
.some((item) => {
|
|
300
|
+
const [name = "", ...params] = item.split(";");
|
|
301
|
+
if (name.trim().toLowerCase() !== "bsdiff")
|
|
302
|
+
return false;
|
|
303
|
+
return params.every((param) => {
|
|
304
|
+
const eq = param.indexOf("=");
|
|
305
|
+
if ((eq === -1 ? param : param.slice(0, eq)).trim().toLowerCase() !== "q")
|
|
306
|
+
return true;
|
|
307
|
+
const q = param.slice(eq + 1).trim();
|
|
308
|
+
return eq !== -1 && QVALUE.test(q) && Number(q) > 0;
|
|
309
|
+
});
|
|
310
|
+
});
|
|
311
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { S3Config } from "@tide-ota/protocol";
|
|
2
|
+
import type { Store } from "./store.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a store that reads objects with signed GetObject requests; the credentials need only s3:GetObject and
|
|
5
|
+
* s3:ListBucket. `timeoutMs` lasts until a 200's headers, or a non-200's error body, have arrived.
|
|
6
|
+
*/
|
|
7
|
+
export declare function s3Store(config: S3Config & {
|
|
8
|
+
readonly timeoutMs?: number;
|
|
9
|
+
}): Store;
|
package/dist/core/s3.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { S3Error, s3Absent, s3BodyProblem, s3Fetch, s3Target } from "@tide-ota/protocol";
|
|
2
|
+
/** Each body's Response: Node's fetch cancels a body once its Response is collected, even while the body is held. */
|
|
3
|
+
const responses = new WeakMap();
|
|
4
|
+
/**
|
|
5
|
+
* Returns a store that reads objects with signed GetObject requests; the credentials need only s3:GetObject and
|
|
6
|
+
* s3:ListBucket. `timeoutMs` lasts until a 200's headers, or a non-200's error body, have arrived.
|
|
7
|
+
*/
|
|
8
|
+
export function s3Store(config) {
|
|
9
|
+
const target = s3Target(config);
|
|
10
|
+
const timeoutMs = config.timeoutMs ?? 10_000;
|
|
11
|
+
const operation = "GetObject";
|
|
12
|
+
return {
|
|
13
|
+
async get(key, signal) {
|
|
14
|
+
const controller = new AbortController();
|
|
15
|
+
const timer = setTimeout(() => {
|
|
16
|
+
controller.abort();
|
|
17
|
+
}, timeoutMs);
|
|
18
|
+
try {
|
|
19
|
+
const res = await s3Fetch(target, { method: "GET", key },
|
|
20
|
+
// The caller's signal also ends a body mid-read.
|
|
21
|
+
signal === undefined ? controller.signal : AbortSignal.any([controller.signal, signal]));
|
|
22
|
+
if (res.status === 200) {
|
|
23
|
+
clearTimeout(timer); // A long download must not be cut off.
|
|
24
|
+
const problem = s3BodyProblem(res);
|
|
25
|
+
if (problem !== undefined || res.body === null) {
|
|
26
|
+
await res.body?.cancel(); // Releases the connection.
|
|
27
|
+
throw new S3Error(operation, { problem: problem ?? "length" });
|
|
28
|
+
}
|
|
29
|
+
responses.set(res.body, res);
|
|
30
|
+
return { body: res.body, size: Number(res.headers.get("content-length")) };
|
|
31
|
+
}
|
|
32
|
+
return await s3Absent(operation, res);
|
|
33
|
+
}
|
|
34
|
+
catch (e) {
|
|
35
|
+
if (e instanceof S3Error)
|
|
36
|
+
throw e;
|
|
37
|
+
if (!controller.signal.aborted && signal?.aborted)
|
|
38
|
+
throw signal.reason;
|
|
39
|
+
// fetch's own text is not ours to log.
|
|
40
|
+
throw S3Error.unanswered(operation, controller.signal.aborted, timeoutMs);
|
|
41
|
+
}
|
|
42
|
+
finally {
|
|
43
|
+
clearTimeout(timer);
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** An object's bytes and their length; the stream must be consumed or cancelled. */
|
|
2
|
+
export interface StoredObject {
|
|
3
|
+
readonly body: ReadableStream<Uint8Array>;
|
|
4
|
+
readonly size: number;
|
|
5
|
+
}
|
|
6
|
+
/** The server's read-only view of the bucket. */
|
|
7
|
+
export interface Store {
|
|
8
|
+
/**
|
|
9
|
+
* Resolves undefined only when the object does not exist; every other failure rejects. `signal` lets an adapter
|
|
10
|
+
* release its I/O early; callers still race the result through `abortable`.
|
|
11
|
+
*/
|
|
12
|
+
get(key: string, signal?: AbortSignal): Promise<StoredObject | undefined>;
|
|
13
|
+
}
|
|
14
|
+
/** Returns `get`'s result, or rejects with the reason once `signal` aborts; a later object has its body cancelled. */
|
|
15
|
+
export declare function abortable(get: Promise<StoredObject | undefined>, signal: AbortSignal): Promise<StoredObject | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* Returns exactly `object.size` bytes. Rejects, cancelling the body, when the size is over `limit`, when the stream
|
|
18
|
+
* delivers more or fewer bytes than its size, or when `signal` aborts, even if the stream never ends.
|
|
19
|
+
*/
|
|
20
|
+
export declare function readBounded(object: StoredObject, limit: number, signal: AbortSignal): Promise<Uint8Array<ArrayBuffer>>;
|
|
21
|
+
/** Starts cancelling without waiting: a source's `cancel` may never settle, and must not delay a reply. */
|
|
22
|
+
export declare function discard(stream: {
|
|
23
|
+
cancel(): Promise<void>;
|
|
24
|
+
}): void;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Returns `get`'s result, or rejects with the reason once `signal` aborts; a later object has its body cancelled. */
|
|
2
|
+
export function abortable(get, signal) {
|
|
3
|
+
const aborted = Promise.withResolvers();
|
|
4
|
+
const abort = () => {
|
|
5
|
+
aborted.reject(signal.reason);
|
|
6
|
+
};
|
|
7
|
+
if (signal.aborted)
|
|
8
|
+
abort();
|
|
9
|
+
else
|
|
10
|
+
signal.addEventListener("abort", abort, { once: true });
|
|
11
|
+
const settled = get.finally(() => {
|
|
12
|
+
signal.removeEventListener("abort", abort);
|
|
13
|
+
});
|
|
14
|
+
settled.then((object) => {
|
|
15
|
+
if (signal.aborted && object !== undefined)
|
|
16
|
+
discard(object.body);
|
|
17
|
+
}, () => undefined);
|
|
18
|
+
return Promise.race([settled, aborted.promise]);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Returns exactly `object.size` bytes. Rejects, cancelling the body, when the size is over `limit`, when the stream
|
|
22
|
+
* delivers more or fewer bytes than its size, or when `signal` aborts, even if the stream never ends.
|
|
23
|
+
*/
|
|
24
|
+
export async function readBounded(object, limit, signal) {
|
|
25
|
+
const { body, size } = object;
|
|
26
|
+
if (signal.aborted) {
|
|
27
|
+
discard(body);
|
|
28
|
+
throw signal.reason;
|
|
29
|
+
}
|
|
30
|
+
if (size > limit) {
|
|
31
|
+
discard(body);
|
|
32
|
+
throw new Error(`object of ${size} bytes is over the ${limit}-byte limit`);
|
|
33
|
+
}
|
|
34
|
+
const out = new Uint8Array(size);
|
|
35
|
+
const reader = body.getReader();
|
|
36
|
+
const cancel = () => {
|
|
37
|
+
discard(reader);
|
|
38
|
+
};
|
|
39
|
+
signal.addEventListener("abort", cancel, { once: true });
|
|
40
|
+
try {
|
|
41
|
+
let at = 0;
|
|
42
|
+
for (;;) {
|
|
43
|
+
const { done, value } = await reader.read();
|
|
44
|
+
// Cancelling resolves a pending read as done, so check abort before treating it as EOF.
|
|
45
|
+
signal.throwIfAborted();
|
|
46
|
+
if (done) {
|
|
47
|
+
if (at !== size)
|
|
48
|
+
throw new Error(`object ended after ${at} of its ${size} bytes`);
|
|
49
|
+
return out;
|
|
50
|
+
}
|
|
51
|
+
// Checked before copying, so memory never passes `size` and an over-long stream need not end.
|
|
52
|
+
if (value.length > size - at)
|
|
53
|
+
throw new Error(`object is longer than its ${size} bytes`);
|
|
54
|
+
out.set(value, at);
|
|
55
|
+
at += value.length;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
catch (e) {
|
|
59
|
+
discard(reader);
|
|
60
|
+
throw e;
|
|
61
|
+
}
|
|
62
|
+
finally {
|
|
63
|
+
signal.removeEventListener("abort", cancel);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/** Starts cancelling without waiting: a source's `cancel` may never settle, and must not delay a reply. */
|
|
67
|
+
export function discard(stream) {
|
|
68
|
+
stream.cancel().catch(() => undefined);
|
|
69
|
+
}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Server } from "node:http";
|
|
2
|
+
import type { Store } from "./core/store.ts";
|
|
3
|
+
/**
|
|
4
|
+
* Returns a store over a directory, for tests and single-host development. The root is trusted (only the publisher
|
|
5
|
+
* writes it), so the key grammar is the whole containment rule.
|
|
6
|
+
*/
|
|
7
|
+
export declare function diskStore(root: string): Store;
|
|
8
|
+
/** Returns the store the environment configures: TIDE_DISK_DIR, or every TIDE_S3_* variable. Empty means unset. */
|
|
9
|
+
export declare function storeFromEnv(env: Readonly<Record<string, string | undefined>>): Store;
|
|
10
|
+
/** Starts the app on Node; port 0 picks a free port, and no `hostname` listens on every interface. */
|
|
11
|
+
export declare function startServer(options: {
|
|
12
|
+
port: number;
|
|
13
|
+
hostname?: string;
|
|
14
|
+
store: Store;
|
|
15
|
+
appId?: string | undefined;
|
|
16
|
+
}): Promise<Server>;
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { statSync } from "node:fs";
|
|
2
|
+
import { open, stat } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import { Readable } from "node:stream";
|
|
5
|
+
import { serve } from "@hono/node-server";
|
|
6
|
+
import { diskPath, storageFromEnv } from "@tide-ota/protocol";
|
|
7
|
+
import { createApp } from "./core/app.js";
|
|
8
|
+
import { s3Store } from "./core/s3.js";
|
|
9
|
+
/**
|
|
10
|
+
* Returns a store over a directory, for tests and single-host development. The root is trusted (only the publisher
|
|
11
|
+
* writes it), so the key grammar is the whole containment rule.
|
|
12
|
+
*/
|
|
13
|
+
export function diskStore(root) {
|
|
14
|
+
if (!statSync(root, { throwIfNoEntry: false })?.isDirectory()) {
|
|
15
|
+
throw new Error(`disk store root ${root} is not a directory`);
|
|
16
|
+
}
|
|
17
|
+
return {
|
|
18
|
+
async get(key) {
|
|
19
|
+
let path;
|
|
20
|
+
try {
|
|
21
|
+
path = diskPath(key);
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
throw new Error(`invalid store key ${JSON.stringify(key)}`);
|
|
25
|
+
}
|
|
26
|
+
let fh;
|
|
27
|
+
try {
|
|
28
|
+
fh = await open(join(root, path), "r");
|
|
29
|
+
}
|
|
30
|
+
catch (e) {
|
|
31
|
+
if (e.code !== "ENOENT")
|
|
32
|
+
throw e;
|
|
33
|
+
// A root gone after startup is an outage, not a miss for every key.
|
|
34
|
+
if ((await stat(root).catch(() => undefined))?.isDirectory())
|
|
35
|
+
return undefined;
|
|
36
|
+
throw new Error(`disk store root ${root} unavailable`, { cause: e });
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const st = await fh.stat();
|
|
40
|
+
if (!st.isFile())
|
|
41
|
+
throw new Error(`${key} is not a regular file`);
|
|
42
|
+
// createReadStream closes the handle on end, error and cancel alike.
|
|
43
|
+
const body = Readable.toWeb(fh.createReadStream());
|
|
44
|
+
return { body, size: st.size };
|
|
45
|
+
}
|
|
46
|
+
catch (e) {
|
|
47
|
+
await fh.close();
|
|
48
|
+
throw e;
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** Returns the store the environment configures: TIDE_DISK_DIR, or every TIDE_S3_* variable. Empty means unset. */
|
|
54
|
+
export function storeFromEnv(env) {
|
|
55
|
+
const storage = storageFromEnv(env);
|
|
56
|
+
return "disk" in storage ? diskStore(storage.disk) : s3Store(storage.s3);
|
|
57
|
+
}
|
|
58
|
+
/** Starts the app on Node; port 0 picks a free port, and no `hostname` listens on every interface. */
|
|
59
|
+
export function startServer(options) {
|
|
60
|
+
const app = createApp(options.store, { appId: options.appId });
|
|
61
|
+
const { port, hostname } = options;
|
|
62
|
+
return new Promise((resolve) => {
|
|
63
|
+
// Without a createServer option, serve makes an HTTP/1.1 server.
|
|
64
|
+
const server = serve({ fetch: app.fetch, port, ...(hostname !== undefined && { hostname }) }, () => resolve(server));
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
if (import.meta.main) {
|
|
68
|
+
let store;
|
|
69
|
+
try {
|
|
70
|
+
store = storeFromEnv(process.env);
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.error(`tide: ${e.message}`);
|
|
74
|
+
process.exit(1);
|
|
75
|
+
}
|
|
76
|
+
const server = await startServer({
|
|
77
|
+
port: Number(process.env.PORT ?? 8787),
|
|
78
|
+
store,
|
|
79
|
+
appId: process.env.TIDE_APP_ID,
|
|
80
|
+
});
|
|
81
|
+
console.log(`tide listening on port ${server.address().port}`);
|
|
82
|
+
// As PID 1 in a container, Node would ignore SIGTERM; close lets in-flight replies finish before exiting.
|
|
83
|
+
let closing = false;
|
|
84
|
+
// close only drops connections idle at the time; one whose reply ends later would wait out its keep-alive.
|
|
85
|
+
server.on("request", (_req, res) => {
|
|
86
|
+
res.once("finish", () => closing && server.closeIdleConnections());
|
|
87
|
+
});
|
|
88
|
+
const shutdown = () => {
|
|
89
|
+
console.log("tide closing");
|
|
90
|
+
closing = true;
|
|
91
|
+
server.close(() => process.exit(0));
|
|
92
|
+
};
|
|
93
|
+
process.once("SIGTERM", shutdown);
|
|
94
|
+
process.once("SIGINT", shutdown);
|
|
95
|
+
}
|
package/dist/workers.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { env } from "cloudflare:workers";
|
|
2
|
+
import { createApp } from "./core/app.js";
|
|
3
|
+
/** Returns a store over an R2 binding; only `get` is reachable, since a binding cannot be made read-only. */
|
|
4
|
+
function r2Store(bucket) {
|
|
5
|
+
return {
|
|
6
|
+
async get(key) {
|
|
7
|
+
const object = await bucket.get(key);
|
|
8
|
+
if (object === null)
|
|
9
|
+
return undefined;
|
|
10
|
+
// Tide stores objects unencoded; an encoded one would reach clients as the wrong bytes.
|
|
11
|
+
const encoding = object.httpMetadata?.contentEncoding;
|
|
12
|
+
if (encoding !== undefined && encoding !== "identity") {
|
|
13
|
+
await object.body.cancel();
|
|
14
|
+
throw new Error(`R2 object ${key} has content-encoding ${encoding}`);
|
|
15
|
+
}
|
|
16
|
+
return { body: object.body, size: object.size };
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
export default createApp(r2Store(env.BUCKET), {
|
|
21
|
+
appId: env.TIDE_APP_ID,
|
|
22
|
+
analytics: (point) => env.ANALYTICS.writeDataPoint(point),
|
|
23
|
+
});
|
package/package.json
CHANGED
|
@@ -1,8 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tide-ota/server",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Self-hosted Expo Updates server for React Native OTA updates, on Cloudflare Workers (R2) or Node (S3). No database.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"expo",
|
|
7
|
+
"expo-updates",
|
|
8
|
+
"expo-updates-server",
|
|
9
|
+
"eas-update",
|
|
10
|
+
"react-native",
|
|
11
|
+
"react-native-ota",
|
|
12
|
+
"ota",
|
|
13
|
+
"ota-updates",
|
|
14
|
+
"self-hosted",
|
|
15
|
+
"codepush-alternative",
|
|
16
|
+
"cloudflare-workers",
|
|
17
|
+
"r2",
|
|
18
|
+
"s3",
|
|
19
|
+
"serverless"
|
|
20
|
+
],
|
|
21
|
+
"homepage": "https://github.com/HashimTheArab/tide/blob/main/docs/deploy.md",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/HashimTheArab/tide/issues"
|
|
24
|
+
},
|
|
5
25
|
"license": "MIT",
|
|
6
|
-
"repository": {
|
|
7
|
-
|
|
8
|
-
|
|
26
|
+
"repository": {
|
|
27
|
+
"type": "git",
|
|
28
|
+
"url": "git+https://github.com/HashimTheArab/tide.git",
|
|
29
|
+
"directory": "packages/server"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"LICENSE"
|
|
34
|
+
],
|
|
35
|
+
"type": "module",
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24.11"
|
|
38
|
+
},
|
|
39
|
+
"exports": {
|
|
40
|
+
"./workers": "./dist/workers.js",
|
|
41
|
+
"./node": "./dist/node.js"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public",
|
|
45
|
+
"provenance": true
|
|
46
|
+
},
|
|
47
|
+
"dependencies": {
|
|
48
|
+
"@hono/node-server": "2.1.8",
|
|
49
|
+
"@tide-ota/protocol": "0.1.0",
|
|
50
|
+
"hono": "^4.13.18"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@cloudflare/vitest-plugin": "1.8.3",
|
|
54
|
+
"@types/node": "^26.6.6",
|
|
55
|
+
"typescript": "7.0.2",
|
|
56
|
+
"vitest": "^5.1.0",
|
|
57
|
+
"wrangler": "^4.163.0",
|
|
58
|
+
"yaml": "2.9.1"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "rm -rf dist && tsc -p tsconfig.build.workers.json && tsc -p tsconfig.build.node.json",
|
|
62
|
+
"wrangler": "WRANGLER_SEND_METRICS=false WRANGLER_SEND_ERROR_REPORTS=false wrangler",
|
|
63
|
+
"dev:workers": "pnpm run wrangler dev",
|
|
64
|
+
"dev:node": "node src/node.ts",
|
|
65
|
+
"types": "pnpm run wrangler types --strict-vars=false",
|
|
66
|
+
"typecheck": "pnpm run types --check && tsc --noEmit -p tsconfig.node.json && tsc --noEmit -p tsconfig.workers.json",
|
|
67
|
+
"test": "vitest run"
|
|
68
|
+
}
|
|
69
|
+
}
|