upload-js
Advanced tools
Comparing version 2.16.0 to 2.17.0
export interface AuthSession { | ||
accessToken: string | undefined; | ||
accessTokenRefreshHandle: number | undefined; | ||
authUrl: string; | ||
isActive: boolean; | ||
} |
@@ -578,11 +578,24 @@ module.exports = | ||
return x.beginAuthSession(authUrl, authHeaders); | ||
}), function () { | ||
return Upload_call(endAuthSession, function () { | ||
}), Upload_async(function () { | ||
debug("User code called 'beginAuthSession'"); // Explanation: | ||
// - Prevents restarting the auth session on accidental double-calls to 'beginAuthSession': in some users' code, | ||
// this happens accidentally every second, so we want to bail-out if we detect this is occurring. | ||
// - We only check 'authUrl' to determine if the 'same call' is being made, since 'authHeaders' is a function | ||
// and therefore its body can be switched-out by the user's code if they desire a change to its behaviour, so | ||
// don't need to call 'beginAuthSession' just to update it. | ||
if ((lastAuthSession === null || lastAuthSession === void 0 ? void 0 : lastAuthSession.authUrl) === authUrl) { | ||
error("'beginAuthSession' has already been called. Ignoring this call. (Hint: call 'endAuthSession' and then 'beginAuthSession' if you want to restart the auth session.)"); | ||
return; | ||
} | ||
return Upload_call(doEndAuthSession, function () { | ||
var authSession = { | ||
accessToken: undefined, | ||
accessTokenRefreshHandle: undefined, | ||
isActive: true | ||
isActive: true, | ||
authUrl: authUrl | ||
}; // Does not need to be inside the mutex since the environment is single-threaded, and we have not async-yielded | ||
// since the mutex from 'endAuthSession' was relinquished (meaning we still have execution, so we know a) nothing | ||
// can interject and b) nothing has interjected since the lock was relinquished). | ||
// since the mutex from 'endAuthSession' was relinquished (meaning we still have execution, | ||
// so we know a) nothing can interject and b) nothing has interjected since the lock was relinquished). | ||
@@ -592,3 +605,3 @@ lastAuthSession = authSession; | ||
}); | ||
})); | ||
}))); | ||
}); | ||
@@ -600,17 +613,4 @@ | ||
}), Upload_async(function () { | ||
return Upload_awaitIgnored(authMutex.safe(Upload_async(function () { | ||
if (lastAuthSession === undefined) { | ||
return; | ||
} | ||
var authSession = lastAuthSession; | ||
lastAuthSession = undefined; | ||
if (authSession.accessTokenRefreshHandle !== undefined) { | ||
clearTimeout(authSession.accessTokenRefreshHandle); | ||
} | ||
authSession.isActive = false; | ||
return _callIgnored(deleteAccessToken); | ||
}))); | ||
debug("User code called 'endAuthSession'"); | ||
return _callIgnored(doEndAuthSession); | ||
}))); | ||
@@ -621,3 +621,4 @@ }); | ||
var params = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
// Initial progress (raised immediately and synchronously). | ||
debug("User code called 'uploadFile'"); // Initial progress (raised immediately and synchronously). | ||
var cancellationHandlers = []; | ||
@@ -668,2 +669,20 @@ | ||
var doEndAuthSession = Upload_async(function () { | ||
return Upload_awaitIgnored(authMutex.safe(Upload_async(function () { | ||
if (lastAuthSession === undefined) { | ||
return; | ||
} | ||
var authSession = lastAuthSession; | ||
lastAuthSession = undefined; | ||
if (authSession.accessTokenRefreshHandle !== undefined) { | ||
clearTimeout(authSession.accessTokenRefreshHandle); | ||
} | ||
authSession.isActive = false; | ||
return _callIgnored(deleteAccessToken); | ||
}))); | ||
}); | ||
var beginFileUpload = Upload_async(function (file, params, addCancellationHandler) { | ||
@@ -670,0 +689,0 @@ var progressSmoother = (0,external_progress_smoother_namespaceObject.ProgressSmoother)({ |
{ | ||
"name": "upload-js", | ||
"version": "2.16.0", | ||
"version": "2.17.0", | ||
"author": "Upload <hello@upload.io> (https://upload.io)", | ||
@@ -5,0 +5,0 @@ "description": "File Upload Library — Upload.js gives developers AJAX multipart file uploading via XHR 🚀 Comes with Cloud Storage 🌐", |
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
78698
1486