@assembly-js/app-foundation 0.3.7 → 0.3.9
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/CHANGELOG.md +6 -0
- package/bin/scan-app-deps.mjs +6 -2
- package/dist/scripts.d.ts +1 -1
- package/dist/scripts.js +5 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,12 @@ A patch release never changes what an app's build requires; a minor release may
|
|
|
19
19
|
not by hand; see `changes/README.md`. CI fails a PR that changes a check script without a
|
|
20
20
|
`bump: minor` change file.
|
|
21
21
|
|
|
22
|
+
## 0.3.9
|
|
23
|
+
- [fix] `getOfflineAssembly` from `@assembly-js/app-foundation/scripts` now refuses to run inside Next, so a route under `app/` can no longer use it to act with the installer's access. The entry shipped in 0.2.1 for standalone scripts only and nothing the build agent is taught imports it from a route, so no existing app's code needs to change.
|
|
24
|
+
|
|
25
|
+
## 0.3.8
|
|
26
|
+
- [behavior] An app that calls a provider's inferred route now lists that provider in `.assembly/app-deps.json`.
|
|
27
|
+
|
|
22
28
|
## 0.3.7
|
|
23
29
|
- [guidance] The `assembly-api-contract` skill now tells the build agent that every documented route must admit an app caller, so other apps' calls are not refused with a 403.
|
|
24
30
|
|
package/bin/scan-app-deps.mjs
CHANGED
|
@@ -28,6 +28,9 @@ const VIA_CLIENT = 'client';
|
|
|
28
28
|
// Lets a reader tell a file from a scanner that sees client calls from an older one that
|
|
29
29
|
// would omit them, since both look the same when an app has none.
|
|
30
30
|
const DETECTS = [VIA_PROXY_PATH, VIA_CLIENT];
|
|
31
|
+
const DETECTS_INFERRED_ROUTES = 'inferred-routes';
|
|
32
|
+
// `via` only ever names a detector that finds calls, so it stays on DETECTS.
|
|
33
|
+
const EMITTED_DETECTS = [...DETECTS, DETECTS_INFERRED_ROUTES];
|
|
31
34
|
const CLIENT_SPECIFIER = /(?:^|\/)generated\/apps\/([^/]+)\/client(?:\.[jt]s)?$/;
|
|
32
35
|
// The generated client's exports that make calls; its other exports (APP_ID, types) do not.
|
|
33
36
|
const CLIENT_EXPORTS = new Set(['installerClient', 'viewerClient']);
|
|
@@ -237,7 +240,8 @@ function opsFor(provider, { template, method }) {
|
|
|
237
240
|
const matched = (provider ?? []).filter((op) => templateMatches(op, template)).sort(bySpecificity(template));
|
|
238
241
|
if (matched.length === 0) return (method ? [method] : PROXY_METHODS).map((m) => `${m} ${template}`);
|
|
239
242
|
const winner = matched.filter((op) => op.template === matched[0].template);
|
|
240
|
-
|
|
243
|
+
// An inferred route accepts any method, so the template is the dependency whether or not the call states one.
|
|
244
|
+
if (winner.every((op) => op.method === INFERRED_METHOD)) return [`${INFERRED_METHOD} ${winner[0].template}`];
|
|
241
245
|
if (method) return [`${method} ${winner[0].template}`];
|
|
242
246
|
return winner.filter((op) => op.method !== INFERRED_METHOD).map((op) => `${op.method} ${op.template}`);
|
|
243
247
|
}
|
|
@@ -269,7 +273,7 @@ export function scanAppDeps(root, { loadTs = loadTypeScript } = {}) {
|
|
|
269
273
|
apps[appId] = { ops: [...ops.get(appId)].sort(byteCompare), via: DETECTS.filter((v) => via.get(appId).has(v)) };
|
|
270
274
|
}
|
|
271
275
|
const hashes = hashFiles(root, files, contents);
|
|
272
|
-
return { apps, detects:
|
|
276
|
+
return { apps, detects: EMITTED_DETECTS, files: Object.fromEntries(files.map((f) => [f, hashes.get(f)])) };
|
|
273
277
|
}
|
|
274
278
|
|
|
275
279
|
export const serializeAppDeps = (result) => JSON.stringify(result, null, 2) + '\n';
|
package/dist/scripts.d.ts
CHANGED
|
@@ -3,6 +3,6 @@ import { type AssemblyAPI } from '@assembly-js/node-sdk';
|
|
|
3
3
|
* The script-side counterpart of `getOfflineAssembly` from `/server`: mints a
|
|
4
4
|
* short-lived app-scoped bearer from `ASSEMBLY_API_KEY` and returns a bearer-only
|
|
5
5
|
* client. There is no request here, so the viewer-identity guard `/server` applies
|
|
6
|
-
* does not exist; use this only from scripts
|
|
6
|
+
* does not exist, so it refuses to run inside Next instead; use this only from scripts.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getOfflineAssembly(): Promise<AssemblyAPI>;
|
package/dist/scripts.js
CHANGED
|
@@ -4676,6 +4676,11 @@ async function mintBearerFromAppKey() {
|
|
|
4676
4676
|
|
|
4677
4677
|
// src/scripts.ts
|
|
4678
4678
|
async function getOfflineAssembly() {
|
|
4679
|
+
if (process.env.NEXT_RUNTIME) {
|
|
4680
|
+
throw new Error(
|
|
4681
|
+
"getOfflineAssembly from '/scripts' must not run inside Next: its app-scoped bearer acts as the installer. Use getAssembly() or getAssemblyForRequest() from '/server' in user-facing routes, or getOfflineAssembly() from '/server' for cron and webhook routes"
|
|
4682
|
+
);
|
|
4683
|
+
}
|
|
4679
4684
|
if (!process.env.ASSEMBLY_API_KEY) {
|
|
4680
4685
|
throw new Error(
|
|
4681
4686
|
"getOfflineAssembly: ASSEMBLY_API_KEY is not set \u2014 cannot mint an app-scoped bearer"
|