@sasjs/api 0.44.0 → 0.44.1
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/build/browser.js +48 -5
- package/build/cjs/corpus/app.js +17 -0
- package/build/cjs/host/dispatch.js +32 -1
- package/build/cjs/routes/overlay.js +2 -3
- package/build/esm/corpus/app.d.ts +3 -5
- package/build/esm/corpus/app.d.ts.map +1 -1
- package/build/esm/corpus/app.js +17 -0
- package/build/esm/host/dispatch.d.ts.map +1 -1
- package/build/esm/host/dispatch.js +33 -2
- package/build/esm/routes/overlay.d.ts.map +1 -1
- package/build/esm/routes/overlay.js +2 -3
- package/package.json +5 -8
package/build/browser.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/* @sasjs/api 0.44.
|
|
1
|
+
/* @sasjs/api 0.44.1 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
|
|
2
2
|
"use strict";
|
|
3
3
|
var SASjsApi = (() => {
|
|
4
4
|
var __defProp = Object.defineProperty;
|
|
@@ -3584,9 +3584,8 @@ var SASjsApi = (() => {
|
|
|
3584
3584
|
// sasjs/cli#1550, not this package's.
|
|
3585
3585
|
"GET /SASjsApi/app/{id}": {
|
|
3586
3586
|
implemented: true,
|
|
3587
|
-
//
|
|
3588
|
-
|
|
3589
|
-
hostResponses: [401, 500],
|
|
3587
|
+
// a drive read that broke is the host's to answer
|
|
3588
|
+
hostResponses: [500],
|
|
3590
3589
|
// the shape a client reads: the entry as registered, the file it is served from,
|
|
3591
3590
|
// and whether that file is there
|
|
3592
3591
|
responses: {
|
|
@@ -6805,7 +6804,8 @@ var SASjsApi = (() => {
|
|
|
6805
6804
|
const runtimeScoped = RUN_ROUTES.includes(routeId);
|
|
6806
6805
|
const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
|
|
6807
6806
|
const grantScoped = grantPath(route.path);
|
|
6808
|
-
|
|
6807
|
+
const appDetailScoped = routeId === "GET /SASjsApi/app/{id}";
|
|
6808
|
+
if ((grantScoped || appDetailScoped) && (identity || request.subject || request.token) && !records)
|
|
6809
6809
|
throw new ApiError(
|
|
6810
6810
|
501,
|
|
6811
6811
|
`This host has no record service, so it cannot answer ${routeId}.`
|
|
@@ -6824,6 +6824,16 @@ var SASjsApi = (() => {
|
|
|
6824
6824
|
}
|
|
6825
6825
|
return subject;
|
|
6826
6826
|
};
|
|
6827
|
+
if (appDetailScoped && (identity || records || request.subject || request.token) && !await caller()) {
|
|
6828
|
+
if (!identity)
|
|
6829
|
+
throw new ApiError(
|
|
6830
|
+
501,
|
|
6831
|
+
`This host has no identity service, so it cannot answer ${routeId}.`
|
|
6832
|
+
);
|
|
6833
|
+
throw new ApiError(401, "Unauthorized");
|
|
6834
|
+
}
|
|
6835
|
+
if (appDetailScoped && records && !await records.mayAct(await caller()))
|
|
6836
|
+
throw new ApiError(401, "Unauthorized");
|
|
6827
6837
|
if (identityScoped && records || runtimeScoped && services.runtime || adminScoped || grantScoped && records) {
|
|
6828
6838
|
const callerSubject = await caller();
|
|
6829
6839
|
let publicGrant = false;
|
|
@@ -7158,6 +7168,22 @@ var SASjsApi = (() => {
|
|
|
7158
7168
|
if (isApiError(err) && err.status === 404) throw appNotRegistered();
|
|
7159
7169
|
throw err;
|
|
7160
7170
|
});
|
|
7171
|
+
if (records) {
|
|
7172
|
+
const subject2 = await caller();
|
|
7173
|
+
if (!await records.mayAdminister(subject2)) {
|
|
7174
|
+
const rules = (await records.listPermissions(subject2)).filter(
|
|
7175
|
+
(rule) => rule.type === "Route"
|
|
7176
|
+
);
|
|
7177
|
+
const paths = [`/AppStream/${entry.id}`, `/AppStream/${entry.name}`];
|
|
7178
|
+
const decided = paths.find((path) => rules.some((rule) => rule.path === path)) ?? paths[0];
|
|
7179
|
+
const routeRules = {
|
|
7180
|
+
user: rules.filter((rule) => rule.user === subject2.userId),
|
|
7181
|
+
group: rules.filter((rule) => rule.group !== void 0)
|
|
7182
|
+
};
|
|
7183
|
+
if (!isRouteGranted(routeRules, decided, "/AppStream"))
|
|
7184
|
+
throw appNotRegistered();
|
|
7185
|
+
}
|
|
7186
|
+
}
|
|
7161
7187
|
const folder = appRootOf(entry);
|
|
7162
7188
|
let entryFileExists = false;
|
|
7163
7189
|
let lastModified = null;
|
|
@@ -11222,6 +11248,13 @@ var SASjsApi = (() => {
|
|
|
11222
11248
|
var FRONTEND_ENTRY_FILE = `/apps/${FRONTEND_APP.name}/index.html`;
|
|
11223
11249
|
var ENTRY_FILE_PATH = `${CORPUS_APP.appLoc}/services/${CORPUS_APP.streamWebFolder}/index.html`;
|
|
11224
11250
|
var APP_CORPUS = [
|
|
11251
|
+
{
|
|
11252
|
+
id: "app-detail-anonymous",
|
|
11253
|
+
route: "GET /SASjsApi/app/{id}",
|
|
11254
|
+
description: "refuses an anonymous caller before looking up an app",
|
|
11255
|
+
request: { params: { id: CORPUS_APP.id } },
|
|
11256
|
+
expect: { status: 401, error: "Unauthorized" }
|
|
11257
|
+
},
|
|
11225
11258
|
{
|
|
11226
11259
|
id: "app-detail-published",
|
|
11227
11260
|
route: "GET /SASjsApi/app/{id}",
|
|
@@ -11280,6 +11313,16 @@ var SASjsApi = (() => {
|
|
|
11280
11313
|
partial: { entryFileExists: false, lastModified: null }
|
|
11281
11314
|
}
|
|
11282
11315
|
},
|
|
11316
|
+
{
|
|
11317
|
+
id: "app-detail-denied",
|
|
11318
|
+
route: "GET /SASjsApi/app/{id}",
|
|
11319
|
+
description: "conceals a registered app from a caller without a stream grant",
|
|
11320
|
+
request: {
|
|
11321
|
+
subject: { userId: "user-restricted", clientId: "web_app" },
|
|
11322
|
+
params: { id: CORPUS_APP.id }
|
|
11323
|
+
},
|
|
11324
|
+
expect: { status: 404, error: "No App Stream is registered with that id." }
|
|
11325
|
+
},
|
|
11283
11326
|
{
|
|
11284
11327
|
id: "app-detail-unknown-id",
|
|
11285
11328
|
route: "GET /SASjsApi/app/{id}",
|
package/build/cjs/corpus/app.js
CHANGED
|
@@ -21,6 +21,13 @@ const FRONTEND_ENTRY_FILE = `/apps/${FRONTEND_APP.name}/index.html`;
|
|
|
21
21
|
/** Where the app's streamed entry file sits inside its folder. */
|
|
22
22
|
const ENTRY_FILE_PATH = `${runner_js_1.CORPUS_APP.appLoc}/services/${runner_js_1.CORPUS_APP.streamWebFolder}/index.html`;
|
|
23
23
|
exports.APP_CORPUS = [
|
|
24
|
+
{
|
|
25
|
+
id: 'app-detail-anonymous',
|
|
26
|
+
route: 'GET /SASjsApi/app/{id}',
|
|
27
|
+
description: 'refuses an anonymous caller before looking up an app',
|
|
28
|
+
request: { params: { id: runner_js_1.CORPUS_APP.id } },
|
|
29
|
+
expect: { status: 401, error: 'Unauthorized' }
|
|
30
|
+
},
|
|
24
31
|
{
|
|
25
32
|
id: 'app-detail-published',
|
|
26
33
|
route: 'GET /SASjsApi/app/{id}',
|
|
@@ -79,6 +86,16 @@ exports.APP_CORPUS = [
|
|
|
79
86
|
partial: { entryFileExists: false, lastModified: null }
|
|
80
87
|
}
|
|
81
88
|
},
|
|
89
|
+
{
|
|
90
|
+
id: 'app-detail-denied',
|
|
91
|
+
route: 'GET /SASjsApi/app/{id}',
|
|
92
|
+
description: 'conceals a registered app from a caller without a stream grant',
|
|
93
|
+
request: {
|
|
94
|
+
subject: { userId: 'user-restricted', clientId: 'web_app' },
|
|
95
|
+
params: { id: runner_js_1.CORPUS_APP.id }
|
|
96
|
+
},
|
|
97
|
+
expect: { status: 404, error: 'No App Stream is registered with that id.' }
|
|
98
|
+
},
|
|
82
99
|
{
|
|
83
100
|
id: 'app-detail-unknown-id',
|
|
84
101
|
route: 'GET /SASjsApi/app/{id}',
|
|
@@ -150,10 +150,13 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
150
150
|
// request meets is the one `myAuthorizedRoutes` reported for the same caller.
|
|
151
151
|
const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
|
|
152
152
|
const grantScoped = grantPath(route.path);
|
|
153
|
+
const appDetailScoped = routeId === 'GET /SASjsApi/app/{id}';
|
|
153
154
|
// A host with identity is enforcing access and must not silently skip a
|
|
154
155
|
// permission gate when its record service is absent. A drive-only host has
|
|
155
156
|
// no identity model at all and retains its existing desktop-style behavior.
|
|
156
|
-
if (grantScoped
|
|
157
|
+
if ((grantScoped || appDetailScoped) &&
|
|
158
|
+
(identity || request.subject || request.token) &&
|
|
159
|
+
!records)
|
|
157
160
|
throw new types_js_1.ApiError(501, `This host has no record service, so it cannot answer ${routeId}.`);
|
|
158
161
|
// The administrator routes need the record service to answer the question the
|
|
159
162
|
// host's middleware answers on a server. A host that supplies the reports
|
|
@@ -179,6 +182,17 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
179
182
|
}
|
|
180
183
|
return subject;
|
|
181
184
|
};
|
|
185
|
+
// Detail uses authentication but is not an ordinary grantable API path:
|
|
186
|
+
// its own app-specific decision is made after lookup and conceals denials.
|
|
187
|
+
if (appDetailScoped &&
|
|
188
|
+
(identity || records || request.subject || request.token) &&
|
|
189
|
+
!(await caller())) {
|
|
190
|
+
if (!identity)
|
|
191
|
+
throw new types_js_1.ApiError(501, `This host has no identity service, so it cannot answer ${routeId}.`);
|
|
192
|
+
throw new types_js_1.ApiError(401, 'Unauthorized');
|
|
193
|
+
}
|
|
194
|
+
if (appDetailScoped && records && !(await records.mayAct(await caller())))
|
|
195
|
+
throw new types_js_1.ApiError(401, 'Unauthorized');
|
|
182
196
|
if ((identityScoped && records) ||
|
|
183
197
|
(runtimeScoped && services.runtime) ||
|
|
184
198
|
adminScoped ||
|
|
@@ -533,6 +547,23 @@ const dispatch = async (services, routeId, request = {}) => {
|
|
|
533
547
|
throw appNotRegistered();
|
|
534
548
|
throw err;
|
|
535
549
|
});
|
|
550
|
+
if (records) {
|
|
551
|
+
const subject = await caller();
|
|
552
|
+
if (!(await records.mayAdminister(subject))) {
|
|
553
|
+
// listPermissions exposes the caller's user/group rules of all types.
|
|
554
|
+
// Only routes select the id or name and decide /AppStream access.
|
|
555
|
+
const rules = (await records.listPermissions(subject)).filter((rule) => rule.type === 'Route');
|
|
556
|
+
const paths = [`/AppStream/${entry.id}`, `/AppStream/${entry.name}`];
|
|
557
|
+
const decided = paths.find((path) => rules.some((rule) => rule.path === path)) ??
|
|
558
|
+
paths[0];
|
|
559
|
+
const routeRules = {
|
|
560
|
+
user: rules.filter((rule) => rule.user === subject.userId),
|
|
561
|
+
group: rules.filter((rule) => rule.group !== undefined)
|
|
562
|
+
};
|
|
563
|
+
if (!(0, routeAccess_js_1.isRouteGranted)(routeRules, decided, '/AppStream'))
|
|
564
|
+
throw appNotRegistered();
|
|
565
|
+
}
|
|
566
|
+
}
|
|
536
567
|
// the entry's own folder, whichever shape it was published in: `streamWebFolder`
|
|
537
568
|
// is the field that separates them - an entry carrying it is served from
|
|
538
569
|
// `<appLoc>/services/<streamWebFolder>`, every other entry from `apps/<name>` -
|
|
@@ -272,9 +272,8 @@ exports.OVERLAY = {
|
|
|
272
272
|
// sasjs/cli#1550, not this package's.
|
|
273
273
|
'GET /SASjsApi/app/{id}': {
|
|
274
274
|
implemented: true,
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
hostResponses: [401, 500],
|
|
275
|
+
// a drive read that broke is the host's to answer
|
|
276
|
+
hostResponses: [500],
|
|
278
277
|
// the shape a client reads: the entry as registered, the file it is served from,
|
|
279
278
|
// and whether that file is there
|
|
280
279
|
responses: {
|
|
@@ -2,11 +2,9 @@
|
|
|
2
2
|
* The App Stream detail route's conformance corpus.
|
|
3
3
|
*
|
|
4
4
|
* `GET /SASjsApi/app/{id}` describes an app by its id: the entry as registered, the
|
|
5
|
-
* file it is served from, and whether that file is there.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* (the route is mounted behind its authenticator) and is marked as such in the
|
|
9
|
-
* overlay.
|
|
5
|
+
* file it is served from, and whether that file is there. The `200`, `401`, and
|
|
6
|
+
* `404` answers have cases here, which `spec/corpus-parity.spec.ts` enforces in
|
|
7
|
+
* both directions. The host also authenticates at the HTTP boundary.
|
|
10
8
|
*
|
|
11
9
|
* The cases name the same app the rest of the corpus starts from (`CORPUS_APP`), so
|
|
12
10
|
* a host running this corpus against a live server sees the same id the package
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/corpus/app.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/corpus/app.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAyB5C,eAAO,MAAM,UAAU,EAAE,UAAU,EA2FlC,CAAA"}
|
package/build/esm/corpus/app.js
CHANGED
|
@@ -18,6 +18,13 @@ const FRONTEND_ENTRY_FILE = `/apps/${FRONTEND_APP.name}/index.html`;
|
|
|
18
18
|
/** Where the app's streamed entry file sits inside its folder. */
|
|
19
19
|
const ENTRY_FILE_PATH = `${CORPUS_APP.appLoc}/services/${CORPUS_APP.streamWebFolder}/index.html`;
|
|
20
20
|
export const APP_CORPUS = [
|
|
21
|
+
{
|
|
22
|
+
id: 'app-detail-anonymous',
|
|
23
|
+
route: 'GET /SASjsApi/app/{id}',
|
|
24
|
+
description: 'refuses an anonymous caller before looking up an app',
|
|
25
|
+
request: { params: { id: CORPUS_APP.id } },
|
|
26
|
+
expect: { status: 401, error: 'Unauthorized' }
|
|
27
|
+
},
|
|
21
28
|
{
|
|
22
29
|
id: 'app-detail-published',
|
|
23
30
|
route: 'GET /SASjsApi/app/{id}',
|
|
@@ -76,6 +83,16 @@ export const APP_CORPUS = [
|
|
|
76
83
|
partial: { entryFileExists: false, lastModified: null }
|
|
77
84
|
}
|
|
78
85
|
},
|
|
86
|
+
{
|
|
87
|
+
id: 'app-detail-denied',
|
|
88
|
+
route: 'GET /SASjsApi/app/{id}',
|
|
89
|
+
description: 'conceals a registered app from a caller without a stream grant',
|
|
90
|
+
request: {
|
|
91
|
+
subject: { userId: 'user-restricted', clientId: 'web_app' },
|
|
92
|
+
params: { id: CORPUS_APP.id }
|
|
93
|
+
},
|
|
94
|
+
expect: { status: 404, error: 'No App Stream is registered with that id.' }
|
|
95
|
+
},
|
|
79
96
|
{
|
|
80
97
|
id: 'app-detail-unknown-id',
|
|
81
98
|
route: 'GET /SASjsApi/app/{id}',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch.d.ts","sourceRoot":"","sources":["../../../src/host/dispatch.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AACvD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC3D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AASvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AACjE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"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AAE,gBAAgB,CAAA;IACvB;;;OAGG;IACH,OAAO,CAAC,EAAE,cAAc,CAAA;IACxB;;;;OAIG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B;;;;OAIG;IACH,cAAc,CAAC,EAAE,qBAAqB,CAAA;CACvC;AAmFD,eAAO,MAAM,QAAQ,GACnB,UAAU,QAAQ,EAClB,SAAS,MAAM,EACf,UAAS,UAAe,KACvB,OAAO,CAAC,WAAW,CA8+BrB,CAAA;AAED;;;;;;;;;;GAUG;AACH,eAAO,MAAM,SAAS,GAAI,SAAS,MAAM,KAAG,QAO3C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,EA+DlC,CAAA"}
|
|
@@ -3,7 +3,7 @@ import { assertOneFileName } from '../drive/deploymentFile.js';
|
|
|
3
3
|
import { appSummary, checkPublishRequest, frontendFolderOf } from '../appstream/service.js';
|
|
4
4
|
import { appRootOf } from '../appstream/web.js';
|
|
5
5
|
import { publishRequestFor, splitAppBundle } from '../appstream/bundle.js';
|
|
6
|
-
import { DEFAULT_GRANTABLE_ROUTES, TOP_LEVEL_ROUTES } from '../identity/routeAccess.js';
|
|
6
|
+
import { DEFAULT_GRANTABLE_ROUTES, TOP_LEVEL_ROUTES, isRouteGranted } from '../identity/routeAccess.js';
|
|
7
7
|
import { ApiError, isApiError } from '../types.js';
|
|
8
8
|
import { DEPLOY_SUCCESS } from '../drive/deploy.js';
|
|
9
9
|
/** The defaults sasjs/server's Client schema applies to an omitted lifetime. */
|
|
@@ -147,10 +147,13 @@ export const dispatch = async (services, routeId, request = {}) => {
|
|
|
147
147
|
// request meets is the one `myAuthorizedRoutes` reported for the same caller.
|
|
148
148
|
const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
|
|
149
149
|
const grantScoped = grantPath(route.path);
|
|
150
|
+
const appDetailScoped = routeId === 'GET /SASjsApi/app/{id}';
|
|
150
151
|
// A host with identity is enforcing access and must not silently skip a
|
|
151
152
|
// permission gate when its record service is absent. A drive-only host has
|
|
152
153
|
// no identity model at all and retains its existing desktop-style behavior.
|
|
153
|
-
if (grantScoped
|
|
154
|
+
if ((grantScoped || appDetailScoped) &&
|
|
155
|
+
(identity || request.subject || request.token) &&
|
|
156
|
+
!records)
|
|
154
157
|
throw new ApiError(501, `This host has no record service, so it cannot answer ${routeId}.`);
|
|
155
158
|
// The administrator routes need the record service to answer the question the
|
|
156
159
|
// host's middleware answers on a server. A host that supplies the reports
|
|
@@ -176,6 +179,17 @@ export const dispatch = async (services, routeId, request = {}) => {
|
|
|
176
179
|
}
|
|
177
180
|
return subject;
|
|
178
181
|
};
|
|
182
|
+
// Detail uses authentication but is not an ordinary grantable API path:
|
|
183
|
+
// its own app-specific decision is made after lookup and conceals denials.
|
|
184
|
+
if (appDetailScoped &&
|
|
185
|
+
(identity || records || request.subject || request.token) &&
|
|
186
|
+
!(await caller())) {
|
|
187
|
+
if (!identity)
|
|
188
|
+
throw new ApiError(501, `This host has no identity service, so it cannot answer ${routeId}.`);
|
|
189
|
+
throw new ApiError(401, 'Unauthorized');
|
|
190
|
+
}
|
|
191
|
+
if (appDetailScoped && records && !(await records.mayAct(await caller())))
|
|
192
|
+
throw new ApiError(401, 'Unauthorized');
|
|
179
193
|
if ((identityScoped && records) ||
|
|
180
194
|
(runtimeScoped && services.runtime) ||
|
|
181
195
|
adminScoped ||
|
|
@@ -530,6 +544,23 @@ export const dispatch = async (services, routeId, request = {}) => {
|
|
|
530
544
|
throw appNotRegistered();
|
|
531
545
|
throw err;
|
|
532
546
|
});
|
|
547
|
+
if (records) {
|
|
548
|
+
const subject = await caller();
|
|
549
|
+
if (!(await records.mayAdminister(subject))) {
|
|
550
|
+
// listPermissions exposes the caller's user/group rules of all types.
|
|
551
|
+
// Only routes select the id or name and decide /AppStream access.
|
|
552
|
+
const rules = (await records.listPermissions(subject)).filter((rule) => rule.type === 'Route');
|
|
553
|
+
const paths = [`/AppStream/${entry.id}`, `/AppStream/${entry.name}`];
|
|
554
|
+
const decided = paths.find((path) => rules.some((rule) => rule.path === path)) ??
|
|
555
|
+
paths[0];
|
|
556
|
+
const routeRules = {
|
|
557
|
+
user: rules.filter((rule) => rule.user === subject.userId),
|
|
558
|
+
group: rules.filter((rule) => rule.group !== undefined)
|
|
559
|
+
};
|
|
560
|
+
if (!isRouteGranted(routeRules, decided, '/AppStream'))
|
|
561
|
+
throw appNotRegistered();
|
|
562
|
+
}
|
|
563
|
+
}
|
|
533
564
|
// the entry's own folder, whichever shape it was published in: `streamWebFolder`
|
|
534
565
|
// is the field that separates them - an entry carrying it is served from
|
|
535
566
|
// `<appLoc>/services/<streamWebFolder>`, every other entry from `apps/<name>` -
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/routes/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGzD,yDAAyD;AACzD,UAAU,aAAa;IACrB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAA;IAC3B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,CAAC;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElE,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAgBzD,CAAA;AAmBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"overlay.d.ts","sourceRoot":"","sources":["../../../src/routes/overlay.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAGzD,yDAAyD;AACzD,UAAU,aAAa;IACrB,YAAY,CAAC,EAAE,UAAU,EAAE,CAAA;IAC3B;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CACpC;AAED;;;;;;GAMG;AACH,MAAM,MAAM,YAAY,GAAG,aAAa,GACtC,CAAC;IAAE,WAAW,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,WAAW,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAElE,kFAAkF;AAClF,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,UAAU,EAAE,CAgBzD,CAAA;AAmBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAwWhD,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,OAAO,EAAE,UAAU,EAA8C,CAAA"}
|
|
@@ -269,9 +269,8 @@ export const OVERLAY = {
|
|
|
269
269
|
// sasjs/cli#1550, not this package's.
|
|
270
270
|
'GET /SASjsApi/app/{id}': {
|
|
271
271
|
implemented: true,
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
hostResponses: [401, 500],
|
|
272
|
+
// a drive read that broke is the host's to answer
|
|
273
|
+
hostResponses: [500],
|
|
275
274
|
// the shape a client reads: the entry as registered, the file it is served from,
|
|
276
275
|
// and whether that file is there
|
|
277
276
|
responses: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sasjs/api",
|
|
3
|
-
"version": "0.44.
|
|
3
|
+
"version": "0.44.1",
|
|
4
4
|
"description": "The SASjs Server API, described once - a generated route table, the services behind it, and the conformance corpus both hosts run",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SASjs",
|
|
@@ -50,14 +50,12 @@
|
|
|
50
50
|
"check:builds": "node scripts/check-builds.mjs",
|
|
51
51
|
"audit:gate": "node scripts/audit.mjs",
|
|
52
52
|
"check:appstream": "node scripts/appstream-browser-check.cjs",
|
|
53
|
-
"conformance": "node tools/viya-conformance/conformance.mjs"
|
|
53
|
+
"conformance": "node tools/viya-conformance/conformance.mjs",
|
|
54
|
+
"release": "sasjs-release",
|
|
55
|
+
"prepublishOnly": "node -e \"const v=require('./package.json').version; if (/^0\\.0\\.0/.test(v)) { console.error('refusing to publish ' + v + ': the version is stamped from the tag by @sasjs/release --prepare-publish'); process.exit(1) }\""
|
|
54
56
|
},
|
|
55
57
|
"devDependencies": {
|
|
56
|
-
"@
|
|
57
|
-
"@semantic-release/exec": "7.1.0",
|
|
58
|
-
"@semantic-release/github": "12.0.10",
|
|
59
|
-
"@semantic-release/npm": "13.2.0",
|
|
60
|
-
"@semantic-release/release-notes-generator": "14.1.1",
|
|
58
|
+
"@sasjs/release": "0.11.1",
|
|
61
59
|
"@types/jest": "30.0.0",
|
|
62
60
|
"@types/node": "22.20.5",
|
|
63
61
|
"deepmerge": "file:./vendor/deepmerge",
|
|
@@ -65,7 +63,6 @@
|
|
|
65
63
|
"jest": "30.5.2",
|
|
66
64
|
"prettier": "3.9.10",
|
|
67
65
|
"rimraf": "6.1.4",
|
|
68
|
-
"semantic-release": "25.0.9",
|
|
69
66
|
"ts-jest": "29.4.15",
|
|
70
67
|
"typescript": "5.9.3",
|
|
71
68
|
"yaml": "2.9.1"
|