cordova-spotify-oauth
Advanced tools
Comparing version 0.1.0 to 0.1.1
{ | ||
"name": "cordova-spotify-oauth", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "Cordova plugin for authenticating with Spotify", | ||
@@ -5,0 +5,0 @@ "main": "www/build/spotify-oauth.min.js", |
@@ -35,2 +35,15 @@ import 'whatwg-fetch'; | ||
/** | ||
* Safety margin time (in milliseconds) for the token refresh. | ||
* | ||
* The plugin applies a safety margin to the token lifetime in order | ||
* to give the token user enough time to perform all operations needed. | ||
* | ||
* Otherwise the plugin might hand out a token that is already expired | ||
* before it could ever be used. | ||
* | ||
* The safety margin defaults to 30s. | ||
*/ | ||
refreshSafetyMargin?: number; | ||
/** Requested OAuth scopes. */ | ||
@@ -79,2 +92,5 @@ scopes: string[]; | ||
} | ||
if ((cfg.refreshSafetyMargin || 0) < 0) { | ||
throw new Error("safety margin < 0"); | ||
} | ||
@@ -86,3 +102,6 @@ const lsData = localStorage.getItem(LOCAL_STORAGE_KEY); | ||
const expiry = Date.now() + 60 * 5 * 1000; // 5min margin | ||
const margin = (cfg.refreshSafetyMargin != undefined) | ||
? cfg.refreshSafetyMargin | ||
: 30000; | ||
const expiry = Date.now() + margin; | ||
if (authData.expiresAt > expiry) { | ||
@@ -89,0 +108,0 @@ return Promise.resolve(authData); |
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
Native code
Supply chain riskContains native code (e.g., compiled binaries or shared libraries). Including native code can obscure malicious behavior.
Found 2 instances in 1 package
146056
404
0
26