@scalar/blocks 0.7.4 → 0.8.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.
- package/CHANGELOG.md +10 -0
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.d.ts.map +1 -1
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js +30 -26
- package/dist/code-example/helpers/operation-to-har/process-security-schemes.js.map +1 -1
- package/dist/constants.js +1 -1
- package/dist/style.css +2 -2
- package/package.json +8 -8
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# @scalar/blocks
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#11103](https://github.com/scalar/scalar/pull/11103): Support `x-scalar-token-prefix` on header API keys. Generated code examples and outgoing requests add the configured prefix while stored credentials remain unchanged.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [#11123](https://github.com/scalar/scalar/pull/11123): Fix the API reference freezing on schemas with several recursive or cross-referencing `$ref`s. Generated examples that are too large to render at full depth are now rendered at the deepest depth that fits.
|
|
12
|
+
|
|
3
13
|
## 0.7.4
|
|
4
14
|
|
|
5
15
|
### Patch Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-security-schemes.d.ts","sourceRoot":"","sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,yCAAyC,CAAA;AACzF,OAAO,KAAK,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,YAAY,CAAA;AAGvD,KAAK,8BAA8B,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;IAC9B,WAAW,EAAE,UAAU,CAAC,aAAa,CAAC,CAAA;IACtC,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAA;CAC/B,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,GACjC,iBAAiB,0BAA0B,EAAE,KAC5C,8BA2EF,CAAA"}
|
|
@@ -1,50 +1,54 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { formatTokenPrefix as e } from "@scalar/helpers/http/format-token-prefix";
|
|
2
|
+
import { encode as t } from "js-base64";
|
|
2
3
|
// src/code-example/helpers/operation-to-har/process-security-schemes.ts
|
|
3
|
-
var
|
|
4
|
-
let
|
|
4
|
+
var n = (n) => {
|
|
5
|
+
let r = {
|
|
5
6
|
headers: [],
|
|
6
7
|
queryString: [],
|
|
7
8
|
cookies: []
|
|
8
9
|
};
|
|
9
|
-
for (let
|
|
10
|
-
let
|
|
11
|
-
if (!
|
|
12
|
-
let
|
|
13
|
-
name:
|
|
14
|
-
value:
|
|
10
|
+
for (let i of n) if (i.type === "apiKey") {
|
|
11
|
+
let t = i["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
12
|
+
if (!i.name) continue;
|
|
13
|
+
let n = {
|
|
14
|
+
name: i.name,
|
|
15
|
+
value: t
|
|
15
16
|
};
|
|
16
|
-
switch (
|
|
17
|
+
switch (i.in) {
|
|
17
18
|
case "header":
|
|
18
|
-
|
|
19
|
+
r.headers.push({
|
|
20
|
+
...n,
|
|
21
|
+
value: e(t, i["x-scalar-token-prefix"])
|
|
22
|
+
});
|
|
19
23
|
break;
|
|
20
24
|
case "query":
|
|
21
|
-
|
|
25
|
+
r.queryString.push(n);
|
|
22
26
|
break;
|
|
23
|
-
case "cookie":
|
|
27
|
+
case "cookie": r.cookies.push(n);
|
|
24
28
|
}
|
|
25
|
-
} else if (
|
|
26
|
-
if (
|
|
27
|
-
let
|
|
28
|
-
|
|
29
|
+
} else if (i.type === "http") {
|
|
30
|
+
if (i.scheme === "basic") {
|
|
31
|
+
let e = `${i["x-scalar-secret-username"] || ""}:${i["x-scalar-secret-password"] || ""}`, n = e === ":" ? "username:password" : t(e);
|
|
32
|
+
r.headers.push({
|
|
29
33
|
name: "Authorization",
|
|
30
|
-
value: `Basic ${
|
|
34
|
+
value: `Basic ${n}`
|
|
31
35
|
});
|
|
32
|
-
} else if (
|
|
33
|
-
let e =
|
|
34
|
-
|
|
36
|
+
} else if (i.scheme === "bearer") {
|
|
37
|
+
let e = i["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
38
|
+
r.headers.push({
|
|
35
39
|
name: "Authorization",
|
|
36
40
|
value: `Bearer ${e}`
|
|
37
41
|
});
|
|
38
42
|
}
|
|
39
|
-
} else if (
|
|
40
|
-
let e = Object.values(
|
|
41
|
-
|
|
43
|
+
} else if (i.type === "oauth2" && i.flows) {
|
|
44
|
+
let e = Object.values(i.flows).find((e) => e["x-scalar-secret-token"])?.["x-scalar-secret-token"] || "YOUR_SECRET_TOKEN";
|
|
45
|
+
r.headers.push({
|
|
42
46
|
name: "Authorization",
|
|
43
47
|
value: `Bearer ${e}`
|
|
44
48
|
});
|
|
45
49
|
}
|
|
46
|
-
return
|
|
50
|
+
return r;
|
|
47
51
|
};
|
|
48
|
-
export {
|
|
52
|
+
export { n as processSecuritySchemes };
|
|
49
53
|
|
|
50
54
|
//# sourceMappingURL=process-security-schemes.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process-security-schemes.js","names":["processSecuritySchemes","result","scheme","securitySchemes","value","param","auth","encode","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push(param)\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"process-security-schemes.js","names":["processSecuritySchemes","result","scheme","securitySchemes","value","param","formatTokenPrefix","auth","encode","token","f"],"sources":["../../../../src/code-example/helpers/operation-to-har/process-security-schemes.ts"],"sourcesContent":["import { formatTokenPrefix } from '@scalar/helpers/http/format-token-prefix'\nimport type { SecuritySchemeObjectSecret } from '@scalar/workspace-store/request-example'\nimport type { Request as HarRequest } from 'har-format'\nimport { encode } from 'js-base64'\n\ntype ProcessedSecuritySchemesReturn = {\n headers: HarRequest['headers']\n queryString: HarRequest['queryString']\n cookies: HarRequest['cookies']\n}\n\n/**\n * Process security schemes into whichever parameters they are applicable to\n *\n * TODO: we probably want to be able to disable YOUR_SECRET_TOKEN placeholder text + or allow it to be customzied\n */\nexport const processSecuritySchemes = (\n securitySchemes: SecuritySchemeObjectSecret[],\n): ProcessedSecuritySchemesReturn => {\n const result: ProcessedSecuritySchemesReturn = {\n headers: [],\n queryString: [],\n cookies: [],\n }\n\n for (const scheme of securitySchemes) {\n // Handle apiKey type\n if (scheme.type === 'apiKey') {\n const value = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n if (!scheme.name) {\n continue\n }\n\n const param = { name: scheme.name, value }\n\n switch (scheme.in) {\n case 'header':\n result.headers.push({ ...param, value: formatTokenPrefix(value, scheme['x-scalar-token-prefix']) })\n break\n case 'query':\n result.queryString.push(param)\n break\n case 'cookie':\n result.cookies.push(param)\n break\n }\n continue\n }\n\n // Handle http type\n if (scheme.type === 'http') {\n if (scheme.scheme === 'basic') {\n const username = scheme['x-scalar-secret-username'] || ''\n const password = scheme['x-scalar-secret-password'] || ''\n\n // The snippet is documentation, so we always show an Authorization header. When both\n // fields are empty we render a readable `username:password` placeholder, mirroring the\n // `YOUR_SECRET_TOKEN` placeholder used by the other schemes. (The real request omits the\n // header entirely in that case — see buildRequestSecurity.)\n const value = `${username}:${password}`\n const auth = value === ':' ? 'username:password' : encode(value)\n\n result.headers.push({\n name: 'Authorization',\n value: `Basic ${auth}`,\n })\n } else if (scheme.scheme === 'bearer') {\n const token = scheme['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n continue\n }\n\n // Handle oauth2 type\n if (scheme.type === 'oauth2' && scheme.flows) {\n const flows = Object.values(scheme.flows)\n\n // Find the first flow with a token\n const flow = flows.find((f) => f['x-scalar-secret-token'])\n const token = flow?.['x-scalar-secret-token'] || 'YOUR_SECRET_TOKEN'\n\n result.headers.push({\n name: 'Authorization',\n value: `Bearer ${token}`,\n })\n }\n }\n\n return result\n}\n"],"mappings":";;;AAgBA,IAAaA,KACX,MACmC;CACnC,IAAMC,IAAyC;EAC7C,SAAS,CAAC;EACV,aAAa,CAAC;EACd,SAAS,CAAC;CACZ;CAEA,KAAK,IAAMC,KAAUC,GAEnB,IAAID,EAAO,SAAS,UAAU;EAC5B,IAAME,IAAQF,EAAO,4BAA4B;EACjD,IAAI,CAACA,EAAO,MACV;EAGF,IAAMG,IAAQ;GAAE,MAAMH,EAAO;GAAM;EAAM;EAEzC,QAAQA,EAAO,IAAf;GACE,KAAK;IACH,EAAO,QAAQ,KAAK;KAAE,GAAGG;KAAO,OAAOC,EAAkBF,GAAOF,EAAO,wBAAwB;IAAE,CAAC;IAClG;GACF,KAAK;IACH,EAAO,YAAY,KAAKG,CAAK;IAC7B;GACF,KAAK,UACH,EAAO,QAAQ,KAAKA,CAAK;EAE7B;CAEF,OAGA,IAAIH,EAAO,SAAS,QAAQ;EAC1B,IAAIA,EAAO,WAAW,SAAS;GAQ7B,IAAME,IAAQ,GAPGF,EAAO,+BAA+B,GAO7B,GANTA,EAAO,+BAA+B,MAOjDK,IAAOH,MAAU,MAAM,sBAAsBI,EAAOJ,CAAK;GAE/D,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,SAASG;GAClB,CAAC;EACH,OAAO,IAAIL,EAAO,WAAW,UAAU;GACrC,IAAMO,IAAQP,EAAO,4BAA4B;GAEjD,EAAO,QAAQ,KAAK;IAClB,MAAM;IACN,OAAO,UAAUO;GACnB,CAAC;EACH;CAEF,OAGA,IAAIP,EAAO,SAAS,YAAYA,EAAO,OAAO;EAK5C,IAAMO,IAJQ,OAAO,OAAOP,EAAO,KAGtB,CAAA,CAAM,MAAM,MAAMQ,EAAE,wBACnB,CAAA,GAAO,4BAA4B;EAEjD,EAAO,QAAQ,KAAK;GAClB,MAAM;GACN,OAAO,UAAUD;EACnB,CAAC;CACH;CAGF,OAAOR;AACT"}
|
package/dist/constants.js
CHANGED
package/dist/style.css
CHANGED
|
@@ -847,8 +847,8 @@
|
|
|
847
847
|
filter: brightness(1.1);
|
|
848
848
|
}
|
|
849
849
|
|
|
850
|
-
.scalar-icon[data-v-
|
|
851
|
-
stroke-width: var(--
|
|
850
|
+
.scalar-icon[data-v-6150d8b1], .scalar-icon[data-v-6150d8b1] * {
|
|
851
|
+
stroke-width: var(--scalar-icon-stroke-width);
|
|
852
852
|
}
|
|
853
853
|
|
|
854
854
|
:where(pre:has( > code.hljs)) {
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"blocks",
|
|
18
18
|
"docs"
|
|
19
19
|
],
|
|
20
|
-
"version": "0.
|
|
20
|
+
"version": "0.8.0",
|
|
21
21
|
"engines": {
|
|
22
22
|
"node": ">=22"
|
|
23
23
|
},
|
|
@@ -62,15 +62,15 @@
|
|
|
62
62
|
"CHANGELOG.md"
|
|
63
63
|
],
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@scalar/components": "0.35.
|
|
66
|
-
"@scalar/helpers": "0.
|
|
65
|
+
"@scalar/components": "0.35.3",
|
|
66
|
+
"@scalar/helpers": "0.19.0",
|
|
67
67
|
"@scalar/icons": "0.7.11",
|
|
68
|
-
"@scalar/localization": "0.2.
|
|
69
|
-
"@scalar/snippetz": "0.10.
|
|
68
|
+
"@scalar/localization": "0.2.15",
|
|
69
|
+
"@scalar/snippetz": "0.10.21",
|
|
70
70
|
"@scalar/themes": "0.20.3",
|
|
71
|
-
"@scalar/types": "0.
|
|
72
|
-
"@scalar/use-hooks": "0.4.
|
|
73
|
-
"@scalar/workspace-store": "0.
|
|
71
|
+
"@scalar/types": "0.31.0",
|
|
72
|
+
"@scalar/use-hooks": "0.4.29",
|
|
73
|
+
"@scalar/workspace-store": "0.75.0",
|
|
74
74
|
"@types/har-format": "^1.2.16",
|
|
75
75
|
"@vueuse/core": "15.0.0",
|
|
76
76
|
"js-base64": "^3.9.6",
|