Skip to content

Commit

Permalink
Maybe improve bundling
Browse files Browse the repository at this point in the history
  • Loading branch information
awlayton committed Apr 16, 2022
1 parent c7649bc commit 4a35040
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 148 deletions.
4 changes: 1 addition & 3 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@

/* eslint-disable unicorn/prevent-abbreviations, import/no-commonjs, unicorn/prefer-module */

require('ts-node/register');

const puppeteer = require('puppeteer');

process.env.CHROME_BIN = puppeteer.executablePath();

const Rewire = require('rewire-webpack-plugin');
const { mode, entry, output, ...webpack } = require('./webpack.config.ts');
const { mode, entry, output, ...webpack } = require('./webpack.config');

webpack.plugins = [new Rewire()].concat(webpack.plugins ?? []);
module.exports = function (config) {
Expand Down
27 changes: 11 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
{
"name": "@oada/id-client",
"version": "2.0.5",
"version": "2.0.6",
"description": "OADA identity client library for Node.JS and Browser",
"main": "index.js",
"browser": {
".": "dist/browser.js",
"./dist/node-browser.js": false
"./dist/node.js": false,
"buffer": "buffer/",
"crypto": "crypto-browserify",
"events": "events/",
"stream": "stream-browserify",
"string_decoder": "string_decoder/",
"url": "url/",
"util": "util/"
},
"engines": {
"node": ">=12.0.0"
Expand All @@ -26,16 +32,6 @@
"dev": "cpx --watch --verbose './' '../oada-cache/node_modules/oada-id-client'",
"clean": "rm -rf ./coverage"
},
"babel": {
"presets": [
[
"@babel/env",
{
"useBuiltIns": "entry"
}
]
]
},
"browserslist": "> 0.25%, not dead",
"c8": {
"reporter": [
Expand Down Expand Up @@ -77,6 +73,7 @@
"homepage": "https://github.com/OADA/oada-id-client-js",
"dependencies": {
"@oada/certs": "^4.1.1",
"eventemitter2": "^6.4.5",
"is-wsl": "^2.2.0",
"jsonwebtoken": "^8.5.1",
"jwt-bearer-client-auth": "^2.0.1",
Expand All @@ -93,6 +90,7 @@
"@types/body-parser": "^1.19.2",
"@types/chai": "^4.3.1",
"@types/cors": "^2.8.12",
"@types/events": "^3",
"@types/express": "^4.17.13",
"@types/express-serve-static-core": "^4.17.28",
"@types/jsonwebtoken": "^8.5.8",
Expand All @@ -108,7 +106,6 @@
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
"@yarnpkg/sdks": "3.0.0-rc.2",
"assert": "^2.0.0",
"body-parser": "^1.20.0",
"brfs": "^2.0.2",
"browserify": "^17.0.0",
Expand Down Expand Up @@ -157,8 +154,6 @@
"karma-vivaldi-launcher": "^0.0.1",
"karma-webpack": "^5.0.0",
"mocha": "^9.2.2",
"os-browserify": "^0.3.0",
"path-browserify": "^1.0.1",
"prettier": "^2.6.2",
"process": "^0.11.10",
"puppeteer": "^13.5.2",
Expand Down
8 changes: 4 additions & 4 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* limitations under the License.
*/

import EventEmitter, { once } from 'events';
import { EventEmitter2 } from 'eventemitter2';

import { RSA_JWK, jwk2pem } from 'pem-jwk';
import request from 'superagent';
Expand Down Expand Up @@ -123,7 +123,7 @@ export const state = {
retrieveState,
};

const emitter = new EventEmitter();
const emitter = new EventEmitter2();

function isArray(value: unknown): value is unknown[] | readonly unknown[] {
return Array.isArray(value);
Expand Down Expand Up @@ -181,12 +181,12 @@ async function authorize(
// Do not send client_secret here
.removeQuery('client_secret');

const response = once(emitter, stateTok) as Promise<[QueryParameters]>;
const response = EventEmitter2.once(emitter, stateTok);
// Redirect the user to constructed uri
// eslint-disable-next-line @typescript-eslint/no-base-to-string
await redirectCB(uri.toString());

const [tok] = await response;
const [tok] = (await response) as [QueryParameters];
return tok;
}

Expand Down
89 changes: 0 additions & 89 deletions webpack.config.ts

This file was deleted.

56 changes: 20 additions & 36 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,7 @@ __metadata:
"@types/body-parser": ^1.19.2
"@types/chai": ^4.3.1
"@types/cors": ^2.8.12
"@types/events": ^3
"@types/express": ^4.17.13
"@types/express-serve-static-core": ^4.17.28
"@types/jsonwebtoken": ^8.5.8
Expand All @@ -499,7 +500,6 @@ __metadata:
"@typescript-eslint/eslint-plugin": ^5.19.0
"@typescript-eslint/parser": ^5.19.0
"@yarnpkg/sdks": 3.0.0-rc.2
assert: ^2.0.0
body-parser: ^1.20.0
brfs: ^2.0.2
browserify: ^17.0.0
Expand Down Expand Up @@ -536,6 +536,7 @@ __metadata:
eslint-plugin-security: ^1.4.0
eslint-plugin-sonarjs: ^0.13.0
eslint-plugin-unicorn: ^42.0.0
eventemitter2: ^6.4.5
events: ^3.3.0
express: ^4.17.3
is-wsl: ^2.2.0
Expand All @@ -553,8 +554,6 @@ __metadata:
mocha: ^9.2.2
oauth-dyn-reg: ^2.1.1
open: ^8.4.0
os-browserify: ^0.3.0
path-browserify: ^1.0.1
pem-jwk: ^2.0.0
prettier: ^2.6.2
process: ^0.11.10
Expand Down Expand Up @@ -783,6 +782,13 @@ __metadata:
languageName: node
linkType: hard

"@types/events@npm:^3":
version: 3.0.0
resolution: "@types/events@npm:3.0.0"
checksum: 9a424c2da210957d5636e0763e8c9fc3aaeee35bf411284ddec62a56a6abe31de9c7c2e713dabdd8a76ff98b47db2bd52f61310be6609641d6234cc842ecbbe3
languageName: node
linkType: hard

"@types/express-serve-static-core@npm:^4.17.18, @types/express-serve-static-core@npm:^4.17.28":
version: 4.17.28
resolution: "@types/express-serve-static-core@npm:4.17.28"
Expand Down Expand Up @@ -1775,18 +1781,6 @@ __metadata:
languageName: node
linkType: hard

"assert@npm:^2.0.0":
version: 2.0.0
resolution: "assert@npm:2.0.0"
dependencies:
es6-object-assign: ^1.1.0
is-nan: ^1.2.1
object-is: ^1.0.1
util: ^0.12.0
checksum: bb91f181a86d10588ee16c5e09c280f9811373974c29974cbe401987ea34e966699d7989a812b0e19377b511ea0bc627f5905647ce569311824848ede382cae8
languageName: node
linkType: hard

"assertion-error@npm:^1.1.0":
version: 1.1.0
resolution: "assertion-error@npm:1.1.0"
Expand Down Expand Up @@ -3496,13 +3490,6 @@ __metadata:
languageName: node
linkType: hard

"es6-object-assign@npm:^1.1.0":
version: 1.1.0
resolution: "es6-object-assign@npm:1.1.0"
checksum: 8d4fdf63484d78b5c64cacc2c2e1165bc7b6a64b739d2a9db6a4dc8641d99cc9efb433cdd4dc3d3d6b00bfa6ce959694e4665e3255190339945c5f33b692b5d8
languageName: node
linkType: hard

"es6-promise@npm:^4.2.8":
version: 4.2.8
resolution: "es6-promise@npm:4.2.8"
Expand Down Expand Up @@ -4211,6 +4198,13 @@ __metadata:
languageName: node
linkType: hard

"eventemitter2@npm:^6.4.5":
version: 6.4.5
resolution: "eventemitter2@npm:6.4.5"
checksum: 84504f9cf0cc30205cdd46783fe9df3733435e5097f13070b678023110b5ef07847651808ae280cd94c42cd5976880211c7a40321a8ff8fa56f7c5f9c5c11960
languageName: node
linkType: hard

"eventemitter3@npm:^4.0.0":
version: 4.0.7
resolution: "eventemitter3@npm:4.0.7"
Expand Down Expand Up @@ -5370,16 +5364,6 @@ __metadata:
languageName: node
linkType: hard

"is-nan@npm:^1.2.1":
version: 1.3.2
resolution: "is-nan@npm:1.3.2"
dependencies:
call-bind: ^1.0.0
define-properties: ^1.1.3
checksum: 5dfadcef6ad12d3029d43643d9800adbba21cf3ce2ec849f734b0e14ee8da4070d82b15fdb35138716d02587c6578225b9a22779cab34888a139cc43e4e3610a
languageName: node
linkType: hard

"is-negative-zero@npm:^2.0.2":
version: 2.0.2
resolution: "is-negative-zero@npm:2.0.2"
Expand Down Expand Up @@ -6889,7 +6873,7 @@ __metadata:
languageName: node
linkType: hard

"object-is@npm:^1.0.1, object-is@npm:^1.1.4":
"object-is@npm:^1.1.4":
version: 1.1.5
resolution: "object-is@npm:1.1.5"
dependencies:
Expand Down Expand Up @@ -7004,7 +6988,7 @@ __metadata:
languageName: node
linkType: hard

"os-browserify@npm:^0.3.0, os-browserify@npm:~0.3.0":
"os-browserify@npm:~0.3.0":
version: 0.3.0
resolution: "os-browserify@npm:0.3.0"
checksum: 16e37ba3c0e6a4c63443c7b55799ce4066d59104143cb637ecb9fce586d5da319cdca786ba1c867abbe3890d2cbf37953f2d51eea85e20dd6c4570d6c54bfebf
Expand Down Expand Up @@ -7166,7 +7150,7 @@ __metadata:
languageName: node
linkType: hard

"path-browserify@npm:^1.0.0, path-browserify@npm:^1.0.1":
"path-browserify@npm:^1.0.0":
version: 1.0.1
resolution: "path-browserify@npm:1.0.1"
checksum: c6d7fa376423fe35b95b2d67990060c3ee304fc815ff0a2dc1c6c3cfaff2bd0d572ee67e18f19d0ea3bbe32e8add2a05021132ac40509416459fffee35200699
Expand Down Expand Up @@ -9208,7 +9192,7 @@ __metadata:
languageName: node
linkType: hard

"util@npm:^0.12.0, util@npm:^0.12.4, util@npm:~0.12.0":
"util@npm:^0.12.4, util@npm:~0.12.0":
version: 0.12.4
resolution: "util@npm:0.12.4"
dependencies:
Expand Down

0 comments on commit 4a35040

Please sign in to comment.