Skip to content

Commit

Permalink
chore: Fix lint issues (#1826)
Browse files Browse the repository at this point in the history
* chore: Fix lint issues

* chore: fix copyright
  • Loading branch information
danielbankhead committed Jun 12, 2024
1 parent 0d0bc2a commit ca8c1f0
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 16 deletions.
3 changes: 0 additions & 3 deletions browser-test/test.oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,10 +160,8 @@ describe('Browser OAuth2 tests', () => {
'}';
const envelope = JSON.stringify({kid: 'keyid', alg: 'RS256'});
let data =
// eslint-disable-next-line node/no-unsupported-features/node-builtins
base64js.fromByteArray(new TextEncoder().encode(envelope)) +
'.' +
// eslint-disable-next-line node/no-unsupported-features/node-builtins
base64js.fromByteArray(new TextEncoder().encode(idToken));
const algo = {
name: 'RSASSA-PKCS1-v1_5',
Expand All @@ -181,7 +179,6 @@ describe('Browser OAuth2 tests', () => {
const signature = await window.crypto.subtle.sign(
algo,
cryptoKey,
// eslint-disable-next-line node/no-unsupported-features/node-builtins
new TextEncoder().encode(data)
);
data += '.' + base64js.fromByteArray(new Uint8Array(signature));
Expand Down
6 changes: 5 additions & 1 deletion samples/oauth2-codeVerifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google Developer Console.
const keys = require('./oauth2.keys.json');
/**
* @example
* require('./oauth2.keys.json');
*/
const keys = {};

/**
* Start by acquiring a pre-authenticated oAuth2 client.
Expand Down
6 changes: 5 additions & 1 deletion samples/oauth2.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google
const keys = require('./oauth2.keys.json');
/**
* @example
* require('./oauth2.keys.json');
*/
const keys = {};

/**
* Start by acquiring a pre-authenticated oAuth2 client.
Expand Down
13 changes: 10 additions & 3 deletions samples/puppeteer/oauth2-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2018, Google, LLC
// Copyright 2018 Google LLC
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
Expand All @@ -22,7 +22,11 @@ const puppeteer = require('puppeteer');
const url = require('url');
const http = require('http');

const keys = require('../oauth2.keys.json');
/**
* @example
* require('../oauth2.keys.json');
*/
const keys = {};

/**
* Keep a config.keys.json with a username and password
Expand All @@ -31,8 +35,11 @@ const keys = require('../oauth2.keys.json');
* "username": "your-user-name@gmail.com",
* "password": "your-password"
* }
*
* @example
* require('../config.keys.json');
*/
const config = require('../config.keys.json');
const config = {};

async function main() {
const oAuth2Client = await getAuthenticatedClient();
Expand Down
6 changes: 5 additions & 1 deletion samples/verifyIdToken.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@ const open = require('open');
const destroyer = require('server-destroy');

// Download your OAuth2 configuration from the Google
const keys = require('./oauth2.keys.json');
/**
* @example
* require('./oauth2.keys.json');
*/
const keys = {};

/**
* Start by acquiring a pre-authenticated oAuth2 client.
Expand Down
9 changes: 2 additions & 7 deletions src/crypto/browser/crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export class BrowserCrypto implements Crypto {

// To calculate SHA256 digest using SubtleCrypto, we first
// need to convert an input string to an ArrayBuffer:
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const inputBuffer = new TextEncoder().encode(str);

// Result is ArrayBuffer as well.
Expand Down Expand Up @@ -74,7 +73,7 @@ export class BrowserCrypto implements Crypto {
name: 'RSASSA-PKCS1-v1_5',
hash: {name: 'SHA-256'},
};
// eslint-disable-next-line node/no-unsupported-features/node-builtins

const dataArray = new TextEncoder().encode(data);
const signatureArray = base64js.toByteArray(
BrowserCrypto.padBase64(signature)
Expand Down Expand Up @@ -103,7 +102,7 @@ export class BrowserCrypto implements Crypto {
name: 'RSASSA-PKCS1-v1_5',
hash: {name: 'SHA-256'},
};
// eslint-disable-next-line node/no-unsupported-features/node-builtins

const dataArray = new TextEncoder().encode(data);
const cryptoKey = await window.crypto.subtle.importKey(
'jwk',
Expand All @@ -121,13 +120,11 @@ export class BrowserCrypto implements Crypto {

decodeBase64StringUtf8(base64: string): string {
const uint8array = base64js.toByteArray(BrowserCrypto.padBase64(base64));
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const result = new TextDecoder().decode(uint8array);
return result;
}

encodeBase64StringUtf8(text: string): string {
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const uint8array = new TextEncoder().encode(text);
const result = base64js.fromByteArray(uint8array);
return result;
Expand All @@ -145,7 +142,6 @@ export class BrowserCrypto implements Crypto {

// To calculate SHA256 digest using SubtleCrypto, we first
// need to convert an input string to an ArrayBuffer:
// eslint-disable-next-line node/no-unsupported-features/node-builtins
const inputBuffer = new TextEncoder().encode(str);

// Result is ArrayBuffer as well.
Expand Down Expand Up @@ -175,7 +171,6 @@ export class BrowserCrypto implements Crypto {
? key
: String.fromCharCode(...new Uint16Array(key));

// eslint-disable-next-line node/no-unsupported-features/node-builtins
const enc = new TextEncoder();
const cryptoKey = await window.crypto.subtle.importKey(
'raw',
Expand Down

0 comments on commit ca8c1f0

Please sign in to comment.