@jfront/oauth-core
Advanced tools
Comparing version 0.2.2 to 0.3.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [0.3.0](https://github.com/Jepria/jfront-oauth/compare/@jfront/oauth-core@0.2.2...@jfront/oauth-core@0.3.0) (2023-07-30) | ||
### Features | ||
- added the ability to request oauthContextPath from the application REST API | ||
([9e0d6f2](https://github.com/Jepria/jfront-oauth/commit/9e0d6f2a8cdfd4a23009b1cf80cf9e8084b71383)) | ||
# Change Log | ||
All notable changes to this project will be documented in this file. See | ||
[Conventional Commits](https://conventionalcommits.org) for commit guidelines. | ||
## [0.2.2](https://github.com/Jepria/jfront-oauth/compare/@jfront/oauth-core@0.2.1...@jfront/oauth-core@0.2.2) (2022-12-29) | ||
@@ -8,0 +20,0 @@ |
@@ -80,3 +80,4 @@ "use strict"; | ||
this.meta = { | ||
currentPath: currentPath | ||
currentPath: currentPath, | ||
oauthContextPath: this.authorizeUrl.replace(new RegExp("/authorize$"), "") | ||
}; | ||
@@ -83,0 +84,0 @@ } |
@@ -69,3 +69,3 @@ "use strict"; | ||
} else { | ||
throw new Error("authorizeUrl must me not null"); | ||
throw new Error("authorizeUrl must be not null"); | ||
} | ||
@@ -72,0 +72,0 @@ }); |
@@ -10,3 +10,6 @@ "use strict"; | ||
exports.tokenRequestFailure = tokenRequestFailure; | ||
exports.TOKEN_REQUEST_FAILURE = exports.TOKEN_REQUEST_SUCCESS = exports.TOKEN_REQUEST = exports.AUTHORIZATION_REQUEST_FAILURE = exports.AUTHORIZATION_REQUEST_SUCCESS = exports.AUTHORIZATION_REQUEST = void 0; | ||
exports.oauthContextPathRequest = oauthContextPathRequest; | ||
exports.oauthContextPathRequestSuccess = oauthContextPathRequestSuccess; | ||
exports.oauthContextPathRequestFailure = oauthContextPathRequestFailure; | ||
exports.OAUTH_CONTEXT_PATH_REQUEST_FAILURE = exports.OAUTH_CONTEXT_PATH_REQUEST_SUCCESS = exports.OAUTH_CONTEXT_PATH_REQUEST = exports.TOKEN_REQUEST_FAILURE = exports.TOKEN_REQUEST_SUCCESS = exports.TOKEN_REQUEST = exports.AUTHORIZATION_REQUEST_FAILURE = exports.AUTHORIZATION_REQUEST_SUCCESS = exports.AUTHORIZATION_REQUEST = void 0; | ||
var AUTHORIZATION_REQUEST = "AUTHORIZATION_REQUEST"; | ||
@@ -24,2 +27,8 @@ exports.AUTHORIZATION_REQUEST = AUTHORIZATION_REQUEST; | ||
exports.TOKEN_REQUEST_FAILURE = TOKEN_REQUEST_FAILURE; | ||
var OAUTH_CONTEXT_PATH_REQUEST = "OAUTH_CONTEXT_PATH_REQUEST"; | ||
exports.OAUTH_CONTEXT_PATH_REQUEST = OAUTH_CONTEXT_PATH_REQUEST; | ||
var OAUTH_CONTEXT_PATH_REQUEST_SUCCESS = "OAUTH_CONTEXT_PATH_REQUEST_SUCCESS"; | ||
exports.OAUTH_CONTEXT_PATH_REQUEST_SUCCESS = OAUTH_CONTEXT_PATH_REQUEST_SUCCESS; | ||
var OAUTH_CONTEXT_PATH_REQUEST_FAILURE = "OAUTH_CONTEXT_PATH_REQUEST_FAILURE"; | ||
exports.OAUTH_CONTEXT_PATH_REQUEST_FAILURE = OAUTH_CONTEXT_PATH_REQUEST_FAILURE; | ||
@@ -75,2 +84,24 @@ function authorizationRequest(authorizationUrl) { | ||
} | ||
function oauthContextPathRequest() { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST | ||
}; | ||
} | ||
function oauthContextPathRequestSuccess(oauthContextPathExt) { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST_SUCCESS, | ||
oauthContextPathExt: oauthContextPathExt | ||
}; | ||
} | ||
function oauthContextPathRequestFailure(errorCode, errorDescription, errorId) { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST_FAILURE, | ||
errorCode: errorCode, | ||
errorDescription: errorDescription, | ||
errorId: errorId | ||
}; | ||
} | ||
//# sourceMappingURL=actions.js.map |
@@ -8,2 +8,4 @@ "use strict"; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
/** | ||
@@ -47,2 +49,3 @@ * Базовый редьюсер OAuth. | ||
authorizationCode: state.authorizationCode, | ||
oauthContextPathExt: state.oauthContextPathExt, | ||
state: state.state, | ||
@@ -60,2 +63,3 @@ isLoading: true | ||
tokenType: action.tokenType, | ||
oauthContextPathExt: state.oauthContextPathExt, | ||
authorizationCode: undefined, | ||
@@ -76,2 +80,27 @@ isLoading: false | ||
} | ||
case _actions.OAUTH_CONTEXT_PATH_REQUEST: | ||
{ | ||
return _extends({}, state, { | ||
isLoading: true | ||
}); | ||
} | ||
case _actions.OAUTH_CONTEXT_PATH_REQUEST_SUCCESS: | ||
{ | ||
return _extends({}, state, { | ||
oauthContextPathExt: action.oauthContextPathExt, | ||
isLoading: false | ||
}); | ||
} | ||
case _actions.OAUTH_CONTEXT_PATH_REQUEST_FAILURE: | ||
{ | ||
return _extends({}, state, { | ||
errorCode: action.errorCode, | ||
errorDescription: action.errorDescription, | ||
errorId: action.errorId, | ||
isLoading: false | ||
}); | ||
} | ||
} | ||
@@ -78,0 +107,0 @@ }; |
"use strict"; | ||
exports.__esModule = true; | ||
exports.getRandomValue = void 0; | ||
exports.getOAuthContextPathFromApi = exports.getRandomValue = void 0; | ||
var _jsChacha = _interopRequireDefault(require("js-chacha20")); | ||
var _axios = _interopRequireDefault(require("axios")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
@@ -66,4 +68,36 @@ | ||
}; | ||
/** | ||
* Получение oauthContextPath от REST API приложения | ||
* | ||
* @param {string} oauthContextPathUrl URL для запроса oauthContextPath от REST API приложения | ||
*/ | ||
exports.getRandomValue = getRandomValue; | ||
var getOAuthContextPathFromApi = function getOAuthContextPathFromApi(oauthContextPathUrl) { | ||
return new Promise(function (resolve, reject) { | ||
if (!oauthContextPathUrl) { | ||
throw new Error("url for oauthContextPath request is empty"); | ||
} | ||
_axios["default"].get(oauthContextPathUrl, { | ||
headers: { | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
"Cache-Control": "no-store" | ||
} | ||
}).then(function (response) { | ||
if (response.status === 200) { | ||
resolve(response == null ? void 0 : response.data); | ||
} else { | ||
reject(response); | ||
} | ||
})["catch"](function (error) { | ||
return reject(error); | ||
}); | ||
}); | ||
}; | ||
exports.getOAuthContextPathFromApi = getOAuthContextPathFromApi; | ||
//# sourceMappingURL=utils.js.map |
@@ -67,3 +67,4 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
this.meta = { | ||
currentPath: currentPath | ||
currentPath: currentPath, | ||
oauthContextPath: this.authorizeUrl.replace(new RegExp("/authorize$"), "") | ||
}; | ||
@@ -70,0 +71,0 @@ } |
@@ -56,3 +56,3 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
} else { | ||
throw new Error("authorizeUrl must me not null"); | ||
throw new Error("authorizeUrl must be not null"); | ||
} | ||
@@ -59,0 +59,0 @@ }); |
@@ -7,2 +7,5 @@ export var AUTHORIZATION_REQUEST = "AUTHORIZATION_REQUEST"; | ||
export var TOKEN_REQUEST_FAILURE = "TOKEN_REQUEST_FAILURE"; | ||
export var OAUTH_CONTEXT_PATH_REQUEST = "OAUTH_CONTEXT_PATH_REQUEST"; | ||
export var OAUTH_CONTEXT_PATH_REQUEST_SUCCESS = "OAUTH_CONTEXT_PATH_REQUEST_SUCCESS"; | ||
export var OAUTH_CONTEXT_PATH_REQUEST_FAILURE = "OAUTH_CONTEXT_PATH_REQUEST_FAILURE"; | ||
export function authorizationRequest(authorizationUrl) { | ||
@@ -52,2 +55,21 @@ return { | ||
} | ||
export function oauthContextPathRequest() { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST | ||
}; | ||
} | ||
export function oauthContextPathRequestSuccess(oauthContextPathExt) { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST_SUCCESS, | ||
oauthContextPathExt | ||
}; | ||
} | ||
export function oauthContextPathRequestFailure(errorCode, errorDescription, errorId) { | ||
return { | ||
type: OAUTH_CONTEXT_PATH_REQUEST_FAILURE, | ||
errorCode, | ||
errorDescription, | ||
errorId | ||
}; | ||
} | ||
//# sourceMappingURL=actions.js.map |
@@ -1,2 +0,4 @@ | ||
import { AUTHORIZATION_REQUEST, AUTHORIZATION_REQUEST_SUCCESS, AUTHORIZATION_REQUEST_FAILURE, TOKEN_REQUEST, TOKEN_REQUEST_SUCCESS, TOKEN_REQUEST_FAILURE } from "./actions"; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
import { AUTHORIZATION_REQUEST, AUTHORIZATION_REQUEST_SUCCESS, AUTHORIZATION_REQUEST_FAILURE, TOKEN_REQUEST, TOKEN_REQUEST_SUCCESS, TOKEN_REQUEST_FAILURE, OAUTH_CONTEXT_PATH_REQUEST, OAUTH_CONTEXT_PATH_REQUEST_SUCCESS, OAUTH_CONTEXT_PATH_REQUEST_FAILURE } from "./actions"; | ||
/** | ||
@@ -41,2 +43,3 @@ * Базовый редьюсер OAuth. | ||
authorizationCode: state.authorizationCode, | ||
oauthContextPathExt: state.oauthContextPathExt, | ||
state: state.state, | ||
@@ -54,2 +57,3 @@ isLoading: true | ||
tokenType: action.tokenType, | ||
oauthContextPathExt: state.oauthContextPathExt, | ||
authorizationCode: undefined, | ||
@@ -70,4 +74,29 @@ isLoading: false | ||
} | ||
case OAUTH_CONTEXT_PATH_REQUEST: | ||
{ | ||
return _extends({}, state, { | ||
isLoading: true | ||
}); | ||
} | ||
case OAUTH_CONTEXT_PATH_REQUEST_SUCCESS: | ||
{ | ||
return _extends({}, state, { | ||
oauthContextPathExt: action.oauthContextPathExt, | ||
isLoading: false | ||
}); | ||
} | ||
case OAUTH_CONTEXT_PATH_REQUEST_FAILURE: | ||
{ | ||
return _extends({}, state, { | ||
errorCode: action.errorCode, | ||
errorDescription: action.errorDescription, | ||
errorId: action.errorId, | ||
isLoading: false | ||
}); | ||
} | ||
} | ||
}; | ||
//# sourceMappingURL=reducer.js.map |
import JSChaCha20 from "js-chacha20"; | ||
import axios from "axios"; | ||
/** | ||
@@ -59,2 +60,29 @@ * weakRand is used to generate start values. | ||
}; | ||
/** | ||
* Получение oauthContextPath от REST API приложения | ||
* | ||
* @param {string} oauthContextPathUrl URL для запроса oauthContextPath от REST API приложения | ||
*/ | ||
export var getOAuthContextPathFromApi = oauthContextPathUrl => { | ||
return new Promise((resolve, reject) => { | ||
if (!oauthContextPathUrl) { | ||
throw new Error("url for oauthContextPath request is empty"); | ||
} | ||
axios.get(oauthContextPathUrl, { | ||
headers: { | ||
Accept: "application/json;charset=utf-8", | ||
"Content-Type": "application/json;charset=utf-8", | ||
"Cache-Control": "no-store" | ||
} | ||
}).then(response => { | ||
if (response.status === 200) { | ||
resolve(response == null ? void 0 : response.data); | ||
} else { | ||
reject(response); | ||
} | ||
}).catch(error => reject(error)); | ||
}); | ||
}; | ||
//# sourceMappingURL=utils.js.map |
@@ -7,2 +7,5 @@ export declare const AUTHORIZATION_REQUEST = "AUTHORIZATION_REQUEST"; | ||
export declare const TOKEN_REQUEST_FAILURE = "TOKEN_REQUEST_FAILURE"; | ||
export declare const OAUTH_CONTEXT_PATH_REQUEST = "OAUTH_CONTEXT_PATH_REQUEST"; | ||
export declare const OAUTH_CONTEXT_PATH_REQUEST_SUCCESS = "OAUTH_CONTEXT_PATH_REQUEST_SUCCESS"; | ||
export declare const OAUTH_CONTEXT_PATH_REQUEST_FAILURE = "OAUTH_CONTEXT_PATH_REQUEST_FAILURE"; | ||
export interface AuthorizationRequestAction { | ||
@@ -40,3 +43,16 @@ type: typeof AUTHORIZATION_REQUEST; | ||
} | ||
export declare type OAuthActionTypes = AuthorizationRequestAction | AuthorizationRequestSuccessAction | AuthorizationRequestFailureAction | TokenRequestAction | TokenRequestSuccessAction | TokenRequestFailureAction; | ||
export interface OAuthContextPathRequestAction { | ||
type: typeof OAUTH_CONTEXT_PATH_REQUEST; | ||
} | ||
export interface OAuthContextPathRequestSuccessAction { | ||
type: typeof OAUTH_CONTEXT_PATH_REQUEST_SUCCESS; | ||
oauthContextPathExt: string; | ||
} | ||
export interface OAuthContextPathRequestFailureAction { | ||
type: typeof OAUTH_CONTEXT_PATH_REQUEST_FAILURE; | ||
errorCode: string; | ||
errorDescription?: string; | ||
errorId?: string; | ||
} | ||
export declare type OAuthActionTypes = AuthorizationRequestAction | AuthorizationRequestSuccessAction | AuthorizationRequestFailureAction | TokenRequestAction | TokenRequestSuccessAction | TokenRequestFailureAction | OAuthContextPathRequestAction | OAuthContextPathRequestSuccessAction | OAuthContextPathRequestFailureAction; | ||
export declare function authorizationRequest(authorizationUrl: string): OAuthActionTypes; | ||
@@ -48,1 +64,4 @@ export declare function authorizationRequestSuccess(authorizationCode: string, state: string): OAuthActionTypes; | ||
export declare function tokenRequestFailure(errorCode: string, errorUri?: string, errorDescription?: string, errorId?: string): OAuthActionTypes; | ||
export declare function oauthContextPathRequest(): OAuthActionTypes; | ||
export declare function oauthContextPathRequestSuccess(oauthContextPathExt: string): OAuthActionTypes; | ||
export declare function oauthContextPathRequestFailure(errorCode: string, errorDescription?: string, errorId?: string): OAuthActionTypes; |
@@ -11,4 +11,6 @@ export declare type TokenResponse = { | ||
expiresIn?: Date; | ||
oauthContextPath?: string; | ||
}; | ||
export interface OAuthState { | ||
oauthContextPathExt?: string; | ||
accessToken?: string; | ||
@@ -15,0 +17,0 @@ expiresIn?: bigint; |
export function getRandomValue(size: number): number; | ||
export function getOAuthContextPathFromApi(oauthContextPathUrl: string): Promise<any>; |
{ | ||
"name": "@jfront/oauth-core", | ||
"version": "0.2.2", | ||
"version": "0.3.0", | ||
"license": "Apache-2.0", | ||
@@ -35,3 +35,3 @@ "repository": "https://github.com/Jepria/jfront-oauth", | ||
}, | ||
"gitHead": "15f07fca8a3f767553f9c3b017da4f8fe78b1d53" | ||
"gitHead": "9720adf4f759ce33a6e2f1001ea87f75b9bc9d82" | ||
} |
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
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
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
150723
1389
0