diff options
-rw-r--r-- | packages/astro/src/container/index.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/app/index.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/build/generate.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/build/index.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/build/plugins/plugin-manifest.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/build/plugins/plugin-ssr.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/core/encryption.ts | 16 | ||||
-rw-r--r-- | packages/astro/src/core/render-context.ts | 1 | ||||
-rw-r--r-- | packages/astro/src/core/server-islands/endpoint.ts | 2 | ||||
-rw-r--r-- | packages/astro/src/runtime/server/render/server-islands.ts | 3 | ||||
-rw-r--r-- | packages/astro/src/vite-plugin-astro-server/plugin.ts | 2 | ||||
-rw-r--r-- | packages/integrations/node/src/serve-static.ts | 2 | ||||
-rw-r--r-- | packages/integrations/node/test/errors.test.js | 2 |
13 files changed, 19 insertions, 21 deletions
diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index d9ad61f25..f0c600a40 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -17,6 +17,7 @@ import type { import { getDefaultClientDirectives } from '../core/client-directive/index.js'; import { ASTRO_CONFIG_DEFAULTS } from '../core/config/schema.js'; import { validateConfig } from '../core/config/validate.js'; +import { createKey } from '../core/encryption.js'; import { Logger } from '../core/logger/core.js'; import { nodeLogDestination } from '../core/logger/node.js'; import { removeLeadingForwardSlash } from '../core/path.js'; @@ -25,7 +26,6 @@ import { getParts, validateSegment } from '../core/routing/manifest/create.js'; import { getPattern } from '../core/routing/manifest/pattern.js'; import type { AstroComponentFactory } from '../runtime/server/index.js'; import { ContainerPipeline } from './pipeline.js'; -import { createKey } from '../core/encryption.js'; /** * Options to be passed when rendering a route diff --git a/packages/astro/src/core/app/index.ts b/packages/astro/src/core/app/index.ts index 7ccf219c8..8041dda3c 100644 --- a/packages/astro/src/core/app/index.ts +++ b/packages/astro/src/core/app/index.ts @@ -416,7 +416,7 @@ export class App { `${this.#baseWithoutTrailingSlash}/${status}${maybeDotHtml}`, url, ); - if(statusURL.toString() !== request.url) { + if (statusURL.toString() !== request.url) { const response = await fetch(statusURL.toString()); // response for /404.html and 500.html is 200, which is not meaningful diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 329530154..fae7896b9 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -522,7 +522,7 @@ function createBuildManifest( internals: BuildInternals, renderers: SSRLoadedRenderer[], middleware: MiddlewareHandler, - key: Promise<CryptoKey> + key: Promise<CryptoKey>, ): SSRManifest { let i18nManifest: SSRManifestI18n | undefined = undefined; if (settings.config.i18n) { diff --git a/packages/astro/src/core/build/index.ts b/packages/astro/src/core/build/index.ts index ecc97161f..1382f85bc 100644 --- a/packages/astro/src/core/build/index.ts +++ b/packages/astro/src/core/build/index.ts @@ -23,6 +23,7 @@ import { resolveConfig } from '../config/config.js'; import { createNodeLogger } from '../config/logging.js'; import { createSettings } from '../config/settings.js'; import { createVite } from '../create-vite.js'; +import { createKey } from '../encryption.js'; import type { Logger } from '../logger/core.js'; import { levels, timerMessage } from '../logger/core.js'; import { apply as applyPolyfill } from '../polyfill.js'; @@ -33,7 +34,6 @@ import { collectPagesData } from './page-data.js'; import { staticBuild, viteBuild } from './static-build.js'; import type { StaticBuildOptions } from './types.js'; import { getTimeStat } from './util.js'; -import { createKey } from '../encryption.js'; export interface BuildOptions { /** diff --git a/packages/astro/src/core/build/plugins/plugin-manifest.ts b/packages/astro/src/core/build/plugins/plugin-manifest.ts index 098c5528d..6b38758c3 100644 --- a/packages/astro/src/core/build/plugins/plugin-manifest.ts +++ b/packages/astro/src/core/build/plugins/plugin-manifest.ts @@ -12,6 +12,7 @@ import type { SerializedRouteInfo, SerializedSSRManifest, } from '../../app/types.js'; +import { encodeKey } from '../../encryption.js'; import { fileExtension, joinPaths, prependForwardSlash } from '../../path.js'; import { serializeRouteData } from '../../routing/index.js'; import { addRollupInput } from '../add-rollup-input.js'; @@ -20,7 +21,6 @@ import { type BuildInternals, cssOrder, mergeInlineCss } from '../internal.js'; import type { AstroBuildPlugin } from '../plugin.js'; import type { StaticBuildOptions } from '../types.js'; import { makePageDataKey } from './util.js'; -import { encodeKey } from '../../encryption.js'; const manifestReplace = '@@ASTRO_MANIFEST_REPLACE@@'; const replaceExp = new RegExp(`['"]${manifestReplace}['"]`, 'g'); diff --git a/packages/astro/src/core/build/plugins/plugin-ssr.ts b/packages/astro/src/core/build/plugins/plugin-ssr.ts index 201c48a5e..70997e40e 100644 --- a/packages/astro/src/core/build/plugins/plugin-ssr.ts +++ b/packages/astro/src/core/build/plugins/plugin-ssr.ts @@ -38,7 +38,7 @@ function vitePluginSSR( } const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint; - if(adapterServerEntrypoint) { + if (adapterServerEntrypoint) { inputs.add(adapterServerEntrypoint); } diff --git a/packages/astro/src/core/encryption.ts b/packages/astro/src/core/encryption.ts index f84966297..ccfc9bdd2 100644 --- a/packages/astro/src/core/encryption.ts +++ b/packages/astro/src/core/encryption.ts @@ -1,4 +1,4 @@ -import { encodeBase64, decodeBase64, decodeHex, encodeHexUpperCase } from '@oslojs/encoding'; +import { decodeBase64, decodeHex, encodeBase64, encodeHexUpperCase } from '@oslojs/encoding'; // Chose this algorithm for no particular reason, can change. // This algo does check against text manipulation though. See @@ -15,7 +15,7 @@ export async function createKey() { length: 256, }, true, - ['encrypt', 'decrypt'] + ['encrypt', 'decrypt'], ); return key; } @@ -24,8 +24,8 @@ export async function createKey() { * Takes a key that has been serialized to an array of bytes and returns a CryptoKey */ export async function importKey(bytes: Uint8Array): Promise<CryptoKey> { - const key = await crypto.subtle.importKey('raw', bytes, ALGORITHM, true, ['encrypt', 'decrypt']); - return key; + const key = await crypto.subtle.importKey('raw', bytes, ALGORITHM, true, ['encrypt', 'decrypt']); + return key; } /** @@ -41,7 +41,7 @@ export async function encodeKey(key: CryptoKey) { * Decodes a base64 string into bytes and then imports the key. */ export async function decodeKey(encoded: string): Promise<CryptoKey> { - const bytes = decodeBase64(encoded); + const bytes = decodeBase64(encoded); return crypto.subtle.importKey('raw', bytes, ALGORITHM, true, ['encrypt', 'decrypt']); } @@ -63,7 +63,7 @@ export async function encryptString(key: CryptoKey, raw: string) { iv, }, key, - data + data, ); // iv is 12, hex brings it to 24 return encodeHexUpperCase(iv) + encodeBase64(new Uint8Array(buffer)); @@ -73,7 +73,7 @@ export async function encryptString(key: CryptoKey, raw: string) { * Takes a base64 encoded string, decodes it and returns the decrypted text. */ export async function decryptString(key: CryptoKey, encoded: string) { - const iv = decodeHex(encoded.slice(0, IV_LENGTH)); + const iv = decodeHex(encoded.slice(0, IV_LENGTH)); const dataArray = decodeBase64(encoded.slice(IV_LENGTH)); const decryptedBuffer = await crypto.subtle.decrypt( { @@ -81,7 +81,7 @@ export async function decryptString(key: CryptoKey, encoded: string) { iv, }, key, - dataArray + dataArray, ); const decryptedString = decoder.decode(decryptedBuffer); return decryptedString; diff --git a/packages/astro/src/core/render-context.ts b/packages/astro/src/core/render-context.ts index 653d853c9..a19d11080 100644 --- a/packages/astro/src/core/render-context.ts +++ b/packages/astro/src/core/render-context.ts @@ -318,7 +318,6 @@ export class RenderContext { ? deserializeActionResult(this.locals._actionPayload.actionResult) : undefined; - // Create the result object that will be passed into the renderPage function. // This object starts here as an empty shell (not yet the result) but then // calling the render() function will populate the object with scripts, styles, etc. diff --git a/packages/astro/src/core/server-islands/endpoint.ts b/packages/astro/src/core/server-islands/endpoint.ts index fc87202ff..368a1b9b1 100644 --- a/packages/astro/src/core/server-islands/endpoint.ts +++ b/packages/astro/src/core/server-islands/endpoint.ts @@ -79,7 +79,7 @@ export function createEndpoint(manifest: SSRManifest) { const encryptedProps = data.encryptedProps; const propString = await decryptString(key, encryptedProps); const props = JSON.parse(propString); - + const componentModule = await imp(); const Component = (componentModule as any)[data.componentExport]; diff --git a/packages/astro/src/runtime/server/render/server-islands.ts b/packages/astro/src/runtime/server/render/server-islands.ts index 46f3fd6b2..58cce4e14 100644 --- a/packages/astro/src/runtime/server/render/server-islands.ts +++ b/packages/astro/src/runtime/server/render/server-islands.ts @@ -1,10 +1,9 @@ -import { encryptString } from '../../../core/encryption.js'; import type { SSRResult } from '../../../@types/astro.js'; +import { encryptString } from '../../../core/encryption.js'; import { renderChild } from './any.js'; import type { RenderInstance } from './common.js'; import { type ComponentSlots, renderSlotToString } from './slot.js'; - const internalProps = new Set([ 'server:component-path', 'server:component-export', diff --git a/packages/astro/src/vite-plugin-astro-server/plugin.ts b/packages/astro/src/vite-plugin-astro-server/plugin.ts index 238eb7c56..2458b5b8d 100644 --- a/packages/astro/src/vite-plugin-astro-server/plugin.ts +++ b/packages/astro/src/vite-plugin-astro-server/plugin.ts @@ -4,6 +4,7 @@ import { IncomingMessage } from 'node:http'; import type * as vite from 'vite'; import type { AstroSettings, ManifestData, SSRManifest } from '../@types/astro.js'; import type { SSRManifestI18n } from '../core/app/types.js'; +import { createKey } from '../core/encryption.js'; import { getViteErrorPayload } from '../core/errors/dev/index.js'; import { AstroError, AstroErrorData } from '../core/errors/index.js'; import { patchOverlay } from '../core/errors/overlay.js'; @@ -18,7 +19,6 @@ import { recordServerError } from './error.js'; import { DevPipeline } from './pipeline.js'; import { handleRequest } from './request.js'; import { setRouteError } from './server-state.js'; -import { createKey } from '../core/encryption.js'; export interface AstroPluginOptions { settings: AstroSettings; diff --git a/packages/integrations/node/src/serve-static.ts b/packages/integrations/node/src/serve-static.ts index e5cd73daf..725f7afa6 100644 --- a/packages/integrations/node/src/serve-static.ts +++ b/packages/integrations/node/src/serve-static.ts @@ -107,7 +107,7 @@ function resolveClientDir(options: Options) { // walk up the parent folders until you find the one that is the root of the server entry folder. This is how we find the client folder relatively. const serverFolder = path.basename(options.server); let serverEntryFolderURL = path.dirname(import.meta.url); - while(!serverEntryFolderURL.endsWith(serverFolder)) { + while (!serverEntryFolderURL.endsWith(serverFolder)) { serverEntryFolderURL = path.dirname(serverEntryFolderURL); } const serverEntryURL = serverEntryFolderURL + '/entry.mjs'; diff --git a/packages/integrations/node/test/errors.test.js b/packages/integrations/node/test/errors.test.js index c785af586..802fa6e25 100644 --- a/packages/integrations/node/test/errors.test.js +++ b/packages/integrations/node/test/errors.test.js @@ -1,7 +1,7 @@ import assert from 'node:assert/strict'; import { after, before, describe, it } from 'node:test'; -import { Worker } from 'node:worker_threads'; import { fileURLToPath } from 'node:url'; +import { Worker } from 'node:worker_threads'; import * as cheerio from 'cheerio'; import nodejs from '../dist/index.js'; import { loadFixture } from './test-utils.js'; |