-
Notifications
You must be signed in to change notification settings - Fork 0
/
apiPayload.ts
172 lines (157 loc) · 4.16 KB
/
apiPayload.ts
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
/**
* Types for the input event of a lambda function using lambda proxy integration with API Gateway.
*
* The input event can be of two types:
* - `RestApiRequestEvent`: when using lambda proxy integration with REST API (API Gateway v1)
* - `HttpApiRequestEvent`: when using lambda proxy integration with HTTP API (API Gateway v2)
*/
/** @example
* {
* "cognito:groups": "group1,group2",
* "cognito:username": "[email protected]",
* "email": "[email protected]"
* }
*/
type Claims = {
[key: string]: string;
};
type ClientCertValidity = {
notBefore: string;
notAfter: string;
};
type ClientCert = {
clientCertPem: string;
subjectDN: string;
issuerDN: string;
serialNumber: string;
validity: ClientCertValidity;
};
type Identity = {
accessKey: string | null;
accountId: string | null;
caller: string | null;
cognitoAuthenticationProvider: string | null;
cognitoAuthenticationType: string | null;
cognitoIdentityId: string | null;
cognitoIdentityPoolId: string | null;
principalOrgId: string | null;
sourceIp: string;
user: string | null;
userAgent: string;
userArn: string | null;
clientCert: ClientCert;
};
type RestApiRequestContext = {
accountId: string;
apiId: string;
authorizer: {
claims: Claims;
scopes: string[] | null;
};
domainName: string;
domainPrefix: string;
extendedRequestId: string;
httpMethod: string;
identity: Identity;
path: string;
protocol: string;
requestId: string;
requestTime: string;
requestTimeEpoch: number;
resourceId: string | null;
resourcePath: string;
stage: string;
};
/** Lambda input event type for REST API, when using lambda proxy integration
*
* See https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
*/
export type RestApiRequestEvent = {
version: "1.0";
resource: string;
path: string;
httpMethod: string;
headers: Record<string, string>;
multiValueHeaders: Record<string, string[]>;
queryStringParameters: Record<string, string>;
multiValueQueryStringParameters: Record<string, string[]>;
requestContext: RestApiRequestContext;
pathParameters: Record<string, string> | null;
stageVariables: Record<string, string> | null;
body: string;
isBase64Encoded: boolean;
};
type Authentication = {
clientCert: ClientCert;
};
/** @example
* {
* "cognito:groups": "[group1 group2]",
* "cognito:username": "[email protected]",
* "email": "[email protected]"
* }
*/
type JwtClaims = {
[key: string]: string;
};
type JwtAuthorizer = {
claims: JwtClaims;
scopes: string[] | null;
};
type Authorizer = {
jwt: JwtAuthorizer;
};
type RequestContextHttp = {
/** @example "GET" */
method: string;
/** @example "/my/path" */
path: string;
/** @example "HTTP/1.1" */
protocol: string;
/** @example "192.0.2.1" */
sourceIp: string;
userAgent: string;
};
type RequestContextTime = {
time: string;
timeEpoch: number;
};
type HttpApiRequestContext = {
/** @example "123456789012" */
accountId: string;
apiId: string;
authentication: Authentication;
authorizer: Authorizer;
domainName: string;
domainPrefix: string;
http: RequestContextHttp;
requestId: string;
/** @example "$default" */
routeKey: string;
/** @example "$default" */
stage: string;
time: RequestContextTime;
};
/** Lambda input event type for HTTP API, when using lambda proxy integration
*
* See https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
*/
export type HttpApiRequestEvent = {
version: "2.0";
/** @example "$default" */
routeKey: string;
/** @example "/my/path" */
rawPath: string;
/** @example "parameter1=value1¶meter1=value2¶meter2=value" */
rawQueryString: string;
cookies: string[];
/** @example { "singleValueHeader": "value1", "multiValueHeader": "value1,value2" } */
headers: Record<string, string>;
/** @example { "singleValueParam": "value1", "multiValueParam": "value1,value2" } */
queryStringParameters: Record<string, string>;
requestContext: HttpApiRequestContext;
body: string;
pathParameters: Record<string, string>;
isBase64Encoded: boolean;
stageVariables: Record<string, string>;
};