@commercelayer/cli-core
Advanced tools
Comparing version 0.1.9 to 0.2.0
@@ -26,4 +26,11 @@ export declare type AccessTokenInfo = { | ||
}; | ||
export declare type CustomToken = { | ||
accessToken: string; | ||
info: AccessTokenInfo; | ||
expMinutes: number; | ||
}; | ||
/** Decode a Commerce Layer access token */ | ||
declare const decodeAccessToken: (accessToken: string) => AccessTokenInfo; | ||
export { decodeAccessToken }; | ||
/** generate a custom access token */ | ||
declare const generateAccessToken: (token: AccessTokenInfo, sharedSecret: string, minutes: number) => CustomToken; | ||
export { decodeAccessToken, generateAccessToken }; |
@@ -1,1 +0,1 @@ | ||
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.decodeAccessToken=void 0;const jsonwebtoken_1=__importDefault(require("jsonwebtoken")),decodeAccessToken=e=>{const o=jsonwebtoken_1.default.decode(e);if(o===null)throw new Error("Error deconding access token");return o};exports.decodeAccessToken=decodeAccessToken; | ||
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.generateAccessToken=exports.decodeAccessToken=void 0;const jsonwebtoken_1=__importDefault(require("jsonwebtoken")),config_1=__importDefault(require("./config")),decodeAccessToken=e=>{const o=jsonwebtoken_1.default.decode(e);if(o===null)throw new Error("Error deconding access token");return o};exports.decodeAccessToken=decodeAccessToken;const generateAccessToken=(e,o,t)=>{const c=Object.assign(Object.assign({},e),{exp:Math.floor(Date.now()/1e3)+t*60,rand:Math.random()}),n=config_1.default.api.token_encoding_algorithm,s=jsonwebtoken_1.default.sign(c,o,{algorithm:n,noTimestamp:!0}),r=jsonwebtoken_1.default.verify(s,o,{algorithms:[n]});return{accessToken:s,info:r,expMinutes:t}};exports.generateAccessToken=generateAccessToken; |
@@ -26,4 +26,11 @@ export declare type AccessTokenInfo = { | ||
}; | ||
export declare type CustomToken = { | ||
accessToken: string; | ||
info: AccessTokenInfo; | ||
expMinutes: number; | ||
}; | ||
/** Decode a Commerce Layer access token */ | ||
declare const decodeAccessToken: (accessToken: string) => AccessTokenInfo; | ||
export { decodeAccessToken }; | ||
/** generate a custom access token */ | ||
declare const generateAccessToken: (token: AccessTokenInfo, sharedSecret: string, minutes: number) => CustomToken; | ||
export { decodeAccessToken, generateAccessToken }; |
@@ -1,1 +0,1 @@ | ||
import n from"jsonwebtoken";const r=e=>{const o=n.decode(e);if(o===null)throw new Error("Error deconding access token");return o};export{r as decodeAccessToken}; | ||
import t from"jsonwebtoken";import i from"./config";const g=n=>{const o=t.decode(n);if(o===null)throw new Error("Error deconding access token");return o},f=(n,o,e)=>{const s=Object.assign(Object.assign({},n),{exp:Math.floor(Date.now()/1e3)+e*60,rand:Math.random()}),c=i.api.token_encoding_algorithm,r=t.sign(s,o,{algorithm:c,noTimestamp:!0}),a=t.verify(r,o,{algorithms:[c]});return{accessToken:r,info:a,expMinutes:e}};export{g as decodeAccessToken,f as generateAccessToken}; |
{ | ||
"name": "@commercelayer/cli-core", | ||
"version": "0.1.9", | ||
"version": "0.2.0", | ||
"main": "lib/cjs/index.js", | ||
@@ -5,0 +5,0 @@ "types": "lib/cjs/index.d.ts", |
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
93427
359