Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@wix/api-client

Package Overview
Dependencies
Maintainers
19
Versions
133
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wix/api-client - npm Package Compare versions

Comparing version 1.1.55 to 1.1.56

4

dist/cjs/__tests__/wixClientOAuthStrategy.spec.js

@@ -289,3 +289,3 @@ "use strict";

value: _constants.VALID_TOKEN,
expiresAt: (0, _tokenHelpers.getCurrentDate)() - 1000
expiresAt: (0, _tokenHelpers.getCurrentDate)() + 1000
},

@@ -425,3 +425,3 @@ refreshToken: {

value: _constants.VALID_TOKEN,
expiresAt: (0, _tokenHelpers.getCurrentDate)() - 1000
expiresAt: (0, _tokenHelpers.getCurrentDate)() + 1000
},

@@ -428,0 +428,0 @@ refreshToken: {

@@ -11,2 +11,5 @@ "use strict";

var _pkceChallenge = _interopRequireDefault(require("pkce-challenge"));
const moduleWithTokens = {
redirects: _redirects.redirects
};
function OAuthStrategy(config) {

@@ -28,14 +31,25 @@ const wixClient = (0, _wixClient.createClient)({

};
let wixClientWithTokens = (0, _wixClient.createClient)({
modules: {
oauth: _identity.oauth,
redirects: _redirects.redirects
},
headers: {
Authorization: _tokens.accessToken.value
const getAuthHeaders = async () => {
var _tokens$accessToken;
if (!((_tokens$accessToken = _tokens.accessToken) != null && _tokens$accessToken.value) || (0, _tokenHelpers.isTokenExpired)(_tokens.accessToken)) {
const tokens = await generateVisitorTokens({
refreshToken: _tokens.refreshToken
});
setTokens(tokens);
}
return Promise.resolve({
headers: {
Authorization: _tokens.accessToken.value
}
});
};
const wixClientWithTokens = (0, _wixClient.createClient)({
modules: moduleWithTokens,
auth: {
getAuthHeaders
}
});
const generateVisitorTokens = async tokens => {
var _tokens$accessToken, _tokens$refreshToken, _tokens$refreshToken2;
if (tokens != null && (_tokens$accessToken = tokens.accessToken) != null && _tokens$accessToken.value && tokens != null && (_tokens$refreshToken = tokens.refreshToken) != null && _tokens$refreshToken.value && !(0, _tokenHelpers.isTokenExpired)(tokens.accessToken)) {
var _tokens$accessToken2, _tokens$refreshToken, _tokens$refreshToken2;
if (tokens != null && (_tokens$accessToken2 = tokens.accessToken) != null && _tokens$accessToken2.value && tokens != null && (_tokens$refreshToken = tokens.refreshToken) != null && _tokens$refreshToken.value && !(0, _tokenHelpers.isTokenExpired)(tokens.accessToken)) {
return Promise.resolve(tokens);

@@ -104,11 +118,2 @@ }

_tokens.refreshToken = tokens.refreshToken;
wixClientWithTokens = (0, _wixClient.createClient)({
modules: {
oauth: _identity.oauth,
redirects: _redirects.redirects
},
headers: {
Authorization: _tokens.accessToken.value
}
});
};

@@ -177,16 +182,3 @@ const parseFromUrl = () => {

generateOauthRedirectState,
getAuthHeaders: async () => {
var _tokens$accessToken2;
if (!((_tokens$accessToken2 = _tokens.accessToken) != null && _tokens$accessToken2.value) || (0, _tokenHelpers.isTokenExpired)(_tokens.accessToken)) {
const tokens = await generateVisitorTokens({
refreshToken: _tokens.refreshToken
});
setTokens(tokens);
}
return Promise.resolve({
headers: {
Authorization: _tokens.accessToken.value
}
});
},
getAuthHeaders,
setTokens,

@@ -193,0 +185,0 @@ getTokens: () => _tokens,

@@ -287,3 +287,3 @@ import { cart } from '@wix/ecom';

value: VALID_TOKEN,
expiresAt: getCurrentDate() - 1000
expiresAt: getCurrentDate() + 1000
},

@@ -423,3 +423,3 @@ refreshToken: {

value: VALID_TOKEN,
expiresAt: getCurrentDate() - 1000
expiresAt: getCurrentDate() + 1000
},

@@ -426,0 +426,0 @@ refreshToken: {

@@ -6,2 +6,5 @@ import { createClient } from '../wixClient';

import pkceChallenge from 'pkce-challenge';
const moduleWithTokens = {
redirects
};
export function OAuthStrategy(config) {

@@ -23,14 +26,25 @@ const wixClient = createClient({

};
let wixClientWithTokens = createClient({
modules: {
oauth,
redirects
},
headers: {
Authorization: _tokens.accessToken.value
const getAuthHeaders = async () => {
var _tokens$accessToken;
if (!((_tokens$accessToken = _tokens.accessToken) != null && _tokens$accessToken.value) || isTokenExpired(_tokens.accessToken)) {
const tokens = await generateVisitorTokens({
refreshToken: _tokens.refreshToken
});
setTokens(tokens);
}
return Promise.resolve({
headers: {
Authorization: _tokens.accessToken.value
}
});
};
const wixClientWithTokens = createClient({
modules: moduleWithTokens,
auth: {
getAuthHeaders
}
});
const generateVisitorTokens = async tokens => {
var _tokens$accessToken, _tokens$refreshToken, _tokens$refreshToken2;
if (tokens != null && (_tokens$accessToken = tokens.accessToken) != null && _tokens$accessToken.value && tokens != null && (_tokens$refreshToken = tokens.refreshToken) != null && _tokens$refreshToken.value && !isTokenExpired(tokens.accessToken)) {
var _tokens$accessToken2, _tokens$refreshToken, _tokens$refreshToken2;
if (tokens != null && (_tokens$accessToken2 = tokens.accessToken) != null && _tokens$accessToken2.value && tokens != null && (_tokens$refreshToken = tokens.refreshToken) != null && _tokens$refreshToken.value && !isTokenExpired(tokens.accessToken)) {
return Promise.resolve(tokens);

@@ -99,11 +113,2 @@ }

_tokens.refreshToken = tokens.refreshToken;
wixClientWithTokens = createClient({
modules: {
oauth,
redirects
},
headers: {
Authorization: _tokens.accessToken.value
}
});
};

@@ -172,16 +177,3 @@ const parseFromUrl = () => {

generateOauthRedirectState,
getAuthHeaders: async () => {
var _tokens$accessToken2;
if (!((_tokens$accessToken2 = _tokens.accessToken) != null && _tokens$accessToken2.value) || isTokenExpired(_tokens.accessToken)) {
const tokens = await generateVisitorTokens({
refreshToken: _tokens.refreshToken
});
setTokens(tokens);
}
return Promise.resolve({
headers: {
Authorization: _tokens.accessToken.value
}
});
},
getAuthHeaders,
setTokens,

@@ -188,0 +180,0 @@ getTokens: () => _tokens,

{
"name": "@wix/api-client",
"version": "1.1.55",
"version": "1.1.56",
"license": "UNLICENSED",

@@ -31,6 +31,6 @@ "author": {

"@babel/runtime": "^7.21.0",
"@wix/identity": "^1.0.25",
"@wix/identity": "^1.0.27",
"@wix/image-kit": "^1.31.0",
"@wix/redirects": "^1.0.0",
"@wix/sdk-types": "1.1.55",
"@wix/redirects": "^1.0.1",
"@wix/sdk-types": "1.1.56",
"pkce-challenge": "^3.1.0",

@@ -43,7 +43,7 @@ "querystring": "^0.2.1",

"@types/node": "^16.18.23",
"@wix/ecom": "^1.0.144",
"@wix/events": "^1.0.74",
"@wix/jest-yoshi-preset": "^6.54.1",
"@wix/ecom": "^1.0.149",
"@wix/events": "^1.0.75",
"@wix/jest-yoshi-preset": "^6.54.2",
"@wix/motion": "^1.0.23",
"@wix/yoshi-flow-library": "^6.54.1",
"@wix/yoshi-flow-library": "^6.54.2",
"ts-jest": "^27.1.5",

@@ -75,3 +75,3 @@ "typescript": "~4.9.5"

},
"falconPackageHash": "ab5f45865e7f5ef6dfce7b4a6e8dc8f009b7ce1192e4f434a39de066"
"falconPackageHash": "271ce011c7238877e8a88fc586e4912570fd4d4ef15db97690ee86fb"
}

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

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