sim 2.0.0-preview.14.1 → 2.0.0-preview.15.1

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/index.js +10 -10
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -6142,6 +6142,8 @@ function sleep(ms) {
6142
6142
  var PAIRING_ALPHABET = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
6143
6143
  var POLL_INTERVAL_MS = 2000;
6144
6144
  var POLL_TIMEOUT_MS = 15 * 60 * 1000;
6145
+ var APPROVAL_PATH = "/cli/auth";
6146
+ var POLL_PATH = "/api/cli/auth/poll";
6145
6147
  var RETRYABLE_POLL_STATUSES = new Set([409, 429, 500, 502, 503, 504]);
6146
6148
  function token() {
6147
6149
  return randomBytes(32).toString("base64url");
@@ -6160,16 +6162,14 @@ function createAuthRequest() {
6160
6162
  };
6161
6163
  }
6162
6164
  function buildApprovalUrl(endpoint, auth, scope, workspaceId) {
6163
- const url = new URL("/cli/auth", endpoint);
6164
- url.searchParams.set("request", auth.request);
6165
- url.searchParams.set("challenge", auth.challenge);
6166
- url.searchParams.set("pairing", auth.pairing);
6167
- url.searchParams.set("scope", scope);
6168
- if (workspaceId)
6169
- url.searchParams.set("workspace", workspaceId);
6170
- return url.toString();
6165
+ return buildUrl(endpoint, APPROVAL_PATH, {
6166
+ request: auth.request,
6167
+ challenge: auth.challenge,
6168
+ pairing: auth.pairing,
6169
+ scope,
6170
+ workspace: workspaceId
6171
+ });
6171
6172
  }
6172
- var POLL_PATH = "/api/cli/auth/poll";
6173
6173
  function toRedirectError(endpoint, response) {
6174
6174
  const location = response.headers.get("location")?.trim();
6175
6175
  let target = null;
@@ -6194,7 +6194,7 @@ async function pollForKey(endpoint, auth, signal) {
6194
6194
  throw new SimApiError("Login cancelled.", 0);
6195
6195
  let response = null;
6196
6196
  try {
6197
- response = await fetch(new URL(POLL_PATH, endpoint), {
6197
+ response = await fetch(buildUrl(endpoint, POLL_PATH), {
6198
6198
  method: "POST",
6199
6199
  headers: {
6200
6200
  "content-type": "application/json",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sim",
3
- "version": "2.0.0-preview.14.1",
3
+ "version": "2.0.0-preview.15.1",
4
4
  "description": "Sim CLI - talk to the Sim API from your terminal",
5
5
  "type": "module",
6
6
  "bin": {