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

Commit

Permalink
feat: introduce sub-directories utils and navigators
Browse files Browse the repository at this point in the history
  • Loading branch information
pamapa committed Jul 21, 2021
1 parent 142d883 commit 3e6d591
Show file tree
Hide file tree
Showing 62 changed files with 72 additions and 73 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"jest": {
"clearMocks": true,
"testMatch": [
"**/test/unit/*.test.ts"
"**/test/unit/**/*.test.ts"
]
},
"engines": {
Expand Down
3 changes: 1 addition & 2 deletions src/AccessTokenEvents.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/CheckSessionIFrame.ts
Original file line number Diff line number Diff line change
@@ -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;

Expand Down
2 changes: 1 addition & 1 deletion src/ErrorResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/InMemoryWebStorage.ts
Original file line number Diff line number Diff line change
@@ -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<string, any>;
Expand Down
2 changes: 1 addition & 1 deletion src/JsonService.ts
Original file line number Diff line number Diff line change
@@ -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[];
Expand Down
2 changes: 1 addition & 1 deletion src/MetadataService.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/OidcClient.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/OidcClientSettings.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 1 addition & 2 deletions src/ResponseValidator.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
3 changes: 1 addition & 2 deletions src/SessionMonitor.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/SigninRequest.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/SigninResponse.ts
Original file line number Diff line number Diff line change
@@ -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";

Expand Down
4 changes: 1 addition & 3 deletions src/SigninState.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/SignoutRequest.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/SignoutResponse.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/SilentRenewService.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions src/State.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/TokenClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion src/TokenRevocationClient.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/User.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
3 changes: 1 addition & 2 deletions src/UserInfoService.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
7 changes: 2 additions & 5 deletions src/UserManager.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';

Expand Down
3 changes: 1 addition & 2 deletions src/UserManagerEvents.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
4 changes: 1 addition & 3 deletions src/UserManagerSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/WebStorageStateStore.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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 {
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion src/IFrameWindow.ts → src/navigators/IFrameWindow.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/PopupNavigator.ts → src/navigators/PopupNavigator.ts
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
3 changes: 1 addition & 2 deletions src/PopupWindow.ts → src/navigators/PopupWindow.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
10 changes: 10 additions & 0 deletions src/navigators/index.ts
Original file line number Diff line number Diff line change
@@ -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';
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 6 additions & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export * from './Event';
export * from './JoseUtil';
export * from './Log';
export * from './random';
export * from './Timer';
export * from './UrlUtility';
2 changes: 1 addition & 1 deletion src/random.ts → src/utils/random.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, '');
Expand Down
2 changes: 1 addition & 1 deletion test/unit/AccessTokenEvents.test.ts
Original file line number Diff line number Diff line change
@@ -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", () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/JsonService.test.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down
Loading

0 comments on commit 3e6d591

Please sign in to comment.