Skip to content

Commit

Permalink
Update to angular 8 (#24)
Browse files Browse the repository at this point in the history
* Update to ng8 and ngrx8
- Serialize identity and error payloads
- Implement action and effect creators
- Make config optional
- update packages
  • Loading branch information
David Turner authored Feb 4, 2020
1 parent be19a36 commit f0cc3db
Show file tree
Hide file tree
Showing 23 changed files with 2,325 additions and 2,011 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [2.0.0] - 2020-02-04
### Breaking Changes
- Updated to Angular/NgRx 8
### Added
- Update packages
- Add configuration options
- Expose oidc client service
- Implement action and effect creators
### Fixed
- Serialize identity
- Added additional request params

## [1.0.7] - 2019-10-27
### Fixed
- Revert to angular 7
Expand Down Expand Up @@ -44,6 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- First release

[2.0.0]: https://github.com/fileless/ng-oidc-client/compare/v1.0.7...v2.0.0
[1.0.7]: https://github.com/fileless/ng-oidc-client/compare/v1.0.6...v1.0.7
[1.0.6]: https://github.com/fileless/ng-oidc-client/compare/v1.0.5...v1.0.6
[1.0.5]: https://github.com/fileless/ng-oidc-client/compare/v1.0.4...v1.0.5
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
[![npm](https://img.shields.io/npm/dm/ng-oidc-client.svg)](https://www.npmjs.com/ng-oidc-client)
[![Maintenance](https://img.shields.io/maintenance/yes/2018.svg)](https://www.npmjs.com/ng-oidc-client)

An Angular 6+ package wrapping [oidc-client-js][1] to manage authentication with OIDC and OAuth2 in a reactive way using [NgRx][2].
An Angular package wrapping [oidc-client-js][1] to manage authentication with OIDC and OAuth2 in a reactive way using [NgRx][2].

<img src="https://github.com/Fileless/ng-oidc-client/blob/master/images/oidc-state-devtools-animated.gif" alt="OIDC State in Redux DevTools">
<img src="https://github.com/sourcenetwork/ng-oidc-client/blob/master/images/oidc-state-devtools-animated.gif" alt="OIDC State in Redux DevTools">

## Getting started 🚀
The configuration for the examples are based on running IdentityServer4 on localhost. A ready-to-go reference implementation for testing purposes can be found at [ng-oidc-client-server][4].
Expand Down Expand Up @@ -315,6 +315,6 @@ This software is [licensed][6] under the MIT
[1]: https://github.com/IdentityModel/oidc-client-js
[2]: https://github.com/ngrx/platform
[3]: https://github.com/IdentityModel/oidc-client-js/wiki#configuration
[4]: https://github.com/Fileless/ng-oidc-client-server
[5]: https://github.com/Fileless/ng-oidc-client/wiki
[6]: https://github.com/Fileless/ng-oidc-client/blob/master/LICENSE
[4]: https://github.com/sourcenetwork/ng-oidc-client-server
[5]: https://github.com/sourcenetwork/ng-oidc-client/wiki
[6]: https://github.com/sourcenetwork/ng-oidc-client/blob/master/LICENSE
71 changes: 35 additions & 36 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,50 +18,49 @@
},
"private": true,
"dependencies": {
"@angular/animations": "~7.2.0",
"@angular/cdk": "^7.2.0",
"@angular/common": "~7.2.0",
"@angular/compiler": "~7.2.0",
"@angular/core": "~7.2.0",
"@angular/forms": "~7.2.0",
"@angular/material": "^7.2.0",
"@angular/platform-browser": "~7.2.0",
"@angular/platform-browser-dynamic": "~7.2.0",
"@angular/router": "~7.2.0",
"@ngrx/effects": "^7.0.0",
"@ngrx/router-store": "^7.0.0",
"@ngrx/store": "^7.0.0",
"@ngrx/store-devtools": "^7.0.0",
"core-js": "^2.6.1",
"oidc-client": "^1.9.0",
"rxjs": "^6.5.2",
"tslib": "^1.9.0",
"@angular/animations": "~8.2.14",
"@angular/cdk": "^8.2.3",
"@angular/common": "~8.2.14",
"@angular/compiler": "~8.2.14",
"@angular/core": "~8.2.14",
"@angular/forms": "~8.2.14",
"@angular/material": "^8.2.3",
"@angular/platform-browser": "~8.2.14",
"@angular/platform-browser-dynamic": "~8.2.14",
"@angular/router": "~8.2.14",
"@ngrx/effects": "^8.5.2",
"@ngrx/router-store": "^8.5.2",
"@ngrx/store": "^8.5.2",
"@ngrx/store-devtools": "^8.5.2",
"ng-oidc-client": "^1.0.7",
"oidc-client": "^1.9.1",
"rxjs": "^6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.13.0",
"@angular-devkit/build-ng-packagr": "~0.13.0",
"@angular/cli": "~7.3.9",
"@angular/compiler-cli": "~7.2.0",
"@angular/language-service": "~7.2.0",
"@types/jasmine": "~2.8.8",
"@angular-devkit/build-angular": "~0.803.19",
"@angular-devkit/build-ng-packagr": "~0.803.19",
"@angular/cli": "~8.3.19",
"@angular/compiler-cli": "~8.2.14",
"@angular/language-service": "~8.2.14",
"@types/jasmine": "~3.3.8",
"@types/jasminewd2": "~2.0.3",
"@types/node": "~8.9.4",
"codelyzer": "~4.5.0",
"copyfiles": "^2.1.0",
"jasmine-core": "~3.3.0",
"codelyzer": "^5.0.0",
"copyfiles": "^2.1.1",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.0.0",
"karma": "~4.1.0",
"karma-chrome-launcher": "~2.2.0",
"karma-coverage-istanbul-reporter": "~2.0.4",
"karma-coverage-istanbul-reporter": "~2.0.1",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"ng-packagr": "^5.3.0",
"protractor": "~5.4.1",
"ts-node": "~7.0.1",
"tsickle": ">=0.34.0",
"tslib": "^1.9.0",
"tslint": "~5.11.0",
"typescript": "~3.2.2"
"ng-packagr": "^5.4.0",
"protractor": "~5.4.0",
"ts-node": "~7.0.0",
"tsickle": "^0.37.0",
"tslint": "~5.15.0",
"typescript": "~3.5.3"
}
}
14 changes: 7 additions & 7 deletions projects/ng-oidc-client/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "ng-oidc-client",
"version": "1.0.7",
"version": "2.0.0",
"main": "index.js",
"description": "An Angular 6+ package wrapping oidc-client library to manage authentication with OpenID Connect (OIDC) and OAuth2 in a reactive way using NgRx.",
"description": "An Angular package wrapping oidc-client library to manage authentication with OpenID Connect (OIDC) and OAuth2 in a reactive way using NgRx.",
"author": "Alexandru Gogan & David Turner",
"contributors": [
{
Expand All @@ -16,16 +16,16 @@
],
"repository": {
"type" : "git",
"url" : "https://github.com/fileless/ng-oidc-client"
"url" : "https://github.com/sourcenetwork/ng-oidc-client"
},
"bugs": {
"url": "https://github.com/fileless/ng-oidc-client/issues"
"url": "https://github.com/sourcenetwork/ng-oidc-client/issues"
},
"homepage" :"https://fileless.github.io/ng-oidc-client/",
"homepage" :"https://sourcenetwork.github.io/ng-oidc-client/",
"keywords" :["angular","library","openidconnect","oidc","openid","authentication","identity","sso", "auth", "oauth2","authn","implicit"],
"peerDependencies": {
"@angular/common": "^6.0.0-rc.0 || ^8.0.0",
"@angular/core": "^6.0.0-rc.0 || ^8.0.0"
"@angular/common": ">=8.0.0",
"@angular/core": ">=8.0.0"
},
"typings": "index.d.ts",
"license": "MIT"
Expand Down
161 changes: 33 additions & 128 deletions projects/ng-oidc-client/src/lib/actions/oidc.action.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
import { Action } from '@ngrx/store';
import { User as OidcUser, User } from 'oidc-client';
import { createAction, props } from '@ngrx/store';
import { UserSettings } from 'oidc-client';
import { RequestArugments } from '../models';

export enum OidcActionTypes {
ClientConfigued = '[Oidc] client configured',
ClientConfigError = '[Oidc] client configuration error',
GetOidcUser = '[Oidc] get oidc user',
RemoveOidcUser = '[Oidc] remove oidc user',

UserExpired = '[Oidc] user expired',
UserFound = '[Oidc] user found',
UserLoading = '[Oidc] user loading',
UserDoneLoading = '[Oidc] user done loading',
UserLoadingError = '[Oidc] user loading error',

// Events
OnAccessTokenExpired = '[Oidc] on access token expired',
OnAccessTokenExpiring = '[Oidc] user expiring',
OnSilentRenewError = '[Oidc] on silent renew error',
Expand All @@ -16,10 +22,6 @@ export enum OidcActionTypes {
OnUserSignedOut = '[Oidc] on user signed out',
OnSessionChanged = '[Oidc] session changed',

UserLoading = '[Oidc] user loading',
UserDoneLoading = '[Oidc] user done loading',
UserLoadingError = '[Oidc] user loading error',

// Sign In
SignInPopup = '[Oidc] sign in popup',
SignInRedirect = '[Oidc] sign in redirect',
Expand All @@ -34,147 +36,50 @@ export enum OidcActionTypes {
OidcError = '[Oidc] error'
}

// OIDC COMMANDS

export class GetOidcUser implements Action {
readonly type = OidcActionTypes.GetOidcUser;

constructor(public payload: any) {}
}

export class RemoveOidcUser implements Action {
readonly type = OidcActionTypes.RemoveOidcUser;
}

export class UserExpired implements Action {
readonly type = OidcActionTypes.UserExpired;
}

export class UserFound implements Action {
readonly type = OidcActionTypes.UserFound;

constructor(public payload: OidcUser) {}
}

export class OnSessionChanged implements Action {
readonly type = OidcActionTypes.OnSessionChanged;
}

export class OnAccessTokenExpired implements Action {
readonly type = OidcActionTypes.OnAccessTokenExpired;
}

export class OnAccessTokenExpiring implements Action {
readonly type = OidcActionTypes.OnAccessTokenExpiring;
}
export const ClientConfigured = createAction(OidcActionTypes.ClientConfigued);

export class OnUserLoading implements Action {
readonly type = OidcActionTypes.UserLoading;
}
export const ClientConfigError = createAction(OidcActionTypes.ClientConfigError, props<{ payload?: string }>());

export class UserDoneLoading implements Action {
readonly type = OidcActionTypes.UserDoneLoading;
}
export const GetOidcUser = createAction(OidcActionTypes.GetOidcUser, props<{ payload?: RequestArugments }>());

export class UserLoadingError implements Action {
readonly type = OidcActionTypes.UserLoadingError;
}
export const RemoveOidcUser = createAction(OidcActionTypes.RemoveOidcUser);

// OIDC EVENTS

export class OnUserLoaded implements Action {
readonly type = OidcActionTypes.OnUserLoaded;

constructor(public payload: OidcUser) {}
}

export class OnUserUnloaded implements Action {
readonly type = OidcActionTypes.OnUserUnloaded;
}
export const UserExpired = createAction(OidcActionTypes.UserExpired);

export class OnUserSignedOut implements Action {
readonly type = OidcActionTypes.OnUserSignedOut;
}
export const UserFound = createAction(OidcActionTypes.UserFound, props<{ payload?: UserSettings }>());

export class OnSilentRenewError implements Action {
readonly type = OidcActionTypes.OnSilentRenewError;
export const OnSessionChanged = createAction(OidcActionTypes.OnSessionChanged);

constructor(public payload: Error) {}
}
export const OnAccessTokenExpired = createAction(OidcActionTypes.OnAccessTokenExpired);

export class SigninPopup implements Action {
readonly type = OidcActionTypes.SignInPopup;
export const OnAccessTokenExpiring = createAction(OidcActionTypes.OnAccessTokenExpiring);

constructor(public payload: any) {}
}
export const OnUserLoading = createAction(OidcActionTypes.UserLoading);

export class SigninRedirect implements Action {
readonly type = OidcActionTypes.SignInRedirect;
export const UserDoneLoading = createAction(OidcActionTypes.UserDoneLoading);

constructor(public payload: any) {}
}
export const UserLoadingError = createAction(OidcActionTypes.UserLoadingError);

export class SignInError implements Action {
readonly type = OidcActionTypes.SignInError;
export const OnUserLoaded = createAction(OidcActionTypes.OnUserLoaded, props<{ payload: UserSettings }>());

constructor(public payload: Error) {}
}
export const OnUserUnloaded = createAction(OidcActionTypes.OnUserUnloaded);

export class SignoutPopup implements Action {
readonly type = OidcActionTypes.SignOutPopup;
export const OnUserSignedOut = createAction(OidcActionTypes.OnUserSignedOut);

constructor(public payload: any) {}
}
export const OnSilentRenewError = createAction(OidcActionTypes.OnSilentRenewError, props<{ payload: string }>());

export class SignoutRedirect implements Action {
readonly type = OidcActionTypes.SignOutRedirect;
export const SigninPopup = createAction(OidcActionTypes.SignInPopup, props<{ payload?: RequestArugments }>());

constructor(public payload: any) {}
}
export const SigninRedirect = createAction(OidcActionTypes.SignInRedirect, props<{ payload?: RequestArugments }>());

export class SignOutError implements Action {
readonly type = OidcActionTypes.SignOutError;
export const SignoutPopup = createAction(OidcActionTypes.SignOutPopup, props<{ payload?: RequestArugments }>());

constructor(public payload: Error) {}
}
export const SignOutRedirect = createAction(OidcActionTypes.SignOutRedirect, props<{ payload?: RequestArugments }>());

export class SigninSilent implements Action {
readonly type = OidcActionTypes.SignInSilent;
export const SigninSilent = createAction(OidcActionTypes.SignInSilent, props<{ payload?: RequestArugments }>());

constructor(public payload: any) {}
}
export const SignInError = createAction(OidcActionTypes.SignInError, props<{ payload: string }>());

export class OidcError implements Action {
readonly type = OidcActionTypes.OidcError;
constructor(public payload: any) {}
}
export const SignOutError = createAction(OidcActionTypes.SignOutError, props<{ payload: string }>());

export type OidcActionsUnion =
| GetOidcUser
| RemoveOidcUser
//
| UserExpired
| UserFound
//
| OnUserLoading
| UserDoneLoading
| UserLoadingError
// Events
| OnAccessTokenExpired
| OnAccessTokenExpiring
| OnSilentRenewError
| OnUserLoaded
| OnUserUnloaded
| OnUserSignedOut
| OnSessionChanged
//
| SigninPopup
| SigninRedirect
| SigninSilent
| SignInError
//
| SignoutPopup
| SignoutRedirect
| SignOutError
//
| OidcError;
export const OidcError = createAction(OidcActionTypes.OidcError, props<{ payload: any }>());
Loading

0 comments on commit f0cc3db

Please sign in to comment.