@sasjs/api 0.40.2 → 0.42.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.
Files changed (39) hide show
  1. package/build/browser.js +1207 -996
  2. package/build/cjs/corpus/admin.js +40 -8
  3. package/build/cjs/corpus/drive.js +29 -0
  4. package/build/cjs/corpus/runner.js +9 -3
  5. package/build/cjs/corpus/runtime.js +24 -0
  6. package/build/cjs/drive/deploymentFile.js +110 -0
  7. package/build/cjs/host/dispatch.js +99 -15
  8. package/build/cjs/identity/records.js +70 -29
  9. package/build/cjs/index.js +8 -3
  10. package/build/cjs/routes/generated.js +12 -2
  11. package/build/cjs/routes/overlay.js +15 -7
  12. package/build/esm/corpus/admin.d.ts +4 -3
  13. package/build/esm/corpus/admin.d.ts.map +1 -1
  14. package/build/esm/corpus/admin.js +40 -8
  15. package/build/esm/corpus/drive.d.ts.map +1 -1
  16. package/build/esm/corpus/drive.js +29 -0
  17. package/build/esm/corpus/runner.d.ts.map +1 -1
  18. package/build/esm/corpus/runner.js +9 -3
  19. package/build/esm/corpus/runtime.d.ts.map +1 -1
  20. package/build/esm/corpus/runtime.js +24 -0
  21. package/build/esm/drive/deploymentFile.d.ts +43 -0
  22. package/build/esm/drive/deploymentFile.d.ts.map +1 -0
  23. package/build/esm/drive/deploymentFile.js +105 -0
  24. package/build/esm/host/dispatch.d.ts +16 -1
  25. package/build/esm/host/dispatch.d.ts.map +1 -1
  26. package/build/esm/host/dispatch.js +99 -15
  27. package/build/esm/identity/records.d.ts +35 -0
  28. package/build/esm/identity/records.d.ts.map +1 -1
  29. package/build/esm/identity/records.js +70 -29
  30. package/build/esm/index.d.ts +2 -0
  31. package/build/esm/index.d.ts.map +1 -1
  32. package/build/esm/index.js +1 -0
  33. package/build/esm/routes/generated.d.ts.map +1 -1
  34. package/build/esm/routes/generated.js +12 -2
  35. package/build/esm/routes/overlay.d.ts.map +1 -1
  36. package/build/esm/routes/overlay.js +15 -7
  37. package/build/esm/types.d.ts +1 -1
  38. package/build/esm/types.d.ts.map +1 -1
  39. package/package.json +3 -2
package/build/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- /* @sasjs/api 0.40.2 - the SASjs Server API, for a service worker. https://github.com/sasjs/api */
1
+ /* @sasjs/api 0.42.0 - 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;
@@ -41,6 +41,7 @@ var SASjsApi = (() => {
41
41
  DEFAULT_IDENTITY: () => DEFAULT_IDENTITY,
42
42
  DEFAULT_LOG_LINES: () => DEFAULT_LOG_LINES,
43
43
  DEFAULT_SESSIONS: () => DEFAULT_SESSIONS,
44
+ DEPLOYMENT_FILE_ERROR: () => DEPLOYMENT_FILE_ERROR,
44
45
  DEPLOY_CORPUS: () => DEPLOY_CORPUS,
45
46
  DEPLOY_LIMITS: () => DEPLOY_LIMITS,
46
47
  DEPLOY_PAYLOAD_BYTES: () => DEPLOY_PAYLOAD_BYTES,
@@ -64,6 +65,7 @@ var SASjsApi = (() => {
64
65
  MemorySessionRunner: () => MemorySessionRunner,
65
66
  NO_SUCH_APP: () => NO_SUCH_APP,
66
67
  NO_WEB_BUILD: () => NO_WEB_BUILD,
68
+ ONE_NAME_ONLY: () => ONE_NAME_ONLY,
67
69
  OVERLAY: () => OVERLAY,
68
70
  PROVIDER_MANAGED: () => PROVIDER_MANAGED,
69
71
  RECORD_CORPUS: () => RECORD_CORPUS,
@@ -84,6 +86,7 @@ var SASjsApi = (() => {
84
86
  VIYA_TARGET_VERSION: () => VIYA_TARGET_VERSION,
85
87
  appRootOf: () => appRootOf,
86
88
  appSummary: () => appSummary,
89
+ assertOneFileName: () => assertOneFileName,
87
90
  basename: () => basename,
88
91
  cacheControlFor: () => cacheControlFor,
89
92
  checkDeployTree: () => checkDeployTree,
@@ -94,6 +97,7 @@ var SASjsApi = (() => {
94
97
  createAppStreamService: () => createAppStreamService,
95
98
  createAppStreamWebService: () => createAppStreamWebService,
96
99
  createAuthConfigService: () => createAuthConfigService,
100
+ createDeploymentFileService: () => createDeploymentFileService,
97
101
  createDirectoryService: () => createDirectoryService,
98
102
  createDriveAppStreamStore: () => createDriveAppStreamStore,
99
103
  createDriveService: () => createDriveService,
@@ -515,142 +519,622 @@ var SASjsApi = (() => {
515
519
  };
516
520
  };
517
521
 
518
- // src/drive/memory-store.ts
519
- var MemoryDriveStore = class {
520
- constructor(seed = {}) {
521
- this.files = /* @__PURE__ */ new Map();
522
- this.folders = /* @__PURE__ */ new Set(["/"]);
523
- /**
524
- * When each entry was first written and last written, ISO strings.
525
- *
526
- * A Map has no clock of its own, so the store keeps one: a seeded drive is
527
- * created when the store is, and a write moves `modified` while `created`
528
- * stays. A host with real file metadata reports its own instead.
529
- */
530
- this.times = /* @__PURE__ */ new Map();
531
- for (const [path, contents] of Object.entries(seed)) {
532
- this.putSync(path, contents);
533
- }
534
- }
535
- /** Everything on the drive, for a snapshot or an assertion. */
536
- dump() {
537
- const out = {};
538
- for (const [path, contents] of this.files) out[path] = contents;
539
- return out;
540
- }
541
- putSync(path, contents) {
542
- this.mkdirpSync(dirname(path));
543
- this.files.set(
544
- path,
545
- typeof contents === "string" ? contents : contents.slice()
522
+ // src/appstream/identity.ts
523
+ var normaliseAppLoc = (appLoc) => {
524
+ if (typeof appLoc !== "string" || appLoc === "")
525
+ throw new Error(
526
+ `App location must be a non-empty string, got ${JSON.stringify(appLoc)}.`
546
527
  );
547
- const now = (/* @__PURE__ */ new Date()).toISOString();
548
- const existing = this.times.get(path);
549
- this.times.set(path, {
550
- created: existing?.created ?? now,
551
- modified: now
552
- });
553
- }
554
- mkdirpSync(path) {
555
- const parts = path.split("/").filter(Boolean);
556
- let acc = "";
557
- for (const part of parts) {
558
- acc += "/" + part;
559
- this.folders.add(acc);
560
- }
561
- }
562
- children(path) {
563
- const prefix = path === "/" ? "/" : path + "/";
564
- const files = [];
565
- const folders = [];
566
- for (const candidate of this.files.keys()) {
567
- if (!candidate.startsWith(prefix)) continue;
568
- const rest = candidate.slice(prefix.length);
569
- if (rest && !rest.includes("/")) files.push(rest);
570
- }
571
- for (const candidate of this.folders) {
572
- if (!candidate.startsWith(prefix)) continue;
573
- const rest = candidate.slice(prefix.length);
574
- if (rest && !rest.includes("/")) folders.push(rest);
575
- }
576
- return { files: files.sort(), folders: folders.sort() };
577
- }
578
- async read(path) {
579
- const contents = this.files.get(path);
580
- if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
581
- return contents;
582
- }
583
- async write(path, contents) {
584
- this.putSync(path, contents);
528
+ const normalised = normaliseDrivePath(appLoc);
529
+ if (normalised === null)
530
+ throw new ApiError(400, "appLoc cannot be outside drive.");
531
+ return normalised;
532
+ };
533
+ var newAppId = () => {
534
+ const webCrypto = globalThis.crypto;
535
+ if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
536
+ if (typeof webCrypto?.getRandomValues !== "function")
537
+ throw new Error("No cryptographic source of randomness is available.");
538
+ const bytes3 = new Uint8Array(16);
539
+ webCrypto.getRandomValues(bytes3);
540
+ bytes3[6] = bytes3[6] & 15 | 64;
541
+ bytes3[8] = bytes3[8] & 63 | 128;
542
+ const hex = Array.from(bytes3).map((byte) => byte.toString(16).padStart(2, "0")).join("");
543
+ return [
544
+ hex.slice(0, 8),
545
+ hex.slice(8, 12),
546
+ hex.slice(12, 16),
547
+ hex.slice(16, 20),
548
+ hex.slice(20)
549
+ ].join("-");
550
+ };
551
+ var APP_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
552
+ var isAppId = (value) => typeof value === "string" && APP_ID.test(value);
553
+
554
+ // src/appstream/service.ts
555
+ var APP_FOLDERS_ROOT = "apps";
556
+ var frontendFolderOf = (name) => `/${APP_FOLDERS_ROOT}/${name}`;
557
+ var appSummary = (entry) => ({
558
+ id: entry.id,
559
+ name: entry.name,
560
+ url: `/app/${entry.id}/`
561
+ });
562
+ var webFolderOf = (value) => {
563
+ if (typeof value !== "string" || value === "")
564
+ throw new ApiError(400, '"streamWebFolder" is required');
565
+ if (value === "." || value === ".." || /[\\/]/.test(value))
566
+ throw new ApiError(400, "streamWebFolder must be a single path segment.");
567
+ return value;
568
+ };
569
+ var defaultAppName = (appLoc) => {
570
+ const segment = appLoc.split("/").filter(Boolean).pop();
571
+ return segment ? segment : "app";
572
+ };
573
+ var sameAppLoc = (left, right) => {
574
+ try {
575
+ return normaliseAppLoc(left) === normaliseAppLoc(right);
576
+ } catch (_) {
577
+ return false;
585
578
  }
586
- async exists(path) {
587
- return this.files.has(path) || this.folders.has(path);
579
+ };
580
+ var appLocOf = (value) => {
581
+ try {
582
+ return normaliseAppLoc(value);
583
+ } catch (error) {
584
+ throw new ApiError(400, error.message);
588
585
  }
589
- async stat(path) {
590
- if (this.folders.has(path) && !this.files.has(path))
591
- return { directory: true, size: 0 };
592
- const contents = this.files.get(path);
593
- if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
594
- const times = this.times.get(path);
586
+ };
587
+ var hasStreamFolder = (tree, streamWebFolder) => {
588
+ const members = tree?.members;
589
+ if (!Array.isArray(members)) return false;
590
+ const isFolder = (member, name) => {
591
+ const entry = member;
592
+ return entry?.type === "folder" && entry?.name === name;
593
+ };
594
+ const services = members.find((member) => isFolder(member, "services"));
595
+ const children = services?.members;
596
+ return Array.isArray(children) && children.some((member) => isFolder(member, streamWebFolder));
597
+ };
598
+ var hasFrontendRoot = (tree) => {
599
+ const members = tree?.members;
600
+ if (!Array.isArray(members)) return false;
601
+ return members.some((member) => {
602
+ const entry = member;
603
+ return entry?.type === "file" && entry?.name === "index.html";
604
+ });
605
+ };
606
+ var checkPublishRequest = (request, tree, options = {}) => {
607
+ const logo = logoOf(request.logo);
608
+ const frameAncestors = frameAncestorsOf(request.frameAncestors);
609
+ const timing = request.publishedAt === void 0 ? {} : { publishedAt: request.publishedAt };
610
+ if (request.streamWebFolder !== void 0) {
611
+ if (request.appLoc === void 0)
612
+ throw new ApiError(
613
+ 400,
614
+ '"appLoc" is required when "streamWebFolder" is stated: the entry keeps its web assets at <appLoc>/services/<streamWebFolder>, so both halves are needed to say where they are.'
615
+ );
616
+ const appLoc2 = appLocOf(request.appLoc);
617
+ if (appLoc2 === "/")
618
+ throw new ApiError(400, "An app cannot be published at the drive root.");
619
+ const streamWebFolder = webFolderOf(request.streamWebFolder);
620
+ if (tree !== void 0 && !hasStreamFolder(tree, streamWebFolder))
621
+ throw new ApiError(
622
+ 400,
623
+ `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc2}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest ? "correct the folder sasjs.app.json names." : "omit streamWebFolder."}`
624
+ );
595
625
  return {
596
- directory: false,
597
- size: typeof contents === "string" ? contents.length : contents.length,
598
- ...times ? { modified: times.modified, created: times.created } : {}
626
+ appLoc: appLoc2,
627
+ streamWebFolder,
628
+ ...request.name === void 0 ? {} : { name: nameOf(request.name) },
629
+ ...logo === void 0 ? {} : { logo },
630
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
631
+ ...timing
599
632
  };
600
633
  }
601
- async list(path) {
602
- return this.children(path);
603
- }
604
- async mkdirp(path) {
605
- this.mkdirpSync(path);
606
- }
607
- async remove(path) {
608
- if (this.files.delete(path)) return;
609
- const prefix = path === "/" ? "/" : path + "/";
610
- for (const candidate of [...this.files.keys()]) {
611
- if (candidate.startsWith(prefix)) this.files.delete(candidate);
612
- }
613
- for (const candidate of [...this.folders]) {
614
- if (candidate === path || candidate.startsWith(prefix))
615
- this.folders.delete(candidate);
616
- }
617
- }
618
- async move(from, to) {
619
- const contents = this.files.get(from);
620
- if (contents !== void 0) {
621
- const copy = typeof contents === "string" ? contents : contents.slice();
622
- this.files.delete(from);
623
- this.mkdirpSync(dirname(to));
624
- this.files.set(to, copy);
625
- return;
626
- }
627
- const prefix = from + "/";
628
- const moves = [];
629
- for (const [candidate, value] of this.files) {
630
- if (candidate.startsWith(prefix))
631
- moves.push([candidate, to + candidate.slice(from.length), value]);
632
- }
633
- for (const [source] of moves) this.files.delete(source);
634
- for (const [, destination, value] of moves) {
635
- this.mkdirpSync(dirname(destination));
636
- this.files.set(destination, value);
637
- }
638
- for (const candidate of [...this.folders]) {
639
- if (candidate === from || candidate.startsWith(prefix)) {
640
- this.folders.delete(candidate);
641
- this.folders.add(to + candidate.slice(from.length));
642
- }
643
- }
644
- this.mkdirpSync(to);
645
- }
634
+ if (request.name === void 0)
635
+ throw new ApiError(
636
+ 400,
637
+ '"name" is required: an app is published at apps/<name>, so the publish has to say what it is called.'
638
+ );
639
+ const name = nameOf(request.name);
640
+ const appLoc = request.appLoc === void 0 ? void 0 : appLocOf(request.appLoc);
641
+ if (appLoc === "/")
642
+ throw new ApiError(400, "An app cannot name the drive root as its backend.");
643
+ if (tree !== void 0 && !hasFrontendRoot(tree))
644
+ throw new ApiError(
645
+ 400,
646
+ `The deployed tree has no "index.html" at its root, so nothing would be published at apps/${name}. Publish the compiled web folder itself, not the folder that holds it.`
647
+ );
648
+ return {
649
+ name,
650
+ ...appLoc === void 0 ? {} : { appLoc },
651
+ ...logo === void 0 ? {} : { logo },
652
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
653
+ ...timing
654
+ };
646
655
  };
647
-
648
- // src/routes/generated.ts
649
- var GENERATED_ROUTES = [
650
- {
651
- id: "GET /",
652
- method: "GET",
653
- path: "/",
656
+ var nameOf = (value) => {
657
+ if (typeof value !== "string" || value.trim() === "")
658
+ throw new ApiError(400, '"name" must be a non-empty string');
659
+ return urlSafeName(value.trim());
660
+ };
661
+ var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
662
+ var NAME_MAX_LENGTH = 64;
663
+ var RESERVED_NAMES = ["apps.json", "index.html"];
664
+ var urlSafeName = (name) => {
665
+ if (name.length > NAME_MAX_LENGTH)
666
+ throw new ApiError(
667
+ 400,
668
+ `"name" must be at most ${NAME_MAX_LENGTH} characters, and "${name}" is ${name.length}.`
669
+ );
670
+ if (!NAME_PATTERN.test(name))
671
+ throw new ApiError(
672
+ 400,
673
+ `"name" must be usable as a URL segment - letters, digits, dot, dash, underscore or tilde, starting with a letter or digit - so "/app/${name}" can be opened. "${name}" is not, because it carries a character that has to be percent-encoded, or a space.`
674
+ );
675
+ if (RESERVED_NAMES.includes(name.toLowerCase()))
676
+ throw new ApiError(
677
+ 400,
678
+ `"name" cannot be "${name}": the App Stream answers /app/${name} itself, so an app with that name could never be opened by name.`
679
+ );
680
+ return name;
681
+ };
682
+ var logoOf = (value) => {
683
+ if (value === void 0) return void 0;
684
+ if (typeof value !== "string" || value === "")
685
+ throw new ApiError(400, '"logo" must be a non-empty string');
686
+ return value;
687
+ };
688
+ var frameAncestorsOf = (value) => {
689
+ if (value === void 0) return void 0;
690
+ const list = Array.isArray(value) ? value : [value];
691
+ if (list.length === 0 || list.some((source) => typeof source !== "string" || source === ""))
692
+ throw new ApiError(
693
+ 400,
694
+ '"frameAncestors" must be a string or a non-empty list of strings'
695
+ );
696
+ return [...list];
697
+ };
698
+ var createAppStreamService = (store) => {
699
+ let queue = Promise.resolve();
700
+ const mutate = (work) => {
701
+ const run = queue.then(work, work);
702
+ queue = run.catch(() => void 0);
703
+ return run;
704
+ };
705
+ const readable = (allow) => store.read().then(
706
+ (entries) => entries.filter((entry) => allow ? allow(entry) : true).map((entry) => ({ ...entry })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
707
+ );
708
+ return {
709
+ list: readable,
710
+ async get(id) {
711
+ const entry = (await store.read()).find(
712
+ (candidate) => candidate.id === id
713
+ );
714
+ if (!entry) throw new ApiError(404, "No app is published with that id.");
715
+ return { ...entry };
716
+ },
717
+ async forAppLoc(appLoc) {
718
+ let normalised;
719
+ try {
720
+ normalised = normaliseAppLoc(appLoc);
721
+ } catch (_) {
722
+ return void 0;
723
+ }
724
+ const entry = (await store.read()).find(
725
+ (candidate) => candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, normalised)
726
+ );
727
+ return entry ? { ...entry } : void 0;
728
+ },
729
+ publish(request) {
730
+ return mutate(async () => {
731
+ const checked = checkPublishRequest(request);
732
+ const entries = await store.read();
733
+ const legacy = checked.streamWebFolder !== void 0;
734
+ const sameTarget = (candidate) => legacy ? candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, checked.appLoc) : candidate.streamWebFolder === void 0 && candidate.name === checked.name;
735
+ const existing = entries.find(sameTarget);
736
+ const logo = checked.logo;
737
+ const frameAncestors = checked.frameAncestors;
738
+ const name = legacy ? checked.name ?? existing?.name ?? defaultAppName(checked.appLoc) : checked.name;
739
+ if (!legacy || checked.name !== void 0) {
740
+ const clash = entries.find(
741
+ (candidate) => candidate !== existing && candidate.name.toLowerCase() === name.toLowerCase()
742
+ );
743
+ if (clash)
744
+ throw new ApiError(
745
+ 409,
746
+ `The name "${name}" is already the address of the app at ${clash.appLoc ?? frontendFolderOf(clash.name)}. An app's name is how it opens (/app/${name}), and two apps holding one name would answer an ambiguous lookup with nothing, so publish this one under a different name.`
747
+ );
748
+ }
749
+ const entry = {
750
+ id: existing ? existing.id : newAppId(),
751
+ // the label is the one field a redeploy inherits: everything else is
752
+ // what this publish states
753
+ name,
754
+ ...checked.appLoc === void 0 ? {} : { appLoc: checked.appLoc },
755
+ ...checked.streamWebFolder === void 0 ? {} : { streamWebFolder: checked.streamWebFolder },
756
+ ...logo === void 0 ? {} : { logo },
757
+ ...frameAncestors === void 0 ? {} : { frameAncestors },
758
+ publishedAt: checked.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString()
759
+ };
760
+ await store.write([
761
+ ...entries.filter((candidate) => !sameTarget(candidate)),
762
+ entry
763
+ ]);
764
+ return { ...entry };
765
+ });
766
+ },
767
+ unpublish(id) {
768
+ return mutate(async () => {
769
+ const entries = await store.read();
770
+ const index = entries.findIndex((entry) => entry.id === id);
771
+ if (index === -1)
772
+ throw new ApiError(404, "No app is published with that id.");
773
+ const [removed] = entries.splice(index, 1);
774
+ await store.write(entries);
775
+ return { ...removed };
776
+ });
777
+ }
778
+ };
779
+ };
780
+ var MemoryAppStreamStore = class {
781
+ constructor(entries = []) {
782
+ this.entries = entries.map((entry) => ({ ...entry }));
783
+ }
784
+ async read() {
785
+ return this.entries.map((entry) => ({ ...entry }));
786
+ }
787
+ async write(entries) {
788
+ this.entries = entries.map((entry) => ({ ...entry }));
789
+ }
790
+ };
791
+
792
+ // src/appstream/web.ts
793
+ var DEFAULT_APP_PATH = "/app";
794
+ var NO_SUCH_APP = "There's no App Stream available here.";
795
+ var ESCAPES = {
796
+ "&": "&amp;",
797
+ "<": "&lt;",
798
+ ">": "&gt;",
799
+ '"': "&quot;",
800
+ "'": "&#39;"
801
+ };
802
+ var escapeHtml = (value) => value.replace(/[&<>"']/g, (character) => ESCAPES[character]);
803
+ var CONTENT_TYPES = {
804
+ html: "text/html; charset=utf-8",
805
+ htm: "text/html; charset=utf-8",
806
+ js: "text/javascript; charset=utf-8",
807
+ mjs: "text/javascript; charset=utf-8",
808
+ css: "text/css; charset=utf-8",
809
+ json: "application/json; charset=utf-8",
810
+ map: "application/json; charset=utf-8",
811
+ txt: "text/plain; charset=utf-8",
812
+ svg: "image/svg+xml",
813
+ png: "image/png",
814
+ jpg: "image/jpeg",
815
+ jpeg: "image/jpeg",
816
+ gif: "image/gif",
817
+ webp: "image/webp",
818
+ ico: "image/x-icon",
819
+ woff: "font/woff",
820
+ woff2: "font/woff2",
821
+ ttf: "font/ttf",
822
+ otf: "font/otf",
823
+ wasm: "application/wasm",
824
+ pdf: "application/pdf",
825
+ zip: "application/zip"
826
+ };
827
+ var contentTypeFor = (filePath2) => {
828
+ const extension = filePath2.slice(filePath2.lastIndexOf(".") + 1).toLowerCase();
829
+ return CONTENT_TYPES[extension] ?? "application/octet-stream";
830
+ };
831
+ var cacheControlFor = (filePath2) => /\.[0-9a-f]{8,}\.[A-Za-z0-9]+$/.test(filePath2) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate";
832
+ var html = (status, markup) => ({
833
+ status,
834
+ body: markup,
835
+ contentType: "text/html; charset=utf-8"
836
+ });
837
+ var json = (status, body) => ({
838
+ status,
839
+ body: JSON.stringify(body),
840
+ contentType: "application/json; charset=utf-8"
841
+ });
842
+ var noSuchApp = () => html(404, `<!doctype html><html><body>${NO_SUCH_APP}</body></html>`);
843
+ var methodNotAllowed = (allowed) => ({
844
+ status: 405,
845
+ body: JSON.stringify({ status: "failure", message: `${allowed} only.` }),
846
+ contentType: "application/json; charset=utf-8",
847
+ headers: { allow: allowed }
848
+ });
849
+ var decoded = (segment) => {
850
+ try {
851
+ return decodeURIComponent(segment);
852
+ } catch (_) {
853
+ return void 0;
854
+ }
855
+ };
856
+ var appRootOf = (entry) => entry.streamWebFolder !== void 0 && entry.appLoc !== void 0 ? `${entry.appLoc}/services/${entry.streamWebFolder}` : frontendFolderOf(entry.name);
857
+ var createAppStreamWebService = (appStream, drive, options = {}) => {
858
+ const base = (options.basePath ?? DEFAULT_APP_PATH).replace(/\/+$/, "");
859
+ const title = options.title ?? "SASjs App Stream";
860
+ const urlOf = (entry) => `${base}/${entry.id}/`;
861
+ const rowOf = (entry) => ({
862
+ id: entry.id,
863
+ name: entry.name,
864
+ appLoc: entry.appLoc ?? null,
865
+ logo: entry.logo === void 0 ? null : `${urlOf(entry)}${entry.logo}`,
866
+ url: urlOf(entry),
867
+ publishedAt: entry.publishedAt ?? null
868
+ });
869
+ const apps = async (allow) => {
870
+ const entries = await appStream.list(allow);
871
+ return { apps: entries.map(rowOf) };
872
+ };
873
+ const landing = async (allow) => {
874
+ const { apps: rows } = await apps(allow);
875
+ const tiles = rows.length ? `<ul class="apps">${rows.map(
876
+ (row) => `<li><a href="${escapeHtml(row.url)}">${escapeHtml(row.name)}</a><span class="loc">${escapeHtml(
877
+ row.appLoc ?? frontendFolderOf(row.name)
878
+ )}</span></li>`
879
+ ).join("")}</ul>` : '<p class="empty">No apps have been published yet.</p>';
880
+ return html(
881
+ 200,
882
+ [
883
+ '<!doctype html><html lang="en"><head><meta charset="utf-8">',
884
+ '<meta name="viewport" content="width=device-width,initial-scale=1">',
885
+ `<title>${escapeHtml(title)}</title>`,
886
+ "<style>",
887
+ "body{font-family:system-ui,sans-serif;margin:2rem;color:#1f2430}",
888
+ "h1{font-size:1.4rem}",
889
+ "ul.apps{list-style:none;padding:0;display:grid;gap:.75rem;max-width:40rem}",
890
+ "ul.apps li{display:flex;flex-direction:column;gap:.15rem;padding:.75rem 1rem;",
891
+ "border:1px solid #d8dee9;border-radius:.5rem}",
892
+ "ul.apps a{font-weight:600;text-decoration:none;color:#0b5cad}",
893
+ ".loc{font-size:.8rem;color:#5b6472;font-family:ui-monospace,monospace}",
894
+ ".empty{color:#5b6472}",
895
+ "</style></head><body>",
896
+ `<h1>${escapeHtml(title)}</h1>`,
897
+ tiles,
898
+ "</body></html>"
899
+ ].join("")
900
+ );
901
+ };
902
+ const resolve = async (segment, allow) => {
903
+ const entries = await appStream.list(allow);
904
+ const byId2 = entries.find((entry) => entry.id === segment);
905
+ if (byId2) return byId2;
906
+ const byName = entries.filter((entry) => entry.name === segment);
907
+ return byName.length === 1 ? byName[0] : void 0;
908
+ };
909
+ const asset = async (entry, segments) => {
910
+ const parts = segments.map(decoded);
911
+ if (parts.some((part) => part === void 0)) return noSuchApp();
912
+ const relative = parts.join("/") || "index.html";
913
+ try {
914
+ const file = await drive.read(`${appRootOf(entry)}/${relative}`);
915
+ return {
916
+ status: 200,
917
+ body: file.contents,
918
+ contentType: contentTypeFor(relative),
919
+ headers: { "cache-control": cacheControlFor(relative) }
920
+ };
921
+ } catch (error) {
922
+ if (error instanceof ApiError && (error.status === 404 || error.status === 400))
923
+ return noSuchApp();
924
+ throw error;
925
+ }
926
+ };
927
+ return {
928
+ apps,
929
+ landing,
930
+ async request({ method, path, allow }) {
931
+ const clean = (path.split(/[?#]/)[0] || "/").replace(/\/{2,}/g, "/");
932
+ const relative = base === "" ? clean : clean === base ? "/" : clean.startsWith(`${base}/`) ? clean.slice(base.length) : null;
933
+ if (relative === null) return noSuchApp();
934
+ if (relative === "" || relative === "/" || relative === "/index.html") {
935
+ if (method !== "GET") return methodNotAllowed("GET");
936
+ return landing(allow);
937
+ }
938
+ if (relative === "/apps.json") {
939
+ if (method !== "GET") return methodNotAllowed("GET");
940
+ return json(200, await apps(allow));
941
+ }
942
+ const segments = relative.split("/").filter(Boolean);
943
+ const key = decoded(segments[0]);
944
+ if (key === void 0) return noSuchApp();
945
+ if (method === "DELETE") {
946
+ const entry2 = await resolve(key, allow);
947
+ if (!entry2) return noSuchApp();
948
+ const removed = await appStream.unpublish(entry2.id);
949
+ return json(200, { status: "success", app: rowOf(removed) });
950
+ }
951
+ if (method !== "GET") return methodNotAllowed("GET, DELETE");
952
+ const entry = await resolve(key, allow);
953
+ if (!entry) return noSuchApp();
954
+ if (segments.length === 1 && !relative.endsWith("/"))
955
+ return { status: 301, location: urlOf(entry) };
956
+ return asset(entry, segments.slice(1));
957
+ }
958
+ };
959
+ };
960
+
961
+ // src/drive/deploymentFile.ts
962
+ var DEPLOYMENT_FILE_ERROR = "Parameter Error\nFile error";
963
+ var ONE_NAME_ONLY = 'Exactly one of "_filePath" and "_FILE" may be given.';
964
+ var assertOneFileName = (query) => {
965
+ if (query._filePath !== void 0 && query._FILE !== void 0)
966
+ throw new ApiError(400, ONE_NAME_ONLY);
967
+ };
968
+ var notFound = (error) => isApiError(error) && error.status === 404 || // a structural read, not `NodeJS.ErrnoException`: this module is in the
969
+ // browser build, which has no node types at all
970
+ error?.code === "ENOENT";
971
+ var notThere = () => ({
972
+ status: 202,
973
+ contentType: "text/plain; charset=utf-8",
974
+ body: DEPLOYMENT_FILE_ERROR
975
+ });
976
+ var createDeploymentFileService = (store) => ({
977
+ async read(input) {
978
+ const checked = checkFilePath(input);
979
+ if ("reason" in checked)
980
+ throw checked.reason === "extension" ? new ApiError(400, "Invalid file extension") : new ApiError(400, `Can't get file outside drive.`);
981
+ if (isRoot(checked.path))
982
+ throw new ApiError(400, `Can't get file outside drive.`);
983
+ const path = checked.path;
984
+ try {
985
+ if ((await store.stat(path)).directory) return notThere();
986
+ return {
987
+ status: 200,
988
+ contentType: contentTypeFor(path),
989
+ // lower case, matching the app stream's own answer (src/appstream/web.ts):
990
+ // the names are case-insensitive in HTTP but not in a plain object, and a
991
+ // host copying one into the other would lose a policy that mattered
992
+ headers: { "cache-control": cacheControlFor(path) },
993
+ body: await store.read(path)
994
+ };
995
+ } catch (error) {
996
+ if (notFound(error)) return notThere();
997
+ throw error;
998
+ }
999
+ }
1000
+ });
1001
+
1002
+ // src/drive/memory-store.ts
1003
+ var MemoryDriveStore = class {
1004
+ constructor(seed = {}) {
1005
+ this.files = /* @__PURE__ */ new Map();
1006
+ this.folders = /* @__PURE__ */ new Set(["/"]);
1007
+ /**
1008
+ * When each entry was first written and last written, ISO strings.
1009
+ *
1010
+ * A Map has no clock of its own, so the store keeps one: a seeded drive is
1011
+ * created when the store is, and a write moves `modified` while `created`
1012
+ * stays. A host with real file metadata reports its own instead.
1013
+ */
1014
+ this.times = /* @__PURE__ */ new Map();
1015
+ for (const [path, contents] of Object.entries(seed)) {
1016
+ this.putSync(path, contents);
1017
+ }
1018
+ }
1019
+ /** Everything on the drive, for a snapshot or an assertion. */
1020
+ dump() {
1021
+ const out = {};
1022
+ for (const [path, contents] of this.files) out[path] = contents;
1023
+ return out;
1024
+ }
1025
+ putSync(path, contents) {
1026
+ this.mkdirpSync(dirname(path));
1027
+ this.files.set(
1028
+ path,
1029
+ typeof contents === "string" ? contents : contents.slice()
1030
+ );
1031
+ const now = (/* @__PURE__ */ new Date()).toISOString();
1032
+ const existing = this.times.get(path);
1033
+ this.times.set(path, {
1034
+ created: existing?.created ?? now,
1035
+ modified: now
1036
+ });
1037
+ }
1038
+ mkdirpSync(path) {
1039
+ const parts = path.split("/").filter(Boolean);
1040
+ let acc = "";
1041
+ for (const part of parts) {
1042
+ acc += "/" + part;
1043
+ this.folders.add(acc);
1044
+ }
1045
+ }
1046
+ children(path) {
1047
+ const prefix = path === "/" ? "/" : path + "/";
1048
+ const files = [];
1049
+ const folders = [];
1050
+ for (const candidate of this.files.keys()) {
1051
+ if (!candidate.startsWith(prefix)) continue;
1052
+ const rest = candidate.slice(prefix.length);
1053
+ if (rest && !rest.includes("/")) files.push(rest);
1054
+ }
1055
+ for (const candidate of this.folders) {
1056
+ if (!candidate.startsWith(prefix)) continue;
1057
+ const rest = candidate.slice(prefix.length);
1058
+ if (rest && !rest.includes("/")) folders.push(rest);
1059
+ }
1060
+ return { files: files.sort(), folders: folders.sort() };
1061
+ }
1062
+ async read(path) {
1063
+ const contents = this.files.get(path);
1064
+ if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
1065
+ return contents;
1066
+ }
1067
+ async write(path, contents) {
1068
+ this.putSync(path, contents);
1069
+ }
1070
+ async exists(path) {
1071
+ return this.files.has(path) || this.folders.has(path);
1072
+ }
1073
+ async stat(path) {
1074
+ if (this.folders.has(path) && !this.files.has(path))
1075
+ return { directory: true, size: 0 };
1076
+ const contents = this.files.get(path);
1077
+ if (contents === void 0) throw new ApiError(404, `File doesn't exist.`);
1078
+ const times = this.times.get(path);
1079
+ return {
1080
+ directory: false,
1081
+ size: typeof contents === "string" ? contents.length : contents.length,
1082
+ ...times ? { modified: times.modified, created: times.created } : {}
1083
+ };
1084
+ }
1085
+ async list(path) {
1086
+ return this.children(path);
1087
+ }
1088
+ async mkdirp(path) {
1089
+ this.mkdirpSync(path);
1090
+ }
1091
+ async remove(path) {
1092
+ if (this.files.delete(path)) return;
1093
+ const prefix = path === "/" ? "/" : path + "/";
1094
+ for (const candidate of [...this.files.keys()]) {
1095
+ if (candidate.startsWith(prefix)) this.files.delete(candidate);
1096
+ }
1097
+ for (const candidate of [...this.folders]) {
1098
+ if (candidate === path || candidate.startsWith(prefix))
1099
+ this.folders.delete(candidate);
1100
+ }
1101
+ }
1102
+ async move(from, to) {
1103
+ const contents = this.files.get(from);
1104
+ if (contents !== void 0) {
1105
+ const copy = typeof contents === "string" ? contents : contents.slice();
1106
+ this.files.delete(from);
1107
+ this.mkdirpSync(dirname(to));
1108
+ this.files.set(to, copy);
1109
+ return;
1110
+ }
1111
+ const prefix = from + "/";
1112
+ const moves = [];
1113
+ for (const [candidate, value] of this.files) {
1114
+ if (candidate.startsWith(prefix))
1115
+ moves.push([candidate, to + candidate.slice(from.length), value]);
1116
+ }
1117
+ for (const [source] of moves) this.files.delete(source);
1118
+ for (const [, destination, value] of moves) {
1119
+ this.mkdirpSync(dirname(destination));
1120
+ this.files.set(destination, value);
1121
+ }
1122
+ for (const candidate of [...this.folders]) {
1123
+ if (candidate === from || candidate.startsWith(prefix)) {
1124
+ this.folders.delete(candidate);
1125
+ this.folders.add(to + candidate.slice(from.length));
1126
+ }
1127
+ }
1128
+ this.mkdirpSync(to);
1129
+ }
1130
+ };
1131
+
1132
+ // src/routes/generated.ts
1133
+ var GENERATED_ROUTES = [
1134
+ {
1135
+ id: "GET /",
1136
+ method: "GET",
1137
+ path: "/",
654
1138
  tag: "Web",
655
1139
  summary: "Serve the web interface",
656
1140
  params: [],
@@ -1387,9 +1871,15 @@ var SASjsApi = (() => {
1387
1871
  summary: "Get a file from SASjs Drive",
1388
1872
  params: [
1389
1873
  {
1390
- name: "_filePath",
1874
+ name: "_filePath",
1875
+ in: "query",
1876
+ required: false,
1877
+ type: "string"
1878
+ },
1879
+ {
1880
+ name: "_FILE",
1391
1881
  in: "query",
1392
- required: true,
1882
+ required: false,
1393
1883
  type: "string"
1394
1884
  }
1395
1885
  ],
@@ -1399,9 +1889,13 @@ var SASjsApi = (() => {
1399
1889
  status: 200,
1400
1890
  description: "The contents of the file"
1401
1891
  },
1892
+ {
1893
+ status: 202,
1894
+ description: "A streamed file is not there: Parameter Error / File error"
1895
+ },
1402
1896
  {
1403
1897
  status: 400,
1404
- description: "Can't get file outside drive"
1898
+ description: "A path outside the drive, a refused extension, or a request naming neither or both"
1405
1899
  },
1406
1900
  {
1407
1901
  status: 404,
@@ -2836,12 +3330,11 @@ var SASjsApi = (() => {
2836
3330
  responses: { 200: "OK!" }
2837
3331
  },
2838
3332
  // Admin - the host's own process and files, over the reports it supplies.
2839
- // The administrator check is the host's mount point (sasjs/server puts
2840
- // authenticateAccessToken and verifyAdmin in front of all three), so its 401
2841
- // - and the 500 a genuine failure answers - are host-only statuses.
3333
+ // The administrator check is the package's, so its 401 is a case like any
3334
+ // other; the 500 a genuine failure answers stays the host's.
2842
3335
  "GET /SASjsApi/admin/diagnostics": {
2843
3336
  implemented: true,
2844
- hostResponses: [401, 500],
3337
+ hostResponses: [500],
2845
3338
  responses: {
2846
3339
  200: {
2847
3340
  build: { version: "", gitHash: "", buildDate: null },
@@ -2881,14 +3374,14 @@ var SASjsApi = (() => {
2881
3374
  },
2882
3375
  "GET /SASjsApi/admin/logs": {
2883
3376
  implemented: true,
2884
- hostResponses: [401, 500],
3377
+ hostResponses: [500],
2885
3378
  responses: { 200: { files: [] } }
2886
3379
  },
2887
3380
  "GET /SASjsApi/admin/logs/{fileName}": {
2888
3381
  implemented: true,
2889
3382
  // 400 and 404 are the name rule's, and this package answers them before the
2890
3383
  // host is asked for anything
2891
- hostResponses: [401, 500],
3384
+ hostResponses: [500],
2892
3385
  responses: {
2893
3386
  200: {
2894
3387
  fileName: "",
@@ -2967,7 +3460,16 @@ var SASjsApi = (() => {
2967
3460
  },
2968
3461
  // Drive - the file and folder rules, and the three deploy routes
2969
3462
  // The body is the file itself, so there is nothing to annotate
2970
- "GET /SASjsApi/drive/file": { implemented: true },
3463
+ // The `_FILE=` read needs one capability the plain drive read does not: a
3464
+ // host that serves a streamed deployment must supply the typed read, and one
3465
+ // that does not answers 501 naming it - which is what a capability is for.
3466
+ // (No route documents 501; the answer a host gives for a capability it lacks
3467
+ // is outside the contract, and this field is where the package says it may
3468
+ // happen.)
3469
+ "GET /SASjsApi/drive/file": {
3470
+ implemented: true,
3471
+ capabilities: ["storage", "deploymentFile"]
3472
+ },
2971
3473
  "POST /SASjsApi/drive/file": {
2972
3474
  implemented: true,
2973
3475
  responses: { 200: success, 409: "File already exists." }
@@ -5793,697 +6295,258 @@ var SASjsApi = (() => {
5793
6295
  createdBy: "string",
5794
6296
  creationTimeStamp: "string",
5795
6297
  id: "string",
5796
- links: [
5797
- {
5798
- href: "string",
5799
- method: "string",
5800
- rel: "string",
5801
- type: "string",
5802
- uri: "string"
5803
- }
5804
- ],
5805
- memberCount: "number",
5806
- modifiedBy: "string",
5807
- modifiedTimeStamp: "string",
5808
- name: "string",
5809
- parentFolderUri: "string",
5810
- type: "string",
5811
- version: "number"
5812
- }
5813
- },
5814
- {
5815
- route: "GET /folders/folders/{}",
5816
- step: "folders/delete",
5817
- queries: [],
5818
- statuses: [200],
5819
- expected: 200,
5820
- shape: {
5821
- createdBy: "string",
5822
- creationTimeStamp: "string",
5823
- description: "string",
5824
- id: "string",
5825
- links: [
5826
- {
5827
- href: "string",
5828
- method: "string",
5829
- rel: "string",
5830
- type: "string",
5831
- uri: "string"
5832
- }
5833
- ],
5834
- memberCount: "number",
5835
- modifiedBy: "string",
5836
- modifiedTimeStamp: "string",
5837
- name: "string",
5838
- parentFolderUri: "string",
5839
- properties: {
5840
- allowMove: "string"
5841
- },
5842
- type: "string",
5843
- version: "number"
5844
- }
5845
- },
5846
- {
5847
- route: "PATCH /folders/folders/{}",
5848
- step: "folders/delete",
5849
- queries: [],
5850
- statuses: [200],
5851
- expected: 200,
5852
- shape: {
5853
- createdBy: "string",
5854
- creationTimeStamp: "string",
5855
- id: "string",
5856
- links: [
5857
- {
5858
- href: "string",
5859
- method: "string",
5860
- rel: "string",
5861
- type: "string",
5862
- uri: "string"
5863
- }
5864
- ],
5865
- memberCount: "number",
5866
- modifiedBy: "string",
5867
- modifiedTimeStamp: "string",
5868
- name: "string",
5869
- parentFolderUri: "string",
5870
- type: "string",
5871
- version: "number"
5872
- }
5873
- },
5874
- {
5875
- route: "GET /folders/folders/{}/members",
5876
- step: "files/content",
5877
- queries: ["limit"],
5878
- statuses: [200],
5879
- expected: 200,
5880
- shape: {
5881
- accept: "string",
5882
- count: "number",
5883
- items: [
5884
- {
5885
- added: "string",
5886
- contentType: "string",
5887
- createdBy: "string",
5888
- creationTimeStamp: "string",
5889
- id: "string",
5890
- links: [
5891
- {
5892
- href: "string",
5893
- method: "string",
5894
- rel: "string",
5895
- type: "string",
5896
- uri: "string"
5897
- }
5898
- ],
5899
- modifiedBy: "string",
5900
- modifiedTimeStamp: "string",
5901
- name: "string",
5902
- parentFolderUri: "string",
5903
- type: "string",
5904
- uri: "string",
5905
- version: "number"
5906
- }
5907
- ],
5908
- limit: "number",
5909
- links: [
5910
- {
5911
- href: "string",
5912
- itemType: "string",
5913
- method: "string",
5914
- rel: "string",
5915
- type: "string",
5916
- uri: "string"
5917
- }
5918
- ],
5919
- name: "string",
5920
- start: "number",
5921
- version: "number"
5922
- }
5923
- },
5924
- {
5925
- route: "GET /folders/folders/@item",
5926
- step: "files/content",
5927
- queries: ["path"],
5928
- statuses: [200, 401, 404],
5929
- expected: 200,
5930
- shape: {
5931
- createdBy: "string",
5932
- creationTimeStamp: "string",
5933
- description: "string",
5934
- id: "string",
5935
- links: [
5936
- {
5937
- href: "string",
5938
- method: "string",
5939
- rel: "string",
5940
- type: "string",
5941
- uri: "string"
5942
- }
5943
- ],
5944
- memberCount: "number",
5945
- modifiedBy: "string",
5946
- modifiedTimeStamp: "string",
5947
- name: "string",
5948
- parentFolderUri: "string",
5949
- type: "string",
5950
- version: "number"
5951
- }
5952
- },
5953
- {
5954
- route: "GET /folders/folders/@myRecycleBin",
5955
- step: "folders/delete",
5956
- queries: [],
5957
- statuses: [200],
5958
- expected: 200,
5959
- shape: {
5960
- createdBy: "string",
5961
- creationTimeStamp: "string",
5962
- description: "string",
5963
- id: "string",
5964
- links: [
5965
- {
5966
- href: "string",
5967
- method: "string",
5968
- rel: "string",
5969
- type: "string",
5970
- uri: "string"
5971
- }
5972
- ],
5973
- memberCount: "number",
5974
- modifiedBy: "string",
5975
- modifiedTimeStamp: "string",
5976
- name: "string",
5977
- parentFolderUri: "string",
5978
- properties: {
5979
- allowMove: "string"
5980
- },
5981
- type: "string",
5982
- version: "number"
5983
- }
5984
- },
5985
- {
5986
- route: "GET /identities/users/@currentUser",
5987
- step: "identities/current-user",
5988
- queries: [],
5989
- statuses: [200],
5990
- expected: 200,
5991
- shape: {
5992
- addresses: [
5993
- {
5994
- locality: "string",
5995
- type: "string"
5996
- }
5997
- ],
5998
- emailAddresses: [
5999
- {
6000
- type: "string",
6001
- value: "string"
6002
- }
6003
- ],
6004
- id: "string",
6005
- links: [
6006
- {
6007
- href: "string",
6008
- method: "string",
6009
- rel: "string",
6010
- type: "string",
6011
- uri: "string"
6012
- }
6013
- ],
6014
- name: "string",
6015
- providerId: "string",
6016
- state: "string",
6017
- version: "number"
6018
- }
6019
- },
6020
- {
6021
- route: "POST /SASLogon/oauth/token",
6022
- step: "auth/token-refresh",
6023
- queries: [],
6024
- statuses: [200, 401],
6025
- expected: 200,
6026
- shape: {
6027
- access_token: "string",
6028
- expires_in: "number",
6029
- id_token: "string",
6030
- jti: "string",
6031
- refresh_expires_in: "number",
6032
- refresh_revocable: "boolean",
6033
- refresh_token: "string",
6034
- revocable: "boolean",
6035
- scope: "string",
6036
- token_type: "string"
6298
+ links: [
6299
+ {
6300
+ href: "string",
6301
+ method: "string",
6302
+ rel: "string",
6303
+ type: "string",
6304
+ uri: "string"
6305
+ }
6306
+ ],
6307
+ memberCount: "number",
6308
+ modifiedBy: "string",
6309
+ modifiedTimeStamp: "string",
6310
+ name: "string",
6311
+ parentFolderUri: "string",
6312
+ type: "string",
6313
+ version: "number"
6037
6314
  }
6038
6315
  },
6039
6316
  {
6040
- route: "GET /types/types",
6041
- step: "files/create",
6042
- queries: ["limit"],
6317
+ route: "GET /folders/folders/{}",
6318
+ step: "folders/delete",
6319
+ queries: [],
6043
6320
  statuses: [200],
6044
6321
  expected: 200,
6045
- shape: void 0
6046
- }
6047
- ];
6048
-
6049
- // src/appstream/identity.ts
6050
- var normaliseAppLoc = (appLoc) => {
6051
- if (typeof appLoc !== "string" || appLoc === "")
6052
- throw new Error(
6053
- `App location must be a non-empty string, got ${JSON.stringify(appLoc)}.`
6054
- );
6055
- const normalised = normaliseDrivePath(appLoc);
6056
- if (normalised === null)
6057
- throw new ApiError(400, "appLoc cannot be outside drive.");
6058
- return normalised;
6059
- };
6060
- var newAppId = () => {
6061
- const webCrypto = globalThis.crypto;
6062
- if (typeof webCrypto?.randomUUID === "function") return webCrypto.randomUUID();
6063
- if (typeof webCrypto?.getRandomValues !== "function")
6064
- throw new Error("No cryptographic source of randomness is available.");
6065
- const bytes3 = new Uint8Array(16);
6066
- webCrypto.getRandomValues(bytes3);
6067
- bytes3[6] = bytes3[6] & 15 | 64;
6068
- bytes3[8] = bytes3[8] & 63 | 128;
6069
- const hex = Array.from(bytes3).map((byte) => byte.toString(16).padStart(2, "0")).join("");
6070
- return [
6071
- hex.slice(0, 8),
6072
- hex.slice(8, 12),
6073
- hex.slice(12, 16),
6074
- hex.slice(16, 20),
6075
- hex.slice(20)
6076
- ].join("-");
6077
- };
6078
- var APP_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/;
6079
- var isAppId = (value) => typeof value === "string" && APP_ID.test(value);
6080
-
6081
- // src/appstream/service.ts
6082
- var APP_FOLDERS_ROOT = "apps";
6083
- var frontendFolderOf = (name) => `/${APP_FOLDERS_ROOT}/${name}`;
6084
- var appSummary = (entry) => ({
6085
- id: entry.id,
6086
- name: entry.name,
6087
- url: `/app/${entry.id}/`
6088
- });
6089
- var webFolderOf = (value) => {
6090
- if (typeof value !== "string" || value === "")
6091
- throw new ApiError(400, '"streamWebFolder" is required');
6092
- if (value === "." || value === ".." || /[\\/]/.test(value))
6093
- throw new ApiError(400, "streamWebFolder must be a single path segment.");
6094
- return value;
6095
- };
6096
- var defaultAppName = (appLoc) => {
6097
- const segment = appLoc.split("/").filter(Boolean).pop();
6098
- return segment ? segment : "app";
6099
- };
6100
- var sameAppLoc = (left, right) => {
6101
- try {
6102
- return normaliseAppLoc(left) === normaliseAppLoc(right);
6103
- } catch (_) {
6104
- return false;
6105
- }
6106
- };
6107
- var appLocOf = (value) => {
6108
- try {
6109
- return normaliseAppLoc(value);
6110
- } catch (error) {
6111
- throw new ApiError(400, error.message);
6112
- }
6113
- };
6114
- var hasStreamFolder = (tree, streamWebFolder) => {
6115
- const members = tree?.members;
6116
- if (!Array.isArray(members)) return false;
6117
- const isFolder = (member, name) => {
6118
- const entry = member;
6119
- return entry?.type === "folder" && entry?.name === name;
6120
- };
6121
- const services = members.find((member) => isFolder(member, "services"));
6122
- const children = services?.members;
6123
- return Array.isArray(children) && children.some((member) => isFolder(member, streamWebFolder));
6124
- };
6125
- var hasFrontendRoot = (tree) => {
6126
- const members = tree?.members;
6127
- if (!Array.isArray(members)) return false;
6128
- return members.some((member) => {
6129
- const entry = member;
6130
- return entry?.type === "file" && entry?.name === "index.html";
6131
- });
6132
- };
6133
- var checkPublishRequest = (request, tree, options = {}) => {
6134
- const logo = logoOf(request.logo);
6135
- const frameAncestors = frameAncestorsOf(request.frameAncestors);
6136
- const timing = request.publishedAt === void 0 ? {} : { publishedAt: request.publishedAt };
6137
- if (request.streamWebFolder !== void 0) {
6138
- if (request.appLoc === void 0)
6139
- throw new ApiError(
6140
- 400,
6141
- '"appLoc" is required when "streamWebFolder" is stated: the entry keeps its web assets at <appLoc>/services/<streamWebFolder>, so both halves are needed to say where they are.'
6142
- );
6143
- const appLoc2 = appLocOf(request.appLoc);
6144
- if (appLoc2 === "/")
6145
- throw new ApiError(400, "An app cannot be published at the drive root.");
6146
- const streamWebFolder = webFolderOf(request.streamWebFolder);
6147
- if (tree !== void 0 && !hasStreamFolder(tree, streamWebFolder))
6148
- throw new ApiError(
6149
- 400,
6150
- `The deployed tree has no "services/${streamWebFolder}" folder, so nothing would be published at ${appLoc2}. Deploy the web assets under services/${streamWebFolder}, or ${options.folderFromManifest ? "correct the folder sasjs.app.json names." : "omit streamWebFolder."}`
6151
- );
6152
- return {
6153
- appLoc: appLoc2,
6154
- streamWebFolder,
6155
- ...request.name === void 0 ? {} : { name: nameOf(request.name) },
6156
- ...logo === void 0 ? {} : { logo },
6157
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6158
- ...timing
6159
- };
6160
- }
6161
- if (request.name === void 0)
6162
- throw new ApiError(
6163
- 400,
6164
- '"name" is required: an app is published at apps/<name>, so the publish has to say what it is called.'
6165
- );
6166
- const name = nameOf(request.name);
6167
- const appLoc = request.appLoc === void 0 ? void 0 : appLocOf(request.appLoc);
6168
- if (appLoc === "/")
6169
- throw new ApiError(400, "An app cannot name the drive root as its backend.");
6170
- if (tree !== void 0 && !hasFrontendRoot(tree))
6171
- throw new ApiError(
6172
- 400,
6173
- `The deployed tree has no "index.html" at its root, so nothing would be published at apps/${name}. Publish the compiled web folder itself, not the folder that holds it.`
6174
- );
6175
- return {
6176
- name,
6177
- ...appLoc === void 0 ? {} : { appLoc },
6178
- ...logo === void 0 ? {} : { logo },
6179
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6180
- ...timing
6181
- };
6182
- };
6183
- var nameOf = (value) => {
6184
- if (typeof value !== "string" || value.trim() === "")
6185
- throw new ApiError(400, '"name" must be a non-empty string');
6186
- return urlSafeName(value.trim());
6187
- };
6188
- var NAME_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._~-]*$/;
6189
- var NAME_MAX_LENGTH = 64;
6190
- var RESERVED_NAMES = ["apps.json", "index.html"];
6191
- var urlSafeName = (name) => {
6192
- if (name.length > NAME_MAX_LENGTH)
6193
- throw new ApiError(
6194
- 400,
6195
- `"name" must be at most ${NAME_MAX_LENGTH} characters, and "${name}" is ${name.length}.`
6196
- );
6197
- if (!NAME_PATTERN.test(name))
6198
- throw new ApiError(
6199
- 400,
6200
- `"name" must be usable as a URL segment - letters, digits, dot, dash, underscore or tilde, starting with a letter or digit - so "/app/${name}" can be opened. "${name}" is not, because it carries a character that has to be percent-encoded, or a space.`
6201
- );
6202
- if (RESERVED_NAMES.includes(name.toLowerCase()))
6203
- throw new ApiError(
6204
- 400,
6205
- `"name" cannot be "${name}": the App Stream answers /app/${name} itself, so an app with that name could never be opened by name.`
6206
- );
6207
- return name;
6208
- };
6209
- var logoOf = (value) => {
6210
- if (value === void 0) return void 0;
6211
- if (typeof value !== "string" || value === "")
6212
- throw new ApiError(400, '"logo" must be a non-empty string');
6213
- return value;
6214
- };
6215
- var frameAncestorsOf = (value) => {
6216
- if (value === void 0) return void 0;
6217
- const list = Array.isArray(value) ? value : [value];
6218
- if (list.length === 0 || list.some((source) => typeof source !== "string" || source === ""))
6219
- throw new ApiError(
6220
- 400,
6221
- '"frameAncestors" must be a string or a non-empty list of strings'
6222
- );
6223
- return [...list];
6224
- };
6225
- var createAppStreamService = (store) => {
6226
- let queue = Promise.resolve();
6227
- const mutate = (work) => {
6228
- const run = queue.then(work, work);
6229
- queue = run.catch(() => void 0);
6230
- return run;
6231
- };
6232
- const readable = (allow) => store.read().then(
6233
- (entries) => entries.filter((entry) => allow ? allow(entry) : true).map((entry) => ({ ...entry })).sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0)
6234
- );
6235
- return {
6236
- list: readable,
6237
- async get(id) {
6238
- const entry = (await store.read()).find(
6239
- (candidate) => candidate.id === id
6240
- );
6241
- if (!entry) throw new ApiError(404, "No app is published with that id.");
6242
- return { ...entry };
6243
- },
6244
- async forAppLoc(appLoc) {
6245
- let normalised;
6246
- try {
6247
- normalised = normaliseAppLoc(appLoc);
6248
- } catch (_) {
6249
- return void 0;
6250
- }
6251
- const entry = (await store.read()).find(
6252
- (candidate) => candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, normalised)
6253
- );
6254
- return entry ? { ...entry } : void 0;
6255
- },
6256
- publish(request) {
6257
- return mutate(async () => {
6258
- const checked = checkPublishRequest(request);
6259
- const entries = await store.read();
6260
- const legacy = checked.streamWebFolder !== void 0;
6261
- const sameTarget = (candidate) => legacy ? candidate.streamWebFolder !== void 0 && candidate.appLoc !== void 0 && sameAppLoc(candidate.appLoc, checked.appLoc) : candidate.streamWebFolder === void 0 && candidate.name === checked.name;
6262
- const existing = entries.find(sameTarget);
6263
- const logo = checked.logo;
6264
- const frameAncestors = checked.frameAncestors;
6265
- const name = legacy ? checked.name ?? existing?.name ?? defaultAppName(checked.appLoc) : checked.name;
6266
- if (!legacy || checked.name !== void 0) {
6267
- const clash = entries.find(
6268
- (candidate) => candidate !== existing && candidate.name.toLowerCase() === name.toLowerCase()
6269
- );
6270
- if (clash)
6271
- throw new ApiError(
6272
- 409,
6273
- `The name "${name}" is already the address of the app at ${clash.appLoc ?? frontendFolderOf(clash.name)}. An app's name is how it opens (/app/${name}), and two apps holding one name would answer an ambiguous lookup with nothing, so publish this one under a different name.`
6274
- );
6322
+ shape: {
6323
+ createdBy: "string",
6324
+ creationTimeStamp: "string",
6325
+ description: "string",
6326
+ id: "string",
6327
+ links: [
6328
+ {
6329
+ href: "string",
6330
+ method: "string",
6331
+ rel: "string",
6332
+ type: "string",
6333
+ uri: "string"
6275
6334
  }
6276
- const entry = {
6277
- id: existing ? existing.id : newAppId(),
6278
- // the label is the one field a redeploy inherits: everything else is
6279
- // what this publish states
6280
- name,
6281
- ...checked.appLoc === void 0 ? {} : { appLoc: checked.appLoc },
6282
- ...checked.streamWebFolder === void 0 ? {} : { streamWebFolder: checked.streamWebFolder },
6283
- ...logo === void 0 ? {} : { logo },
6284
- ...frameAncestors === void 0 ? {} : { frameAncestors },
6285
- publishedAt: checked.publishedAt ?? (/* @__PURE__ */ new Date()).toISOString()
6286
- };
6287
- await store.write([
6288
- ...entries.filter((candidate) => !sameTarget(candidate)),
6289
- entry
6290
- ]);
6291
- return { ...entry };
6292
- });
6293
- },
6294
- unpublish(id) {
6295
- return mutate(async () => {
6296
- const entries = await store.read();
6297
- const index = entries.findIndex((entry) => entry.id === id);
6298
- if (index === -1)
6299
- throw new ApiError(404, "No app is published with that id.");
6300
- const [removed] = entries.splice(index, 1);
6301
- await store.write(entries);
6302
- return { ...removed };
6303
- });
6335
+ ],
6336
+ memberCount: "number",
6337
+ modifiedBy: "string",
6338
+ modifiedTimeStamp: "string",
6339
+ name: "string",
6340
+ parentFolderUri: "string",
6341
+ properties: {
6342
+ allowMove: "string"
6343
+ },
6344
+ type: "string",
6345
+ version: "number"
6304
6346
  }
6305
- };
6306
- };
6307
- var MemoryAppStreamStore = class {
6308
- constructor(entries = []) {
6309
- this.entries = entries.map((entry) => ({ ...entry }));
6310
- }
6311
- async read() {
6312
- return this.entries.map((entry) => ({ ...entry }));
6313
- }
6314
- async write(entries) {
6315
- this.entries = entries.map((entry) => ({ ...entry }));
6316
- }
6317
- };
6318
-
6319
- // src/appstream/web.ts
6320
- var DEFAULT_APP_PATH = "/app";
6321
- var NO_SUCH_APP = "There's no App Stream available here.";
6322
- var ESCAPES = {
6323
- "&": "&amp;",
6324
- "<": "&lt;",
6325
- ">": "&gt;",
6326
- '"': "&quot;",
6327
- "'": "&#39;"
6328
- };
6329
- var escapeHtml = (value) => value.replace(/[&<>"']/g, (character) => ESCAPES[character]);
6330
- var CONTENT_TYPES = {
6331
- html: "text/html; charset=utf-8",
6332
- htm: "text/html; charset=utf-8",
6333
- js: "text/javascript; charset=utf-8",
6334
- mjs: "text/javascript; charset=utf-8",
6335
- css: "text/css; charset=utf-8",
6336
- json: "application/json; charset=utf-8",
6337
- map: "application/json; charset=utf-8",
6338
- txt: "text/plain; charset=utf-8",
6339
- svg: "image/svg+xml",
6340
- png: "image/png",
6341
- jpg: "image/jpeg",
6342
- jpeg: "image/jpeg",
6343
- gif: "image/gif",
6344
- webp: "image/webp",
6345
- ico: "image/x-icon",
6346
- woff: "font/woff",
6347
- woff2: "font/woff2",
6348
- ttf: "font/ttf",
6349
- otf: "font/otf",
6350
- wasm: "application/wasm",
6351
- pdf: "application/pdf",
6352
- zip: "application/zip"
6353
- };
6354
- var contentTypeFor = (filePath2) => {
6355
- const extension = filePath2.slice(filePath2.lastIndexOf(".") + 1).toLowerCase();
6356
- return CONTENT_TYPES[extension] ?? "application/octet-stream";
6357
- };
6358
- var cacheControlFor = (filePath2) => /\.[0-9a-f]{8,}\.[A-Za-z0-9]+$/.test(filePath2) ? "public, max-age=31536000, immutable" : "public, max-age=0, must-revalidate";
6359
- var html = (status, markup) => ({
6360
- status,
6361
- body: markup,
6362
- contentType: "text/html; charset=utf-8"
6363
- });
6364
- var json = (status, body) => ({
6365
- status,
6366
- body: JSON.stringify(body),
6367
- contentType: "application/json; charset=utf-8"
6368
- });
6369
- var noSuchApp = () => html(404, `<!doctype html><html><body>${NO_SUCH_APP}</body></html>`);
6370
- var methodNotAllowed = (allowed) => ({
6371
- status: 405,
6372
- body: JSON.stringify({ status: "failure", message: `${allowed} only.` }),
6373
- contentType: "application/json; charset=utf-8",
6374
- headers: { allow: allowed }
6375
- });
6376
- var decoded = (segment) => {
6377
- try {
6378
- return decodeURIComponent(segment);
6379
- } catch (_) {
6380
- return void 0;
6381
- }
6382
- };
6383
- var appRootOf = (entry) => entry.streamWebFolder !== void 0 && entry.appLoc !== void 0 ? `${entry.appLoc}/services/${entry.streamWebFolder}` : frontendFolderOf(entry.name);
6384
- var createAppStreamWebService = (appStream, drive, options = {}) => {
6385
- const base = (options.basePath ?? DEFAULT_APP_PATH).replace(/\/+$/, "");
6386
- const title = options.title ?? "SASjs App Stream";
6387
- const urlOf = (entry) => `${base}/${entry.id}/`;
6388
- const rowOf = (entry) => ({
6389
- id: entry.id,
6390
- name: entry.name,
6391
- appLoc: entry.appLoc ?? null,
6392
- logo: entry.logo === void 0 ? null : `${urlOf(entry)}${entry.logo}`,
6393
- url: urlOf(entry),
6394
- publishedAt: entry.publishedAt ?? null
6395
- });
6396
- const apps = async (allow) => {
6397
- const entries = await appStream.list(allow);
6398
- return { apps: entries.map(rowOf) };
6399
- };
6400
- const landing = async (allow) => {
6401
- const { apps: rows } = await apps(allow);
6402
- const tiles = rows.length ? `<ul class="apps">${rows.map(
6403
- (row) => `<li><a href="${escapeHtml(row.url)}">${escapeHtml(row.name)}</a><span class="loc">${escapeHtml(
6404
- row.appLoc ?? frontendFolderOf(row.name)
6405
- )}</span></li>`
6406
- ).join("")}</ul>` : '<p class="empty">No apps have been published yet.</p>';
6407
- return html(
6408
- 200,
6409
- [
6410
- '<!doctype html><html lang="en"><head><meta charset="utf-8">',
6411
- '<meta name="viewport" content="width=device-width,initial-scale=1">',
6412
- `<title>${escapeHtml(title)}</title>`,
6413
- "<style>",
6414
- "body{font-family:system-ui,sans-serif;margin:2rem;color:#1f2430}",
6415
- "h1{font-size:1.4rem}",
6416
- "ul.apps{list-style:none;padding:0;display:grid;gap:.75rem;max-width:40rem}",
6417
- "ul.apps li{display:flex;flex-direction:column;gap:.15rem;padding:.75rem 1rem;",
6418
- "border:1px solid #d8dee9;border-radius:.5rem}",
6419
- "ul.apps a{font-weight:600;text-decoration:none;color:#0b5cad}",
6420
- ".loc{font-size:.8rem;color:#5b6472;font-family:ui-monospace,monospace}",
6421
- ".empty{color:#5b6472}",
6422
- "</style></head><body>",
6423
- `<h1>${escapeHtml(title)}</h1>`,
6424
- tiles,
6425
- "</body></html>"
6426
- ].join("")
6427
- );
6428
- };
6429
- const resolve = async (segment, allow) => {
6430
- const entries = await appStream.list(allow);
6431
- const byId2 = entries.find((entry) => entry.id === segment);
6432
- if (byId2) return byId2;
6433
- const byName = entries.filter((entry) => entry.name === segment);
6434
- return byName.length === 1 ? byName[0] : void 0;
6435
- };
6436
- const asset = async (entry, segments) => {
6437
- const parts = segments.map(decoded);
6438
- if (parts.some((part) => part === void 0)) return noSuchApp();
6439
- const relative = parts.join("/") || "index.html";
6440
- try {
6441
- const file = await drive.read(`${appRootOf(entry)}/${relative}`);
6442
- return {
6443
- status: 200,
6444
- body: file.contents,
6445
- contentType: contentTypeFor(relative),
6446
- headers: { "cache-control": cacheControlFor(relative) }
6447
- };
6448
- } catch (error) {
6449
- if (error instanceof ApiError && (error.status === 404 || error.status === 400))
6450
- return noSuchApp();
6451
- throw error;
6347
+ },
6348
+ {
6349
+ route: "PATCH /folders/folders/{}",
6350
+ step: "folders/delete",
6351
+ queries: [],
6352
+ statuses: [200],
6353
+ expected: 200,
6354
+ shape: {
6355
+ createdBy: "string",
6356
+ creationTimeStamp: "string",
6357
+ id: "string",
6358
+ links: [
6359
+ {
6360
+ href: "string",
6361
+ method: "string",
6362
+ rel: "string",
6363
+ type: "string",
6364
+ uri: "string"
6365
+ }
6366
+ ],
6367
+ memberCount: "number",
6368
+ modifiedBy: "string",
6369
+ modifiedTimeStamp: "string",
6370
+ name: "string",
6371
+ parentFolderUri: "string",
6372
+ type: "string",
6373
+ version: "number"
6374
+ }
6375
+ },
6376
+ {
6377
+ route: "GET /folders/folders/{}/members",
6378
+ step: "files/content",
6379
+ queries: ["limit"],
6380
+ statuses: [200],
6381
+ expected: 200,
6382
+ shape: {
6383
+ accept: "string",
6384
+ count: "number",
6385
+ items: [
6386
+ {
6387
+ added: "string",
6388
+ contentType: "string",
6389
+ createdBy: "string",
6390
+ creationTimeStamp: "string",
6391
+ id: "string",
6392
+ links: [
6393
+ {
6394
+ href: "string",
6395
+ method: "string",
6396
+ rel: "string",
6397
+ type: "string",
6398
+ uri: "string"
6399
+ }
6400
+ ],
6401
+ modifiedBy: "string",
6402
+ modifiedTimeStamp: "string",
6403
+ name: "string",
6404
+ parentFolderUri: "string",
6405
+ type: "string",
6406
+ uri: "string",
6407
+ version: "number"
6408
+ }
6409
+ ],
6410
+ limit: "number",
6411
+ links: [
6412
+ {
6413
+ href: "string",
6414
+ itemType: "string",
6415
+ method: "string",
6416
+ rel: "string",
6417
+ type: "string",
6418
+ uri: "string"
6419
+ }
6420
+ ],
6421
+ name: "string",
6422
+ start: "number",
6423
+ version: "number"
6452
6424
  }
6453
- };
6454
- return {
6455
- apps,
6456
- landing,
6457
- async request({ method, path, allow }) {
6458
- const clean = (path.split(/[?#]/)[0] || "/").replace(/\/{2,}/g, "/");
6459
- const relative = base === "" ? clean : clean === base ? "/" : clean.startsWith(`${base}/`) ? clean.slice(base.length) : null;
6460
- if (relative === null) return noSuchApp();
6461
- if (relative === "" || relative === "/" || relative === "/index.html") {
6462
- if (method !== "GET") return methodNotAllowed("GET");
6463
- return landing(allow);
6464
- }
6465
- if (relative === "/apps.json") {
6466
- if (method !== "GET") return methodNotAllowed("GET");
6467
- return json(200, await apps(allow));
6468
- }
6469
- const segments = relative.split("/").filter(Boolean);
6470
- const key = decoded(segments[0]);
6471
- if (key === void 0) return noSuchApp();
6472
- if (method === "DELETE") {
6473
- const entry2 = await resolve(key, allow);
6474
- if (!entry2) return noSuchApp();
6475
- const removed = await appStream.unpublish(entry2.id);
6476
- return json(200, { status: "success", app: rowOf(removed) });
6477
- }
6478
- if (method !== "GET") return methodNotAllowed("GET, DELETE");
6479
- const entry = await resolve(key, allow);
6480
- if (!entry) return noSuchApp();
6481
- if (segments.length === 1 && !relative.endsWith("/"))
6482
- return { status: 301, location: urlOf(entry) };
6483
- return asset(entry, segments.slice(1));
6425
+ },
6426
+ {
6427
+ route: "GET /folders/folders/@item",
6428
+ step: "files/content",
6429
+ queries: ["path"],
6430
+ statuses: [200, 401, 404],
6431
+ expected: 200,
6432
+ shape: {
6433
+ createdBy: "string",
6434
+ creationTimeStamp: "string",
6435
+ description: "string",
6436
+ id: "string",
6437
+ links: [
6438
+ {
6439
+ href: "string",
6440
+ method: "string",
6441
+ rel: "string",
6442
+ type: "string",
6443
+ uri: "string"
6444
+ }
6445
+ ],
6446
+ memberCount: "number",
6447
+ modifiedBy: "string",
6448
+ modifiedTimeStamp: "string",
6449
+ name: "string",
6450
+ parentFolderUri: "string",
6451
+ type: "string",
6452
+ version: "number"
6484
6453
  }
6485
- };
6486
- };
6454
+ },
6455
+ {
6456
+ route: "GET /folders/folders/@myRecycleBin",
6457
+ step: "folders/delete",
6458
+ queries: [],
6459
+ statuses: [200],
6460
+ expected: 200,
6461
+ shape: {
6462
+ createdBy: "string",
6463
+ creationTimeStamp: "string",
6464
+ description: "string",
6465
+ id: "string",
6466
+ links: [
6467
+ {
6468
+ href: "string",
6469
+ method: "string",
6470
+ rel: "string",
6471
+ type: "string",
6472
+ uri: "string"
6473
+ }
6474
+ ],
6475
+ memberCount: "number",
6476
+ modifiedBy: "string",
6477
+ modifiedTimeStamp: "string",
6478
+ name: "string",
6479
+ parentFolderUri: "string",
6480
+ properties: {
6481
+ allowMove: "string"
6482
+ },
6483
+ type: "string",
6484
+ version: "number"
6485
+ }
6486
+ },
6487
+ {
6488
+ route: "GET /identities/users/@currentUser",
6489
+ step: "identities/current-user",
6490
+ queries: [],
6491
+ statuses: [200],
6492
+ expected: 200,
6493
+ shape: {
6494
+ addresses: [
6495
+ {
6496
+ locality: "string",
6497
+ type: "string"
6498
+ }
6499
+ ],
6500
+ emailAddresses: [
6501
+ {
6502
+ type: "string",
6503
+ value: "string"
6504
+ }
6505
+ ],
6506
+ id: "string",
6507
+ links: [
6508
+ {
6509
+ href: "string",
6510
+ method: "string",
6511
+ rel: "string",
6512
+ type: "string",
6513
+ uri: "string"
6514
+ }
6515
+ ],
6516
+ name: "string",
6517
+ providerId: "string",
6518
+ state: "string",
6519
+ version: "number"
6520
+ }
6521
+ },
6522
+ {
6523
+ route: "POST /SASLogon/oauth/token",
6524
+ step: "auth/token-refresh",
6525
+ queries: [],
6526
+ statuses: [200, 401],
6527
+ expected: 200,
6528
+ shape: {
6529
+ access_token: "string",
6530
+ expires_in: "number",
6531
+ id_token: "string",
6532
+ jti: "string",
6533
+ refresh_expires_in: "number",
6534
+ refresh_revocable: "boolean",
6535
+ refresh_token: "string",
6536
+ revocable: "boolean",
6537
+ scope: "string",
6538
+ token_type: "string"
6539
+ }
6540
+ },
6541
+ {
6542
+ route: "GET /types/types",
6543
+ step: "files/create",
6544
+ queries: ["limit"],
6545
+ statuses: [200],
6546
+ expected: 200,
6547
+ shape: void 0
6548
+ }
6549
+ ];
6487
6550
 
6488
6551
  // src/appstream/bundle.ts
6489
6552
  var APP_MANIFEST = "sasjs.app.json";
@@ -6607,6 +6670,16 @@ var SASjsApi = (() => {
6607
6670
  "POST /SASjsApi/code/execute",
6608
6671
  "POST /SASjsApi/code/trigger"
6609
6672
  ];
6673
+ var GRANTED_RUN_ROUTES = [
6674
+ "GET /SASjsApi/stp/execute",
6675
+ "POST /SASjsApi/stp/execute",
6676
+ "POST /SASjsApi/code/execute"
6677
+ ];
6678
+ var ADMIN_ROUTES = [
6679
+ "GET /SASjsApi/admin/diagnostics",
6680
+ "GET /SASjsApi/admin/logs",
6681
+ "GET /SASjsApi/admin/logs/{fileName}"
6682
+ ];
6610
6683
  var given = (value) => typeof value === "string" && value !== "" ? value : void 0;
6611
6684
  var replaceOf = (value) => {
6612
6685
  if (value === void 0 || value === "") return void 0;
@@ -6647,9 +6720,25 @@ var SASjsApi = (() => {
6647
6720
  const { drive, identity, records, code } = services;
6648
6721
  const identityScoped = ["User", "Group", "Permission", "Client"].includes(route.tag) || routeId === "PATCH /SASjsApi/auth/updatePassword";
6649
6722
  const runtimeScoped = RUN_ROUTES.includes(routeId);
6650
- if (identityScoped && records || runtimeScoped && services.runtime) {
6651
- const subject = request.subject ?? (identity ? await identity.authenticate(request.token) : void 0);
6652
- if (!subject) {
6723
+ const adminScoped = ADMIN_ROUTES.includes(routeId) && Boolean(services.admin);
6724
+ const grantScoped = Boolean(records) && GRANTED_RUN_ROUTES.includes(routeId);
6725
+ if (adminScoped && !records)
6726
+ throw new ApiError(
6727
+ 501,
6728
+ `This host has no record service, so it cannot answer ${routeId}.`
6729
+ );
6730
+ let subject = request.subject;
6731
+ let subjectResolved = Boolean(request.subject);
6732
+ const caller = async () => {
6733
+ if (!subjectResolved) {
6734
+ subject = identity ? await identity.authenticate(request.token) : void 0;
6735
+ subjectResolved = true;
6736
+ }
6737
+ return subject;
6738
+ };
6739
+ if (identityScoped && records || runtimeScoped && services.runtime || adminScoped || grantScoped) {
6740
+ const callerSubject = await caller();
6741
+ if (!callerSubject) {
6653
6742
  if (!identity)
6654
6743
  throw new ApiError(
6655
6744
  501,
@@ -6657,6 +6746,13 @@ var SASjsApi = (() => {
6657
6746
  );
6658
6747
  throw new ApiError(401, "Unauthorized");
6659
6748
  }
6749
+ if (adminScoped && !await records.mayAdminister(callerSubject)) {
6750
+ if (!await records.mayAct(callerSubject))
6751
+ throw new ApiError(401, "Unauthorized");
6752
+ throw new ApiError(401, "Admin account required");
6753
+ }
6754
+ if (grantScoped && !await records.mayUseRoute(callerSubject, route.path))
6755
+ throw new ApiError(401, "Unauthorized");
6660
6756
  }
6661
6757
  validate(route, request);
6662
6758
  const query = request.query || {};
@@ -6698,10 +6794,6 @@ var SASjsApi = (() => {
6698
6794
  );
6699
6795
  return records;
6700
6796
  };
6701
- const caller = async () => {
6702
- if (request.subject) return request.subject;
6703
- return identity?.authenticate(request.token);
6704
- };
6705
6797
  if (routeId.startsWith("POST /SASjsApi/auth/") || routeId.startsWith("POST /SASLogon/") || routeId === "GET /SASLogon/logout" || routeId === "GET /SASjsApi/session") {
6706
6798
  if (!identity)
6707
6799
  throw new ApiError(
@@ -6770,10 +6862,11 @@ var SASjsApi = (() => {
6770
6862
  }
6771
6863
  // ------------------------------------------------- a host's own reports
6772
6864
  //
6773
- // The administrator middleware is the host's (sasjs/server mounts
6774
- // authenticateAccessToken and verifyAdmin ahead of all of these), which is
6775
- // why their 401 is marked host-only in the overlay. The package answers a
6776
- // body, and for a log tail the refusals that belong to the name rule.
6865
+ // The administrator check is the package's, from the caller the transport
6866
+ // resolved: `mayAdminister` is the decision `verifyAdmin` makes on a server,
6867
+ // asked here so a browser host that supplies these reports cannot serve them
6868
+ // to anyone who asks. What stays the host's is the body, and for a log tail
6869
+ // the refusals that belong to the name rule.
6777
6870
  case "GET /SASjsApi/admin/diagnostics": {
6778
6871
  if (!services.admin)
6779
6872
  throw new ApiError(
@@ -6821,7 +6914,24 @@ var SASjsApi = (() => {
6821
6914
  return { status: 200, body: await services.directory.synchronise() };
6822
6915
  }
6823
6916
  case "GET /SASjsApi/drive/file": {
6824
- const file = await drive.read(String(query._filePath || ""));
6917
+ assertOneFileName(query);
6918
+ if (query._FILE !== void 0) {
6919
+ if (!services.deploymentFile)
6920
+ throw new ApiError(
6921
+ 501,
6922
+ `This host has no deployment-file service, so it cannot answer ${routeId}.`
6923
+ );
6924
+ const page = await services.deploymentFile.read(String(query._FILE));
6925
+ return {
6926
+ status: page.status,
6927
+ contents: page.body,
6928
+ contentType: page.contentType,
6929
+ headers: page.headers
6930
+ };
6931
+ }
6932
+ if (query._filePath === void 0)
6933
+ throw new ApiError(400, '"_filePath" is required');
6934
+ const file = await drive.read(String(query._filePath));
6825
6935
  return { status: 200, contents: file.contents };
6826
6936
  }
6827
6937
  case "POST /SASjsApi/drive/file":
@@ -7485,10 +7595,14 @@ var SASjsApi = (() => {
7485
7595
  var ALL_USERS_GROUP = "all-users";
7486
7596
  var PUBLIC_GROUP = "public";
7487
7597
  var unauthorized2 = () => new ApiError(401, "Unauthorized");
7488
- var requireCaller = async (store, caller) => {
7489
- if (!caller) throw unauthorized2();
7598
+ var readerOf = async (store, caller) => {
7599
+ if (!caller) return void 0;
7490
7600
  const user3 = await store.userById(caller.userId);
7491
- if (!user3 || !user3.isActive) throw unauthorized2();
7601
+ return user3 && user3.isActive ? user3 : void 0;
7602
+ };
7603
+ var requireCaller = async (store, caller) => {
7604
+ const user3 = await readerOf(store, caller);
7605
+ if (!user3) throw unauthorized2();
7492
7606
  return user3;
7493
7607
  };
7494
7608
  var requireAdmin = async (store, caller) => {
@@ -7517,6 +7631,25 @@ var SASjsApi = (() => {
7517
7631
  });
7518
7632
  var createRecordService = (store, options = {}) => {
7519
7633
  const grantableRoutes = options.grantableRoutes || DEFAULT_GRANTABLE_ROUTES;
7634
+ const grantedRoutesFor = async (reader) => {
7635
+ if (reader.isAdmin) return new Set(grantableRoutes);
7636
+ const rules = await store.permissions();
7637
+ const mine = {
7638
+ user: rules.filter((rule) => rule.user === reader.uid).map((rule) => ({ path: rule.path, setting: rule.setting })),
7639
+ group: rules.filter(
7640
+ (rule) => rule.group !== void 0 && reader.groups.includes(rule.group)
7641
+ ).map((rule) => ({ path: rule.path, setting: rule.setting }))
7642
+ };
7643
+ const publicGroup = rules.some((rule) => rule.group !== void 0) ? (await store.groups()).find((group) => group.name === PUBLIC_GROUP) : void 0;
7644
+ const publicGrants = publicGroup ? rules.filter(
7645
+ (rule) => rule.group === publicGroup.uid && rule.setting === "Grant"
7646
+ ).map((rule) => rule.path) : [];
7647
+ return new Set(
7648
+ grantableRoutes.filter(
7649
+ (path) => ALWAYS_VISIBLE_ROUTES.includes(path) || publicGrants.includes(path) || isRouteGranted(mine, path, topLevelRouteFor(path))
7650
+ )
7651
+ );
7652
+ };
7520
7653
  const groupDetails = async (group) => {
7521
7654
  const members = [];
7522
7655
  for (const uid of group.users) {
@@ -7710,25 +7843,22 @@ var SASjsApi = (() => {
7710
7843
  },
7711
7844
  async myAuthorizedRoutes(caller) {
7712
7845
  const reader = await requireCaller(store, caller);
7713
- if (reader.isAdmin) return { paths: [...grantableRoutes] };
7714
- const rules = await store.permissions();
7715
- const mine = {
7716
- user: rules.filter((rule) => rule.user === reader.uid).map((rule) => ({ path: rule.path, setting: rule.setting })),
7717
- group: rules.filter(
7718
- (rule) => rule.group !== void 0 && reader.groups.includes(rule.group)
7719
- ).map((rule) => ({ path: rule.path, setting: rule.setting }))
7720
- };
7721
- const publicGroup = (await store.groups()).find(
7722
- (group) => group.name === "public"
7723
- );
7724
- const publicGrants = publicGroup ? rules.filter(
7725
- (rule) => rule.group === publicGroup.uid && rule.setting === "Grant"
7726
- ).map((rule) => rule.path) : [];
7727
- return {
7728
- paths: grantableRoutes.filter(
7729
- (path) => ALWAYS_VISIBLE_ROUTES.includes(path) || publicGrants.includes(path) || isRouteGranted(mine, path, topLevelRouteFor(path))
7730
- )
7731
- };
7846
+ const granted = await grantedRoutesFor(reader);
7847
+ return { paths: grantableRoutes.filter((path) => granted.has(path)) };
7848
+ },
7849
+ async mayAdminister(caller) {
7850
+ const reader = await readerOf(store, caller);
7851
+ return Boolean(reader?.isAdmin);
7852
+ },
7853
+ async mayAct(caller) {
7854
+ return Boolean(await readerOf(store, caller));
7855
+ },
7856
+ async mayUseRoute(caller, path) {
7857
+ const reader = await readerOf(store, caller);
7858
+ if (!reader) return false;
7859
+ if (reader.isAdmin) return true;
7860
+ const granted = await grantedRoutesFor(reader);
7861
+ return granted.has(path);
7732
7862
  },
7733
7863
  async listPermissions(caller) {
7734
7864
  const reader = await requireCaller(store, caller);
@@ -7988,41 +8118,71 @@ var SASjsApi = (() => {
7988
8118
  newestModified: CORPUS_LOG.modified
7989
8119
  }
7990
8120
  };
8121
+ var ADMIN = { userId: "user-admin", clientId: "web_app" };
8122
+ var RESTRICTED = { userId: "user-restricted", clientId: "web_app" };
7991
8123
  var ADMIN_CORPUS = [
7992
8124
  {
7993
8125
  id: "admin-diagnostics-answers-the-report",
7994
8126
  route: "GET /SASjsApi/admin/diagnostics",
7995
8127
  description: "answers the host diagnostics report field for field",
7996
- request: {},
8128
+ request: { subject: ADMIN },
7997
8129
  expect: { status: 200, body: CORPUS_DIAGNOSTICS }
7998
8130
  },
7999
8131
  {
8000
8132
  id: "admin-logs-lists-the-files",
8001
8133
  route: "GET /SASjsApi/admin/logs",
8002
8134
  description: "answers the log files the host holds, newest first",
8003
- request: {},
8135
+ request: { subject: ADMIN },
8004
8136
  expect: { status: 200, body: { files: [CORPUS_LOG] } }
8005
8137
  },
8006
8138
  {
8007
8139
  id: "admin-log-tail-answers-the-tail",
8008
8140
  route: "GET /SASjsApi/admin/logs/{fileName}",
8009
8141
  description: "answers the tail of a log the folder holds",
8010
- request: { params: { fileName: CORPUS_LOG.name } },
8142
+ request: { subject: ADMIN, params: { fileName: CORPUS_LOG.name } },
8011
8143
  expect: { status: 200, body: CORPUS_LOG_TAIL }
8012
8144
  },
8013
8145
  {
8014
8146
  id: "admin-log-tail-refuses-a-traversal",
8015
8147
  route: "GET /SASjsApi/admin/logs/{fileName}",
8016
8148
  description: "refuses a name that could resolve outside the log folder, before the host is asked",
8017
- request: { params: { fileName: "../20260101000000.log" } },
8149
+ request: { subject: ADMIN, params: { fileName: "../20260101000000.log" } },
8018
8150
  expect: { status: 400, error: "Invalid log file name." }
8019
8151
  },
8020
8152
  {
8021
8153
  id: "admin-log-tail-answers-404",
8022
8154
  route: "GET /SASjsApi/admin/logs/{fileName}",
8023
8155
  description: "answers 404 for a name the folder does not hold",
8024
- request: { params: { fileName: "20250101000000.log" } },
8156
+ request: { subject: ADMIN, params: { fileName: "20250101000000.log" } },
8025
8157
  expect: { status: 404, error: "Log file not found." }
8158
+ },
8159
+ {
8160
+ id: "admin-diagnostics-refused-to-a-restricted-account",
8161
+ route: "GET /SASjsApi/admin/diagnostics",
8162
+ description: "refuses a signed-in account that is not an administrator, in the wording verifyAdmin uses",
8163
+ request: { subject: RESTRICTED },
8164
+ expect: { status: 401, error: "Admin account required" }
8165
+ },
8166
+ {
8167
+ id: "admin-logs-refused-to-a-restricted-account",
8168
+ route: "GET /SASjsApi/admin/logs",
8169
+ description: "refuses the log inventory to a restricted account",
8170
+ request: { subject: RESTRICTED },
8171
+ expect: { status: 401, error: "Admin account required" }
8172
+ },
8173
+ {
8174
+ id: "admin-log-tail-refused-to-a-restricted-account",
8175
+ route: "GET /SASjsApi/admin/logs/{fileName}",
8176
+ description: "refuses a log tail to a restricted account",
8177
+ request: { subject: RESTRICTED, params: { fileName: CORPUS_LOG.name } },
8178
+ expect: { status: 401, error: "Admin account required" }
8179
+ },
8180
+ {
8181
+ id: "admin-logs-refused-with-no-caller",
8182
+ route: "GET /SASjsApi/admin/logs",
8183
+ description: "refuses a request that carries no caller at all",
8184
+ request: {},
8185
+ expect: { status: 401, error: "Unauthorized" }
8026
8186
  }
8027
8187
  ];
8028
8188
 
@@ -9230,6 +9390,34 @@ var SASjsApi = (() => {
9230
9390
  request: { query: { _filePath: "/../escape.csv" } },
9231
9391
  expect: { status: 400, error: "Can't get file outside drive." }
9232
9392
  },
9393
+ {
9394
+ id: "read-file-names-both",
9395
+ route: "GET /SASjsApi/drive/file",
9396
+ description: "refuses a request that names the file twice, in two readings",
9397
+ seed: { "/data/keep.csv": "a" },
9398
+ request: {
9399
+ query: { _filePath: "/data/keep.csv", _FILE: "/data/keep.csv" }
9400
+ },
9401
+ expect: {
9402
+ status: 400,
9403
+ error: 'Exactly one of "_filePath" and "_FILE" may be given.'
9404
+ }
9405
+ },
9406
+ {
9407
+ id: "read-streamed-file",
9408
+ route: "GET /SASjsApi/drive/file",
9409
+ description: "reads a deployment file by the name a streamed page links to",
9410
+ seed: { "/Public/app/services/web/main.js": "console.log(1)" },
9411
+ request: { query: { _FILE: "/Public/app/services/web/main.js" } },
9412
+ expect: { status: 200, contents: "console.log(1)" }
9413
+ },
9414
+ {
9415
+ id: "read-streamed-file-missing",
9416
+ route: "GET /SASjsApi/drive/file",
9417
+ description: "answers a missing deployment file the way the estate does, not as a 404",
9418
+ request: { query: { _FILE: "/Public/app/services/web/gone.js" } },
9419
+ expect: { status: 202, contents: DEPLOYMENT_FILE_ERROR }
9420
+ },
9233
9421
  {
9234
9422
  id: "delete-file",
9235
9423
  route: "DELETE /SASjsApi/drive/file",
@@ -10252,7 +10440,7 @@ var SASjsApi = (() => {
10252
10440
 
10253
10441
  // src/session/service.ts
10254
10442
  var createSessionService = (directory, host) => {
10255
- const notFound2 = (id) => `Session with ID '${id}' was not found.`;
10443
+ const notFound3 = (id) => `Session with ID '${id}' was not found.`;
10256
10444
  const visible = async (caller, id) => {
10257
10445
  if (!caller) throw new ApiError(401, "Unauthorized");
10258
10446
  const reader = await directory.userById(
@@ -10260,10 +10448,10 @@ var SASjsApi = (() => {
10260
10448
  );
10261
10449
  if (!reader || !reader.isActive) throw new ApiError(401, "Unauthorized");
10262
10450
  const session = await host.session(id);
10263
- if (!session) throw new ApiError(404, notFound2(id));
10451
+ if (!session) throw new ApiError(404, notFound3(id));
10264
10452
  const owner = session.owner;
10265
10453
  if (owner !== reader.uid && owner !== reader.username && !reader.isAdmin)
10266
- throw new ApiError(404, notFound2(id));
10454
+ throw new ApiError(404, notFound3(id));
10267
10455
  return session;
10268
10456
  };
10269
10457
  return {
@@ -10274,19 +10462,19 @@ var SASjsApi = (() => {
10274
10462
  async state(caller, id) {
10275
10463
  await visible(caller, id);
10276
10464
  const state = await host.state(id);
10277
- if (!state) throw new ApiError(404, notFound2(id));
10465
+ if (!state) throw new ApiError(404, notFound3(id));
10278
10466
  return state;
10279
10467
  },
10280
10468
  async log(caller, id) {
10281
10469
  await visible(caller, id);
10282
10470
  const log = await host.log(id);
10283
- if (log === void 0) throw new ApiError(404, notFound2(id));
10471
+ if (log === void 0) throw new ApiError(404, notFound3(id));
10284
10472
  return log;
10285
10473
  },
10286
10474
  async output(caller, id) {
10287
10475
  await visible(caller, id);
10288
10476
  const output = await host.output(id);
10289
- if (output === void 0) throw new ApiError(404, notFound2(id));
10477
+ if (output === void 0) throw new ApiError(404, notFound3(id));
10290
10478
  return output;
10291
10479
  }
10292
10480
  };
@@ -10297,7 +10485,7 @@ var SASjsApi = (() => {
10297
10485
 
10298
10486
  // src/runtime/program.ts
10299
10487
  var programNotFound = (given2) => `The Program at (${given2}) does not exist.`;
10300
- var notThere = (given2) => new ApiError(400, programNotFound(given2));
10488
+ var notThere2 = (given2) => new ApiError(400, programNotFound(given2));
10301
10489
  var runTimeOfPath = (path) => {
10302
10490
  const file = path.split(/[\\/]/).pop() || "";
10303
10491
  const dot = file.lastIndexOf(".");
@@ -10306,7 +10494,7 @@ var SASjsApi = (() => {
10306
10494
  };
10307
10495
  var resolveProgram = async (given2, deps) => {
10308
10496
  const resolved = deps.resolve(given2);
10309
- if (resolved === null) throw notThere(given2);
10497
+ if (resolved === null) throw notThere2(given2);
10310
10498
  const extension = runTimeOfPath(resolved);
10311
10499
  if (extension !== void 0) {
10312
10500
  if (await deps.exists(resolved))
@@ -10317,7 +10505,7 @@ var SASjsApi = (() => {
10317
10505
  if (await deps.exists(candidate)) return { path: candidate, runTime };
10318
10506
  }
10319
10507
  }
10320
- throw notThere(given2);
10508
+ throw notThere2(given2);
10321
10509
  };
10322
10510
 
10323
10511
  // src/runtime/service.ts
@@ -10340,7 +10528,7 @@ var SASjsApi = (() => {
10340
10528
  pad(now.getSeconds())
10341
10529
  ].join("");
10342
10530
  var newSessionId = (now) => `${timestamp(now)}-${Math.round(Math.random() * 1e5)}-${now.getTime()}`;
10343
- var notThere2 = (programPath) => programNotFound(programPath);
10531
+ var notThere3 = (programPath) => programNotFound(programPath);
10344
10532
  var failedRun = (error) => {
10345
10533
  const message = "Job execution failed.";
10346
10534
  throw new ApiError(400, message, {
@@ -10374,7 +10562,7 @@ var SASjsApi = (() => {
10374
10562
  if (request.program === "")
10375
10563
  throw new ApiError(400, '"_program" is not allowed to be empty');
10376
10564
  const resolved = normaliseDrivePath(request.program);
10377
- if (resolved === null) return failedRun(notThere2(request.program));
10565
+ if (resolved === null) return failedRun(notThere3(request.program));
10378
10566
  return { path: resolved };
10379
10567
  };
10380
10568
  const runTimeForPath = (path, request) => (
@@ -10600,10 +10788,10 @@ var SASjsApi = (() => {
10600
10788
  fail: testCase.failingRun,
10601
10789
  outputs: testCase.runOutput ? { [programOf(testCase)]: testCase.runOutput } : void 0
10602
10790
  });
10791
+ const driveStore = testCase.unwritable ? new RefusingDriveStore(testCase.seed || {}) : new MemoryDriveStore(testCase.seed || {});
10603
10792
  return {
10604
- drive: createDriveService(
10605
- testCase.unwritable ? new RefusingDriveStore(testCase.seed || {}) : new MemoryDriveStore(testCase.seed || {})
10606
- ),
10793
+ drive: createDriveService(driveStore),
10794
+ deploymentFile: createDeploymentFileService(driveStore),
10607
10795
  info: createInfoService(BROWSER_INFO),
10608
10796
  home: createHomeService(async () => CORPUS_WEB_PAGE),
10609
10797
  authConfig: createAuthConfigService(CORPUS_AUTH_CONFIG),
@@ -10753,9 +10941,9 @@ var SASjsApi = (() => {
10753
10941
  ];
10754
10942
 
10755
10943
  // src/corpus/session.ts
10756
- var ADMIN = { userId: "user-admin", clientId: "web_app" };
10757
- var RESTRICTED = { userId: "user-restricted", clientId: "web_app" };
10758
- var notFound = (id) => `Session with ID '${id}' was not found.`;
10944
+ var ADMIN2 = { userId: "user-admin", clientId: "web_app" };
10945
+ var RESTRICTED2 = { userId: "user-restricted", clientId: "web_app" };
10946
+ var notFound2 = (id) => `Session with ID '${id}' was not found.`;
10759
10947
  var UNAUTHORIZED = "Unauthorized";
10760
10948
  var SESSION_CORPUS = [
10761
10949
  // ---------------------------------------------------------------- summary
@@ -10763,7 +10951,7 @@ var SASjsApi = (() => {
10763
10951
  id: "session-summary-own",
10764
10952
  route: "GET /SASjsApi/session/{sessionId}",
10765
10953
  description: "answers the owner the summary of their own session",
10766
- request: { subject: ADMIN, params: { sessionId: "sess-admin" } },
10954
+ request: { subject: ADMIN2, params: { sessionId: "sess-admin" } },
10767
10955
  expect: {
10768
10956
  status: 200,
10769
10957
  body: {
@@ -10780,7 +10968,7 @@ var SASjsApi = (() => {
10780
10968
  id: "session-summary-as-admin",
10781
10969
  route: "GET /SASjsApi/session/{sessionId}",
10782
10970
  description: "answers an administrator another account's session",
10783
- request: { subject: ADMIN, params: { sessionId: "sess-restricted" } },
10971
+ request: { subject: ADMIN2, params: { sessionId: "sess-restricted" } },
10784
10972
  // both stamps: the document requires them, and this host stamps a session's
10785
10973
  // death time at creation rather than at completion - a running session
10786
10974
  // answers with the moment it is due to be destroyed
@@ -10806,22 +10994,22 @@ var SASjsApi = (() => {
10806
10994
  id: "session-summary-foreign",
10807
10995
  route: "GET /SASjsApi/session/{sessionId}",
10808
10996
  description: "answers 404 for another account's session, not 403",
10809
- request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10810
- expect: { status: 404, error: notFound("sess-admin") }
10997
+ request: { subject: RESTRICTED2, params: { sessionId: "sess-admin" } },
10998
+ expect: { status: 404, error: notFound2("sess-admin") }
10811
10999
  },
10812
11000
  {
10813
11001
  id: "session-summary-unknown",
10814
11002
  route: "GET /SASjsApi/session/{sessionId}",
10815
11003
  description: "answers the same 404 for a session that does not exist",
10816
- request: { subject: ADMIN, params: { sessionId: "sess-nope" } },
10817
- expect: { status: 404, error: notFound("sess-nope") }
11004
+ request: { subject: ADMIN2, params: { sessionId: "sess-nope" } },
11005
+ expect: { status: 404, error: notFound2("sess-nope") }
10818
11006
  },
10819
11007
  // -------------------------------------------------------------------- log
10820
11008
  {
10821
11009
  id: "session-log-own",
10822
11010
  route: "GET /SASjsApi/session/{sessionId}/log",
10823
11011
  description: "answers the log this session wrote",
10824
- request: { subject: ADMIN, params: { sessionId: "sess-admin" } },
11012
+ request: { subject: ADMIN2, params: { sessionId: "sess-admin" } },
10825
11013
  expect: {
10826
11014
  status: 200,
10827
11015
  contents: "NOTE: session started\nNOTE: session completed\n"
@@ -10831,7 +11019,7 @@ var SASjsApi = (() => {
10831
11019
  id: "session-log-nothing-written",
10832
11020
  route: "GET /SASjsApi/session/{sessionId}/log",
10833
11021
  description: "answers an empty body for a session that has written nothing",
10834
- request: { subject: ADMIN, params: { sessionId: "sess-silent" } },
11022
+ request: { subject: ADMIN2, params: { sessionId: "sess-silent" } },
10835
11023
  expect: { status: 200, contents: "" }
10836
11024
  },
10837
11025
  {
@@ -10845,15 +11033,15 @@ var SASjsApi = (() => {
10845
11033
  id: "session-log-foreign",
10846
11034
  route: "GET /SASjsApi/session/{sessionId}/log",
10847
11035
  description: "will not read another account's log",
10848
- request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10849
- expect: { status: 404, error: notFound("sess-admin") }
11036
+ request: { subject: RESTRICTED2, params: { sessionId: "sess-admin" } },
11037
+ expect: { status: 404, error: notFound2("sess-admin") }
10850
11038
  },
10851
11039
  // ----------------------------------------------------------------- output
10852
11040
  {
10853
11041
  id: "session-output-own",
10854
11042
  route: "GET /SASjsApi/session/{sessionId}/output",
10855
11043
  description: "answers the webout this session produced",
10856
- request: { subject: ADMIN, params: { sessionId: "sess-admin" } },
11044
+ request: { subject: ADMIN2, params: { sessionId: "sess-admin" } },
10857
11045
  expect: { status: 200, contents: "<html><body>42</body></html>" }
10858
11046
  },
10859
11047
  {
@@ -10867,15 +11055,15 @@ var SASjsApi = (() => {
10867
11055
  id: "session-output-foreign",
10868
11056
  route: "GET /SASjsApi/session/{sessionId}/output",
10869
11057
  description: "will not read another account's webout",
10870
- request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10871
- expect: { status: 404, error: notFound("sess-admin") }
11058
+ request: { subject: RESTRICTED2, params: { sessionId: "sess-admin" } },
11059
+ expect: { status: 404, error: notFound2("sess-admin") }
10872
11060
  },
10873
11061
  // ------------------------------------------------------------------ state
10874
11062
  {
10875
11063
  id: "session-state-own",
10876
11064
  route: "GET /SASjsApi/session/{sessionId}/state",
10877
11065
  description: "answers the run time's state for this session",
10878
- request: { subject: RESTRICTED, params: { sessionId: "sess-restricted" } },
11066
+ request: { subject: RESTRICTED2, params: { sessionId: "sess-restricted" } },
10879
11067
  // the state alone: the document's SessionStateResponse permits no other
10880
11068
  // property, and `sasjs/server` answers exactly this object
10881
11069
  expect: { status: 200, body: { state: "running" } }
@@ -10891,13 +11079,14 @@ var SASjsApi = (() => {
10891
11079
  id: "session-state-foreign",
10892
11080
  route: "GET /SASjsApi/session/{sessionId}/state",
10893
11081
  description: "will not report another account's session state",
10894
- request: { subject: RESTRICTED, params: { sessionId: "sess-admin" } },
10895
- expect: { status: 404, error: notFound("sess-admin") }
11082
+ request: { subject: RESTRICTED2, params: { sessionId: "sess-admin" } },
11083
+ expect: { status: 404, error: notFound2("sess-admin") }
10896
11084
  }
10897
11085
  ];
10898
11086
 
10899
11087
  // src/corpus/runtime.ts
10900
- var ADMIN2 = { userId: "user-admin", clientId: "web_app" };
11088
+ var ADMIN3 = { userId: "user-admin", clientId: "web_app" };
11089
+ var RESTRICTED3 = { userId: "user-restricted", clientId: "web_app" };
10901
11090
  var PROGRAM = "/Public/apps/demo/run.sas";
10902
11091
  var CODE = 'data _null_;\n put "hello";\nrun;';
10903
11092
  var UNAUTHORIZED2 = "Unauthorized";
@@ -10909,7 +11098,7 @@ var SASjsApi = (() => {
10909
11098
  id: "stp-execute-get-answers-output",
10910
11099
  route: "GET /SASjsApi/stp/execute",
10911
11100
  description: "answers the output the program produced",
10912
- request: { subject: ADMIN2, query: { _program: PROGRAM } },
11101
+ request: { subject: ADMIN3, query: { _program: PROGRAM } },
10913
11102
  runOutput: { contents: "hello from the program" },
10914
11103
  expect: { status: 200, contents: "hello from the program" }
10915
11104
  },
@@ -10917,7 +11106,7 @@ var SASjsApi = (() => {
10917
11106
  id: "stp-execute-get-answers-bytes",
10918
11107
  route: "GET /SASjsApi/stp/execute",
10919
11108
  description: "answers an output that is bytes as bytes",
10920
- request: { subject: ADMIN2, query: { _program: PROGRAM } },
11109
+ request: { subject: ADMIN3, query: { _program: PROGRAM } },
10921
11110
  runOutput: { contents: bytes2(1, 2, 3) },
10922
11111
  expect: { status: 200, contents: bytes2(1, 2, 3) }
10923
11112
  },
@@ -10925,14 +11114,14 @@ var SASjsApi = (() => {
10925
11114
  id: "stp-execute-get-missing-program",
10926
11115
  route: "GET /SASjsApi/stp/execute",
10927
11116
  description: "refuses a request that names no program",
10928
- request: { subject: ADMIN2, query: {} },
11117
+ request: { subject: ADMIN3, query: {} },
10929
11118
  expect: { status: 400, error: '"_program" is required' }
10930
11119
  },
10931
11120
  {
10932
11121
  id: "stp-execute-get-failed-run",
10933
11122
  route: "GET /SASjsApi/stp/execute",
10934
11123
  description: "answers 400 when the program could not be run",
10935
- request: { subject: ADMIN2, query: { _program: PROGRAM } },
11124
+ request: { subject: ADMIN3, query: { _program: PROGRAM } },
10936
11125
  failingRun: true,
10937
11126
  expect: { status: 400, error: FAILED }
10938
11127
  },
@@ -10948,7 +11137,7 @@ var SASjsApi = (() => {
10948
11137
  id: "stp-execute-post-body-program",
10949
11138
  route: "POST /SASjsApi/stp/execute",
10950
11139
  description: "runs the program the body names",
10951
- request: { subject: ADMIN2, body: { _program: PROGRAM } },
11140
+ request: { subject: ADMIN3, body: { _program: PROGRAM } },
10952
11141
  runOutput: { contents: "hello from the body" },
10953
11142
  expect: { status: 200, contents: "hello from the body" }
10954
11143
  },
@@ -10956,7 +11145,7 @@ var SASjsApi = (() => {
10956
11145
  id: "stp-execute-post-query-program",
10957
11146
  route: "POST /SASjsApi/stp/execute",
10958
11147
  description: "runs the program the query names, with no body",
10959
- request: { subject: ADMIN2, query: { _program: PROGRAM }, body: {} },
11148
+ request: { subject: ADMIN3, query: { _program: PROGRAM }, body: {} },
10960
11149
  runOutput: { contents: "hello from the query" },
10961
11150
  expect: { status: 200, contents: "hello from the query" }
10962
11151
  },
@@ -10964,14 +11153,14 @@ var SASjsApi = (() => {
10964
11153
  id: "stp-execute-post-no-program",
10965
11154
  route: "POST /SASjsApi/stp/execute",
10966
11155
  description: "refuses a request with no program in the query or the body",
10967
- request: { subject: ADMIN2, body: {} },
11156
+ request: { subject: ADMIN3, body: {} },
10968
11157
  expect: { status: 400, error: '"_program" is required' }
10969
11158
  },
10970
11159
  {
10971
11160
  id: "stp-execute-post-failed-run",
10972
11161
  route: "POST /SASjsApi/stp/execute",
10973
11162
  description: "answers 400 when the program could not be run",
10974
- request: { subject: ADMIN2, body: { _program: PROGRAM } },
11163
+ request: { subject: ADMIN3, body: { _program: PROGRAM } },
10975
11164
  failingRun: true,
10976
11165
  expect: { status: 400, error: FAILED }
10977
11166
  },
@@ -10987,7 +11176,7 @@ var SASjsApi = (() => {
10987
11176
  id: "stp-trigger-answers-session",
10988
11177
  route: "POST /SASjsApi/stp/trigger",
10989
11178
  description: "answers the session a caller polls, and no pid from a mock",
10990
- request: { subject: ADMIN2, query: { _program: PROGRAM } },
11179
+ request: { subject: ADMIN3, query: { _program: PROGRAM } },
10991
11180
  expect: { status: 200, keys: ["sessionId"] }
10992
11181
  },
10993
11182
  {
@@ -10995,7 +11184,7 @@ var SASjsApi = (() => {
10995
11184
  route: "POST /SASjsApi/stp/trigger",
10996
11185
  description: "accepts a retention in minutes, as the query carries it",
10997
11186
  request: {
10998
- subject: ADMIN2,
11187
+ subject: ADMIN3,
10999
11188
  query: { _program: PROGRAM, expiresAfterMins: "15" }
11000
11189
  },
11001
11190
  expect: { status: 200, keys: ["sessionId"] }
@@ -11005,7 +11194,7 @@ var SASjsApi = (() => {
11005
11194
  route: "POST /SASjsApi/stp/trigger",
11006
11195
  description: "refuses a retention that is not a positive number of minutes",
11007
11196
  request: {
11008
- subject: ADMIN2,
11197
+ subject: ADMIN3,
11009
11198
  query: { _program: PROGRAM, expiresAfterMins: "0" }
11010
11199
  },
11011
11200
  expect: { status: 400, error: '"expiresAfterMins" must be greater than 0' }
@@ -11014,14 +11203,14 @@ var SASjsApi = (() => {
11014
11203
  id: "stp-trigger-missing-program",
11015
11204
  route: "POST /SASjsApi/stp/trigger",
11016
11205
  description: "refuses a request that names no program",
11017
- request: { subject: ADMIN2, query: {} },
11206
+ request: { subject: ADMIN3, query: {} },
11018
11207
  expect: { status: 400, error: '"_program" is required' }
11019
11208
  },
11020
11209
  {
11021
11210
  id: "stp-trigger-failed-run",
11022
11211
  route: "POST /SASjsApi/stp/trigger",
11023
11212
  description: "answers 400 when the program could not be started",
11024
- request: { subject: ADMIN2, query: { _program: PROGRAM } },
11213
+ request: { subject: ADMIN3, query: { _program: PROGRAM } },
11025
11214
  failingRun: true,
11026
11215
  expect: { status: 400, error: FAILED }
11027
11216
  },
@@ -11037,7 +11226,7 @@ var SASjsApi = (() => {
11037
11226
  id: "code-execute-answers-output",
11038
11227
  route: "POST /SASjsApi/code/execute",
11039
11228
  description: "runs the code in the body and answers its output",
11040
- request: { subject: ADMIN2, body: { code: CODE, runTime: "sas" } },
11229
+ request: { subject: ADMIN3, body: { code: CODE, runTime: "sas" } },
11041
11230
  runOutput: { contents: "NOTE: mock run" },
11042
11231
  expect: { status: 200, contents: "NOTE: mock run" }
11043
11232
  },
@@ -11051,35 +11240,35 @@ var SASjsApi = (() => {
11051
11240
  id: "code-execute-unknown-runtime",
11052
11241
  route: "POST /SASjsApi/code/execute",
11053
11242
  description: "refuses a run time the document does not name",
11054
- request: { subject: ADMIN2, body: { code: CODE, runTime: "cobol" } },
11243
+ request: { subject: ADMIN3, body: { code: CODE, runTime: "cobol" } },
11055
11244
  expect: { status: 400 }
11056
11245
  },
11057
11246
  {
11058
11247
  id: "code-execute-missing-code",
11059
11248
  route: "POST /SASjsApi/code/execute",
11060
11249
  description: "refuses a payload with no code",
11061
- request: { subject: ADMIN2, body: { runTime: "sas" } },
11250
+ request: { subject: ADMIN3, body: { runTime: "sas" } },
11062
11251
  expect: { status: 400, error: '"code" is required' }
11063
11252
  },
11064
11253
  {
11065
11254
  id: "code-execute-empty-code",
11066
11255
  route: "POST /SASjsApi/code/execute",
11067
11256
  description: "refuses code that is present but empty",
11068
- request: { subject: ADMIN2, body: { code: "", runTime: "sas" } },
11257
+ request: { subject: ADMIN3, body: { code: "", runTime: "sas" } },
11069
11258
  expect: { status: 400, error: '"code" is not allowed to be empty' }
11070
11259
  },
11071
11260
  {
11072
11261
  id: "code-execute-non-string-code",
11073
11262
  route: "POST /SASjsApi/code/execute",
11074
11263
  description: "refuses code that is not a string rather than running its text",
11075
- request: { subject: ADMIN2, body: { code: 123, runTime: "sas" } },
11264
+ request: { subject: ADMIN3, body: { code: 123, runTime: "sas" } },
11076
11265
  expect: { status: 400, error: '"code" must be a string' }
11077
11266
  },
11078
11267
  {
11079
11268
  id: "code-execute-failed-run",
11080
11269
  route: "POST /SASjsApi/code/execute",
11081
11270
  description: "answers 400 when the code could not be run",
11082
- request: { subject: ADMIN2, body: { code: CODE, runTime: "sas" } },
11271
+ request: { subject: ADMIN3, body: { code: CODE, runTime: "sas" } },
11083
11272
  failingRun: true,
11084
11273
  expect: { status: 400, error: FAILED }
11085
11274
  },
@@ -11090,19 +11279,41 @@ var SASjsApi = (() => {
11090
11279
  request: { body: {} },
11091
11280
  expect: { status: 401, error: UNAUTHORIZED2 }
11092
11281
  },
11282
+ {
11283
+ // The fixture denies this account `/SASjsApi/code/execute` with a user rule,
11284
+ // and a denied rule refuses the call rather than only the menu entry beside
11285
+ // it. On a server that is `authorize`; here it is the decision
11286
+ // `myAuthorizedRoutes` reports from, asked of the same store.
11287
+ id: "code-execute-denied-by-a-rule",
11288
+ route: "POST /SASjsApi/code/execute",
11289
+ description: "refuses a caller the rules do not grant, with the 401 a missing token earns",
11290
+ request: { subject: RESTRICTED3, body: { code: CODE, runTime: "sas" } },
11291
+ expect: { status: 401, error: UNAUTHORIZED2 }
11292
+ },
11293
+ {
11294
+ // The positive control for the case above: the same account is granted
11295
+ // `stp/execute` by a group rule, so the refusal there is the rule and not a
11296
+ // blanket refusal of everything a restricted account asks for.
11297
+ id: "stp-execute-granted-by-a-group-rule",
11298
+ route: "POST /SASjsApi/stp/execute",
11299
+ description: "admits a restricted account the rules grant",
11300
+ request: { subject: RESTRICTED3, body: { _program: PROGRAM } },
11301
+ runOutput: { contents: "granted run" },
11302
+ expect: { status: 200, contents: "granted run" }
11303
+ },
11093
11304
  // ----------------------------------------------- POST /code/trigger
11094
11305
  {
11095
11306
  id: "code-trigger-answers-session",
11096
11307
  route: "POST /SASjsApi/code/trigger",
11097
11308
  description: "answers the session a caller polls, and no pid from a mock",
11098
- request: { subject: ADMIN2, body: { code: CODE, runTime: "sas" } },
11309
+ request: { subject: ADMIN3, body: { code: CODE, runTime: "sas" } },
11099
11310
  expect: { status: 200, keys: ["sessionId"] }
11100
11311
  },
11101
11312
  {
11102
11313
  id: "code-trigger-missing-runtime",
11103
11314
  route: "POST /SASjsApi/code/trigger",
11104
11315
  description: "refuses a payload with no run time, which the document requires",
11105
- request: { subject: ADMIN2, body: { code: CODE } },
11316
+ request: { subject: ADMIN3, body: { code: CODE } },
11106
11317
  expect: { status: 400, error: '"runTime" is required' }
11107
11318
  },
11108
11319
  {
@@ -11110,7 +11321,7 @@ var SASjsApi = (() => {
11110
11321
  route: "POST /SASjsApi/code/trigger",
11111
11322
  description: "refuses a retention that is not a positive number of minutes",
11112
11323
  request: {
11113
- subject: ADMIN2,
11324
+ subject: ADMIN3,
11114
11325
  body: { code: CODE, runTime: "sas", expiresAfterMins: 0 }
11115
11326
  },
11116
11327
  expect: { status: 400, error: '"expiresAfterMins" must be greater than 0' }
@@ -11119,7 +11330,7 @@ var SASjsApi = (() => {
11119
11330
  id: "code-trigger-failed-run",
11120
11331
  route: "POST /SASjsApi/code/trigger",
11121
11332
  description: "answers 400 when the code could not be started",
11122
- request: { subject: ADMIN2, body: { code: CODE, runTime: "sas" } },
11333
+ request: { subject: ADMIN3, body: { code: CODE, runTime: "sas" } },
11123
11334
  failingRun: true,
11124
11335
  expect: { status: 400, error: FAILED }
11125
11336
  },
@@ -11194,8 +11405,8 @@ var SASjsApi = (() => {
11194
11405
  }
11195
11406
  ]
11196
11407
  };
11197
- var ADMIN3 = "admin-access";
11198
- var RESTRICTED2 = "user-access";
11408
+ var ADMIN4 = "admin-access";
11409
+ var RESTRICTED4 = "user-access";
11199
11410
  var RESTRICTED_UID = "user-restricted";
11200
11411
  var ADMIN_UID = "user-admin";
11201
11412
  var RECORD_CORPUS = [
@@ -11205,7 +11416,7 @@ var SASjsApi = (() => {
11205
11416
  route: "GET /SASjsApi/user",
11206
11417
  description: "lists the accounts any signed-in caller may see",
11207
11418
  identity: ADMIN_SIGNED_IN,
11208
- request: { token: ADMIN3 },
11419
+ request: { token: ADMIN4 },
11209
11420
  expect: {
11210
11421
  status: 200,
11211
11422
  body: [
@@ -11229,7 +11440,7 @@ var SASjsApi = (() => {
11229
11440
  route: "GET /SASjsApi/user/{uid}",
11230
11441
  description: "returns the caller their own details, with the auto-exec code",
11231
11442
  identity: ADMIN_SIGNED_IN,
11232
- request: { token: RESTRICTED2, params: { uid: RESTRICTED_UID } },
11443
+ request: { token: RESTRICTED4, params: { uid: RESTRICTED_UID } },
11233
11444
  expect: {
11234
11445
  status: 200,
11235
11446
  partial: {
@@ -11254,7 +11465,7 @@ var SASjsApi = (() => {
11254
11465
  route: "GET /SASjsApi/user/{uid}",
11255
11466
  description: "answers 404 for an identifier no account has",
11256
11467
  identity: ADMIN_SIGNED_IN,
11257
- request: { token: ADMIN3, params: { uid: "user-none" } },
11468
+ request: { token: ADMIN4, params: { uid: "user-none" } },
11258
11469
  expect: { status: 404, error: "User is not found." }
11259
11470
  },
11260
11471
  {
@@ -11262,7 +11473,7 @@ var SASjsApi = (() => {
11262
11473
  route: "GET /SASjsApi/user/by/username/{username}",
11263
11474
  description: "finds an account by username",
11264
11475
  identity: ADMIN_SIGNED_IN,
11265
- request: { token: ADMIN3, params: { username: "sasjsuser" } },
11476
+ request: { token: ADMIN4, params: { username: "sasjsuser" } },
11266
11477
  expect: {
11267
11478
  status: 200,
11268
11479
  partial: { uid: RESTRICTED_UID, username: "sasjsuser", isAdmin: false }
@@ -11281,7 +11492,7 @@ var SASjsApi = (() => {
11281
11492
  route: "GET /SASjsApi/user/by/username/{username}",
11282
11493
  description: "answers 404 for a username no account has",
11283
11494
  identity: ADMIN_SIGNED_IN,
11284
- request: { token: ADMIN3, params: { username: "nobody" } },
11495
+ request: { token: ADMIN4, params: { username: "nobody" } },
11285
11496
  expect: { status: 404, error: "User is not found." }
11286
11497
  },
11287
11498
  {
@@ -11290,7 +11501,7 @@ var SASjsApi = (() => {
11290
11501
  description: "creates an account, sanitised, and reports it",
11291
11502
  identity: ADMIN_SIGNED_IN,
11292
11503
  request: {
11293
- token: ADMIN3,
11504
+ token: ADMIN4,
11294
11505
  body: {
11295
11506
  username: "newuser",
11296
11507
  displayName: " New User ",
@@ -11315,7 +11526,7 @@ var SASjsApi = (() => {
11315
11526
  description: "refuses a creation by a caller who is not an administrator",
11316
11527
  identity: ADMIN_SIGNED_IN,
11317
11528
  request: {
11318
- token: RESTRICTED2,
11529
+ token: RESTRICTED4,
11319
11530
  body: {
11320
11531
  username: "newuser",
11321
11532
  displayName: "New User",
@@ -11338,7 +11549,7 @@ var SASjsApi = (() => {
11338
11549
  description: "refuses a username that is taken",
11339
11550
  identity: ADMIN_SIGNED_IN,
11340
11551
  request: {
11341
- token: ADMIN3,
11552
+ token: ADMIN4,
11342
11553
  body: {
11343
11554
  username: "sasjsuser",
11344
11555
  displayName: "Another",
@@ -11353,7 +11564,7 @@ var SASjsApi = (() => {
11353
11564
  description: "changes an account's display name",
11354
11565
  identity: ADMIN_SIGNED_IN,
11355
11566
  request: {
11356
- token: ADMIN3,
11567
+ token: ADMIN4,
11357
11568
  params: { uid: RESTRICTED_UID },
11358
11569
  body: {
11359
11570
  displayName: "Renamed User",
@@ -11372,7 +11583,7 @@ var SASjsApi = (() => {
11372
11583
  description: "refuses a change to somebody else's account",
11373
11584
  identity: ADMIN_SIGNED_IN,
11374
11585
  request: {
11375
- token: RESTRICTED2,
11586
+ token: RESTRICTED4,
11376
11587
  params: { uid: ADMIN_UID },
11377
11588
  body: {
11378
11589
  displayName: "Hijacked",
@@ -11388,7 +11599,7 @@ var SASjsApi = (() => {
11388
11599
  description: "answers 404 with the identifier it looked up",
11389
11600
  identity: ADMIN_SIGNED_IN,
11390
11601
  request: {
11391
- token: ADMIN3,
11602
+ token: ADMIN4,
11392
11603
  params: { uid: "user-none" },
11393
11604
  body: { displayName: "Nobody", username: "nobody", password: "none123" }
11394
11605
  },
@@ -11400,7 +11611,7 @@ var SASjsApi = (() => {
11400
11611
  description: "refuses a username change on a provider-managed account",
11401
11612
  identity: PROVIDER_MANAGED,
11402
11613
  request: {
11403
- token: ADMIN3,
11614
+ token: ADMIN4,
11404
11615
  params: { uid: "user-directory" },
11405
11616
  body: {
11406
11617
  username: "renamed",
@@ -11419,7 +11630,7 @@ var SASjsApi = (() => {
11419
11630
  description: "refuses a username another account already has",
11420
11631
  identity: ADMIN_SIGNED_IN,
11421
11632
  request: {
11422
- token: ADMIN3,
11633
+ token: ADMIN4,
11423
11634
  params: { uid: RESTRICTED_UID },
11424
11635
  body: {
11425
11636
  username: "sasjsadmin",
@@ -11435,7 +11646,7 @@ var SASjsApi = (() => {
11435
11646
  description: "changes an account looked up by username",
11436
11647
  identity: ADMIN_SIGNED_IN,
11437
11648
  request: {
11438
- token: ADMIN3,
11649
+ token: ADMIN4,
11439
11650
  params: { username: "sasjsuser" },
11440
11651
  body: {
11441
11652
  isActive: false,
@@ -11452,7 +11663,7 @@ var SASjsApi = (() => {
11452
11663
  description: "refuses a change to another account by username",
11453
11664
  identity: ADMIN_SIGNED_IN,
11454
11665
  request: {
11455
- token: RESTRICTED2,
11666
+ token: RESTRICTED4,
11456
11667
  params: { username: "sasjsadmin" },
11457
11668
  body: {
11458
11669
  displayName: "Hijacked",
@@ -11468,7 +11679,7 @@ var SASjsApi = (() => {
11468
11679
  description: "answers 404 with the username it looked up",
11469
11680
  identity: ADMIN_SIGNED_IN,
11470
11681
  request: {
11471
- token: ADMIN3,
11682
+ token: ADMIN4,
11472
11683
  params: { username: "nobody" },
11473
11684
  body: { displayName: "Nobody", username: "nobody", password: "none123" }
11474
11685
  },
@@ -11480,7 +11691,7 @@ var SASjsApi = (() => {
11480
11691
  description: "refuses a display-name change on a provider-managed account",
11481
11692
  identity: PROVIDER_MANAGED,
11482
11693
  request: {
11483
- token: ADMIN3,
11694
+ token: ADMIN4,
11484
11695
  params: { username: "diruser" },
11485
11696
  body: { displayName: "Renamed", username: "diruser", password: "dir123" }
11486
11697
  },
@@ -11495,7 +11706,7 @@ var SASjsApi = (() => {
11495
11706
  description: "refuses a username another account already has",
11496
11707
  identity: ADMIN_SIGNED_IN,
11497
11708
  request: {
11498
- token: ADMIN3,
11709
+ token: ADMIN4,
11499
11710
  params: { username: "sasjsuser" },
11500
11711
  body: {
11501
11712
  username: "sasjsadmin",
@@ -11510,7 +11721,7 @@ var SASjsApi = (() => {
11510
11721
  route: "DELETE /SASjsApi/user/{uid}",
11511
11722
  description: "deletes an account as an administrator, without a password",
11512
11723
  identity: ADMIN_SIGNED_IN,
11513
- request: { token: ADMIN3, params: { uid: RESTRICTED_UID }, body: {} },
11724
+ request: { token: ADMIN4, params: { uid: RESTRICTED_UID }, body: {} },
11514
11725
  expect: { status: 200, body: "Account Deleted!" }
11515
11726
  },
11516
11727
  {
@@ -11518,7 +11729,7 @@ var SASjsApi = (() => {
11518
11729
  route: "DELETE /SASjsApi/user/{uid}",
11519
11730
  description: "refuses a deletion of somebody else's account",
11520
11731
  identity: ADMIN_SIGNED_IN,
11521
- request: { token: RESTRICTED2, params: { uid: ADMIN_UID }, body: {} },
11732
+ request: { token: RESTRICTED4, params: { uid: ADMIN_UID }, body: {} },
11522
11733
  expect: { status: 401, error: "Admin account required" }
11523
11734
  },
11524
11735
  {
@@ -11526,7 +11737,7 @@ var SASjsApi = (() => {
11526
11737
  route: "DELETE /SASjsApi/user/{uid}",
11527
11738
  description: "answers 404 for an identifier no account has",
11528
11739
  identity: ADMIN_SIGNED_IN,
11529
- request: { token: ADMIN3, params: { uid: "user-none" }, body: {} },
11740
+ request: { token: ADMIN4, params: { uid: "user-none" }, body: {} },
11530
11741
  expect: { status: 404, error: "User is not found." }
11531
11742
  },
11532
11743
  {
@@ -11535,7 +11746,7 @@ var SASjsApi = (() => {
11535
11746
  description: "deletes an account looked up by username",
11536
11747
  identity: ADMIN_SIGNED_IN,
11537
11748
  request: {
11538
- token: ADMIN3,
11749
+ token: ADMIN4,
11539
11750
  params: { username: "sasjsuser" },
11540
11751
  body: {}
11541
11752
  },
@@ -11547,7 +11758,7 @@ var SASjsApi = (() => {
11547
11758
  description: "refuses a self-deletion whose password is wrong",
11548
11759
  identity: ADMIN_SIGNED_IN,
11549
11760
  request: {
11550
- token: RESTRICTED2,
11761
+ token: RESTRICTED4,
11551
11762
  params: { username: "sasjsuser" },
11552
11763
  body: { password: "wrong123" }
11553
11764
  },
@@ -11558,7 +11769,7 @@ var SASjsApi = (() => {
11558
11769
  route: "DELETE /SASjsApi/user/by/username/{username}",
11559
11770
  description: "answers 404 for a username no account has",
11560
11771
  identity: ADMIN_SIGNED_IN,
11561
- request: { token: ADMIN3, params: { username: "nobody" }, body: {} },
11772
+ request: { token: ADMIN4, params: { username: "nobody" }, body: {} },
11562
11773
  expect: { status: 404, error: "User is not found." }
11563
11774
  },
11564
11775
  // ----------------------------------------------------------------- groups
@@ -11567,7 +11778,7 @@ var SASjsApi = (() => {
11567
11778
  route: "GET /SASjsApi/group",
11568
11779
  description: "lists the groups",
11569
11780
  identity: ADMIN_SIGNED_IN,
11570
- request: { token: RESTRICTED2 },
11781
+ request: { token: RESTRICTED4 },
11571
11782
  expect: {
11572
11783
  status: 200,
11573
11784
  body: [
@@ -11589,7 +11800,7 @@ var SASjsApi = (() => {
11589
11800
  route: "GET /SASjsApi/group/{uid}",
11590
11801
  description: "returns a group and its members",
11591
11802
  identity: ADMIN_SIGNED_IN,
11592
- request: { token: RESTRICTED2, params: { uid: "group-admins" } },
11803
+ request: { token: RESTRICTED4, params: { uid: "group-admins" } },
11593
11804
  expect: {
11594
11805
  status: 200,
11595
11806
  partial: {
@@ -11612,7 +11823,7 @@ var SASjsApi = (() => {
11612
11823
  route: "GET /SASjsApi/group/{uid}",
11613
11824
  description: "answers 404 for an identifier no group has",
11614
11825
  identity: ADMIN_SIGNED_IN,
11615
- request: { token: ADMIN3, params: { uid: "group-none" } },
11826
+ request: { token: ADMIN4, params: { uid: "group-none" } },
11616
11827
  expect: { status: 404, error: "Group not found." }
11617
11828
  },
11618
11829
  {
@@ -11620,7 +11831,7 @@ var SASjsApi = (() => {
11620
11831
  route: "GET /SASjsApi/group/by/groupname/{name}",
11621
11832
  description: "finds a group by name",
11622
11833
  identity: ADMIN_SIGNED_IN,
11623
- request: { token: ADMIN3, params: { name: "DCGroup" } },
11834
+ request: { token: ADMIN4, params: { name: "DCGroup" } },
11624
11835
  expect: {
11625
11836
  status: 200,
11626
11837
  partial: { uid: "group-data-controller", name: "DCGroup" }
@@ -11631,7 +11842,7 @@ var SASjsApi = (() => {
11631
11842
  route: "GET /SASjsApi/group/by/groupname/{name}",
11632
11843
  description: "answers 404 for a name no group has",
11633
11844
  identity: ADMIN_SIGNED_IN,
11634
- request: { token: ADMIN3, params: { name: "nope" } },
11845
+ request: { token: ADMIN4, params: { name: "nope" } },
11635
11846
  expect: { status: 404, error: "Group not found." }
11636
11847
  },
11637
11848
  {
@@ -11640,7 +11851,7 @@ var SASjsApi = (() => {
11640
11851
  description: "creates a group with no members",
11641
11852
  identity: ADMIN_SIGNED_IN,
11642
11853
  request: {
11643
- token: ADMIN3,
11854
+ token: ADMIN4,
11644
11855
  body: { name: "NewGroup", description: "A new group", isActive: true }
11645
11856
  },
11646
11857
  expect: {
@@ -11659,7 +11870,7 @@ var SASjsApi = (() => {
11659
11870
  description: "refuses a creation by a caller who is not an administrator",
11660
11871
  identity: ADMIN_SIGNED_IN,
11661
11872
  request: {
11662
- token: RESTRICTED2,
11873
+ token: RESTRICTED4,
11663
11874
  body: { name: "NewGroup", description: "x" }
11664
11875
  },
11665
11876
  expect: { status: 401, error: "Admin account required" }
@@ -11669,7 +11880,7 @@ var SASjsApi = (() => {
11669
11880
  route: "POST /SASjsApi/group",
11670
11881
  description: "refuses a name that is taken",
11671
11882
  identity: ADMIN_SIGNED_IN,
11672
- request: { token: ADMIN3, body: { name: "DCGroup", description: "again" } },
11883
+ request: { token: ADMIN4, body: { name: "DCGroup", description: "again" } },
11673
11884
  expect: { status: 409, error: "Group name already exists." }
11674
11885
  },
11675
11886
  {
@@ -11678,7 +11889,7 @@ var SASjsApi = (() => {
11678
11889
  description: "adds a member and returns the group",
11679
11890
  identity: ADMIN_SIGNED_IN,
11680
11891
  request: {
11681
- token: ADMIN3,
11892
+ token: ADMIN4,
11682
11893
  params: { groupUid: "group-admins", userUid: RESTRICTED_UID }
11683
11894
  },
11684
11895
  expect: {
@@ -11692,7 +11903,7 @@ var SASjsApi = (() => {
11692
11903
  description: "refuses a change to the reserved public group",
11693
11904
  identity: PROVIDER_MANAGED,
11694
11905
  request: {
11695
- token: ADMIN3,
11906
+ token: ADMIN4,
11696
11907
  params: { groupUid: "group-public", userUid: RESTRICTED_UID }
11697
11908
  },
11698
11909
  expect: { status: 400, error: "Can't add/remove user to 'public' group." }
@@ -11703,7 +11914,7 @@ var SASjsApi = (() => {
11703
11914
  description: "refuses a membership change by a non-administrator",
11704
11915
  identity: ADMIN_SIGNED_IN,
11705
11916
  request: {
11706
- token: RESTRICTED2,
11917
+ token: RESTRICTED4,
11707
11918
  params: { groupUid: "group-admins", userUid: RESTRICTED_UID }
11708
11919
  },
11709
11920
  expect: { status: 401, error: "Admin account required" }
@@ -11714,7 +11925,7 @@ var SASjsApi = (() => {
11714
11925
  description: "answers 404 for a group that does not exist",
11715
11926
  identity: ADMIN_SIGNED_IN,
11716
11927
  request: {
11717
- token: ADMIN3,
11928
+ token: ADMIN4,
11718
11929
  params: { groupUid: "group-none", userUid: RESTRICTED_UID }
11719
11930
  },
11720
11931
  expect: { status: 404, error: "Group not found." }
@@ -11725,7 +11936,7 @@ var SASjsApi = (() => {
11725
11936
  description: "refuses a membership change on a provider-managed group",
11726
11937
  identity: PROVIDER_MANAGED,
11727
11938
  request: {
11728
- token: ADMIN3,
11939
+ token: ADMIN4,
11729
11940
  params: { groupUid: "group-directory", userUid: RESTRICTED_UID }
11730
11941
  },
11731
11942
  expect: {
@@ -11739,7 +11950,7 @@ var SASjsApi = (() => {
11739
11950
  description: "removes a member and returns the group",
11740
11951
  identity: ADMIN_SIGNED_IN,
11741
11952
  request: {
11742
- token: ADMIN3,
11953
+ token: ADMIN4,
11743
11954
  params: { groupUid: "group-data-controller", userUid: RESTRICTED_UID }
11744
11955
  },
11745
11956
  expect: {
@@ -11753,7 +11964,7 @@ var SASjsApi = (() => {
11753
11964
  description: "refuses a membership change for a provider-managed user",
11754
11965
  identity: PROVIDER_MANAGED,
11755
11966
  request: {
11756
- token: ADMIN3,
11967
+ token: ADMIN4,
11757
11968
  params: { groupUid: "group-admins", userUid: "user-directory" }
11758
11969
  },
11759
11970
  expect: {
@@ -11767,7 +11978,7 @@ var SASjsApi = (() => {
11767
11978
  description: "refuses a membership change for a provider-managed user",
11768
11979
  identity: PROVIDER_MANAGED,
11769
11980
  request: {
11770
- token: ADMIN3,
11981
+ token: ADMIN4,
11771
11982
  params: { groupUid: "group-admins", userUid: "user-directory" }
11772
11983
  },
11773
11984
  expect: {
@@ -11781,7 +11992,7 @@ var SASjsApi = (() => {
11781
11992
  description: "refuses a change to the reserved public group",
11782
11993
  identity: PROVIDER_MANAGED,
11783
11994
  request: {
11784
- token: ADMIN3,
11995
+ token: ADMIN4,
11785
11996
  params: { groupUid: "group-public", userUid: RESTRICTED_UID }
11786
11997
  },
11787
11998
  expect: { status: 400, error: "Can't add/remove user to 'public' group." }
@@ -11792,7 +12003,7 @@ var SASjsApi = (() => {
11792
12003
  description: "refuses a membership change by a non-administrator",
11793
12004
  identity: ADMIN_SIGNED_IN,
11794
12005
  request: {
11795
- token: RESTRICTED2,
12006
+ token: RESTRICTED4,
11796
12007
  params: { groupUid: "group-data-controller", userUid: RESTRICTED_UID }
11797
12008
  },
11798
12009
  expect: { status: 401, error: "Admin account required" }
@@ -11803,7 +12014,7 @@ var SASjsApi = (() => {
11803
12014
  description: "answers 404 for a member that does not exist",
11804
12015
  identity: ADMIN_SIGNED_IN,
11805
12016
  request: {
11806
- token: ADMIN3,
12017
+ token: ADMIN4,
11807
12018
  params: { groupUid: "group-admins", userUid: "user-none" }
11808
12019
  },
11809
12020
  expect: { status: 404, error: "User not found." }
@@ -11814,7 +12025,7 @@ var SASjsApi = (() => {
11814
12025
  description: "refuses a membership change on a provider-managed group",
11815
12026
  identity: PROVIDER_MANAGED,
11816
12027
  request: {
11817
- token: ADMIN3,
12028
+ token: ADMIN4,
11818
12029
  params: { groupUid: "group-directory", userUid: RESTRICTED_UID }
11819
12030
  },
11820
12031
  expect: {
@@ -11827,7 +12038,7 @@ var SASjsApi = (() => {
11827
12038
  route: "DELETE /SASjsApi/group/{uid}",
11828
12039
  description: "deletes a group",
11829
12040
  identity: ADMIN_SIGNED_IN,
11830
- request: { token: ADMIN3, params: { uid: "group-data-controller" } },
12041
+ request: { token: ADMIN4, params: { uid: "group-data-controller" } },
11831
12042
  expect: { status: 200 }
11832
12043
  },
11833
12044
  {
@@ -11835,7 +12046,7 @@ var SASjsApi = (() => {
11835
12046
  route: "DELETE /SASjsApi/group/{uid}",
11836
12047
  description: "refuses a deletion by a caller who is not an administrator",
11837
12048
  identity: ADMIN_SIGNED_IN,
11838
- request: { token: RESTRICTED2, params: { uid: "group-admins" } },
12049
+ request: { token: RESTRICTED4, params: { uid: "group-admins" } },
11839
12050
  expect: { status: 401, error: "Admin account required" }
11840
12051
  },
11841
12052
  {
@@ -11843,7 +12054,7 @@ var SASjsApi = (() => {
11843
12054
  route: "DELETE /SASjsApi/group/{uid}",
11844
12055
  description: "answers 404 for an identifier no group has",
11845
12056
  identity: ADMIN_SIGNED_IN,
11846
- request: { token: ADMIN3, params: { uid: "group-none" } },
12057
+ request: { token: ADMIN4, params: { uid: "group-none" } },
11847
12058
  expect: { status: 404, error: "Group not found." }
11848
12059
  },
11849
12060
  // ------------------------------------------------------------ permissions
@@ -11852,7 +12063,7 @@ var SASjsApi = (() => {
11852
12063
  route: "GET /SASjsApi/info/authorizedRoutes",
11853
12064
  description: "answers the route inventory to an administrator",
11854
12065
  identity: ADMIN_SIGNED_IN,
11855
- request: { token: ADMIN3 },
12066
+ request: { token: ADMIN4 },
11856
12067
  expect: {
11857
12068
  status: 200,
11858
12069
  body: {
@@ -11876,7 +12087,7 @@ var SASjsApi = (() => {
11876
12087
  route: "GET /SASjsApi/info/authorizedRoutes",
11877
12088
  description: "refuses the inventory to a caller who is not an administrator",
11878
12089
  identity: ADMIN_SIGNED_IN,
11879
- request: { token: RESTRICTED2 },
12090
+ request: { token: RESTRICTED4 },
11880
12091
  expect: { status: 401, error: "Admin account required" }
11881
12092
  },
11882
12093
  {
@@ -11884,7 +12095,7 @@ var SASjsApi = (() => {
11884
12095
  route: "GET /SASjsApi/info/myAuthorizedRoutes",
11885
12096
  description: "answers every route to an administrator",
11886
12097
  identity: ADMIN_SIGNED_IN,
11887
- request: { token: ADMIN3 },
12098
+ request: { token: ADMIN4 },
11888
12099
  expect: {
11889
12100
  status: 200,
11890
12101
  body: {
@@ -11908,7 +12119,7 @@ var SASjsApi = (() => {
11908
12119
  route: "GET /SASjsApi/info/myAuthorizedRoutes",
11909
12120
  description: "answers a caller only the routes its rules grant",
11910
12121
  identity: ADMIN_SIGNED_IN,
11911
- request: { token: RESTRICTED2 },
12122
+ request: { token: RESTRICTED4 },
11912
12123
  expect: {
11913
12124
  status: 200,
11914
12125
  // /AppStream is visible whatever the rules say; the two grants come from
@@ -11924,7 +12135,7 @@ var SASjsApi = (() => {
11924
12135
  route: "GET /SASjsApi/permission",
11925
12136
  description: "returns every rule to an administrator",
11926
12137
  identity: ADMIN_SIGNED_IN,
11927
- request: { token: ADMIN3 },
12138
+ request: { token: ADMIN4 },
11928
12139
  expect: {
11929
12140
  status: 200,
11930
12141
  body: [
@@ -11957,7 +12168,7 @@ var SASjsApi = (() => {
11957
12168
  route: "GET /SASjsApi/permission",
11958
12169
  description: "returns a caller only their own rules and their groups'",
11959
12170
  identity: ADMIN_SIGNED_IN,
11960
- request: { token: RESTRICTED2 },
12171
+ request: { token: RESTRICTED4 },
11961
12172
  expect: {
11962
12173
  status: 200,
11963
12174
  body: [
@@ -11999,7 +12210,7 @@ var SASjsApi = (() => {
11999
12210
  description: "creates a rule for a user",
12000
12211
  identity: ADMIN_SIGNED_IN,
12001
12212
  request: {
12002
- token: ADMIN3,
12213
+ token: ADMIN4,
12003
12214
  body: {
12004
12215
  path: "/SASjsApi/drive/folder",
12005
12216
  type: "Route",
@@ -12019,7 +12230,7 @@ var SASjsApi = (() => {
12019
12230
  description: "creates a rule for a group",
12020
12231
  identity: ADMIN_SIGNED_IN,
12021
12232
  request: {
12022
- token: ADMIN3,
12233
+ token: ADMIN4,
12023
12234
  body: {
12024
12235
  path: "/SASjsApi/drive/rename",
12025
12236
  type: "Route",
@@ -12043,7 +12254,7 @@ var SASjsApi = (() => {
12043
12254
  description: "refuses a principal type that is neither a user nor a group",
12044
12255
  identity: ADMIN_SIGNED_IN,
12045
12256
  request: {
12046
- token: ADMIN3,
12257
+ token: ADMIN4,
12047
12258
  body: {
12048
12259
  path: "/SASjsApi/drive/deploy",
12049
12260
  type: "Route",
@@ -12063,7 +12274,7 @@ var SASjsApi = (() => {
12063
12274
  description: "refuses a rule assigned to an administrator",
12064
12275
  identity: ADMIN_SIGNED_IN,
12065
12276
  request: {
12066
- token: ADMIN3,
12277
+ token: ADMIN4,
12067
12278
  body: {
12068
12279
  path: "/SASjsApi/drive/folder",
12069
12280
  type: "Route",
@@ -12083,7 +12294,7 @@ var SASjsApi = (() => {
12083
12294
  description: "refuses a creation by a non-administrator",
12084
12295
  identity: ADMIN_SIGNED_IN,
12085
12296
  request: {
12086
- token: RESTRICTED2,
12297
+ token: RESTRICTED4,
12087
12298
  body: {
12088
12299
  path: "/SASjsApi/drive/folder",
12089
12300
  type: "Route",
@@ -12100,7 +12311,7 @@ var SASjsApi = (() => {
12100
12311
  description: "answers 404 for a principal that does not exist",
12101
12312
  identity: ADMIN_SIGNED_IN,
12102
12313
  request: {
12103
- token: ADMIN3,
12314
+ token: ADMIN4,
12104
12315
  body: {
12105
12316
  path: "/SASjsApi/drive/rename",
12106
12317
  type: "Route",
@@ -12117,7 +12328,7 @@ var SASjsApi = (() => {
12117
12328
  description: "refuses a group rule that already exists",
12118
12329
  identity: ADMIN_SIGNED_IN,
12119
12330
  request: {
12120
- token: ADMIN3,
12331
+ token: ADMIN4,
12121
12332
  body: {
12122
12333
  path: "/SASjsApi/drive/file",
12123
12334
  type: "Route",
@@ -12137,7 +12348,7 @@ var SASjsApi = (() => {
12137
12348
  description: "refuses a rule that already exists",
12138
12349
  identity: ADMIN_SIGNED_IN,
12139
12350
  request: {
12140
- token: ADMIN3,
12351
+ token: ADMIN4,
12141
12352
  body: {
12142
12353
  path: "/SASjsApi/code/execute",
12143
12354
  type: "Route",
@@ -12157,7 +12368,7 @@ var SASjsApi = (() => {
12157
12368
  description: "flips a rule from Deny to Grant",
12158
12369
  identity: ADMIN_SIGNED_IN,
12159
12370
  request: {
12160
- token: ADMIN3,
12371
+ token: ADMIN4,
12161
12372
  params: { uid: "rule-code" },
12162
12373
  body: { setting: "Grant" }
12163
12374
  },
@@ -12169,7 +12380,7 @@ var SASjsApi = (() => {
12169
12380
  description: "refuses a change by a non-administrator",
12170
12381
  identity: ADMIN_SIGNED_IN,
12171
12382
  request: {
12172
- token: RESTRICTED2,
12383
+ token: RESTRICTED4,
12173
12384
  params: { uid: "rule-code" },
12174
12385
  body: { setting: "Grant" }
12175
12386
  },
@@ -12181,7 +12392,7 @@ var SASjsApi = (() => {
12181
12392
  description: "answers 404 for a rule that does not exist",
12182
12393
  identity: ADMIN_SIGNED_IN,
12183
12394
  request: {
12184
- token: ADMIN3,
12395
+ token: ADMIN4,
12185
12396
  params: { uid: "rule-none" },
12186
12397
  body: { setting: "Grant" }
12187
12398
  },
@@ -12192,7 +12403,7 @@ var SASjsApi = (() => {
12192
12403
  route: "DELETE /SASjsApi/permission/{uid}",
12193
12404
  description: "deletes a rule",
12194
12405
  identity: ADMIN_SIGNED_IN,
12195
- request: { token: ADMIN3, params: { uid: "rule-code" } },
12406
+ request: { token: ADMIN4, params: { uid: "rule-code" } },
12196
12407
  expect: { status: 200, body: "Permission Deleted!" }
12197
12408
  },
12198
12409
  {
@@ -12200,7 +12411,7 @@ var SASjsApi = (() => {
12200
12411
  route: "DELETE /SASjsApi/permission/{uid}",
12201
12412
  description: "refuses a deletion by a non-administrator",
12202
12413
  identity: ADMIN_SIGNED_IN,
12203
- request: { token: RESTRICTED2, params: { uid: "rule-code" } },
12414
+ request: { token: RESTRICTED4, params: { uid: "rule-code" } },
12204
12415
  expect: { status: 401, error: "Admin account required" }
12205
12416
  },
12206
12417
  {
@@ -12208,7 +12419,7 @@ var SASjsApi = (() => {
12208
12419
  route: "DELETE /SASjsApi/permission/{uid}",
12209
12420
  description: "answers 404 for a rule that does not exist",
12210
12421
  identity: ADMIN_SIGNED_IN,
12211
- request: { token: ADMIN3, params: { uid: "rule-none" } },
12422
+ request: { token: ADMIN4, params: { uid: "rule-none" } },
12212
12423
  expect: { status: 404, error: "Permission not found." }
12213
12424
  },
12214
12425
  // --------------------------------------------------------------- clients
@@ -12217,7 +12428,7 @@ var SASjsApi = (() => {
12217
12428
  route: "GET /SASjsApi/client",
12218
12429
  description: "lists the registered clients",
12219
12430
  identity: ADMIN_SIGNED_IN,
12220
- request: { token: ADMIN3 },
12431
+ request: { token: ADMIN4 },
12221
12432
  expect: {
12222
12433
  status: 200,
12223
12434
  body: [
@@ -12241,7 +12452,7 @@ var SASjsApi = (() => {
12241
12452
  route: "GET /SASjsApi/client",
12242
12453
  description: "refuses the list to a caller who is not an administrator",
12243
12454
  identity: ADMIN_SIGNED_IN,
12244
- request: { token: RESTRICTED2 },
12455
+ request: { token: RESTRICTED4 },
12245
12456
  expect: { status: 401, error: "Admin account required" }
12246
12457
  },
12247
12458
  {
@@ -12250,7 +12461,7 @@ var SASjsApi = (() => {
12250
12461
  description: "registers a client",
12251
12462
  identity: ADMIN_SIGNED_IN,
12252
12463
  request: {
12253
- token: ADMIN3,
12464
+ token: ADMIN4,
12254
12465
  body: {
12255
12466
  clientId: "new_app",
12256
12467
  clientSecret: "new_secret",
@@ -12274,7 +12485,7 @@ var SASjsApi = (() => {
12274
12485
  description: "applies the schema defaults when the lifetimes are omitted",
12275
12486
  identity: ADMIN_SIGNED_IN,
12276
12487
  request: {
12277
- token: ADMIN3,
12488
+ token: ADMIN4,
12278
12489
  body: { clientId: "default_app", clientSecret: "default_secret" }
12279
12490
  },
12280
12491
  expect: {
@@ -12293,7 +12504,7 @@ var SASjsApi = (() => {
12293
12504
  description: "refuses a registration by a non-administrator",
12294
12505
  identity: ADMIN_SIGNED_IN,
12295
12506
  request: {
12296
- token: RESTRICTED2,
12507
+ token: RESTRICTED4,
12297
12508
  body: {
12298
12509
  clientId: "new_app",
12299
12510
  clientSecret: "new_secret",
@@ -12309,7 +12520,7 @@ var SASjsApi = (() => {
12309
12520
  description: "refuses a client id that is registered, with the 403 the server sends",
12310
12521
  identity: ADMIN_SIGNED_IN,
12311
12522
  request: {
12312
- token: ADMIN3,
12523
+ token: ADMIN4,
12313
12524
  body: {
12314
12525
  clientId: "web_app",
12315
12526
  clientSecret: "other",
@@ -12326,7 +12537,7 @@ var SASjsApi = (() => {
12326
12537
  description: "changes the caller’s own password",
12327
12538
  identity: ADMIN_SIGNED_IN,
12328
12539
  request: {
12329
- token: RESTRICTED2,
12540
+ token: RESTRICTED4,
12330
12541
  body: { currentPassword: "Orion123", newPassword: "changed123" }
12331
12542
  },
12332
12543
  expect: { status: 204 }
@@ -12336,7 +12547,7 @@ var SASjsApi = (() => {
12336
12547
  route: "PATCH /SASjsApi/auth/updatePassword",
12337
12548
  description: "refuses a body without the current password",
12338
12549
  identity: ADMIN_SIGNED_IN,
12339
- request: { token: RESTRICTED2, body: { newPassword: "changed123" } },
12550
+ request: { token: RESTRICTED4, body: { newPassword: "changed123" } },
12340
12551
  expect: { status: 400, error: '"currentPassword" is required' }
12341
12552
  },
12342
12553
  {
@@ -12355,7 +12566,7 @@ var SASjsApi = (() => {
12355
12566
  description: "refuses a change whose current password is wrong",
12356
12567
  identity: ADMIN_SIGNED_IN,
12357
12568
  request: {
12358
- token: RESTRICTED2,
12569
+ token: RESTRICTED4,
12359
12570
  body: { currentPassword: "wrong", newPassword: "changed123" }
12360
12571
  },
12361
12572
  expect: { status: 403, error: "Invalid current password!" }