@phron/image 0.1.0 → 0.2.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 +231 -0
- package/native.cjs +56 -56
- package/package.json +5 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Phron
|
|
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
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
1
|
+
# @phron/image
|
|
2
|
+
|
|
3
|
+
Build and sign [Phron Image](https://phron.net) URLs from TypeScript and JavaScript.
|
|
4
|
+
|
|
5
|
+
- One Rust implementation of the URL format, bound through napi-rs. On Linux x64 (glibc),
|
|
6
|
+
Node.js (22.18+) loads a prebuilt native binary. Everywhere else (macOS, arm64, Alpine, Windows)
|
|
7
|
+
it loads the same Rust code compiled to WebAssembly, with the same API and results. No
|
|
8
|
+
install-time compile.
|
|
9
|
+
- Edge runtimes use the WebAssembly build (see below). After each release, CI installs the
|
|
10
|
+
package from npm and runs the shared test vectors in workerd (Cloudflare Workers), in Deno, and
|
|
11
|
+
in Vercel's Edge Runtime emulator. It has not yet run on a Deno Deploy or Vercel deployment.
|
|
12
|
+
`@phron/image/next` builds public URLs in plain TypeScript and runs in the browser.
|
|
13
|
+
- Signed URLs, unsigned public URLs, API URLs, `srcset`, and a Next.js loader for public sources.
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
npm install @phron/image
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Security: keys and salts stay on the server
|
|
20
|
+
|
|
21
|
+
A signing key and salt can mint a valid URL for any image in the source. Keep them in server-side
|
|
22
|
+
code and server-side environment variables. **Never ship them to a browser**: not in a client
|
|
23
|
+
component, not in a `NEXT_PUBLIC_*` variable, not in a bundle. The same goes for API keys.
|
|
24
|
+
|
|
25
|
+
## Signed URLs
|
|
26
|
+
|
|
27
|
+
For a source whose access is "API key and signed URLs". Key and salt are the hex strings shown
|
|
28
|
+
once in the [console](https://console.phron.net).
|
|
29
|
+
|
|
30
|
+
```ts
|
|
31
|
+
import { options, roundedExpiry, signUrl } from "@phron/image";
|
|
32
|
+
|
|
33
|
+
const url = signUrl({
|
|
34
|
+
label: "my-source", // https://my-source.phronusercontent.com
|
|
35
|
+
key: process.env.PHRON_IMAGE_KEY!,
|
|
36
|
+
salt: process.env.PHRON_IMAGE_SALT!,
|
|
37
|
+
options: [options.resize("fit", 800, 800), options.quality(80)],
|
|
38
|
+
path: "photos/my cat.jpg", // not yet encoded; the SDK percent-encodes it before signing
|
|
39
|
+
format: "webp", // optional, written as @webp
|
|
40
|
+
expiresAt: roundedExpiry(24 * 3600), // optional
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The signature is the base64url (no padding) HMAC-SHA256, keyed with the hex-decoded key, over the
|
|
45
|
+
hex-decoded salt followed by the path exactly as sent. The SDK encodes the path first and signs
|
|
46
|
+
the encoded string.
|
|
47
|
+
|
|
48
|
+
Use `baseUrl` instead of `label` for a custom domain: `baseUrl: "https://img.example.com"`.
|
|
49
|
+
|
|
50
|
+
### Expiry and caching
|
|
51
|
+
|
|
52
|
+
`expiresAt` adds an `exp:<unix seconds>` option, which is part of the signed path. A browser keeps
|
|
53
|
+
a result for up to a day (or until `exp`, if that comes sooner). If every render computes `exp`
|
|
54
|
+
as "now plus an hour", the URL changes every second and the browser can never reuse a cached
|
|
55
|
+
result. `roundedExpiry(ttlSeconds, bucketSeconds = 3600)` rounds the expiry **up** to a bucket
|
|
56
|
+
boundary, so the URL is identical for every render in the same bucket.
|
|
57
|
+
|
|
58
|
+
## Public URLs
|
|
59
|
+
|
|
60
|
+
For a source whose access is "public". No secret, and only a preset and one optional width from
|
|
61
|
+
the source's list of public widths are accepted:
|
|
62
|
+
|
|
63
|
+
```ts
|
|
64
|
+
import { publicUrl } from "@phron/image";
|
|
65
|
+
|
|
66
|
+
publicUrl({
|
|
67
|
+
label: "my-source",
|
|
68
|
+
preset: "card",
|
|
69
|
+
width: 640,
|
|
70
|
+
path: "photos/cat.jpg",
|
|
71
|
+
format: "webp",
|
|
72
|
+
});
|
|
73
|
+
// https://my-source.phronusercontent.com/_/pr:card/w:640/plain/photos/cat.jpg@webp
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## API URLs
|
|
77
|
+
|
|
78
|
+
The API takes the same options, unsigned, with your API key as a bearer token. The SDK returns
|
|
79
|
+
the URL; you add the header and make the request (server-side).
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
import { apiUrl, infoUrl, options } from "@phron/image";
|
|
83
|
+
|
|
84
|
+
const url = apiUrl({ label: "my-source", options: [options.width(800)], path: "photos/cat.jpg" });
|
|
85
|
+
const res = await fetch(url, { headers: { Authorization: `Bearer ${process.env.PHRON_API_KEY}` } });
|
|
86
|
+
|
|
87
|
+
const info = infoUrl({ label: "my-source", options: ["size:1"], path: "photos/cat.jpg" });
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Options
|
|
91
|
+
|
|
92
|
+
`options.resize`, `width`, `height`, `quality`, `format`, `gravity`, `preset` and `expires`
|
|
93
|
+
cover the common cases. Anything else goes in as a raw string: `options.raw("blur:3")` or just
|
|
94
|
+
`"blur:3"` in the array.
|
|
95
|
+
|
|
96
|
+
## srcset
|
|
97
|
+
|
|
98
|
+
```ts
|
|
99
|
+
import { options, signUrl, srcset } from "@phron/image";
|
|
100
|
+
|
|
101
|
+
const widths = [320, 640, 960, 1280];
|
|
102
|
+
const value = srcset(
|
|
103
|
+
(w) => signUrl({ label: "my-source", key, salt, options: [options.width(w)], path, expiresAt }),
|
|
104
|
+
widths,
|
|
105
|
+
);
|
|
106
|
+
// "https://… 320w, https://… 640w, …"
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Next.js
|
|
110
|
+
|
|
111
|
+
### Public sources: `publicLoader`
|
|
112
|
+
|
|
113
|
+
A custom loader runs in the browser, so it can only build URLs that need no secret. For a public
|
|
114
|
+
source:
|
|
115
|
+
|
|
116
|
+
```js
|
|
117
|
+
// next.config.js
|
|
118
|
+
module.exports = {
|
|
119
|
+
images: {
|
|
120
|
+
loader: "custom",
|
|
121
|
+
loaderFile: "./phron-loader.ts",
|
|
122
|
+
// Use the source's list of public widths.
|
|
123
|
+
deviceSizes: [320, 640, 960, 1280],
|
|
124
|
+
imageSizes: [64, 128],
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
```ts
|
|
130
|
+
// phron-loader.ts
|
|
131
|
+
"use client";
|
|
132
|
+
import { publicLoader } from "@phron/image/next";
|
|
133
|
+
|
|
134
|
+
export default publicLoader({ label: "my-source", preset: "card", format: "webp" });
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
`quality` is ignored: a preset fixes the quality.
|
|
138
|
+
|
|
139
|
+
### Signed sources: sign on the server
|
|
140
|
+
|
|
141
|
+
A client-side loader can never hold the signing key, so it cannot produce signed URLs. For a
|
|
142
|
+
signed source, build the URLs in a Server Component and pass the result down:
|
|
143
|
+
|
|
144
|
+
```tsx
|
|
145
|
+
// app/page.tsx (Server Component)
|
|
146
|
+
import { options, roundedExpiry, signUrl, srcset } from "@phron/image";
|
|
147
|
+
|
|
148
|
+
export default function Page() {
|
|
149
|
+
const expiresAt = roundedExpiry(24 * 3600);
|
|
150
|
+
const sign = (width: number) =>
|
|
151
|
+
signUrl({
|
|
152
|
+
label: "my-source",
|
|
153
|
+
key: process.env.PHRON_IMAGE_KEY!,
|
|
154
|
+
salt: process.env.PHRON_IMAGE_SALT!,
|
|
155
|
+
options: [options.width(width)],
|
|
156
|
+
path: "photos/cat.jpg",
|
|
157
|
+
format: "webp",
|
|
158
|
+
expiresAt,
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
return (
|
|
162
|
+
// biome-ignore lint/performance/noImgElement: pre-signed srcset
|
|
163
|
+
<img
|
|
164
|
+
src={sign(640)}
|
|
165
|
+
srcSet={srcset(sign, [320, 640, 960, 1280])}
|
|
166
|
+
sizes="(min-width: 960px) 960px, 100vw"
|
|
167
|
+
alt=""
|
|
168
|
+
/>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Cloudflare Workers
|
|
174
|
+
|
|
175
|
+
Workers cannot load a native binary, so they use the WebAssembly build. Import the module and
|
|
176
|
+
instantiate it once; the functions are the same Rust core (`signUrl`, `publicUrl`, `apiUrl`,
|
|
177
|
+
`infoUrl`, and `optionWidth`, `optionQuality` and so on for the option helpers):
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
import wasm from "@phron/image/wasm";
|
|
181
|
+
import { instantiate } from "@phron/image/workerd";
|
|
182
|
+
|
|
183
|
+
export default {
|
|
184
|
+
async fetch(_req: Request, env: { PHRON_KEY: string; PHRON_SALT: string }) {
|
|
185
|
+
const image = await instantiate(wasm); // resolves to the same instance after the first call
|
|
186
|
+
const url = image.signUrl({
|
|
187
|
+
key: env.PHRON_KEY,
|
|
188
|
+
salt: env.PHRON_SALT,
|
|
189
|
+
baseUrl: "https://acme.phronusercontent.com",
|
|
190
|
+
options: ["w:640"],
|
|
191
|
+
path: "photos/cat.jpg",
|
|
192
|
+
});
|
|
193
|
+
return Response.json({ url });
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Deno and Vercel Edge
|
|
199
|
+
|
|
200
|
+
The same two imports work, with the WebAssembly module loaded the way each runtime expects:
|
|
201
|
+
|
|
202
|
+
```ts
|
|
203
|
+
// Deno, with "nodeModulesDir": "auto" in deno.json and an import map entry
|
|
204
|
+
// "@phron/image/": "npm:/@phron/image@<version>/". Deno may compile WebAssembly from bytes, so
|
|
205
|
+
// read the module from node_modules (run with --allow-read).
|
|
206
|
+
import { instantiate } from "@phron/image/workerd";
|
|
207
|
+
|
|
208
|
+
const wasm = await WebAssembly.compile(
|
|
209
|
+
await Deno.readFile(new URL(import.meta.resolve("@phron/image/wasm.wasm"))),
|
|
210
|
+
);
|
|
211
|
+
const image = await instantiate(wasm);
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
```ts
|
|
215
|
+
// Vercel Edge: Vercel compiles a `?module` import of a .wasm file to a WebAssembly.Module.
|
|
216
|
+
import wasm from "@phron/image/wasm.wasm?module";
|
|
217
|
+
import { instantiate } from "@phron/image/workerd";
|
|
218
|
+
|
|
219
|
+
const image = await instantiate(wasm);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Other languages
|
|
223
|
+
|
|
224
|
+
This repository holds every Phron Image SDK. The URL format is implemented once, in the Rust
|
|
225
|
+
crate [`crates/phron-image`](crates/phron-image); each language package binds it, and
|
|
226
|
+
[`conformance/vectors.json`](conformance/vectors.json) pins the output every language must
|
|
227
|
+
reproduce. See [docs/adr/0001-rust-core-multi-language.md](docs/adr/0001-rust-core-multi-language.md).
|
|
228
|
+
|
|
229
|
+
## License
|
|
230
|
+
|
|
231
|
+
MIT
|
package/native.cjs
CHANGED
|
@@ -94,8 +94,8 @@ function requireNative() {
|
|
|
94
94
|
try {
|
|
95
95
|
const binding = require('@phron/image-android-arm64')
|
|
96
96
|
const bindingPackageVersion = require('@phron/image-android-arm64/package.json').version
|
|
97
|
-
if (bindingPackageVersion !== '0.
|
|
98
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
97
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
98
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
99
99
|
}
|
|
100
100
|
return binding
|
|
101
101
|
} catch (e) {
|
|
@@ -110,8 +110,8 @@ function requireNative() {
|
|
|
110
110
|
try {
|
|
111
111
|
const binding = require('@phron/image-android-arm-eabi')
|
|
112
112
|
const bindingPackageVersion = require('@phron/image-android-arm-eabi/package.json').version
|
|
113
|
-
if (bindingPackageVersion !== '0.
|
|
114
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
113
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
114
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
115
115
|
}
|
|
116
116
|
return binding
|
|
117
117
|
} catch (e) {
|
|
@@ -131,8 +131,8 @@ function requireNative() {
|
|
|
131
131
|
try {
|
|
132
132
|
const binding = require('@phron/image-win32-x64-gnu')
|
|
133
133
|
const bindingPackageVersion = require('@phron/image-win32-x64-gnu/package.json').version
|
|
134
|
-
if (bindingPackageVersion !== '0.
|
|
135
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
134
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
135
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
136
136
|
}
|
|
137
137
|
return binding
|
|
138
138
|
} catch (e) {
|
|
@@ -147,8 +147,8 @@ function requireNative() {
|
|
|
147
147
|
try {
|
|
148
148
|
const binding = require('@phron/image-win32-x64-msvc')
|
|
149
149
|
const bindingPackageVersion = require('@phron/image-win32-x64-msvc/package.json').version
|
|
150
|
-
if (bindingPackageVersion !== '0.
|
|
151
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
150
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
151
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
152
152
|
}
|
|
153
153
|
return binding
|
|
154
154
|
} catch (e) {
|
|
@@ -164,8 +164,8 @@ function requireNative() {
|
|
|
164
164
|
try {
|
|
165
165
|
const binding = require('@phron/image-win32-ia32-msvc')
|
|
166
166
|
const bindingPackageVersion = require('@phron/image-win32-ia32-msvc/package.json').version
|
|
167
|
-
if (bindingPackageVersion !== '0.
|
|
168
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
167
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
168
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
169
169
|
}
|
|
170
170
|
return binding
|
|
171
171
|
} catch (e) {
|
|
@@ -180,8 +180,8 @@ function requireNative() {
|
|
|
180
180
|
try {
|
|
181
181
|
const binding = require('@phron/image-win32-arm64-msvc')
|
|
182
182
|
const bindingPackageVersion = require('@phron/image-win32-arm64-msvc/package.json').version
|
|
183
|
-
if (bindingPackageVersion !== '0.
|
|
184
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
183
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
184
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
185
185
|
}
|
|
186
186
|
return binding
|
|
187
187
|
} catch (e) {
|
|
@@ -199,8 +199,8 @@ function requireNative() {
|
|
|
199
199
|
try {
|
|
200
200
|
const binding = require('@phron/image-darwin-universal')
|
|
201
201
|
const bindingPackageVersion = require('@phron/image-darwin-universal/package.json').version
|
|
202
|
-
if (bindingPackageVersion !== '0.
|
|
203
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
202
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
203
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
204
204
|
}
|
|
205
205
|
return binding
|
|
206
206
|
} catch (e) {
|
|
@@ -215,8 +215,8 @@ function requireNative() {
|
|
|
215
215
|
try {
|
|
216
216
|
const binding = require('@phron/image-darwin-x64')
|
|
217
217
|
const bindingPackageVersion = require('@phron/image-darwin-x64/package.json').version
|
|
218
|
-
if (bindingPackageVersion !== '0.
|
|
219
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
218
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
219
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
220
220
|
}
|
|
221
221
|
return binding
|
|
222
222
|
} catch (e) {
|
|
@@ -231,8 +231,8 @@ function requireNative() {
|
|
|
231
231
|
try {
|
|
232
232
|
const binding = require('@phron/image-darwin-arm64')
|
|
233
233
|
const bindingPackageVersion = require('@phron/image-darwin-arm64/package.json').version
|
|
234
|
-
if (bindingPackageVersion !== '0.
|
|
235
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
234
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
235
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
236
236
|
}
|
|
237
237
|
return binding
|
|
238
238
|
} catch (e) {
|
|
@@ -251,8 +251,8 @@ function requireNative() {
|
|
|
251
251
|
try {
|
|
252
252
|
const binding = require('@phron/image-freebsd-x64')
|
|
253
253
|
const bindingPackageVersion = require('@phron/image-freebsd-x64/package.json').version
|
|
254
|
-
if (bindingPackageVersion !== '0.
|
|
255
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
254
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
255
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
256
256
|
}
|
|
257
257
|
return binding
|
|
258
258
|
} catch (e) {
|
|
@@ -267,8 +267,8 @@ function requireNative() {
|
|
|
267
267
|
try {
|
|
268
268
|
const binding = require('@phron/image-freebsd-arm64')
|
|
269
269
|
const bindingPackageVersion = require('@phron/image-freebsd-arm64/package.json').version
|
|
270
|
-
if (bindingPackageVersion !== '0.
|
|
271
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
270
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
271
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
272
272
|
}
|
|
273
273
|
return binding
|
|
274
274
|
} catch (e) {
|
|
@@ -283,8 +283,8 @@ function requireNative() {
|
|
|
283
283
|
try {
|
|
284
284
|
const binding = require('@phron/image-freebsd-ppc64')
|
|
285
285
|
const bindingPackageVersion = require('@phron/image-freebsd-ppc64/package.json').version
|
|
286
|
-
if (bindingPackageVersion !== '0.
|
|
287
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
286
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
287
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
288
288
|
}
|
|
289
289
|
return binding
|
|
290
290
|
} catch (e) {
|
|
@@ -304,8 +304,8 @@ function requireNative() {
|
|
|
304
304
|
try {
|
|
305
305
|
const binding = require('@phron/image-linux-x64-musl')
|
|
306
306
|
const bindingPackageVersion = require('@phron/image-linux-x64-musl/package.json').version
|
|
307
|
-
if (bindingPackageVersion !== '0.
|
|
308
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
307
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
308
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
309
309
|
}
|
|
310
310
|
return binding
|
|
311
311
|
} catch (e) {
|
|
@@ -320,8 +320,8 @@ function requireNative() {
|
|
|
320
320
|
try {
|
|
321
321
|
const binding = require('@phron/image-linux-x64-gnu')
|
|
322
322
|
const bindingPackageVersion = require('@phron/image-linux-x64-gnu/package.json').version
|
|
323
|
-
if (bindingPackageVersion !== '0.
|
|
324
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
323
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
324
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
325
325
|
}
|
|
326
326
|
return binding
|
|
327
327
|
} catch (e) {
|
|
@@ -338,8 +338,8 @@ function requireNative() {
|
|
|
338
338
|
try {
|
|
339
339
|
const binding = require('@phron/image-linux-arm64-musl')
|
|
340
340
|
const bindingPackageVersion = require('@phron/image-linux-arm64-musl/package.json').version
|
|
341
|
-
if (bindingPackageVersion !== '0.
|
|
342
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
341
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
342
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
343
343
|
}
|
|
344
344
|
return binding
|
|
345
345
|
} catch (e) {
|
|
@@ -354,8 +354,8 @@ function requireNative() {
|
|
|
354
354
|
try {
|
|
355
355
|
const binding = require('@phron/image-linux-arm64-gnu')
|
|
356
356
|
const bindingPackageVersion = require('@phron/image-linux-arm64-gnu/package.json').version
|
|
357
|
-
if (bindingPackageVersion !== '0.
|
|
358
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
357
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
358
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
359
359
|
}
|
|
360
360
|
return binding
|
|
361
361
|
} catch (e) {
|
|
@@ -372,8 +372,8 @@ function requireNative() {
|
|
|
372
372
|
try {
|
|
373
373
|
const binding = require('@phron/image-linux-arm-musleabihf')
|
|
374
374
|
const bindingPackageVersion = require('@phron/image-linux-arm-musleabihf/package.json').version
|
|
375
|
-
if (bindingPackageVersion !== '0.
|
|
376
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
375
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
376
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
377
377
|
}
|
|
378
378
|
return binding
|
|
379
379
|
} catch (e) {
|
|
@@ -388,8 +388,8 @@ function requireNative() {
|
|
|
388
388
|
try {
|
|
389
389
|
const binding = require('@phron/image-linux-arm-gnueabihf')
|
|
390
390
|
const bindingPackageVersion = require('@phron/image-linux-arm-gnueabihf/package.json').version
|
|
391
|
-
if (bindingPackageVersion !== '0.
|
|
392
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
391
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
392
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
393
393
|
}
|
|
394
394
|
return binding
|
|
395
395
|
} catch (e) {
|
|
@@ -406,8 +406,8 @@ function requireNative() {
|
|
|
406
406
|
try {
|
|
407
407
|
const binding = require('@phron/image-linux-loong64-musl')
|
|
408
408
|
const bindingPackageVersion = require('@phron/image-linux-loong64-musl/package.json').version
|
|
409
|
-
if (bindingPackageVersion !== '0.
|
|
410
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
409
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
410
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
411
411
|
}
|
|
412
412
|
return binding
|
|
413
413
|
} catch (e) {
|
|
@@ -422,8 +422,8 @@ function requireNative() {
|
|
|
422
422
|
try {
|
|
423
423
|
const binding = require('@phron/image-linux-loong64-gnu')
|
|
424
424
|
const bindingPackageVersion = require('@phron/image-linux-loong64-gnu/package.json').version
|
|
425
|
-
if (bindingPackageVersion !== '0.
|
|
426
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
425
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
426
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
427
427
|
}
|
|
428
428
|
return binding
|
|
429
429
|
} catch (e) {
|
|
@@ -440,8 +440,8 @@ function requireNative() {
|
|
|
440
440
|
try {
|
|
441
441
|
const binding = require('@phron/image-linux-riscv64-musl')
|
|
442
442
|
const bindingPackageVersion = require('@phron/image-linux-riscv64-musl/package.json').version
|
|
443
|
-
if (bindingPackageVersion !== '0.
|
|
444
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
443
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
444
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
445
445
|
}
|
|
446
446
|
return binding
|
|
447
447
|
} catch (e) {
|
|
@@ -456,8 +456,8 @@ function requireNative() {
|
|
|
456
456
|
try {
|
|
457
457
|
const binding = require('@phron/image-linux-riscv64-gnu')
|
|
458
458
|
const bindingPackageVersion = require('@phron/image-linux-riscv64-gnu/package.json').version
|
|
459
|
-
if (bindingPackageVersion !== '0.
|
|
460
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
459
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
460
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
461
461
|
}
|
|
462
462
|
return binding
|
|
463
463
|
} catch (e) {
|
|
@@ -473,8 +473,8 @@ function requireNative() {
|
|
|
473
473
|
try {
|
|
474
474
|
const binding = require('@phron/image-linux-ppc64-gnu')
|
|
475
475
|
const bindingPackageVersion = require('@phron/image-linux-ppc64-gnu/package.json').version
|
|
476
|
-
if (bindingPackageVersion !== '0.
|
|
477
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
476
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
477
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
478
478
|
}
|
|
479
479
|
return binding
|
|
480
480
|
} catch (e) {
|
|
@@ -489,8 +489,8 @@ function requireNative() {
|
|
|
489
489
|
try {
|
|
490
490
|
const binding = require('@phron/image-linux-s390x-gnu')
|
|
491
491
|
const bindingPackageVersion = require('@phron/image-linux-s390x-gnu/package.json').version
|
|
492
|
-
if (bindingPackageVersion !== '0.
|
|
493
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
492
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
493
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
494
494
|
}
|
|
495
495
|
return binding
|
|
496
496
|
} catch (e) {
|
|
@@ -509,8 +509,8 @@ function requireNative() {
|
|
|
509
509
|
try {
|
|
510
510
|
const binding = require('@phron/image-openharmony-arm64')
|
|
511
511
|
const bindingPackageVersion = require('@phron/image-openharmony-arm64/package.json').version
|
|
512
|
-
if (bindingPackageVersion !== '0.
|
|
513
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
512
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
513
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
514
514
|
}
|
|
515
515
|
return binding
|
|
516
516
|
} catch (e) {
|
|
@@ -525,8 +525,8 @@ function requireNative() {
|
|
|
525
525
|
try {
|
|
526
526
|
const binding = require('@phron/image-openharmony-x64')
|
|
527
527
|
const bindingPackageVersion = require('@phron/image-openharmony-x64/package.json').version
|
|
528
|
-
if (bindingPackageVersion !== '0.
|
|
529
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
528
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
529
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
530
530
|
}
|
|
531
531
|
return binding
|
|
532
532
|
} catch (e) {
|
|
@@ -541,8 +541,8 @@ function requireNative() {
|
|
|
541
541
|
try {
|
|
542
542
|
const binding = require('@phron/image-openharmony-arm')
|
|
543
543
|
const bindingPackageVersion = require('@phron/image-openharmony-arm/package.json').version
|
|
544
|
-
if (bindingPackageVersion !== '0.
|
|
545
|
-
throw new Error(`Native binding package version mismatch, expected 0.
|
|
544
|
+
if (bindingPackageVersion !== '0.2.0' && process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
545
|
+
throw new Error(`Native binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
546
546
|
}
|
|
547
547
|
return binding
|
|
548
548
|
} catch (e) {
|
|
@@ -683,8 +683,8 @@ if (!nativeBinding || forceWasi) {
|
|
|
683
683
|
if (!candidateFailed) {
|
|
684
684
|
if (process.env.NAPI_RS_ENFORCE_VERSION_CHECK && process.env.NAPI_RS_ENFORCE_VERSION_CHECK !== '0') {
|
|
685
685
|
const bindingPackageVersion = require('@phron/image-wasm32-wasip1/package.json').version
|
|
686
|
-
if (bindingPackageVersion !== '0.
|
|
687
|
-
throw new Error(`WASI binding package version mismatch, expected 0.
|
|
686
|
+
if (bindingPackageVersion !== '0.2.0') {
|
|
687
|
+
throw new Error(`WASI binding package version mismatch, expected 0.2.0 but got ${bindingPackageVersion}. You can reinstall dependencies to fix this issue.`)
|
|
688
688
|
}
|
|
689
689
|
}
|
|
690
690
|
wasiBinding = require('@phron/image-wasm32-wasip1')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phron/image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Build and sign Phron Image URLs. A Rust core, bound through napi-rs: native on Linux x64, WebAssembly everywhere else.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"phron",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"phron-image.wasm32-wasip1.wasm.d.mts"
|
|
56
56
|
],
|
|
57
57
|
"engines": {
|
|
58
|
-
"node": ">=
|
|
58
|
+
"node": ">=22.18.0"
|
|
59
59
|
},
|
|
60
60
|
"napi": {
|
|
61
61
|
"binaryName": "phron-image",
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
78
78
|
"typecheck": "tsc --noEmit",
|
|
79
79
|
"test": "vitest run",
|
|
80
|
+
"prepack": "cp ../../README.md ../../LICENSE .",
|
|
80
81
|
"prepublishOnly": "napi prepublish -t npm --no-gh-release"
|
|
81
82
|
},
|
|
82
83
|
"devDependencies": {
|
|
@@ -92,7 +93,7 @@
|
|
|
92
93
|
"vitest": "^5.1.0"
|
|
93
94
|
},
|
|
94
95
|
"optionalDependencies": {
|
|
95
|
-
"@phron/image-linux-x64-gnu": "0.
|
|
96
|
-
"@phron/image-wasm32-wasip1": "0.
|
|
96
|
+
"@phron/image-linux-x64-gnu": "0.2.0",
|
|
97
|
+
"@phron/image-wasm32-wasip1": "0.2.0"
|
|
97
98
|
}
|
|
98
99
|
}
|