-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bd1d4aa
commit c0c9645
Showing
3 changed files
with
26 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,33 @@ | ||
import { type Flags, flagsToAstroInlineConfig } from '../flags.js'; | ||
import { createNodeLogger } from '../../core/config/logging.js'; | ||
import { createKey as createCryptoKey,encodeKey } from '../../core/encryption.js'; | ||
import { createKey as createCryptoKey, encodeKey } from '../../core/encryption.js'; | ||
import { type Flags, flagsToAstroInlineConfig } from '../flags.js'; | ||
|
||
interface CreateKeyOptions { | ||
flags: Flags; | ||
} | ||
|
||
export async function createKey({ flags }: CreateKeyOptions): Promise<0 | 1> { | ||
try { | ||
const inlineConfig = flagsToAstroInlineConfig(flags); | ||
const logger = createNodeLogger(inlineConfig); | ||
try { | ||
const inlineConfig = flagsToAstroInlineConfig(flags); | ||
const logger = createNodeLogger(inlineConfig); | ||
|
||
const keyPromise = createCryptoKey(); | ||
const key = await keyPromise; | ||
const encoded = await encodeKey(key); | ||
const keyPromise = createCryptoKey(); | ||
const key = await keyPromise; | ||
const encoded = await encodeKey(key); | ||
|
||
logger.info('crypto', `Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server. | ||
logger.info( | ||
'crypto', | ||
`Generated a key to encrypt props passed to Server islands. To reuse the same key across builds, set this value as ASTRO_KEY in an environment variable on your build server. | ||
ASTRO_KEY=${encoded}`); | ||
} catch(err: unknown) { | ||
if(err != null) { | ||
// eslint-disable-next-line no-console | ||
console.error(err.toString()); | ||
} | ||
return 1; | ||
} | ||
ASTRO_KEY=${encoded}`, | ||
); | ||
} catch (err: unknown) { | ||
if (err != null) { | ||
// eslint-disable-next-line no-console | ||
console.error(err.toString()); | ||
} | ||
return 1; | ||
} | ||
|
||
return 0; | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters