Skip to content
This repository has been archived by the owner on Jan 10, 2024. It is now read-only.

Commit

Permalink
fix: change classes to use named exports instead of default exports
Browse files Browse the repository at this point in the history
using default exports on the classes causes problems when attempting to
use oidc-client as ES modules, since modules with default exports are
being re-exported as named exports in index.js
  • Loading branch information
DanielSchaffer committed Feb 20, 2018
1 parent 2b38397 commit 712986f
Show file tree
Hide file tree
Showing 73 changed files with 1,104 additions and 5,421 deletions.
2,728 changes: 288 additions & 2,440 deletions dist/oidc-client.js

Large diffs are not rendered by default.

68 changes: 31 additions & 37 deletions dist/oidc-client.min.js

Large diffs are not rendered by default.

30 changes: 15 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

export const Log = require('./src/Log');
export const OidcClient = require('./src/OidcClient');
export const OidcClientSettings = require('./src/OidcClientSettings');
export const WebStorageStateStore = require('./src/WebStorageStateStore');
export const InMemoryWebStorage = require('./src/InMemoryWebStorage');
export const UserManager = require('./src/UserManager');
export const AccessTokenEvents = require('./src/AccessTokenEvents');
export const MetadataService = require('./src/MetadataService');
export const CordovaPopupNavigator = require('./src/CordovaPopupNavigator');
export const CordovaIFrameNavigator = require('./src/CordovaIFrameNavigator');
export const CheckSessionIFrame = require('./src/CheckSessionIFrame');
export const TokenRevocationClient = require('./src/TokenRevocationClient');
export const SessionMonitor = require('./src/SessionMonitor');
export const Global = require('./src/Global');
export const User = require('./src/User');
export const Log = require('./src/Log').Log;
export const OidcClient = require('./src/OidcClient').OidcClient;
export const OidcClientSettings = require('./src/OidcClientSettings').OidcClientSettings;
export const WebStorageStateStore = require('./src/WebStorageStateStore').WebStorageStateStore;
export const InMemoryWebStorage = require('./src/InMemoryWebStorage').InMemoryWebStorage;
export const UserManager = require('./src/UserManager').UserManager;
export const AccessTokenEvents = require('./src/AccessTokenEvents').AccessTokenEvents;
export const MetadataService = require('./src/MetadataService').MetadataService;
export const CordovaPopupNavigator = require('./src/CordovaPopupNavigator').CordovaPopupNavigator;
export const CordovaIFrameNavigator = require('./src/CordovaIFrameNavigator').CordovaIFrameNavigator;
export const CheckSessionIFrame = require('./src/CheckSessionIFrame').CheckSessionIFrame;
export const TokenRevocationClient = require('./src/TokenRevocationClient').TokenRevocationClient;
export const SessionMonitor = require('./src/SessionMonitor').SessionMonitor;
export const Global = require('./src/Global').Global;
export const User = require('./src/User').User;

