Skip to content

Commit 7e01b57

Browse files
committed
pnpm format && pnpm lint:fix
1 parent 08aea9b commit 7e01b57

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

packages/utils/src/access-key.ts

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,30 @@
11
export const extractProjectIdFromAccessKey = (accessKey: string): number => {
2-
// Convert URL-safe base64 string to standard base64 string
3-
const base64String = accessKey.replace(/-/g, '+').replace(/_/g, '/');
4-
// Decode the base64 string to a binary string
5-
const binaryString = atob(base64String);
2+
// Convert URL-safe base64 string to standard base64 string
3+
const base64String = accessKey.replace(/-/g, '+').replace(/_/g, '/')
4+
// Decode the base64 string to a binary string
5+
const binaryString = atob(base64String)
66

7-
// Convert the binary string to a byte array (Uint8Array)
8-
const byteArray = new Uint8Array(binaryString.length);
9-
for (let i = 0; i < binaryString.length; i++) {
10-
byteArray[i] = binaryString.charCodeAt(i);
11-
}
7+
// Convert the binary string to a byte array (Uint8Array)
8+
const byteArray = new Uint8Array(binaryString.length)
9+
for (let i = 0; i < binaryString.length; i++) {
10+
byteArray[i] = binaryString.charCodeAt(i)
11+
}
1212

13-
if (byteArray[0] !== 1) {
14-
throw new Error('UnsupportedVersion');
15-
}
13+
if (byteArray[0] !== 1) {
14+
throw new Error('UnsupportedVersion')
15+
}
1616

17-
// Extract the project ID from bytes 2 to 9 (8 bytes)
18-
const projectIdBytes = byteArray.slice(1, 9);
19-
const projectId = projectIdBytes[7] | projectIdBytes[6]<<8 | projectIdBytes[5]<<16 | projectIdBytes[4]<<24 |
20-
projectIdBytes[3]<<32 | projectIdBytes[2]<<40 | projectIdBytes[1]<<48 | projectIdBytes[0]<<56;
17+
// Extract the project ID from bytes 2 to 9 (8 bytes)
18+
const projectIdBytes = byteArray.slice(1, 9)
19+
const projectId =
20+
projectIdBytes[7] |
21+
(projectIdBytes[6] << 8) |
22+
(projectIdBytes[5] << 16) |
23+
(projectIdBytes[4] << 24) |
24+
(projectIdBytes[3] << 32) |
25+
(projectIdBytes[2] << 40) |
26+
(projectIdBytes[1] << 48) |
27+
(projectIdBytes[0] << 56)
2128

22-
return projectId;
29+
return projectId
2330
}

0 commit comments

Comments
 (0)