vslides 1.0.10 → 1.0.12

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.
Files changed (2) hide show
  1. package/dist/cli.js +38 -0
  2. 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)}`);
@@ -4034,6 +4069,7 @@ async function push(options = {}) {
4034
4069
  info(`Server has version ${conflict.currentVersion}, you expected version ${cfg.version}.`);
4035
4070
  info("Server content saved to: upstream.md");
4036
4071
  writeUpstream(conflict.currentMarkdown);
4072
+ updateConfig({ version: conflict.currentVersion });
4037
4073
  instructions([
4038
4074
  "Compare slides.md (your changes) with upstream.md (server version)",
4039
4075
  "Merge both sets of changes into slides.md",
@@ -4088,6 +4124,7 @@ async function sync() {
4088
4124
  const serverMarkdown = getResult.data.markdown;
4089
4125
  if (localVersion !== void 0 && serverVersion > localVersion) {
4090
4126
  writeUpstream(serverMarkdown);
4127
+ updateConfig({ version: serverVersion });
4091
4128
  info(`SERVER_UPDATED: Version ${serverVersion} available`);
4092
4129
  info("Server content saved to: upstream.md");
4093
4130
  instructions([
@@ -4127,6 +4164,7 @@ async function sync() {
4127
4164
  info(`Server has version ${conflict.currentVersion}, you expected version ${serverVersion}.`);
4128
4165
  info("Server content saved to: upstream.md");
4129
4166
  writeUpstream(conflict.currentMarkdown);
4167
+ updateConfig({ version: conflict.currentVersion });
4130
4168
  instructions([
4131
4169
  "Compare slides.md (your changes) with upstream.md (server version)",
4132
4170
  "Merge both sets of changes into slides.md",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vslides",
3
- "version": "1.0.10",
3
+ "version": "1.0.12",
4
4
  "description": "CLI for Vercel Slides API",
5
5
  "license": "MIT",
6
6
  "author": "Vercel",