Socket
Socket
Sign inDemoInstall

@http-ext/plugin-auth

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@http-ext/plugin-auth - npm Package Compare versions

Comparing version 1.2.0 to 2.0.0

6

bundles/http-ext-plugin-auth.umd.js

@@ -324,3 +324,3 @@ (function (global, factory) {

/** @type {?|undefined} */
AuthPluginOptions.prototype.condition;
AuthPluginOptions.prototype.shouldHandleRequest;
}

@@ -332,5 +332,5 @@ /**

function createAuthPlugin(_a) {
var condition = _a.condition, token = _a.token, onUnauthorized = _a.onUnauthorized;
var shouldHandleRequest = _a.shouldHandleRequest, token = _a.token, onUnauthorized = _a.onUnauthorized;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new AuthHandler({

@@ -337,0 +337,0 @@ token: token,

@@ -1,2 +0,2 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@http-ext/plugin-auth",["exports","rxjs","rxjs/operators"],e):e(((t=t||self)["http-ext"]=t["http-ext"]||{},t["http-ext"]["plugin-auth"]={}),t.rxjs,t.rxjs.operators)}(this,(function(t,e,n){"use strict";
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("rxjs"),require("rxjs/operators")):"function"==typeof define&&define.amd?define("@http-ext/plugin-auth",["exports","rxjs","rxjs/operators"],t):t(((e=e||self)["http-ext"]=e["http-ext"]||{},e["http-ext"]["plugin-auth"]={}),e.rxjs,e.rxjs.operators)}(this,(function(e,t,n){"use strict";
/*! *****************************************************************************

@@ -15,3 +15,3 @@ Copyright (c) Microsoft Corporation. All rights reserved.

and limitations under the License.
***************************************************************************** */var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};var o=function(){function t(t){var e=t.token,n=t.onUnauthorized;this._token$=e,this._onUnauthorized=n}return t.prototype.handle=function(t){var o=this,u=t.request,i=t.next;return e.defer((function(){return o._token$.pipe(n.first(),n.map((function(t){return function(t){var e,n=t.request,o=t.key,u=t.value;return r(r({},n),{headers:r(r({},n.headers),(e={},e[o]=u,e))})}({request:u,key:"Authorization",value:"Bearer "+t})})),n.switchMap((function(t){return i({request:t})})),n.tap((function(t){401===t.status&&o._onUnauthorized&&o._onUnauthorized(t)})))}))},t}();t.createAuthPlugin=function(t){var e=t.condition,n=t.token,r=t.onUnauthorized;return{condition:e,handler:new o({token:n,onUnauthorized:r})}},t.ɵa=o,Object.defineProperty(t,"__esModule",{value:!0})}));
***************************************************************************** */var r=function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)};var o=function(){function e(e){var t=e.token,n=e.onUnauthorized;this._token$=t,this._onUnauthorized=n}return e.prototype.handle=function(e){var o=this,u=e.request,i=e.next;return t.defer((function(){return o._token$.pipe(n.first(),n.map((function(e){return function(e){var t,n=e.request,o=e.key,u=e.value;return r(r({},n),{headers:r(r({},n.headers),(t={},t[o]=u,t))})}({request:u,key:"Authorization",value:"Bearer "+e})})),n.switchMap((function(e){return i({request:e})})),n.tap((function(e){401===e.status&&o._onUnauthorized&&o._onUnauthorized(e)})))}))},e}();e.createAuthPlugin=function(e){var t=e.shouldHandleRequest,n=e.token,r=e.onUnauthorized;return{shouldHandleRequest:t,handler:new o({token:n,onUnauthorized:r})}},e.ɵa=o,Object.defineProperty(e,"__esModule",{value:!0})}));
//# sourceMappingURL=http-ext-plugin-auth.umd.min.js.map

@@ -6,2 +6,20 @@ # Change Log

