Skip to content

Commit 9533976

Browse files
committed
Fix formatting
1 parent 16c7086 commit 9533976

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

src/patterns/ec2-app/base.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import {
4242
import { AppAccess } from "../../types";
4343
import type { GuAsgCapacity, GuDomainName } from "../../types";
4444
import type { AmigoProps } from "../../types/amigo";
45-
import {getUserPoolDomainPrefix} from "../../utils/cognito/cognito";
45+
import { getUserPoolDomainPrefix } from "../../utils/cognito/cognito";
4646

4747
export interface AccessLoggingProps {
4848
/**

src/utils/cognito/cognito.test.ts

+11-12
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,29 @@ describe("getUserPoolDomainPrefix", () => {
55
const shortPrefix = "hello";
66
const domainPrefix = getUserPoolDomainPrefix(shortPrefix);
77

8-
expect(domainPrefix.length).toEqual(32+shortPrefix.length+1)
8+
expect(domainPrefix.length).toEqual(32 + shortPrefix.length + 1);
99
});
1010

1111
it("should include the full prefix where there is space for a 5 character hash", () => {
12-
const prefix55 = new Array(55 + 1).join( "#" );
12+
const prefix55 = new Array(55 + 1).join("#");
1313
const domainPrefix = getUserPoolDomainPrefix(prefix55);
1414

15-
expect(domainPrefix.includes(prefix55)).toEqual(true)
16-
expect(domainPrefix.length).toEqual(63)
15+
expect(domainPrefix.includes(prefix55)).toEqual(true);
16+
expect(domainPrefix.length).toEqual(63);
1717
});
1818

1919
it("should not include the full prefix where there is not space for a 5 character hash", () => {
20-
const prefix56 = new Array(58 + 1).join( "#" );
20+
const prefix56 = new Array(58 + 1).join("#");
2121
const domainPrefix = getUserPoolDomainPrefix(prefix56);
2222

23-
expect(domainPrefix.includes(prefix56)).toEqual(false)
24-
expect(domainPrefix.length).toEqual(63)
25-
})
23+
expect(domainPrefix.includes(prefix56)).toEqual(false);
24+
expect(domainPrefix.length).toEqual(63);
25+
});
2626

2727
it("should be 63 characters long even with a very long prefix", () => {
28-
const prefix = new Array(63 + 1).join( "#" );
28+
const prefix = new Array(63 + 1).join("#");
2929
const domainPrefix = getUserPoolDomainPrefix(prefix);
3030

31-
expect(domainPrefix.length).toEqual(63)
32-
})
33-
31+
expect(domainPrefix.length).toEqual(63);
32+
});
3433
});

src/utils/cognito/cognito.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ import crypto from "crypto";
33
export const getUserPoolDomainPrefix = (prefix: string): string => {
44
// the user pool domain prefix has a max length of 63 characters. We want them to be unique so we add a hash to the end
55
// here we hope that a 5 character hash is unique enough to avoid collisions
6-
const maxLength = 63
7-
const prefixLengthWithHashSpace = maxLength - 6 // 6 = 5 char hash, 1 hyphen
6+
const maxLength = 63;
7+
const prefixLengthWithHashSpace = maxLength - 6; // 6 = 5 char hash, 1 hyphen
88
const suffix = crypto.createHash("md5").update(prefix).digest("hex");
99

1010
// make space in prefix for hash
1111
const prefixTrimmed = prefix.slice(0, prefixLengthWithHashSpace);
1212

1313
return `${prefixTrimmed}-${suffix}`.slice(0, maxLength);
14-
}
14+
};

0 commit comments

Comments
 (0)