mirror of
https://github.com/withastro/astro.git
synced 2025-01-20 22:12:38 -05:00
[ci] format
This commit is contained in:
parent
932bd2eb07
commit
f5616a8ac0
13 changed files with 19 additions and 21 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 {
|
||||
/**
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -38,7 +38,7 @@ function vitePluginSSR(
|
|||
}
|
||||
|
||||
const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint;
|
||||
if(adapterServerEntrypoint) {
|
||||
if (adapterServerEntrypoint) {
|
||||
inputs.add(adapterServerEntrypoint);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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];
|
||||
|
||||
|
|
|
@ -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',
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -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';
|
||||
|
|
Loading…
Add table
Reference in a new issue