export default {
Log,
Expand Down
2,742 changes: 295 additions & 2,447 deletions lib/oidc-client.js

Large diffs are not rendered by default.

72 changes: 33 additions & 39 deletions lib/oidc-client.min.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.4.2",
"description": "OpenID Connect (OIDC) & OAuth2 client library",
"main": "lib/oidc-client.min.js",
"module": "index.js",
"scripts": {
"build": "gulp build",
"start": "node sample/server.js",
Expand Down
10 changes: 5 additions & 5 deletions src/AccessTokenEvents.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import Timer from './Timer';
import { Log } from './Log';
import { Timer } from './Timer';

const DefaultAccessTokenExpiringNotificationTime = 60; // seconds

export default class AccessTokenEvents {
export class AccessTokenEvents {

constructor({
accessTokenExpiringNotificationTime = DefaultAccessTokenExpiringNotificationTime,
Expand All @@ -21,7 +21,7 @@ export default class AccessTokenEvents {

load(container) {
Log.debug("AccessTokenEvents.load");

this._cancelTimers();

// only register events if there's an access token where we care about expiration
Expand Down Expand Up @@ -50,7 +50,7 @@ export default class AccessTokenEvents {
Log.debug("AccessTokenEvents.unload");
this._cancelTimers();
}

_cancelTimers(){
Log.debug("canceling existing access token timers");
this._accessTokenExpiring.cancel();
Expand Down
4 changes: 2 additions & 2 deletions src/CheckSessionIFrame.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

const DefaultInterval = 2000;

export default class CheckSessionIFrame {
export class CheckSessionIFrame {
constructor(callback, client_id, url, interval) {
this._callback = callback;
this._client_id = client_id;
Expand Down
7 changes: 3 additions & 4 deletions src/CordovaIFrameNavigator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import CordovaPopupWindow from './CordovaPopupWindow';
import { CordovaPopupWindow } from './CordovaPopupWindow';

export class CordovaIFrameNavigator {

export default class CordovaIFrameNavigator {

prepare(params) {
params.popupWindowFeatures = 'hidden=yes';
let popup = new CordovaPopupWindow(params);
Expand Down
7 changes: 3 additions & 4 deletions src/CordovaPopupNavigator.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import CordovaPopupWindow from './CordovaPopupWindow';
import { CordovaPopupWindow } from './CordovaPopupWindow';

export class CordovaPopupNavigator {

export default class CordovaPopupNavigator {

prepare(params) {
let popup = new CordovaPopupWindow(params);
return Promise.resolve(popup);
Expand Down
4 changes: 2 additions & 2 deletions src/CordovaPopupWindow.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

const DefaultPopupFeatures = 'location=no,toolbar=no,zoom=no';
const DefaultPopupTarget = "_blank";

export default class CordovaPopupWindow {
export class CordovaPopupWindow {

constructor(params) {
Log.debug("CordovaPopupWindow.ctor");
Expand Down
14 changes: 7 additions & 7 deletions src/ErrorResponse.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

export default class ErrorResponse extends Error {
export class ErrorResponse extends Error {
constructor({error, error_description, error_uri, state}={}
) {
if (!error){
Log.error("No error passed to ErrorResponse");
throw new Error("error");
}

super(error_description || error);
this.name = "ErrorResponse";

this.name = "ErrorResponse";

this.error = error;
this.error_description = error_description;
this.error_uri = error_uri;

this.state = state;
}
}
4 changes: 2 additions & 2 deletions src/Event.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

export default class Event {
export class Event {

constructor(name) {
this._name = name;
Expand Down
4 changes: 2 additions & 2 deletions src/Global.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const timer = {
let testing = false;
let request = null;

export default class Global {
export class Global {

static _testing() {
testing = true;
Expand Down Expand Up @@ -52,4 +52,4 @@ export default class Global {
return timer;
}
}
};
}
6 changes: 3 additions & 3 deletions src/IFrameNavigator.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import IFrameWindow from './IFrameWindow';
import { Log } from './Log';
import { IFrameWindow } from './IFrameWindow';

export default class IFrameNavigator {
export class IFrameNavigator {

prepare(params) {
let frame = new IFrameWindow(params);
Expand Down
10 changes: 5 additions & 5 deletions src/IFrameWindow.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

const DefaultTimeout = 10000;

export default class IFrameWindow {
export class IFrameWindow {

constructor(params) {
Log.debug("IFrameWindow.ctor");
Expand All @@ -17,7 +17,7 @@ export default class IFrameWindow {

this._boundMessageEvent = this._message.bind(this);
window.addEventListener("message", this._boundMessageEvent, false);

this._frame = window.document.createElement("iframe");

// shotgun approach
Expand All @@ -26,7 +26,7 @@ export default class IFrameWindow {
this._frame.style.display = "none";
this._frame.style.width = 0;
this._frame.style.height = 0;

window.document.body.appendChild(this._frame);
}

Expand All @@ -42,7 +42,7 @@ export default class IFrameWindow {
this._timer = window.setTimeout(this._timeout.bind(this), timeout);
this._frame.src = params.url;
}

return this.promise;
}

Expand Down
18 changes: 9 additions & 9 deletions src/InMemoryWebStorage.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import { Log } from './Log';

export default class InMemoryWebStorage{
export class InMemoryWebStorage{
constructor(){
this._data = {};
}

getItem(key) {
Log.debug("InMemoryWebStorage.getItem", key);
return this._data[key];
}

setItem(key, value){
Log.debug("InMemoryWebStorage.setItem", key);
this._data[key] = value;
}
}

removeItem(key){
Log.debug("InMemoryWebStorage.removeItem", key);
delete this._data[key];
}

get length() {
return Object.getOwnPropertyNames(this._data).length;
}

key(index) {
return Object.getOwnPropertyNames(this._data)[index];
}
}
}
6 changes: 3 additions & 3 deletions src/JoseUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import { jws, KEYUTIL as KeyUtil, X509, crypto, hextob64u } from 'jsrsasign';
import Log from './Log';
import { Log } from './Log';

const AllowedSigningAlgs = ['RS256', 'RS384', 'RS512', 'PS256', 'PS384', 'PS512', 'ES256', 'ES384', 'ES512'];

export default class JoseUtil {
export class JoseUtil {

static parseJwt(jwt) {
Log.debug("JoseUtil.parseJwt");
Expand Down Expand Up @@ -86,7 +86,7 @@ export default class JoseUtil {
Log.error("aud was not provided");
return Promise.reject(new Error("aud was not provided"));
}
var validAudience = payload.aud === audience || (Array.isArray(payload.aud) && payload.aud.indexOf(audience) >= 0);
var validAudience = payload.aud === audience || (Array.isArray(payload.aud) && payload.aud.indexOf(audience) >= 0);
if (!validAudience) {
Log.error("Invalid audience in token", payload.aud);
return Promise.reject(new Error("Invalid audience in token: " + payload.aud));
Expand Down
20 changes: 10 additions & 10 deletions src/JsonService.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,30 @@
// Copyright (c) Brock Allen & Dominick Baier. All rights reserved.
// Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information.

import Log from './Log';
import Global from './Global';
import { Log } from './Log';
import { Global } from './Global';

export default class JsonService {
export class JsonService {
constructor(XMLHttpRequestCtor = Global.XMLHttpRequest) {
this._XMLHttpRequest = XMLHttpRequestCtor;
}

getJson(url, token) {
Log.debug("JsonService.getJson", url);

if (!url){
Log.error("No url passed");
throw new Error("url");
}

return new Promise((resolve, reject) => {

var req = new this._XMLHttpRequest();
req.open('GET', url);

req.onload = function() {
Log.debug("HTTP response received, status", req.status);

if (req.status === 200) {
try {
resolve(JSON.parse(req.responseText));
Expand All @@ -43,7 +43,7 @@ export default class JsonService {
Log.error("network error");
reject(Error("Network Error"));
};

if (token) {
Log.debug("token passed, setting Authorization header");
req.setRequestHeader("Authorization", "Bearer " + token);
Expand All @@ -52,4 +52,4 @@ export default class JsonService {
req.send();
});
}
}
}
4 changes: 2 additions & 2 deletions src/Log.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const DEBUG = 4;
let logger;
let level;

export default class Log {
export class Log {
static get NONE() {return NONE};
static get ERROR() {return ERROR};
static get WARN() {return WARN};
Expand Down Expand Up @@ -80,4 +80,4 @@ export default class Log {
}
}

Log.reset();
Log.reset();
Loading

0 comments on commit 712986f

Please sign in to comment.