vslides 1.0.10 → 1.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +35 -0
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3204,6 +3204,18 @@ async function getShare(slug, token) {
|
|
|
3204
3204
|
async function getJoin(code) {
|
|
3205
3205
|
return request(`/api/share/${code}`);
|
|
3206
3206
|
}
|
|
3207
|
+
async function authenticateToShare(code, cliAuthToken) {
|
|
3208
|
+
return request(`/api/share/${code}/authenticate`, {
|
|
3209
|
+
method: "POST",
|
|
3210
|
+
headers: {
|
|
3211
|
+
"X-CLI-Auth-Token": cliAuthToken,
|
|
3212
|
+
"Content-Type": "application/json"
|
|
3213
|
+
},
|
|
3214
|
+
body: JSON.stringify({}),
|
|
3215
|
+
skipAuthCheck: true
|
|
3216
|
+
// Don't clear auth on failure (might be session issue, not auth issue)
|
|
3217
|
+
});
|
|
3218
|
+
}
|
|
3207
3219
|
async function getSlides(slug, token) {
|
|
3208
3220
|
return request("/api/slides", {
|
|
3209
3221
|
headers: {
|
|
@@ -3694,6 +3706,29 @@ async function join3(urlOrCode) {
|
|
|
3694
3706
|
code = match[1];
|
|
3695
3707
|
}
|
|
3696
3708
|
}
|
|
3709
|
+
const cachedAuth = getCachedAuth();
|
|
3710
|
+
if (cachedAuth && isAuthValid(cachedAuth)) {
|
|
3711
|
+
const authResult = await authenticateToShare(code, cachedAuth.token);
|
|
3712
|
+
if (authResult.ok) {
|
|
3713
|
+
const { slug: slug2, pollSecret: pollSecret2, token, previewUrl, email } = authResult.data;
|
|
3714
|
+
writeConfig({
|
|
3715
|
+
slug: slug2,
|
|
3716
|
+
pollSecret: pollSecret2,
|
|
3717
|
+
token,
|
|
3718
|
+
previewUrl: previewUrl || `${getBaseUrl()}/slides/${slug2}`
|
|
3719
|
+
});
|
|
3720
|
+
success(`Joined session: ${slug2}`);
|
|
3721
|
+
url("USER", email);
|
|
3722
|
+
url("PREVIEW_URL", previewUrl || `${getBaseUrl()}/slides/${slug2}`);
|
|
3723
|
+
newline();
|
|
3724
|
+
info("You are authenticated. Run: vslides get");
|
|
3725
|
+
return;
|
|
3726
|
+
}
|
|
3727
|
+
if (authResult.status !== 400 && authResult.status !== 401 && authResult.status !== 403) {
|
|
3728
|
+
error(`Failed to join session: ${JSON.stringify(authResult.data)}`);
|
|
3729
|
+
process.exit(ExitCode.NetworkError);
|
|
3730
|
+
}
|
|
3731
|
+
}
|
|
3697
3732
|
const result = await getJoin(code);
|
|
3698
3733
|
if (!result.ok) {
|
|
3699
3734
|
error(`Failed to join session: ${JSON.stringify(result.data)}`);
|