@scalar/workspace-store 0.76.0 → 0.77.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 (62) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/dist/client.d.ts.map +1 -1
  3. package/dist/client.js +76 -62
  4. package/dist/entities/auth/index.d.ts.map +1 -1
  5. package/dist/entities/auth/index.js +26 -14
  6. package/dist/entities/auth/schema.d.ts +65 -0
  7. package/dist/entities/auth/schema.d.ts.map +1 -1
  8. package/dist/entities/history/index.d.ts.map +1 -1
  9. package/dist/entities/history/index.js +25 -14
  10. package/dist/helpers/dynamic-ref.d.ts +4 -25
  11. package/dist/helpers/dynamic-ref.d.ts.map +1 -1
  12. package/dist/helpers/dynamic-ref.js +33 -76
  13. package/dist/helpers/resolve-form-schema.js +1 -1
  14. package/dist/helpers/resolve-schema-with-annotations.js +1 -1
  15. package/dist/mutators/document.js +3 -3
  16. package/dist/navigation/get-navigation-options.d.ts.map +1 -1
  17. package/dist/navigation/get-navigation-options.js +10 -0
  18. package/dist/navigation/helpers/traverse-asyncapi-document.d.ts.map +1 -1
  19. package/dist/navigation/helpers/traverse-asyncapi-document.js +37 -3
  20. package/dist/request-example/builder/helpers/get-example-from-schema.d.ts.map +1 -1
  21. package/dist/request-example/builder/helpers/get-example-from-schema.js +21 -16
  22. package/dist/request-example/builder/helpers/get-example.js +1 -1
  23. package/dist/request-example/builder/helpers/get-resolved-url.d.ts.map +1 -1
  24. package/dist/request-example/builder/helpers/get-resolved-url.js +2 -4
  25. package/dist/request-example/builder/helpers/get-server-variables.d.ts +1 -1
  26. package/dist/request-example/builder/helpers/get-server-variables.d.ts.map +1 -1
  27. package/dist/request-example/builder/helpers/get-server-variables.js +2 -12
  28. package/dist/request-example/builder/helpers/resolve-server-url.d.ts +4 -0
  29. package/dist/request-example/builder/helpers/resolve-server-url.d.ts.map +1 -0
  30. package/dist/request-example/builder/helpers/resolve-server-url.js +4 -0
  31. package/dist/request-example/builder/index.d.ts +1 -0
  32. package/dist/request-example/builder/index.d.ts.map +1 -1
  33. package/dist/request-example/builder/index.js +1 -0
  34. package/dist/request-example/builder/request-factory.d.ts.map +1 -1
  35. package/dist/request-example/builder/request-factory.js +2 -5
  36. package/dist/request-example/context/security/merge-security.d.ts.map +1 -1
  37. package/dist/request-example/context/security/merge-security.js +13 -1
  38. package/dist/request-example/index.d.ts +1 -1
  39. package/dist/request-example/index.d.ts.map +1 -1
  40. package/dist/request-example/index.js +1 -1
  41. package/dist/request-example/xml/get-xml-example.js +7 -5
  42. package/dist/request-example/xml/write-xml.d.ts +2 -0
  43. package/dist/request-example/xml/write-xml.d.ts.map +1 -1
  44. package/dist/request-example/xml/write-xml.js +14 -4
  45. package/dist/{resolve.d.ts → resolve/index.d.ts} +3 -3
  46. package/dist/resolve/index.d.ts.map +1 -0
  47. package/dist/{resolve.js → resolve/index.js} +7 -5
  48. package/dist/schemas/navigation.d.ts +47 -2
  49. package/dist/schemas/navigation.d.ts.map +1 -1
  50. package/dist/schemas/navigation.js +11 -0
  51. package/dist/schemas/reference-config/index.d.ts +13 -0
  52. package/dist/schemas/reference-config/index.d.ts.map +1 -1
  53. package/dist/schemas/reference-config/settings.d.ts +13 -0
  54. package/dist/schemas/reference-config/settings.d.ts.map +1 -1
  55. package/dist/schemas/v3.1/strict/openapi-document.d.ts +455 -0
  56. package/dist/schemas/v3.1/strict/openapi-document.d.ts.map +1 -1
  57. package/dist/schemas/v3.2/strict/openapi-document.d.ts +455 -0
  58. package/dist/schemas/v3.2/strict/openapi-document.d.ts.map +1 -1
  59. package/dist/server.d.ts.map +1 -1
  60. package/dist/server.js +11 -10
  61. package/package.json +13 -13
  62. package/dist/resolve.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.77.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [#11180](https://github.com/scalar/scalar/pull/11180): Render reusable AsyncAPI messages in a searchable **Messages** section above **Models**. The section lists visible messages from `components.messages` with their headers, payload, examples, and applied traits. Set `hideModels` to hide the section.
8
+ - [#9625](https://github.com/scalar/scalar/pull/9625): Resolve JSON Schema 2020-12 `$dynamicRef` in the magic proxy and expose the bound schema through `@scalar/workspace-store/resolve`. Generic and recursive schemas now show their concrete types in rendered properties and JSON/XML request examples, including anchors nested inside a schema resource.
9
+
10
+ Keep repeated reads stable within each dynamic scope while allowing shared templates to bind independently. Edits through the proxy refresh bindings and resolved references while preserving ordinary proxy identities and unrelated documents’ anchor caches.
11
+
12
+ ### Patch Changes
13
+
14
+ - [#11165](https://github.com/scalar/scalar/pull/11165): Update compatible npm dependencies for Vue rendering, HTTP requests and serving, editor utilities, and query caching while preserving supported consumer TypeScript versions.
15
+
16
+ Keep string target IDs valid in the production-built Floating component after the Vue update.
17
+ - [#11206](https://github.com/scalar/scalar/pull/11206): Use empty OpenAPI server variable defaults in request URLs, OAuth server URLs, and code snippets.
18
+ - [#11224](https://github.com/scalar/scalar/pull/11224): Send authored response header examples (`example`, `examples`, or a `content` media type) instead of values generated from the header schema.
19
+
20
+ Emit each cookie in its own field and escape Unicode in JSON and XML header examples. Use the referenced schema’s component name as the default XML root element.
21
+
22
+ Share HTTP quoted-string escaping and support character references for line breaks and Unicode in XML header data.
23
+ - [#11193](https://github.com/scalar/scalar/pull/11193): Guard document, history, and authentication lookups against inherited properties while preserving valid workspace document names such as `constructor` and `prototype`. Ignore reserved keys when loading workspace snapshots and copying workspace metadata.
24
+ - [#11188](https://github.com/scalar/scalar/pull/11188): Preserve OAuth flow client IDs and other configured defaults when normalizing authentication schemes.
25
+
3
26
  ## 0.76.0
4
27
 
5
28
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,YAAY,EAAU,MAAM,2BAA2B,CAAA;AAErE,OAAO,EAAE,KAAK,UAAU,EA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GAAG,IAAI,CAAA;IAC7C;;;;;;;;;;;;;;;;;;;;;;;OAuBG;IACH,gCAAgC,CAAC,aAAa,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC,CAAA;IAC3F;;;;;;;;;;;;;;;;;;;OAmBG;IACH,cAAc,EAAE,CAAC,KAAK,EAAE,sBAAsB,KAAK,OAAO,CACtD;QACE,EAAE,EAAE,KAAK,CAAA;QACT,IAAI,EAAE,iBAAiB,GAAG,cAAc,GAAG,qBAAqB,CAAA;QAChE,OAAO,EAAE,MAAM,CAAA;KAChB,GACD;QACE,EAAE,EAAE,IAAI,CAAA;QACR,OAAO,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC,CAAA;QAC1C,SAAS,EAAE,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC,WAAW,CAAC,CAAA;QAChD,YAAY,EAAE,CACZ,iBAAiB,EACb;YACE,iBAAiB,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAA;SACzC,GACD;YACE,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAC1C,KACF,OAAO,CAAC,IAAI,CAAC,CAAA;KACnB,CACJ,CAAA;CACF,CAAA;AA2DD;;;;;;;;;;GAUG;AACH,eAAO,MAAM,oBAAoB,oBAAqB,cAAc,KAAG,cAy6CtE,CAAA;AAGD,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA"}
package/dist/client.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { upgrade as upgradeAsyncApi } from '@scalar/asyncapi-upgrader';
2
+ import { getOwnEntry } from '@scalar/helpers/object/get-own-entry';
2
3
  import { getValueAtPath } from '@scalar/helpers/object/get-value-at-path';
3
4
  import { isObject } from '@scalar/helpers/object/is-object';
4
5
  import { preventPollution } from '@scalar/helpers/object/prevent-pollution';
@@ -52,6 +53,17 @@ import { upgradeDocuments } from './plugins/bundler/upgrade-documents.js';
52
53
  * an unbounded number of connections on load.
53
54
  */
54
55
  const EXTERNAL_FETCH_CONCURRENCY_LIMIT = 10;
56
+ /** Removes the reserved key before assignment can change a workspace map's prototype. */
57
+ const omitReservedWorkspaceKey = (source) => {
58
+ if (!source || !Object.hasOwn(source, '__proto__')) {
59
+ return source;
60
+ }
61
+ console.warn('Ignoring reserved workspace key "__proto__".');
62
+ // Copy before filtering so the caller retains its original snapshot.
63
+ const copy = { ...source };
64
+ Reflect.deleteProperty(copy, '__proto__');
65
+ return copy;
66
+ };
55
67
  /**
56
68
  * Resolves a workspace document from various input sources (URL, local file, or direct document object).
57
69
  *
@@ -242,7 +254,8 @@ export const createWorkspaceStore = (workspaceProps) => {
242
254
  * @returns The active document or undefined if no document is found
243
255
  */
244
256
  get activeDocument() {
245
- return workspace.documents[getActiveDocumentName()];
257
+ const name = getActiveDocumentName();
258
+ return getOwnEntry(workspace.documents, name);
246
259
  },
247
260
  };
248
261
  /**
@@ -276,7 +289,7 @@ export const createWorkspaceStore = (workspaceProps) => {
276
289
  return;
277
290
  }
278
291
  const documentName = path[1];
279
- const document = workspace.documents[documentName] ?? {
292
+ const document = getOwnEntry(workspace.documents, documentName) ?? {
280
293
  openapi: '3.1.0',
281
294
  info: { title: '', version: '' },
282
295
  'x-scalar-original-document-hash': '',
@@ -304,7 +317,7 @@ export const createWorkspaceStore = (workspaceProps) => {
304
317
  /** Active document changes */
305
318
  if (type === 'activeDocument') {
306
319
  const documentName = getActiveDocumentName();
307
- const document = workspace.documents[documentName] ?? {
320
+ const document = getOwnEntry(workspace.documents, documentName) ?? {
308
321
  openapi: '3.1.0',
309
322
  info: { title: '', version: '' },
310
323
  'x-scalar-original-document-hash': '',
@@ -400,7 +413,7 @@ export const createWorkspaceStore = (workspaceProps) => {
400
413
  const event = {
401
414
  type,
402
415
  documentName: documentName,
403
- value: unpackProxyObject(originalDocuments[documentName] ?? {}),
416
+ value: unpackProxyObject(getOwnEntry(originalDocuments, documentName) ?? {}),
404
417
  path: path.splice(2),
405
418
  };
406
419
  fireWorkspaceChange(event);
@@ -409,7 +422,7 @@ export const createWorkspaceStore = (workspaceProps) => {
409
422
  const event = {
410
423
  type,
411
424
  documentName: documentName,
412
- value: unpackProxyObject(intermediateDocuments[documentName] ?? {}),
425
+ value: unpackProxyObject(getOwnEntry(intermediateDocuments, documentName) ?? {}),
413
426
  path: path.splice(2),
414
427
  };
415
428
  fireWorkspaceChange(event);
@@ -418,7 +431,7 @@ export const createWorkspaceStore = (workspaceProps) => {
418
431
  const event = {
419
432
  type,
420
433
  documentName: documentName,
421
- value: unpackProxyObject(overrides[documentName] ?? {}),
434
+ value: unpackProxyObject(getOwnEntry(overrides, documentName) ?? {}),
422
435
  };
423
436
  fireWorkspaceChange(event);
424
437
  }
@@ -434,7 +447,7 @@ export const createWorkspaceStore = (workspaceProps) => {
434
447
  fireWorkspaceChange({
435
448
  type: 'history',
436
449
  documentName,
437
- value: history.export()[documentName] ?? {},
450
+ value: getOwnEntry(history.export(), documentName) ?? {},
438
451
  });
439
452
  },
440
453
  },
@@ -448,7 +461,7 @@ export const createWorkspaceStore = (workspaceProps) => {
448
461
  fireWorkspaceChange({
449
462
  type: 'auth',
450
463
  documentName,
451
- value: auth.export()[documentName] ?? {
464
+ value: getOwnEntry(auth.export(), documentName) ?? {
452
465
  secrets: {},
453
466
  selected: { document: { selectedIndex: 0, selectedSchemes: [] }, path: {} },
454
467
  },
@@ -482,7 +495,7 @@ export const createWorkspaceStore = (workspaceProps) => {
482
495
  // the document - `saveDocument` writes directly into it and
483
496
  // `revertDocumentChanges` reads from it. Exporting therefore mirrors
484
497
  // exactly what the user would get if they reverted to the last save.
485
- const savedDocument = originalDocuments[documentName];
498
+ const savedDocument = getOwnEntry(originalDocuments, documentName);
486
499
  if (!savedDocument) {
487
500
  return;
488
501
  }
@@ -500,7 +513,7 @@ export const createWorkspaceStore = (workspaceProps) => {
500
513
  // reading from `getIntermediateDocument` observes fresh content while
501
514
  // the layer is being phased out.
502
515
  const saveDocument = async (documentName) => {
503
- const activeDocument = workspace.documents[documentName];
516
+ const activeDocument = getOwnEntry(workspace.documents, documentName);
504
517
  const newDocument = await getEditableDocument(documentName);
505
518
  if (!activeDocument || !newDocument) {
506
519
  console.warn('Failed to save document, active document is missing');
@@ -558,7 +571,7 @@ export const createWorkspaceStore = (workspaceProps) => {
558
571
  });
559
572
  const loaders = [
560
573
  fetchUrls({
561
- fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch,
574
+ fetch: getOwnEntry(extraDocumentConfigurations, name)?.fetch ?? workspaceProps?.fetch,
562
575
  // Cap concurrent fetches so a document with many external references or example
563
576
  // `externalValue`s (potentially thousands) does not flood the network on load.
564
577
  limit: EXTERNAL_FETCH_CONCURRENCY_LIMIT,
@@ -727,6 +740,11 @@ export const createWorkspaceStore = (workspaceProps) => {
727
740
  // If loading fails, a placeholder error document is added instead.
728
741
  async function addDocument(input, navigationOptions) {
729
742
  const { name, meta } = input;
743
+ // Assignment to this key on a plain document map changes its prototype.
744
+ if (name === '__proto__') {
745
+ console.error(`Invalid workspace document name: "${name}"`);
746
+ return false;
747
+ }
730
748
  /** Ensure we use the active proxy to fetch documents unless we have a custom fetch override */
731
749
  const fetch = getFetch({
732
750
  fetch: input.fetch ?? workspaceProps?.fetch,
@@ -754,18 +772,10 @@ export const createWorkspaceStore = (workspaceProps) => {
754
772
  });
755
773
  }
756
774
  const getOriginalDocument = (documentName) => {
757
- const rawDocument = unpackProxyObject(originalDocuments[documentName], { depth: 1 });
758
- if (!rawDocument) {
759
- return null;
760
- }
761
- return rawDocument;
775
+ return unpackProxyObject(getOwnEntry(originalDocuments, documentName), { depth: 1 }) ?? null;
762
776
  };
763
777
  const getIntermediateDocument = (documentName) => {
764
- const rawDocument = unpackProxyObject(intermediateDocuments[documentName], { depth: 1 });
765
- if (!rawDocument) {
766
- return null;
767
- }
768
- return rawDocument;
778
+ return unpackProxyObject(getOwnEntry(intermediateDocuments, documentName), { depth: 1 }) ?? null;
769
779
  };
770
780
  /**
771
781
  * Promotes the intermediate document to the original document so the
@@ -779,7 +789,7 @@ export const createWorkspaceStore = (workspaceProps) => {
779
789
  * reports `false` when the document does not exist at all.
780
790
  */
781
791
  const promoteIntermediateToOriginal = (documentName) => {
782
- return Boolean(intermediateDocuments[documentName]);
792
+ return Boolean(getOwnEntry(intermediateDocuments, documentName));
783
793
  };
784
794
  /**
785
795
  * Retrieves an editable clone of a workspace document.
@@ -792,11 +802,7 @@ export const createWorkspaceStore = (workspaceProps) => {
792
802
  * @returns The editable document object, or null if not found.
793
803
  */
794
804
  const getEditableDocument = async (documentName) => {
795
- if (!Object.hasOwn(workspace.documents, documentName)) {
796
- return null;
797
- }
798
- preventPollution(documentName, 'workspace document name');
799
- const rawDocument = unpackProxyObject(workspace.documents[documentName], { depth: 1 });
805
+ const rawDocument = unpackProxyObject(getOwnEntry(workspace.documents, documentName), { depth: 1 });
800
806
  if (!rawDocument) {
801
807
  // If the document does not exist, return null
802
808
  return null;
@@ -828,7 +834,7 @@ export const createWorkspaceStore = (workspaceProps) => {
828
834
  * @returns {boolean} True if the sidebar was built successfully, false if the document does not exist.
829
835
  */
830
836
  const buildSidebar = (documentName) => {
831
- const document = workspace.documents[documentName];
837
+ const document = getOwnEntry(workspace.documents, documentName);
832
838
  if (!document) {
833
839
  // Log and exit if the document does not exist in the workspace
834
840
  console.error(`Document '${documentName}' does not exist in the workspace.`);
@@ -868,7 +874,7 @@ export const createWorkspaceStore = (workspaceProps) => {
868
874
  await bundle(getRaw(holder), {
869
875
  plugins: [
870
876
  fetchUrls({
871
- fetch: extraDocumentConfigurations[documentName]?.fetch ?? workspaceProps?.fetch,
877
+ fetch: getOwnEntry(extraDocumentConfigurations, documentName)?.fetch ?? workspaceProps?.fetch,
872
878
  limit: EXTERNAL_FETCH_CONCURRENCY_LIMIT,
873
879
  }),
874
880
  ...(workspaceProps?.fileLoader ? [workspaceProps.fileLoader] : []),
@@ -892,11 +898,7 @@ export const createWorkspaceStore = (workspaceProps) => {
892
898
  * key in place, so asking again retries.
893
899
  */
894
900
  const loadNavigationChildren = async (documentName) => {
895
- // An inherited entry can point at a prototype, which must never receive chunk writes.
896
- if (!Object.hasOwn(workspace.documents, documentName)) {
897
- return;
898
- }
899
- const document = workspace.documents[documentName];
901
+ const document = getOwnEntry(workspace.documents, documentName);
900
902
  if (!isOpenApiDocument(document) && !isAsyncApiDocument(document)) {
901
903
  return;
902
904
  }
@@ -913,7 +915,7 @@ export const createWorkspaceStore = (workspaceProps) => {
913
915
  const load = (async () => {
914
916
  const chunk = await fetchNavigationChunk(documentName, ref, document['x-scalar-original-source-url']);
915
917
  // A replaced or deleted document must not publish changes from a stale request.
916
- if (chunk === undefined || workspace.documents[documentName] !== document) {
918
+ if (chunk === undefined || getOwnEntry(workspace.documents, documentName) !== document) {
917
919
  return;
918
920
  }
919
921
  // Assigned through the store's document, so the write is observed: a Vue effect reading the
@@ -935,7 +937,7 @@ export const createWorkspaceStore = (workspaceProps) => {
935
937
  return {
936
938
  asyncApiSchemaResources: (documentName) => {
937
939
  const name = documentName ?? getActiveDocumentName();
938
- const document = workspace.documents[name];
940
+ const document = getOwnEntry(workspace.documents, name);
939
941
  if (!document)
940
942
  return fallbackNativeSchemas;
941
943
  const raw = unpackProxyShallow(document);
@@ -947,14 +949,14 @@ export const createWorkspaceStore = (workspaceProps) => {
947
949
  origin: document['x-scalar-original-source-url'],
948
950
  usePreparedResources: !nativeSchemaEdits.has(raw),
949
951
  fileLoader: workspaceProps?.fileLoader,
950
- fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch,
952
+ fetch: getOwnEntry(extraDocumentConfigurations, name)?.fetch ?? workspaceProps?.fetch,
951
953
  });
952
954
  nativeSchemaResolvers.set(raw, resolve);
953
955
  return resolve;
954
956
  },
955
957
  externalExamples: (documentName) => {
956
958
  const name = documentName ?? getActiveDocumentName();
957
- const document = workspace.documents[name];
959
+ const document = getOwnEntry(workspace.documents, name);
958
960
  if (!document) {
959
961
  return fallbackExternalExamples;
960
962
  }
@@ -965,7 +967,7 @@ export const createWorkspaceStore = (workspaceProps) => {
965
967
  const resolver = createExternalExampleResolver({
966
968
  origin: document['x-scalar-original-source-url'],
967
969
  fileLoader: workspaceProps?.fileLoader,
968
- fetch: extraDocumentConfigurations[name]?.fetch ?? workspaceProps?.fetch,
970
+ fetch: getOwnEntry(extraDocumentConfigurations, name)?.fetch ?? workspaceProps?.fetch,
969
971
  });
970
972
  externalExampleResolvers.set(document, resolver);
971
973
  return resolver;
@@ -1000,8 +1002,8 @@ export const createWorkspaceStore = (workspaceProps) => {
1000
1002
  const loaded = await baselineStore.addDocument({
1001
1003
  name: documentName,
1002
1004
  document: original,
1003
- documentSource: workspace.documents[documentName]?.['x-scalar-original-source-url'],
1004
- fetch: extraDocumentConfigurations[documentName]?.fetch,
1005
+ documentSource: getOwnEntry(workspace.documents, documentName)?.['x-scalar-original-source-url'],
1006
+ fetch: getOwnEntry(extraDocumentConfigurations, documentName)?.fetch,
1005
1007
  });
1006
1008
  if (!loaded) {
1007
1009
  return undefined;
@@ -1012,7 +1014,8 @@ export const createWorkspaceStore = (workspaceProps) => {
1012
1014
  },
1013
1015
  getIntermediateDocument,
1014
1016
  updateDocument(name, key, value) {
1015
- const currentDocument = workspace.documents[name === 'active' ? getActiveDocumentName() : name];
1017
+ const documentName = name === 'active' ? getActiveDocumentName() : name;
1018
+ const currentDocument = getOwnEntry(workspace.documents, documentName);
1016
1019
  if (!currentDocument) {
1017
1020
  return false;
1018
1021
  }
@@ -1022,7 +1025,7 @@ export const createWorkspaceStore = (workspaceProps) => {
1022
1025
  },
1023
1026
  async replaceDocument(documentName, input) {
1024
1027
  // Used to preserve the original metadata of the document (we need to unpack so we don't store a proxy object)
1025
- const currentDocument = unpackProxyObject(workspace.documents[documentName], { depth: 1 });
1028
+ const currentDocument = unpackProxyObject(getOwnEntry(workspace.documents, documentName), { depth: 1 });
1026
1029
  if (!currentDocument) {
1027
1030
  return console.error(`Document '${documentName}' does not exist in the workspace.`);
1028
1031
  }
@@ -1097,7 +1100,7 @@ export const createWorkspaceStore = (workspaceProps) => {
1097
1100
  asyncApiSchemaResources(),
1098
1101
  openApiDocument(),
1099
1102
  fetchUrls({
1100
- fetch: extraDocumentConfigurations[getActiveDocumentName()]?.fetch ?? workspaceProps?.fetch,
1103
+ fetch: getOwnEntry(extraDocumentConfigurations, getActiveDocumentName())?.fetch ?? workspaceProps?.fetch,
1101
1104
  limit: EXTERNAL_FETCH_CONCURRENCY_LIMIT,
1102
1105
  }),
1103
1106
  ...(workspaceProps?.fileLoader ? [workspaceProps.fileLoader] : []),
@@ -1120,7 +1123,7 @@ export const createWorkspaceStore = (workspaceProps) => {
1120
1123
  */
1121
1124
  deleteDocument: (documentName) => {
1122
1125
  // Check if the document exists before attempting deletion
1123
- if (!workspace.documents[documentName]) {
1126
+ if (!getOwnEntry(workspace.documents, documentName)) {
1124
1127
  return;
1125
1128
  }
1126
1129
  // Delete the document from the workspace (this will trigger change detection events)
@@ -1153,12 +1156,12 @@ export const createWorkspaceStore = (workspaceProps) => {
1153
1156
  promoteIntermediateToOriginal,
1154
1157
  async revertDocumentChanges(documentName) {
1155
1158
  // Used to preserve the original metadata of the document (we need to unpack so we don't store a proxy object)
1156
- const workspaceDocument = unpackProxyObject(workspace.documents[documentName], { depth: 1 });
1159
+ const workspaceDocument = unpackProxyObject(getOwnEntry(workspace.documents, documentName), { depth: 1 });
1157
1160
  // Restore from the original (last saved) snapshot. `saveDocument`
1158
1161
  // writes here, so this reliably rolls back to whatever the user
1159
1162
  // last persisted - matching the soft-deprecation path away from the
1160
1163
  // intermediate document layer.
1161
- const baseline = unpackProxyObject(originalDocuments[documentName], { depth: 1 });
1164
+ const baseline = getOriginalDocument(documentName);
1162
1165
  if (!workspaceDocument || !baseline) {
1163
1166
  return;
1164
1167
  }
@@ -1204,18 +1207,20 @@ export const createWorkspaceStore = (workspaceProps) => {
1204
1207
  };
1205
1208
  },
1206
1209
  loadWorkspace(input) {
1210
+ const documents = omitReservedWorkspaceKey(input.documents);
1211
+ const loadedOverrides = omitReservedWorkspaceKey(input.overrides);
1207
1212
  // A workspace from a compact server store carries an index rather than per-node chunk
1208
1213
  // references; expanded here for the same reason `addInMemoryDocument` expands.
1209
- for (const document of Object.values(input.documents)) {
1214
+ for (const document of Object.values(documents)) {
1210
1215
  expandChunkIndex(document);
1211
1216
  }
1212
- safeAssign(workspace.documents, Object.fromEntries(Object.entries(input.documents).map(([name, doc]) => {
1217
+ safeAssign(workspace.documents, Object.fromEntries(Object.entries(documents).map(([name, doc]) => {
1213
1218
  // Hydration only rewraps: an exported document has already been upgraded, bundled, coerced
1214
1219
  // and given its navigation, so nothing here re-processes it.
1215
1220
  const magicDocument = createMagicProxy(doc, {
1216
1221
  documentUri: resolveOpenApiDocument(doc, doc['x-scalar-original-source-url'] ?? '/')?.baseUri,
1217
1222
  });
1218
- const documentOverrides = input.overrides[name];
1223
+ const documentOverrides = getOwnEntry(loadedOverrides, name);
1219
1224
  if (isAsyncApiDocument(magicDocument))
1220
1225
  checkNativeSchemaEdits(magicDocument);
1221
1226
  return [
@@ -1229,20 +1234,29 @@ export const createWorkspaceStore = (workspaceProps) => {
1229
1234
  if (isAsyncApiDocument(document))
1230
1235
  checkNativeSchemaEdits(document);
1231
1236
  }
1232
- safeAssign(originalDocuments, input.originalDocuments);
1233
- safeAssign(intermediateDocuments, input.intermediateDocuments);
1234
- safeAssign(overrides, input.overrides);
1235
- safeAssign(requestBodyBaselines, deepClone(input.requestBodyBaselines ?? {}));
1236
- safeAssign(workspace, input.meta);
1237
- history.load(input.history);
1238
- auth.load(input.auth);
1237
+ safeAssign(originalDocuments, omitReservedWorkspaceKey(input.originalDocuments));
1238
+ safeAssign(intermediateDocuments, omitReservedWorkspaceKey(input.intermediateDocuments));
1239
+ safeAssign(overrides, loadedOverrides);
1240
+ safeAssign(requestBodyBaselines, deepClone(omitReservedWorkspaceKey(input.requestBodyBaselines) ?? {}));
1241
+ safeAssign(workspace, omitReservedWorkspaceKey(input.meta));
1242
+ history.load(omitReservedWorkspaceKey(input.history));
1243
+ auth.load(omitReservedWorkspaceKey(input.auth));
1239
1244
  },
1240
- importWorkspaceFromSpecification: (specification) => {
1245
+ importWorkspaceFromSpecification: async (specification) => {
1241
1246
  const { documents, overrides, info: _info, workspace: _workspaceVersion, ...meta } = specification;
1247
+ for (const entries of [documents, overrides]) {
1248
+ if (entries && Object.hasOwn(entries, '__proto__')) {
1249
+ preventPollution('__proto__', 'workspace document name');
1250
+ }
1251
+ }
1242
1252
  // Assign workspace metadata
1243
- safeAssign(workspace, meta);
1253
+ safeAssign(workspace, omitReservedWorkspaceKey(meta));
1244
1254
  // Add workspace documents
1245
- return Promise.all(Object.entries(documents ?? {}).map(([name, doc]) => addDocument({ url: doc.$ref, name, overrides: overrides?.[name] })));
1255
+ return await Promise.all(Object.entries(documents ?? {}).map(([name, doc]) => addDocument({
1256
+ url: doc.$ref,
1257
+ name,
1258
+ overrides: getOwnEntry(overrides, name),
1259
+ })));
1246
1260
  },
1247
1261
  rebaseDocument: async (input) => {
1248
1262
  const { name } = input;
@@ -1251,9 +1265,9 @@ export const createWorkspaceStore = (workspaceProps) => {
1251
1265
  // about exactly two local snapshots: the original (last saved
1252
1266
  // baseline, written by `saveDocument`) and the active in-memory
1253
1267
  // document (with any unsaved edits on top).
1254
- const originalDocument = unpackProxyObject(originalDocuments[name], { depth: 1 });
1268
+ const originalDocument = getOriginalDocument(name);
1255
1269
  // raw version without any proxies
1256
- const activeDocumentRaw = unpackProxyObject(workspace.documents[name], { depth: 1 });
1270
+ const activeDocumentRaw = unpackProxyObject(getOwnEntry(workspace.documents, name), { depth: 1 });
1257
1271
  // editable version of the document (reversing bundling and also remove internal metadata)
1258
1272
  const activeDocument = await getEditableDocument(name);
1259
1273
  if (!originalDocument || !activeDocument || !activeDocumentRaw) {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/entities/auth/index.ts"],"names":[],"mapp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,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,gBAAgB,CAAC,KAAK,IAAI,CAAA;IAEvG;;;;OAIG;IACH,gBAAgB,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,KAAK,IAAI,CAAA;IAEpE;;;OAGG;IACH,iBAAiB,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;IAEjD;;;OAGG;IACH,IAAI,EAAE,CAAC,IAAI,EAAE,YAAY,KAAK,IAAI,CAAA;IAElC;;;OAGG;IACH,MAAM,EAAE,MAAM,YAAY,CAAA;CAC3B,CAAA;AAED,KAAK,sBAAsB,GAAG;IAC5B,KAAK,CAAC,EAAE;QACN,YAAY,CAAC,EAAE,CAAC,YAAY,EAAE,MAAM,KAAK,IAAI,CAAA;KAC9C,CAAA;CACF,CAAA;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,eAAe,sBAAsB,KAAQ,SAqHxE,CAAA"}
@@ -1,3 +1,4 @@
1
+ import { getOwnEntry } from '@scalar/helpers/object/get-own-entry';
1
2
  import { preventPollution } from '@scalar/helpers/object/prevent-pollution';
2
3
  import { reactive } from 'vue';
3
4
  import { DocumentAuthSchema, SecretsAuthUnionSchema, } from './schema.js';
@@ -12,28 +13,36 @@ export const createAuthStore = ({ hooks } = {}) => {
12
13
  // Vue reactive object to hold all authentication state
13
14
  const auth = reactive({});
14
15
  const getAuthSecrets = (documentName, schemeName) => {
15
- return auth[documentName]?.secrets?.[schemeName];
16
+ return getOwnEntry(getOwnEntry(auth, documentName)?.secrets, schemeName);
16
17
  };
17
18
  const setAuthSecrets = (documentName, schemeName, data) => {
18
- auth[documentName] ||= { secrets: {}, selected: { document: undefined, path: undefined } };
19
+ if (documentName === '__proto__' || schemeName === '__proto__') {
20
+ return;
21
+ }
22
+ if (!getOwnEntry(auth, documentName)) {
23
+ auth[documentName] = { secrets: {}, selected: { document: undefined, path: undefined } };
24
+ }
19
25
  auth[documentName].secrets[schemeName] = coerceValue(SecretsAuthUnionSchema, data);
20
26
  hooks?.onAuthChange?.(documentName);
21
27
  };
22
28
  const clearAuthSecrets = (documentName, schemeName) => {
23
- delete auth[documentName]?.secrets?.[schemeName];
29
+ delete getOwnEntry(auth, documentName)?.secrets?.[schemeName];
24
30
  hooks?.onAuthChange?.(documentName);
25
31
  };
26
32
  const getAuthSelectedSchemas = (payload) => {
33
+ const selected = getOwnEntry(auth, payload.documentName)?.selected;
27
34
  if (payload.type === 'document') {
28
- return auth[payload.documentName]?.selected?.document;
35
+ return selected?.document;
29
36
  }
30
- return auth[payload.documentName]?.selected?.path?.[payload.path]?.[payload.method];
37
+ return getOwnEntry(getOwnEntry(selected?.path, payload.path), payload.method);
31
38
  };
32
39
  const setAuthSelectedSchemas = (payload, selectedSchemes) => {
33
- auth[payload.documentName] ||= {
34
- secrets: {},
35
- selected: { document: undefined, path: undefined },
36
- };
40
+ if (payload.documentName === '__proto__') {
41
+ return;
42
+ }
43
+ if (!getOwnEntry(auth, payload.documentName)) {
44
+ auth[payload.documentName] = { secrets: {}, selected: { document: undefined, path: undefined } };
45
+ }
37
46
  // TypeScript needs a non-null assertion here since we just ensured it exists
38
47
  const documentAuth = auth[payload.documentName];
39
48
  if (payload.type === 'document') {
@@ -44,14 +53,16 @@ export const createAuthStore = ({ hooks } = {}) => {
44
53
  preventPollution(payload.path);
45
54
  preventPollution(payload.method);
46
55
  documentAuth.selected.path ||= {};
47
- documentAuth.selected.path[payload.path] ||= {};
56
+ if (!getOwnEntry(documentAuth.selected.path, payload.path)) {
57
+ documentAuth.selected.path[payload.path] = {};
58
+ }
48
59
  const pathAuth = documentAuth.selected.path[payload.path];
49
60
  pathAuth[payload.method] = selectedSchemes;
50
61
  }
51
62
  hooks?.onAuthChange?.(payload.documentName);
52
63
  };
53
64
  const clearAuthSelectedSchemas = (payload) => {
54
- const documentAuth = auth[payload.documentName];
65
+ const documentAuth = getOwnEntry(auth, payload.documentName);
55
66
  if (!documentAuth) {
56
67
  return;
57
68
  }
@@ -63,7 +74,7 @@ export const createAuthStore = ({ hooks } = {}) => {
63
74
  // Prevent altering dangerous keys to the path items object
64
75
  preventPollution(payload.method);
65
76
  preventPollution(payload.path);
66
- const pathAuth = documentAuth.selected.path?.[payload.path];
77
+ const pathAuth = getOwnEntry(documentAuth.selected.path, payload.path);
67
78
  if (!pathAuth) {
68
79
  return;
69
80
  }
@@ -75,9 +86,10 @@ export const createAuthStore = ({ hooks } = {}) => {
75
86
  hooks?.onAuthChange?.(documentName);
76
87
  };
77
88
  const load = (data) => {
78
- safeAssign(auth, coerceValue(DocumentAuthSchema, data));
89
+ const { __proto__: _reserved, ...documents } = data;
90
+ safeAssign(auth, coerceValue(DocumentAuthSchema, documents));
79
91
  // Trigger change events for all loaded documents
80
- Object.keys(data).forEach((documentName) => {
92
+ Object.keys(documents).forEach((documentName) => {
81
93
  hooks?.onAuthChange?.(documentName);
82
94
  });
83
95
  };