@infoxchange/make-it-so 2.12.0-internal-testing-odic-verify-proxy-fix.2 → 2.12.0-internal-testing-add-ix-ses-idenity.1
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/README.md +22 -0
- package/dist/cdk-constructs/IxDnsRecord.d.ts +4 -1
- package/dist/cdk-constructs/IxDnsRecord.d.ts.map +1 -1
- package/dist/cdk-constructs/IxDnsRecord.js +19 -2
- package/dist/cdk-constructs/IxSESIdentity.d.ts +15 -0
- package/dist/cdk-constructs/IxSESIdentity.d.ts.map +1 -0
- package/dist/cdk-constructs/IxSESIdentity.js +43 -0
- package/dist/cdk-constructs/index.d.ts +1 -0
- package/dist/cdk-constructs/index.d.ts.map +1 -1
- package/dist/cdk-constructs/index.js +1 -0
- package/dist/lib/auth/oidc.d.ts.map +1 -1
- package/dist/lib/auth/oidc.js +0 -5
- package/dist/lib/utils/objects.d.ts +1 -1
- package/dist/lib/utils/objects.d.ts.map +1 -1
- package/package.json +2 -6
- package/src/cdk-constructs/IxDnsRecord.ts +28 -4
- package/src/cdk-constructs/IxSESIdentity.ts +74 -0
- package/src/cdk-constructs/index.ts +1 -0
- package/src/lib/auth/oidc.ts +0 -6
- package/src/lib/utils/objects.ts +5 -1
- package/dist/lib/proxy/fetch.d.ts +0 -4
- package/dist/lib/proxy/fetch.d.ts.map +0 -1
- package/dist/lib/proxy/fetch.js +0 -27
- package/dist/lib/proxy/index.d.ts +0 -2
- package/dist/lib/proxy/index.d.ts.map +0 -1
- package/dist/lib/proxy/index.js +0 -1
- package/src/lib/proxy/fetch.ts +0 -36
- package/src/lib/proxy/index.ts +0 -1
package/README.md
CHANGED
|
@@ -261,6 +261,28 @@ new IxDnsRecord(scope, "IxDnsRecord", {
|
|
|
261
261
|
|
|
262
262
|
</details>
|
|
263
263
|
|
|
264
|
+
<details>
|
|
265
|
+
<summary><strong>IxSESIdentity</strong> - Creates an SES domain identity for a domain managed by IX.</summary>
|
|
266
|
+
|
|
267
|
+
```typescript
|
|
268
|
+
import { IxSESIdentity } from "@infoxchange/make-it-so/cdk-constructs";
|
|
269
|
+
|
|
270
|
+
new IxSESIdentity(scope, "IxSESIdentity", {
|
|
271
|
+
domain: "example.dev.ixapps.org",
|
|
272
|
+
mailFromSubdomain: "info",
|
|
273
|
+
});
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
#### Options:
|
|
277
|
+
|
|
278
|
+
| Prop | Type | Description |
|
|
279
|
+
| ----------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
280
|
+
| domain | string | The domain of the identity. Either this for `from` must be specified. |
|
|
281
|
+
| from | string | An email address from get domain of the identity. Either this for `domain` must be specified. |
|
|
282
|
+
| mailFromSubdomain | string | (optional) by default the custom mail from domain will be `mail.${domain}`. This lets you change that. It should be given as just the subdomain part, not the fully qualified domain. |
|
|
283
|
+
|
|
284
|
+
</details>
|
|
285
|
+
|
|
264
286
|
<details>
|
|
265
287
|
<summary><strong>IxWebsiteRedirect</strong> - Creates a redirect from one domain to another.</summary>
|
|
266
288
|
|
|
@@ -7,10 +7,13 @@ type Props = {
|
|
|
7
7
|
ttl?: number;
|
|
8
8
|
hostedZoneId?: string;
|
|
9
9
|
} & ({
|
|
10
|
-
type: "A" | "CNAME" | "NS" | "SOA";
|
|
10
|
+
type: "A" | "CNAME" | "NS" | "SOA" | "TXT";
|
|
11
11
|
} | {
|
|
12
12
|
type: "ALIAS";
|
|
13
13
|
aliasZoneId: string;
|
|
14
|
+
} | {
|
|
15
|
+
type: "MX";
|
|
16
|
+
priority: number;
|
|
14
17
|
});
|
|
15
18
|
export declare class IxDnsRecord extends Construct {
|
|
16
19
|
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IxDnsRecord.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxDnsRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,CACA;IACE,IAAI,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"IxDnsRecord.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxDnsRecord.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,CACA;IACE,IAAI,EAAE,GAAG,GAAG,OAAO,GAAG,IAAI,GAAG,KAAK,GAAG,KAAK,CAAC;CAC5C,GACD;IACE,IAAI,EAAE,OAAO,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,GACD;IACE,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;CAClB,CACJ,CAAC;AAEF,qBAAa,WAAY,SAAQ,SAAS;gBAC5B,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;IAKhE,OAAO,CAAC,eAAe;CA6CxB"}
|
|
@@ -9,14 +9,31 @@ export class IxDnsRecord extends Construct {
|
|
|
9
9
|
}
|
|
10
10
|
createDnsRecord(scope, id, constructProps) {
|
|
11
11
|
const dnsRecordUpdaterLambdaArn = StringParameter.valueForStringParameter(scope, "/shared-services/route53/lambdaArn");
|
|
12
|
-
const
|
|
12
|
+
const keysMap = {
|
|
13
13
|
name: "RecordFQDN",
|
|
14
14
|
value: "RecordValue",
|
|
15
15
|
ttl: "RecordTTL",
|
|
16
16
|
hostedZoneId: "HostedZoneId",
|
|
17
17
|
type: "RecordType",
|
|
18
18
|
aliasZoneId: "AliasZoneId",
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
|
+
let lambdaProps;
|
|
21
|
+
if (constructProps.type === "TXT") {
|
|
22
|
+
lambdaProps = remapKeys({
|
|
23
|
+
...constructProps,
|
|
24
|
+
value: `"${constructProps.value}"`,
|
|
25
|
+
}, keysMap);
|
|
26
|
+
}
|
|
27
|
+
else if (constructProps.type === "MX") {
|
|
28
|
+
const { priority, ...rest } = constructProps;
|
|
29
|
+
lambdaProps = remapKeys({
|
|
30
|
+
...rest,
|
|
31
|
+
value: `${priority} ${rest.value}`,
|
|
32
|
+
}, keysMap);
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
lambdaProps = remapKeys(constructProps, keysMap);
|
|
36
|
+
}
|
|
20
37
|
new CustomResource(scope, id + "-CertificateCustomResource", {
|
|
21
38
|
resourceType: "Custom::DNSRecordUpdaterLambda",
|
|
22
39
|
serviceToken: dnsRecordUpdaterLambdaArn,
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
type ConstructScope = ConstructorParameters<typeof Construct>[0];
|
|
3
|
+
type ConstructId = ConstructorParameters<typeof Construct>[1];
|
|
4
|
+
type Props = {
|
|
5
|
+
mailFromSubdomain?: string;
|
|
6
|
+
} & ({
|
|
7
|
+
domain: string;
|
|
8
|
+
} | {
|
|
9
|
+
from: string;
|
|
10
|
+
});
|
|
11
|
+
export declare class IxSESIdentity extends Construct {
|
|
12
|
+
constructor(scope: ConstructScope, id: ConstructId, props: Props);
|
|
13
|
+
}
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=IxSESIdentity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IxSESIdentity.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/IxSESIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAKvC,KAAK,cAAc,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AACjE,KAAK,WAAW,GAAG,qBAAqB,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;AAE9D,KAAK,KAAK,GAAG;IACX,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B,GAAG,CACA;IACE,MAAM,EAAE,MAAM,CAAC;CAChB,GACD;IACE,IAAI,EAAE,MAAM,CAAC;CACd,CACJ,CAAC;AAEF,qBAAa,aAAc,SAAQ,SAAS;gBAC9B,KAAK,EAAE,cAAc,EAAE,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,KAAK;CAqDjE"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { IxDnsRecord } from "./IxDnsRecord.js";
|
|
3
|
+
import * as ses from "aws-cdk-lib/aws-ses";
|
|
4
|
+
import * as cdk from "aws-cdk-lib";
|
|
5
|
+
export class IxSESIdentity extends Construct {
|
|
6
|
+
constructor(scope, id, props) {
|
|
7
|
+
const domain = "domain" in props ? props.domain : props.from.split("@")[1];
|
|
8
|
+
const mailFromDomain = `${props.mailFromSubdomain ?? "mail"}.${domain}`;
|
|
9
|
+
super(scope, id);
|
|
10
|
+
const identity = new ses.EmailIdentity(scope, "EmailIdentity", {
|
|
11
|
+
identity: ses.Identity.domain(domain),
|
|
12
|
+
mailFromDomain,
|
|
13
|
+
});
|
|
14
|
+
// Based on https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L247
|
|
15
|
+
for (const i of [1, 2, 3]) {
|
|
16
|
+
new IxDnsRecord(scope, `${id}DkimDnsToken${i}`, {
|
|
17
|
+
type: "CNAME",
|
|
18
|
+
name: identity[`dkimDnsTokenName${i}`],
|
|
19
|
+
value: identity[`dkimDnsTokenValue${i}`],
|
|
20
|
+
ttl: 1800,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
// Based on
|
|
24
|
+
// https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L512
|
|
25
|
+
new IxDnsRecord(scope, `${id}MailFromMxRecord`, {
|
|
26
|
+
type: "MX",
|
|
27
|
+
name: mailFromDomain,
|
|
28
|
+
value: `feedback-smtp.${cdk.Stack.of(scope).region}.amazonses.com`,
|
|
29
|
+
priority: 10,
|
|
30
|
+
});
|
|
31
|
+
new IxDnsRecord(scope, `${id}MailFromTxtRecord`, {
|
|
32
|
+
type: "TXT",
|
|
33
|
+
name: mailFromDomain,
|
|
34
|
+
value: "v=spf1 include:amazonses.com ~all",
|
|
35
|
+
});
|
|
36
|
+
// Set up DMARC record
|
|
37
|
+
new IxDnsRecord(scope, `${id}DMARC`, {
|
|
38
|
+
type: "TXT",
|
|
39
|
+
name: `_dmarc.${domain}`,
|
|
40
|
+
value: "v=DMARC1; p=none;",
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cdk-constructs/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,YAAY,CAAC;AAC3B,cAAc,4BAA4B,CAAC;AAC3C,cAAc,yBAAyB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/oidc.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,UAAU,EAAa,MAAM,MAAM,CAAC;AAEjE,KAAK,uBAAuB,CAAC,UAAU,SAAS,OAAO,GAAG,KAAK,IAAI;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,SAAS,OAAO,GAAG,KAAK,EAAE,EAC1E,KAAK,EACL,SAAS,EACT,QAAQ,EACR,UAAU,GACX,EAAE,uBAAuB,CAAC,UAAU,CAAC,GAAG,OAAO,CAC9C,UAAU,SAAS,IAAI,GAEf;IAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GACzC;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GACxC,UAAU,CACf,
|
|
1
|
+
{"version":3,"file":"oidc.d.ts","sourceRoot":"","sources":["../../../src/lib/auth/oidc.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,UAAU,EAAa,MAAM,MAAM,CAAC;AAEjE,KAAK,uBAAuB,CAAC,UAAU,SAAS,OAAO,GAAG,KAAK,IAAI;IACjE,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,UAAU,CAAC;CACzB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAsB,iBAAiB,CAAC,UAAU,SAAS,OAAO,GAAG,KAAK,EAAE,EAC1E,KAAK,EACL,SAAS,EACT,QAAQ,EACR,UAAU,GACX,EAAE,uBAAuB,CAAC,UAAU,CAAC,GAAG,OAAO,CAC9C,UAAU,SAAS,IAAI,GAEf;IAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAAC;IAAC,OAAO,EAAE,IAAI,CAAA;CAAE,GACzC;IAAE,KAAK,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,GACxC,UAAU,CACf,CAyCA"}
|
package/dist/lib/auth/oidc.js
CHANGED
|
@@ -12,21 +12,16 @@ import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
|
12
12
|
*/
|
|
13
13
|
export async function verifyAccessToken({ token, issuerUrl, audience, safeVerify, }) {
|
|
14
14
|
try {
|
|
15
|
-
console.debug("Discovered JWKS URI aa:", issuerUrl);
|
|
16
15
|
const issuer = await Issuer.discover(issuerUrl);
|
|
17
|
-
console.debug("Discovered JWKS URI aa 2");
|
|
18
16
|
const jwksUri = issuer.metadata.jwks_uri;
|
|
19
17
|
if (!jwksUri) {
|
|
20
18
|
throw new Error("JWKS URI not found in issuer metadata");
|
|
21
19
|
}
|
|
22
|
-
console.debug("Discovered JWKS URI:", jwksUri);
|
|
23
20
|
const JWKS = createRemoteJWKSet(new URL(jwksUri));
|
|
24
|
-
console.debug("Discovered JWKS URI 1");
|
|
25
21
|
// Verify the signature and basic claims
|
|
26
22
|
const { payload } = await jwtVerify(token, JWKS, {
|
|
27
23
|
issuer: issuer.metadata.issuer,
|
|
28
24
|
});
|
|
29
|
-
console.debug("Discovered JWKS URI 2");
|
|
30
25
|
const tokenAud = payload.aud ?? payload.client_id;
|
|
31
26
|
let audienceMatches = false;
|
|
32
27
|
for (const aud of Array.isArray(tokenAud) ? tokenAud : [tokenAud]) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export declare function remapKeys<SourceObject extends object, MapObject extends Record<keyof SourceObject, string>>(object: SourceObject, keyMap: Readonly<MapObject>): {
|
|
2
|
-
[k in keyof SourceObject]:
|
|
2
|
+
[k in keyof SourceObject as k extends keyof MapObject ? MapObject[k] : k]: SourceObject[k];
|
|
3
3
|
};
|
|
4
4
|
//# sourceMappingURL=objects.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,YAAY,SAAS,MAAM,EAC3B,SAAS,SAAS,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,EAEpD,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC1B;
|
|
1
|
+
{"version":3,"file":"objects.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/objects.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CACvB,YAAY,SAAS,MAAM,EAC3B,SAAS,SAAS,MAAM,CAAC,MAAM,YAAY,EAAE,MAAM,CAAC,EAEpD,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,QAAQ,CAAC,SAAS,CAAC,GAC1B;KACA,CAAC,IAAI,MAAM,YAAY,IAAI,CAAC,SAAS,MAAM,SAAS,GACjD,SAAS,CAAC,CAAC,CAAC,GACZ,CAAC,GAAG,YAAY,CAAC,CAAC,CAAC;CACxB,CAQA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@infoxchange/make-it-so",
|
|
3
|
-
"version": "2.12.0-internal-testing-
|
|
3
|
+
"version": "2.12.0-internal-testing-add-ix-ses-idenity.1",
|
|
4
4
|
"description": "Makes deploying services to IX infra easy",
|
|
5
5
|
"repository": "github:infoxchange/make-it-so",
|
|
6
6
|
"type": "module",
|
|
@@ -17,8 +17,7 @@
|
|
|
17
17
|
"exports": {
|
|
18
18
|
"./cdk-constructs": "./dist/cdk-constructs/index.js",
|
|
19
19
|
"./deployConfig": "./dist/deployConfig.js",
|
|
20
|
-
"./auth": "./dist/lib/auth/index.js"
|
|
21
|
-
"./proxy": "./dist/lib/proxy/index.js"
|
|
20
|
+
"./auth": "./dist/lib/auth/index.js"
|
|
22
21
|
},
|
|
23
22
|
"lint-staged": {
|
|
24
23
|
"**/*": [
|
|
@@ -33,7 +32,6 @@
|
|
|
33
32
|
"@eslint/js": "^9.3.0",
|
|
34
33
|
"@tsconfig/node21": "^21.0.3",
|
|
35
34
|
"@types/aws-cloudfront-function": "^1.0.6",
|
|
36
|
-
"@types/global-agent": "^3.0.0",
|
|
37
35
|
"@types/jsonwebtoken": "^9.0.10",
|
|
38
36
|
"aws-cdk-lib": "2.142.1",
|
|
39
37
|
"constructs": "^10.3.0",
|
|
@@ -55,9 +53,7 @@
|
|
|
55
53
|
"sst": "^2.0.0"
|
|
56
54
|
},
|
|
57
55
|
"dependencies": {
|
|
58
|
-
"global-agent": "^3.0.0",
|
|
59
56
|
"jsonwebtoken": "^9.0.2",
|
|
60
|
-
"undici": "^7.16.0",
|
|
61
57
|
"zod": "^3.24.2"
|
|
62
58
|
}
|
|
63
59
|
}
|
|
@@ -13,12 +13,16 @@ type Props = {
|
|
|
13
13
|
hostedZoneId?: string;
|
|
14
14
|
} & (
|
|
15
15
|
| {
|
|
16
|
-
type: "A" | "CNAME" | "NS" | "SOA";
|
|
16
|
+
type: "A" | "CNAME" | "NS" | "SOA" | "TXT";
|
|
17
17
|
}
|
|
18
18
|
| {
|
|
19
19
|
type: "ALIAS";
|
|
20
20
|
aliasZoneId: string;
|
|
21
21
|
}
|
|
22
|
+
| {
|
|
23
|
+
type: "MX";
|
|
24
|
+
priority: number;
|
|
25
|
+
}
|
|
22
26
|
);
|
|
23
27
|
|
|
24
28
|
export class IxDnsRecord extends Construct {
|
|
@@ -36,15 +40,35 @@ export class IxDnsRecord extends Construct {
|
|
|
36
40
|
scope,
|
|
37
41
|
"/shared-services/route53/lambdaArn",
|
|
38
42
|
);
|
|
39
|
-
|
|
40
|
-
const lambdaProps = remapKeys(constructProps, {
|
|
43
|
+
const keysMap = {
|
|
41
44
|
name: "RecordFQDN",
|
|
42
45
|
value: "RecordValue",
|
|
43
46
|
ttl: "RecordTTL",
|
|
44
47
|
hostedZoneId: "HostedZoneId",
|
|
45
48
|
type: "RecordType",
|
|
46
49
|
aliasZoneId: "AliasZoneId",
|
|
47
|
-
}
|
|
50
|
+
};
|
|
51
|
+
let lambdaProps;
|
|
52
|
+
if (constructProps.type === "TXT") {
|
|
53
|
+
lambdaProps = remapKeys(
|
|
54
|
+
{
|
|
55
|
+
...constructProps,
|
|
56
|
+
value: `"${constructProps.value}"`,
|
|
57
|
+
},
|
|
58
|
+
keysMap,
|
|
59
|
+
);
|
|
60
|
+
} else if (constructProps.type === "MX") {
|
|
61
|
+
const { priority, ...rest } = constructProps;
|
|
62
|
+
lambdaProps = remapKeys(
|
|
63
|
+
{
|
|
64
|
+
...rest,
|
|
65
|
+
value: `${priority} ${rest.value}`,
|
|
66
|
+
},
|
|
67
|
+
keysMap,
|
|
68
|
+
);
|
|
69
|
+
} else {
|
|
70
|
+
lambdaProps = remapKeys(constructProps, keysMap);
|
|
71
|
+
}
|
|
48
72
|
|
|
49
73
|
new CustomResource(scope, id + "-CertificateCustomResource", {
|
|
50
74
|
resourceType: "Custom::DNSRecordUpdaterLambda",
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Construct } from "constructs";
|
|
2
|
+
import { IxDnsRecord } from "./IxDnsRecord.js";
|
|
3
|
+
import * as ses from "aws-cdk-lib/aws-ses";
|
|
4
|
+
import * as cdk from "aws-cdk-lib";
|
|
5
|
+
|
|
6
|
+
type ConstructScope = ConstructorParameters<typeof Construct>[0];
|
|
7
|
+
type ConstructId = ConstructorParameters<typeof Construct>[1];
|
|
8
|
+
|
|
9
|
+
type Props = {
|
|
10
|
+
mailFromSubdomain?: string;
|
|
11
|
+
} & (
|
|
12
|
+
| {
|
|
13
|
+
domain: string;
|
|
14
|
+
}
|
|
15
|
+
| {
|
|
16
|
+
from: string;
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
export class IxSESIdentity extends Construct {
|
|
21
|
+
constructor(scope: ConstructScope, id: ConstructId, props: Props) {
|
|
22
|
+
const domain = "domain" in props ? props.domain : props.from.split("@")[1];
|
|
23
|
+
const mailFromDomain = `${props.mailFromSubdomain ?? "mail"}.${domain}`;
|
|
24
|
+
|
|
25
|
+
super(scope, id);
|
|
26
|
+
|
|
27
|
+
const identity = new ses.EmailIdentity(scope, "EmailIdentity", {
|
|
28
|
+
identity: ses.Identity.domain(domain),
|
|
29
|
+
mailFromDomain,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Based on https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L247
|
|
33
|
+
for (const i of [1, 2, 3]) {
|
|
34
|
+
new IxDnsRecord(scope, `${id}DkimDnsToken${i}`, {
|
|
35
|
+
type: "CNAME",
|
|
36
|
+
name: identity[
|
|
37
|
+
`dkimDnsTokenName${i}` as
|
|
38
|
+
| "dkimDnsTokenName1"
|
|
39
|
+
| "dkimDnsTokenName2"
|
|
40
|
+
| "dkimDnsTokenName3"
|
|
41
|
+
],
|
|
42
|
+
value:
|
|
43
|
+
identity[
|
|
44
|
+
`dkimDnsTokenValue${i}` as
|
|
45
|
+
| "dkimDnsTokenValue1"
|
|
46
|
+
| "dkimDnsTokenValue2"
|
|
47
|
+
| "dkimDnsTokenValue3"
|
|
48
|
+
],
|
|
49
|
+
ttl: 1800,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Based on
|
|
54
|
+
// https://github.com/aws/aws-cdk/blob/e2ef65a26c833ecb4a29c22e070c3c5f01c31995/packages/aws-cdk-lib/aws-ses/lib/email-identity.ts#L512
|
|
55
|
+
new IxDnsRecord(scope, `${id}MailFromMxRecord`, {
|
|
56
|
+
type: "MX",
|
|
57
|
+
name: mailFromDomain,
|
|
58
|
+
value: `feedback-smtp.${cdk.Stack.of(scope).region}.amazonses.com`,
|
|
59
|
+
priority: 10,
|
|
60
|
+
});
|
|
61
|
+
new IxDnsRecord(scope, `${id}MailFromTxtRecord`, {
|
|
62
|
+
type: "TXT",
|
|
63
|
+
name: mailFromDomain,
|
|
64
|
+
value: "v=spf1 include:amazonses.com ~all",
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
// Set up DMARC record
|
|
68
|
+
new IxDnsRecord(scope, `${id}DMARC`, {
|
|
69
|
+
type: "TXT",
|
|
70
|
+
name: `_dmarc.${domain}`,
|
|
71
|
+
value: "v=DMARC1; p=none;",
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
}
|
package/src/lib/auth/oidc.ts
CHANGED
|
@@ -31,24 +31,18 @@ export async function verifyAccessToken<SafeVerify extends boolean = false>({
|
|
|
31
31
|
: JWTPayload
|
|
32
32
|
> {
|
|
33
33
|
try {
|
|
34
|
-
console.debug("Discovered JWKS URI aa:", issuerUrl);
|
|
35
34
|
const issuer = await Issuer.discover(issuerUrl);
|
|
36
|
-
console.debug("Discovered JWKS URI aa 2");
|
|
37
35
|
const jwksUri = issuer.metadata.jwks_uri;
|
|
38
36
|
if (!jwksUri) {
|
|
39
37
|
throw new Error("JWKS URI not found in issuer metadata");
|
|
40
38
|
}
|
|
41
|
-
console.debug("Discovered JWKS URI:", jwksUri);
|
|
42
39
|
const JWKS = createRemoteJWKSet(new URL(jwksUri));
|
|
43
|
-
console.debug("Discovered JWKS URI 1");
|
|
44
40
|
|
|
45
41
|
// Verify the signature and basic claims
|
|
46
42
|
const { payload } = await jwtVerify(token, JWKS, {
|
|
47
43
|
issuer: issuer.metadata.issuer,
|
|
48
44
|
});
|
|
49
45
|
|
|
50
|
-
console.debug("Discovered JWKS URI 2");
|
|
51
|
-
|
|
52
46
|
const tokenAud = payload.aud ?? payload.client_id;
|
|
53
47
|
let audienceMatches = false;
|
|
54
48
|
for (const aud of Array.isArray(tokenAud) ? tokenAud : [tokenAud]) {
|
package/src/lib/utils/objects.ts
CHANGED
|
@@ -4,7 +4,11 @@ export function remapKeys<
|
|
|
4
4
|
>(
|
|
5
5
|
object: SourceObject,
|
|
6
6
|
keyMap: Readonly<MapObject>,
|
|
7
|
-
): {
|
|
7
|
+
): {
|
|
8
|
+
[k in keyof SourceObject as k extends keyof MapObject
|
|
9
|
+
? MapObject[k]
|
|
10
|
+
: k]: SourceObject[k];
|
|
11
|
+
} {
|
|
8
12
|
return Object.fromEntries(
|
|
9
13
|
Object.entries(object).map(([key, value]) => {
|
|
10
14
|
// @ts-expect-error the typing for map() reduces keys to general string
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../../../src/lib/proxy/fetch.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,IAAI,WAAW,EACrB,MAAM,QAAQ,CAAC;AAGhB,wBAAgB,kBAAkB,SAcjC;AAED,wBAAgB,eAAe,uBAY9B"}
|
package/dist/lib/proxy/fetch.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { setGlobalDispatcher, EnvHttpProxyAgent, fetch as undiciFetch, } from "undici";
|
|
2
|
-
import { bootstrap } from "global-agent";
|
|
3
|
-
export function setupProxyGlobally() {
|
|
4
|
-
// To cover libraries that use fetch
|
|
5
|
-
// See https://nodejs.org/api/globals.html#custom-dispatcher
|
|
6
|
-
// This might stop being needed at some point: https://github.com/actions/create-github-app-token/pull/143#discussion_r1747641337
|
|
7
|
-
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
8
|
-
setGlobalDispatcher(envHttpProxyAgent);
|
|
9
|
-
// To cover libraries that use the http/https object
|
|
10
|
-
if (!process.env.GLOBAL_AGENT_HTTP_PROXY) {
|
|
11
|
-
process.env.GLOBAL_AGENT_HTTP_PROXY = process.env.HTTP_PROXY;
|
|
12
|
-
process.env.GLOBAL_AGENT_HTTPS_PROXY =
|
|
13
|
-
process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY;
|
|
14
|
-
}
|
|
15
|
-
bootstrap();
|
|
16
|
-
}
|
|
17
|
-
export function getProxiedFetch() {
|
|
18
|
-
const fetch = (input, init = {}) => {
|
|
19
|
-
console.log("Using proxied fetch for request to:", input);
|
|
20
|
-
if (init.dispatcher) {
|
|
21
|
-
console.warn("A custom dispatcher was provided to fetch but this is ignored as a proxy agent is being used.");
|
|
22
|
-
}
|
|
23
|
-
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
24
|
-
return undiciFetch(input, { ...init, dispatcher: envHttpProxyAgent });
|
|
25
|
-
};
|
|
26
|
-
return fetch;
|
|
27
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/proxy/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
|
package/dist/lib/proxy/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./fetch.js";
|
package/src/lib/proxy/fetch.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
setGlobalDispatcher,
|
|
3
|
-
EnvHttpProxyAgent,
|
|
4
|
-
fetch as undiciFetch,
|
|
5
|
-
} from "undici";
|
|
6
|
-
import { bootstrap } from "global-agent";
|
|
7
|
-
|
|
8
|
-
export function setupProxyGlobally() {
|
|
9
|
-
// To cover libraries that use fetch
|
|
10
|
-
// See https://nodejs.org/api/globals.html#custom-dispatcher
|
|
11
|
-
// This might stop being needed at some point: https://github.com/actions/create-github-app-token/pull/143#discussion_r1747641337
|
|
12
|
-
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
13
|
-
setGlobalDispatcher(envHttpProxyAgent);
|
|
14
|
-
|
|
15
|
-
// To cover libraries that use the http/https object
|
|
16
|
-
if (!process.env.GLOBAL_AGENT_HTTP_PROXY) {
|
|
17
|
-
process.env.GLOBAL_AGENT_HTTP_PROXY = process.env.HTTP_PROXY;
|
|
18
|
-
process.env.GLOBAL_AGENT_HTTPS_PROXY =
|
|
19
|
-
process.env.HTTPS_PROXY ?? process.env.HTTP_PROXY;
|
|
20
|
-
}
|
|
21
|
-
bootstrap();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function getProxiedFetch() {
|
|
25
|
-
const fetch: typeof undiciFetch = (input, init = {}) => {
|
|
26
|
-
console.log("Using proxied fetch for request to:", input);
|
|
27
|
-
if (init.dispatcher) {
|
|
28
|
-
console.warn(
|
|
29
|
-
"A custom dispatcher was provided to fetch but this is ignored as a proxy agent is being used.",
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
const envHttpProxyAgent = new EnvHttpProxyAgent();
|
|
33
|
-
return undiciFetch(input, { ...init, dispatcher: envHttpProxyAgent });
|
|
34
|
-
};
|
|
35
|
-
return fetch;
|
|
36
|
-
}
|
package/src/lib/proxy/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./fetch.js";
|