@sasjs/api 0.19.0 → 0.20.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 CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.19.0 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.20.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;
@@ -28,6 +28,7 @@ var SASjsApi = (() => {
28
28
  AUTH_CONFIG_CORPUS: () => AUTH_CONFIG_CORPUS,
29
29
  ApiError: () => ApiError,
30
30
  BROWSER_INFO: () => BROWSER_INFO,
31
+ BUNDLE_NAME: () => BUNDLE_NAME,
31
32
  CODE_CORPUS: () => CODE_CORPUS,
32
33
  CODE_DEBUG: () => CODE_DEBUG,
33
34
  DEFAULT_GRANTABLE_ROUTES: () => DEFAULT_GRANTABLE_ROUTES,
@@ -41,6 +42,7 @@ var SASjsApi = (() => {
41
42
  DOCUMENTED_RUN_TIMES: () => DOCUMENTED_RUN_TIMES,
42
43
  DRIVE_CORPUS: () => DRIVE_CORPUS,
43
44
  HANDLED_ROUTES: () => HANDLED_ROUTES,
45
+ HOME_CORPUS: () => HOME_CORPUS,
44
46
  IDENTITY_CORPUS: () => IDENTITY_CORPUS,
45
47
  IDENTITY_FORMAT: () => IDENTITY_FORMAT,
46
48
  INFO_CORPUS: () => INFO_CORPUS,
@@ -49,6 +51,7 @@ var SASjsApi = (() => {
49
51
  MemoryIdentityStore: () => MemoryIdentityStore,
50
52
  MemorySessionHost: () => MemorySessionHost,
51
53
  MemorySessionRunner: () => MemorySessionRunner,
54
+ NO_WEB_BUILD: () => NO_WEB_BUILD,
52
55
  OVERLAY: () => OVERLAY,
53
56
  PROVIDER_MANAGED: () => PROVIDER_MANAGED,
54
57
  RECORD_CORPUS: () => RECORD_CORPUS,
@@ -61,6 +64,7 @@ var SASjsApi = (() => {
61
64
  basename: () => basename,
62
65
  checkDeployTree: () => checkDeployTree,
63
66
  createDriveService: () => createDriveService,
67
+ createHomeService: () => createHomeService,
64
68
  createIdentityService: () => createIdentityService,
65
69
  createInfoService: () => createInfoService,
66
70
  createRecordService: () => createRecordService,
@@ -85,7 +89,8 @@ var SASjsApi = (() => {
85
89
  sanitiseDisplayName: () => sanitiseDisplayName,
86
90
  servicesFor: () => servicesFor,
87
91
  topLevelRouteFor: () => topLevelRouteFor,
88
- unpublishAppStream: () => unpublishAppStream
92
+ unpublishAppStream: () => unpublishAppStream,
93
+ withBundleVersion: () => withBundleVersion
89
94
  });
90
95
 
91
96
  // src/types.ts
@@ -2626,7 +2631,6 @@ var SASjsApi = (() => {
2626
2631
  Client: ["identity"],
2627
2632
  Web: ["identity"]
2628
2633
  };
2629
- var WEB_BUNDLE = "The host serves its own web bundle; there is no API decision here for this package to answer.";
2630
2634
  var success = { status: "success" };
2631
2635
  var user = {
2632
2636
  uid: "",
@@ -2636,8 +2640,19 @@ var SASjsApi = (() => {
2636
2640
  needsToUpdatePassword: false
2637
2641
  };
2638
2642
  var OVERLAY = {
2639
- // Web - the sign-in pages the identity service answers, and the bundle itself
2640
- "GET /": { implemented: false, reason: WEB_BUNDLE },
2643
+ // Web - the sign-in pages the identity service answers, and the shell itself.
2644
+ // The page is the host's file; the stamping rule that keeps a cached shell
2645
+ // from pinning an old bundle is the package's.
2646
+ "GET /": {
2647
+ implemented: true,
2648
+ // public: the shell is what an unauthenticated browser asks for first
2649
+ capabilities: []
2650
+ // No body annotation: this status carries two, and neither is a value a
2651
+ // client keys on. The usual answer is the host's own page, stamped with its
2652
+ // bundle token (its bytes are the host's, so the corpus pins the transform
2653
+ // rather than the page); the fallback is NO_WEB_BUILD, which is a constant
2654
+ // here rather than a literal copied into this table.
2655
+ },
2641
2656
  "POST /SASLogon/login": {
2642
2657
  implemented: true,
2643
2658
  // The lockout and the provider failure are answered before the package is
@@ -3175,6 +3190,17 @@ var SASjsApi = (() => {
3175
3190
  }
3176
3191
  }
3177
3192
  switch (routeId) {
3193
+ // The shell is a body, not JSON: an HTML page served with the content type
3194
+ // the document states, as it came from the host (stamped, if it references
3195
+ // a bundle).
3196
+ case "GET /": {
3197
+ if (!services.home)
3198
+ throw new ApiError(
3199
+ 501,
3200
+ `This host has no home service, so it cannot answer ${routeId}.`
3201
+ );
3202
+ return { status: 200, contents: await services.home.home() };
3203
+ }
3178
3204
  // The one answer a host states rather than derives: public, pre-auth, and
3179
3205
  // read by the login screen before anything else.
3180
3206
  case "GET /SASjsApi/info": {
@@ -3588,16 +3614,19 @@ var SASjsApi = (() => {
3588
3614
  newPassword: String(body.newPassword ?? "")
3589
3615
  });
3590
3616
  return { status: 204 };
3591
- default: {
3592
- const reason = routeById(routeId)?.reason;
3593
- throw new ApiError(
3594
- 501,
3595
- `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ""}`
3596
- );
3597
- }
3617
+ default:
3618
+ throw noHandler(routeId);
3598
3619
  }
3599
3620
  };
3621
+ var noHandler = (routeId) => {
3622
+ const reason = routeById(routeId)?.reason;
3623
+ return new ApiError(
3624
+ 501,
3625
+ `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ""}`
3626
+ );
3627
+ };
3600
3628
  var HANDLED_ROUTES = [
3629
+ "GET /",
3601
3630
  "GET /SASjsApi/info",
3602
3631
  "GET /SASjsApi/admin/diagnostics",
3603
3632
  "GET /SASjsApi/admin/logs",
@@ -4369,6 +4398,75 @@ var SASjsApi = (() => {
4369
4398
  }
4370
4399
  ];
4371
4400
 
4401
+ // src/corpus/home.ts
4402
+ var CORPUS_WEB_PAGE = {
4403
+ version: "4a26a3d1b2c3",
4404
+ html: [
4405
+ "<!doctype html>",
4406
+ "<html>",
4407
+ "<head>",
4408
+ ' <script src="./index.bundle.js"></script>',
4409
+ ' <script src="./vendor.js?v=keepme"></script>',
4410
+ ' <link rel="stylesheet" href="./index.bundle.css" />',
4411
+ // a name that merely begins with the bundle's: stamped by an `includes`
4412
+ // match, left alone here - see BUNDLE_REFERENCE
4413
+ ' <link rel="stylesheet" href="./index.bundle.js.css" />',
4414
+ "</head>",
4415
+ "<body>",
4416
+ " <p>The page loads index.bundle.js from the folder beside it.</p>",
4417
+ ' <div id="root"></div>',
4418
+ "</body>",
4419
+ "</html>"
4420
+ ].join("\n")
4421
+ };
4422
+ var CORPUS_WEB_BODY = CORPUS_WEB_PAGE.html.replace(
4423
+ './index.bundle.js"',
4424
+ `./index.bundle.js?v=${CORPUS_WEB_PAGE.version}"`
4425
+ );
4426
+ var HOME_CORPUS = [
4427
+ {
4428
+ id: "home-answers-the-stamped-shell",
4429
+ route: "GET /",
4430
+ description: "answers the shell with its bundle reference stamped, leaving prose and an already-versioned reference alone",
4431
+ request: {},
4432
+ expect: { status: 200, contents: CORPUS_WEB_BODY }
4433
+ }
4434
+ ];
4435
+
4436
+ // src/home/service.ts
4437
+ var BUNDLE_NAME = "index.bundle.js";
4438
+ var NO_WEB_BUILD = "<html><head></head><body>Web Build is not present</body></html>";
4439
+ var FILE_ATTRIBUTE = /(\s(?:src|href)=)("[^"]*"|'[^']*'|[^\s>]+)/g;
4440
+ var BUNDLE_REFERENCE = new RegExp(
4441
+ `(^|/)${BUNDLE_NAME.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")}$`
4442
+ );
4443
+ var withBundleVersion = (html, version) => html.replace(FILE_ATTRIBUTE, (match, attribute, value) => {
4444
+ const quote = value[0] === '"' || value[0] === "'" ? value[0] : "";
4445
+ const target = quote ? value.slice(1, -1) : value;
4446
+ if (!BUNDLE_REFERENCE.test(target) || target.includes("?")) return match;
4447
+ return `${attribute}${quote}${target}?v=${version}${quote}`;
4448
+ });
4449
+ var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
4450
+ var pageOf = (page) => {
4451
+ if (!page || typeof page !== "object")
4452
+ throw new Error("The web page is not an object.");
4453
+ if (!isNonEmptyString(page.html))
4454
+ throw new Error(
4455
+ "The web page states no html, so there is nothing to serve. Answer `undefined` from the port when the host has no build."
4456
+ );
4457
+ if (!isNonEmptyString(page.version) || !/^[A-Za-z0-9._-]+$/.test(page.version))
4458
+ throw new Error(
4459
+ `The web page states version as ${JSON.stringify(page.version)}; it is the bundle's cache token, so it may contain only letters, digits, ".", "_" and "-" - anything else, a quote above all, would end the attribute it is written into.`
4460
+ );
4461
+ return withBundleVersion(page.html, page.version);
4462
+ };
4463
+ var createHomeService = (page) => ({
4464
+ async home() {
4465
+ const found = await page();
4466
+ return found === void 0 ? NO_WEB_BUILD : pageOf(found);
4467
+ }
4468
+ });
4469
+
4372
4470
  // src/info/service.ts
4373
4471
  var BROWSER_INFO = {
4374
4472
  mode: "desktop",
@@ -4394,7 +4492,7 @@ var SASjsApi = (() => {
4394
4492
  var REQUIRED_FIELDS = FIELDS.filter((field) => field !== "oidcProviderName");
4395
4493
  var MODES = ["server", "desktop"];
4396
4494
  var CORS_VALUES = ["enable", "disable"];
4397
- var isNonEmptyString = (value) => typeof value === "string" && value.length > 0;
4495
+ var isNonEmptyString2 = (value) => typeof value === "string" && value.length > 0;
4398
4496
  var portOf = (value, name) => {
4399
4497
  if (value === null || value === void 0) return null;
4400
4498
  if (typeof value !== "number" || !Number.isInteger(value))
@@ -4413,7 +4511,7 @@ var SASjsApi = (() => {
4413
4511
  `The info configuration states ${name} as ${JSON.stringify(value)}; the document states an array of strings.`
4414
4512
  );
4415
4513
  for (const entry of value)
4416
- if (!isNonEmptyString(entry))
4514
+ if (!isNonEmptyString2(entry))
4417
4515
  throw new Error(
4418
4516
  `The info configuration states ${name} with an entry that is not a name: ${JSON.stringify(entry)}.`
4419
4517
  );
@@ -4443,14 +4541,14 @@ var SASjsApi = (() => {
4443
4541
  `The info configuration states cors as ${JSON.stringify(cors)}; the document states the CorsType enum - ${CORS_VALUES.map((value) => `\`${value}\``).join(" or ")}.`
4444
4542
  );
4445
4543
  const version = config.version;
4446
- if (!isNonEmptyString(version) || version.trim() === "")
4544
+ if (!isNonEmptyString2(version) || version.trim() === "")
4447
4545
  throw new Error(
4448
4546
  `The info configuration states version as ${JSON.stringify(version)}; the document states the release that produced the build, such as \`v3.2.2 (4a26a3d)\`.`
4449
4547
  );
4450
4548
  const authProviders = namesOf(config.authProviders, "authProviders");
4451
4549
  const runTimes = namesOf(config.runTimes, "runTimes");
4452
4550
  const rawName = config.oidcProviderName;
4453
- if (rawName !== void 0 && !isNonEmptyString(rawName))
4551
+ if (rawName !== void 0 && !isNonEmptyString2(rawName))
4454
4552
  throw new Error(
4455
4553
  `The info configuration states oidcProviderName as ${JSON.stringify(rawName)}; the document states the sign-on button's label, or omits it.`
4456
4554
  );
@@ -7926,13 +8024,13 @@ var SASjsApi = (() => {
7926
8024
  });
7927
8025
 
7928
8026
  // src/directory/service.ts
7929
- var isNonEmptyString2 = (value) => typeof value === "string" && value.length > 0;
8027
+ var isNonEmptyString3 = (value) => typeof value === "string" && value.length > 0;
7930
8028
  var usersOf = (users) => {
7931
8029
  if (!Array.isArray(users))
7932
8030
  throw new Error("The directory answer has no users array.");
7933
8031
  const seen = /* @__PURE__ */ new Set();
7934
8032
  for (const user3 of users) {
7935
- if (!isNonEmptyString2(user3?.username) || !isNonEmptyString2(user3?.displayName))
8033
+ if (!isNonEmptyString3(user3?.username) || !isNonEmptyString3(user3?.displayName))
7936
8034
  throw new Error(
7937
8035
  `The directory answer carries a user without a username or displayName: ${JSON.stringify(user3)}. Both are what the API keys an account on, so the import cannot guess them.`
7938
8036
  );
@@ -7949,7 +8047,7 @@ var SASjsApi = (() => {
7949
8047
  throw new Error("The directory answer has no groups array.");
7950
8048
  const seen = /* @__PURE__ */ new Set();
7951
8049
  for (const group of groups) {
7952
- if (!isNonEmptyString2(group?.name))
8050
+ if (!isNonEmptyString3(group?.name))
7953
8051
  throw new Error(
7954
8052
  `The directory answer carries a group without a name: ${JSON.stringify(group)}.`
7955
8053
  );
@@ -8035,6 +8133,7 @@ var SASjsApi = (() => {
8035
8133
  testCase.unwritable ? new RefusingDriveStore(testCase.seed || {}) : new MemoryDriveStore(testCase.seed || {})
8036
8134
  ),
8037
8135
  info: createInfoService(BROWSER_INFO),
8136
+ home: createHomeService(async () => CORPUS_WEB_PAGE),
8038
8137
  authConfig: createAuthConfigService(CORPUS_AUTH_CONFIG),
8039
8138
  admin: createAdminService({
8040
8139
  diagnostics: async () => CORPUS_DIAGNOSTICS,
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HOME_CORPUS = exports.CORPUS_WEB_BODY = exports.CORPUS_WEB_PAGE = void 0;
4
+ /**
5
+ * The shell the corpus host serves.
6
+ *
7
+ * A bundle reference the stamping rule must rewrite, a second reference that
8
+ * already carries a query string (left alone, which is what makes the transform
9
+ * idempotent), a stylesheet whose name merely begins with the bundle's (left
10
+ * alone, which is where this rule differs from sasjs/server's `includes`), and
11
+ * the bundle's name in prose (left as prose). The page a real host reads looks
12
+ * like this; the values are a fixture so a case can pin the exact bytes.
13
+ */
14
+ exports.CORPUS_WEB_PAGE = {
15
+ version: '4a26a3d1b2c3',
16
+ html: [
17
+ '<!doctype html>',
18
+ '<html>',
19
+ '<head>',
20
+ ' <script src="./index.bundle.js"></script>',
21
+ ' <script src="./vendor.js?v=keepme"></script>',
22
+ ' <link rel="stylesheet" href="./index.bundle.css" />',
23
+ // a name that merely begins with the bundle's: stamped by an `includes`
24
+ // match, left alone here - see BUNDLE_REFERENCE
25
+ ' <link rel="stylesheet" href="./index.bundle.js.css" />',
26
+ '</head>',
27
+ '<body>',
28
+ ' <p>The page loads index.bundle.js from the folder beside it.</p>',
29
+ ' <div id="root"></div>',
30
+ '</body>',
31
+ '</html>'
32
+ ].join('\n')
33
+ };
34
+ /**
35
+ * The body that page must answer with: the bundle reference stamped, the
36
+ * already-versioned one and the prose untouched.
37
+ */
38
+ exports.CORPUS_WEB_BODY = exports.CORPUS_WEB_PAGE.html.replace('./index.bundle.js"', `./index.bundle.js?v=${exports.CORPUS_WEB_PAGE.version}"`);
39
+ /**
40
+ * The home corpus.
41
+ *
42
+ * The document states one status, `200` as `text/html`; what a client cannot see
43
+ * is that the page's bundle reference carries the build's token. That is what the
44
+ * case pins, because a browser holding the previous build is the failure this
45
+ * route exists to prevent.
46
+ */
47
+ exports.HOME_CORPUS = [
48
+ {
49
+ id: 'home-answers-the-stamped-shell',
50
+ route: 'GET /',
51
+ description: 'answers the shell with its bundle reference stamped, leaving prose and an already-versioned reference alone',
52
+ request: {},
53
+ expect: { status: 200, contents: exports.CORPUS_WEB_BODY }
54
+ }
55
+ ];
@@ -17,6 +17,8 @@ const service_js_8 = require("../directory/service.js");
17
17
  const authconfig_js_1 = require("./authconfig.js");
18
18
  const admin_js_1 = require("./admin.js");
19
19
  const directory_js_1 = require("./directory.js");
20
+ const service_js_9 = require("../home/service.js");
21
+ const home_js_1 = require("./home.js");
20
22
  const memory_store_js_2 = require("../identity/memory-store.js");
21
23
  const fixture_js_1 = require("../identity/fixture.js");
22
24
  const types_js_1 = require("../types.js");
@@ -45,6 +47,7 @@ const servicesFor = (testCase) => {
45
47
  ? new RefusingDriveStore(testCase.seed || {})
46
48
  : new memory_store_js_1.MemoryDriveStore(testCase.seed || {})),
47
49
  info: (0, service_js_5.createInfoService)(service_js_5.BROWSER_INFO),
50
+ home: (0, service_js_9.createHomeService)(async () => home_js_1.CORPUS_WEB_PAGE),
48
51
  authConfig: (0, service_js_6.createAuthConfigService)(authconfig_js_1.CORPUS_AUTH_CONFIG),
49
52
  admin: (0, service_js_7.createAdminService)({
50
53
  diagnostics: async () => admin_js_1.CORPUS_DIAGNOSTICS,
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ /**
3
+ * The web interface's shell - the one page every host serves at `/`.
4
+ *
5
+ * The document states what the route is for: "Serves the web interface's
6
+ * `index.html`, with the current bundle version appended so a returning browser
7
+ * loads the updated bundle." That is the whole decision, and it is the same one
8
+ * on every host:
9
+ *
10
+ * - the SPA bundle has a fixed name (`index.bundle.js`), so a browser that
11
+ * keeps the previous build cached goes on rendering the previous interface
12
+ * after an update. A login screen once kept offering a password form the new
13
+ * server refused, and only a cache-disabled reload showed the new screen. The
14
+ * token is derived from the bundle's contents, so it changes with every build
15
+ * and is stable within one;
16
+ * - only an attribute naming the bundle is rewritten, so the same words in
17
+ * prose are left as prose;
18
+ * - a reference that already carries a query string is left alone, so applying
19
+ * this twice cannot produce a second `?v=`;
20
+ * - a host with no build answers a page saying so, rather than an error: a
21
+ * missing bundle costs a stale page at worst, and must never be the reason a
22
+ * deployment cannot render its own app.
23
+ *
24
+ * The host still reads the file and computes the digest - a hash of a megabyte
25
+ * bundle is the host's to make, and the package compiles with no node built-ins
26
+ * and no DOM `crypto`. What it cannot be left to each host is the rule that
27
+ * turns the two into the page, which is why it lives here.
28
+ */
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.createHomeService = exports.withBundleVersion = exports.NO_WEB_BUILD = exports.BUNDLE_NAME = void 0;
31
+ /** The entry bundle the served page references. */
32
+ exports.BUNDLE_NAME = 'index.bundle.js';
33
+ /**
34
+ * What a host with no web build answers.
35
+ *
36
+ * A page rather than a `404`: the route is the interface, and an operator whose
37
+ * build did not land needs to see that from the browser rather than from a JSON
38
+ * error. The wording is sasjs/server's, so an adopting host changes nothing a
39
+ * user or a smoke test already reads.
40
+ */
41
+ exports.NO_WEB_BUILD = '<html><head></head><body>Web Build is not present</body></html>';
42
+ /** An attribute whose value names a file; quoted or not, both are valid. */
43
+ const FILE_ATTRIBUTE = /(\s(?:src|href)=)("[^"]*"|'[^']*'|[^\s>]+)/g;
44
+ /**
45
+ * A reference that names the bundle file itself.
46
+ *
47
+ * Anchored at the end (and at a path boundary) rather than matched with
48
+ * `includes`, which is what sasjs/server's copy does: `includes` stamps
49
+ * `index.bundle.js.css` with a token derived from a different file, and a token
50
+ * that describes something it did not is worse than no token. The divergence is
51
+ * deliberate and is pinned by the corpus case every host runs, so an adopting
52
+ * host changes this behaviour knowingly rather than by accident.
53
+ */
54
+ const BUNDLE_REFERENCE = new RegExp(`(^|/)${exports.BUNDLE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`);
55
+ /**
56
+ * The page with its bundle reference carrying that token.
57
+ *
58
+ * Only an attribute naming the bundle is rewritten. A reference that already
59
+ * carries a query string is left alone, so applying this twice is the same as
60
+ * applying it once.
61
+ */
62
+ const withBundleVersion = (html, version) => html.replace(FILE_ATTRIBUTE, (match, attribute, value) => {
63
+ const quote = value[0] === '"' || value[0] === "'" ? value[0] : '';
64
+ const target = quote ? value.slice(1, -1) : value;
65
+ if (!BUNDLE_REFERENCE.test(target) || target.includes('?'))
66
+ return match;
67
+ return `${attribute}${quote}${target}?v=${version}${quote}`;
68
+ });
69
+ exports.withBundleVersion = withBundleVersion;
70
+ const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
71
+ /**
72
+ * The page, checked and stamped.
73
+ *
74
+ * A version is a query-string token: whitespace or a `?`/`#` would produce a URL
75
+ * that does not resolve, and a host that computed one from the wrong input would
76
+ * otherwise serve a broken reference rather than noticing.
77
+ */
78
+ const pageOf = (page) => {
79
+ if (!page || typeof page !== 'object')
80
+ throw new Error('The web page is not an object.');
81
+ if (!isNonEmptyString(page.html))
82
+ throw new Error('The web page states no html, so there is nothing to serve. Answer `undefined` from the port when the host has no build.');
83
+ // a token, not text: the value is written into a quoted attribute, so a
84
+ // quote closes it early and serves a broken reference - the failure this
85
+ // check exists to stop. A digest is `[0-9a-f]`, so the set below is strict
86
+ // enough to be safe and wide enough for any host's chosen encoding
87
+ if (!isNonEmptyString(page.version) ||
88
+ !/^[A-Za-z0-9._-]+$/.test(page.version))
89
+ throw new Error(`The web page states version as ${JSON.stringify(page.version)}; it is the bundle's cache token, so it may contain only letters, digits, ".", "_" and "-" - anything else, a quote above all, would end the attribute it is written into.`);
90
+ return (0, exports.withBundleVersion)(page.html, page.version);
91
+ };
92
+ /**
93
+ * The home service, over the host's own page.
94
+ *
95
+ * The port answers `undefined` when this host has no web build - a packaged
96
+ * server whose build folder is absent, a host that only answers the API - and
97
+ * the service answers the documented page rather than an error.
98
+ */
99
+ const createHomeService = (page) => ({
100
+ async home() {
101
+ const found = await page();
102
+ return found === undefined ? exports.NO_WEB_BUILD : pageOf(found);
103
+ }
104
+ });
105
+ exports.createHomeService = createHomeService;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HANDLED_ROUTES = exports.dispatch = void 0;
3
+ exports.HANDLED_ROUTES = exports.noHandler = exports.dispatch = void 0;
4
4
  const index_js_1 = require("../routes/index.js");
5
5
  const registry_js_1 = require("../drive/registry.js");
6
6
  const types_js_1 = require("../types.js");
@@ -187,6 +187,14 @@ const dispatch = async (services, routeId, request = {}) => {
187
187
  }
188
188
  }
189
189
  switch (routeId) {
190
+ // The shell is a body, not JSON: an HTML page served with the content type
191
+ // the document states, as it came from the host (stamped, if it references
192
+ // a bundle).
193
+ case 'GET /': {
194
+ if (!services.home)
195
+ throw new types_js_1.ApiError(501, `This host has no home service, so it cannot answer ${routeId}.`);
196
+ return { status: 200, contents: await services.home.home() };
197
+ }
190
198
  // The one answer a host states rather than derives: public, pre-auth, and
191
199
  // read by the login screen before anything else.
192
200
  case 'GET /SASjsApi/info': {
@@ -539,18 +547,30 @@ const dispatch = async (services, routeId, request = {}) => {
539
547
  newPassword: String(body.newPassword ?? '')
540
548
  });
541
549
  return { status: 204 };
542
- default: {
543
- // The reason the table carries travels with the refusal: a host developer
544
- // reading a 501 wants to know what the operation waits on, not only that
545
- // it is missing.
546
- const reason = (0, index_js_1.routeById)(routeId)?.reason;
547
- throw new types_js_1.ApiError(501, `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ''}`);
548
- }
550
+ default:
551
+ throw (0, exports.noHandler)(routeId);
549
552
  }
550
553
  };
551
554
  exports.dispatch = dispatch;
555
+ /**
556
+ * The refusal for an operation the table states and this file does not answer.
557
+ *
558
+ * Unreachable while every operation has a handler - `spec/routes.spec` asserts
559
+ * that the table's `implemented` set and `HANDLED_ROUTES` are the same list - but
560
+ * it is kept as the answer a future operation gets if it reaches the document
561
+ * before it reaches the dispatcher, rather than a promise that resolves
562
+ * `undefined`. The reason the table carries travels with it: a host developer
563
+ * reading a 501 wants to know what the operation waits on, not only that it is
564
+ * missing.
565
+ */
566
+ const noHandler = (routeId) => {
567
+ const reason = (0, index_js_1.routeById)(routeId)?.reason;
568
+ return new types_js_1.ApiError(501, `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ''}`);
569
+ };
570
+ exports.noHandler = noHandler;
552
571
  /** Whether a route is one `dispatch` can answer today. */
553
572
  exports.HANDLED_ROUTES = [
573
+ 'GET /',
554
574
  'GET /SASjsApi/info',
555
575
  'GET /SASjsApi/admin/diagnostics',
556
576
  'GET /SASjsApi/admin/logs',
@@ -14,8 +14,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.MemoryAppStreamRegistry = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.createRuntimeService = exports.DOCUMENTED_RUN_TIMES = exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = exports.DEFAULT_IDENTITY = exports.MemoryIdentityStore = exports.normaliseInfo = exports.createInfoService = exports.BROWSER_INFO = exports.DIRECTORY_CORPUS = exports.AUTH_CONFIG_CORPUS = exports.ADMIN_CORPUS = exports.INFO_CORPUS = exports.CODE_CORPUS = exports.sanitiseDisplayName = exports.createRecordService = exports.createIdentityService = exports.HANDLED_ROUTES = exports.dispatch = exports.TAG_CAPABILITIES = exports.OVERLAY = exports.findRoute = exports.routeById = exports.ROUTES = exports.MemoryDriveStore = exports.measureDeployTree = exports.isDeployTree = exports.deployTree = exports.decodeBase64 = exports.checkDeployTree = exports.DEPLOY_SUCCESS = exports.DEPLOY_PAYLOAD_BYTES = exports.DEPLOY_LIMITS = exports.createDriveService = exports.isRoot = exports.basename = exports.dirname = exports.hasBlockedExtension = exports.normaliseDrivePath = void 0;
18
- exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.unpublishAppStream = void 0;
17
+ exports.CODE_DEBUG = exports.MemorySessionHost = exports.DEFAULT_SESSIONS = exports.createSessionService = exports.SESSION_CORPUS = exports.DEPLOY_CORPUS = exports.IDENTITY_CORPUS = exports.DRIVE_CORPUS = exports.parseIdentity = exports.IDENTITY_FORMAT = exports.DEFAULT_IDENTITY = exports.MemoryIdentityStore = exports.normaliseInfo = exports.createInfoService = exports.BROWSER_INFO = exports.withBundleVersion = exports.createHomeService = exports.NO_WEB_BUILD = exports.BUNDLE_NAME = exports.HOME_CORPUS = exports.DIRECTORY_CORPUS = exports.AUTH_CONFIG_CORPUS = exports.ADMIN_CORPUS = exports.INFO_CORPUS = exports.CODE_CORPUS = exports.sanitiseDisplayName = exports.createRecordService = exports.createIdentityService = exports.HANDLED_ROUTES = exports.dispatch = exports.TAG_CAPABILITIES = exports.OVERLAY = exports.findRoute = exports.routeById = exports.ROUTES = exports.MemoryDriveStore = exports.measureDeployTree = exports.isDeployTree = exports.deployTree = exports.decodeBase64 = exports.checkDeployTree = exports.DEPLOY_SUCCESS = exports.DEPLOY_PAYLOAD_BYTES = exports.DEPLOY_LIMITS = exports.createDriveService = exports.isRoot = exports.basename = exports.dirname = exports.hasBlockedExtension = exports.normaliseDrivePath = void 0;
18
+ exports.servicesFor = exports.runCase = exports.PROVIDER_MANAGED = exports.ADMIN_SIGNED_IN = exports.RECORD_CORPUS = exports.unpublishAppStream = exports.MemoryAppStreamRegistry = exports.RUNTIME_CORPUS = exports.MemorySessionRunner = exports.createRuntimeService = exports.DOCUMENTED_RUN_TIMES = void 0;
19
19
  /**
20
20
  * `@sasjs/api` - the SASjs Server API described once.
21
21
  *
@@ -78,10 +78,17 @@ var authconfig_js_1 = require("./corpus/authconfig.js");
78
78
  Object.defineProperty(exports, "AUTH_CONFIG_CORPUS", { enumerable: true, get: function () { return authconfig_js_1.AUTH_CONFIG_CORPUS; } });
79
79
  var directory_js_1 = require("./corpus/directory.js");
80
80
  Object.defineProperty(exports, "DIRECTORY_CORPUS", { enumerable: true, get: function () { return directory_js_1.DIRECTORY_CORPUS; } });
81
- var service_js_3 = require("./info/service.js");
82
- Object.defineProperty(exports, "BROWSER_INFO", { enumerable: true, get: function () { return service_js_3.BROWSER_INFO; } });
83
- Object.defineProperty(exports, "createInfoService", { enumerable: true, get: function () { return service_js_3.createInfoService; } });
84
- Object.defineProperty(exports, "normaliseInfo", { enumerable: true, get: function () { return service_js_3.normaliseInfo; } });
81
+ var home_js_1 = require("./corpus/home.js");
82
+ Object.defineProperty(exports, "HOME_CORPUS", { enumerable: true, get: function () { return home_js_1.HOME_CORPUS; } });
83
+ var service_js_3 = require("./home/service.js");
84
+ Object.defineProperty(exports, "BUNDLE_NAME", { enumerable: true, get: function () { return service_js_3.BUNDLE_NAME; } });
85
+ Object.defineProperty(exports, "NO_WEB_BUILD", { enumerable: true, get: function () { return service_js_3.NO_WEB_BUILD; } });
86
+ Object.defineProperty(exports, "createHomeService", { enumerable: true, get: function () { return service_js_3.createHomeService; } });
87
+ Object.defineProperty(exports, "withBundleVersion", { enumerable: true, get: function () { return service_js_3.withBundleVersion; } });
88
+ var service_js_4 = require("./info/service.js");
89
+ Object.defineProperty(exports, "BROWSER_INFO", { enumerable: true, get: function () { return service_js_4.BROWSER_INFO; } });
90
+ Object.defineProperty(exports, "createInfoService", { enumerable: true, get: function () { return service_js_4.createInfoService; } });
91
+ Object.defineProperty(exports, "normaliseInfo", { enumerable: true, get: function () { return service_js_4.normaliseInfo; } });
85
92
  var memory_store_js_2 = require("./identity/memory-store.js");
86
93
  Object.defineProperty(exports, "MemoryIdentityStore", { enumerable: true, get: function () { return memory_store_js_2.MemoryIdentityStore; } });
87
94
  var fixture_js_1 = require("./identity/fixture.js");
@@ -96,15 +103,15 @@ var deploy_js_2 = require("./corpus/deploy.js");
96
103
  Object.defineProperty(exports, "DEPLOY_CORPUS", { enumerable: true, get: function () { return deploy_js_2.DEPLOY_CORPUS; } });
97
104
  var session_js_1 = require("./corpus/session.js");
98
105
  Object.defineProperty(exports, "SESSION_CORPUS", { enumerable: true, get: function () { return session_js_1.SESSION_CORPUS; } });
99
- var service_js_4 = require("./session/service.js");
100
- Object.defineProperty(exports, "createSessionService", { enumerable: true, get: function () { return service_js_4.createSessionService; } });
106
+ var service_js_5 = require("./session/service.js");
107
+ Object.defineProperty(exports, "createSessionService", { enumerable: true, get: function () { return service_js_5.createSessionService; } });
101
108
  var memory_host_js_1 = require("./session/memory-host.js");
102
109
  Object.defineProperty(exports, "DEFAULT_SESSIONS", { enumerable: true, get: function () { return memory_host_js_1.DEFAULT_SESSIONS; } });
103
110
  Object.defineProperty(exports, "MemorySessionHost", { enumerable: true, get: function () { return memory_host_js_1.MemorySessionHost; } });
104
- var service_js_5 = require("./runtime/service.js");
105
- Object.defineProperty(exports, "CODE_DEBUG", { enumerable: true, get: function () { return service_js_5.CODE_DEBUG; } });
106
- Object.defineProperty(exports, "DOCUMENTED_RUN_TIMES", { enumerable: true, get: function () { return service_js_5.DOCUMENTED_RUN_TIMES; } });
107
- Object.defineProperty(exports, "createRuntimeService", { enumerable: true, get: function () { return service_js_5.createRuntimeService; } });
111
+ var service_js_6 = require("./runtime/service.js");
112
+ Object.defineProperty(exports, "CODE_DEBUG", { enumerable: true, get: function () { return service_js_6.CODE_DEBUG; } });
113
+ Object.defineProperty(exports, "DOCUMENTED_RUN_TIMES", { enumerable: true, get: function () { return service_js_6.DOCUMENTED_RUN_TIMES; } });
114
+ Object.defineProperty(exports, "createRuntimeService", { enumerable: true, get: function () { return service_js_6.createRuntimeService; } });
108
115
  var memory_runner_js_1 = require("./runtime/memory-runner.js");
109
116
  Object.defineProperty(exports, "MemorySessionRunner", { enumerable: true, get: function () { return memory_runner_js_1.MemorySessionRunner; } });
110
117
  var runtime_js_1 = require("./corpus/runtime.js");
@@ -25,7 +25,6 @@ exports.TAG_CAPABILITIES = {
25
25
  * operation waits on, and thirty copies of the same sentence would say the same
26
26
  * thing thirty times.
27
27
  */
28
- const WEB_BUNDLE = 'The host serves its own web bundle; there is no API decision here for this package to answer.';
29
28
  const success = { status: 'success' };
30
29
  const user = {
31
30
  uid: '',
@@ -35,8 +34,19 @@ const user = {
35
34
  needsToUpdatePassword: false
36
35
  };
37
36
  exports.OVERLAY = {
38
- // Web - the sign-in pages the identity service answers, and the bundle itself
39
- 'GET /': { implemented: false, reason: WEB_BUNDLE },
37
+ // Web - the sign-in pages the identity service answers, and the shell itself.
38
+ // The page is the host's file; the stamping rule that keeps a cached shell
39
+ // from pinning an old bundle is the package's.
40
+ 'GET /': {
41
+ implemented: true,
42
+ // public: the shell is what an unauthenticated browser asks for first
43
+ capabilities: []
44
+ // No body annotation: this status carries two, and neither is a value a
45
+ // client keys on. The usual answer is the host's own page, stamped with its
46
+ // bundle token (its bytes are the host's, so the corpus pins the transform
47
+ // rather than the page); the fallback is NO_WEB_BUILD, which is a constant
48
+ // here rather than a literal copied into this table.
49
+ },
40
50
  'POST /SASLogon/login': {
41
51
  implemented: true,
42
52
  // The lockout and the provider failure are answered before the package is
@@ -0,0 +1,28 @@
1
+ import type { CorpusCase } from './drive.js';
2
+ import type { WebPage } from '../home/service.js';
3
+ /**
4
+ * The shell the corpus host serves.
5
+ *
6
+ * A bundle reference the stamping rule must rewrite, a second reference that
7
+ * already carries a query string (left alone, which is what makes the transform
8
+ * idempotent), a stylesheet whose name merely begins with the bundle's (left
9
+ * alone, which is where this rule differs from sasjs/server's `includes`), and
10
+ * the bundle's name in prose (left as prose). The page a real host reads looks
11
+ * like this; the values are a fixture so a case can pin the exact bytes.
12
+ */
13
+ export declare const CORPUS_WEB_PAGE: WebPage;
14
+ /**
15
+ * The body that page must answer with: the bundle reference stamped, the
16
+ * already-versioned one and the prose untouched.
17
+ */
18
+ export declare const CORPUS_WEB_BODY: string;
19
+ /**
20
+ * The home corpus.
21
+ *
22
+ * The document states one status, `200` as `text/html`; what a client cannot see
23
+ * is that the page's bundle reference carries the build's token. That is what the
24
+ * case pins, because a browser holding the previous build is the failure this
25
+ * route exists to prevent.
26
+ */
27
+ export declare const HOME_CORPUS: CorpusCase[];
28
+ //# sourceMappingURL=home.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"home.d.ts","sourceRoot":"","sources":["../../../src/corpus/home.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAA;AAEjD;;;;;;;;;GASG;AACH,eAAO,MAAM,eAAe,EAAE,OAmB7B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,QAG3B,CAAA;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,UAAU,EASnC,CAAA"}
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The shell the corpus host serves.
3
+ *
4
+ * A bundle reference the stamping rule must rewrite, a second reference that
5
+ * already carries a query string (left alone, which is what makes the transform
6
+ * idempotent), a stylesheet whose name merely begins with the bundle's (left
7
+ * alone, which is where this rule differs from sasjs/server's `includes`), and
8
+ * the bundle's name in prose (left as prose). The page a real host reads looks
9
+ * like this; the values are a fixture so a case can pin the exact bytes.
10
+ */
11
+ export const CORPUS_WEB_PAGE = {
12
+ version: '4a26a3d1b2c3',
13
+ html: [
14
+ '<!doctype html>',
15
+ '<html>',
16
+ '<head>',
17
+ ' <script src="./index.bundle.js"></script>',
18
+ ' <script src="./vendor.js?v=keepme"></script>',
19
+ ' <link rel="stylesheet" href="./index.bundle.css" />',
20
+ // a name that merely begins with the bundle's: stamped by an `includes`
21
+ // match, left alone here - see BUNDLE_REFERENCE
22
+ ' <link rel="stylesheet" href="./index.bundle.js.css" />',
23
+ '</head>',
24
+ '<body>',
25
+ ' <p>The page loads index.bundle.js from the folder beside it.</p>',
26
+ ' <div id="root"></div>',
27
+ '</body>',
28
+ '</html>'
29
+ ].join('\n')
30
+ };
31
+ /**
32
+ * The body that page must answer with: the bundle reference stamped, the
33
+ * already-versioned one and the prose untouched.
34
+ */
35
+ export const CORPUS_WEB_BODY = CORPUS_WEB_PAGE.html.replace('./index.bundle.js"', `./index.bundle.js?v=${CORPUS_WEB_PAGE.version}"`);
36
+ /**
37
+ * The home corpus.
38
+ *
39
+ * The document states one status, `200` as `text/html`; what a client cannot see
40
+ * is that the page's bundle reference carries the build's token. That is what the
41
+ * case pins, because a browser holding the previous build is the failure this
42
+ * route exists to prevent.
43
+ */
44
+ export const HOME_CORPUS = [
45
+ {
46
+ id: 'home-answers-the-stamped-shell',
47
+ route: 'GET /',
48
+ description: 'answers the shell with its bundle reference stamped, leaving prose and an already-versioned reference alone',
49
+ request: {},
50
+ expect: { status: 200, contents: CORPUS_WEB_BODY }
51
+ }
52
+ ];
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAoBnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,UAAU,KAAG,QAyClD,CAAA;AA2BD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,UAAU,EACpB,WAAU,QAAgC,KACzC,OAAO,CAAC,UAAU,CAepB,CAAA"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/corpus/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAsBnD,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,QAAQ,CAAC,EAAE,MAAM,GAAG,UAAU,CAAA;IAC9B,wDAAwD;IACxD,KAAK,CAAC,EAAE,MAAM,CAAA;CACf;AAED;;;;;GAKG;AACH,eAAO,MAAM,WAAW,GAAI,UAAU,UAAU,KAAG,QA0ClD,CAAA;AA2BD;;;;GAIG;AACH,eAAO,MAAM,OAAO,GAClB,UAAU,UAAU,EACpB,WAAU,QAAgC,KACzC,OAAO,CAAC,UAAU,CAepB,CAAA"}
@@ -14,6 +14,8 @@ import { createDirectoryService } from '../directory/service.js';
14
14
  import { CORPUS_AUTH_CONFIG } from './authconfig.js';
15
15
  import { CORPUS_DIAGNOSTICS, CORPUS_LOG, CORPUS_LOG_TAIL } from './admin.js';
16
16
  import { CORPUS_DIRECTORY } from './directory.js';
17
+ import { createHomeService } from '../home/service.js';
18
+ import { CORPUS_WEB_PAGE } from './home.js';
17
19
  import { MemoryIdentityStore } from '../identity/memory-store.js';
18
20
  import { DEFAULT_IDENTITY } from '../identity/fixture.js';
19
21
  import { isApiError } from '../types.js';
@@ -42,6 +44,7 @@ export const servicesFor = (testCase) => {
42
44
  ? new RefusingDriveStore(testCase.seed || {})
43
45
  : new MemoryDriveStore(testCase.seed || {})),
44
46
  info: createInfoService(BROWSER_INFO),
47
+ home: createHomeService(async () => CORPUS_WEB_PAGE),
45
48
  authConfig: createAuthConfigService(CORPUS_AUTH_CONFIG),
46
49
  admin: createAdminService({
47
50
  diagnostics: async () => CORPUS_DIAGNOSTICS,
@@ -0,0 +1,69 @@
1
+ /**
2
+ * The web interface's shell - the one page every host serves at `/`.
3
+ *
4
+ * The document states what the route is for: "Serves the web interface's
5
+ * `index.html`, with the current bundle version appended so a returning browser
6
+ * loads the updated bundle." That is the whole decision, and it is the same one
7
+ * on every host:
8
+ *
9
+ * - the SPA bundle has a fixed name (`index.bundle.js`), so a browser that
10
+ * keeps the previous build cached goes on rendering the previous interface
11
+ * after an update. A login screen once kept offering a password form the new
12
+ * server refused, and only a cache-disabled reload showed the new screen. The
13
+ * token is derived from the bundle's contents, so it changes with every build
14
+ * and is stable within one;
15
+ * - only an attribute naming the bundle is rewritten, so the same words in
16
+ * prose are left as prose;
17
+ * - a reference that already carries a query string is left alone, so applying
18
+ * this twice cannot produce a second `?v=`;
19
+ * - a host with no build answers a page saying so, rather than an error: a
20
+ * missing bundle costs a stale page at worst, and must never be the reason a
21
+ * deployment cannot render its own app.
22
+ *
23
+ * The host still reads the file and computes the digest - a hash of a megabyte
24
+ * bundle is the host's to make, and the package compiles with no node built-ins
25
+ * and no DOM `crypto`. What it cannot be left to each host is the rule that
26
+ * turns the two into the page, which is why it lives here.
27
+ */
28
+ /** The entry bundle the served page references. */
29
+ export declare const BUNDLE_NAME = "index.bundle.js";
30
+ /**
31
+ * What a host with no web build answers.
32
+ *
33
+ * A page rather than a `404`: the route is the interface, and an operator whose
34
+ * build did not land needs to see that from the browser rather than from a JSON
35
+ * error. The wording is sasjs/server's, so an adopting host changes nothing a
36
+ * user or a smoke test already reads.
37
+ */
38
+ export declare const NO_WEB_BUILD = "<html><head></head><body>Web Build is not present</body></html>";
39
+ /** What the host hands over: the page it read, and the token it computed. */
40
+ export interface WebPage {
41
+ /** The shell document, as it was read. */
42
+ html: string;
43
+ /**
44
+ * The cache-busting token for the bundle the page references - a digest of the
45
+ * bundle's contents, twelve characters in sasjs/server's implementation.
46
+ */
47
+ version: string;
48
+ }
49
+ export interface HomeService {
50
+ /** The page to send with a `200`, as `text/html`. */
51
+ home(): Promise<string>;
52
+ }
53
+ /**
54
+ * The page with its bundle reference carrying that token.
55
+ *
56
+ * Only an attribute naming the bundle is rewritten. A reference that already
57
+ * carries a query string is left alone, so applying this twice is the same as
58
+ * applying it once.
59
+ */
60
+ export declare const withBundleVersion: (html: string, version: string) => string;
61
+ /**
62
+ * The home service, over the host's own page.
63
+ *
64
+ * The port answers `undefined` when this host has no web build - a packaged
65
+ * server whose build folder is absent, a host that only answers the API - and
66
+ * the service answers the documented page rather than an error.
67
+ */
68
+ export declare const createHomeService: (page: () => Promise<WebPage | undefined>) => HomeService;
69
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../src/home/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,mDAAmD;AACnD,eAAO,MAAM,WAAW,oBAAoB,CAAA;AAE5C;;;;;;;GAOG;AACH,eAAO,MAAM,YAAY,oEAC0C,CAAA;AAEnE,6EAA6E;AAC7E,MAAM,WAAW,OAAO;IACtB,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAA;IACZ;;;OAGG;IACH,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAA;CACxB;AAmBD;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAM,MAAM,EAAE,SAAS,MAAM,KAAG,MAQ9D,CAAA;AAoCJ;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,GAC5B,MAAM,MAAM,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,KACvC,WAKD,CAAA"}
@@ -0,0 +1,100 @@
1
+ /**
2
+ * The web interface's shell - the one page every host serves at `/`.
3
+ *
4
+ * The document states what the route is for: "Serves the web interface's
5
+ * `index.html`, with the current bundle version appended so a returning browser
6
+ * loads the updated bundle." That is the whole decision, and it is the same one
7
+ * on every host:
8
+ *
9
+ * - the SPA bundle has a fixed name (`index.bundle.js`), so a browser that
10
+ * keeps the previous build cached goes on rendering the previous interface
11
+ * after an update. A login screen once kept offering a password form the new
12
+ * server refused, and only a cache-disabled reload showed the new screen. The
13
+ * token is derived from the bundle's contents, so it changes with every build
14
+ * and is stable within one;
15
+ * - only an attribute naming the bundle is rewritten, so the same words in
16
+ * prose are left as prose;
17
+ * - a reference that already carries a query string is left alone, so applying
18
+ * this twice cannot produce a second `?v=`;
19
+ * - a host with no build answers a page saying so, rather than an error: a
20
+ * missing bundle costs a stale page at worst, and must never be the reason a
21
+ * deployment cannot render its own app.
22
+ *
23
+ * The host still reads the file and computes the digest - a hash of a megabyte
24
+ * bundle is the host's to make, and the package compiles with no node built-ins
25
+ * and no DOM `crypto`. What it cannot be left to each host is the rule that
26
+ * turns the two into the page, which is why it lives here.
27
+ */
28
+ /** The entry bundle the served page references. */
29
+ export const BUNDLE_NAME = 'index.bundle.js';
30
+ /**
31
+ * What a host with no web build answers.
32
+ *
33
+ * A page rather than a `404`: the route is the interface, and an operator whose
34
+ * build did not land needs to see that from the browser rather than from a JSON
35
+ * error. The wording is sasjs/server's, so an adopting host changes nothing a
36
+ * user or a smoke test already reads.
37
+ */
38
+ export const NO_WEB_BUILD = '<html><head></head><body>Web Build is not present</body></html>';
39
+ /** An attribute whose value names a file; quoted or not, both are valid. */
40
+ const FILE_ATTRIBUTE = /(\s(?:src|href)=)("[^"]*"|'[^']*'|[^\s>]+)/g;
41
+ /**
42
+ * A reference that names the bundle file itself.
43
+ *
44
+ * Anchored at the end (and at a path boundary) rather than matched with
45
+ * `includes`, which is what sasjs/server's copy does: `includes` stamps
46
+ * `index.bundle.js.css` with a token derived from a different file, and a token
47
+ * that describes something it did not is worse than no token. The divergence is
48
+ * deliberate and is pinned by the corpus case every host runs, so an adopting
49
+ * host changes this behaviour knowingly rather than by accident.
50
+ */
51
+ const BUNDLE_REFERENCE = new RegExp(`(^|/)${BUNDLE_NAME.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`);
52
+ /**
53
+ * The page with its bundle reference carrying that token.
54
+ *
55
+ * Only an attribute naming the bundle is rewritten. A reference that already
56
+ * carries a query string is left alone, so applying this twice is the same as
57
+ * applying it once.
58
+ */
59
+ export const withBundleVersion = (html, version) => html.replace(FILE_ATTRIBUTE, (match, attribute, value) => {
60
+ const quote = value[0] === '"' || value[0] === "'" ? value[0] : '';
61
+ const target = quote ? value.slice(1, -1) : value;
62
+ if (!BUNDLE_REFERENCE.test(target) || target.includes('?'))
63
+ return match;
64
+ return `${attribute}${quote}${target}?v=${version}${quote}`;
65
+ });
66
+ const isNonEmptyString = (value) => typeof value === 'string' && value.length > 0;
67
+ /**
68
+ * The page, checked and stamped.
69
+ *
70
+ * A version is a query-string token: whitespace or a `?`/`#` would produce a URL
71
+ * that does not resolve, and a host that computed one from the wrong input would
72
+ * otherwise serve a broken reference rather than noticing.
73
+ */
74
+ const pageOf = (page) => {
75
+ if (!page || typeof page !== 'object')
76
+ throw new Error('The web page is not an object.');
77
+ if (!isNonEmptyString(page.html))
78
+ throw new Error('The web page states no html, so there is nothing to serve. Answer `undefined` from the port when the host has no build.');
79
+ // a token, not text: the value is written into a quoted attribute, so a
80
+ // quote closes it early and serves a broken reference - the failure this
81
+ // check exists to stop. A digest is `[0-9a-f]`, so the set below is strict
82
+ // enough to be safe and wide enough for any host's chosen encoding
83
+ if (!isNonEmptyString(page.version) ||
84
+ !/^[A-Za-z0-9._-]+$/.test(page.version))
85
+ throw new Error(`The web page states version as ${JSON.stringify(page.version)}; it is the bundle's cache token, so it may contain only letters, digits, ".", "_" and "-" - anything else, a quote above all, would end the attribute it is written into.`);
86
+ return withBundleVersion(page.html, page.version);
87
+ };
88
+ /**
89
+ * The home service, over the host's own page.
90
+ *
91
+ * The port answers `undefined` when this host has no web build - a packaged
92
+ * server whose build folder is absent, a host that only answers the API - and
93
+ * the service answers the documented page rather than an error.
94
+ */
95
+ export const createHomeService = (page) => ({
96
+ async home() {
97
+ const found = await page();
98
+ return found === undefined ? NO_WEB_BUILD : pageOf(found);
99
+ }
100
+ });
@@ -9,7 +9,9 @@ import type { InfoService } from '../info/service.js';
9
9
  import type { AuthConfigService } from '../authconfig/service.js';
10
10
  import type { AdminService } from '../admin/service.js';
11
11
  import type { DirectoryService } from '../directory/service.js';
12
+ import type { HomeService } from '../home/service.js';
12
13
  import type { Subject } from '../identity/types.js';
14
+ import { ApiError } from '../types.js';
13
15
  export interface ApiRequest {
14
16
  query?: Record<string, string | undefined>;
15
17
  body?: Record<string, unknown>;
@@ -73,6 +75,11 @@ export interface Services {
73
75
  * the connection is the host's.
74
76
  */
75
77
  directory?: DirectoryService;
78
+ /**
79
+ * The web interface's shell. Absent, `GET /` answers 501: the page is a file
80
+ * only the host holds.
81
+ */
82
+ home?: HomeService;
76
83
  drive: DriveService;
77
84
  /**
78
85
  * Users, clients and tokens. A host without one answers 501 for the identity
@@ -99,6 +106,18 @@ export interface Services {
99
106
  registry?: AppStreamRegistry;
100
107
  }
101
108
  export declare const dispatch: (services: Services, routeId: string, request?: ApiRequest) => Promise<ApiResponse>;
109
+ /**
110
+ * The refusal for an operation the table states and this file does not answer.
111
+ *
112
+ * Unreachable while every operation has a handler - `spec/routes.spec` asserts
113
+ * that the table's `implemented` set and `HANDLED_ROUTES` are the same list - but
114
+ * it is kept as the answer a future operation gets if it reaches the document
115
+ * before it reaches the dispatcher, rather than a promise that resolves
116
+ * `undefined`. The reason the table carries travels with it: a host developer
117
+ * reading a 501 wants to know what the operation waits on, not only that it is
118
+ * missing.
119
+ */
120
+ export declare const noHandler: (routeId: string) => ApiError;
102
121
  /** Whether a route is one `dispatch` can answer today. */
103
122
  export declare const HANDLED_ROUTES: string[];
104
123
  //# sourceMapping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AA"}
@@ -184,6 +184,14 @@ export const dispatch = async (services, routeId, request = {}) => {
184
184
  }
185
185
  }
186
186
  switch (routeId) {
187
+ // The shell is a body, not JSON: an HTML page served with the content type
188
+ // the document states, as it came from the host (stamped, if it references
189
+ // a bundle).
190
+ case 'GET /': {
191
+ if (!services.home)
192
+ throw new ApiError(501, `This host has no home service, so it cannot answer ${routeId}.`);
193
+ return { status: 200, contents: await services.home.home() };
194
+ }
187
195
  // The one answer a host states rather than derives: public, pre-auth, and
188
196
  // read by the login screen before anything else.
189
197
  case 'GET /SASjsApi/info': {
@@ -536,17 +544,28 @@ export const dispatch = async (services, routeId, request = {}) => {
536
544
  newPassword: String(body.newPassword ?? '')
537
545
  });
538
546
  return { status: 204 };
539
- default: {
540
- // The reason the table carries travels with the refusal: a host developer
541
- // reading a 501 wants to know what the operation waits on, not only that
542
- // it is missing.
543
- const reason = routeById(routeId)?.reason;
544
- throw new ApiError(501, `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ''}`);
545
- }
547
+ default:
548
+ throw noHandler(routeId);
546
549
  }
547
550
  };
551
+ /**
552
+ * The refusal for an operation the table states and this file does not answer.
553
+ *
554
+ * Unreachable while every operation has a handler - `spec/routes.spec` asserts
555
+ * that the table's `implemented` set and `HANDLED_ROUTES` are the same list - but
556
+ * it is kept as the answer a future operation gets if it reaches the document
557
+ * before it reaches the dispatcher, rather than a promise that resolves
558
+ * `undefined`. The reason the table carries travels with it: a host developer
559
+ * reading a 501 wants to know what the operation waits on, not only that it is
560
+ * missing.
561
+ */
562
+ export const noHandler = (routeId) => {
563
+ const reason = routeById(routeId)?.reason;
564
+ return new ApiError(501, `This package has no handler for ${routeId}.${reason ? ` ${reason}` : ''}`);
565
+ };
548
566
  /** Whether a route is one `dispatch` can answer today. */
549
567
  export const HANDLED_ROUTES = [
568
+ 'GET /',
550
569
  'GET /SASjsApi/info',
551
570
  'GET /SASjsApi/admin/diagnostics',
552
571
  'GET /SASjsApi/admin/logs',
@@ -34,6 +34,9 @@ export { INFO_CORPUS } from './corpus/info.js';
34
34
  export { ADMIN_CORPUS } from './corpus/admin.js';
35
35
  export { AUTH_CONFIG_CORPUS } from './corpus/authconfig.js';
36
36
  export { DIRECTORY_CORPUS } from './corpus/directory.js';
37
+ export { HOME_CORPUS } from './corpus/home.js';
38
+ export { BUNDLE_NAME, NO_WEB_BUILD, createHomeService, withBundleVersion } from './home/service.js';
39
+ export type { HomeService, WebPage } from './home/service.js';
37
40
  export { BROWSER_INFO, createInfoService, normaliseInfo } from './info/service.js';
38
41
  export type { InfoResponse, InfoService } from './info/service.js';
39
42
  export type { AuthorizedRoutesResponse, GroupDetailsResponse, GroupResponse, PermissionResponse, RecordServiceOptions, RecordService, UserDetailsResponse, UserResponse } from './identity/records.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,cAAc,YAAY,CAAA;AAC1B,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,OAAO,EACP,QAAQ,EACR,MAAM,EACP,MAAM,kBAAkB,CAAA;AACzB,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,eAAe,EACf,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,iBAAiB,EAClB,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,YAAY,EACZ,kBAAkB,EAClB,YAAY,EACZ,aAAa,EACb,UAAU,EACX,MAAM,mBAAmB,CAAA;AAC1B,YAAY,EACV,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,SAAS,EACT,SAAS,EACV,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAChE,YAAY,EAA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AO,EACL,aAAa,EACb,eAAe,EACf,gBAAgB,EACjB,MAAM,qBAAqB,CAAA;AAC5B,YAAY,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AACzD,YAAY,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA"}
@@ -30,6 +30,8 @@ export { INFO_CORPUS } from './corpus/info.js';
30
30
  export { ADMIN_CORPUS } from './corpus/admin.js';
31
31
  export { AUTH_CONFIG_CORPUS } from './corpus/authconfig.js';
32
32
  export { DIRECTORY_CORPUS } from './corpus/directory.js';
33
+ export { HOME_CORPUS } from './corpus/home.js';
34
+ export { BUNDLE_NAME, NO_WEB_BUILD, createHomeService, withBundleVersion } from './home/service.js';
33
35
  export { BROWSER_INFO, createInfoService, normaliseInfo } from './info/service.js';
34
36
  export { MemoryIdentityStore } from './identity/memory-store.js';
35
37
  export { DEFAULT_IDENTITY, IDENTITY_FORMAT, parseIdentity } from './identity/fixture.js';
@@ -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,CAczD,CAAA;AAsBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAsThD,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,OAAO,EAAE,UAAU,EAA8C,CAAA"}
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,CAczD,CAAA;AAmBD,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAiUhD,CAAA;AAED,wEAAwE;AACxE,eAAO,MAAM,OAAO,EAAE,UAAU,EAA8C,CAAA"}
@@ -22,7 +22,6 @@ export const TAG_CAPABILITIES = {
22
22
  * operation waits on, and thirty copies of the same sentence would say the same
23
23
  * thing thirty times.
24
24
  */
25
- const WEB_BUNDLE = 'The host serves its own web bundle; there is no API decision here for this package to answer.';
26
25
  const success = { status: 'success' };
27
26
  const user = {
28
27
  uid: '',
@@ -32,8 +31,19 @@ const user = {
32
31
  needsToUpdatePassword: false
33
32
  };
34
33
  export const OVERLAY = {
35
- // Web - the sign-in pages the identity service answers, and the bundle itself
36
- 'GET /': { implemented: false, reason: WEB_BUNDLE },
34
+ // Web - the sign-in pages the identity service answers, and the shell itself.
35
+ // The page is the host's file; the stamping rule that keeps a cached shell
36
+ // from pinning an old bundle is the package's.
37
+ 'GET /': {
38
+ implemented: true,
39
+ // public: the shell is what an unauthenticated browser asks for first
40
+ capabilities: []
41
+ // No body annotation: this status carries two, and neither is a value a
42
+ // client keys on. The usual answer is the host's own page, stamped with its
43
+ // bundle token (its bytes are the host's, so the corpus pins the transform
44
+ // rather than the page); the fallback is NO_WEB_BUILD, which is a constant
45
+ // here rather than a literal copied into this table.
46
+ },
37
47
  'POST /SASLogon/login': {
38
48
  implemented: true,
39
49
  // The lockout and the provider failure are answered before the package is
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sasjs/api",
3
- "version": "0.19.0",
3
+ "version": "0.20.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",