@commercelayer/js-auth
Advanced tools
Comparing version 4.1.1 to 4.2.0
import { type TReturn, type GrantType, type TOptions } from './types/index'; | ||
export declare function authentication<G extends GrantType>(grantType: G, { domain, slug, ...options }: TOptions<G>): Promise<TReturn<G>>; | ||
export default authentication; | ||
export { provisioning } from './provisioning'; | ||
export declare const core: { | ||
authentication: typeof authentication; | ||
}; |
@@ -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 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; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.core=exports.provisioning=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;var provisioning_1=require("./provisioning");Object.defineProperty(exports,"provisioning",{enumerable:!0,get:function(){return provisioning_1.provisioning}}),exports.core={authentication}; |
import { type TReturn, type GrantType, type TOptions } from './types/index'; | ||
export declare function authentication<G extends GrantType>(grantType: G, { domain, slug, ...options }: TOptions<G>): Promise<TReturn<G>>; | ||
export default authentication; | ||
export { provisioning } from './provisioning'; | ||
export declare const core: { | ||
authentication: typeof authentication; | ||
}; |
@@ -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 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; | ||
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;export{provisioning}from"./provisioning";export const core={authentication}; |
{ | ||
"name": "@commercelayer/js-auth", | ||
"version": "4.1.1", | ||
"version": "4.2.0", | ||
"description": "Commerce Layer Javascript Auth", | ||
@@ -36,13 +36,13 @@ "repository": { | ||
"devDependencies": { | ||
"@types/node": "^20.1.2", | ||
"@vitejs/plugin-react": "^4.0.0", | ||
"@vitest/coverage-c8": "^0.31.0", | ||
"jsdom": "^22.0.0", | ||
"minimize-js": "^1.3.1", | ||
"tsc-alias": "^1.8.6", | ||
"tslib": "^2.5.0", | ||
"typescript": "^5.0.4", | ||
"vite": "^4.3.5", | ||
"vite-tsconfig-paths": "^4.2.0", | ||
"vitest": "^0.31.0" | ||
"@types/node": "^20.8.9", | ||
"@vitejs/plugin-react": "^4.1.0", | ||
"@vitest/coverage-c8": "^0.33.0", | ||
"jsdom": "^22.1.0", | ||
"minimize-js": "^1.4.0", | ||
"tsc-alias": "^1.8.8", | ||
"tslib": "^2.6.2", | ||
"typescript": "^5.2.2", | ||
"vite": "^4.5.0", | ||
"vite-tsconfig-paths": "^4.2.1", | ||
"vitest": "^0.34.6" | ||
}, | ||
@@ -53,4 +53,4 @@ "engines": { | ||
"scripts": { | ||
"lint": "eslint src", | ||
"lint:fix": "eslint src --fix", | ||
"lint": "eslint src --ext .ts,.tsx", | ||
"lint:fix": "eslint src --ext .ts,.tsx --fix", | ||
"test": "pnpm run lint && vitest run --silent", | ||
@@ -57,0 +57,0 @@ "coverage": "vitest run --coverage", |
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
19056
38
262
2
4