Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | 5x 5x 66x 5x 66x | import { CloudFrontRequest, CloudFrontRequestEvent } from 'aws-lambda'
export function toAwsResponse<T>(value: T) {
return {
promise: () => Promise.resolve(value),
}
}
interface MockRequestParams {
uri: string
querystring?: string
method?: string
body?: CloudFrontRequest['body']
headers?: CloudFrontRequest['headers']
}
export const mockRequest = ({
uri,
querystring = 'apiKey=ujKG34hUYKLJKJ1F&version=3&loaderVersion=3.6.2',
method = 'POST',
body,
headers = {},
}: MockRequestParams) => {
return {
clientIp: '1.1.1.1',
method: method,
uri,
body,
querystring,
headers: {
host: [
{
key: 'host',
value: 'adewe.cloudfront.net',
},
],
cookie: [
{
key: 'cookie',
value: '',
},
],
...headers,
},
origin: {
s3: {
domainName: 'adewe.cloudfront.net',
path: '/',
region: 'us',
authMethod: 'origin-access-identity',
customHeaders: {
fpjs_pre_shared_secret: [
{
key: 'fpjs_pre_shared_secret',
value: 'qwertyuio1356767',
},
],
fpjs_agent_download_path: [
{
key: 'fpjs_agent_download_path',
value: 'greiodsfkljlds',
},
],
fpjs_get_result_path: [
{
key: 'fpjs_get_result_path',
value: 'result',
},
],
fpjs_integration_path_depth: [
{
key: 'fpjs_integration_path_depth',
value: '1',
},
],
},
},
},
} satisfies CloudFrontRequest
}
export const mockEvent = (request: CloudFrontRequest): CloudFrontRequestEvent => {
return {
Records: [
{
cf: {
request,
config: {
eventType: 'origin-request',
requestId: 'fake-id',
distributionId: 'fake-id',
distributionDomainName: 'fake-domain.tld',
},
},
},
],
}
}
|