Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
matthewp authored and astrobot-houston committed Aug 13, 2024
1 parent 932bd2e commit f5616a8
Show file tree
Hide file tree
Showing 13 changed files with 19 additions and 21 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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 {
/**
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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');
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ function vitePluginSSR(
}

const adapterServerEntrypoint = options.settings.adapter?.serverEntrypoint;
if(adapterServerEntrypoint) {
if (adapterServerEntrypoint) {
inputs.add(adapterServerEntrypoint);
}

Expand Down
16 changes: 8 additions & 8 deletions packages/astro/src/core/encryption.ts
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,7 +15,7 @@ export async function createKey() {
length: 256,
},
true,
['encrypt', 'decrypt']
['encrypt', 'decrypt'],
);
return key;
}
Expand All @@ -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;
}

/**
Expand All @@ -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']);
}

Expand All @@ -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));
Expand All @@ -73,15 +73,15 @@ 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(
{
name: ALGORITHM,
iv,
},
key,
dataArray
dataArray,
);
const decryptedString = decoder.decode(decryptedBuffer);
return decryptedString;
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/render-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/server-islands/endpoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down
3 changes: 1 addition & 2 deletions packages/astro/src/runtime/server/render/server-islands.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-astro-server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/src/serve-static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/integrations/node/test/errors.test.js
Original file line number Diff line number Diff line change
@@ -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';
Expand Down

0 comments on commit f5616a8

Please sign in to comment.