@scalar/workspace-store 0.71.0 → 0.71.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @scalar/workspace-store
2
2
 
3
+ ## 0.71.1
4
+
5
+ ### Patch Changes
6
+
7
+ - [#10937](https://github.com/scalar/scalar/pull/10937): fix: generate valid base64 examples for `format: byte` and `contentEncoding: base64`/`base64url` strings
8
+
3
9
  ## 0.71.0
4
10
 
5
11
  ### Minor Changes
@@ -1 +1 @@
1
- {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAia9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA6tBD,sEAAsE;AACtE,MAAM,MAAM,2BAA2B,GAAG;IACxC,2EAA2E;IAC3E,CAAC,kBAAkB,CAAC,CAAC,EAAE,sBAAsB,CAAA;IAC7C,mFAAmF;IACnF,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,kFAAkF;IAClF,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,uDAAuD;IACvD,IAAI,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;IACvB,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,qDAAqD;IACrD,8BAA8B,CAAC,EAAE,OAAO,CAAA;IACxC,0DAA0D;IAC1D,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAC9C,CAAA;AA6fD;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,yBAAyB,WACrB,YAAY,YACV,2BAA2B,sGAUlC,OAAO,CAAC;IACT,KAAK,EAAE,MAAM,CAAA;IACb,YAAY,EAAE,YAAY,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,OAAO,CAAC,MAAM,CAAC,CAAA;IACrB,6EAA6E;IAC7E,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,qGAAqG;IACrG,YAAY,EAAE,YAAY,CAAA;IAC1B,4FAA4F;IAC5F,aAAa,EAAE,WAAW,CAAC,MAAM,CAAC,CAAA;IAClC,+GAA+G;IAC/G,kBAAkB,EAAE,OAAO,CAAA;CAC5B,CAAC,KACD,OAgTF,CAAA;AAkBD;;;GAGG;AACH,eAAO,MAAM,oBAAoB,WACvB,YAAY,YACV,2BAA2B,YAC5B,UAAU,CAAC,OAAO,yBAAyB,CAAC,CAAC,CAAC,CAAC,KACvD,OA2BF,CAAA"}
1
+ {"version":3,"file":"get-example-from-schema.d.ts","sourceRoot":"","sources":["../../../../src/request-example/builder/helpers/get-example-from-schema.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,KAAK,YAAY,EAAqD,MAAM,uBAAuB,CAAA;AAM5G,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAA;AAE1E,OAAO,EAAE,kBAAkB,EAA0B,KAAK,sBAAsB,EAAE,MAAM,sBAAsB,CAAA;AAob9G,gGAAgG;AAChG,eAAO,MAAM,wBAAwB,WAC3B,YAAY,cACR,MAAM,EAAE,YACV,2BAA2B,+BAE7B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAC9B,YAAY,GAAG,SAoBjB,CAAA;AA6t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.js';
14
14
  const MAX_LEVELS_DEEP = 10;
15
15
  /** Default name used for additional properties when no custom name is provided */
16
16
  const DEFAULT_ADDITIONAL_PROPERTIES_NAME = 'additionalProperty';
17
+ /**
18
+ * Base64 of the bytes "scalar". Six bytes encode without `=` padding and the output avoids `+`, `/`,
19
+ * `-` and `_`, so strict decoders accept it under both the standard and URL-safe alphabets (RFC 4648).
20
+ */
21
+ const BASE64_EXAMPLE = 'c2NhbGFy';
22
+ /** Content encodings whose example is the base64 placeholder (compared case-insensitively, as in RFC 2045). */
23
+ const BASE64_CONTENT_ENCODINGS = new Set(['base64', 'base64url']);
17
24
  /**
18
25
  * Mapping of OpenAPI string formats to example values.
19
26
  * Used to generate realistic examples for different string formats.
20
27
  */
21
28
  const genericExampleValues = {
29
+ // OpenAPI 3.0 base64 encoded characters. A plain placeholder like "string" is not valid base64.
30
+ 'byte': BASE64_EXAMPLE,
22
31
  'duration': 'P1D',
23
32
  'email': 'hello@example.com',
24
33
  'hostname': 'example.com',
@@ -75,6 +84,11 @@ const guessFromFormat = (schema, makeUpRandomData = false, fallback = '') => {
75
84
  if (isFileSchema(schema, false)) {
76
85
  return '@filename';
77
86
  }
87
+ // Encoded strings need a valid encoding even when a format also supplies a placeholder, such as password.
88
+ if (typeof schema.contentEncoding === 'string' &&
89
+ BASE64_CONTENT_ENCODINGS.has(schema.contentEncoding.toLowerCase())) {
90
+ return BASE64_EXAMPLE;
91
+ }
78
92
  if ('format' in schema && ['date', 'date-time', 'time'].includes(schema.format ?? '')) {
79
93
  // Do not persist enclosing objects or arrays with generated clock-dependent values.
80
94
  generatedCurrentTime = true;
package/package.json CHANGED
@@ -16,7 +16,7 @@
16
16
  "openapi",
17
17
  "scalar"
18
18
  ],
19
- "version": "0.71.0",
19
+ "version": "0.71.1",
20
20
  "engines": {
21
21
  "node": ">=22.19.0"
22
22
  },
@@ -153,14 +153,14 @@
153
153
  "CHANGELOG.md"
154
154
  ],
155
155
  "dependencies": {
156
- "@scalar/asyncapi-upgrader": "0.1.20",
157
- "@scalar/helpers": "0.17.1",
158
- "@scalar/json-magic": "0.19.0",
159
- "@scalar/openapi-upgrader": "0.4.8",
160
- "@scalar/schemas": "0.17.0",
161
- "@scalar/snippetz": "0.10.16",
156
+ "@scalar/asyncapi-upgrader": "0.1.21",
157
+ "@scalar/helpers": "0.18.0",
158
+ "@scalar/json-magic": "0.19.1",
159
+ "@scalar/openapi-upgrader": "0.4.9",
160
+ "@scalar/schemas": "0.17.1",
161
+ "@scalar/snippetz": "0.10.17",
162
162
  "@scalar/typebox": "0.1.3",
163
- "@scalar/types": "0.28.0",
163
+ "@scalar/types": "0.28.1",
164
164
  "@scalar/validation": "0.6.7",
165
165
  "js-base64": "^3.9.4",
166
166
  "type-fest": "^5.10.0",