From 3e6d591e00d0148006ecc93ebc65a4054f336d9e Mon Sep 17 00:00:00 2001 From: pamapa Date: Wed, 21 Jul 2021 10:22:52 +0200 Subject: [PATCH] feat: introduce sub-directories utils and navigators --- package.json | 2 +- src/AccessTokenEvents.ts | 3 +-- src/CheckSessionIFrame.ts | 2 +- src/ErrorResponse.ts | 2 +- src/InMemoryWebStorage.ts | 2 +- src/JsonService.ts | 2 +- src/MetadataService.ts | 2 +- src/OidcClient.ts | 2 +- src/OidcClientSettings.ts | 2 +- src/ResponseValidator.ts | 3 +-- src/SessionMonitor.ts | 3 +-- src/SigninRequest.ts | 3 +-- src/SigninResponse.ts | 2 +- src/SigninState.ts | 4 +--- src/SignoutRequest.ts | 3 +-- src/SignoutResponse.ts | 2 +- src/SilentRenewService.ts | 2 +- src/State.ts | 3 +-- src/TokenClient.ts | 2 +- src/TokenRevocationClient.ts | 2 +- src/User.ts | 2 +- src/UserInfoService.ts | 3 +-- src/UserManager.ts | 7 ++----- src/UserManagerEvents.ts | 3 +-- src/UserManagerSettings.ts | 4 +--- src/WebStorageStateStore.ts | 2 +- src/index.ts | 7 +++---- src/{ => navigators}/CordovaIFrameNavigator.ts | 0 src/{ => navigators}/CordovaPopupNavigator.ts | 0 src/{ => navigators}/CordovaPopupWindow.ts | 2 +- src/{ => navigators}/IFrameNavigator.ts | 2 +- src/{ => navigators}/IFrameWindow.ts | 2 +- src/{ => navigators}/INavigator.ts | 0 src/{ => navigators}/IWindow.ts | 0 src/{ => navigators}/PopupNavigator.ts | 2 +- src/{ => navigators}/PopupWindow.ts | 3 +-- src/{ => navigators}/RedirectNavigator.ts | 2 +- src/navigators/index.ts | 10 ++++++++++ src/{ => utils}/Event.ts | 0 src/{ => utils}/JoseUtil.ts | 0 src/{ => utils}/Log.ts | 0 src/{ => utils}/Timer.ts | 0 src/{ => utils}/UrlUtility.ts | 0 src/utils/index.ts | 6 ++++++ src/{ => utils}/random.ts | 2 +- test/unit/AccessTokenEvents.test.ts | 2 +- test/unit/JsonService.test.ts | 2 +- test/unit/MetadataService.test.ts | 2 +- test/unit/OidcClient.test.ts | 2 +- test/unit/OidcClientSettings.test.ts | 3 ++- test/unit/ResponseValidator.test.ts | 3 +-- test/unit/SigninState.test.ts | 2 +- test/unit/State.test.ts | 2 +- test/unit/StubJsonService.ts | 2 +- test/unit/UserManager.test.ts | 3 ++- test/unit/UserManagerSettings.test.ts | 2 +- test/unit/{ => utils}/Event.test.ts | 2 +- test/unit/{ => utils}/JoseUtil.test.ts | 3 +-- test/unit/{ => utils}/Log.test.ts | 2 +- test/unit/{ => utils}/Timer.test.ts | 2 +- test/unit/{ => utils}/UrlUtility.test.ts | 2 +- test/unit/{ => utils}/random.test.ts | 2 +- 62 files changed, 72 insertions(+), 73 deletions(-) rename src/{ => navigators}/CordovaIFrameNavigator.ts (100%) rename src/{ => navigators}/CordovaPopupNavigator.ts (100%) rename src/{ => navigators}/CordovaPopupWindow.ts (99%) rename src/{ => navigators}/IFrameNavigator.ts (95%) rename src/{ => navigators}/IFrameWindow.ts (99%) rename src/{ => navigators}/INavigator.ts (100%) rename src/{ => navigators}/IWindow.ts (100%) rename src/{ => navigators}/PopupNavigator.ts (95%) rename src/{ => navigators}/PopupWindow.ts (98%) rename src/{ => navigators}/RedirectNavigator.ts (96%) create mode 100644 src/navigators/index.ts rename src/{ => utils}/Event.ts (100%) rename src/{ => utils}/JoseUtil.ts (100%) rename src/{ => utils}/Log.ts (100%) rename src/{ => utils}/Timer.ts (100%) rename src/{ => utils}/UrlUtility.ts (100%) create mode 100644 src/utils/index.ts rename src/{ => utils}/random.ts (94%) rename test/unit/{ => utils}/Event.test.ts (98%) rename test/unit/{ => utils}/JoseUtil.test.ts (99%) rename test/unit/{ => utils}/Log.test.ts (98%) rename test/unit/{ => utils}/Timer.test.ts (99%) rename test/unit/{ => utils}/UrlUtility.test.ts (98%) rename test/unit/{ => utils}/random.test.ts (89%) diff --git a/package.json b/package.json index 23c114711..b8399bc94 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "jest": { "clearMocks": true, "testMatch": [ - "**/test/unit/*.test.ts" + "**/test/unit/**/*.test.ts" ] }, "engines": { diff --git a/src/AccessTokenEvents.ts b/src/AccessTokenEvents.ts index 6b2954ae9..2c110634e 100644 --- a/src/AccessTokenEvents.ts +++ b/src/AccessTokenEvents.ts @@ -1,8 +1,7 @@ // 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, Timer } from './utils'; import { User } from './User'; const DefaultAccessTokenExpiringNotificationTime = 60; // seconds diff --git a/src/CheckSessionIFrame.ts b/src/CheckSessionIFrame.ts index 9329622c9..e5905e82a 100644 --- a/src/CheckSessionIFrame.ts +++ b/src/CheckSessionIFrame.ts @@ -1,7 +1,7 @@ // 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 './utils'; const DefaultInterval = 2000; diff --git a/src/ErrorResponse.ts b/src/ErrorResponse.ts index db1e826c8..0e2050dd1 100644 --- a/src/ErrorResponse.ts +++ b/src/ErrorResponse.ts @@ -1,7 +1,7 @@ // 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 './utils'; export class ErrorResponse extends Error { public readonly name: string; diff --git a/src/InMemoryWebStorage.ts b/src/InMemoryWebStorage.ts index fb2c2a738..2cb73c12a 100644 --- a/src/InMemoryWebStorage.ts +++ b/src/InMemoryWebStorage.ts @@ -1,7 +1,7 @@ // 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 './utils'; export class InMemoryWebStorage implements Storage { private _data: Record; diff --git a/src/JsonService.ts b/src/JsonService.ts index 0c5d13e2c..65164587d 100644 --- a/src/JsonService.ts +++ b/src/JsonService.ts @@ -1,7 +1,7 @@ // 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 './utils'; export class JsonService { private _contentTypes: string[]; diff --git a/src/MetadataService.ts b/src/MetadataService.ts index a807381a4..6d3dd9fb7 100644 --- a/src/MetadataService.ts +++ b/src/MetadataService.ts @@ -1,7 +1,7 @@ // 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 './utils'; import { JsonService } from './JsonService'; import { OidcClientSettingsStore } from './OidcClientSettings'; import { OidcMetadata } from './OidcMetadata'; diff --git a/src/OidcClient.ts b/src/OidcClient.ts index 6bb07eec6..9bd478d61 100644 --- a/src/OidcClient.ts +++ b/src/OidcClient.ts @@ -1,7 +1,7 @@ // 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 './utils'; import { OidcClientSettings, OidcClientSettingsStore } from './OidcClientSettings'; import { ErrorResponse } from './ErrorResponse'; import { SigninRequest } from './SigninRequest'; diff --git a/src/OidcClientSettings.ts b/src/OidcClientSettings.ts index 3ab05029c..dbc4f601e 100644 --- a/src/OidcClientSettings.ts +++ b/src/OidcClientSettings.ts @@ -1,7 +1,7 @@ // 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 './utils'; import { ClockService } from './ClockService'; import { WebStorageStateStore } from './WebStorageStateStore'; import { ResponseValidator } from './ResponseValidator'; diff --git a/src/ResponseValidator.ts b/src/ResponseValidator.ts index ab966cd55..0e029fa8e 100644 --- a/src/ResponseValidator.ts +++ b/src/ResponseValidator.ts @@ -1,12 +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, JoseUtil } from './utils'; import { MetadataService } from './MetadataService'; import { UserInfoService } from './UserInfoService'; import { TokenClient } from './TokenClient'; import { ErrorResponse } from './ErrorResponse'; -import { JoseUtil } from './JoseUtil'; import { OidcClientSettingsStore } from './OidcClientSettings'; import { SigninState } from './SigninState'; import { SigninResponse } from './SigninResponse'; diff --git a/src/SessionMonitor.ts b/src/SessionMonitor.ts index 8c7b746c1..9f064f073 100644 --- a/src/SessionMonitor.ts +++ b/src/SessionMonitor.ts @@ -1,10 +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, g_timer, IntervalTimer } from './utils'; import { CheckSessionIFrame } from './CheckSessionIFrame'; import { UserManager } from './UserManager'; -import { g_timer, IntervalTimer } from './Timer'; export class SessionMonitor { private _userManager: UserManager; diff --git a/src/SigninRequest.ts b/src/SigninRequest.ts index c95cfc240..27427ed29 100644 --- a/src/SigninRequest.ts +++ b/src/SigninRequest.ts @@ -1,8 +1,7 @@ // 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 { UrlUtility } from './UrlUtility'; +import { Log, UrlUtility } from './utils'; import { SigninState } from './SigninState'; export class SigninRequest { diff --git a/src/SigninResponse.ts b/src/SigninResponse.ts index 1510e73e4..c7fccd48c 100644 --- a/src/SigninResponse.ts +++ b/src/SigninResponse.ts @@ -1,7 +1,7 @@ // 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 { UrlUtility } from './UrlUtility'; +import { UrlUtility } from './utils'; const OidcScope = "openid"; diff --git a/src/SigninState.ts b/src/SigninState.ts index e1cb67c2b..812b18b02 100644 --- a/src/SigninState.ts +++ b/src/SigninState.ts @@ -1,10 +1,8 @@ // 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, JoseUtil, random } from './utils'; import { State } from './State'; -import { JoseUtil } from './JoseUtil'; -import random from './random'; export class SigninState extends State { private _nonce: any; diff --git a/src/SignoutRequest.ts b/src/SignoutRequest.ts index 1baa14a88..a82f12f0f 100644 --- a/src/SignoutRequest.ts +++ b/src/SignoutRequest.ts @@ -1,8 +1,7 @@ // 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 { UrlUtility } from './UrlUtility'; +import { Log, UrlUtility } from './utils'; import { State } from './State'; export class SignoutRequest { diff --git a/src/SignoutResponse.ts b/src/SignoutResponse.ts index 385b034f8..e457486f0 100644 --- a/src/SignoutResponse.ts +++ b/src/SignoutResponse.ts @@ -1,7 +1,7 @@ // 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 { UrlUtility } from './UrlUtility'; +import { UrlUtility } from './utils'; export class SignoutResponse { public error?: string; diff --git a/src/SilentRenewService.ts b/src/SilentRenewService.ts index 0373c92d6..e2634f56e 100644 --- a/src/SilentRenewService.ts +++ b/src/SilentRenewService.ts @@ -1,7 +1,7 @@ // 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 './utils'; import { UserManager } from './UserManager'; export class SilentRenewService { diff --git a/src/State.ts b/src/State.ts index 93d0cb5da..39e29d7e7 100644 --- a/src/State.ts +++ b/src/State.ts @@ -1,8 +1,7 @@ // 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 random from './random'; +import { Log, random } from './utils'; import { StateStore } from './StateStore'; export class State { diff --git a/src/TokenClient.ts b/src/TokenClient.ts index 3c13c75a7..b37c0e5f2 100644 --- a/src/TokenClient.ts +++ b/src/TokenClient.ts @@ -3,7 +3,7 @@ import { JsonService } from './JsonService'; import { MetadataService } from './MetadataService'; -import { Log } from './Log'; +import { Log } from './utils'; import { OidcClientSettingsStore } from './OidcClientSettings'; export class TokenClient { diff --git a/src/TokenRevocationClient.ts b/src/TokenRevocationClient.ts index 16193daf4..18ae0d78e 100644 --- a/src/TokenRevocationClient.ts +++ b/src/TokenRevocationClient.ts @@ -1,7 +1,7 @@ // 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 './utils'; import { MetadataService } from './MetadataService'; import { OidcClientSettingsStore } from './OidcClientSettings'; diff --git a/src/User.ts b/src/User.ts index ba2b70de8..3a1355681 100644 --- a/src/User.ts +++ b/src/User.ts @@ -1,7 +1,7 @@ // 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 './utils'; export class User { public id_token: string; diff --git a/src/UserInfoService.ts b/src/UserInfoService.ts index 42b4b511d..a67c49432 100644 --- a/src/UserInfoService.ts +++ b/src/UserInfoService.ts @@ -1,10 +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, JoseUtil } from './utils'; import { JsonService } from './JsonService'; import { MetadataService } from './MetadataService'; -import { Log } from './Log'; -import { JoseUtil } from './JoseUtil'; import { OidcClientSettingsStore } from './OidcClientSettings'; export class UserInfoService { diff --git a/src/UserManager.ts b/src/UserManager.ts index db76978f6..abb37ece5 100644 --- a/src/UserManager.ts +++ b/src/UserManager.ts @@ -1,7 +1,8 @@ // 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, JoseUtil } from './utils'; +import { INavigator, IFrameNavigator, PopupNavigator } from './navigators'; import { OidcClient } from './OidcClient'; import { UserManagerSettings, UserManagerSettingsStore } from './UserManagerSettings'; import { User } from './User'; @@ -11,10 +12,6 @@ import { SessionMonitor } from './SessionMonitor'; import { SigninRequest } from "./SigninRequest"; import { TokenRevocationClient } from './TokenRevocationClient'; import { TokenClient } from './TokenClient'; -import { JoseUtil } from './JoseUtil'; -import { INavigator } from './INavigator'; -import { IFrameNavigator } from './IFrameNavigator'; -import { PopupNavigator } from './PopupNavigator'; import { SessionStatus } from './SessionStatus' import { SignoutResponse } from './SignoutResponse'; diff --git a/src/UserManagerEvents.ts b/src/UserManagerEvents.ts index 7316ffd4d..827c24bb0 100644 --- a/src/UserManagerEvents.ts +++ b/src/UserManagerEvents.ts @@ -1,10 +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, Event } from './utils'; import { AccessTokenEvents } from './AccessTokenEvents'; import { UserManagerSettingsStore } from './UserManagerSettings'; -import { Event } from './Event'; import { User } from './User'; export type UserLoadedCallback = (user: User) => void; diff --git a/src/UserManagerSettings.ts b/src/UserManagerSettings.ts index ef96b3d47..e598330c1 100644 --- a/src/UserManagerSettings.ts +++ b/src/UserManagerSettings.ts @@ -2,9 +2,7 @@ // Licensed under the Apache License, Version 2.0. See LICENSE in the project root for license information. import { OidcClientSettings, OidcClientSettingsStore } from './OidcClientSettings'; -import { RedirectNavigator } from './RedirectNavigator'; -import { PopupNavigator } from './PopupNavigator'; -import { IFrameNavigator } from './IFrameNavigator'; +import { RedirectNavigator, PopupNavigator, IFrameNavigator } from './navigators'; import { WebStorageStateStore } from './WebStorageStateStore'; import { SigninRequest } from './SigninRequest'; diff --git a/src/WebStorageStateStore.ts b/src/WebStorageStateStore.ts index a306024d0..4b9886571 100644 --- a/src/WebStorageStateStore.ts +++ b/src/WebStorageStateStore.ts @@ -1,7 +1,7 @@ // 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 './utils'; export class WebStorageStateStore { private _store: Storage diff --git a/src/index.ts b/src/index.ts index 4af9fc98d..94052fb52 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,7 +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 './utils'; +import { CordovaPopupNavigator, CordovaIFrameNavigator } from './navigators'; + import { OidcClient } from './OidcClient'; import { OidcClientSettings } from './OidcClientSettings'; import { WebStorageStateStore } from './WebStorageStateStore'; @@ -10,14 +12,11 @@ import { UserManager } from './UserManager'; import { UserManagerSettings } from './UserManagerSettings'; import { AccessTokenEvents } from './AccessTokenEvents'; import { MetadataService } from './MetadataService'; -import { CordovaPopupNavigator } from './CordovaPopupNavigator'; -import { CordovaIFrameNavigator } from './CordovaIFrameNavigator'; import { CheckSessionIFrame } from './CheckSessionIFrame'; import { TokenRevocationClient } from './TokenRevocationClient'; import { SessionMonitor } from './SessionMonitor'; import { SessionStatus } from './SessionStatus'; import { User } from './User'; - import { Version } from './Version'; export type { diff --git a/src/CordovaIFrameNavigator.ts b/src/navigators/CordovaIFrameNavigator.ts similarity index 100% rename from src/CordovaIFrameNavigator.ts rename to src/navigators/CordovaIFrameNavigator.ts diff --git a/src/CordovaPopupNavigator.ts b/src/navigators/CordovaPopupNavigator.ts similarity index 100% rename from src/CordovaPopupNavigator.ts rename to src/navigators/CordovaPopupNavigator.ts diff --git a/src/CordovaPopupWindow.ts b/src/navigators/CordovaPopupWindow.ts similarity index 99% rename from src/CordovaPopupWindow.ts rename to src/navigators/CordovaPopupWindow.ts index 74bf3ce18..812c32978 100644 --- a/src/CordovaPopupWindow.ts +++ b/src/navigators/CordovaPopupWindow.ts @@ -1,7 +1,7 @@ // 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 '../utils'; import { IWindow } from './IWindow'; const DefaultPopupFeatures = 'location=no,toolbar=no,zoom=no'; diff --git a/src/IFrameNavigator.ts b/src/navigators/IFrameNavigator.ts similarity index 95% rename from src/IFrameNavigator.ts rename to src/navigators/IFrameNavigator.ts index d26a83d2e..64414cd8d 100644 --- a/src/IFrameNavigator.ts +++ b/src/navigators/IFrameNavigator.ts @@ -1,7 +1,7 @@ // 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 '../utils'; import { IFrameWindow } from './IFrameWindow'; import { INavigator } from './INavigator'; diff --git a/src/IFrameWindow.ts b/src/navigators/IFrameWindow.ts similarity index 99% rename from src/IFrameWindow.ts rename to src/navigators/IFrameWindow.ts index fdd09ab21..ce599dba3 100644 --- a/src/IFrameWindow.ts +++ b/src/navigators/IFrameWindow.ts @@ -1,7 +1,7 @@ // 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 '../utils'; import { IWindow } from './IWindow'; const DefaultTimeout = 10000; diff --git a/src/INavigator.ts b/src/navigators/INavigator.ts similarity index 100% rename from src/INavigator.ts rename to src/navigators/INavigator.ts diff --git a/src/IWindow.ts b/src/navigators/IWindow.ts similarity index 100% rename from src/IWindow.ts rename to src/navigators/IWindow.ts diff --git a/src/PopupNavigator.ts b/src/navigators/PopupNavigator.ts similarity index 95% rename from src/PopupNavigator.ts rename to src/navigators/PopupNavigator.ts index 3681a2388..3be29630e 100644 --- a/src/PopupNavigator.ts +++ b/src/navigators/PopupNavigator.ts @@ -1,7 +1,7 @@ // 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 '../utils'; import { PopupWindow } from './PopupWindow'; import { INavigator } from './INavigator'; diff --git a/src/PopupWindow.ts b/src/navigators/PopupWindow.ts similarity index 98% rename from src/PopupWindow.ts rename to src/navigators/PopupWindow.ts index 4eecc4cd3..636812ab1 100644 --- a/src/PopupWindow.ts +++ b/src/navigators/PopupWindow.ts @@ -1,8 +1,7 @@ // 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 { UrlUtility } from './UrlUtility'; +import { Log, UrlUtility } from '../utils'; import { IWindow } from './IWindow'; const CheckForPopupClosedInterval = 500; diff --git a/src/RedirectNavigator.ts b/src/navigators/RedirectNavigator.ts similarity index 96% rename from src/RedirectNavigator.ts rename to src/navigators/RedirectNavigator.ts index e253cc6da..d82ca277b 100644 --- a/src/RedirectNavigator.ts +++ b/src/navigators/RedirectNavigator.ts @@ -1,7 +1,7 @@ // 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 '../utils'; import { INavigator } from './INavigator'; import { IWindow } from './IWindow'; diff --git a/src/navigators/index.ts b/src/navigators/index.ts new file mode 100644 index 000000000..2401f0adc --- /dev/null +++ b/src/navigators/index.ts @@ -0,0 +1,10 @@ +export * from './CordovaIFrameNavigator'; +export * from './CordovaPopupNavigator'; +export * from './CordovaPopupWindow'; +export * from './IFrameNavigator'; +export * from './IFrameWindow'; +export * from './INavigator'; +export * from './IWindow'; +export * from './PopupNavigator'; +export * from './PopupWindow'; +export * from './RedirectNavigator'; diff --git a/src/Event.ts b/src/utils/Event.ts similarity index 100% rename from src/Event.ts rename to src/utils/Event.ts diff --git a/src/JoseUtil.ts b/src/utils/JoseUtil.ts similarity index 100% rename from src/JoseUtil.ts rename to src/utils/JoseUtil.ts diff --git a/src/Log.ts b/src/utils/Log.ts similarity index 100% rename from src/Log.ts rename to src/utils/Log.ts diff --git a/src/Timer.ts b/src/utils/Timer.ts similarity index 100% rename from src/Timer.ts rename to src/utils/Timer.ts diff --git a/src/UrlUtility.ts b/src/utils/UrlUtility.ts similarity index 100% rename from src/UrlUtility.ts rename to src/utils/UrlUtility.ts diff --git a/src/utils/index.ts b/src/utils/index.ts new file mode 100644 index 000000000..564174ead --- /dev/null +++ b/src/utils/index.ts @@ -0,0 +1,6 @@ +export * from './Event'; +export * from './JoseUtil'; +export * from './Log'; +export * from './random'; +export * from './Timer'; +export * from './UrlUtility'; diff --git a/src/random.ts b/src/utils/random.ts similarity index 94% rename from src/random.ts rename to src/utils/random.ts index db1a0fdf9..294b8cabe 100644 --- a/src/random.ts +++ b/src/utils/random.ts @@ -19,7 +19,7 @@ function _uuidv4() { ) } -export default function random(): string { +export function random(): string { const hasRandomValues = crypto && crypto.hasOwnProperty("getRandomValues"); var uuid = hasRandomValues ? _cryptoUuidv4 : _uuidv4; return uuid().replace(/-/g, ''); diff --git a/test/unit/AccessTokenEvents.test.ts b/test/unit/AccessTokenEvents.test.ts index 34ef378ab..45e1774d1 100644 --- a/test/unit/AccessTokenEvents.test.ts +++ b/test/unit/AccessTokenEvents.test.ts @@ -1,8 +1,8 @@ // 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 { Timer } from '../../src/utils'; import { AccessTokenEvents } from '../../src/AccessTokenEvents'; -import { Timer } from '../../src/Timer'; import { User } from '../../src/User'; describe("AccessTokenEvents", () => { diff --git a/test/unit/JsonService.test.ts b/test/unit/JsonService.test.ts index 54f6b70d7..7fa2bb4fd 100644 --- a/test/unit/JsonService.test.ts +++ b/test/unit/JsonService.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { JsonService } from '../../src/JsonService'; class XMLHttpRequestMock { diff --git a/test/unit/MetadataService.test.ts b/test/unit/MetadataService.test.ts index b85e862cb..8ce096ea4 100644 --- a/test/unit/MetadataService.test.ts +++ b/test/unit/MetadataService.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { MetadataService } from '../../src/MetadataService'; import { StubJsonService } from './StubJsonService'; diff --git a/test/unit/OidcClient.test.ts b/test/unit/OidcClient.test.ts index 9f2d3975e..8b7222180 100644 --- a/test/unit/OidcClient.test.ts +++ b/test/unit/OidcClient.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { OidcClient } from '../../src/OidcClient'; import { OidcClientSettingsStore } from '../../src/OidcClientSettings'; import { SigninState } from '../../src/SigninState'; diff --git a/test/unit/OidcClientSettings.test.ts b/test/unit/OidcClientSettings.test.ts index 8c59295d1..5e1b96e48 100644 --- a/test/unit/OidcClientSettings.test.ts +++ b/test/unit/OidcClientSettings.test.ts @@ -1,11 +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 '../../src/Log'; +import { Log } from '../../src/utils'; import { MetadataService } from '../../src/MetadataService'; import { OidcClientSettingsStore } from '../../src/OidcClientSettings'; import { ResponseValidator } from '../../src/ResponseValidator'; import { StateStore } from '../../src/StateStore'; + import { mocked } from 'ts-jest/utils'; describe("OidcClientSettings", () => { diff --git a/test/unit/ResponseValidator.test.ts b/test/unit/ResponseValidator.test.ts index 3a6ed1958..ab598c637 100644 --- a/test/unit/ResponseValidator.test.ts +++ b/test/unit/ResponseValidator.test.ts @@ -1,9 +1,8 @@ // 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 '../../src/Log'; +import { Log, JoseUtil } from '../../src/utils'; import { ResponseValidator } from '../../src/ResponseValidator'; -import { JoseUtil } from '../../src/JoseUtil'; import { StubMetadataService } from './StubMetadataService'; diff --git a/test/unit/SigninState.test.ts b/test/unit/SigninState.test.ts index 9a70de379..1b9ad95b4 100644 --- a/test/unit/SigninState.test.ts +++ b/test/unit/SigninState.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { SigninState } from '../../src/SigninState'; describe("SigninState", () => { diff --git a/test/unit/State.test.ts b/test/unit/State.test.ts index a4a2b675b..f389b8021 100644 --- a/test/unit/State.test.ts +++ b/test/unit/State.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { State } from '../../src/State'; import { InMemoryWebStorage } from '../../src/InMemoryWebStorage'; diff --git a/test/unit/StubJsonService.ts b/test/unit/StubJsonService.ts index 8eda70dbb..a2e22e4c6 100644 --- a/test/unit/StubJsonService.ts +++ b/test/unit/StubJsonService.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; export class StubJsonService { url: any; diff --git a/test/unit/UserManager.test.ts b/test/unit/UserManager.test.ts index ab84fa1c3..6a00ad61d 100644 --- a/test/unit/UserManager.test.ts +++ b/test/unit/UserManager.test.ts @@ -1,11 +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 '../../src/Log'; +import { Log } from '../../src/utils'; import { UserManager } from '../../src/UserManager'; import { UserManagerSettings, UserManagerSettingsStore } from '../../src/UserManagerSettings'; import { User } from '../../src/User'; import { WebStorageStateStore } from '../../src/WebStorageStateStore'; + import { mocked } from 'ts-jest/utils'; describe("UserManager", () => { diff --git a/test/unit/UserManagerSettings.test.ts b/test/unit/UserManagerSettings.test.ts index bd60703f1..968e2679a 100644 --- a/test/unit/UserManagerSettings.test.ts +++ b/test/unit/UserManagerSettings.test.ts @@ -1,7 +1,7 @@ // 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 '../../src/Log'; +import { Log } from '../../src/utils'; import { UserManagerSettingsStore } from '../../src/UserManagerSettings'; import { WebStorageStateStore } from '../../src/WebStorageStateStore'; diff --git a/test/unit/Event.test.ts b/test/unit/utils/Event.test.ts similarity index 98% rename from test/unit/Event.test.ts rename to test/unit/utils/Event.test.ts index 290b5f88c..80f36a505 100644 --- a/test/unit/Event.test.ts +++ b/test/unit/utils/Event.test.ts @@ -1,7 +1,7 @@ // 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 { Event } from '../../src/Event'; +import { Event } from '../../../src/utils'; describe("Event", () => { diff --git a/test/unit/JoseUtil.test.ts b/test/unit/utils/JoseUtil.test.ts similarity index 99% rename from test/unit/JoseUtil.test.ts rename to test/unit/utils/JoseUtil.test.ts index b6aa34a33..fe4293d9b 100644 --- a/test/unit/JoseUtil.test.ts +++ b/test/unit/utils/JoseUtil.test.ts @@ -1,8 +1,7 @@ // 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 '../../src/Log'; -import { JoseUtil } from '../../src/JoseUtil'; +import { Log, JoseUtil } from '../../../src/utils'; describe("JoseUtil", () => { diff --git a/test/unit/Log.test.ts b/test/unit/utils/Log.test.ts similarity index 98% rename from test/unit/Log.test.ts rename to test/unit/utils/Log.test.ts index 656fa51b9..1136fc18e 100644 --- a/test/unit/Log.test.ts +++ b/test/unit/utils/Log.test.ts @@ -1,7 +1,7 @@ // 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, Logger } from '../../src/Log'; +import { Log, Logger } from '../../../src/utils'; describe("Log", () => { beforeEach(() => { diff --git a/test/unit/Timer.test.ts b/test/unit/utils/Timer.test.ts similarity index 99% rename from test/unit/Timer.test.ts rename to test/unit/utils/Timer.test.ts index 66df79003..64616dfa5 100644 --- a/test/unit/Timer.test.ts +++ b/test/unit/utils/Timer.test.ts @@ -1,7 +1,7 @@ // 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 { IntervalTimer, Timer } from '../../src/Timer'; +import { IntervalTimer, Timer } from '../../../src/utils'; class IntervalTimerMock implements IntervalTimer { callback: ((...args: any[]) => void); diff --git a/test/unit/UrlUtility.test.ts b/test/unit/utils/UrlUtility.test.ts similarity index 98% rename from test/unit/UrlUtility.test.ts rename to test/unit/utils/UrlUtility.test.ts index f9e51ca95..64b165ff0 100644 --- a/test/unit/UrlUtility.test.ts +++ b/test/unit/utils/UrlUtility.test.ts @@ -1,7 +1,7 @@ // 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 { UrlUtility } from '../../src/UrlUtility'; +import { UrlUtility } from '../../../src/utils'; describe("UrlUtility", () => { diff --git a/test/unit/random.test.ts b/test/unit/utils/random.test.ts similarity index 89% rename from test/unit/random.test.ts rename to test/unit/utils/random.test.ts index 2b2a77567..ab769cb2a 100644 --- a/test/unit/random.test.ts +++ b/test/unit/utils/random.test.ts @@ -1,4 +1,4 @@ -import random from '../../src/random' +import { random } from '../../../src/utils' const pattern = /^[0-9a-f]{8}[0-9a-f]{4}4[0-9a-f]{3}[89ab][0-9a-f]{3}[0-9a-f]{12}$/ //const pattern = /^[0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/