create-snipara 1.3.39 → 1.3.40
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/index.js +31 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { homedir } from "os";
|
|
|
13
13
|
// package.json
|
|
14
14
|
var package_default = {
|
|
15
15
|
name: "create-snipara",
|
|
16
|
-
version: "1.3.
|
|
16
|
+
version: "1.3.40",
|
|
17
17
|
description: "Onboard Snipara Hosted MCP Context + Memory with auth, companion workflows, and optional Snipara Sandbox",
|
|
18
18
|
main: "dist/index.js",
|
|
19
19
|
type: "module",
|
|
@@ -607,7 +607,10 @@ async function gatherConfiguration(options) {
|
|
|
607
607
|
let signupResult = null;
|
|
608
608
|
if (!apiKey && response.profile !== "runtime-only") {
|
|
609
609
|
if (response.apiKeyType === "signup") {
|
|
610
|
-
signupResult = await handleSignup(
|
|
610
|
+
signupResult = await handleSignup({
|
|
611
|
+
projectHint: response.projectSlug,
|
|
612
|
+
repoHint: detectedGitRepo?.fullName
|
|
613
|
+
});
|
|
611
614
|
apiKey = signupResult.apiKey;
|
|
612
615
|
apiKeyType = "api";
|
|
613
616
|
} else if (response.apiKeyType === "api") {
|
|
@@ -800,10 +803,10 @@ function buildAnswersFromProfile(input) {
|
|
|
800
803
|
githubPath: input.githubPath
|
|
801
804
|
};
|
|
802
805
|
}
|
|
803
|
-
async function handleSignup() {
|
|
806
|
+
async function handleSignup(hints = {}) {
|
|
804
807
|
console.log(chalk.bold("\n\u{1F510} Browser Account Authorization\n"));
|
|
805
808
|
try {
|
|
806
|
-
return await runDeviceAuthorization();
|
|
809
|
+
return await runDeviceAuthorization(hints);
|
|
807
810
|
} catch (error) {
|
|
808
811
|
if (error instanceof DeviceAuthorizationAborted) {
|
|
809
812
|
throw error;
|
|
@@ -831,7 +834,27 @@ async function handleManualSignup() {
|
|
|
831
834
|
});
|
|
832
835
|
return { apiKey: response.apiKey };
|
|
833
836
|
}
|
|
834
|
-
|
|
837
|
+
function normalizeDeviceFlowHint(value) {
|
|
838
|
+
const normalized = value?.trim();
|
|
839
|
+
return normalized && !normalized.includes("<") && !normalized.includes(">") ? normalized : null;
|
|
840
|
+
}
|
|
841
|
+
function appendDeviceFlowHints(url, hints) {
|
|
842
|
+
try {
|
|
843
|
+
const parsed = new URL(url);
|
|
844
|
+
const projectHint = normalizeDeviceFlowHint(hints.projectHint);
|
|
845
|
+
const repoHint = normalizeDeviceFlowHint(hints.repoHint);
|
|
846
|
+
if (projectHint) {
|
|
847
|
+
parsed.searchParams.set("project_hint", projectHint);
|
|
848
|
+
}
|
|
849
|
+
if (repoHint) {
|
|
850
|
+
parsed.searchParams.set("repo_hint", repoHint);
|
|
851
|
+
}
|
|
852
|
+
return parsed.toString();
|
|
853
|
+
} catch {
|
|
854
|
+
return url;
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
async function runDeviceAuthorization(hints = {}) {
|
|
835
858
|
const codeResponse = await postJson(`${BASE_URL}/api/oauth/device/code`, {
|
|
836
859
|
client_id: DEVICE_CLIENT_ID,
|
|
837
860
|
scope: "mcp:read mcp:write",
|
|
@@ -840,11 +863,10 @@ async function runDeviceAuthorization() {
|
|
|
840
863
|
if (codeResponse.error) {
|
|
841
864
|
throw new Error(codeResponse.error_description || codeResponse.error);
|
|
842
865
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
);
|
|
866
|
+
const verificationUrl = appendDeviceFlowHints(codeResponse.verification_uri_complete, hints);
|
|
867
|
+
console.log(chalk.cyan(` Opening ${verificationUrl} in your browser...`));
|
|
846
868
|
console.log(chalk.dim(` Device code: ${codeResponse.user_code}`));
|
|
847
|
-
openBrowser(
|
|
869
|
+
openBrowser(verificationUrl);
|
|
848
870
|
const spinner = ora("Waiting for Snipara authorization in the browser...").start();
|
|
849
871
|
const startedAt = Date.now();
|
|
850
872
|
let intervalMs = Math.max(1, codeResponse.interval || 5) * 1e3;
|
package/package.json
CHANGED