in src/lambda-edge/shared/shared.ts [178:219]
export function getCompleteConfig(): CompleteConfig {
const config = getConfigWithHeaders();
if (!isCompleteConfig(config)) {
throw new Error("Incomplete config in configuration.json");
}
// Derive cookie settings by merging the defaults with the explicitly provided values
const defaultCookieSettings = getDefaultCookieSettings({
compatibility: config.cookieCompatibility,
mode: config.mode,
});
const cookieSettings = config.cookieSettings
? (Object.fromEntries(
Object.entries({
...defaultCookieSettings,
...config.cookieSettings,
}).map(([k, v]) => [
k,
v || defaultCookieSettings[k as keyof CookieSettings],
])
) as CookieSettings)
: defaultCookieSettings;
// Defaults for nonce and PKCE
const defaults = {
secretAllowedCharacters:
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-._~",
pkceLength: 43, // Should be between 43 and 128 - per spec
nonceLength: 16,
nonceMaxAge:
(cookieSettings?.nonce &&
parseInt(parse(cookieSettings.nonce.toLowerCase())["max-age"])) ||
60 * 60 * 24,
};
return {
...defaults,
...config,
cookieSettings,
};
}