Skip to content

Commit

Permalink
build!: remove arrify and fast-text-encoding (#1583)
Browse files Browse the repository at this point in the history
* build!: remove arrify and fast-text-encoding
  • Loading branch information
sofisl committed Jul 7, 2023
1 parent 5b9adef commit d736da3
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 28 deletions.
5 changes: 0 additions & 5 deletions browser-test/test.crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ import {BrowserCrypto} from '../src/crypto/browser/crypto';
import {privateKey, publicKey} from './fixtures/keys';
import {describe, it} from 'mocha';

// Not all browsers support `TextEncoder`. The following `require` will
// provide a fast UTF8-only replacement for those browsers that don't support
// text encoding natively.
require('fast-text-encoding');

describe('Browser crypto tests', () => {
const crypto = createCrypto();

Expand Down
5 changes: 0 additions & 5 deletions browser-test/test.oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ import * as sinon from 'sinon';
import {privateKey, publicKey} from './fixtures/keys';
import {it, describe, beforeEach} from 'mocha';

// Not all browsers support `TextEncoder`. The following `require` will
// provide a fast UTF8-only replacement for those browsers that don't support
// text encoding natively.
require('fast-text-encoding');

import {CodeChallengeMethod, OAuth2Client} from '../src';
import {CertificateFormat} from '../src/auth/oauth2client';
import {JwkCertificate} from '../src/crypto/crypto';
Expand Down
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
"client library"
],
"dependencies": {
"arrify": "^2.0.0",
"base64-js": "^1.3.0",
"ecdsa-sig-formatter": "^1.0.11",
"fast-text-encoding": "^1.0.0",
"gaxios": "^5.0.0",
"gcp-metadata": "^5.3.0",
"gtoken": "^6.1.0",
Expand Down
7 changes: 5 additions & 2 deletions src/auth/computeclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.

import arrify = require('arrify');
import {GaxiosError} from 'gaxios';
import * as gcpMetadata from 'gcp-metadata';

Expand Down Expand Up @@ -49,7 +48,11 @@ export class Compute extends OAuth2Client {
// refreshed before the first API call is made.
this.credentials = {expiry_date: 1, refresh_token: 'compute-placeholder'};
this.serviceAccountEmail = options.serviceAccountEmail || 'default';
this.scopes = arrify(options.scopes);
this.scopes = Array.isArray(options.scopes)
? options.scopes
: options.scopes
? [options.scopes]
: [];
}

/**
Expand Down
8 changes: 0 additions & 8 deletions src/crypto/browser/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@

import * as base64js from 'base64-js';

// Not all browsers support `TextEncoder`. The following `require` will
// provide a fast UTF8-only replacement for those browsers that don't support
// text encoding natively.
// eslint-disable-next-line node/no-unsupported-features/node-builtins
if (typeof process === 'undefined' && typeof TextEncoder === 'undefined') {
require('fast-text-encoding');
}

import {Crypto, JwkCertificate, fromArrayBufferToHex} from '../crypto';

export class BrowserCrypto implements Crypto {
Expand Down
6 changes: 0 additions & 6 deletions test/test.crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,12 +104,6 @@ describe('crypto', () => {
assert.strictEqual(encodedString, base64String);
});

it('should not load fast-text-encoding while running in nodejs', () => {
const loadedModules = Object.keys(require('module')._cache);
const hits = loadedModules.filter(x => x.includes('fast-text-encoding'));
assert.strictEqual(hits.length, 0);
});

it('should calculate SHA256 digest in hex encoding', async () => {
const input = 'I can calculate SHA256';
const expectedHexDigest =
Expand Down

0 comments on commit d736da3

Please sign in to comment.