Skip to content

Commit b1dcca9

Browse files
author
Vieltojarvi
committed
crpyto polyfill in e2e test seed script
1 parent c05e494 commit b1dcca9

File tree

3 files changed

+13
-2
lines changed

3 files changed

+13
-2
lines changed

package-lock.json

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/cli/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@
4545
"@aws-amplify/schema-generator": "^1.2.7",
4646
"@aws-sdk/client-amplify": "^3.624.0",
4747
"@aws-sdk/client-cloudformation": "^3.624.0",
48-
"@aws-sdk/client-cognito-identity-provider": "^3.624.0",
4948
"@aws-sdk/client-s3": "^3.624.0",
5049
"@aws-sdk/client-sts": "^3.624.0",
5150
"@aws-sdk/credential-provider-ini": "^3.624.0",

packages/integration-tests/src/test-projects/seed-test-project/amplify/seed/seed.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,19 @@ import { Amplify } from 'aws-amplify';
55
// @ts-ignore typescript does not like this import
66
import outputs from '../../amplify_outputs.json';
77
import { generateClient } from 'aws-amplify/api';
8+
import { SemVer } from 'semver';
9+
import crypto from 'node:crypto';
10+
11+
// TODO: this is a work around - in theory this should be fixed
12+
// it seems like as of amplify v6 , some of the code only runs in the browser ...
13+
// see https://github.com/aws-amplify/amplify-js/issues/12751
14+
if (process.versions.node) {
15+
// node >= 20 now exposes crypto by default. This workaround is not needed: https://github.com/nodejs/node/pull/42083
16+
if (new SemVer(process.versions.node).major < 20) {
17+
// @ts-expect-error altering typing for global to make compiler happy is not worth the effort assuming this is temporary workaround
18+
globalThis.crypto = crypto;
19+
}
20+
}
821

922
Amplify.configure(outputs);
1023

0 commit comments

Comments
 (0)