Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build!: remove arrify and fast-text-encoding #1583

Merged
merged 3 commits into from
Jul 7, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 5 additions & 1 deletion src/auth/computeclient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,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