@telorun/kernel 0.46.0 → 0.48.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/dist/application-env.d.ts +26 -11
- package/dist/application-env.d.ts.map +1 -1
- package/dist/application-env.js +36 -12
- package/dist/application-env.js.map +1 -1
- package/dist/bundle/module-manifest.d.ts +6 -0
- package/dist/bundle/module-manifest.d.ts.map +1 -1
- package/dist/bundle/module-manifest.js +4 -0
- package/dist/bundle/module-manifest.js.map +1 -1
- package/dist/controller-loaders/npm-loader.d.ts +2 -16
- package/dist/controller-loaders/npm-loader.d.ts.map +1 -1
- package/dist/controller-loaders/npm-loader.js +42 -1
- package/dist/controller-loaders/npm-loader.js.map +1 -1
- package/dist/controller-registry.d.ts +6 -6
- package/dist/controller-registry.d.ts.map +1 -1
- package/dist/controller-registry.js +14 -10
- package/dist/controller-registry.js.map +1 -1
- package/dist/controllers/module/import-controller.d.ts +0 -46
- package/dist/controllers/module/import-controller.d.ts.map +1 -1
- package/dist/controllers/module/import-controller.js +10 -30
- package/dist/controllers/module/import-controller.js.map +1 -1
- package/dist/controllers/resource-definition/abstract-controller.d.ts +0 -4
- package/dist/controllers/resource-definition/abstract-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/abstract-controller.js +0 -4
- package/dist/controllers/resource-definition/abstract-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts +0 -4
- package/dist/controllers/resource-definition/resource-definition-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-definition-controller.js +0 -4
- package/dist/controllers/resource-definition/resource-definition-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-inherited-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-inherited-controller.js +0 -1
- package/dist/controllers/resource-definition/resource-inherited-controller.js.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.d.ts.map +1 -1
- package/dist/controllers/resource-definition/resource-template-controller.js +0 -1
- package/dist/controllers/resource-definition/resource-template-controller.js.map +1 -1
- package/dist/kernel.d.ts.map +1 -1
- package/dist/kernel.js +19 -12
- package/dist/kernel.js.map +1 -1
- package/dist/module-context.d.ts +25 -4
- package/dist/module-context.d.ts.map +1 -1
- package/dist/module-context.js +28 -5
- package/dist/module-context.js.map +1 -1
- package/dist/resource-context.d.ts +3 -1
- package/dist/resource-context.d.ts.map +1 -1
- package/dist/resource-context.js +2 -0
- package/dist/resource-context.js.map +1 -1
- package/dist/transports/oci/oci-client.d.ts +5 -0
- package/dist/transports/oci/oci-client.d.ts.map +1 -1
- package/dist/transports/oci/oci-client.js.map +1 -1
- package/dist/transports/oci/oci-transport.d.ts +18 -0
- package/dist/transports/oci/oci-transport.d.ts.map +1 -1
- package/dist/transports/oci/oci-transport.js +41 -8
- package/dist/transports/oci/oci-transport.js.map +1 -1
- package/dist/transports/registry-transport.d.ts +7 -0
- package/dist/transports/registry-transport.d.ts.map +1 -1
- package/dist/transports/registry-transport.js +29 -10
- package/dist/transports/registry-transport.js.map +1 -1
- package/dist/transports/transport.d.ts +19 -0
- package/dist/transports/transport.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/application-env.ts +36 -11
- package/src/bundle/module-manifest.ts +10 -0
- package/src/controller-loaders/npm-loader.ts +47 -1
- package/src/controller-registry.ts +14 -10
- package/src/controllers/module/import-controller.ts +11 -30
- package/src/controllers/resource-definition/abstract-controller.ts +0 -4
- package/src/controllers/resource-definition/resource-definition-controller.ts +0 -4
- package/src/controllers/resource-definition/resource-inherited-controller.ts +0 -2
- package/src/controllers/resource-definition/resource-template-controller.ts +0 -2
- package/src/kernel.ts +21 -12
- package/src/module-context.ts +30 -6
- package/src/resource-context.ts +3 -1
- package/src/transports/oci/oci-client.ts +5 -0
- package/src/transports/oci/oci-transport.ts +46 -10
- package/src/transports/registry-transport.ts +32 -10
- package/src/transports/transport.ts +20 -0
|
@@ -168,20 +168,26 @@ export class RegistryTransport implements Transport {
|
|
|
168
168
|
return Array.isArray(body.versions) ? body.versions : [];
|
|
169
169
|
}
|
|
170
170
|
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
171
|
+
/** Mirrors the sources' fetch-URL derivation: a direct URL points at (or
|
|
172
|
+
* contains) the YAML file; a bare registry ref folds into the registry
|
|
173
|
+
* layout. `null` when this transport does not own the ref's shape. */
|
|
174
|
+
private manifestUrl(ref: string): string | null {
|
|
175
175
|
const { base } = splitIntegrity(ref);
|
|
176
|
-
let fetchUrl: string;
|
|
177
176
|
if (base.startsWith("http://") || base.startsWith("https://")) {
|
|
178
|
-
|
|
179
|
-
}
|
|
177
|
+
return base.includes(".yaml") ? base : `${base}/${DEFAULT_MANIFEST_FILENAME}`;
|
|
178
|
+
}
|
|
179
|
+
if (isRegistryRef(ref)) {
|
|
180
180
|
const { modulePath, version } = parseModuleRef(ref);
|
|
181
|
-
|
|
182
|
-
} else {
|
|
183
|
-
return null;
|
|
181
|
+
return `${this.registryUrl.replace(/\/+$/, "")}/${modulePath}/${version}/${DEFAULT_MANIFEST_FILENAME}`;
|
|
184
182
|
}
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
async digest(ref: string): Promise<string | null> {
|
|
187
|
+
// The digest is Telo's canonical hash over the `telo.yaml` bytes — the same
|
|
188
|
+
// value `manifestHash` returns, but absent-is-null rather than a throw.
|
|
189
|
+
const fetchUrl = this.manifestUrl(ref);
|
|
190
|
+
if (!fetchUrl) return null;
|
|
185
191
|
await assertPublicEgress(fetchUrl);
|
|
186
192
|
const res = await fetch(fetchUrl);
|
|
187
193
|
if (res.status === 404) return null;
|
|
@@ -192,6 +198,22 @@ export class RegistryTransport implements Transport {
|
|
|
192
198
|
return `sha256-${await sha256Base64Url(bytes)}`;
|
|
193
199
|
}
|
|
194
200
|
|
|
201
|
+
/** Hashes the **raw response bytes**, which is exactly what `verifiedFetch`
|
|
202
|
+
* checks an inline `#sha256-…` pin against on the read path. */
|
|
203
|
+
async manifestHash(ref: string): Promise<string> {
|
|
204
|
+
const fetchUrl = this.manifestUrl(ref);
|
|
205
|
+
if (!fetchUrl) {
|
|
206
|
+
throw new Error(`cannot hash non-remote import '${ref}'`);
|
|
207
|
+
}
|
|
208
|
+
await assertPublicEgress(fetchUrl);
|
|
209
|
+
const res = await fetch(fetchUrl);
|
|
210
|
+
if (!res.ok) {
|
|
211
|
+
throw new Error(`fetch ${fetchUrl}: ${res.status} ${res.statusText}`);
|
|
212
|
+
}
|
|
213
|
+
const bytes = new Uint8Array(await res.arrayBuffer());
|
|
214
|
+
return `sha256-${await sha256Base64Url(bytes)}`;
|
|
215
|
+
}
|
|
216
|
+
|
|
195
217
|
async fetchArtifact(ref: string): Promise<FetchedArtifact> {
|
|
196
218
|
// `read` verifies the manifest bytes against the inline `#sha256-...` hash.
|
|
197
219
|
const { text: manifest, source } = await this.source.read(ref);
|
|
@@ -99,6 +99,26 @@ export interface Transport {
|
|
|
99
99
|
* digest per version and re-checks it on every track. */
|
|
100
100
|
digest(ref: string): Promise<string | null>;
|
|
101
101
|
|
|
102
|
+
/** Telo's inline integrity hash (`sha256-<base64url>`) for the `telo.yaml`
|
|
103
|
+
* `ref` resolves to — the value written as a `#sha256-…` pin by `telo
|
|
104
|
+
* publish` and re-pinned by `telo upgrade`. Throws when the ref does not
|
|
105
|
+
* resolve; callers decide whether that is fatal (`--frozen`) or best-effort.
|
|
106
|
+
*
|
|
107
|
+
* This is on the interface, not computed by the caller, because *what gets
|
|
108
|
+
* hashed* is transport-specific and must match exactly what that transport's
|
|
109
|
+
* own `source.read()` verifies — otherwise a pin written at publish fails
|
|
110
|
+
* verification at import. HTTP/registry hash the raw response bytes;
|
|
111
|
+
* OCI hashes the UTF-8 encoding of the `telo.yaml` extracted from the tar
|
|
112
|
+
* layer. A caller cannot know which, so a caller-side scheme branch silently
|
|
113
|
+
* degrades the moment a transport is added — which is exactly how `oci://`
|
|
114
|
+
* refs came to be published unpinned.
|
|
115
|
+
*
|
|
116
|
+
* Distinct from `digest()`: that is an opaque transport-native content id for
|
|
117
|
+
* change detection, never written into a manifest or compared across
|
|
118
|
+
* transports. This is the portable, cross-transport hash Telo itself
|
|
119
|
+
* verifies. */
|
|
120
|
+
manifestHash(ref: string): Promise<string>;
|
|
121
|
+
|
|
102
122
|
/** Push `bundle` to `destination` (a base ref / repo whose scheme this
|
|
103
123
|
* transport owns), pinning the payload and writing the transport-native
|
|
104
124
|
* artifact shape. Throws on failure. Used by `telo publish`. */
|