ngx-oauth 1.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ngx-oauth.mjs","sources":["../../../projects/ngx-oauth/src/lib/models/index.ts","../../../projects/ngx-oauth/src/lib/services/oauth.service.ts","../../../projects/ngx-oauth/src/lib/services/oauth.interceptor.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.ts","../../../projects/ngx-oauth/src/lib/components/login/oauth-login.component.html","../../../projects/ngx-oauth/src/lib/oauth.module.ts","../../../projects/ngx-oauth/src/index.ts","../../../projects/ngx-oauth/src/ngx-oauth.ts"],"sourcesContent":["import {InjectionToken} from '@angular/core';\n\nexport const SERVER_HOST = new InjectionToken<string>('SERVER_HOST');\nexport const SERVER_PATH = new InjectionToken<string>('SERVER_PATH');\nexport const LOCATION = new InjectionToken<Location>('Location');\nexport const STORAGE = new InjectionToken<Storage>('Storage');\nexport const OAUTH_CONFIG = new InjectionToken<OAuthConfig>('OAuthConfig');\nexport const OAUTH_TOKEN = new InjectionToken<OAuthToken>('OAuthToken');\n\nexport enum OAuthType {\n RESOURCE = 'password',\n AUTHORIZATION_CODE = 'code',\n IMPLICIT = 'token',\n CLIENT_CREDENTIAL = 'client_credentials'\n}\n\nexport interface OAuthConfig {\n type: OAuthType;\n config: OAuthTypeConfig;\n storageKey?: string;\n storage?: Storage;\n ignorePaths?: RegExp[];\n}\n\nexport interface ClientCredentialConfig {\n tokenPath: string;\n revokePath?: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface ResourceConfig extends ClientCredentialConfig {\n}\n\nexport interface ImplicitConfig {\n authorizePath: string;\n revokePath?: string;\n clientId: string;\n scope?: string;\n}\n\nexport interface AuthorizationCodeConfig extends ResourceConfig {\n authorizePath: string;\n}\n\nexport interface AuthorizationCodePKCEConfig extends AuthorizationCodeConfig {\n pkce: boolean;\n}\n\nexport interface OpenIdConfig {\n issuerPath: string;\n clientId: string;\n clientSecret?: string;\n scope?: string;\n}\n\nexport interface ResourceParameters {\n username: string;\n password: string;\n}\n\nexport interface ImplicitParameters {\n redirectUri: string;\n state?: string;\n}\n\n// tslint:disable-next-line:no-empty-interface\nexport interface AuthorizationCodeParameters extends ImplicitParameters {\n}\n\nexport type OAuthParameters = ResourceParameters | AuthorizationCodeParameters | ImplicitParameters;\nexport type OAuthTypeConfig = OpenIdConfig\n | AuthorizationCodePKCEConfig\n | AuthorizationCodeConfig\n | ImplicitConfig\n | ResourceConfig\n | ClientCredentialConfig;\n\nexport interface OAuthToken {\n id_token?: string;\n access_token?: string;\n refresh_token?: string;\n token_type?: string;\n state?: string;\n error?: string;\n error_description?: string;\n expires_in?: number | string;\n refresh_expires_in?: number;\n scope?: string;\n codeVerifier?: string;\n nonce?: string;\n}\n\nexport enum OAuthStatus {\n NOT_AUTHORIZED = 'NOT_AUTHORIZED',\n AUTHORIZED = 'AUTHORIZED',\n DENIED = 'DENIED'\n}\n\nexport interface OpenIdConfiguration {\n issuer?: string;\n authorization_endpoint?: string;\n introspection_endpoint?: string;\n token_endpoint?: string;\n userinfo_endpoint?: string;\n end_session_endpoint?: string;\n revocation_endpoint?: string;\n scopes_supported?: string[];\n code_challenge_methods_supported?: string[];\n}\n\nexport interface UserInfo {\n email?: string;\n email_verified?: boolean;\n family_name?: string;\n given_name?: string;\n name?: string;\n preferred_username?: string;\n sub?: string;\n address?: object;\n}\n\nexport interface IntrospectInfo extends UserInfo {\n active: boolean;\n scope: string;\n client_id?: string;\n username: string;\n exp: number;\n}\n","import {Inject, Injectable, NgZone} from '@angular/core';\nimport {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';\nimport {catchError, concatMap, delay, filter, map, shareReplay, switchMap, tap} from 'rxjs/operators';\nimport {EMPTY, from, noop, Observable, of, ReplaySubject} from 'rxjs';\nimport {\n AuthorizationCodeParameters,\n ImplicitParameters,\n LOCATION,\n OAUTH_CONFIG,\n OAuthConfig,\n OAuthParameters,\n OAuthStatus,\n OAuthToken,\n OAuthType,\n OAuthTypeConfig, OpenIdConfig, OpenIdConfiguration,\n ResourceParameters, UserInfo\n} from '../models';\nimport {Location as Location2} from '@angular/common';\n\nconst arrToString = (buf: Uint8Array) => buf.reduce((s, b) => s + String.fromCharCode(b), '');\n\nconst base64url = (str: string) => btoa(str)\n .replace(/\\+/g, '-')\n .replace(/\\//g, '_')\n .replace(/=/g, '');\n\nconst randomString = (length: number = 48) => {\n const buff = arrToString(crypto.getRandomValues(new Uint8Array(length * 2)));\n return base64url(buff).substring(0, length);\n};\n\nconst pkce = async (value: string) => {\n const buff = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(value));\n return base64url(arrToString(new Uint8Array(buff)));\n};\n\nconst REQUEST_HEADER = new HttpHeaders({'Content-Type': 'application/x-www-form-urlencoded'});\n\nconst parseOauthUri = (hash: string): Record<string, string> | null => {\n const regex = /([^&=]+)=([^&]*)/g;\n const params: Record<string, string> = {};\n let m;\n // tslint:disable-next-line:no-conditional-assignment\n while ((m = regex.exec(hash)) !== null) {\n params[decodeURIComponent(m[1])] = decodeURIComponent(m[2]);\n }\n if (Object.keys(params).length) {\n return params;\n }\n return null;\n};\n\nconst jwt = (token: string) => JSON.parse(atob(token.split('.')[1]));\n\n@Injectable()\nexport class OAuthService {\n\n private _token: OAuthToken | null = null;\n private _status = OAuthStatus.NOT_AUTHORIZED;\n private timer: any;\n state$: ReplaySubject<string> = new ReplaySubject(1);\n status$: ReplaySubject<OAuthStatus> = new ReplaySubject(1);\n userInfo$: Observable<UserInfo> = this.status$.pipe(\n filter(s => s === OAuthStatus.AUTHORIZED),\n map(() => {\n const {config} = this.authConfig as any;\n return config.userPath;\n }),\n filter(p => !!p),\n switchMap(path => this.http.get<UserInfo>(path)),\n shareReplay()\n );\n\n constructor(private http: HttpClient,\n private zone: NgZone,\n @Inject(OAUTH_CONFIG) private authConfig: OAuthConfig,\n @Inject(LOCATION) private location: Location,\n private locationService: Location2) {\n setTimeout(() => this.init()); // decouple for http interceptor\n }\n\n /**\n * Get the oauth config for initialize. If OpenId with issuerPath is configured then configure from server openid configuration.\n * @protected\n */\n protected get config$() {\n let {config} = this.authConfig;\n if (config && config.clientId) {\n const {issuerPath, scope} = config as OpenIdConfig;\n if (issuerPath) {\n return this.http.get<OpenIdConfiguration>(`${issuerPath}/.well-known/openid-configuration`).pipe(\n tap(v => this.set(this.type, {\n ...v.authorization_endpoint && {authorizePath: v.authorization_endpoint} || {},\n ...v.token_endpoint && {tokenPath: v.token_endpoint} || {},\n ...v.revocation_endpoint && {revokePath: v.revocation_endpoint} || {},\n ...v.code_challenge_methods_supported && {pkce: v.code_challenge_methods_supported.indexOf('S256') > -1} || {},\n ...v.userinfo_endpoint && {userPath: v.userinfo_endpoint} || {},\n ...v.introspection_endpoint && {introspectionPath: v.introspection_endpoint} || {},\n ...scope && {} || {scope: 'openid'}\n } as any)),\n map(() => this.authConfig.config)\n );\n }\n return of(config);\n }\n console.warn('clientId is missing in oauth config');\n return EMPTY;\n }\n\n /**\n * Init. Will check the url implicit or authorization flow or existing saved token.\n * @protected\n */\n protected init(): void {\n const {hash, search, origin, pathname} = this.location;\n const isImplicitRedirect = hash && /(access_token=)|(error=)/.test(hash);\n const isAuthCodeRedirect = search && /(code=)|(error=)/.test(search);\n const {storageKey} = this.authConfig;\n const savedToken = storageKey && this.authConfig.storage && this.authConfig.storage[storageKey] &&\n JSON.parse(this.authConfig.storage[storageKey]);\n this.config$.subscribe(config => {\n if (isImplicitRedirect) {\n const parameters = parseOauthUri(hash.substr(1));\n this.token = parameters;\n this.status = this.checkResponse(savedToken, parameters) && OAuthStatus.AUTHORIZED || OAuthStatus.DENIED;\n } else if (isAuthCodeRedirect) {\n const parameters = parseOauthUri(search.substr(1));\n if (!this.checkResponse(savedToken, parameters)) {\n this.token = parameters;\n this.status = OAuthStatus.DENIED;\n } else {\n const newParametersString = this.getCleanedUnSearchParameters();\n const {clientId, clientSecret, tokenPath, scope} = config as any;\n const codeVerifier = savedToken && savedToken.codeVerifier;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n code: parameters?.code,\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n redirect_uri: `${origin}${pathname}${newParametersString}`,\n grant_type: 'authorization_code',\n ...scope && {scope} || {},\n ...codeVerifier && {code_verifier: codeVerifier} || {}\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError((err) => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n return EMPTY;\n })\n ).subscribe(token => {\n this.token = token;\n this.status = OAuthStatus.AUTHORIZED;\n this.locationService.replaceState(`${pathname}${newParametersString}`);\n });\n }\n } else if (savedToken) {\n this._token = savedToken;\n const {access_token, refresh_token, error} = savedToken;\n if (access_token) {\n if (refresh_token) { // force refresh since might be a manual page refresh\n this.refreshToken();\n } else {\n this.status = OAuthStatus.AUTHORIZED;\n }\n } else {\n this.status = error && OAuthStatus.DENIED || OAuthStatus.NOT_AUTHORIZED;\n }\n } else {\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n });\n }\n\n async login(parameters?: OAuthParameters) {\n if (this.isResourceType(parameters as ResourceParameters)) {\n this.resourceLogin(parameters as ResourceParameters);\n } else if (this.isAuthorizationCodeType(parameters as AuthorizationCodeParameters)) {\n await this.authorizationCodeLogin(parameters as AuthorizationCodeParameters);\n } else if (this.isImplicitType(parameters as ImplicitParameters)) {\n await this.implicitLogin(parameters as ImplicitParameters);\n } else if (this.isClientCredentialType()) {\n this.clientCredentialLogin();\n }\n }\n\n logout() {\n this.revoke();\n this.token = null;\n this.status = OAuthStatus.NOT_AUTHORIZED;\n }\n\n revoke() {\n const {revokePath, clientId, clientSecret} = this.authConfig.config as any;\n if (revokePath) {\n const {access_token, refresh_token} = this.token as OAuthToken;\n const toRevoke = [];\n if (access_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: access_token,\n token_type_hint: 'access_token'\n });\n }\n if (refresh_token) {\n toRevoke.push({\n ...clientId && {client_id: clientId} || {},\n ...clientSecret && {client_secret: clientSecret} || {},\n token: refresh_token,\n token_type_hint: 'refresh_token'\n });\n }\n from(toRevoke).pipe(\n concatMap(o => of(o).pipe(delay(300))), // space request to avoid cancellation\n switchMap(o => this.http.post(revokePath, new HttpParams({fromObject: o}))),\n ).subscribe(noop);\n }\n }\n\n get status(): OAuthStatus {\n return this._status;\n }\n\n set status(status) {\n this._status = status;\n this.status$.next(status);\n }\n\n set(type: OAuthType, config?: OAuthTypeConfig): void {\n this.authConfig.type = type;\n if (config) {\n this.authConfig.config = {\n ...this.authConfig.config,\n ...config\n };\n }\n }\n\n get type(): OAuthType {\n return this.authConfig.type;\n }\n\n get ignorePaths(): RegExp[] {\n return this.authConfig.ignorePaths || [];\n }\n\n private resourceLogin(parameters: ResourceParameters) {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n const {username, password} = parameters;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: OAuthType.RESOURCE,\n ...scope && {scope} || {},\n username,\n password\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(err => {\n this.token = err;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private async authorizationCodeLogin(parameters: AuthorizationCodeParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.AUTHORIZATION_CODE);\n this.location.replace(authUrl);\n }\n\n private async implicitLogin(parameters: ImplicitParameters) {\n const authUrl = await this.toAuthorizationUrl(parameters, OAuthType.IMPLICIT);\n this.location.replace(authUrl);\n }\n\n private clientCredentialLogin() {\n const {clientId, clientSecret, tokenPath, scope} = this.authConfig.config as any;\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: OAuthType.CLIENT_CREDENTIAL,\n ...scope ? {scope} : {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.token = null;\n this.status = OAuthStatus.DENIED;\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = params;\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n\n private isClientCredentialType(): boolean {\n return this.authConfig.type === OAuthType.CLIENT_CREDENTIAL;\n }\n\n private isResourceType(parameters?: ResourceParameters): boolean {\n return this.authConfig.type === OAuthType.RESOURCE && !!parameters?.password;\n }\n\n private isImplicitType(parameters?: ImplicitParameters): boolean {\n return this.authConfig.type === OAuthType.IMPLICIT && !!parameters?.redirectUri;\n }\n\n private isAuthorizationCodeType(parameters?: AuthorizationCodeParameters): boolean {\n return this.authConfig.type === OAuthType.AUTHORIZATION_CODE && !!parameters?.redirectUri;\n }\n\n private async toAuthorizationUrl(parameters: AuthorizationCodeParameters | ImplicitParameters, responseType: OAuthType): Promise<string> {\n const {config} = this.authConfig as any;\n let authorizationUrl = `${config.authorizePath}`;\n authorizationUrl += config.authorizePath.includes('?') && '&' || '?';\n authorizationUrl += `client_id=${config.clientId}`;\n authorizationUrl += `&redirect_uri=${encodeURIComponent(parameters.redirectUri)}`;\n authorizationUrl += `&response_type=${responseType}`;\n authorizationUrl += `&scope=${encodeURIComponent(config.scope || '')}`;\n authorizationUrl += `&state=${encodeURIComponent(parameters.state || '')}`;\n return `${authorizationUrl}${this.generateNonce(config)}${await this.generateCodeChallenge(config)}`;\n }\n\n private async generateCodeChallenge(config: any) {\n if (config.pkce) {\n const codeVerifier = randomString();\n this.token = {...this.token, codeVerifier};\n return `&code_challenge=${await pkce(codeVerifier)}&code_challenge_method=S256`;\n }\n return '';\n }\n\n private generateNonce(config: any) {\n if (config && config.scope && config.scope.indexOf('openid') > -1) {\n const nonce = randomString(10);\n this.token = {...this.token, nonce};\n return `&nonce=${nonce}`;\n }\n return '';\n }\n\n private checkResponse(token: any, parameters: Record<string, string> | null) {\n this.emitState(parameters);\n this.cleanLocationHash();\n if (!parameters || parameters.error) {\n return false;\n }\n if (token && token.nonce && parameters.access_token) {\n const jwtToken = jwt(parameters.access_token);\n return token.nonce === jwtToken.nonce;\n }\n return parameters.access_token || parameters.code;\n }\n\n set token(token: OAuthToken | null) {\n this._token = token;\n const {storageKey} = this.authConfig;\n if (token) {\n // @ts-ignore\n this.authConfig.storage[storageKey] = JSON.stringify(this.token);\n clearTimeout(this.timer);\n if (this.token && this.token.expires_in) {\n this.zone.runOutsideAngular(() => {\n this.timer = setTimeout(() => {\n this.zone.run(() => {\n this.refreshToken();\n });\n }, Number(this.token?.expires_in) * 1000);\n });\n }\n } else {\n // @ts-ignore\n delete this.authConfig.storage[storageKey];\n }\n }\n\n get token() {\n return this._token;\n }\n\n private refreshToken() {\n const {tokenPath, clientId, clientSecret, scope} = this.authConfig.config as any;\n const {refresh_token} = this.token as OAuthToken;\n if (tokenPath && refresh_token) {\n this.http.post(tokenPath, new HttpParams({\n fromObject: {\n client_id: clientId,\n ...clientSecret && {client_secret: clientSecret} || {},\n grant_type: 'refresh_token',\n refresh_token,\n ...scope && {scope} || {},\n }\n }), {headers: REQUEST_HEADER}).pipe(\n catchError(() => {\n this.logout();\n return EMPTY;\n })\n ).subscribe(params => {\n this.token = {\n ...this.token,\n ...params\n };\n this.status = OAuthStatus.AUTHORIZED;\n });\n }\n }\n\n private getCleanedUnSearchParameters(): string {\n const {search} = this.location;\n let searchString = search.substr(1);\n const hashKeys = ['code', 'state', 'error', 'error_description', 'session_state'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n searchString = searchString.replace(re, '');\n });\n return searchString.length && `?${searchString}` || '';\n }\n\n private cleanLocationHash() {\n const {hash} = this.location;\n let curHash = hash.substr(1);\n const hashKeys = ['access_token', 'token_type', 'expires_in', 'scope', 'state', 'error', 'error_description', 'session_state', 'nonce'];\n hashKeys.forEach((hashKey) => {\n const re = new RegExp('&' + hashKey + '(=[^&]*)?|^' + hashKey + '(=[^&]*)?&?');\n curHash = curHash.replace(re, '');\n });\n this.location.hash = curHash;\n }\n\n private emitState(parameters: Record<string, string> | null) {\n const {state} = parameters as any;\n if (state) {\n this.state$.next(state);\n }\n }\n}\n","import {Injectable} from '@angular/core';\nimport {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http';\nimport {EMPTY, Observable, throwError} from 'rxjs';\nimport {catchError} from 'rxjs/operators';\nimport {OAuthService} from './oauth.service';\nimport {OAuthStatus} from '../models';\n\n@Injectable()\nexport class OAuthInterceptor implements HttpInterceptor {\n\n constructor(private oauthService: OAuthService) {\n }\n\n intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {\n if (this.oauthService) {\n if (!this.isPathExcepted(req)) {\n const {token} = this.oauthService;\n if (token && token.access_token) {\n req = req.clone({\n setHeaders: {\n Authorization: `${token.token_type} ${token.access_token}`\n }\n });\n }\n }\n return next.handle(req).pipe(\n catchError((err) => {\n if (err.status === 401) {\n this.oauthService.token = null;\n this.oauthService.status = OAuthStatus.DENIED;\n return EMPTY;\n }\n return throwError(() => new Error(err));\n })\n );\n } else {\n return next.handle(req);\n }\n }\n\n private isPathExcepted(req: HttpRequest<any>) {\n const {ignorePaths} = this.oauthService;\n if (ignorePaths) {\n for (const ignorePath of this.oauthService.ignorePaths) {\n try {\n if (req.url.match(ignorePath)) {\n return true;\n }\n } catch (err) {\n }\n }\n }\n return false;\n }\n}\n","import {\r\n Component,\r\n ContentChild,\r\n EventEmitter,\r\n HostListener,\r\n Inject,\r\n Input,\r\n OnDestroy,\r\n Output,\r\n TemplateRef,\r\n ViewEncapsulation\r\n} from '@angular/core';\r\nimport {Observable, Subscription, take} from 'rxjs';\r\nimport {LOCATION, OAuthParameters, OAuthStatus, OAuthType} from '../../models';\r\nimport {tap} from 'rxjs/operators';\r\nimport {OAuthService} from '../../services/oauth.service';\r\nimport {Location as Location2} from '@angular/common';\r\n\r\nexport interface OAuthLoginI18n {\r\n username?: string;\r\n password?: string;\r\n submit?: string;\r\n notAuthorized?: string;\r\n authorized?: string;\r\n denied?: string;\r\n}\r\n\r\n@Component({\r\n selector: 'oauth-login',\r\n templateUrl: 'oauth-login.component.html',\r\n styleUrls: ['oauth-login.component.scss'],\r\n encapsulation: ViewEncapsulation.None,\r\n})\r\nexport class OAuthLoginComponent implements OnDestroy {\r\n\r\n private _redirectUri: string | undefined;\r\n private subscription = new Subscription();\r\n private _i18n: OAuthLoginI18n = {\r\n username: 'Username',\r\n password: 'Password',\r\n submit: 'Sign in',\r\n notAuthorized: 'Sign in',\r\n authorized: 'Welcome',\r\n denied: 'Access Denied. Try again!'\r\n };\r\n\r\n get i18n() {\r\n return this._i18n;\r\n }\r\n\r\n @Input()\r\n set i18n(i18n) {\r\n this._i18n = {\r\n ...this._i18n,\r\n ...i18n\r\n };\r\n }\r\n\r\n @Input()\r\n set redirectUri(redirectUri: string) {\r\n if (redirectUri) {\r\n this._redirectUri = redirectUri;\r\n }\r\n }\r\n\r\n get redirectUri() {\r\n return this._redirectUri || `${this.location.origin}${this.locationService.path(true) || '/'}`;\r\n }\r\n\r\n @Input()\r\n state = '';\r\n @Output()\r\n stateChange: EventEmitter<string> = new EventEmitter();\r\n @Input()\r\n profileName$: Observable<string | undefined> | undefined;\r\n @ContentChild('login', {static: false})\r\n loginTemplate: TemplateRef<any> | undefined;\r\n username = '';\r\n password = '';\r\n profileName: string | undefined;\r\n OAuthStatus = OAuthStatus;\r\n OAuthType = OAuthType;\r\n collapse = false;\r\n type = this.oauthService.type;\r\n state$ = this.oauthService.state$.pipe(\r\n tap(s => this.stateChange.emit(s))\r\n );\r\n status$ = this.oauthService.status$.pipe(\r\n tap(s => {\r\n if (s === OAuthStatus.AUTHORIZED && this.profileName$) {\r\n this.subscription.add(this.profileName$.pipe(take(1)).subscribe(n => this.profileName = n));\r\n } else {\r\n const {token} = this.oauthService;\r\n const userInfo = token && token.id_token && JSON.parse(atob(token.id_token.split('.')[1])) || {};\r\n this.profileName = userInfo.name || userInfo.username || userInfo.email || userInfo.sub || '';\r\n }\r\n })\r\n );\r\n loginFunction = (p: OAuthParameters) => this.login(p);\r\n logoutFunction = () => this.logout();\r\n\r\n constructor(private oauthService: OAuthService,\r\n private locationService: Location2,\r\n @Inject(LOCATION) private location: Location) {\r\n }\r\n\r\n ngOnDestroy() {\r\n this.subscription.unsubscribe();\r\n }\r\n\r\n logout() {\r\n this.oauthService.logout();\r\n }\r\n\r\n async login(parameters: OAuthParameters) {\r\n await this.oauthService.login(parameters);\r\n this.collapse = false;\r\n }\r\n\r\n toggleCollapse() {\r\n this.collapse = !this.collapse;\r\n }\r\n\r\n @HostListener('window:keydown.escape')\r\n keyboardEvent() {\r\n this.collapse = false;\r\n }\r\n}\r\n","<ng-container *ngIf=\"state$ | async\"></ng-container>\r\n<ng-container *ngIf=\"loginTemplate; else defaultLogin\"\r\n [ngTemplateOutlet]=\"loginTemplate\"\r\n [ngTemplateOutletContext]=\"{login: loginFunction, logout: logoutFunction, status: status$ | async}\">\r\n</ng-container>\r\n<ng-template #defaultLogin>\r\n <ng-container *ngIf=\"status$ | async as status\">\r\n <ng-container *ngIf=\"type === OAuthType.RESOURCE; else noResource\">\r\n <div class=\"oauth dropdown text-end p-3 {{collapse ? 'show': ''}}\">\r\n <button class=\"btn btn-link p-0 dropdown-toggle\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : toggleCollapse()\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </button>\r\n <div class=\"dropdown-menu mr-3 {{collapse ? 'show': ''}}\">\r\n <form class=\"p-3\" #form=\"ngForm\"\r\n *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED || status === OAuthStatus.DENIED\"\r\n (submit)=\"login({username: username, password: password})\">\r\n <div class=\"mb-3\">\r\n <input type=\"text\"\r\n class=\"form-control\"\r\n name=\"username\"\r\n required\r\n [(ngModel)]=\"username\"\r\n [placeholder]=\"i18n.username\">\r\n </div>\r\n <div class=\"mb-3\">\r\n <input type=\"password\"\r\n class=\"form-control\"\r\n name=\"password\"\r\n required\r\n [(ngModel)]=\"password\"\r\n [placeholder]=\"i18n.password\">\r\n </div>\r\n <div class=\"text-end\">\r\n <button type=\"submit\"\r\n class=\"btn btn-primary\"\r\n [disabled]=\"form.invalid\">{{i18n.submit}}</button>\r\n </div>\r\n </form>\r\n </div>\r\n </div>\r\n </ng-container>\r\n\r\n <ng-template #noResource>\r\n <a role=\"button\" class=\"oauth\"\r\n (click)=\"status === OAuthStatus.AUTHORIZED ? logout() : login({redirectUri: redirectUri, state:state})\">\r\n <ng-container *ngTemplateOutlet=\"message\"></ng-container>\r\n </a>\r\n </ng-template>\r\n\r\n <ng-template #message>\r\n <span *ngIf=\"status === OAuthStatus.NOT_AUTHORIZED\">{{i18n.notAuthorized}}</span>\r\n <span *ngIf=\"status === OAuthStatus.AUTHORIZED\">\r\n {{i18n.authorized}}<strong>&nbsp;{{profileName}}</strong>\r\n </span>\r\n <span *ngIf=\"status === OAuthStatus.DENIED\">{{i18n.denied}}</span>\r\n </ng-template>\r\n </ng-container>\r\n</ng-template>\r\n\r\n","import {ModuleWithProviders, NgModule, Optional, PLATFORM_ID} from '@angular/core';\nimport {FormsModule} from '@angular/forms';\nimport {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http';\nimport {RouterModule} from '@angular/router';\nimport {OAuthConfig, OAUTH_CONFIG, LOCATION, SERVER_HOST, SERVER_PATH, STORAGE} from './models';\nimport {OAuthService} from './services/oauth.service';\nimport {OAuthLoginComponent} from './components/login/oauth-login.component';\nimport {CommonModule, isPlatformBrowser} from '@angular/common';\nimport {OAuthInterceptor} from './services/oauth.interceptor';\n\nconst mockLocation = (serverHost: string, serverPath: string): Location => {\n const url = new URL(serverHost && serverPath ? `${serverHost}${serverPath}` : 'http://localhost');\n const {href, origin, protocol, host, hostname, port, pathname, search, hash} = url;\n return {\n href, origin, protocol, host, hostname, port, pathname, search, hash,\n reload() {\n },\n assign(u: string) {\n },\n ancestorOrigins: {} as any,\n replace(u: string) {\n }\n };\n};\n\nconst LocationService = {\n provide: LOCATION,\n useFactory(platformId: Object, serverHost: string, serverPath: string) {\n return isPlatformBrowser(platformId) ? location : mockLocation(serverHost, serverPath);\n },\n deps: [\n PLATFORM_ID,\n [new Optional(), SERVER_HOST],\n [new Optional(), SERVER_PATH]\n ]\n};\n\nconst mockStorage: Storage = {\n clear() {\n },\n getItem(key: string) {\n return null;\n },\n key(index: number) {\n return null;\n },\n removeItem(key: string) {\n },\n setItem(key: string, value: string) {\n },\n length: 0\n};\n\nconst StorageService = {\n provide: STORAGE,\n useFactory(platformId: Object) {\n return isPlatformBrowser(platformId) ? localStorage : mockStorage;\n },\n deps: [PLATFORM_ID]\n};\n\nconst OAuthInterceptorService = {\n provide: HTTP_INTERCEPTORS,\n useClass: OAuthInterceptor,\n multi: true,\n};\n\nconst defaultConfig = (storage: Storage) => {\n return {\n storage,\n storageKey: 'token',\n ignorePaths: []\n };\n};\n\n@NgModule({\n imports: [\n CommonModule,\n FormsModule,\n HttpClientModule,\n RouterModule,\n ],\n declarations: [OAuthLoginComponent],\n exports: [OAuthLoginComponent],\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n ]\n})\nexport class OAuthModule {\n\n static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule> {\n return {\n ngModule: OAuthModule,\n providers: [\n LocationService,\n StorageService,\n OAuthService,\n OAuthInterceptorService,\n {\n provide: OAUTH_CONFIG,\n useFactory(storage: Storage) {\n return {\n ...defaultConfig(storage),\n ...config,\n };\n },\n deps: [\n STORAGE\n ]\n }\n ]\n };\n }\n}\n","/*\n * Public API Surface of ngx-oauth\n */\nexport * from './lib/models';\nexport * from './lib/services/oauth.service';\nexport * from './lib/services/oauth.interceptor';\nexport * from './lib/components/login/oauth-login.component';\nexport * from './lib/oauth.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;;;;;;;;;;MAEa,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,WAAW,GAAG,IAAI,cAAc,CAAS,aAAa,EAAE;MACxD,QAAQ,GAAG,IAAI,cAAc,CAAW,UAAU,EAAE;MACpD,OAAO,GAAG,IAAI,cAAc,CAAU,SAAS,EAAE;MACjD,YAAY,GAAG,IAAI,cAAc,CAAc,aAAa,EAAE;MAC9D,WAAW,GAAG,IAAI,cAAc,CAAa,YAAY,EAAE;IAE5D;AAAZ,WAAY,SAAS;IACnB,kCAAqB,CAAA;IACrB,wCAA2B,CAAA;IAC3B,+BAAkB,CAAA;IAClB,qDAAwC,CAAA;AAC1C,CAAC,EALW,SAAS,KAAT,SAAS,QAKpB;IAiFW;AAAZ,WAAY,WAAW;IACrB,gDAAiC,CAAA;IACjC,wCAAyB,CAAA;IACzB,gCAAiB,CAAA;AACnB,CAAC,EAJW,WAAW,KAAX,WAAW;;AC5EvB,MAAM,WAAW,GAAG,CAAC,GAAe,KAAK,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AAE9F,MAAM,SAAS,GAAG,CAAC,GAAW,KAAK,IAAI,CAAC,GAAG,CAAC;KACzC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;KACnB,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;AAErB,MAAM,YAAY,GAAG,CAAC,SAAiB,EAAE;IACvC,MAAM,IAAI,GAAG,WAAW,CAAC,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;IAC7E,OAAO,SAAS,CAAC,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,CAAC;AAEF,MAAM,aAAa,GAAG,CAAC,OAAgB;IACrC,OAAO;QACL,OAAO;QACP,UAAU,EAAE,OAAO;QACnB,WAAW,EAAE,EAAE;KAChB,CAAC;AACJ,CAAC,CAAC;MAkBW,WAAW;IAEtB,OAAO,OAAO,CAAC,MAAmB;QAChC,OAAO;YACL,QAAQ,EAAE,WAAW;YACrB,SAAS,EAAE;gBACT,eAAe;gBACf,cAAc;gBACd,YAAY;gBACZ,uBAAuB;gBACvB;oBACE,OAAO,EAAE,YAAY;oBACrB,UAAU,CAAC,OAAgB;wBACzB,OAAO;4BACL,GAAG,aAAa,CAAC,OAAO,CAAC;4BACzB,GAAG,MAAM;yBACV,CAAC;qBACH;oBACD,IAAI,EAAE;wBACJ,OAAO;qBACR;iBACF;aACF;SACF,CAAC;KACH;;wGAxBU,WAAW;yGAAX,WAAW,iBATP,mBAAmB,aALhC,YAAY;QACZ,WAAW;QACX,gBAAgB;QAChB,YAAY,aAGJ,mBAAmB;yGAQlB,WAAW,aAPX;QACT,eAAe;QACf,cAAc;QACd,YAAY;QACZ,uBAAuB;KACxB,YAbQ;YACP,YAAY;YACZ,WAAW;YACX,gBAAgB;YAChB,YAAY;SACb;2FAUU,WAAW;kBAhBvB,QAAQ;mBAAC;oBACR,OAAO,EAAE;wBACP,YAAY;wBACZ,WAAW;wBACX,gBAAgB;wBAChB,YAAY;qBACb;oBACD,YAAY,EAAE,CAAC,mBAAmB,CAAC;oBACnC,OAAO,EAAE,CAAC,mBAAmB,CAAC;oBAC9B,SAAS,EAAE;wBACT,eAAe;wBACf,cAAc;wBACd,YAAY;wBACZ,uBAAuB;qBACxB;iBACF;;;AC1FD;;;;ACAA;;;;;;"}
@@ -2,6 +2,8 @@ import { EventEmitter, OnDestroy, TemplateRef } from '@angular/core';
2
2
  import { Observable } from 'rxjs';
3
3
  import { OAuthParameters, OAuthStatus, OAuthType } from '../../models';
4
4
  import { OAuthService } from '../../services/oauth.service';
5
+ import { Location as Location2 } from '@angular/common';
6
+ import * as i0 from "@angular/core";
5
7
  export interface OAuthLoginI18n {
6
8
  username?: string;
7
9
  password?: string;
@@ -12,14 +14,18 @@ export interface OAuthLoginI18n {
12
14
  }
13
15
  export declare class OAuthLoginComponent implements OnDestroy {
14
16
  private oauthService;
17
+ private locationService;
15
18
  private location;
19
+ private _redirectUri;
16
20
  private subscription;
17
21
  private _i18n;
18
22
  get i18n(): OAuthLoginI18n;
19
23
  set i18n(i18n: OAuthLoginI18n);
24
+ set redirectUri(redirectUri: string);
25
+ get redirectUri(): string;
20
26
  state: string;
21
27
  stateChange: EventEmitter<string>;
22
- profileName$: Observable<string> | undefined;
28
+ profileName$: Observable<string | undefined> | undefined;
23
29
  loginTemplate: TemplateRef<any> | undefined;
24
30
  username: string;
25
31
  password: string;
@@ -28,15 +34,16 @@ export declare class OAuthLoginComponent implements OnDestroy {
28
34
  OAuthType: typeof OAuthType;
29
35
  collapse: boolean;
30
36
  type: OAuthType;
31
- redirectUri: string;
32
37
  state$: Observable<string>;
33
38
  status$: Observable<OAuthStatus>;
34
- loginFunction: (p: OAuthParameters) => void;
39
+ loginFunction: (p: OAuthParameters) => Promise<void>;
35
40
  logoutFunction: () => void;
36
- constructor(oauthService: OAuthService, location: Location);
41
+ constructor(oauthService: OAuthService, locationService: Location2, location: Location);
37
42
  ngOnDestroy(): void;
38
43
  logout(): void;
39
- login(parameters: OAuthParameters): void;
44
+ login(parameters: OAuthParameters): Promise<void>;
40
45
  toggleCollapse(): void;
41
46
  keyboardEvent(): void;
47
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuthLoginComponent, never>;
48
+ static ɵcmp: i0.ɵɵComponentDeclaration<OAuthLoginComponent, "oauth-login", never, { "i18n": "i18n"; "redirectUri": "redirectUri"; "state": "state"; "profileName$": "profileName$"; }, { "stateChange": "stateChange"; }, ["loginTemplate"], never>;
42
49
  }
@@ -4,6 +4,7 @@ export declare const SERVER_PATH: InjectionToken<string>;
4
4
  export declare const LOCATION: InjectionToken<Location>;
5
5
  export declare const STORAGE: InjectionToken<Storage>;
6
6
  export declare const OAUTH_CONFIG: InjectionToken<OAuthConfig>;
7
+ export declare const OAUTH_TOKEN: InjectionToken<OAuthToken>;
7
8
  export declare enum OAuthType {
8
9
  RESOURCE = "password",
9
10
  AUTHORIZATION_CODE = "code",
@@ -21,7 +22,7 @@ export interface ClientCredentialConfig {
21
22
  tokenPath: string;
22
23
  revokePath?: string;
23
24
  clientId: string;
24
- clientSecret: string;
25
+ clientSecret?: string;
25
26
  scope?: string;
26
27
  }
27
28
  export interface ResourceConfig extends ClientCredentialConfig {
@@ -36,7 +37,13 @@ export interface AuthorizationCodeConfig extends ResourceConfig {
36
37
  authorizePath: string;
37
38
  }
38
39
  export interface AuthorizationCodePKCEConfig extends AuthorizationCodeConfig {
39
- codeVerifier: string;
40
+ pkce: boolean;
41
+ }
42
+ export interface OpenIdConfig {
43
+ issuerPath: string;
44
+ clientId: string;
45
+ clientSecret?: string;
46
+ scope?: string;
40
47
  }
41
48
  export interface ResourceParameters {
42
49
  username: string;
@@ -49,7 +56,7 @@ export interface ImplicitParameters {
49
56
  export interface AuthorizationCodeParameters extends ImplicitParameters {
50
57
  }
51
58
  export declare type OAuthParameters = ResourceParameters | AuthorizationCodeParameters | ImplicitParameters;
52
- export declare type OAuthTypeConfig = AuthorizationCodePKCEConfig | AuthorizationCodeConfig | ImplicitConfig | ResourceConfig | ClientCredentialConfig;
59
+ export declare type OAuthTypeConfig = OpenIdConfig | AuthorizationCodePKCEConfig | AuthorizationCodeConfig | ImplicitConfig | ResourceConfig | ClientCredentialConfig;
53
60
  export interface OAuthToken {
54
61
  id_token?: string;
55
62
  access_token?: string;
@@ -57,12 +64,43 @@ export interface OAuthToken {
57
64
  token_type?: string;
58
65
  state?: string;
59
66
  error?: string;
67
+ error_description?: string;
60
68
  expires_in?: number | string;
61
69
  refresh_expires_in?: number;
62
70
  scope?: string;
71
+ codeVerifier?: string;
72
+ nonce?: string;
63
73
  }
64
74
  export declare enum OAuthStatus {
65
75
  NOT_AUTHORIZED = "NOT_AUTHORIZED",
66
76
  AUTHORIZED = "AUTHORIZED",
67
77
  DENIED = "DENIED"
68
78
  }
79
+ export interface OpenIdConfiguration {
80
+ issuer?: string;
81
+ authorization_endpoint?: string;
82
+ introspection_endpoint?: string;
83
+ token_endpoint?: string;
84
+ userinfo_endpoint?: string;
85
+ end_session_endpoint?: string;
86
+ revocation_endpoint?: string;
87
+ scopes_supported?: string[];
88
+ code_challenge_methods_supported?: string[];
89
+ }
90
+ export interface UserInfo {
91
+ email?: string;
92
+ email_verified?: boolean;
93
+ family_name?: string;
94
+ given_name?: string;
95
+ name?: string;
96
+ preferred_username?: string;
97
+ sub?: string;
98
+ address?: object;
99
+ }
100
+ export interface IntrospectInfo extends UserInfo {
101
+ active: boolean;
102
+ scope: string;
103
+ client_id?: string;
104
+ username: string;
105
+ exp: number;
106
+ }
@@ -1,5 +1,14 @@
1
1
  import { ModuleWithProviders } from '@angular/core';
2
2
  import { OAuthConfig } from './models';
3
+ import * as i0 from "@angular/core";
4
+ import * as i1 from "./components/login/oauth-login.component";
5
+ import * as i2 from "@angular/common";
6
+ import * as i3 from "@angular/forms";
7
+ import * as i4 from "@angular/common/http";
8
+ import * as i5 from "@angular/router";
3
9
  export declare class OAuthModule {
4
10
  static forRoot(config: OAuthConfig): ModuleWithProviders<OAuthModule>;
11
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuthModule, never>;
12
+ static ɵmod: i0.ɵɵNgModuleDeclaration<OAuthModule, [typeof i1.OAuthLoginComponent], [typeof i2.CommonModule, typeof i3.FormsModule, typeof i4.HttpClientModule, typeof i5.RouterModule], [typeof i1.OAuthLoginComponent]>;
13
+ static ɵinj: i0.ɵɵInjectorDeclaration<OAuthModule>;
5
14
  }
@@ -1,9 +1,12 @@
1
1
  import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http';
2
2
  import { Observable } from 'rxjs';
3
3
  import { OAuthService } from './oauth.service';
4
+ import * as i0 from "@angular/core";
4
5
  export declare class OAuthInterceptor implements HttpInterceptor {
5
6
  private oauthService;
6
7
  constructor(oauthService: OAuthService);
7
8
  intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
8
9
  private isPathExcepted;
10
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuthInterceptor, never>;
11
+ static ɵprov: i0.ɵɵInjectableDeclaration<OAuthInterceptor>;
9
12
  }
@@ -1,20 +1,33 @@
1
1
  import { NgZone } from '@angular/core';
2
2
  import { HttpClient } from '@angular/common/http';
3
- import { ReplaySubject } from 'rxjs';
4
- import { OAuthConfig, OAuthParameters, OAuthStatus, OAuthToken, OAuthType, OAuthTypeConfig } from '../models';
3
+ import { Observable, ReplaySubject } from 'rxjs';
4
+ import { OAuthConfig, OAuthParameters, OAuthStatus, OAuthToken, OAuthType, OAuthTypeConfig, UserInfo } from '../models';
5
+ import { Location as Location2 } from '@angular/common';
6
+ import * as i0 from "@angular/core";
5
7
  export declare class OAuthService {
6
8
  private http;
7
9
  private zone;
8
10
  private authConfig;
11
+ private location;
9
12
  private locationService;
10
13
  private _token;
11
14
  private _status;
12
15
  private timer;
13
16
  state$: ReplaySubject<string>;
14
17
  status$: ReplaySubject<OAuthStatus>;
15
- constructor(http: HttpClient, zone: NgZone, authConfig: OAuthConfig, locationService: Location);
18
+ userInfo$: Observable<UserInfo>;
19
+ constructor(http: HttpClient, zone: NgZone, authConfig: OAuthConfig, location: Location, locationService: Location2);
20
+ /**
21
+ * Get the oauth config for initialize. If OpenId with issuerPath is configured then configure from server openid configuration.
22
+ * @protected
23
+ */
24
+ protected get config$(): Observable<OAuthTypeConfig>;
25
+ /**
26
+ * Init. Will check the url implicit or authorization flow or existing saved token.
27
+ * @protected
28
+ */
16
29
  protected init(): void;
17
- login(parameters?: OAuthParameters): void;
30
+ login(parameters?: OAuthParameters): Promise<void>;
18
31
  logout(): void;
19
32
  revoke(): void;
20
33
  get status(): OAuthStatus;
@@ -31,10 +44,15 @@ export declare class OAuthService {
31
44
  private isImplicitType;
32
45
  private isAuthorizationCodeType;
33
46
  private toAuthorizationUrl;
47
+ private generateCodeChallenge;
48
+ private generateNonce;
49
+ private checkResponse;
34
50
  set token(token: OAuthToken | null);
35
51
  get token(): OAuthToken | null;
36
52
  private refreshToken;
37
53
  private getCleanedUnSearchParameters;
38
54
  private cleanLocationHash;
39
55
  private emitState;
56
+ static ɵfac: i0.ɵɵFactoryDeclaration<OAuthService, never>;
57
+ static ɵprov: i0.ɵɵInjectableDeclaration<OAuthService>;
40
58
  }
package/ngx-oauth.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  /**
2
2
  * Generated bundle index. Do not edit.
3
3
  */
4
+ /// <amd-module name="ngx-oauth" />
4
5
  export * from './index';
package/package.json CHANGED
@@ -1,19 +1,52 @@
1
1
  {
2
2
  "name": "ngx-oauth",
3
- "version": "1.1.0",
3
+ "version": "2.1.2",
4
+ "author": "Fl0r14n <florian.chis@gmail.com>",
5
+ "homepage": "https://github.com/Fl0r14n/ngx-oauth",
6
+ "description": "A fully OAuth2.1 compliant angular library",
7
+ "license": "MIT",
8
+ "keywords": [
9
+ "angular",
10
+ "angular13",
11
+ "Angular 13",
12
+ "ng2",
13
+ "oauth",
14
+ "oauth2",
15
+ "oidc",
16
+ "pkce",
17
+ "authorization",
18
+ "openid",
19
+ "openid connect"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/Fl0r14n/ngx-oauth"
24
+ },
4
25
  "peerDependencies": {
5
- "@angular/common": "^12.0.0",
6
- "@angular/core": "^12.0.0"
26
+ "@angular/common": "^13.0.0",
27
+ "@angular/core": "^13.0.0"
7
28
  },
8
29
  "dependencies": {
9
30
  "tslib": "^2.0.0"
10
31
  },
11
- "main": "bundles/ngx-oauth.umd.js",
12
- "module": "fesm2015/ngx-oauth.js",
13
- "es2015": "fesm2015/ngx-oauth.js",
14
- "esm2015": "esm2015/ngx-oauth.js",
15
- "fesm2015": "fesm2015/ngx-oauth.js",
32
+ "module": "fesm2015/ngx-oauth.mjs",
33
+ "es2020": "fesm2020/ngx-oauth.mjs",
34
+ "esm2020": "esm2020/ngx-oauth.mjs",
35
+ "fesm2020": "fesm2020/ngx-oauth.mjs",
36
+ "fesm2015": "fesm2015/ngx-oauth.mjs",
16
37
  "typings": "ngx-oauth.d.ts",
17
- "metadata": "ngx-oauth.metadata.json",
38
+ "exports": {
39
+ "./package.json": {
40
+ "default": "./package.json"
41
+ },
42
+ ".": {
43
+ "types": "./ngx-oauth.d.ts",
44
+ "esm2020": "./esm2020/ngx-oauth.mjs",
45
+ "es2020": "./fesm2020/ngx-oauth.mjs",
46
+ "es2015": "./fesm2015/ngx-oauth.mjs",
47
+ "node": "./fesm2015/ngx-oauth.mjs",
48
+ "default": "./fesm2020/ngx-oauth.mjs"
49
+ }
50
+ },
18
51
  "sideEffects": false
19
52
  }