@auth0/auth0-angular 1.8.2 → 1.10.1
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.
- package/README.md +31 -4
- package/auth0-auth0-angular.metadata.json +1 -1
- package/bundles/auth0-auth0-angular.umd.js +60 -4
- package/bundles/auth0-auth0-angular.umd.js.map +1 -1
- package/esm2015/lib/auth.client.js +5 -2
- package/esm2015/lib/auth.config.js +1 -1
- package/esm2015/lib/auth.service.js +45 -3
- package/esm2015/useragent.js +2 -2
- package/fesm2015/auth0-auth0-angular.js +48 -3
- package/fesm2015/auth0-auth0-angular.js.map +1 -1
- package/lib/auth.config.d.ts +21 -0
- package/lib/auth.service.d.ts +41 -3
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -208,6 +208,36 @@ export class AppRoutingModule {}
|
|
|
208
208
|
|
|
209
209
|
The SDK provides an `HttpInterceptor` that automatically attaches access tokens to outgoing requests when using the built-in `HttpClient`. However, you must provide configuration that tells the interceptor which requests to attach access tokens to.
|
|
210
210
|
|
|
211
|
+
#### Specify the Audience
|
|
212
|
+
In order for Auth0 to be able to issue tokens for a specific API, we need to configure the Audience to inform Auth0 about the API in question.
|
|
213
|
+
Set the `audience`, when calling `AuthModule.forRoot()`, to the **API Identifier** of the API from within your Auth0 dashboard.
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
import { BrowserModule } from '@angular/platform-browser';
|
|
217
|
+
import { NgModule } from '@angular/core';
|
|
218
|
+
import { AppComponent } from './app.component';
|
|
219
|
+
|
|
220
|
+
// Import the module from the SDK
|
|
221
|
+
import { AuthModule } from '@auth0/auth0-angular';
|
|
222
|
+
|
|
223
|
+
@NgModule({
|
|
224
|
+
declarations: [AppComponent],
|
|
225
|
+
imports: [
|
|
226
|
+
BrowserModule,
|
|
227
|
+
|
|
228
|
+
// Import the module into the application, with configuration
|
|
229
|
+
AuthModule.forRoot({
|
|
230
|
+
domain: 'YOUR_AUTH0_DOMAIN',
|
|
231
|
+
clientId: 'YOUR_AUTH0_CLIENT_ID',
|
|
232
|
+
audience: 'YOUR_AUTH0_API_IDENTIFIER',
|
|
233
|
+
}),
|
|
234
|
+
],
|
|
235
|
+
|
|
236
|
+
bootstrap: [AppComponent],
|
|
237
|
+
})
|
|
238
|
+
export class AppModule {}
|
|
239
|
+
```
|
|
240
|
+
|
|
211
241
|
#### Register AuthHttpInterceptor
|
|
212
242
|
|
|
213
243
|
First, register the interceptor with your application module, along with the `HttpClientModule`.
|
|
@@ -252,10 +282,7 @@ import { HttpMethod } from '@auth0/auth0-angular';
|
|
|
252
282
|
|
|
253
283
|
// Modify your existing SDK configuration to include the httpInterceptor config
|
|
254
284
|
AuthModule.forRoot({
|
|
255
|
-
|
|
256
|
-
clientId: 'YOUR_AUTH0_CLIENT_ID',
|
|
257
|
-
redirectUri: window.location.origin,
|
|
258
|
-
|
|
285
|
+
...
|
|
259
286
|
// The AuthHttpInterceptor configuration
|
|
260
287
|
httpInterceptor: {
|
|
261
288
|
allowedList: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"__symbolic":"module","version":4,"exports":[{"export":[{"name":"ICache","as":"ICache"},{"name":"Cacheable","as":"Cacheable"},{"name":"LocalStorageCache","as":"LocalStorageCache"},{"name":"InMemoryCache","as":"InMemoryCache"},{"name":"IdToken","as":"IdToken"},{"name":"User","as":"User"}],"from":"@auth0/auth0-spa-js"}],"metadata":{"AuthService":{"__symbolic":"class","arity":1,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":
|
|
1
|
+
{"__symbolic":"module","version":4,"exports":[{"export":[{"name":"ICache","as":"ICache"},{"name":"Cacheable","as":"Cacheable"},{"name":"LocalStorageCache","as":"LocalStorageCache"},{"name":"InMemoryCache","as":"InMemoryCache"},{"name":"IdToken","as":"IdToken"},{"name":"User","as":"User"}],"from":"@auth0/auth0-spa-js"}],"metadata":{"AuthService":{"__symbolic":"class","arity":1,"decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":45,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":87,"character":5},"arguments":[{"__symbolic":"reference","name":"Auth0ClientService"}]}],null,null,null],"parameters":[{"__symbolic":"reference","module":"@auth0/auth0-spa-js","name":"Auth0Client","line":87,"character":53},{"__symbolic":"reference","name":"AuthClientConfig"},{"__symbolic":"reference","name":"ɵa"},{"__symbolic":"reference","name":"AuthState"}]}],"ngOnDestroy":[{"__symbolic":"method"}],"loginWithRedirect":[{"__symbolic":"method"}],"loginWithPopup":[{"__symbolic":"method"}],"logout":[{"__symbolic":"method"}],"getAccessTokenSilently":[{"__symbolic":"method"},{"__symbolic":"method"},{"__symbolic":"method"}],"getAccessTokenWithPopup":[{"__symbolic":"method"}],"getUser":[{"__symbolic":"method"}],"getIdTokenClaims":[{"__symbolic":"method"}],"handleRedirectCallback":[{"__symbolic":"method"}],"buildAuthorizeUrl":[{"__symbolic":"method"}],"buildLogoutUrl":[{"__symbolic":"method"}],"shouldHandleCallback":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"AuthModule":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"NgModule","line":6,"character":1}}],"members":{},"statics":{"forRoot":{"__symbolic":"function","parameters":["config"],"value":{"ngModule":{"__symbolic":"reference","name":"AuthModule"},"providers":[{"__symbolic":"reference","name":"AuthService"},{"__symbolic":"reference","name":"AuthGuard"},{"provide":{"__symbolic":"reference","name":"AuthConfigService"},"useValue":{"__symbolic":"reference","name":"config"}},{"provide":{"__symbolic":"reference","name":"Auth0ClientService"},"useFactory":{"__symbolic":"select","expression":{"__symbolic":"reference","name":"Auth0ClientFactory"},"member":"createClient"},"deps":[{"__symbolic":"reference","name":"AuthClientConfig"}]}]}}}},"AuthGuard":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":14,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"AuthService"}]}],"canLoad":[{"__symbolic":"method"}],"canActivate":[{"__symbolic":"method"}],"canActivateChild":[{"__symbolic":"method"}],"redirectIfUnauthenticated":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"AuthHttpInterceptor":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":29,"character":1}}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[null,[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":33,"character":5},"arguments":[{"__symbolic":"reference","name":"Auth0ClientService"}]}],null],"parameters":[{"__symbolic":"reference","name":"AuthClientConfig"},{"__symbolic":"reference","module":"@auth0/auth0-spa-js","name":"Auth0Client","line":33,"character":53},{"__symbolic":"reference","name":"AuthState"}]}],"intercept":[{"__symbolic":"method"}],"getAccessTokenSilently":[{"__symbolic":"method"}],"stripQueryFrom":[{"__symbolic":"method"}],"canAttachToken":[{"__symbolic":"method"}],"findMatchingRoute":[{"__symbolic":"method"}],"allowAnonymous":[{"__symbolic":"method"}]}},"HttpMethod":{"Get":"GET","Post":"POST","Put":"PUT","Patch":"PATCH","Delete":"DELETE","Head":"HEAD"},"ApiRouteDefinition":{"__symbolic":"interface"},"isHttpInterceptorRouteConfig":{"__symbolic":"function","parameters":["def"],"value":{"__symbolic":"binop","operator":"!==","left":{"__symbolic":"error","message":"Expression form not supported","line":35,"character":9,"module":"./lib/auth.config"},"right":"string"}},"HttpInterceptorConfig":{"__symbolic":"interface"},"HttpInterceptorRouteConfig":{"__symbolic":"interface"},"AuthConfig":{"__symbolic":"interface"},"AppState":{"__symbolic":"interface"},"AuthClientConfig":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":345,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Optional","line":349,"character":15}},{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":349,"character":27},"arguments":[{"__symbolic":"reference","name":"AuthConfigService"}]}]],"parameters":[{"__symbolic":"reference","name":"any"}]}],"set":[{"__symbolic":"method"}],"get":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"AuthConfigService":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":382,"character":37},"arguments":["auth0-angular.config"]},"Auth0ClientFactory":{"__symbolic":"class","members":{}},"Auth0ClientService":{"__symbolic":"new","expression":{"__symbolic":"reference","module":"@angular/core","name":"InjectionToken","line":33,"character":38},"arguments":["auth0.client"]},"AuthState":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":24,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameterDecorators":[[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Inject","line":112,"character":15},"arguments":[{"__symbolic":"reference","name":"Auth0ClientService"}]}]],"parameters":[{"__symbolic":"reference","module":"@auth0/auth0-spa-js","name":"Auth0Client","line":112,"character":63}]}],"setIsLoading":[{"__symbolic":"method"}],"refresh":[{"__symbolic":"method"}],"setAccessToken":[{"__symbolic":"method"}],"setError":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}},"ɵa":{"__symbolic":"class","decorators":[{"__symbolic":"call","expression":{"__symbolic":"reference","module":"@angular/core","name":"Injectable","line":4,"character":1},"arguments":[{"providedIn":"root"}]}],"members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","module":"@angular/common","name":"Location","line":10,"character":32},{"__symbolic":"reference","module":"@angular/core","name":"Injector","line":10,"character":52}]}],"navigateByUrl":[{"__symbolic":"method"}]},"statics":{"ɵprov":{}}}},"origins":{"AuthService":"./lib/auth.service","AuthModule":"./lib/auth.module","AuthGuard":"./lib/auth.guard","AuthHttpInterceptor":"./lib/auth.interceptor","HttpMethod":"./lib/auth.config","ApiRouteDefinition":"./lib/auth.config","isHttpInterceptorRouteConfig":"./lib/auth.config","HttpInterceptorConfig":"./lib/auth.config","HttpInterceptorRouteConfig":"./lib/auth.config","AuthConfig":"./lib/auth.config","AppState":"./lib/auth.config","AuthClientConfig":"./lib/auth.config","AuthConfigService":"./lib/auth.config","Auth0ClientFactory":"./lib/auth.client","Auth0ClientService":"./lib/auth.client","AuthState":"./lib/auth.state","ɵa":"./lib/abstract-navigator"},"importAs":"@auth0/auth0-angular"}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
|
|
28
28
|
var i1__namespace = /*#__PURE__*/_interopNamespace(i1);
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
/******************************************************************************
|
|
31
31
|
Copyright (c) Microsoft Corporation.
|
|
32
32
|
|
|
33
33
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -189,7 +189,11 @@
|
|
|
189
189
|
var __createBinding = Object.create ? (function (o, m, k, k2) {
|
|
190
190
|
if (k2 === undefined)
|
|
191
191
|
k2 = k;
|
|
192
|
-
Object.
|
|
192
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
193
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
194
|
+
desc = { enumerable: true, get: function () { return m[k]; } };
|
|
195
|
+
}
|
|
196
|
+
Object.defineProperty(o, k2, desc);
|
|
193
197
|
}) : (function (o, m, k, k2) {
|
|
194
198
|
if (k2 === undefined)
|
|
195
199
|
k2 = k;
|
|
@@ -344,8 +348,13 @@
|
|
|
344
348
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
345
349
|
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
346
350
|
}
|
|
351
|
+
function __classPrivateFieldIn(state, receiver) {
|
|
352
|
+
if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function"))
|
|
353
|
+
throw new TypeError("Cannot use 'in' operator on non-object");
|
|
354
|
+
return typeof state === "function" ? receiver === state : state.has(receiver);
|
|
355
|
+
}
|
|
347
356
|
|
|
348
|
-
var useragent = { name: '@auth0/auth0-angular', version: '1.
|
|
357
|
+
var useragent = { name: '@auth0/auth0-angular', version: '1.10.1' };
|
|
349
358
|
|
|
350
359
|
var Auth0ClientFactory = /** @class */ (function () {
|
|
351
360
|
function Auth0ClientFactory() {
|
|
@@ -359,6 +368,9 @@
|
|
|
359
368
|
return new auth0SpaJs.Auth0Client(Object.assign(Object.assign({ redirect_uri: redirectUri || window.location.origin, client_id: clientId, max_age: maxAge }, rest), { auth0Client: {
|
|
360
369
|
name: useragent.name,
|
|
361
370
|
version: useragent.version,
|
|
371
|
+
env: {
|
|
372
|
+
'angular/core': i0.VERSION.full,
|
|
373
|
+
},
|
|
362
374
|
} }));
|
|
363
375
|
};
|
|
364
376
|
return Auth0ClientFactory;
|
|
@@ -625,8 +637,8 @@
|
|
|
625
637
|
this.shouldHandleCallback()
|
|
626
638
|
.pipe(operators.switchMap(function (isCallback) { return checkSessionOrCallback$(isCallback).pipe(operators.catchError(function (error) {
|
|
627
639
|
var config = _this.configFactory.get();
|
|
628
|
-
_this.authState.setError(error);
|
|
629
640
|
_this.navigator.navigateByUrl(config.errorPath || '/');
|
|
641
|
+
_this.authState.setError(error);
|
|
630
642
|
return rxjs.of(undefined);
|
|
631
643
|
})); }), operators.tap(function () {
|
|
632
644
|
_this.authState.setIsLoading(false);
|
|
@@ -760,6 +772,50 @@
|
|
|
760
772
|
return rxjs.throwError(error);
|
|
761
773
|
}));
|
|
762
774
|
};
|
|
775
|
+
/**
|
|
776
|
+
* ```js
|
|
777
|
+
* getUser(options).subscribe(user => ...);
|
|
778
|
+
* ```
|
|
779
|
+
*
|
|
780
|
+
* Returns the user information if available (decoded
|
|
781
|
+
* from the `id_token`).
|
|
782
|
+
*
|
|
783
|
+
* If you provide an audience or scope, they should match an existing Access Token
|
|
784
|
+
* (the SDK stores a corresponding ID Token with every Access Token, and uses the
|
|
785
|
+
* scope and audience to look up the ID Token)
|
|
786
|
+
*
|
|
787
|
+
* @remarks
|
|
788
|
+
*
|
|
789
|
+
* The returned observable will emit once and then complete.
|
|
790
|
+
*
|
|
791
|
+
* @typeparam TUser The type to return, has to extend {@link User}.
|
|
792
|
+
* @param options The options to get the user
|
|
793
|
+
*/
|
|
794
|
+
AuthService.prototype.getUser = function (options) {
|
|
795
|
+
var _this = this;
|
|
796
|
+
return rxjs.defer(function () { return _this.auth0Client.getUser(options); });
|
|
797
|
+
};
|
|
798
|
+
/**
|
|
799
|
+
* ```js
|
|
800
|
+
* getIdTokenClaims(options).subscribe(claims => ...);
|
|
801
|
+
* ```
|
|
802
|
+
*
|
|
803
|
+
* Returns all claims from the id_token if available.
|
|
804
|
+
*
|
|
805
|
+
* If you provide an audience or scope, they should match an existing Access Token
|
|
806
|
+
* (the SDK stores a corresponding ID Token with every Access Token, and uses the
|
|
807
|
+
* scope and audience to look up the ID Token)
|
|
808
|
+
*
|
|
809
|
+
* @remarks
|
|
810
|
+
*
|
|
811
|
+
* The returned observable will emit once and then complete.
|
|
812
|
+
*
|
|
813
|
+
* @param options The options to get the Id token claims
|
|
814
|
+
*/
|
|
815
|
+
AuthService.prototype.getIdTokenClaims = function (options) {
|
|
816
|
+
var _this = this;
|
|
817
|
+
return rxjs.defer(function () { return _this.auth0Client.getIdTokenClaims(options); });
|
|
818
|
+
};
|
|
763
819
|
/**
|
|
764
820
|
* ```js
|
|
765
821
|
* handleRedirectCallback(url).subscribe(result => ...)
|