angular2-jwt
Advanced tools
Comparing version 0.1.27 to 0.1.28
@@ -1,6 +0,6 @@ | ||
import { Provider } from '@angular/core'; | ||
import { Http, Request, RequestOptions, RequestOptionsArgs, Response } from '@angular/http'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import 'rxjs/add/observable/fromPromise'; | ||
import 'rxjs/add/operator/mergeMap'; | ||
import { Http, Request, RequestOptions, RequestOptionsArgs, Response } from "@angular/http"; | ||
import { Provider, ModuleWithProviders } from "@angular/core"; | ||
import { Observable } from "rxjs/Observable"; | ||
import "rxjs/add/observable/fromPromise"; | ||
import "rxjs/add/operator/mergeMap"; | ||
export interface IAuthConfig { | ||
@@ -81,1 +81,9 @@ globalHeaders: Array<Object>; | ||
export declare function provideAuth(config?: IAuthConfigOptional): Provider[]; | ||
/** | ||
* Module for angular2-jwt | ||
* @experimental | ||
*/ | ||
export declare class AuthModule { | ||
constructor(parentModule: AuthModule); | ||
static forRoot(config: AuthConfig): ModuleWithProviders; | ||
} |
@@ -16,4 +16,7 @@ "use strict"; | ||
}; | ||
var __param = (this && this.__param) || function (paramIndex, decorator) { | ||
return function (target, key) { decorator(target, key, paramIndex); } | ||
}; | ||
var http_1 = require("@angular/http"); | ||
var core_1 = require("@angular/core"); | ||
var http_1 = require("@angular/http"); | ||
var Observable_1 = require("rxjs/Observable"); | ||
@@ -25,7 +28,7 @@ require("rxjs/add/observable/fromPromise"); | ||
} | ||
AuthConfigConsts.DEFAULT_TOKEN_NAME = 'id_token'; | ||
AuthConfigConsts.DEFAULT_HEADER_NAME = 'Authorization'; | ||
AuthConfigConsts.HEADER_PREFIX_BEARER = 'Bearer '; | ||
return AuthConfigConsts; | ||
}()); | ||
AuthConfigConsts.DEFAULT_TOKEN_NAME = 'id_token'; | ||
AuthConfigConsts.DEFAULT_HEADER_NAME = 'Authorization'; | ||
AuthConfigConsts.HEADER_PREFIX_BEARER = 'Bearer '; | ||
exports.AuthConfigConsts = AuthConfigConsts; | ||
@@ -71,3 +74,3 @@ var AuthConfigDefaults = { | ||
function AuthHttpError() { | ||
return _super.apply(this, arguments) || this; | ||
_super.apply(this, arguments); | ||
} | ||
@@ -167,8 +170,8 @@ return AuthHttpError; | ||
}; | ||
AuthHttp = __decorate([ | ||
core_1.Injectable(), | ||
__metadata('design:paramtypes', [AuthConfig, http_1.Http, http_1.RequestOptions]) | ||
], AuthHttp); | ||
return AuthHttp; | ||
}()); | ||
AuthHttp = __decorate([ | ||
core_1.Injectable(), | ||
__metadata("design:paramtypes", [AuthConfig, http_1.Http, http_1.RequestOptions]) | ||
], AuthHttp); | ||
exports.AuthHttp = AuthHttp; | ||
@@ -209,5 +212,3 @@ /** | ||
} | ||
for ( | ||
// initialize result and counters | ||
var bc = 0, bs = void 0, buffer = void 0, idx = 0; | ||
for (var bc = 0, bs = void 0, buffer = void 0, idx = 0; | ||
// get next character | ||
@@ -330,2 +331,32 @@ buffer = str.charAt(idx++); | ||
} | ||
/** | ||
* Module for angular2-jwt | ||
* @experimental | ||
*/ | ||
var AuthModule = (function () { | ||
function AuthModule(parentModule) { | ||
if (parentModule) { | ||
throw new Error('AuthModule is already loaded. Import it in the AppModule only'); | ||
} | ||
} | ||
AuthModule.forRoot = function (config) { | ||
return { | ||
ngModule: AuthModule, | ||
providers: [ | ||
{ provide: AuthConfig, useValue: config } | ||
] | ||
}; | ||
}; | ||
AuthModule = __decorate([ | ||
core_1.NgModule({ | ||
imports: [http_1.HttpModule], | ||
providers: [AuthHttp, JwtHelper] | ||
}), | ||
__param(0, core_1.Optional()), | ||
__param(0, core_1.SkipSelf()), | ||
__metadata('design:paramtypes', [AuthModule]) | ||
], AuthModule); | ||
return AuthModule; | ||
}()); | ||
exports.AuthModule = AuthModule; | ||
//# sourceMappingURL=angular2-jwt.js.map |
{ | ||
"name": "angular2-jwt", | ||
"version": "0.1.27", | ||
"version": "0.1.28", | ||
"description": "Helper library for handling JWTs in Angular 2", | ||
@@ -12,3 +12,4 @@ "repository": { | ||
"test": "karma start", | ||
"prepublish": "tsc" | ||
"prepublish": "tsc", | ||
"ngc":"ngc" | ||
}, | ||
@@ -28,8 +29,11 @@ "keywords": [ | ||
"typings": "./angular2-jwt.d.ts", | ||
"types": "./angular2-jwt.d.ts", | ||
"homepage": "https://github.com/auth0/angular2-jwt#readme", | ||
"devDependencies": { | ||
"@angular/common": "^2.0.0", | ||
"@angular/core": "^2.0.0", | ||
"@angular/http": "^2.0.0", | ||
"@angular/platform-browser": "^2.0.0", | ||
"@angular/common": "^2.4.2", | ||
"@angular/compiler": "^2.4.2", | ||
"@angular/compiler-cli": "^2.4.2", | ||
"@angular/core": "^2.4.2", | ||
"@angular/http": "^2.4.2", | ||
"@angular/platform-browser": "^2.4.2", | ||
"@types/jasmine": "^2.2.33", | ||
@@ -50,5 +54,5 @@ "@types/js-base64": "^2.1.3", | ||
"rxjs": "~5.0.0-beta.12", | ||
"typescript": "^2.0.2", | ||
"typescript": ">=2.0.2 <=2.0.10", | ||
"webpack": "^1.13.0", | ||
"zone.js": "~0.6.12" | ||
"zone.js": "~0.7.2" | ||
}, | ||
@@ -58,4 +62,4 @@ "peerDependencies": { | ||
"@angular/http": "^2.0.0", | ||
"rxjs": "5.0.0-beta.12" | ||
"rxjs": "^5.0.0" | ||
} | ||
} |
@@ -129,3 +129,3 @@ # angular2-jwt | ||
You may customize any of the above options using `provideAuth` in the `providers` array in your `@NgModule`. | ||
You may customize any of the above options using a factory which returns an `AuthHttp` instance with the options you would like to change. | ||
@@ -136,20 +136,21 @@ ```ts | ||
... | ||
export function authHttpServiceFactory(http: Http, options: RequestOptions) { | ||
return new AuthHttp(new AuthConfig({ | ||
tokenName: 'token', | ||
tokenGetter: (() => sessionStorage.getItem('token')), | ||
globalHeaders: [{'Content-Type':'application/json'}], | ||
}), http, options); | ||
} | ||
@NgModule({ | ||
... | ||
// ... | ||
providers: [ | ||
provideAuth({ | ||
headerName: YOUR_HEADER_NAME, | ||
headerPrefix: YOUR_HEADER_PREFIX, | ||
tokenName: YOUR_TOKEN_NAME, | ||
tokenGetter: YOUR_TOKEN_GETTER_FUNCTION, | ||
globalHeaders: [{'Content-Type':'application/json'}], | ||
noJwtError: true, | ||
noTokenScheme: true | ||
}) | ||
], | ||
... | ||
// ... | ||
{ | ||
provide: AuthHttp, | ||
useFactory: authHttpServiceFactory, | ||
deps: [Http, RequestOptions] | ||
} | ||
] | ||
}) | ||
@@ -156,0 +157,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
44241
450
388
24