@superwall/cli 2.1.0 → 2.2.0
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/README.md +12 -2
- package/dist/{apple-CSzNTGHM.js → apple-Bcr_PteR.js} +13 -13
- package/dist/auth.d.ts +1 -1
- package/dist/auth.js +3 -3
- package/dist/{billing-C3Q8DBU2.js → billing-CWM1ds3K.js} +3 -3
- package/dist/{bind-BumHTi9O.js → bind-DEYxsnZD.js} +4 -4
- package/dist/{build-Bpviiclc.js → build--oQKfZU6.js} +6 -6
- package/dist/{client-BL0f_yGf.js → client-CimFymxG.js} +7 -3
- package/dist/{create-BUcVG4Ab.js → create-BG9n4fvs.js} +22 -22
- package/dist/{create-CfK3PeKA.js → create-DTAyHkxb.js} +6 -6
- package/dist/create-kT2C9k4h.js +19 -0
- package/dist/{doctor-BWqIYcMn.js → doctor-BkygMUe2.js} +6 -6
- package/dist/{drivers-CPhdPkW5.js → drivers-C6eXj5-r.js} +3 -3
- package/dist/entry.js +19 -19
- package/dist/{environment-eBXjELoN.js → environment-CQn323uB.js} +15 -2
- package/dist/{existing-BltvQiX5.js → existing-CvOluc9U.js} +2 -2
- package/dist/held-Bwkhufdj.js +16 -0
- package/dist/{held-DgnTFMl3.js → held-QM7yfrXq.js} +6 -6
- package/dist/{integrate-BRsqoe01.js → integrate-Ci_MLkQG.js} +21 -21
- package/dist/{login-BbTIrCFT.js → login-BIAWgdzM.js} +256 -33
- package/dist/{login-BCEH5q0U.js → login-DLi71nJq.js} +1 -1
- package/dist/login-Dy9N5ZDH.js +16 -0
- package/dist/{lookup-rr1AkCJA.js → lookup-DZFrfzO0.js} +2 -2
- package/dist/{migrate-C9X2Vz81.js → migrate-BKF1WckS.js} +21 -21
- package/dist/{notification-url-CV86qiKP.js → notification-url-erXQ1edb.js} +2 -2
- package/dist/{open-CcpXotHG.js → open-BjvGVwJf.js} +10 -10
- package/dist/{org-BQQDo7wm.js → org-CvPGVSBF.js} +2 -2
- package/dist/{paths-CRlU72cq.js → paths-oRuC18Kt.js} +1 -1
- package/dist/{playbook-DVMXN7fh.js → playbook-CtTj1HBK.js} +10 -10
- package/dist/{promote-Da8xctzy.js → promote-BkJYISza.js} +16 -16
- package/dist/push-BIizJJOn.js +22 -0
- package/dist/{push-D6R9icWN.js → push-Ul2SW87i.js} +4 -4
- package/dist/{registry-BYVD-_h6.js → registry-OmPZ6dj0.js} +407 -177
- package/dist/{resources-DLON3-61.js → resources-FIrK7pE9.js} +1 -1
- package/dist/{run-Co-BwhOg.js → run-CwEY1eu5.js} +2 -2
- package/dist/{scan-CKuk-_6W.js → scan-CpbfZ2ju.js} +1 -1
- package/dist/scan-DjyvuWel.js +4 -0
- package/dist/{scope-DV22_Ufm.js → scope-BSqVfZvy.js} +4 -4
- package/dist/{selection-C2_KbLuo.js → selection-CHnVk8uw.js} +3 -3
- package/dist/server-BTveynqC.js +22 -0
- package/dist/{server-D0d2oP-5.js → server-D5xl5iKO.js} +66 -16
- package/dist/{session-B-Uz0cQ7.js → session-6lnJ0shD.js} +1 -1
- package/dist/{session-C4rbE3VS.js → session-BFwasPVq.js} +9 -8
- package/dist/session-Ds6tLC19.js +6 -0
- package/dist/skills/superwall/references/data-analytics.md +7 -8
- package/dist/skills/superwall-framework/SKILL.md +36 -4
- package/dist/skills/superwall-framework/references/examples.md +1 -0
- package/dist/skills/superwall-framework/references/migrate-from-editor.md +18 -4
- package/dist/{skills-CLGJuMnF.js → skills-B8uSuanf.js} +8 -8
- package/dist/{skills-CZcpnEnG.js → skills-D7sG0xom.js} +4 -4
- package/dist/{spinner-C2U6QBJ9.js → spinner-TZeZEeVv.js} +3 -3
- package/dist/{storage-CerJ5KLP.d.ts → storage-BbJF7z3l.d.ts} +1 -0
- package/dist/{storage-6h9vyiAz.js → storage-DqKJe13V.js} +12 -2
- package/dist/storekit-C_LFh8qy.js +16 -0
- package/dist/{storekit-CinJra3V.js → storekit-uyT3DWo4.js} +3 -3
- package/dist/{telemetry-DKyDhURo.js → telemetry-D_uIIuSk.js} +1 -1
- package/dist/{token-DaxQgQkv.js → token-BJsLGoSX.js} +1 -1
- package/dist/tools.d.ts +11 -9
- package/dist/tools.js +389 -161
- package/dist/{upgrade-DPo0a4Es.js → upgrade-BRM51As6.js} +1 -1
- package/dist/{upgrade-ffseQDMx.js → upgrade-DV_rmhyV.js} +2 -2
- package/package.json +2 -2
- package/dist/create-BSfvpWoD.js +0 -19
- package/dist/held-CPve03KJ.js +0 -16
- package/dist/login-BPOONe7n.js +0 -16
- package/dist/push-BV-grvQg.js +0 -22
- package/dist/scan-B88OlWOt.js +0 -4
- package/dist/server-C4f6ccUr.js +0 -22
- package/dist/session-BuvArt1j.js +0 -6
- package/dist/storekit-CK9JmM2D.js +0 -16
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { f as Integration, i as AUTH_HOST, p as OAUTH_SCOPE, s as CLI_CLIENT_ID, t as API_HOST } from "./environment-
|
|
2
|
-
import {
|
|
1
|
+
import { f as Integration, i as AUTH_HOST, p as OAUTH_SCOPE, s as CLI_CLIENT_ID, t as API_HOST } from "./environment-CQn323uB.js";
|
|
2
|
+
import { c as writePendingLogin, l as writeSession, o as serializeSession, r as removePendingLogin, t as readPendingLogin } from "./storage-DqKJe13V.js";
|
|
3
3
|
import { a as readOnboardingIdempotencyKey, d as writeOnboardedApp, f as writeOnboardedOrg, i as readOnboardedOrg } from "./config-BO1Y87kV.js";
|
|
4
|
-
import { r as track } from "./telemetry-
|
|
4
|
+
import { r as track } from "./telemetry-D_uIIuSk.js";
|
|
5
|
+
import { r as UsageError } from "./spinner-TZeZEeVv.js";
|
|
5
6
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
6
|
-
import { t as scanProject } from "./scan-
|
|
7
|
-
import { s as ensureSkillsCurrent } from "./skills-
|
|
7
|
+
import { t as scanProject } from "./scan-CpbfZ2ju.js";
|
|
8
|
+
import { s as ensureSkillsCurrent } from "./skills-D7sG0xom.js";
|
|
8
9
|
import { spawn } from "node:child_process";
|
|
9
10
|
import { setTimeout } from "node:timers/promises";
|
|
10
11
|
|
|
@@ -65,7 +66,8 @@ function hasDisplay(env, platform) {
|
|
|
65
66
|
}
|
|
66
67
|
function openBrowser(url, deps = {}) {
|
|
67
68
|
const platform = deps.platform ?? process.platform;
|
|
68
|
-
|
|
69
|
+
const env = deps.env ?? process.env;
|
|
70
|
+
if (env.BROWSER === "none" || !hasDisplay(env, platform)) return Promise.resolve(false);
|
|
69
71
|
const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : "xdg-open";
|
|
70
72
|
const args = platform === "win32" ? [
|
|
71
73
|
"/c",
|
|
@@ -91,22 +93,116 @@ function openBrowser(url, deps = {}) {
|
|
|
91
93
|
//#endregion
|
|
92
94
|
//#region src/core/account/login.ts
|
|
93
95
|
const DEVICE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
|
|
94
|
-
async function
|
|
96
|
+
async function createPendingLogin(opts) {
|
|
95
97
|
const issuer = opts.issuer ?? AUTH_HOST();
|
|
96
|
-
const apiHost = opts.apiHost ?? API_HOST();
|
|
97
98
|
const clientId = opts.clientId ?? CLI_CLIENT_ID();
|
|
98
99
|
const disc = await discover(issuer);
|
|
99
100
|
if (!disc.device_authorization_endpoint) throw new Error("auth.superwall.com does not advertise a device-authorization endpoint.");
|
|
100
101
|
const dev = await startDeviceAuth(disc.device_authorization_endpoint, clientId);
|
|
101
102
|
const url = dev.verification_uri_complete ?? dev.verification_uri;
|
|
102
103
|
const browserOpened = await (opts.openBrowser ?? openBrowser)(url);
|
|
104
|
+
const now = Date.now();
|
|
105
|
+
return {
|
|
106
|
+
browserOpened,
|
|
107
|
+
pending: {
|
|
108
|
+
apiHost: opts.apiHost ?? API_HOST(),
|
|
109
|
+
clientId,
|
|
110
|
+
tokenEndpoint: disc.token_endpoint,
|
|
111
|
+
deviceCode: dev.device_code,
|
|
112
|
+
userCode: dev.user_code,
|
|
113
|
+
url,
|
|
114
|
+
interval: dev.interval ?? 5,
|
|
115
|
+
expiresAt: now + (dev.expires_in ?? 600) * 1e3,
|
|
116
|
+
lastPolledAt: now,
|
|
117
|
+
...opts.orgName ? { orgName: opts.orgName } : {},
|
|
118
|
+
...opts.app ? { app: opts.app } : {}
|
|
119
|
+
}
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
async function performLogin(opts = {}) {
|
|
123
|
+
const { pending, browserOpened } = await createPendingLogin(opts);
|
|
103
124
|
opts.onVerify?.({
|
|
104
|
-
url,
|
|
105
|
-
userCode:
|
|
125
|
+
url: pending.url,
|
|
126
|
+
userCode: pending.userCode,
|
|
106
127
|
browserOpened
|
|
107
128
|
});
|
|
108
|
-
const
|
|
109
|
-
|
|
129
|
+
const tokens = await pollForToken(pending, pending.expiresAt, opts.onStatus);
|
|
130
|
+
if (!tokens) throw new Error("Login timed out.");
|
|
131
|
+
const finished = await finishLogin(pending, tokens, opts);
|
|
132
|
+
if ("needsOrganization" in finished) throw new Error("Your account has no organization yet - run `superwall login` interactively to create one.");
|
|
133
|
+
return finished.session;
|
|
134
|
+
}
|
|
135
|
+
async function startLogin(opts = {}) {
|
|
136
|
+
const started = await createPendingLogin(opts);
|
|
137
|
+
writePendingLogin(started.pending);
|
|
138
|
+
return started;
|
|
139
|
+
}
|
|
140
|
+
async function pollLogin(opts) {
|
|
141
|
+
const pending = readPendingLogin();
|
|
142
|
+
if (!pending) throw new Error("No login in progress. Run `superwall login` first.");
|
|
143
|
+
if (opts.orgName) pending.orgName = opts.orgName;
|
|
144
|
+
if (opts.app) pending.app = opts.app;
|
|
145
|
+
const tokens = await resolvePollTokens(pending, opts);
|
|
146
|
+
if (!tokens) {
|
|
147
|
+
writePendingLogin(pending);
|
|
148
|
+
return {
|
|
149
|
+
status: "pending",
|
|
150
|
+
pending
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
pending.tokens = tokens;
|
|
154
|
+
writePendingLogin(pending);
|
|
155
|
+
const finished = await finishLogin(pending, tokens, {
|
|
156
|
+
...opts,
|
|
157
|
+
orgName: pending.orgName,
|
|
158
|
+
app: pending.app
|
|
159
|
+
});
|
|
160
|
+
if ("session" in finished) {
|
|
161
|
+
removePendingLogin();
|
|
162
|
+
return {
|
|
163
|
+
status: "logged_in",
|
|
164
|
+
session: finished.session
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
status: "needs_organization",
|
|
169
|
+
pending
|
|
170
|
+
};
|
|
171
|
+
}
|
|
172
|
+
async function resolvePollTokens(pending, opts) {
|
|
173
|
+
const held = pending.tokens;
|
|
174
|
+
if (held) {
|
|
175
|
+
if (!held.refreshToken) return held;
|
|
176
|
+
const fresh = await refreshAccessToken(pending.tokenEndpoint, pending.clientId, held.refreshToken);
|
|
177
|
+
return fresh ? {
|
|
178
|
+
...held,
|
|
179
|
+
...fresh,
|
|
180
|
+
expiresIn: fresh.expiresIn
|
|
181
|
+
} : held;
|
|
182
|
+
}
|
|
183
|
+
if (Date.now() >= pending.expiresAt) {
|
|
184
|
+
removePendingLogin();
|
|
185
|
+
throw new Error("The login request expired. Run `superwall login` again for a new code.");
|
|
186
|
+
}
|
|
187
|
+
try {
|
|
188
|
+
return await pollForToken(pending, Math.min(pending.expiresAt, Date.now() + opts.timeoutMs), opts.onStatus);
|
|
189
|
+
} catch (error) {
|
|
190
|
+
removePendingLogin();
|
|
191
|
+
throw error;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
async function resolveOnboardSetup(opts) {
|
|
195
|
+
if (opts.onOnboard) return opts.onOnboard();
|
|
196
|
+
if (opts.orgName) return {
|
|
197
|
+
orgName: opts.orgName,
|
|
198
|
+
...opts.app ? { app: opts.app } : {}
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
async function finishLogin(pending, tokens, opts) {
|
|
202
|
+
const { apiHost, clientId, tokenEndpoint } = pending;
|
|
203
|
+
const { idToken } = tokens;
|
|
204
|
+
let { refreshToken, expiresIn } = tokens;
|
|
205
|
+
let apiToken = tokens.accessToken;
|
|
110
206
|
if (idToken) await findJson(`${apiHost}/v2/me`, idToken).catch(() => null);
|
|
111
207
|
const me = await findJson(`${apiHost}/v2/me`, apiToken).catch(() => null);
|
|
112
208
|
let hasOrg = false;
|
|
@@ -117,8 +213,8 @@ async function performLogin(opts = {}) {
|
|
|
117
213
|
}
|
|
118
214
|
let createdNewOrg = false;
|
|
119
215
|
if (!hasOrg && !readOnboardedOrg()) {
|
|
120
|
-
|
|
121
|
-
|
|
216
|
+
const setup = await resolveOnboardSetup(opts);
|
|
217
|
+
if (setup === void 0) return { needsOrganization: true };
|
|
122
218
|
if (!setup) throw new Error("Cancelled.");
|
|
123
219
|
opts.onStatus?.("Creating your account…");
|
|
124
220
|
let org;
|
|
@@ -138,8 +234,12 @@ async function performLogin(opts = {}) {
|
|
|
138
234
|
}
|
|
139
235
|
if (createdNewOrg && refreshToken) {
|
|
140
236
|
opts.onStatus?.("Activating your organization…");
|
|
141
|
-
const fresh = await refreshAccessToken(
|
|
142
|
-
if (fresh)
|
|
237
|
+
const fresh = await refreshAccessToken(tokenEndpoint, clientId, refreshToken);
|
|
238
|
+
if (fresh) {
|
|
239
|
+
apiToken = fresh.accessToken;
|
|
240
|
+
refreshToken = fresh.refreshToken;
|
|
241
|
+
expiresIn = fresh.expiresIn;
|
|
242
|
+
}
|
|
143
243
|
}
|
|
144
244
|
const session = {
|
|
145
245
|
authMethod: "oauth",
|
|
@@ -149,11 +249,11 @@ async function performLogin(opts = {}) {
|
|
|
149
249
|
accessToken: apiToken,
|
|
150
250
|
refreshToken,
|
|
151
251
|
accessTokenExpiresAt: expiresIn ? Date.now() + expiresIn * 1e3 : void 0,
|
|
152
|
-
tokenEndpoint
|
|
252
|
+
tokenEndpoint,
|
|
153
253
|
oauthClientId: clientId
|
|
154
254
|
};
|
|
155
255
|
writeSession(session);
|
|
156
|
-
return session;
|
|
256
|
+
return { session };
|
|
157
257
|
}
|
|
158
258
|
async function loginWithApiKey(apiKey, apiHost = API_HOST()) {
|
|
159
259
|
const key = apiKey.trim();
|
|
@@ -198,18 +298,18 @@ async function startDeviceAuth(endpoint, clientId) {
|
|
|
198
298
|
}
|
|
199
299
|
return await r.json();
|
|
200
300
|
}
|
|
201
|
-
async function pollForToken(
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
const r = await fetch(tokenEndpoint, {
|
|
301
|
+
async function pollForToken(pending, deadline, onStatus) {
|
|
302
|
+
let wait = Math.max(0, pending.lastPolledAt + pending.interval * 1e3 - Date.now());
|
|
303
|
+
while (Date.now() + wait < deadline) {
|
|
304
|
+
await setTimeout(wait);
|
|
305
|
+
pending.lastPolledAt = Date.now();
|
|
306
|
+
const r = await fetch(pending.tokenEndpoint, {
|
|
207
307
|
method: "POST",
|
|
208
308
|
headers: { "content-type": "application/x-www-form-urlencoded" },
|
|
209
309
|
body: new URLSearchParams({
|
|
210
310
|
grant_type: DEVICE_GRANT,
|
|
211
|
-
device_code:
|
|
212
|
-
client_id: clientId
|
|
311
|
+
device_code: pending.deviceCode,
|
|
312
|
+
client_id: pending.clientId
|
|
213
313
|
})
|
|
214
314
|
});
|
|
215
315
|
const d = await r.json().catch(() => ({}));
|
|
@@ -222,16 +322,17 @@ async function pollForToken(tokenEndpoint, clientId, dev, onStatus) {
|
|
|
222
322
|
switch (d.error) {
|
|
223
323
|
case "authorization_pending":
|
|
224
324
|
onStatus?.("Waiting for you to approve in the browser…");
|
|
225
|
-
|
|
325
|
+
break;
|
|
226
326
|
case "slow_down":
|
|
227
|
-
interval += 5;
|
|
228
|
-
|
|
327
|
+
pending.interval += 5;
|
|
328
|
+
break;
|
|
229
329
|
case "expired_token": throw new Error("The login request expired - run `superwall login` again.");
|
|
230
330
|
case "access_denied": throw new Error("Login was denied.");
|
|
231
331
|
default: throw new Error(d.error_description || d.error || "Token polling failed.");
|
|
232
332
|
}
|
|
333
|
+
wait = pending.interval * 1e3;
|
|
233
334
|
}
|
|
234
|
-
|
|
335
|
+
return null;
|
|
235
336
|
}
|
|
236
337
|
async function createOrganization(apiHost, token, name) {
|
|
237
338
|
const created = await postJson(`${apiHost}/v2/me/organizations`, token, { name });
|
|
@@ -271,7 +372,13 @@ async function refreshAccessToken(tokenEndpoint, clientId, refreshToken) {
|
|
|
271
372
|
})
|
|
272
373
|
});
|
|
273
374
|
if (!r.ok) return null;
|
|
274
|
-
|
|
375
|
+
const d = await r.json();
|
|
376
|
+
if (!d.access_token) return null;
|
|
377
|
+
return {
|
|
378
|
+
accessToken: d.access_token,
|
|
379
|
+
refreshToken: d.refresh_token ?? refreshToken,
|
|
380
|
+
...d.expires_in === void 0 ? {} : { expiresIn: d.expires_in }
|
|
381
|
+
};
|
|
275
382
|
} catch {
|
|
276
383
|
return null;
|
|
277
384
|
}
|
|
@@ -300,6 +407,120 @@ async function postJson(url, accessToken, body) {
|
|
|
300
407
|
}
|
|
301
408
|
return r.json();
|
|
302
409
|
}
|
|
410
|
+
const POLL_HINT = "superwall login --poll";
|
|
411
|
+
const POLL_TIMEOUT_SECONDS = 60;
|
|
412
|
+
function isPlatform(value) {
|
|
413
|
+
return value === "ios" || value === "android" || value === "web";
|
|
414
|
+
}
|
|
415
|
+
function resolveAgentLogin(flags) {
|
|
416
|
+
const orgName = flags.orgName?.trim() || void 0;
|
|
417
|
+
const appName = flags.appName?.trim() || void 0;
|
|
418
|
+
const base = {
|
|
419
|
+
orgName,
|
|
420
|
+
issuer: flags.host,
|
|
421
|
+
clientId: flags.clientId
|
|
422
|
+
};
|
|
423
|
+
if (!appName) {
|
|
424
|
+
if (flags.platform || flags.bundleId) throw new UsageError("--platform and --bundle-id need --app-name.");
|
|
425
|
+
return base;
|
|
426
|
+
}
|
|
427
|
+
if (!orgName) throw new UsageError("--app-name needs --org-name.");
|
|
428
|
+
if (!flags.platform || !isPlatform(flags.platform)) throw new UsageError("--app-name needs --platform ios, android or web.");
|
|
429
|
+
const bundleId = flags.bundleId?.trim() || void 0;
|
|
430
|
+
return {
|
|
431
|
+
...base,
|
|
432
|
+
app: {
|
|
433
|
+
name: appName,
|
|
434
|
+
platform: flags.platform,
|
|
435
|
+
...bundleId ? { bundleId } : {}
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
const formatExpiry = (pending) => new Date(pending.expiresAt).toISOString();
|
|
440
|
+
async function runAgentLoginStart(ctx, agent, openBrowser$1) {
|
|
441
|
+
const { pending, browserOpened } = await startLogin({
|
|
442
|
+
...agent,
|
|
443
|
+
...openBrowser$1 ? { openBrowser: openBrowser$1 } : {}
|
|
444
|
+
});
|
|
445
|
+
track("login started", { method: "oauth_poll" });
|
|
446
|
+
if (ctx.json) return ctx.output.data({
|
|
447
|
+
status: "pending",
|
|
448
|
+
verification_url: pending.url,
|
|
449
|
+
user_code: pending.userCode,
|
|
450
|
+
expires_at: formatExpiry(pending),
|
|
451
|
+
browser_opened: browserOpened,
|
|
452
|
+
next: POLL_HINT
|
|
453
|
+
});
|
|
454
|
+
ctx.ui.info(`Approve this login in your browser · code \`${pending.userCode}\`\n${pending.url}`);
|
|
455
|
+
if (!browserOpened) ctx.ui.warn(BROWSER_UNAVAILABLE);
|
|
456
|
+
ctx.ui.outro(`Once it's approved, run \`${POLL_HINT}\` to finish. The code expires at ${formatExpiry(pending)}.`);
|
|
457
|
+
}
|
|
458
|
+
async function runAgentLoginPoll(ctx, agent, timeoutSeconds) {
|
|
459
|
+
const { ui: ui$1 } = ctx;
|
|
460
|
+
const seconds = timeoutSeconds !== void 0 && timeoutSeconds >= 0 ? timeoutSeconds : POLL_TIMEOUT_SECONDS;
|
|
461
|
+
const hooks = onboardingHooks((await scanProject(ctx.installDir).catch(() => null))?.apps[0]);
|
|
462
|
+
const spin = ui$1.spinner();
|
|
463
|
+
spin.start("Waiting for you to approve in the browser");
|
|
464
|
+
let result;
|
|
465
|
+
try {
|
|
466
|
+
result = await pollLogin({
|
|
467
|
+
...agent,
|
|
468
|
+
timeoutMs: seconds * 1e3,
|
|
469
|
+
onStatus: (m) => spin.message(m),
|
|
470
|
+
onProvisioned: hooks.onProvisioned
|
|
471
|
+
});
|
|
472
|
+
} catch (e) {
|
|
473
|
+
spin.stop("Login failed");
|
|
474
|
+
track("login finished", {
|
|
475
|
+
status: "error",
|
|
476
|
+
method: "oauth_poll"
|
|
477
|
+
});
|
|
478
|
+
throw e;
|
|
479
|
+
}
|
|
480
|
+
if (result.status === "logged_in") {
|
|
481
|
+
spin.stop(`Logged in as \`${result.session.userEmail ?? "you"}\``);
|
|
482
|
+
track("login finished", {
|
|
483
|
+
status: "success",
|
|
484
|
+
method: "oauth_poll"
|
|
485
|
+
});
|
|
486
|
+
const provisioned = hooks.provisioned();
|
|
487
|
+
if (ctx.json) return ctx.output.data({
|
|
488
|
+
status: "logged_in",
|
|
489
|
+
...serializeSession(result.session),
|
|
490
|
+
...provisioned?.publicApiKey ? { app: {
|
|
491
|
+
public_api_key: provisioned.publicApiKey,
|
|
492
|
+
application_id: provisioned.applicationId ?? null,
|
|
493
|
+
project_id: provisioned.projectId ?? null
|
|
494
|
+
} } : {}
|
|
495
|
+
});
|
|
496
|
+
await ensureSkillsCurrent(false, "login").catch(() => {});
|
|
497
|
+
ui$1.outro(provisioned?.publicApiKey ? "Your app is ready - run `superwall integrate` to set up the SDK." : "You're all set - run `superwall integrate` to set up your app.");
|
|
498
|
+
return;
|
|
499
|
+
}
|
|
500
|
+
ctx.fail();
|
|
501
|
+
if (result.status === "needs_organization") {
|
|
502
|
+
spin.stop("Approved");
|
|
503
|
+
const next = `${POLL_HINT} --org-name "<name>"`;
|
|
504
|
+
const message = `This account has no organization yet. Run \`${next}\` to create one, with --app-name and --platform to create its first app too.`;
|
|
505
|
+
if (ctx.json) return ctx.output.data({
|
|
506
|
+
status: "needs_organization",
|
|
507
|
+
message,
|
|
508
|
+
next
|
|
509
|
+
});
|
|
510
|
+
ui$1.warn(message);
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
const { pending } = result;
|
|
514
|
+
spin.stop("Not approved yet");
|
|
515
|
+
if (ctx.json) return ctx.output.data({
|
|
516
|
+
status: "pending",
|
|
517
|
+
verification_url: pending.url,
|
|
518
|
+
user_code: pending.userCode,
|
|
519
|
+
expires_at: formatExpiry(pending),
|
|
520
|
+
next: POLL_HINT
|
|
521
|
+
});
|
|
522
|
+
ui$1.info(`Still waiting for approval · code \`${pending.userCode}\`\n${pending.url}\nRun \`${POLL_HINT}\` again. The code expires at ${formatExpiry(pending)}.`);
|
|
523
|
+
}
|
|
303
524
|
async function runLogin(ctx, { flags, openBrowser: openBrowser$1 }) {
|
|
304
525
|
const { ui: ui$1 } = ctx;
|
|
305
526
|
ui$1.intro("Superwall login");
|
|
@@ -327,7 +548,9 @@ async function runLogin(ctx, { flags, openBrowser: openBrowser$1 }) {
|
|
|
327
548
|
}
|
|
328
549
|
return;
|
|
329
550
|
}
|
|
330
|
-
|
|
551
|
+
const agent = resolveAgentLogin(flags);
|
|
552
|
+
if (flags.poll) return runAgentLoginPoll(ctx, agent, flags.timeout);
|
|
553
|
+
if (!ctx.interactive) return runAgentLoginStart(ctx, agent, openBrowser$1);
|
|
331
554
|
const hooks = onboardingHooks((await scanProject(ctx.installDir).catch(() => null))?.apps[0]);
|
|
332
555
|
const spin = ui$1.spinner();
|
|
333
556
|
try {
|
|
@@ -366,4 +589,4 @@ async function runLogin(ctx, { flags, openBrowser: openBrowser$1 }) {
|
|
|
366
589
|
}
|
|
367
590
|
|
|
368
591
|
//#endregion
|
|
369
|
-
export {
|
|
592
|
+
export { BROWSER_UNAVAILABLE as a, startLogin as i, pollLogin as n, openBrowser as o, runLogin as r, onboardingHooks as s, performLogin as t };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
2
|
-
import { a as
|
|
2
|
+
import { a as BROWSER_UNAVAILABLE, s as onboardingHooks, t as performLogin } from "./login-BIAWgdzM.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/workflows/login.ts
|
|
5
5
|
async function performLoginWithUi(app, onProvisioned) {
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./token-BJsLGoSX.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import "./environment-CQn323uB.js";
|
|
4
|
+
import "./storage-DqKJe13V.js";
|
|
5
|
+
import "./client-CimFymxG.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import "./telemetry-D_uIIuSk.js";
|
|
8
|
+
import "./spawn-DmmmHIP-.js";
|
|
9
|
+
import "./spinner-TZeZEeVv.js";
|
|
10
|
+
import "./ui-D_qf3Gvw.js";
|
|
11
|
+
import "./scan-CpbfZ2ju.js";
|
|
12
|
+
import "./paths-oRuC18Kt.js";
|
|
13
|
+
import { i as startLogin, n as pollLogin, r as runLogin, t as performLogin } from "./login-BIAWgdzM.js";
|
|
14
|
+
import "./skills-D7sG0xom.js";
|
|
15
|
+
|
|
16
|
+
export { performLogin, pollLogin, runLogin, startLogin };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as ApiError } from "./client-
|
|
2
|
-
import { F as orgProjects, L as rememberOrg, p as listProjects } from "./resources-
|
|
1
|
+
import { t as ApiError } from "./client-CimFymxG.js";
|
|
2
|
+
import { F as orgProjects, L as rememberOrg, p as listProjects } from "./resources-FIrK7pE9.js";
|
|
3
3
|
|
|
4
4
|
//#region src/core/api/lookup.ts
|
|
5
5
|
const DASHBOARD_PATH = /^\/(\d+)(?:\/(\d+))?(?:\/|$)/;
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import "./token-
|
|
1
|
+
import "./token-BJsLGoSX.js";
|
|
2
2
|
import { t as blocks } from "./output-Ggzq5_-t.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import "./client-
|
|
3
|
+
import { c as DASHBOARD_URL, v as VERSION } from "./environment-CQn323uB.js";
|
|
4
|
+
import { n as readSession, s as sessionOrgName } from "./storage-DqKJe13V.js";
|
|
5
|
+
import "./client-CimFymxG.js";
|
|
6
6
|
import "./config-BO1Y87kV.js";
|
|
7
|
-
import "./telemetry-
|
|
7
|
+
import "./telemetry-D_uIIuSk.js";
|
|
8
8
|
import "./spawn-DmmmHIP-.js";
|
|
9
|
-
import "./spinner-
|
|
9
|
+
import "./spinner-TZeZEeVv.js";
|
|
10
10
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
11
11
|
import "./theme-DUsCh-Vd.js";
|
|
12
12
|
import { t as stripReport } from "./log-NVhVe_oe.js";
|
|
13
|
-
import { t as scanProject } from "./scan-
|
|
14
|
-
import { t as detectExisting } from "./existing-
|
|
15
|
-
import "./paths-
|
|
16
|
-
import "./resources-
|
|
17
|
-
import "./lookup-
|
|
18
|
-
import "./login-
|
|
19
|
-
import "./skills-
|
|
20
|
-
import "./selection-
|
|
21
|
-
import { n as requireApi } from "./session-
|
|
22
|
-
import { n as performLoginWithUi } from "./login-
|
|
23
|
-
import { t as runAction } from "./run-
|
|
24
|
-
import { t as detectDrivers } from "./drivers-
|
|
25
|
-
import { _ as screenNameOf, a as buildMigrationCopyPrompt, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, g as placementOfName, h as findScreenCandidates, i as startStudio, l as migrationSource, m as screenMigrationFor, n as migrationNextSteps, o as hasOriginal, p as scaffoldFromScreen, r as screenNextSteps, t as askStudio, u as offerMigration } from "./open-
|
|
26
|
-
import "./server-
|
|
27
|
-
import { r as actionById, t as detectBilling } from "./billing-
|
|
13
|
+
import { t as scanProject } from "./scan-CpbfZ2ju.js";
|
|
14
|
+
import { t as detectExisting } from "./existing-CvOluc9U.js";
|
|
15
|
+
import "./paths-oRuC18Kt.js";
|
|
16
|
+
import "./resources-FIrK7pE9.js";
|
|
17
|
+
import "./lookup-DZFrfzO0.js";
|
|
18
|
+
import "./login-BIAWgdzM.js";
|
|
19
|
+
import "./skills-D7sG0xom.js";
|
|
20
|
+
import "./selection-CHnVk8uw.js";
|
|
21
|
+
import { n as requireApi } from "./session-BFwasPVq.js";
|
|
22
|
+
import { n as performLoginWithUi } from "./login-DLi71nJq.js";
|
|
23
|
+
import { t as runAction } from "./run-CwEY1eu5.js";
|
|
24
|
+
import { t as detectDrivers } from "./drivers-C6eXj5-r.js";
|
|
25
|
+
import { _ as screenNameOf, a as buildMigrationCopyPrompt, c as migrationFor, d as projectDirOf, f as scaffoldFromPaywall, g as placementOfName, h as findScreenCandidates, i as startStudio, l as migrationSource, m as screenMigrationFor, n as migrationNextSteps, o as hasOriginal, p as scaffoldFromScreen, r as screenNextSteps, t as askStudio, u as offerMigration } from "./open-BjvGVwJf.js";
|
|
26
|
+
import "./server-D5xl5iKO.js";
|
|
27
|
+
import { r as actionById, t as detectBilling } from "./billing-CWM1ds3K.js";
|
|
28
28
|
import { n as writeReport } from "./reports-D_qbl7_u.js";
|
|
29
29
|
import { execFile } from "node:child_process";
|
|
30
30
|
import * as fs from "node:fs";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as updateServerNotifications, r as chooseKeyApp } from "./held-
|
|
2
|
-
import { t as apiCall } from "./spinner-
|
|
1
|
+
import { D as updateServerNotifications, r as chooseKeyApp } from "./held-QM7yfrXq.js";
|
|
2
|
+
import { t as apiCall } from "./spinner-TZeZEeVv.js";
|
|
3
3
|
import { i as findAppNotificationUrl } from "./client-BZ1UbpXz.js";
|
|
4
4
|
import { t as timing } from "./timing-BVxPrYq3.js";
|
|
5
5
|
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as ApiError } from "./client-
|
|
1
|
+
import { S as isNonInteractive, c as DASHBOARD_URL } from "./environment-CQn323uB.js";
|
|
2
|
+
import { t as ApiError } from "./client-CimFymxG.js";
|
|
3
3
|
import { t as stripReport } from "./log-NVhVe_oe.js";
|
|
4
|
-
import { i as readPackageJson, r as allDeps } from "./scan-
|
|
5
|
-
import { c as findPaywall, f as listApplications } from "./resources-
|
|
6
|
-
import { d as readBundledSkill } from "./skills-
|
|
7
|
-
import { E as writeApp, S as isScreenOrigin, k as writeOrigin, w as readLock } from "./selection-
|
|
8
|
-
import { c as projectPackageName } from "./session-
|
|
9
|
-
import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-
|
|
10
|
-
import { t as detectDrivers } from "./drivers-
|
|
11
|
-
import { t as runStudio } from "./server-
|
|
4
|
+
import { i as readPackageJson, r as allDeps } from "./scan-CpbfZ2ju.js";
|
|
5
|
+
import { c as findPaywall, f as listApplications } from "./resources-FIrK7pE9.js";
|
|
6
|
+
import { d as readBundledSkill } from "./skills-D7sG0xom.js";
|
|
7
|
+
import { E as writeApp, S as isScreenOrigin, k as writeOrigin, w as readLock } from "./selection-CHnVk8uw.js";
|
|
8
|
+
import { c as projectPackageName } from "./session-BFwasPVq.js";
|
|
9
|
+
import { a as copyToClipboard, i as readPrompt, n as runWithDriverFallback } from "./run-CwEY1eu5.js";
|
|
10
|
+
import { t as detectDrivers } from "./drivers-C6eXj5-r.js";
|
|
11
|
+
import { t as runStudio } from "./server-D5xl5iKO.js";
|
|
12
12
|
import * as fs from "node:fs";
|
|
13
13
|
import * as path from "node:path";
|
|
14
14
|
import fg from "fast-glob";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as withSpinner } from "./spinner-
|
|
1
|
+
import { n as withSpinner } from "./spinner-TZeZEeVv.js";
|
|
2
2
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
3
|
-
import { M as listOrgGroups, N as listOrganizations, T as titleCase, w as rowName } from "./resources-
|
|
3
|
+
import { M as listOrgGroups, N as listOrganizations, T as titleCase, w as rowName } from "./resources-FIrK7pE9.js";
|
|
4
4
|
|
|
5
5
|
//#region src/core/account/org.ts
|
|
6
6
|
async function orgForNewProject(api, interactive) {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import "./token-
|
|
1
|
+
import "./token-BJsLGoSX.js";
|
|
2
2
|
import "./output-Ggzq5_-t.js";
|
|
3
|
-
import "./environment-
|
|
4
|
-
import "./storage-
|
|
5
|
-
import "./client-
|
|
3
|
+
import "./environment-CQn323uB.js";
|
|
4
|
+
import "./storage-DqKJe13V.js";
|
|
5
|
+
import "./client-CimFymxG.js";
|
|
6
6
|
import "./config-BO1Y87kV.js";
|
|
7
|
-
import { i as updateTelemetryTags, r as track } from "./telemetry-
|
|
7
|
+
import { i as updateTelemetryTags, r as track } from "./telemetry-D_uIIuSk.js";
|
|
8
8
|
import "./spawn-DmmmHIP-.js";
|
|
9
|
-
import "./spinner-
|
|
9
|
+
import "./spinner-TZeZEeVv.js";
|
|
10
10
|
import "./ui-D_qf3Gvw.js";
|
|
11
|
-
import { t as scanProject } from "./scan-
|
|
12
|
-
import "./paths-
|
|
13
|
-
import { d as readBundledSkill } from "./skills-
|
|
14
|
-
import { n as FRAMEWORK_REF, t as detectBilling } from "./billing-
|
|
11
|
+
import { t as scanProject } from "./scan-CpbfZ2ju.js";
|
|
12
|
+
import "./paths-oRuC18Kt.js";
|
|
13
|
+
import { d as readBundledSkill } from "./skills-D7sG0xom.js";
|
|
14
|
+
import { n as FRAMEWORK_REF, t as detectBilling } from "./billing-CWM1ds3K.js";
|
|
15
15
|
|
|
16
16
|
//#region src/core/workflows/playbook.ts
|
|
17
17
|
async function printPlaybook(installDir, playbook) {
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import "./token-
|
|
1
|
+
import "./token-BJsLGoSX.js";
|
|
2
2
|
import "./output-Ggzq5_-t.js";
|
|
3
|
-
import {
|
|
4
|
-
import "./storage-
|
|
5
|
-
import { t as ApiError } from "./client-
|
|
3
|
+
import { v as VERSION } from "./environment-CQn323uB.js";
|
|
4
|
+
import "./storage-DqKJe13V.js";
|
|
5
|
+
import { t as ApiError } from "./client-CimFymxG.js";
|
|
6
6
|
import "./config-BO1Y87kV.js";
|
|
7
|
-
import "./telemetry-
|
|
7
|
+
import "./telemetry-D_uIIuSk.js";
|
|
8
8
|
import "./spawn-DmmmHIP-.js";
|
|
9
|
-
import "./spinner-
|
|
9
|
+
import "./spinner-TZeZEeVv.js";
|
|
10
10
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
11
|
-
import "./scan-
|
|
12
|
-
import "./paths-
|
|
13
|
-
import { b as promotePaywallVersion, g as livePaywallVersion } from "./resources-
|
|
14
|
-
import "./lookup-
|
|
15
|
-
import "./login-
|
|
16
|
-
import "./skills-
|
|
17
|
-
import { N as resolveFramework, a as resolveProjectDir, g as transition, s as selectSurfaces, v as collectProjectDeclarations, w as readLock } from "./selection-
|
|
18
|
-
import { _ as targetLabel, g as planTargets, h as parsePlatformFlags, n as requireApi, v as wantedPlatforms, x as resolveApps, y as resolveBinding } from "./session-
|
|
19
|
-
import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-
|
|
20
|
-
import "./login-
|
|
11
|
+
import "./scan-CpbfZ2ju.js";
|
|
12
|
+
import "./paths-oRuC18Kt.js";
|
|
13
|
+
import { b as promotePaywallVersion, g as livePaywallVersion } from "./resources-FIrK7pE9.js";
|
|
14
|
+
import "./lookup-DZFrfzO0.js";
|
|
15
|
+
import "./login-BIAWgdzM.js";
|
|
16
|
+
import "./skills-D7sG0xom.js";
|
|
17
|
+
import { N as resolveFramework, a as resolveProjectDir, g as transition, s as selectSurfaces, v as collectProjectDeclarations, w as readLock } from "./selection-CHnVk8uw.js";
|
|
18
|
+
import { _ as targetLabel, g as planTargets, h as parsePlatformFlags, n as requireApi, v as wantedPlatforms, x as resolveApps, y as resolveBinding } from "./session-BFwasPVq.js";
|
|
19
|
+
import { a as pickApplicationOption, i as timed, o as pickAdoptOption, t as group } from "./push-Ul2SW87i.js";
|
|
20
|
+
import "./login-DLi71nJq.js";
|
|
21
21
|
import pc from "picocolors";
|
|
22
22
|
|
|
23
23
|
//#region src/core/paywalls/promote.ts
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import "./token-BJsLGoSX.js";
|
|
2
|
+
import "./output-Ggzq5_-t.js";
|
|
3
|
+
import "./environment-CQn323uB.js";
|
|
4
|
+
import "./storage-DqKJe13V.js";
|
|
5
|
+
import "./client-CimFymxG.js";
|
|
6
|
+
import "./config-BO1Y87kV.js";
|
|
7
|
+
import "./telemetry-D_uIIuSk.js";
|
|
8
|
+
import "./spawn-DmmmHIP-.js";
|
|
9
|
+
import "./spinner-TZeZEeVv.js";
|
|
10
|
+
import "./ui-D_qf3Gvw.js";
|
|
11
|
+
import "./scan-CpbfZ2ju.js";
|
|
12
|
+
import "./paths-oRuC18Kt.js";
|
|
13
|
+
import "./resources-FIrK7pE9.js";
|
|
14
|
+
import "./lookup-DZFrfzO0.js";
|
|
15
|
+
import "./login-BIAWgdzM.js";
|
|
16
|
+
import "./skills-D7sG0xom.js";
|
|
17
|
+
import "./selection-CHnVk8uw.js";
|
|
18
|
+
import "./session-BFwasPVq.js";
|
|
19
|
+
import { i as timed, n as runPush, r as runPushPipeline, t as group } from "./push-Ul2SW87i.js";
|
|
20
|
+
import "./login-DLi71nJq.js";
|
|
21
|
+
|
|
22
|
+
export { group, runPush, runPushPipeline, timed };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { v as VERSION } from "./environment-CQn323uB.js";
|
|
2
2
|
import { n as ui } from "./ui-D_qf3Gvw.js";
|
|
3
|
-
import { C as pushedProducts, E as versionProducts, S as pushPaywallVersion, b as promotePaywallVersion, h as livePaywall, v as platformLabel, y as platformStore } from "./resources-
|
|
4
|
-
import { A as writeSnapshot, F as requireAssets, I as syncAssets, M as frameworkVersion, N as resolveFramework, O as writeBindings, P as assetBaseUrl, T as removeBinding, _ as weight, a as resolveProjectDir, b as describeBindings, c as storesDiffer, d as kb, f as pendingPromoteWarning, g as transition, h as took, i as requireProject, l as BIND_VERB, m as resolveNote, p as pushedLine, r as requireClean, s as selectSurfaces, t as needsWork, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-
|
|
5
|
-
import { _ as targetLabel, d as listProjectCatalogue, g as planTargets, h as parsePlatformFlags, i as pushSource, l as writeProjectScaffold, m as requireProducts, n as requireApi, o as collectSourceFiles, p as projectForApplication, r as assertGit, s as warnNotPortable, v as wantedPlatforms, x as resolveApps, y as resolveBinding } from "./session-
|
|
3
|
+
import { C as pushedProducts, E as versionProducts, S as pushPaywallVersion, b as promotePaywallVersion, h as livePaywall, v as platformLabel, y as platformStore } from "./resources-FIrK7pE9.js";
|
|
4
|
+
import { A as writeSnapshot, F as requireAssets, I as syncAssets, M as frameworkVersion, N as resolveFramework, O as writeBindings, P as assetBaseUrl, T as removeBinding, _ as weight, a as resolveProjectDir, b as describeBindings, c as storesDiffer, d as kb, f as pendingPromoteWarning, g as transition, h as took, i as requireProject, l as BIND_VERB, m as resolveNote, p as pushedLine, r as requireClean, s as selectSurfaces, t as needsWork, v as collectProjectDeclarations, w as readLock, y as writeProjectTypes } from "./selection-CHnVk8uw.js";
|
|
5
|
+
import { _ as targetLabel, d as listProjectCatalogue, g as planTargets, h as parsePlatformFlags, i as pushSource, l as writeProjectScaffold, m as requireProducts, n as requireApi, o as collectSourceFiles, p as projectForApplication, r as assertGit, s as warnNotPortable, v as wantedPlatforms, x as resolveApps, y as resolveBinding } from "./session-BFwasPVq.js";
|
|
6
6
|
import pc from "picocolors";
|
|
7
7
|
import { cpus } from "node:os";
|
|
8
8
|
|