@shawnstack/quickforge 1.3.12 → 1.3.13
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/README.md +348 -348
- package/dist/assets/{anthropic-xAV_KBCN.js → anthropic-Ckozj5YL.js} +1 -1
- package/dist/assets/{azure-openai-responses-BczDocGX.js → azure-openai-responses-BwnfX0zX.js} +1 -1
- package/dist/assets/{google-DlBM2UuM.js → google-C68FfCgv.js} +1 -1
- package/dist/assets/{google-gemini-cli-BNOncgB1.js → google-gemini-cli-Bvmj_VP7.js} +1 -1
- package/dist/assets/{google-vertex-B9BjJowW.js → google-vertex-DfBcqFGy.js} +1 -1
- package/dist/assets/{icons-pEANlMqZ.js → icons-BHkxP7oT.js} +1 -1
- package/dist/assets/{index-Cq4dknqT.js → index-Bx9iFrzC.js} +527 -520
- package/dist/assets/index-kYsI9py3.css +3 -0
- package/dist/assets/{mistral-Dldc_EeW.js → mistral-soe30nal.js} +1 -1
- package/dist/assets/{openai-codex-responses-vFjB6yfe.js → openai-codex-responses-BX3Fx3LC.js} +1 -1
- package/dist/assets/{openai-completions-DPFPTHxA.js → openai-completions-CYI6ynqy.js} +1 -1
- package/dist/assets/{openai-responses-B9SrG5r6.js → openai-responses-X7pjajQb.js} +1 -1
- package/dist/assets/{openai-responses-shared-DCiYCDet.js → openai-responses-shared-Cx1dCwfa.js} +1 -1
- package/dist/assets/{react-vendor-ORf0unE-.js → react-vendor-CmyL2roG.js} +1 -1
- package/dist/index.html +10 -4
- package/dist/manifest.webmanifest +30 -0
- package/dist/pwa-icon-192.png +0 -0
- package/dist/pwa-icon-512.png +0 -0
- package/dist/pwa-maskable-512.png +0 -0
- package/dist/sw.js +79 -0
- package/node_modules/@aws-sdk/client-bedrock-runtime/package.json +2 -2
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/LICENSE +201 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/README.md +62 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-cjs/index.js +156 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/constants.js +2 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromEnvSigningName.js +16 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromSso.js +80 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/fromStatic.js +8 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getNewSsoOidcToken.js +11 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/getSsoOidcClient.js +10 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/index.js +4 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/nodeProvider.js +5 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenExpiry.js +7 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/validateTokenKey.js +7 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/dist-es/writeSSOTokenToFile.js +8 -0
- package/node_modules/@aws-sdk/credential-provider-sso/node_modules/@aws-sdk/token-providers/package.json +69 -0
- package/node_modules/@aws-sdk/token-providers/package.json +1 -1
- package/node_modules/es-object-atoms/CHANGELOG.md +21 -14
- package/node_modules/es-object-atoms/package.json +6 -7
- package/node_modules/es-object-atoms/tsconfig.json +1 -0
- package/node_modules/hono/dist/adapter/deno/websocket.js +5 -1
- package/node_modules/hono/dist/cjs/adapter/deno/websocket.js +5 -1
- package/node_modules/hono/dist/cjs/index.js +3 -0
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +31 -5
- package/node_modules/hono/dist/cjs/utils/compress.js +1 -1
- package/node_modules/hono/dist/cjs/utils/filepath.js +1 -1
- package/node_modules/hono/dist/cjs/utils/ipaddr.js +1 -1
- package/node_modules/hono/dist/cjs/utils/mime.js +15 -17
- package/node_modules/hono/dist/index.js +2 -0
- package/node_modules/hono/dist/middleware/compress/index.js +30 -5
- package/node_modules/hono/dist/utils/compress.js +1 -1
- package/node_modules/hono/dist/utils/filepath.js +1 -1
- package/node_modules/hono/dist/utils/ipaddr.js +1 -1
- package/node_modules/hono/dist/utils/mime.js +15 -17
- package/node_modules/hono/package.json +3 -3
- package/node_modules/ws/lib/receiver.js +54 -0
- package/node_modules/ws/lib/websocket-server.js +8 -0
- package/node_modules/ws/lib/websocket.js +14 -0
- package/node_modules/ws/package.json +1 -1
- package/package.json +1 -1
- package/server/routes/workspace.mjs +33 -1
- package/dist/assets/index-Dq1Kwzwg.css +0 -3
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { setTokenFeature } from "@aws-sdk/core/client";
|
|
2
|
+
import { getBearerTokenEnvKey } from "@aws-sdk/core/httpAuthSchemes";
|
|
3
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
4
|
+
export const fromEnvSigningName = ({ logger, signingName } = {}) => async () => {
|
|
5
|
+
logger?.debug?.("@aws-sdk/token-providers - fromEnvSigningName");
|
|
6
|
+
if (!signingName) {
|
|
7
|
+
throw new TokenProviderError("Please pass 'signingName' to compute environment variable key", { logger });
|
|
8
|
+
}
|
|
9
|
+
const bearerTokenKey = getBearerTokenEnvKey(signingName);
|
|
10
|
+
if (!(bearerTokenKey in process.env)) {
|
|
11
|
+
throw new TokenProviderError(`Token not present in '${bearerTokenKey}' environment variable`, { logger });
|
|
12
|
+
}
|
|
13
|
+
const token = { token: process.env[bearerTokenKey] };
|
|
14
|
+
setTokenFeature(token, "BEARER_SERVICE_ENV_VARS", "3");
|
|
15
|
+
return token;
|
|
16
|
+
};
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { getProfileName, getSSOTokenFromFile, loadSsoSessionData, parseKnownFiles, TokenProviderError, } from "@smithy/core/config";
|
|
2
|
+
import { EXPIRE_WINDOW_MS, REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
import { getNewSsoOidcToken } from "./getNewSsoOidcToken";
|
|
4
|
+
import { validateTokenExpiry } from "./validateTokenExpiry";
|
|
5
|
+
import { validateTokenKey } from "./validateTokenKey";
|
|
6
|
+
import { writeSSOTokenToFile } from "./writeSSOTokenToFile";
|
|
7
|
+
const lastRefreshAttemptTime = new Date(0);
|
|
8
|
+
export const fromSso = (init = {}) => async ({ callerClientConfig } = {}) => {
|
|
9
|
+
init.logger?.debug("@aws-sdk/token-providers - fromSso");
|
|
10
|
+
const profiles = await parseKnownFiles(init);
|
|
11
|
+
const profileName = getProfileName({
|
|
12
|
+
profile: init.profile ?? callerClientConfig?.profile,
|
|
13
|
+
});
|
|
14
|
+
const profile = profiles[profileName];
|
|
15
|
+
if (!profile) {
|
|
16
|
+
throw new TokenProviderError(`Profile '${profileName}' could not be found in shared credentials file.`, false);
|
|
17
|
+
}
|
|
18
|
+
else if (!profile["sso_session"]) {
|
|
19
|
+
throw new TokenProviderError(`Profile '${profileName}' is missing required property 'sso_session'.`);
|
|
20
|
+
}
|
|
21
|
+
const ssoSessionName = profile["sso_session"];
|
|
22
|
+
const ssoSessions = await loadSsoSessionData(init);
|
|
23
|
+
const ssoSession = ssoSessions[ssoSessionName];
|
|
24
|
+
if (!ssoSession) {
|
|
25
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' could not be found in shared credentials file.`, false);
|
|
26
|
+
}
|
|
27
|
+
for (const ssoSessionRequiredKey of ["sso_start_url", "sso_region"]) {
|
|
28
|
+
if (!ssoSession[ssoSessionRequiredKey]) {
|
|
29
|
+
throw new TokenProviderError(`Sso session '${ssoSessionName}' is missing required property '${ssoSessionRequiredKey}'.`, false);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
const ssoStartUrl = ssoSession["sso_start_url"];
|
|
33
|
+
const ssoRegion = ssoSession["sso_region"];
|
|
34
|
+
let ssoToken;
|
|
35
|
+
try {
|
|
36
|
+
ssoToken = await getSSOTokenFromFile(ssoSessionName);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
throw new TokenProviderError(`The SSO session token associated with profile=${profileName} was not found or is invalid. ${REFRESH_MESSAGE}`, false);
|
|
40
|
+
}
|
|
41
|
+
validateTokenKey("accessToken", ssoToken.accessToken);
|
|
42
|
+
validateTokenKey("expiresAt", ssoToken.expiresAt);
|
|
43
|
+
const { accessToken, expiresAt } = ssoToken;
|
|
44
|
+
const existingToken = { token: accessToken, expiration: new Date(expiresAt) };
|
|
45
|
+
if (existingToken.expiration.getTime() - Date.now() > EXPIRE_WINDOW_MS) {
|
|
46
|
+
return existingToken;
|
|
47
|
+
}
|
|
48
|
+
if (Date.now() - lastRefreshAttemptTime.getTime() < 30 * 1000) {
|
|
49
|
+
validateTokenExpiry(existingToken);
|
|
50
|
+
return existingToken;
|
|
51
|
+
}
|
|
52
|
+
validateTokenKey("clientId", ssoToken.clientId, true);
|
|
53
|
+
validateTokenKey("clientSecret", ssoToken.clientSecret, true);
|
|
54
|
+
validateTokenKey("refreshToken", ssoToken.refreshToken, true);
|
|
55
|
+
try {
|
|
56
|
+
lastRefreshAttemptTime.setTime(Date.now());
|
|
57
|
+
const newSsoOidcToken = await getNewSsoOidcToken(ssoToken, ssoRegion, init, callerClientConfig);
|
|
58
|
+
validateTokenKey("accessToken", newSsoOidcToken.accessToken);
|
|
59
|
+
validateTokenKey("expiresIn", newSsoOidcToken.expiresIn);
|
|
60
|
+
const newTokenExpiration = new Date(Date.now() + newSsoOidcToken.expiresIn * 1000);
|
|
61
|
+
try {
|
|
62
|
+
await writeSSOTokenToFile(ssoSessionName, {
|
|
63
|
+
...ssoToken,
|
|
64
|
+
accessToken: newSsoOidcToken.accessToken,
|
|
65
|
+
expiresAt: newTokenExpiration.toISOString(),
|
|
66
|
+
refreshToken: newSsoOidcToken.refreshToken,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
token: newSsoOidcToken.accessToken,
|
|
73
|
+
expiration: newTokenExpiration,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
validateTokenExpiry(existingToken);
|
|
78
|
+
return existingToken;
|
|
79
|
+
}
|
|
80
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
export const fromStatic = ({ token, logger }) => async () => {
|
|
3
|
+
logger?.debug("@aws-sdk/token-providers - fromStatic");
|
|
4
|
+
if (!token || !token.token) {
|
|
5
|
+
throw new TokenProviderError(`Please pass a valid token to fromStatic`, false);
|
|
6
|
+
}
|
|
7
|
+
return token;
|
|
8
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { getSsoOidcClient } from "./getSsoOidcClient";
|
|
2
|
+
export const getNewSsoOidcToken = async (ssoToken, ssoRegion, init = {}, callerClientConfig) => {
|
|
3
|
+
const { CreateTokenCommand } = await import("@aws-sdk/nested-clients/sso-oidc");
|
|
4
|
+
const ssoOidcClient = await getSsoOidcClient(ssoRegion, init, callerClientConfig);
|
|
5
|
+
return ssoOidcClient.send(new CreateTokenCommand({
|
|
6
|
+
clientId: ssoToken.clientId,
|
|
7
|
+
clientSecret: ssoToken.clientSecret,
|
|
8
|
+
refreshToken: ssoToken.refreshToken,
|
|
9
|
+
grantType: "refresh_token",
|
|
10
|
+
}));
|
|
11
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export const getSsoOidcClient = async (ssoRegion, init = {}, callerClientConfig) => {
|
|
2
|
+
const { SSOOIDCClient } = await import("@aws-sdk/nested-clients/sso-oidc");
|
|
3
|
+
const coalesce = (prop) => init.clientConfig?.[prop] ?? init.parentClientConfig?.[prop] ?? callerClientConfig?.[prop];
|
|
4
|
+
const ssoOidcClient = new SSOOIDCClient(Object.assign({}, init.clientConfig ?? {}, {
|
|
5
|
+
region: ssoRegion ?? init.clientConfig?.region,
|
|
6
|
+
logger: coalesce("logger"),
|
|
7
|
+
userAgentAppId: coalesce("userAgentAppId"),
|
|
8
|
+
}));
|
|
9
|
+
return ssoOidcClient;
|
|
10
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { chain, memoize, TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { fromSso } from "./fromSso";
|
|
3
|
+
export const nodeProvider = (init = {}) => memoize(chain(fromSso(init), async () => {
|
|
4
|
+
throw new TokenProviderError("Could not load token from any providers", false);
|
|
5
|
+
}), (token) => token.expiration !== undefined && token.expiration.getTime() - Date.now() < 300000, (token) => token.expiration !== undefined);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
export const validateTokenExpiry = (token) => {
|
|
4
|
+
if (token.expiration && token.expiration.getTime() < Date.now()) {
|
|
5
|
+
throw new TokenProviderError(`Token is expired. ${REFRESH_MESSAGE}`, false);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TokenProviderError } from "@smithy/core/config";
|
|
2
|
+
import { REFRESH_MESSAGE } from "./constants";
|
|
3
|
+
export const validateTokenKey = (key, value, forRefresh = false) => {
|
|
4
|
+
if (typeof value === "undefined") {
|
|
5
|
+
throw new TokenProviderError(`Value not present for '${key}' in SSO Token${forRefresh ? ". Cannot refresh" : ""}. ${REFRESH_MESSAGE}`, false);
|
|
6
|
+
}
|
|
7
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getSSOTokenFilepath } from "@smithy/core/config";
|
|
2
|
+
import { promises as fsPromises } from "node:fs";
|
|
3
|
+
const { writeFile } = fsPromises;
|
|
4
|
+
export const writeSSOTokenToFile = (id, ssoToken) => {
|
|
5
|
+
const tokenFilepath = getSSOTokenFilepath(id);
|
|
6
|
+
const tokenString = JSON.stringify(ssoToken, null, 2);
|
|
7
|
+
return writeFile(tokenFilepath, tokenString);
|
|
8
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@aws-sdk/token-providers",
|
|
3
|
+
"version": "3.1052.0",
|
|
4
|
+
"description": "A collection of token providers",
|
|
5
|
+
"main": "./dist-cjs/index.js",
|
|
6
|
+
"module": "./dist-es/index.js",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"build": "concurrently 'yarn:build:types' 'yarn:build:es' && yarn build:cjs",
|
|
9
|
+
"build:cjs": "node ../../scripts/compilation/inline token-providers",
|
|
10
|
+
"build:es": "tsc -p tsconfig.es.json",
|
|
11
|
+
"build:include:deps": "yarn g:turbo run build -F=\"$npm_package_name\"",
|
|
12
|
+
"build:types": "tsc -p tsconfig.types.json",
|
|
13
|
+
"build:types:downlevel": "downlevel-dts dist-types dist-types/ts3.4",
|
|
14
|
+
"clean": "premove dist-cjs dist-es dist-types tsconfig.cjs.tsbuildinfo tsconfig.es.tsbuildinfo tsconfig.types.tsbuildinfo",
|
|
15
|
+
"extract:docs": "api-extractor run --local",
|
|
16
|
+
"test": "yarn g:vitest run",
|
|
17
|
+
"test:watch": "yarn g:vitest watch",
|
|
18
|
+
"test:integration": "yarn g:vitest run -c vitest.config.integ.mts",
|
|
19
|
+
"test:integration:watch": "yarn g:vitest watch -c vitest.config.integ.mts"
|
|
20
|
+
},
|
|
21
|
+
"keywords": [
|
|
22
|
+
"aws",
|
|
23
|
+
"token"
|
|
24
|
+
],
|
|
25
|
+
"sideEffects": false,
|
|
26
|
+
"author": {
|
|
27
|
+
"name": "AWS SDK for JavaScript Team",
|
|
28
|
+
"url": "https://aws.amazon.com/javascript/"
|
|
29
|
+
},
|
|
30
|
+
"license": "Apache-2.0",
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@aws-sdk/core": "^3.974.13",
|
|
33
|
+
"@aws-sdk/nested-clients": "^3.997.11",
|
|
34
|
+
"@aws-sdk/types": "^3.973.9",
|
|
35
|
+
"@smithy/core": "^3.24.3",
|
|
36
|
+
"@smithy/types": "^4.14.2",
|
|
37
|
+
"tslib": "^2.6.2"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@tsconfig/recommended": "1.0.1",
|
|
41
|
+
"@types/node": "^20.14.8",
|
|
42
|
+
"concurrently": "7.0.0",
|
|
43
|
+
"downlevel-dts": "0.10.1",
|
|
44
|
+
"premove": "4.0.0",
|
|
45
|
+
"typescript": "~5.8.3"
|
|
46
|
+
},
|
|
47
|
+
"types": "./dist-types/index.d.ts",
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=20.0.0"
|
|
50
|
+
},
|
|
51
|
+
"typesVersions": {
|
|
52
|
+
"<4.5": {
|
|
53
|
+
"dist-types/*": [
|
|
54
|
+
"dist-types/ts3.4/*"
|
|
55
|
+
]
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"files": [
|
|
59
|
+
"dist-*/**"
|
|
60
|
+
],
|
|
61
|
+
"browser": {},
|
|
62
|
+
"react-native": {},
|
|
63
|
+
"homepage": "https://github.com/aws/aws-sdk-js-v3/tree/main/packages/token-providers",
|
|
64
|
+
"repository": {
|
|
65
|
+
"type": "git",
|
|
66
|
+
"url": "https://github.com/aws/aws-sdk-js-v3.git",
|
|
67
|
+
"directory": "packages/token-providers"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
@@ -5,33 +5,40 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
-
## [v1.1.
|
|
8
|
+
## [v1.1.2](https://github.com/es-shims/es-object-atoms/compare/v1.1.1...v1.1.2) - 2026-05-22
|
|
9
9
|
|
|
10
10
|
### Commits
|
|
11
11
|
|
|
12
|
-
- [
|
|
12
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `auto-changelog`, `eslint`, `npmignore` [`41e3d94`](https://github.com/es-shims/es-object-atoms/commit/41e3d94f6b49237fa490ec598e068f170c8b161e)
|
|
13
|
+
- [types] improve `isObject` type [`758edc2`](https://github.com/es-shims/es-object-atoms/commit/758edc2280fa6993a294a55957a43cee5951bf51)
|
|
13
14
|
|
|
14
|
-
## [v1.1.
|
|
15
|
+
## [v1.1.1](https://github.com/es-shims/es-object-atoms/compare/v1.1.0...v1.1.1) - 2025-01-14
|
|
15
16
|
|
|
16
17
|
### Commits
|
|
17
18
|
|
|
18
|
-
- [
|
|
19
|
+
- [types] `ToObject`: improve types [`cfe8c8a`](https://github.com/es-shims/es-object-atoms/commit/cfe8c8a105c44820cb22e26f62d12ef0ad9715c8)
|
|
19
20
|
|
|
20
|
-
## [v1.0
|
|
21
|
+
## [v1.1.0](https://github.com/es-shims/es-object-atoms/compare/v1.0.1...v1.1.0) - 2025-01-14
|
|
21
22
|
|
|
22
23
|
### Commits
|
|
23
24
|
|
|
24
|
-
- [
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
25
|
+
- [New] add `isObject` [`51e4042`](https://github.com/es-shims/es-object-atoms/commit/51e4042df722eb3165f40dc5f4bf33d0197ecb07)
|
|
26
|
+
|
|
27
|
+
## [v1.0.1](https://github.com/es-shims/es-object-atoms/compare/v1.0.0...v1.0.1) - 2025-01-13
|
|
28
|
+
|
|
29
|
+
### Commits
|
|
30
|
+
|
|
31
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `@ljharb/tsconfig`, `@types/tape`, `auto-changelog`, `tape` [`38ab9eb`](https://github.com/es-shims/es-object-atoms/commit/38ab9eb00b62c2f4668644f5e513d9b414ebd595)
|
|
32
|
+
- [types] improve types [`7d1beb8`](https://github.com/es-shims/es-object-atoms/commit/7d1beb887958b78b6a728a210a1c8370ab7e2aa1)
|
|
33
|
+
- [Tests] replace `aud` with `npm audit` [`25863ba`](https://github.com/es-shims/es-object-atoms/commit/25863baf99178f1d1ad33d1120498db28631907e)
|
|
34
|
+
- [Dev Deps] add missing peer dep [`c012309`](https://github.com/es-shims/es-object-atoms/commit/c0123091287e6132d6f4240496340c427433df28)
|
|
28
35
|
|
|
29
36
|
## v1.0.0 - 2024-03-16
|
|
30
37
|
|
|
31
38
|
### Commits
|
|
32
39
|
|
|
33
|
-
- Initial implementation, tests, readme, types [`f1499db`](https://github.com/
|
|
34
|
-
- Initial commit [`99eedc7`](https://github.com/
|
|
35
|
-
- [meta] rename repo [`fc851fa`](https://github.com/
|
|
36
|
-
- npm init [`b909377`](https://github.com/
|
|
37
|
-
- Only apps should have lockfiles [`7249edd`](https://github.com/
|
|
40
|
+
- Initial implementation, tests, readme, types [`f1499db`](https://github.com/es-shims/es-object-atoms/commit/f1499db7d3e1741e64979c61d645ab3137705e82)
|
|
41
|
+
- Initial commit [`99eedc7`](https://github.com/es-shims/es-object-atoms/commit/99eedc7b5fde38a50a28d3c8b724706e3e4c5f6a)
|
|
42
|
+
- [meta] rename repo [`fc851fa`](https://github.com/es-shims/es-object-atoms/commit/fc851fa70616d2d182aaf0bd02c2ed7084dea8fa)
|
|
43
|
+
- npm init [`b909377`](https://github.com/es-shims/es-object-atoms/commit/b909377c50049bd0ec575562d20b0f9ebae8947f)
|
|
44
|
+
- Only apps should have lockfiles [`7249edd`](https://github.com/es-shims/es-object-atoms/commit/7249edd2178c1b9ddfc66ffcc6d07fdf0d28efc1)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "es-object-atoms",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "ES Object-related atoms: Object, ToObject, RequireObjectCoercible",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -46,16 +46,15 @@
|
|
|
46
46
|
"es-errors": "^1.3.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@ljharb/eslint-config": "^
|
|
50
|
-
"@ljharb/tsconfig": "^0.2
|
|
49
|
+
"@ljharb/eslint-config": "^22.2.3",
|
|
50
|
+
"@ljharb/tsconfig": "^0.3.2",
|
|
51
51
|
"@types/tape": "^5.8.1",
|
|
52
|
-
"auto-changelog": "^2.5.
|
|
52
|
+
"auto-changelog": "^2.5.1",
|
|
53
53
|
"eclint": "^2.8.1",
|
|
54
|
-
"
|
|
55
|
-
"eslint": "^8.8.0",
|
|
54
|
+
"eslint": "^8.57.1",
|
|
56
55
|
"evalmd": "^0.0.19",
|
|
57
56
|
"in-publish": "^2.0.1",
|
|
58
|
-
"npmignore": "^0.3.
|
|
57
|
+
"npmignore": "^0.3.5",
|
|
59
58
|
"nyc": "^10.3.2",
|
|
60
59
|
"safe-publish-latest": "^2.0.0",
|
|
61
60
|
"tape": "^5.9.0",
|
|
@@ -4,7 +4,11 @@ var upgradeWebSocket = defineWebSocketHelper(async (c, events, options) => {
|
|
|
4
4
|
if (c.req.header("upgrade") !== "websocket") {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
|
-
const
|
|
7
|
+
const subprotocol = c.req.header("sec-websocket-protocol")?.split(",")[0]?.trim();
|
|
8
|
+
const { response, socket } = Deno.upgradeWebSocket(c.req.raw, {
|
|
9
|
+
...subprotocol ? { protocol: subprotocol } : {},
|
|
10
|
+
...options
|
|
11
|
+
});
|
|
8
12
|
const wsContext = new WSContext({
|
|
9
13
|
close: (code, reason) => socket.close(code, reason),
|
|
10
14
|
get protocol() {
|
|
@@ -25,7 +25,11 @@ const upgradeWebSocket = (0, import_websocket.defineWebSocketHelper)(async (c, e
|
|
|
25
25
|
if (c.req.header("upgrade") !== "websocket") {
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
|
-
const
|
|
28
|
+
const subprotocol = c.req.header("sec-websocket-protocol")?.split(",")[0]?.trim();
|
|
29
|
+
const { response, socket } = Deno.upgradeWebSocket(c.req.raw, {
|
|
30
|
+
...subprotocol ? { protocol: subprotocol } : {},
|
|
31
|
+
...options
|
|
32
|
+
});
|
|
29
33
|
const wsContext = new import_websocket.WSContext({
|
|
30
34
|
close: (code, reason) => socket.close(code, reason),
|
|
31
35
|
get protocol() {
|
|
@@ -17,11 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var index_exports = {};
|
|
19
19
|
__export(index_exports, {
|
|
20
|
+
Context: () => import_context.Context,
|
|
20
21
|
Hono: () => import_hono.Hono
|
|
21
22
|
});
|
|
22
23
|
module.exports = __toCommonJS(index_exports);
|
|
23
24
|
var import_hono = require("./hono");
|
|
25
|
+
var import_context = require("./context");
|
|
24
26
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
27
|
0 && (module.exports = {
|
|
28
|
+
Context,
|
|
26
29
|
Hono
|
|
27
30
|
});
|
|
@@ -17,14 +17,43 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var compress_exports = {};
|
|
19
19
|
__export(compress_exports, {
|
|
20
|
+
COMPRESSIBLE_CONTENT_TYPE_REGEX: () => import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX,
|
|
20
21
|
compress: () => compress
|
|
21
22
|
});
|
|
22
23
|
module.exports = __toCommonJS(compress_exports);
|
|
24
|
+
var import_accept = require("../../utils/accept");
|
|
23
25
|
var import_compress = require("../../utils/compress");
|
|
24
26
|
const ENCODING_TYPES = ["gzip", "deflate"];
|
|
25
27
|
const cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
|
|
28
|
+
const selectEncoding = (header, candidates) => {
|
|
29
|
+
if (header === void 0) {
|
|
30
|
+
return void 0;
|
|
31
|
+
}
|
|
32
|
+
const accepts = (0, import_accept.parseAccept)(header);
|
|
33
|
+
const wildcardQ = accepts.find((a) => a.type === "*")?.q;
|
|
34
|
+
let best;
|
|
35
|
+
for (const enc of candidates) {
|
|
36
|
+
const explicit = accepts.find((a) => a.type.toLowerCase() === enc);
|
|
37
|
+
const q = explicit ? explicit.q : wildcardQ ?? 0;
|
|
38
|
+
if (q === 1) {
|
|
39
|
+
return enc;
|
|
40
|
+
} else if (q > 0 && (!best || q > best.q)) {
|
|
41
|
+
best = { encoding: enc, q };
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return best?.encoding;
|
|
45
|
+
};
|
|
26
46
|
const compress = (options) => {
|
|
27
47
|
const threshold = options?.threshold ?? 1024;
|
|
48
|
+
const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
|
|
49
|
+
const contentTypeFilter = options?.contentTypeFilter ?? import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX;
|
|
50
|
+
const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
|
|
51
|
+
const type = res.headers.get("Content-Type");
|
|
52
|
+
return type && contentTypeFilter(type);
|
|
53
|
+
} : (res) => {
|
|
54
|
+
const type = res.headers.get("Content-Type");
|
|
55
|
+
return type && contentTypeFilter.test(type);
|
|
56
|
+
};
|
|
28
57
|
return async function compress2(ctx, next) {
|
|
29
58
|
await next();
|
|
30
59
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
@@ -37,7 +66,7 @@ const compress = (options) => {
|
|
|
37
66
|
return;
|
|
38
67
|
}
|
|
39
68
|
const accepted = ctx.req.header("Accept-Encoding");
|
|
40
|
-
const encoding =
|
|
69
|
+
const encoding = selectEncoding(accepted, candidates);
|
|
41
70
|
if (!encoding || !ctx.res.body) {
|
|
42
71
|
return;
|
|
43
72
|
}
|
|
@@ -51,15 +80,12 @@ const compress = (options) => {
|
|
|
51
80
|
}
|
|
52
81
|
};
|
|
53
82
|
};
|
|
54
|
-
const shouldCompress = (res) => {
|
|
55
|
-
const type = res.headers.get("Content-Type");
|
|
56
|
-
return type && import_compress.COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
|
|
57
|
-
};
|
|
58
83
|
const shouldTransform = (res) => {
|
|
59
84
|
const cacheControl = res.headers.get("Cache-Control");
|
|
60
85
|
return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl);
|
|
61
86
|
};
|
|
62
87
|
// Annotate the CommonJS export names for ESM import in node:
|
|
63
88
|
0 && (module.exports = {
|
|
89
|
+
COMPRESSIBLE_CONTENT_TYPE_REGEX,
|
|
64
90
|
compress
|
|
65
91
|
});
|
|
@@ -20,7 +20,7 @@ __export(compress_exports, {
|
|
|
20
20
|
COMPRESSIBLE_CONTENT_TYPE_REGEX: () => COMPRESSIBLE_CONTENT_TYPE_REGEX
|
|
21
21
|
});
|
|
22
22
|
module.exports = __toCommonJS(compress_exports);
|
|
23
|
-
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
23
|
+
const COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/(?!event-stream(?:[;\s]|$))[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|msgpack|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|vnd\.msgpack|wasm|x-httpd-php|x-javascript|x-msgpack|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml|msgpack))(?:[;\s]|$)/i;
|
|
24
24
|
// Annotate the CommonJS export names for ESM import in node:
|
|
25
25
|
0 && (module.exports = {
|
|
26
26
|
COMPRESSIBLE_CONTENT_TYPE_REGEX
|
|
@@ -42,7 +42,7 @@ const getFilePathWithoutDefaultDocument = (options) => {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
filename = filename.replace(/^\.?[\/\\]/, "");
|
|
45
|
-
filename = filename.replace(
|
|
45
|
+
filename = filename.replace(/\\/g, "/");
|
|
46
46
|
root = root.replace(/\/$/, "");
|
|
47
47
|
let path = root ? root + "/" + filename : filename;
|
|
48
48
|
path = path.replace(/^\.?\//, "");
|
|
@@ -294,7 +294,7 @@ const convertIPv6BinaryToString = (ipV6) => {
|
|
|
294
294
|
maxZeroEnd = 8;
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
|
-
if (maxZeroStart !== -1) {
|
|
297
|
+
if (maxZeroStart !== -1 && maxZeroEnd - maxZeroStart > 1) {
|
|
298
298
|
sections.splice(maxZeroStart, maxZeroEnd - maxZeroStart, ":");
|
|
299
299
|
}
|
|
300
300
|
return sections.join(":").replace(/:{2,}/g, "::");
|
|
@@ -28,15 +28,13 @@ const getMimeType = (filename, mimes = baseMimes) => {
|
|
|
28
28
|
if (!match) {
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
if (mimeType && mimeType.startsWith("text")) {
|
|
33
|
-
mimeType += "; charset=utf-8";
|
|
34
|
-
}
|
|
35
|
-
return mimeType;
|
|
31
|
+
return mimes[match[1].toLowerCase()];
|
|
36
32
|
};
|
|
37
33
|
const getExtension = (mimeType) => {
|
|
34
|
+
const baseType = mimeType.split(";", 1)[0].trim();
|
|
38
35
|
for (const ext in baseMimes) {
|
|
39
|
-
|
|
36
|
+
const stored = baseMimes[ext];
|
|
37
|
+
if (stored === mimeType || stored.split(";", 1)[0].trim() === baseType) {
|
|
40
38
|
return ext;
|
|
41
39
|
}
|
|
42
40
|
}
|
|
@@ -48,25 +46,25 @@ const _baseMimes = {
|
|
|
48
46
|
av1: "video/av1",
|
|
49
47
|
bin: "application/octet-stream",
|
|
50
48
|
bmp: "image/bmp",
|
|
51
|
-
css: "text/css",
|
|
52
|
-
csv: "text/csv",
|
|
49
|
+
css: "text/css; charset=utf-8",
|
|
50
|
+
csv: "text/csv; charset=utf-8",
|
|
53
51
|
eot: "application/vnd.ms-fontobject",
|
|
54
52
|
epub: "application/epub+zip",
|
|
55
53
|
gif: "image/gif",
|
|
56
54
|
gz: "application/gzip",
|
|
57
|
-
htm: "text/html",
|
|
58
|
-
html: "text/html",
|
|
55
|
+
htm: "text/html; charset=utf-8",
|
|
56
|
+
html: "text/html; charset=utf-8",
|
|
59
57
|
ico: "image/x-icon",
|
|
60
|
-
ics: "text/calendar",
|
|
58
|
+
ics: "text/calendar; charset=utf-8",
|
|
61
59
|
jpeg: "image/jpeg",
|
|
62
60
|
jpg: "image/jpeg",
|
|
63
|
-
js: "text/javascript",
|
|
61
|
+
js: "text/javascript; charset=utf-8",
|
|
64
62
|
json: "application/json",
|
|
65
63
|
jsonld: "application/ld+json",
|
|
66
64
|
map: "application/json",
|
|
67
65
|
mid: "audio/x-midi",
|
|
68
66
|
midi: "audio/x-midi",
|
|
69
|
-
mjs: "text/javascript",
|
|
67
|
+
mjs: "text/javascript; charset=utf-8",
|
|
70
68
|
mp3: "audio/mpeg",
|
|
71
69
|
mp4: "video/mp4",
|
|
72
70
|
mpeg: "video/mpeg",
|
|
@@ -78,12 +76,12 @@ const _baseMimes = {
|
|
|
78
76
|
pdf: "application/pdf",
|
|
79
77
|
png: "image/png",
|
|
80
78
|
rtf: "application/rtf",
|
|
81
|
-
svg: "image/svg+xml",
|
|
79
|
+
svg: "image/svg+xml; charset=utf-8",
|
|
82
80
|
tif: "image/tiff",
|
|
83
81
|
tiff: "image/tiff",
|
|
84
82
|
ts: "video/mp2t",
|
|
85
83
|
ttf: "font/ttf",
|
|
86
|
-
txt: "text/plain",
|
|
84
|
+
txt: "text/plain; charset=utf-8",
|
|
87
85
|
wasm: "application/wasm",
|
|
88
86
|
webm: "video/webm",
|
|
89
87
|
weba: "audio/webm",
|
|
@@ -91,8 +89,8 @@ const _baseMimes = {
|
|
|
91
89
|
webp: "image/webp",
|
|
92
90
|
woff: "font/woff",
|
|
93
91
|
woff2: "font/woff2",
|
|
94
|
-
xhtml: "application/xhtml+xml",
|
|
95
|
-
xml: "application/xml",
|
|
92
|
+
xhtml: "application/xhtml+xml; charset=utf-8",
|
|
93
|
+
xml: "application/xml; charset=utf-8",
|
|
96
94
|
zip: "application/zip",
|
|
97
95
|
"3gp": "video/3gpp",
|
|
98
96
|
"3g2": "video/3gpp2",
|
|
@@ -1,9 +1,37 @@
|
|
|
1
1
|
// src/middleware/compress/index.ts
|
|
2
|
+
import { parseAccept } from "../../utils/accept.js";
|
|
2
3
|
import { COMPRESSIBLE_CONTENT_TYPE_REGEX } from "../../utils/compress.js";
|
|
3
4
|
var ENCODING_TYPES = ["gzip", "deflate"];
|
|
4
5
|
var cacheControlNoTransformRegExp = /(?:^|,)\s*?no-transform\s*?(?:,|$)/i;
|
|
6
|
+
var selectEncoding = (header, candidates) => {
|
|
7
|
+
if (header === void 0) {
|
|
8
|
+
return void 0;
|
|
9
|
+
}
|
|
10
|
+
const accepts = parseAccept(header);
|
|
11
|
+
const wildcardQ = accepts.find((a) => a.type === "*")?.q;
|
|
12
|
+
let best;
|
|
13
|
+
for (const enc of candidates) {
|
|
14
|
+
const explicit = accepts.find((a) => a.type.toLowerCase() === enc);
|
|
15
|
+
const q = explicit ? explicit.q : wildcardQ ?? 0;
|
|
16
|
+
if (q === 1) {
|
|
17
|
+
return enc;
|
|
18
|
+
} else if (q > 0 && (!best || q > best.q)) {
|
|
19
|
+
best = { encoding: enc, q };
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return best?.encoding;
|
|
23
|
+
};
|
|
5
24
|
var compress = (options) => {
|
|
6
25
|
const threshold = options?.threshold ?? 1024;
|
|
26
|
+
const candidates = options?.encoding ? [options.encoding] : ENCODING_TYPES;
|
|
27
|
+
const contentTypeFilter = options?.contentTypeFilter ?? COMPRESSIBLE_CONTENT_TYPE_REGEX;
|
|
28
|
+
const shouldCompress = typeof contentTypeFilter === "function" ? (res) => {
|
|
29
|
+
const type = res.headers.get("Content-Type");
|
|
30
|
+
return type && contentTypeFilter(type);
|
|
31
|
+
} : (res) => {
|
|
32
|
+
const type = res.headers.get("Content-Type");
|
|
33
|
+
return type && contentTypeFilter.test(type);
|
|
34
|
+
};
|
|
7
35
|
return async function compress2(ctx, next) {
|
|
8
36
|
await next();
|
|
9
37
|
const contentLength = ctx.res.headers.get("Content-Length");
|
|
@@ -16,7 +44,7 @@ var compress = (options) => {
|
|
|
16
44
|
return;
|
|
17
45
|
}
|
|
18
46
|
const accepted = ctx.req.header("Accept-Encoding");
|
|
19
|
-
const encoding =
|
|
47
|
+
const encoding = selectEncoding(accepted, candidates);
|
|
20
48
|
if (!encoding || !ctx.res.body) {
|
|
21
49
|
return;
|
|
22
50
|
}
|
|
@@ -30,14 +58,11 @@ var compress = (options) => {
|
|
|
30
58
|
}
|
|
31
59
|
};
|
|
32
60
|
};
|
|
33
|
-
var shouldCompress = (res) => {
|
|
34
|
-
const type = res.headers.get("Content-Type");
|
|
35
|
-
return type && COMPRESSIBLE_CONTENT_TYPE_REGEX.test(type);
|
|
36
|
-
};
|
|
37
61
|
var shouldTransform = (res) => {
|
|
38
62
|
const cacheControl = res.headers.get("Cache-Control");
|
|
39
63
|
return !cacheControl || !cacheControlNoTransformRegExp.test(cacheControl);
|
|
40
64
|
};
|
|
41
65
|
export {
|
|
66
|
+
COMPRESSIBLE_CONTENT_TYPE_REGEX,
|
|
42
67
|
compress
|
|
43
68
|
};
|