# [2.0.0](https://github.com/jscutlery/http-ext/compare/v1.0.0...v2.0.0) (2020-04-01)
### Features
* ✅ rename `condition` to `shouldHandleRequest` ([9e93b5d](https://github.com/jscutlery/http-ext/commit/9e93b5d20e4c3cb0ef94b5b6a1440565b685b6c7))
### BREAKING CHANGES
* rename `condition` to `shouldHandleRequest`
Co-authored-by: Edouard Bozon <bozonedouard@gmail.com>
# [1.2.0](https://github.com/jscutlery/http-ext/compare/v1.1.0...v1.2.0) (2020-03-31)

@@ -8,0 +26,0 @@

@@ -13,3 +13,3 @@ /**

/** @type {?|undefined} */
AuthPluginOptions.prototype.condition;
AuthPluginOptions.prototype.shouldHandleRequest;
}

@@ -20,5 +20,5 @@ /**

*/
export function createAuthPlugin({ condition, token, onUnauthorized }) {
export function createAuthPlugin({ shouldHandleRequest, token, onUnauthorized }) {
return {
condition,
shouldHandleRequest,
handler: new AuthHandler({

@@ -30,2 +30,2 @@ token,

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWF1dGgtcGx1Z2luLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGh0dHAtZXh0L3BsdWdpbi1hdXRoLyIsInNvdXJjZXMiOlsibGliL2NyZWF0ZS1hdXRoLXBsdWdpbi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUVBLE9BQU8sRUFBRSxXQUFXLEVBQWtCLE1BQU0sZ0JBQWdCLENBQUM7Ozs7QUFFN0QsdUNBRUM7OztJQURDLHNDQUE2Qjs7Ozs7O0FBRy9CLE1BQU0sVUFBVSxnQkFBZ0IsQ0FBQyxFQUMvQixTQUFTLEVBQ1QsS0FBSyxFQUNMLGNBQWMsRUFDSTtJQUNsQixPQUFPO1FBQ0wsU0FBUztRQUNULE9BQU8sRUFBRSxJQUFJLFdBQVcsQ0FBQztZQUN2QixLQUFLO1lBQ0wsY0FBYztTQUNmLENBQUM7S0FDSCxDQUFDO0FBQ0osQ0FBQyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IFJlcXVlc3RDb25kaXRpb24gfSBmcm9tICdAaHR0cC1leHQvY29yZSc7XG5cbmltcG9ydCB7IEF1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JjZXNDb250ZW50IjpbImltcG9ydCB7IFJlcXVlc3RDb25kaXRpb24gfSBmcm9tICdAaHR0cC1leHQvY29yZSc7XG5cbmltcG9ydCB7IEF1dGhIYW5kbGVyLCBIYW5kbGVyT3B0aW9ucyB9IGZyb20gJy4vYXV0aC1oYW5kbGVyJztcblxuZXhwb3J0IGludGVyZmFjZSBBdXRoUGx1Z2luT3B0aW9ucyBleHRlbmRzIEhhbmRsZXJPcHRpb25zIHtcbiAgc2hvdWxkSGFuZGxlUmVxdWVzdD86IFJlcXVlc3RDb25kaXRpb247XG59XG5cbmV4cG9ydCBmdW5jdGlvbiBjcmVhdGVBdXRoUGx1Z2luKHtcbiAgc2hvdWxkSGFuZGxlUmVxdWVzdCxcbiAgdG9rZW4sXG4gIG9uVW5hdXRob3JpemVkXG59OiBBdXRoUGx1Z2luT3B0aW9ucykge1xuICByZXR1cm4ge1xuICAgIHNob3VsZEhhbmRsZVJlcXVlc3QsXG4gICAgaGFuZGxlcjogbmV3IEF1dGhIYW5kbGVyKHtcbiAgICAgIHRva2VuLFxuICAgICAgb25VbmF1dGhvcml6ZWRcbiAgICB9KVxuICB9O1xufVxuIl19

@@ -13,3 +13,3 @@ /**

/** @type {?|undefined} */
AuthPluginOptions.prototype.condition;
AuthPluginOptions.prototype.shouldHandleRequest;
}

@@ -21,5 +21,5 @@ /**

export function createAuthPlugin(_a) {
var condition = _a.condition, token = _a.token, onUnauthorized = _a.onUnauthorized;
var shouldHandleRequest = _a.shouldHandleRequest, token = _a.token, onUnauthorized = _a.onUnauthorized;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new AuthHandler({

@@ -31,2 +31,2 @@ token: token,

}
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY3JlYXRlLWF1dGgtcGx1Z2luLmpzIiwic291cmNlUm9vdCI6Im5nOi8vQGh0dHAtZXh0L3BsdWdpbi1hdXRoLyIsInNvdXJjZXMiOlsibGliL2NyZW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QsXG4gICAgaGFuZGxlcjogbmV3IEF1dGhIYW5kbGVyKHtcbiAgICAgIHRva2VuLFxuICAgICAgb25VbmF1dGhvcml6ZWRcbiAgICB9KVxuICB9O1xufVxuIl19

@@ -98,3 +98,3 @@ import { defer } from 'rxjs';

/** @type {?|undefined} */
AuthPluginOptions.prototype.condition;
AuthPluginOptions.prototype.shouldHandleRequest;
}

@@ -105,5 +105,5 @@ /**

*/
function createAuthPlugin({ condition, token, onUnauthorized }) {
function createAuthPlugin({ shouldHandleRequest, token, onUnauthorized }) {
return {
condition,
shouldHandleRequest,
handler: new AuthHandler({

@@ -110,0 +110,0 @@ token,

@@ -108,3 +108,3 @@ import { defer } from 'rxjs';

/** @type {?|undefined} */
AuthPluginOptions.prototype.condition;
AuthPluginOptions.prototype.shouldHandleRequest;
}

@@ -116,5 +116,5 @@ /**

function createAuthPlugin(_a) {
var condition = _a.condition, token = _a.token, onUnauthorized = _a.onUnauthorized;
var shouldHandleRequest = _a.shouldHandleRequest, token = _a.token, onUnauthorized = _a.onUnauthorized;
return {
condition: condition,
shouldHandleRequest: shouldHandleRequest,
handler: new AuthHandler({

@@ -121,0 +121,0 @@ token: token,

@@ -1,1 +0,1 @@

{"__symbolic":"module","version":4,"metadata":{"createAuthPlugin":{"__symbolic":"function","parameters":["condition","token","onUnauthorized"],"value":{"condition":{"__symbolic":"reference","name":"condition"},"handler":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"ɵa"},"arguments":[{"token":{"__symbolic":"reference","name":"token"},"onUnauthorized":{"__symbolic":"reference","name":"onUnauthorized"}}]}}},"AuthPluginOptions":{"__symbolic":"interface"},"OnUnauthorized":{"__symbolic":"interface"},"ɵa":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"handle":[{"__symbolic":"method"}]}}},"origins":{"createAuthPlugin":"./lib/create-auth-plugin","AuthPluginOptions":"./lib/create-auth-plugin","OnUnauthorized":"./lib/on-unauthorized","ɵa":"./lib/auth-handler"},"importAs":"@http-ext/plugin-auth"}
{"__symbolic":"module","version":4,"metadata":{"createAuthPlugin":{"__symbolic":"function","parameters":["shouldHandleRequest","token","onUnauthorized"],"value":{"shouldHandleRequest":{"__symbolic":"reference","name":"shouldHandleRequest"},"handler":{"__symbolic":"new","expression":{"__symbolic":"reference","name":"ɵa"},"arguments":[{"token":{"__symbolic":"reference","name":"token"},"onUnauthorized":{"__symbolic":"reference","name":"onUnauthorized"}}]}}},"AuthPluginOptions":{"__symbolic":"interface"},"OnUnauthorized":{"__symbolic":"interface"},"ɵa":{"__symbolic":"class","members":{"__ctor__":[{"__symbolic":"constructor","parameters":[{"__symbolic":"reference","name":"any"}]}],"handle":[{"__symbolic":"method"}]}}},"origins":{"createAuthPlugin":"./lib/create-auth-plugin","AuthPluginOptions":"./lib/create-auth-plugin","OnUnauthorized":"./lib/on-unauthorized","ɵa":"./lib/auth-handler"},"importAs":"@http-ext/plugin-auth"}
import { RequestCondition } from '@http-ext/core';
import { AuthHandler, HandlerOptions } from './auth-handler';
export interface AuthPluginOptions extends HandlerOptions {
condition?: RequestCondition;
shouldHandleRequest?: RequestCondition;
}
export declare function createAuthPlugin({ condition, token, onUnauthorized }: AuthPluginOptions): {
condition: RequestCondition;
export declare function createAuthPlugin({ shouldHandleRequest, token, onUnauthorized }: AuthPluginOptions): {
shouldHandleRequest: RequestCondition;
handler: AuthHandler;
};
{
"name": "@http-ext/plugin-auth",
"version": "1.2.0",
"version": "2.0.0",
"peerDependencies": {

@@ -5,0 +5,0 @@ "@http-ext/core": "^1.0.0",

# @http-ext/plugin-auth
> An auth plugin for [HttpExt](https://github.com/jscutlery/http-ext).
> A auth plugin for [HttpExt](https://github.com/jscutlery/http-ext).

@@ -45,3 +45,3 @@ This plugin takes care of handling authorization by:

createAuthPlugin({
condition: matchOrigin('https://secure-origin.com'),
shouldHandleRequest: matchOrigin('https://secure-origin.com'),
token: authService.getToken(), // Returns an Observable<string>.

@@ -61,8 +61,8 @@ onUnauthorized: () => authService.markTokenExpired()

| Property | Type | Required | Default value | Description |
| ---------------- | -------------------- | ---------| ---------------------------------------| -------------------------------------------------------------------------------------------- |
| `token` | `Observable<string>` | Yes | `undefined` | The bearer token that will be added to every matching request in the `Authorization` header. |
| `onUnauthorized` | `OnUnauthorized` | No | `undefined` | A function executed when an unauthorized response is thrown. |
| `condition` | `RequestCondition` | No | `matchOrigin('https://my-origin.com')` | Predicate function to know which request the plugin should handle. |
| Property | Type | Required | Default value | Description |
| -------------------- | -------------------- | ---------| ---------------------------------------| -------------------------------------------------------------------------------------------- |
| `token` | `Observable<string>` | Yes | `undefined` | The bearer token that will be added to every matching request in the `Authorization` header. |
| `onUnauthorized` | `OnUnauthorized` | No | `undefined` | A function executed when an unauthorized response is thrown. |
| `shouldHandleRequest`| `RequestCondition` | No | `matchOrigin('https://my-origin.com')` | Predicate function to know which request the plugin should handle. |
To know more about the `condition` property check-out the [conditional handling section](https://github.com/jscutlery/http-ext#conditional-handling).
To know more about the `shouldHandleRequest` property check-out the [conditional handling section](https://github.com/jscutlery/http-ext#conditional-handling).

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc