Skip to content

Commit b402da9

Browse files
authored
chore: remove dependency on node built-in (#3058)
The health checks are now failing with ``` error TS2307: Cannot find module 'node:crypto' or its corresponding type declarations. ``` What the test does is `cdk init` a project, then remove the `node_modules` directory in order to source the node modules from elsewhere. Rather than try to figure out where the package is installed and what changed where in order to get the right definition of `@types/node` anywhere, I figured it would be easier to just cut the single dependency on the node built-in, and make the test sliiiightly more robust against what types are installed. _By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license._
1 parent 6469019 commit b402da9

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

.changeset/ripe-clocks-stop.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
---

packages/integration-tests/src/test-cdk-projects/auth-cdk/test-cdk-project-auth-cdk-stack.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1+
/* eslint-disable no-restricted-syntax */
12
import * as cdk from 'aws-cdk-lib';
23
import { Construct } from 'constructs';
34
import { AmplifyAuth, AuthProps } from '@aws-amplify/auth-construct';
4-
import { randomBytes } from 'node:crypto';
55

66
export class TestCdkProjectAuthCdkStack extends cdk.Stack {
77
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
@@ -20,7 +20,7 @@ export class TestCdkProjectAuthCdkStack extends cdk.Stack {
2020
clientId: '123',
2121
clientSecret: '123',
2222
},
23-
domainPrefix: randomBytes(10).toString('hex'),
23+
domainPrefix: randomHex(20),
2424
logoutUrls: ['https://logout.com'],
2525
callbackUrls: ['https://redirect.com'],
2626
},
@@ -32,3 +32,12 @@ export class TestCdkProjectAuthCdkStack extends cdk.Stack {
3232
new AmplifyAuth(this, 'test-auth', authProps);
3333
}
3434
}
35+
36+
function randomHex(n: number) {
37+
const hex = '0123456789abcdef';
38+
const ret: string[] = [];
39+
for (let i = 0; i < n; i++) {
40+
ret.push(hex[Math.floor(Math.random() * hex.length)]);
41+
}
42+
return ret.join('');
43+
}

0 commit comments

Comments
 (0)