@cedarjs/api 6.0.0-canary.2700 → 6.0.0-canary.2702
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auth/index.d.ts +6 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js +14 -4
- package/dist/cjs/auth/index.d.ts +6 -0
- package/dist/cjs/auth/index.d.ts.map +1 -1
- package/dist/cjs/auth/index.js +13 -3
- package/dist/cjs/index.js +3 -3
- package/dist/cjs/runtime.d.ts.map +1 -1
- package/dist/cjs/runtime.js +4 -53
- package/dist/cjs/transforms.d.ts +1 -0
- package/dist/cjs/transforms.d.ts.map +1 -1
- package/dist/cjs/transforms.js +80 -2
- package/dist/index.js +3 -3
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +4 -53
- package/dist/transforms.d.ts +1 -0
- package/dist/transforms.d.ts.map +1 -1
- package/dist/transforms.js +78 -1
- package/package.json +2 -2
package/dist/auth/index.d.ts
CHANGED
|
@@ -32,11 +32,17 @@ export type AuthContextPayload = [
|
|
|
32
32
|
} & AuthorizationHeader,
|
|
33
33
|
{
|
|
34
34
|
event: APIGatewayProxyEvent | Request;
|
|
35
|
+
/**
|
|
36
|
+
* The native fetch `Request`, when available. This lets user code choose
|
|
37
|
+
* between `event.headers['key']` and `request.headers.get('key')`.
|
|
38
|
+
*/
|
|
39
|
+
request?: Request;
|
|
35
40
|
context?: LambdaContext;
|
|
36
41
|
}
|
|
37
42
|
];
|
|
38
43
|
export type Decoder = (token: string, type: string, req: {
|
|
39
44
|
event: APIGatewayProxyEvent | Request;
|
|
45
|
+
request?: Request;
|
|
40
46
|
context?: LambdaContext;
|
|
41
47
|
}) => Promise<Decoded>;
|
|
42
48
|
/**
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,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AAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;QACrC;;;WAGG;QACH,OAAO,CAAC,EAAE,OAAO,CAAA;QACjB,OAAO,CAAC,EAAE,aAAa,CAAA;KACxB;CACF,CAAA;AAED,MAAM,MAAM,OAAO,GAAG,CACpB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE;IACH,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KACE,OAAO,CAAC,OAAO,CAAC,CAAA;AAErB;;;IAGI;AACJ,eAAO,MAAM,wBAAwB,GAAU,kCAI5C;IACD,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;IACjC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CA0EzC,CAAA"}
|
package/dist/auth/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export * from "./parseJWT.js";
|
|
2
2
|
import * as cookie from "cookie";
|
|
3
3
|
import { getEventHeader } from "../event.js";
|
|
4
|
-
import { isFetchApiRequest } from "../transforms.js";
|
|
4
|
+
import { isFetchApiRequest, requestToBaseEvent } from "../transforms.js";
|
|
5
5
|
const AUTH_PROVIDER_HEADER = "auth-provider";
|
|
6
6
|
const getAuthProviderHeader = (event) => {
|
|
7
7
|
if (isFetchApiRequest(event)) {
|
|
@@ -73,16 +73,26 @@ const getAuthenticationContext = async ({
|
|
|
73
73
|
authDecoders = [authDecoder];
|
|
74
74
|
}
|
|
75
75
|
let decoded = null;
|
|
76
|
+
const normalizedEvent = isFetchApiRequest(event) ? await requestToBaseEvent(event) : event;
|
|
77
|
+
const underlyingRequest = isFetchApiRequest(event) ? event : void 0;
|
|
76
78
|
let i = 0;
|
|
77
79
|
while (!decoded && i < authDecoders.length) {
|
|
78
80
|
decoded = await authDecoders[i](token, type, {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
event: normalizedEvent,
|
|
82
|
+
request: underlyingRequest,
|
|
81
83
|
context
|
|
82
84
|
});
|
|
83
85
|
i++;
|
|
84
86
|
}
|
|
85
|
-
return [
|
|
87
|
+
return [
|
|
88
|
+
decoded,
|
|
89
|
+
{ type, schema, token },
|
|
90
|
+
{
|
|
91
|
+
event: normalizedEvent,
|
|
92
|
+
request: underlyingRequest,
|
|
93
|
+
context
|
|
94
|
+
}
|
|
95
|
+
];
|
|
86
96
|
};
|
|
87
97
|
export {
|
|
88
98
|
AUTH_PROVIDER_HEADER,
|
package/dist/cjs/auth/index.d.ts
CHANGED
|
@@ -32,11 +32,17 @@ export type AuthContextPayload = [
|
|
|
32
32
|
} & AuthorizationHeader,
|
|
33
33
|
{
|
|
34
34
|
event: APIGatewayProxyEvent | Request;
|
|
35
|
+
/**
|
|
36
|
+
* The native fetch `Request`, when available. This lets user code choose
|
|
37
|
+
* between `event.headers['key']` and `request.headers.get('key')`.
|
|
38
|
+
*/
|
|
39
|
+
request?: Request;
|
|
35
40
|
context?: LambdaContext;
|
|
36
41
|
}
|
|
37
42
|
];
|
|
38
43
|
export type Decoder = (token: string, type: string, req: {
|
|
39
44
|
event: APIGatewayProxyEvent | Request;
|
|
45
|
+
request?: Request;
|
|
40
46
|
context?: LambdaContext;
|
|
41
47
|
}) => Promise<Decoded>;
|
|
42
48
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/auth/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAE7B,OAAO,KAAK,EAAE,oBAAoB,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAMhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAA;AAC5C,YAAY,EAAE,OAAO,EAAE,CAAA;AAGv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M,EACb,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE;IACH,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KACE,OAAO,CAAC,OAAO,CAAC,CAAA;AAErB;;;IAGI;AACJ,eAAO,MAAM,wBAAwB,GAAU,kCAI5C;IACD,WAAW,CAAC,EAAE,OAAO,GAAG,OAAO,EAAE,CAAA;IACjC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,aAAa,CAAA;CACxB,KAAG,OAAO,CAAC,SAAS,GAAG,kBAAkB,CA0EzC,CAAA"}
|
package/dist/cjs/auth/index.js
CHANGED
|
@@ -111,16 +111,26 @@ const getAuthenticationContext = async ({
|
|
|
111
111
|
authDecoders = [authDecoder];
|
|
112
112
|
}
|
|
113
113
|
let decoded = null;
|
|
114
|
+
const normalizedEvent = (0, import_transforms.isFetchApiRequest)(event) ? await (0, import_transforms.requestToBaseEvent)(event) : event;
|
|
115
|
+
const underlyingRequest = (0, import_transforms.isFetchApiRequest)(event) ? event : void 0;
|
|
114
116
|
let i = 0;
|
|
115
117
|
while (!decoded && i < authDecoders.length) {
|
|
116
118
|
decoded = await authDecoders[i](token, type, {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
event: normalizedEvent,
|
|
120
|
+
request: underlyingRequest,
|
|
119
121
|
context
|
|
120
122
|
});
|
|
121
123
|
i++;
|
|
122
124
|
}
|
|
123
|
-
return [
|
|
125
|
+
return [
|
|
126
|
+
decoded,
|
|
127
|
+
{ type, schema, token },
|
|
128
|
+
{
|
|
129
|
+
event: normalizedEvent,
|
|
130
|
+
request: underlyingRequest,
|
|
131
|
+
context
|
|
132
|
+
}
|
|
133
|
+
];
|
|
124
134
|
};
|
|
125
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
126
136
|
0 && (module.exports = {
|
package/dist/cjs/index.js
CHANGED
|
@@ -34,9 +34,9 @@ __reExport(index_exports, require("./transforms.js"), module.exports);
|
|
|
34
34
|
__reExport(index_exports, require("./cors.js"), module.exports);
|
|
35
35
|
__reExport(index_exports, require("./event.js"), module.exports);
|
|
36
36
|
const prismaVersion = "7.8.0";
|
|
37
|
-
const redwoodVersion = "6.0.0-canary.
|
|
38
|
-
const cedarjsVersion = "6.0.0-canary.
|
|
39
|
-
const cedarVersion = "6.0.0-canary.
|
|
37
|
+
const redwoodVersion = "6.0.0-canary.2702";
|
|
38
|
+
const cedarjsVersion = "6.0.0-canary.2702";
|
|
39
|
+
const cedarVersion = "6.0.0-canary.2702";
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
|
41
41
|
0 && (module.exports = {
|
|
42
42
|
cedarVersion,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;AAG1D,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC9B,KAAK,EAAE,eAAe,CAAA;IACtB,OAAO,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACpC,eAAe,CAAC,EAAE,OAAO,CAAC,UAAU,CAAC,OAAO,wBAAwB,CAAC,CAAC,CAAA;CACvE;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AAC,CAwB9B;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,eAAe,EAAE,GAC5B,YAAY,CAMd;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAEtE;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAQd;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,CAsD5E"}
|
package/dist/cjs/runtime.js
CHANGED
|
@@ -40,6 +40,7 @@ module.exports = __toCommonJS(runtime_exports);
|
|
|
40
40
|
var cookie = __toESM(require("cookie"), 1);
|
|
41
41
|
var import_picoquery = require("picoquery");
|
|
42
42
|
var import_auth = require("./auth/index.js");
|
|
43
|
+
var import_transforms = require("./transforms.js");
|
|
43
44
|
const DEFAULT_LAMBDA_CONTEXT = {
|
|
44
45
|
callbackWaitsForEmptyEventLoop: false,
|
|
45
46
|
functionName: "cedar",
|
|
@@ -113,55 +114,17 @@ function wrapLegacyHandler(legacyHandler, options = {}) {
|
|
|
113
114
|
}
|
|
114
115
|
async function requestToLegacyEvent(request, ctx) {
|
|
115
116
|
const url = new URL(request.url);
|
|
116
|
-
const
|
|
117
|
-
const headers = Object.fromEntries(request.headers.entries());
|
|
117
|
+
const base = await (0, import_transforms.requestToBaseEvent)(request);
|
|
118
118
|
const queryStringParameters = (0, import_picoquery.parse)(url.search ? url.search.slice(1) : "", {
|
|
119
119
|
nestingSyntax: "index",
|
|
120
120
|
arrayRepeat: true,
|
|
121
121
|
arrayRepeatSyntax: "bracket"
|
|
122
122
|
});
|
|
123
123
|
return {
|
|
124
|
-
|
|
125
|
-
headers,
|
|
126
|
-
multiValueHeaders: toMultiValueHeaders(request.headers) ?? {},
|
|
127
|
-
httpMethod: request.method,
|
|
128
|
-
isBase64Encoded: false,
|
|
129
|
-
path: url.pathname,
|
|
130
|
-
pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : null,
|
|
124
|
+
...base,
|
|
131
125
|
queryStringParameters,
|
|
132
126
|
multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
|
|
133
|
-
|
|
134
|
-
requestContext: {
|
|
135
|
-
accountId: "cedar",
|
|
136
|
-
apiId: "cedar",
|
|
137
|
-
authorizer: void 0,
|
|
138
|
-
protocol: "HTTP/1.1",
|
|
139
|
-
identity: {
|
|
140
|
-
accessKey: null,
|
|
141
|
-
accountId: null,
|
|
142
|
-
apiKey: null,
|
|
143
|
-
apiKeyId: null,
|
|
144
|
-
caller: null,
|
|
145
|
-
clientCert: null,
|
|
146
|
-
cognitoAuthenticationProvider: null,
|
|
147
|
-
cognitoAuthenticationType: null,
|
|
148
|
-
cognitoIdentityId: null,
|
|
149
|
-
cognitoIdentityPoolId: null,
|
|
150
|
-
principalOrgId: null,
|
|
151
|
-
sourceIp: "",
|
|
152
|
-
user: null,
|
|
153
|
-
userAgent: request.headers.get("user-agent"),
|
|
154
|
-
userArn: null
|
|
155
|
-
},
|
|
156
|
-
path: url.pathname,
|
|
157
|
-
stage: "",
|
|
158
|
-
requestId: "cedar-request",
|
|
159
|
-
requestTimeEpoch: Date.now(),
|
|
160
|
-
resourceId: "cedar",
|
|
161
|
-
resourcePath: url.pathname,
|
|
162
|
-
httpMethod: request.method
|
|
163
|
-
},
|
|
164
|
-
resource: url.pathname
|
|
127
|
+
pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : base.pathParameters
|
|
165
128
|
};
|
|
166
129
|
}
|
|
167
130
|
function legacyResultToResponse(result) {
|
|
@@ -204,18 +167,6 @@ function legacyResultToResponse(result) {
|
|
|
204
167
|
headers
|
|
205
168
|
});
|
|
206
169
|
}
|
|
207
|
-
function toMultiValueHeaders(headers) {
|
|
208
|
-
const values = /* @__PURE__ */ new Map();
|
|
209
|
-
for (const [name, value] of headers.entries()) {
|
|
210
|
-
const existing = values.get(name) ?? [];
|
|
211
|
-
existing.push(value);
|
|
212
|
-
values.set(name, existing);
|
|
213
|
-
}
|
|
214
|
-
if (values.size === 0) {
|
|
215
|
-
return null;
|
|
216
|
-
}
|
|
217
|
-
return Object.fromEntries(values.entries());
|
|
218
|
-
}
|
|
219
170
|
function toMultiValueQueryStringParameters(url) {
|
|
220
171
|
const values = /* @__PURE__ */ new Map();
|
|
221
172
|
for (const [name, value] of url.searchParams.entries()) {
|
package/dist/cjs/transforms.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const parseLambdaEventBody: (event: APIGatewayProxyEvent) => any;
|
|
|
17
17
|
* see readme here: https://github.com/ardatan/whatwg-node/tree/master/packages/server#aws-lambda
|
|
18
18
|
*/
|
|
19
19
|
export declare const parseFetchEventBody: (event: Request) => Promise<any>;
|
|
20
|
+
export declare const requestToBaseEvent: (request: Request) => Promise<APIGatewayProxyEvent>;
|
|
20
21
|
export declare const isFetchApiRequest: (event: Request | APIGatewayProxyEvent) => event is Request;
|
|
21
22
|
/**
|
|
22
23
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAA;AAKtD,MAAM,WAAW,cAAc,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IACzD,QAAQ,EAAE,KAAK,CAAA;IACf,OAAO,EAAE,OAAO,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,GAAG,CAAA;CACX;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,GAAI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AO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,0CAcvE,CAAA"}
|
package/dist/cjs/transforms.js
CHANGED
|
@@ -22,7 +22,8 @@ __export(transforms_exports, {
|
|
|
22
22
|
normalizeRequest: () => normalizeRequest,
|
|
23
23
|
parseFetchEventBody: () => parseFetchEventBody,
|
|
24
24
|
parseLambdaEventBody: () => parseLambdaEventBody,
|
|
25
|
-
removeNulls: () => removeNulls
|
|
25
|
+
removeNulls: () => removeNulls,
|
|
26
|
+
requestToBaseEvent: () => requestToBaseEvent
|
|
26
27
|
});
|
|
27
28
|
module.exports = __toCommonJS(transforms_exports);
|
|
28
29
|
var import_fetch = require("@whatwg-node/fetch");
|
|
@@ -43,6 +44,82 @@ const parseFetchEventBody = async (event) => {
|
|
|
43
44
|
const body = await event.text();
|
|
44
45
|
return body ? JSON.parse(body) : {};
|
|
45
46
|
};
|
|
47
|
+
const requestToBaseEvent = async (request) => {
|
|
48
|
+
const url = new URL(request.url);
|
|
49
|
+
const bodyText = await request.clone().text();
|
|
50
|
+
const queryStringParameters = {};
|
|
51
|
+
url.searchParams.forEach((value, key) => {
|
|
52
|
+
queryStringParameters[key] = value;
|
|
53
|
+
});
|
|
54
|
+
const event = {
|
|
55
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
56
|
+
body: bodyText || null,
|
|
57
|
+
httpMethod: request.method,
|
|
58
|
+
path: url.pathname,
|
|
59
|
+
queryStringParameters,
|
|
60
|
+
isBase64Encoded: false,
|
|
61
|
+
multiValueHeaders: toMultiValueHeaders(request.headers),
|
|
62
|
+
multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
|
|
63
|
+
pathParameters: null,
|
|
64
|
+
stageVariables: null,
|
|
65
|
+
resource: url.pathname,
|
|
66
|
+
requestContext: {
|
|
67
|
+
accountId: "cedar",
|
|
68
|
+
apiId: "cedar",
|
|
69
|
+
authorizer: void 0,
|
|
70
|
+
protocol: "HTTP/1.1",
|
|
71
|
+
identity: {
|
|
72
|
+
accessKey: null,
|
|
73
|
+
accountId: null,
|
|
74
|
+
apiKey: null,
|
|
75
|
+
apiKeyId: null,
|
|
76
|
+
caller: null,
|
|
77
|
+
clientCert: null,
|
|
78
|
+
cognitoAuthenticationProvider: null,
|
|
79
|
+
cognitoAuthenticationType: null,
|
|
80
|
+
cognitoIdentityId: null,
|
|
81
|
+
cognitoIdentityPoolId: null,
|
|
82
|
+
principalOrgId: null,
|
|
83
|
+
sourceIp: "",
|
|
84
|
+
user: null,
|
|
85
|
+
userAgent: request.headers.get("user-agent"),
|
|
86
|
+
userArn: null
|
|
87
|
+
},
|
|
88
|
+
path: url.pathname,
|
|
89
|
+
stage: "",
|
|
90
|
+
requestId: "cedar-request",
|
|
91
|
+
requestTimeEpoch: Date.now(),
|
|
92
|
+
resourceId: "cedar",
|
|
93
|
+
resourcePath: url.pathname,
|
|
94
|
+
httpMethod: request.method
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
return event;
|
|
98
|
+
};
|
|
99
|
+
function toMultiValueHeaders(headers) {
|
|
100
|
+
const values = /* @__PURE__ */ new Map();
|
|
101
|
+
for (const [name, value] of headers.entries()) {
|
|
102
|
+
const existing = values.get(name) ?? [];
|
|
103
|
+
existing.push(value);
|
|
104
|
+
values.set(name, existing);
|
|
105
|
+
}
|
|
106
|
+
if (values.size === 0) {
|
|
107
|
+
return {};
|
|
108
|
+
}
|
|
109
|
+
return Object.fromEntries(values.entries());
|
|
110
|
+
}
|
|
111
|
+
function toMultiValueQueryStringParameters(url) {
|
|
112
|
+
const values = /* @__PURE__ */ new Map();
|
|
113
|
+
for (const [name, value] of url.searchParams.entries()) {
|
|
114
|
+
const existing = values.get(name) ?? [];
|
|
115
|
+
existing.push(value);
|
|
116
|
+
values.set(name, existing);
|
|
117
|
+
}
|
|
118
|
+
if (values.size === 0) {
|
|
119
|
+
return null;
|
|
120
|
+
}
|
|
121
|
+
return Object.fromEntries(values.entries());
|
|
122
|
+
}
|
|
46
123
|
const isFetchApiRequest = (event) => {
|
|
47
124
|
if (event.constructor.name === "Request" || event.constructor.name === import_fetch.Request.name) {
|
|
48
125
|
return true;
|
|
@@ -94,5 +171,6 @@ const removeNulls = (input) => {
|
|
|
94
171
|
normalizeRequest,
|
|
95
172
|
parseFetchEventBody,
|
|
96
173
|
parseLambdaEventBody,
|
|
97
|
-
removeNulls
|
|
174
|
+
removeNulls,
|
|
175
|
+
requestToBaseEvent
|
|
98
176
|
});
|
package/dist/index.js
CHANGED
|
@@ -7,9 +7,9 @@ export * from "./transforms.js";
|
|
|
7
7
|
export * from "./cors.js";
|
|
8
8
|
export * from "./event.js";
|
|
9
9
|
const prismaVersion = "7.8.0";
|
|
10
|
-
const redwoodVersion = "6.0.0-canary.
|
|
11
|
-
const cedarjsVersion = "6.0.0-canary.
|
|
12
|
-
const cedarVersion = "6.0.0-canary.
|
|
10
|
+
const redwoodVersion = "6.0.0-canary.2702";
|
|
11
|
+
const cedarjsVersion = "6.0.0-canary.2702";
|
|
12
|
+
const cedarVersion = "6.0.0-canary.2702";
|
|
13
13
|
export {
|
|
14
14
|
cedarVersion,
|
|
15
15
|
cedarjsVersion,
|
package/dist/runtime.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../src/runtime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,oBAAoB,EAEpB,qBAAqB,EACrB,OAAO,IAAI,aAAa,EACzB,MAAM,YAAY,CAAA;AAInB,OAAO,EAAE,wBAAwB,EAAE,M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AM,mBAAmB,GAAG,qBAAqB,GAAG,QAAQ,CAAA;AAElE,MAAM,MAAM,aAAa,GAAG,CAC1B,KAAK,EAAE,oBAAoB,EAC3B,OAAO,EAAE,aAAa,KACnB,OAAO,CAAC,mBAAmB,CAAC,GAAG,mBAAmB,CAAA;AAyBvD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,OAAO,EAChB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,mBAAmB,CAAC,CAwB9B;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,YAAY,EACrB,UAAU,EAAE,eAAe,EAAE,GAC5B,YAAY,CAMd;AAED,wBAAgB,mBAAmB,CACjC,MAAM,EAAE,gBAAgB,EAAE,GACzB,gBAAgB,EAAE,CAOpB;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,EAAE,GAAG,MAAM,CAEtE;AAED,wBAAgB,iBAAiB,CAC/B,aAAa,EAAE,aAAa,EAC5B,OAAO,GAAE,wBAA6B,GACrC,YAAY,CAQd;AAED,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,OAAO,EAChB,GAAG,EAAE,mBAAmB,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAqB/B;AAED,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,mBAAmB,GAAG,QAAQ,CAsD5E"}
|
package/dist/runtime.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import * as cookie from "cookie";
|
|
2
2
|
import { parse } from "picoquery";
|
|
3
3
|
import { getAuthenticationContext } from "./auth/index.js";
|
|
4
|
+
import { requestToBaseEvent } from "./transforms.js";
|
|
4
5
|
const DEFAULT_LAMBDA_CONTEXT = {
|
|
5
6
|
callbackWaitsForEmptyEventLoop: false,
|
|
6
7
|
functionName: "cedar",
|
|
@@ -74,55 +75,17 @@ function wrapLegacyHandler(legacyHandler, options = {}) {
|
|
|
74
75
|
}
|
|
75
76
|
async function requestToLegacyEvent(request, ctx) {
|
|
76
77
|
const url = new URL(request.url);
|
|
77
|
-
const
|
|
78
|
-
const headers = Object.fromEntries(request.headers.entries());
|
|
78
|
+
const base = await requestToBaseEvent(request);
|
|
79
79
|
const queryStringParameters = parse(url.search ? url.search.slice(1) : "", {
|
|
80
80
|
nestingSyntax: "index",
|
|
81
81
|
arrayRepeat: true,
|
|
82
82
|
arrayRepeatSyntax: "bracket"
|
|
83
83
|
});
|
|
84
84
|
return {
|
|
85
|
-
|
|
86
|
-
headers,
|
|
87
|
-
multiValueHeaders: toMultiValueHeaders(request.headers) ?? {},
|
|
88
|
-
httpMethod: request.method,
|
|
89
|
-
isBase64Encoded: false,
|
|
90
|
-
path: url.pathname,
|
|
91
|
-
pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : null,
|
|
85
|
+
...base,
|
|
92
86
|
queryStringParameters,
|
|
93
87
|
multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
|
|
94
|
-
|
|
95
|
-
requestContext: {
|
|
96
|
-
accountId: "cedar",
|
|
97
|
-
apiId: "cedar",
|
|
98
|
-
authorizer: void 0,
|
|
99
|
-
protocol: "HTTP/1.1",
|
|
100
|
-
identity: {
|
|
101
|
-
accessKey: null,
|
|
102
|
-
accountId: null,
|
|
103
|
-
apiKey: null,
|
|
104
|
-
apiKeyId: null,
|
|
105
|
-
caller: null,
|
|
106
|
-
clientCert: null,
|
|
107
|
-
cognitoAuthenticationProvider: null,
|
|
108
|
-
cognitoAuthenticationType: null,
|
|
109
|
-
cognitoIdentityId: null,
|
|
110
|
-
cognitoIdentityPoolId: null,
|
|
111
|
-
principalOrgId: null,
|
|
112
|
-
sourceIp: "",
|
|
113
|
-
user: null,
|
|
114
|
-
userAgent: request.headers.get("user-agent"),
|
|
115
|
-
userArn: null
|
|
116
|
-
},
|
|
117
|
-
path: url.pathname,
|
|
118
|
-
stage: "",
|
|
119
|
-
requestId: "cedar-request",
|
|
120
|
-
requestTimeEpoch: Date.now(),
|
|
121
|
-
resourceId: "cedar",
|
|
122
|
-
resourcePath: url.pathname,
|
|
123
|
-
httpMethod: request.method
|
|
124
|
-
},
|
|
125
|
-
resource: url.pathname
|
|
88
|
+
pathParameters: Object.keys(ctx.params).length > 0 ? ctx.params : base.pathParameters
|
|
126
89
|
};
|
|
127
90
|
}
|
|
128
91
|
function legacyResultToResponse(result) {
|
|
@@ -165,18 +128,6 @@ function legacyResultToResponse(result) {
|
|
|
165
128
|
headers
|
|
166
129
|
});
|
|
167
130
|
}
|
|
168
|
-
function toMultiValueHeaders(headers) {
|
|
169
|
-
const values = /* @__PURE__ */ new Map();
|
|
170
|
-
for (const [name, value] of headers.entries()) {
|
|
171
|
-
const existing = values.get(name) ?? [];
|
|
172
|
-
existing.push(value);
|
|
173
|
-
values.set(name, existing);
|
|
174
|
-
}
|
|
175
|
-
if (values.size === 0) {
|
|
176
|
-
return null;
|
|
177
|
-
}
|
|
178
|
-
return Object.fromEntries(values.entries());
|
|
179
|
-
}
|
|
180
131
|
function toMultiValueQueryStringParameters(url) {
|
|
181
132
|
const values = /* @__PURE__ */ new Map();
|
|
182
133
|
for (const [name, value] of url.searchParams.entries()) {
|
package/dist/transforms.d.ts
CHANGED
|
@@ -17,6 +17,7 @@ export declare const parseLambdaEventBody: (event: APIGatewayProxyEvent) => any;
|
|
|
17
17
|
* see readme here: https://github.com/ardatan/whatwg-node/tree/master/packages/server#aws-lambda
|
|
18
18
|
*/
|
|
19
19
|
export declare const parseFetchEventBody: (event: Request) => Promise<any>;
|
|
20
|
+
export declare const requestToBaseEvent: (request: Request) => Promise<APIGatewayProxyEvent>;
|
|
20
21
|
export declare const isFetchApiRequest: (event: Request | APIGatewayProxyEvent) => event is Request;
|
|
21
22
|
/**
|
|
22
23
|
*
|
package/dist/transforms.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transforms.d.ts","sourceRoot":"","sources":["../src/transforms.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,YAAY,C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AoB,CAsD9B,CAAA;AAoCD,eAAO,MAAM,iBAAiB,GAC5B,OAAO,OAAO,GAAG,oBAAoB,KACpC,KAAK,IAAI,OAcX,CAAA;AAaD;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CACpC,KAAK,EAAE,oBAAoB,GAAG,OAAO,GACpC,OAAO,CAAC,cAAc,CAAC,CAkBzB;AAID;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,CAAC,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,0CAcvE,CAAA"}
|
package/dist/transforms.js
CHANGED
|
@@ -16,6 +16,82 @@ const parseFetchEventBody = async (event) => {
|
|
|
16
16
|
const body = await event.text();
|
|
17
17
|
return body ? JSON.parse(body) : {};
|
|
18
18
|
};
|
|
19
|
+
const requestToBaseEvent = async (request) => {
|
|
20
|
+
const url = new URL(request.url);
|
|
21
|
+
const bodyText = await request.clone().text();
|
|
22
|
+
const queryStringParameters = {};
|
|
23
|
+
url.searchParams.forEach((value, key) => {
|
|
24
|
+
queryStringParameters[key] = value;
|
|
25
|
+
});
|
|
26
|
+
const event = {
|
|
27
|
+
headers: Object.fromEntries(request.headers.entries()),
|
|
28
|
+
body: bodyText || null,
|
|
29
|
+
httpMethod: request.method,
|
|
30
|
+
path: url.pathname,
|
|
31
|
+
queryStringParameters,
|
|
32
|
+
isBase64Encoded: false,
|
|
33
|
+
multiValueHeaders: toMultiValueHeaders(request.headers),
|
|
34
|
+
multiValueQueryStringParameters: toMultiValueQueryStringParameters(url),
|
|
35
|
+
pathParameters: null,
|
|
36
|
+
stageVariables: null,
|
|
37
|
+
resource: url.pathname,
|
|
38
|
+
requestContext: {
|
|
39
|
+
accountId: "cedar",
|
|
40
|
+
apiId: "cedar",
|
|
41
|
+
authorizer: void 0,
|
|
42
|
+
protocol: "HTTP/1.1",
|
|
43
|
+
identity: {
|
|
44
|
+
accessKey: null,
|
|
45
|
+
accountId: null,
|
|
46
|
+
apiKey: null,
|
|
47
|
+
apiKeyId: null,
|
|
48
|
+
caller: null,
|
|
49
|
+
clientCert: null,
|
|
50
|
+
cognitoAuthenticationProvider: null,
|
|
51
|
+
cognitoAuthenticationType: null,
|
|
52
|
+
cognitoIdentityId: null,
|
|
53
|
+
cognitoIdentityPoolId: null,
|
|
54
|
+
principalOrgId: null,
|
|
55
|
+
sourceIp: "",
|
|
56
|
+
user: null,
|
|
57
|
+
userAgent: request.headers.get("user-agent"),
|
|
58
|
+
userArn: null
|
|
59
|
+
},
|
|
60
|
+
path: url.pathname,
|
|
61
|
+
stage: "",
|
|
62
|
+
requestId: "cedar-request",
|
|
63
|
+
requestTimeEpoch: Date.now(),
|
|
64
|
+
resourceId: "cedar",
|
|
65
|
+
resourcePath: url.pathname,
|
|
66
|
+
httpMethod: request.method
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
return event;
|
|
70
|
+
};
|
|
71
|
+
function toMultiValueHeaders(headers) {
|
|
72
|
+
const values = /* @__PURE__ */ new Map();
|
|
73
|
+
for (const [name, value] of headers.entries()) {
|
|
74
|
+
const existing = values.get(name) ?? [];
|
|
75
|
+
existing.push(value);
|
|
76
|
+
values.set(name, existing);
|
|
77
|
+
}
|
|
78
|
+
if (values.size === 0) {
|
|
79
|
+
return {};
|
|
80
|
+
}
|
|
81
|
+
return Object.fromEntries(values.entries());
|
|
82
|
+
}
|
|
83
|
+
function toMultiValueQueryStringParameters(url) {
|
|
84
|
+
const values = /* @__PURE__ */ new Map();
|
|
85
|
+
for (const [name, value] of url.searchParams.entries()) {
|
|
86
|
+
const existing = values.get(name) ?? [];
|
|
87
|
+
existing.push(value);
|
|
88
|
+
values.set(name, existing);
|
|
89
|
+
}
|
|
90
|
+
if (values.size === 0) {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
return Object.fromEntries(values.entries());
|
|
94
|
+
}
|
|
19
95
|
const isFetchApiRequest = (event) => {
|
|
20
96
|
if (event.constructor.name === "Request" || event.constructor.name === PonyfillRequest.name) {
|
|
21
97
|
return true;
|
|
@@ -66,5 +142,6 @@ export {
|
|
|
66
142
|
normalizeRequest,
|
|
67
143
|
parseFetchEventBody,
|
|
68
144
|
parseLambdaEventBody,
|
|
69
|
-
removeNulls
|
|
145
|
+
removeNulls,
|
|
146
|
+
requestToBaseEvent
|
|
70
147
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/api",
|
|
3
|
-
"version": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2702",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
"title-case": "3.0.3"
|
|
109
109
|
},
|
|
110
110
|
"devDependencies": {
|
|
111
|
-
"@cedarjs/framework-tools": "6.0.0-canary.
|
|
111
|
+
"@cedarjs/framework-tools": "6.0.0-canary.2702",
|
|
112
112
|
"@types/aws-lambda": "8.10.162",
|
|
113
113
|
"@types/jsonwebtoken": "9.0.10",
|
|
114
114
|
"@types/memjs": "1",
|