@commercelayer/js-auth
Advanced tools
Comparing version 4.0.0 to 4.1.0
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.authentication=void 0;const tslib_1=require("tslib"),camelCaseToSnake_1=require("./utils/camelCaseToSnake"),snakeToCamelCase_1=require("./utils/snakeToCamelCase");function authentication(grantType,_a){var{domain="commercelayer.io",slug}=_a,options=tslib_1.__rest(_a,["domain","slug"]);return tslib_1.__awaiter(this,void 0,void 0,function*(){const attributes=Object.assign({grant_type:grantType},options),body=Object.keys(attributes).reduce((acc,key)=>{const camelKey=(0,camelCaseToSnake_1.camelCaseToSnake)(key);return acc[camelKey]=attributes[key],acc},{});return yield fetch(`https://${slug}.${domain}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(body)}).then(response=>tslib_1.__awaiter(this,void 0,void 0,function*(){const json=yield response.json();return Object.keys(json).reduce((acc,key)=>{const camelKey=(0,snakeToCamelCase_1.snakeToCamelCase)(key);return acc[camelKey]=json[key],acc},{})}))})}exports.authentication=authentication,exports.default=authentication; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.authentication=void 0;const tslib_1=require("tslib"),camelCaseToSnake_1=require("./utils/camelCaseToSnake"),snakeToCamelCase_1=require("./utils/snakeToCamelCase");function authentication(grantType,_a){var{domain="commercelayer.io",slug}=_a,options=tslib_1.__rest(_a,["domain","slug"]);return tslib_1.__awaiter(this,void 0,void 0,function*(){const attributes=Object.assign({grant_type:grantType},options),body=Object.keys(attributes).reduce((acc,key)=>{const camelKey=(0,camelCaseToSnake_1.camelCaseToSnake)(key);return acc[camelKey]=attributes[key],acc},{});return yield fetch(`https://${slug}.${domain}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(body)}).then(response=>tslib_1.__awaiter(this,void 0,void 0,function*(){const json=yield response.json();return json.expires=new Date(Date.now()+json.expires_in*1e3),Object.keys(json).reduce((acc,key)=>{const camelKey=(0,snakeToCamelCase_1.snakeToCamelCase)(key);return acc[camelKey]=json[key],acc},{})}))})}exports.authentication=authentication,exports.default=authentication; |
@@ -38,6 +38,10 @@ import { type TPasswordReturn, type TPassword } from './password'; | ||
/** | ||
* The expiration date of the access token. | ||
* The access token expiration time in seconds. | ||
*/ | ||
expiresIn: number; | ||
/** | ||
* The access token expiration date. | ||
*/ | ||
expires: Date; | ||
/** | ||
* The access token scope (market, stock location). | ||
@@ -44,0 +48,0 @@ */ |
@@ -1,1 +0,1 @@ | ||
import{camelCaseToSnake}from"./utils/camelCaseToSnake";import{snakeToCamelCase}from"./utils/snakeToCamelCase";export async function authentication(grantType,{domain="commercelayer.io",slug,...options}){const attributes={grant_type:grantType,...options},body=Object.keys(attributes).reduce((acc,key)=>{const camelKey=camelCaseToSnake(key);return acc[camelKey]=attributes[key],acc},{});return await fetch(`https://${slug}.${domain}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(body)}).then(async response=>{const json=await response.json();return Object.keys(json).reduce((acc,key)=>{const camelKey=snakeToCamelCase(key);return acc[camelKey]=json[key],acc},{})})}export default authentication; | ||
import{camelCaseToSnake}from"./utils/camelCaseToSnake";import{snakeToCamelCase}from"./utils/snakeToCamelCase";export async function authentication(grantType,{domain="commercelayer.io",slug,...options}){const attributes={grant_type:grantType,...options},body=Object.keys(attributes).reduce((acc,key)=>{const camelKey=camelCaseToSnake(key);return acc[camelKey]=attributes[key],acc},{});return await fetch(`https://${slug}.${domain}/oauth/token`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(body)}).then(async response=>{const json=await response.json();return json.expires=new Date(Date.now()+json.expires_in*1e3),Object.keys(json).reduce((acc,key)=>{const camelKey=snakeToCamelCase(key);return acc[camelKey]=json[key],acc},{})})}export default authentication; |
@@ -38,6 +38,10 @@ import { type TPasswordReturn, type TPassword } from './password'; | ||
/** | ||
* The expiration date of the access token. | ||
* The access token expiration time in seconds. | ||
*/ | ||
expiresIn: number; | ||
/** | ||
* The access token expiration date. | ||
*/ | ||
expires: Date; | ||
/** | ||
* The access token scope (market, stock location). | ||
@@ -44,0 +48,0 @@ */ |
{ | ||
"name": "@commercelayer/js-auth", | ||
"version": "4.0.0", | ||
"version": "4.1.0", | ||
"description": "Commerce Layer Javascript Auth", | ||
@@ -48,2 +48,5 @@ "repository": { | ||
}, | ||
"engines": { | ||
"node": ">=18.0.0" | ||
}, | ||
"scripts": { | ||
@@ -50,0 +53,0 @@ "lint": "eslint src", |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
15521
234
2