Skip to content

Commit 67d6d82

Browse files
add node prefix to crypto imports (#3144)
1 parent 2c8d215 commit 67d6d82

5 files changed

Lines changed: 8 additions & 8 deletions

File tree

src/app/credential-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*/
1717

1818
import fs = require('fs');
19-
import { createPrivateKey } from 'crypto';
19+
import { createPrivateKey } from 'node:crypto';
2020

2121
import { Credentials as GoogleAuthCredentials, GoogleAuth, Compute, AnyAuthClient } from 'google-auth-library'
2222
import { Agent } from 'http';

src/remote-config/condition-evaluator-internal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import {
2727
CustomSignalCondition,
2828
CustomSignalOperator,
2929
} from './remote-config-api';
30-
import { createHash } from 'crypto';
30+
import { createHash } from 'node:crypto';
3131

3232

3333
/**

src/utils/crypto-signer.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ export class ServiceAccountSigner implements CryptoSigner {
7979
* @inheritDoc
8080
*/
8181
public sign(buffer: Buffer): Promise<Buffer> {
82-
const crypto = require('crypto'); // eslint-disable-line @typescript-eslint/no-var-requires
82+
const crypto = require('node:crypto'); // eslint-disable-line @typescript-eslint/no-var-requires
8383
const sign = crypto.createSign('RSA-SHA256');
8484
sign.update(buffer);
8585
return Promise.resolve(sign.sign(this.credential.privateKey));

test/integration/auth.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616

1717
import * as url from 'url';
18-
import * as crypto from 'crypto';
18+
import * as crypto from 'node:crypto';
1919
import * as bcrypt from 'bcrypt';
2020
import * as chai from 'chai';
2121
import * as chaiAsPromised from 'chai-as-promised';

test/unit/utils/crypto-signer.spec.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ describe('CryptoSigner', () => {
5757
const cert = new ServiceAccountCredential(mocks.certificateObject);
5858

5959
// eslint-disable-next-line @typescript-eslint/no-var-requires
60-
const crypto = require('crypto');
60+
const crypto = require('node:crypto');
6161
const rsa = crypto.createSign('RSA-SHA256');
6262
rsa.update(payload);
6363
const result = rsa.sign(cert.privateKey, 'base64');
@@ -104,8 +104,8 @@ describe('CryptoSigner', () => {
104104
const signRequest = {
105105
method: 'POST',
106106
url: 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/foo@project_id.iam.gserviceaccount.com:signBlob',
107-
headers: {
108-
Authorization: `Bearer ${mockAccessToken}`,
107+
headers: {
108+
Authorization: `Bearer ${mockAccessToken}`,
109109
'X-Goog-Api-Client': getMetricsHeader()
110110
},
111111
data: { payload: input.toString('base64') },
@@ -162,7 +162,7 @@ describe('CryptoSigner', () => {
162162
const signRequest = {
163163
method: 'POST',
164164
url: 'https://iamcredentials.googleapis.com/v1/projects/-/serviceAccounts/discovered-service-account:signBlob',
165-
headers: {
165+
headers: {
166166
Authorization: `Bearer ${mockAccessToken}`,
167167
'X-Goog-Api-Client': getMetricsHeader()
168168
},

0 commit comments

Comments
 (0)