vibedgames 0.8.1 → 0.10.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 +17 -8
- package/assets/align-framing.py +242 -0
- package/assets/render-model.py +406 -0
- package/assets/tilemap-editor.html +630 -0
- package/dist/THIRD_PARTY_NOTICES.txt +59 -7
- package/dist/chunk-2KVQJKIZ.js +6495 -0
- package/dist/chunk-2SBBKY5C.js +16993 -0
- package/dist/chunk-2ZKS7V72.js +170 -0
- package/dist/{chunk-RAUJA3OY.js → chunk-3HGBIUM5.js} +21 -18
- package/dist/chunk-3UGGMFJJ.js +22 -0
- package/dist/{chunk-I6O4HIDY.js → chunk-42K3BJJH.js} +163 -131
- package/dist/chunk-43P4U7CB.js +104 -0
- package/dist/chunk-4FJXCS3K.js +741 -0
- package/dist/{chunk-NC5XCGYU.js → chunk-4UU622RK.js} +6 -5
- package/dist/{chunk-2QBYTIMH.js → chunk-5535KDYI.js} +1 -1
- package/dist/chunk-5YPLKGY3.js +87 -0
- package/dist/chunk-6KXXZXSO.js +475 -0
- package/dist/chunk-7RPLQWR2.js +91 -0
- package/dist/{chunk-C2IRIRAA.js → chunk-A556KALN.js} +15 -14
- package/dist/{chunk-N3XAUFKH.js → chunk-ABTUEIRC.js} +576 -301
- package/dist/{chunk-PEUP4MZR.js → chunk-AWJNAGPE.js} +6 -3
- package/dist/{chunk-QGEITHUP.js → chunk-BN3Q7UEC.js} +22 -19
- package/dist/chunk-BZOMEG3X.js +412 -0
- package/dist/{chunk-ZYCSYJWX.js → chunk-COSLGSVO.js} +14 -24
- package/dist/{chunk-PQDBCZRT.js → chunk-CTY2WZQK.js} +204 -158
- package/dist/{chunk-CU7UY5YJ.js → chunk-D2RF35HJ.js} +1 -1
- package/dist/chunk-DB7WVFS7.js +80 -0
- package/dist/chunk-DOOQUFPG.js +73 -0
- package/dist/chunk-E3FJUPLT.js +177 -0
- package/dist/chunk-E7NDOZ27.js +428 -0
- package/dist/chunk-F42QKWBB.js +39 -0
- package/dist/chunk-FXXVXDTW.js +168 -0
- package/dist/{chunk-VFFOT7KD.js → chunk-G66HRVDW.js} +1 -1
- package/dist/{chunk-CAKBGDCY.js → chunk-GKDUYJ7R.js} +5 -0
- package/dist/chunk-GLEW7VJQ.js +45 -0
- package/dist/{chunk-MGIASPED.js → chunk-H2C4QUTG.js} +9 -8
- package/dist/{chunk-HCMTSR7E.js → chunk-HRKVAXNN.js} +21 -17
- package/dist/{chunk-TLRL6FHW.js → chunk-HSMG6U7J.js} +10 -9
- package/dist/chunk-HX5Q63UA.js +48 -0
- package/dist/chunk-HYOXGNWS.js +53 -0
- package/dist/chunk-I5LELJSK.js +22 -0
- package/dist/{chunk-6FZPPUQH.js → chunk-JN4WZCR7.js} +5 -4
- package/dist/{chunk-QJZ72MSY.js → chunk-K36EOII3.js} +7 -6
- package/dist/chunk-KAGVI3CE.js +62 -0
- package/dist/chunk-KJK5CB6E.js +58 -0
- package/dist/chunk-KLFBAFXD.js +25 -0
- package/dist/{chunk-7MKUR7Y3.js → chunk-LONQWRTR.js} +112 -81
- package/dist/chunk-LORGE2NB.js +2484 -0
- package/dist/{chunk-HKA5LBYW.js → chunk-MEAO33XW.js} +22 -19
- package/dist/{chunk-PM5UOIKR.js → chunk-MR5KIFI7.js} +22 -21
- package/dist/{chunk-GCX5KQ6A.js → chunk-N2UHAQXC.js} +18 -11
- package/dist/chunk-NCX6LYNJ.js +117 -0
- package/dist/chunk-OGX4DKIS.js +215 -0
- package/dist/chunk-OPUCUUID.js +41 -0
- package/dist/chunk-Q2QC6KAZ.js +132 -0
- package/dist/{chunk-2GL2WJZX.js → chunk-Q3XQPNF6.js} +14 -14
- package/dist/{chunk-RYFO3ZPO.js → chunk-Q5NZNXJE.js} +15 -12
- package/dist/{chunk-JT2AU24K.js → chunk-QARXJGI5.js} +1 -1
- package/dist/chunk-QLCVLCPM.js +126 -0
- package/dist/chunk-R2WVORGD.js +91 -0
- package/dist/chunk-RKS7SI5L.js +64 -0
- package/dist/{chunk-4BGCA3W7.js → chunk-RPJR3S5S.js} +32 -18
- package/dist/chunk-RPSUFZAG.js +3307 -0
- package/dist/chunk-RRI23NK2.js +40 -0
- package/dist/chunk-S7HYWITX.js +57 -0
- package/dist/chunk-SBXCK2I2.js +48 -0
- package/dist/chunk-SUSX3QIA.js +62 -0
- package/dist/{chunk-PHEDW6C7.js → chunk-SXYQL4GK.js} +16 -7
- package/dist/{chunk-ZI6PKVXG.js → chunk-TMPBGXT4.js} +6 -5
- package/dist/chunk-TXOE5UY5.js +72 -0
- package/dist/chunk-U6DTE5IX.js +124 -0
- package/dist/chunk-UPHB5HWO.js +115 -0
- package/dist/chunk-UQ7VO6B3.js +91 -0
- package/dist/chunk-VB4WLJR2.js +47 -0
- package/dist/{chunk-FNYBZNW2.js → chunk-VIEKOGKG.js} +21 -3
- package/dist/{chunk-QIVCBUYD.js → chunk-VZEJ2ZHE.js} +18 -18
- package/dist/chunk-X75Y7LUW.js +126 -0
- package/dist/{chunk-Z4Z24FWO.js → chunk-YNCYMWER.js} +8 -5
- package/dist/chunk-ZHLPE6LI.js +71 -0
- package/dist/index.js +48 -34
- package/package.json +32 -16
- package/templates/none/src/main.ts +4 -0
- package/templates/none/vite.config.ts +0 -2
- package/templates/phaser/src/main.ts +0 -1
- package/templates/phaser/src/scenes/game-scene.ts +10 -8
- package/templates/phaser/vite.config.ts +0 -2
- package/templates/react-r3f/src/app.tsx +3 -1
- package/templates/react-r3f/src/main.tsx +1 -0
- package/templates/react-r3f/vite.config.ts +0 -2
- package/templates/threejs/src/main.ts +10 -1
- package/templates/threejs/vite.config.ts +0 -2
- package/LICENSE +0 -21
- package/dist/chunk-AYJQVZXY.js +0 -39
- package/dist/chunk-J6PKNPI2.js +0 -26
- package/dist/chunk-MJQSHP3Y.js +0 -415
- package/dist/chunk-MYFLYNPO.js +0 -68
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
analyzeBaseline,
|
|
9
|
+
fail,
|
|
10
|
+
failUsage,
|
|
11
|
+
getInt,
|
|
12
|
+
getString,
|
|
13
|
+
main,
|
|
14
|
+
parseArgs,
|
|
15
|
+
parseFrame,
|
|
16
|
+
resolveTargets,
|
|
17
|
+
writeJsonFile
|
|
18
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
19
|
+
import "./chunk-2SBBKY5C.js";
|
|
20
|
+
import "./chunk-GKDUYJ7R.js";
|
|
21
|
+
|
|
22
|
+
// src/commands/asset/sprite-baseline.ts
|
|
23
|
+
import { statSync } from "node:fs";
|
|
24
|
+
import path from "node:path";
|
|
25
|
+
var run = (argv) => {
|
|
26
|
+
main(() => {
|
|
27
|
+
const args = parseArgs([...argv], {
|
|
28
|
+
values: ["frame", "json", "out", "out-dir", "target-bottom", "target-center-x"]
|
|
29
|
+
});
|
|
30
|
+
const [input = ""] = args.positionals;
|
|
31
|
+
if (input === "") {
|
|
32
|
+
failUsage("A PNG file or folder path is required.");
|
|
33
|
+
}
|
|
34
|
+
const frameSpec = getString(args, "frame") ?? "";
|
|
35
|
+
if (frameSpec === "") {
|
|
36
|
+
failUsage("--frame is required, e.g. --frame 256x256");
|
|
37
|
+
}
|
|
38
|
+
const frame = parseFrame(frameSpec);
|
|
39
|
+
const targetBottom = getInt(args, "target-bottom", frame.height - 1);
|
|
40
|
+
const targetCenterX = getString(args, "target-center-x") === void 0 ? null : getInt(args, "target-center-x", 0);
|
|
41
|
+
const targets = resolveTargets(input);
|
|
42
|
+
if (targets.length === 0) {
|
|
43
|
+
fail(`No PNG files found in ${input}`);
|
|
44
|
+
}
|
|
45
|
+
const out = getString(args, "out") ?? "";
|
|
46
|
+
const outDir = getString(args, "out-dir") ?? "";
|
|
47
|
+
if (out !== "" && outDir !== "") {
|
|
48
|
+
fail("Use either --out or --out-dir, not both.");
|
|
49
|
+
}
|
|
50
|
+
if (out !== "" && targets.length !== 1) {
|
|
51
|
+
fail("--out can only be used with a single PNG input; use --out-dir for folders.");
|
|
52
|
+
}
|
|
53
|
+
const inputIsFile = statSync(input).isFile();
|
|
54
|
+
const reports = targets.map((target) => {
|
|
55
|
+
let outPath = null;
|
|
56
|
+
if (out !== "") {
|
|
57
|
+
outPath = out;
|
|
58
|
+
} else if (outDir !== "") {
|
|
59
|
+
outPath = path.join(
|
|
60
|
+
outDir,
|
|
61
|
+
inputIsFile ? path.basename(target) : path.relative(input, target)
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const report = analyzeBaseline(target, frame, targetBottom, targetCenterX, outPath);
|
|
65
|
+
const bottomRange = report.visibleBottomYRange;
|
|
66
|
+
const shiftRange = report.shiftYRange;
|
|
67
|
+
console.log(
|
|
68
|
+
`${target} frame=${frame.width}x${frame.height} bottom_range=${bottomRange ? `[${bottomRange.join(", ")}]` : "None"} shift_y_range=${shiftRange ? `[${shiftRange.join(", ")}]` : "None"}`
|
|
69
|
+
);
|
|
70
|
+
return report;
|
|
71
|
+
});
|
|
72
|
+
const json = getString(args, "json") ?? "";
|
|
73
|
+
if (json !== "") {
|
|
74
|
+
writeJsonFile(json, reports);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
export {
|
|
79
|
+
run
|
|
80
|
+
};
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
buildSequenceGif,
|
|
9
|
+
fail,
|
|
10
|
+
failUsage,
|
|
11
|
+
getString,
|
|
12
|
+
main,
|
|
13
|
+
parseArgs,
|
|
14
|
+
parseColor
|
|
15
|
+
} from "./chunk-2KVQJKIZ.js";
|
|
16
|
+
import "./chunk-2SBBKY5C.js";
|
|
17
|
+
import "./chunk-GKDUYJ7R.js";
|
|
18
|
+
|
|
19
|
+
// src/commands/asset/build-sequence-gif.ts
|
|
20
|
+
import { mkdirSync, writeFileSync } from "node:fs";
|
|
21
|
+
import path from "node:path";
|
|
22
|
+
var run = (argv) => {
|
|
23
|
+
main(() => {
|
|
24
|
+
const args = parseArgs([...argv], {
|
|
25
|
+
values: ["durations-ms", "flat-bg", "input-dir", "order", "out", "pattern"]
|
|
26
|
+
});
|
|
27
|
+
const inputDir = getString(args, "input-dir") ?? "";
|
|
28
|
+
const order = getString(args, "order") ?? "";
|
|
29
|
+
const out = getString(args, "out") ?? "";
|
|
30
|
+
if (inputDir === "") {
|
|
31
|
+
failUsage("--input-dir is required");
|
|
32
|
+
}
|
|
33
|
+
if (order === "") {
|
|
34
|
+
failUsage("--order is required, e.g. --order 01,03,02,04");
|
|
35
|
+
}
|
|
36
|
+
if (out === "") {
|
|
37
|
+
failUsage("--out is required");
|
|
38
|
+
}
|
|
39
|
+
const ids = order.split(",").map((part) => part.trim()).filter(Boolean);
|
|
40
|
+
if (ids.length === 0) {
|
|
41
|
+
fail("No frames selected");
|
|
42
|
+
}
|
|
43
|
+
const pattern = getString(args, "pattern") ?? "frame-{id}.png";
|
|
44
|
+
const durationsSpec = getString(args, "durations-ms") ?? "";
|
|
45
|
+
let durations = null;
|
|
46
|
+
if (durationsSpec !== "") {
|
|
47
|
+
durations = durationsSpec.split(",").map((part) => part.trim()).filter(Boolean).map(Number);
|
|
48
|
+
if (durations.length !== ids.length) {
|
|
49
|
+
fail("durations-ms length must match frame order length");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
const flatBg = getString(args, "flat-bg") ?? "";
|
|
53
|
+
const frames = ids.map((id, i) => ({
|
|
54
|
+
delayMs: durations?.[i] ?? 120,
|
|
55
|
+
path: path.resolve(inputDir, pattern.replace("{id}", id))
|
|
56
|
+
}));
|
|
57
|
+
let gif;
|
|
58
|
+
try {
|
|
59
|
+
gif = buildSequenceGif(frames, flatBg === "" ? null : parseColor(flatBg));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof Error && "code" in error && error.code === "ENOENT") {
|
|
62
|
+
fail(`frame file not found: ${"path" in error ? String(error.path) : "undefined"}`);
|
|
63
|
+
}
|
|
64
|
+
throw error;
|
|
65
|
+
}
|
|
66
|
+
mkdirSync(path.dirname(path.resolve(out)), { recursive: true });
|
|
67
|
+
writeFileSync(out, gif);
|
|
68
|
+
console.log(out);
|
|
69
|
+
});
|
|
70
|
+
};
|
|
71
|
+
export {
|
|
72
|
+
run
|
|
73
|
+
};
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { createRequire as __createRequire } from "node:module";
|
|
2
|
+
import { dirname as __pathDirname } from "node:path";
|
|
3
|
+
import { fileURLToPath as __fileURLToPath } from "node:url";
|
|
4
|
+
const require = __createRequire(import.meta.url);
|
|
5
|
+
var __filename = __fileURLToPath(import.meta.url);
|
|
6
|
+
var __dirname = __pathDirname(__filename);
|
|
7
|
+
import {
|
|
8
|
+
getConfig,
|
|
9
|
+
saveConfig
|
|
10
|
+
} from "./chunk-Q5NZNXJE.js";
|
|
11
|
+
import {
|
|
12
|
+
isJsonNumber,
|
|
13
|
+
isJsonObject,
|
|
14
|
+
isJsonString,
|
|
15
|
+
parseJson
|
|
16
|
+
} from "./chunk-RPSUFZAG.js";
|
|
17
|
+
|
|
18
|
+
// ../../packages/contract/src/auth/oauth-scopes.ts
|
|
19
|
+
var OAUTH_SCOPES = {
|
|
20
|
+
"credits:read": "See your credit balance",
|
|
21
|
+
"credits:write": "Buy credits and redeem credit codes",
|
|
22
|
+
"games:read": "See your games and download their source",
|
|
23
|
+
"games:write": "Deploy, update and delete your games",
|
|
24
|
+
generate: "Generate images, audio, video and 3D with your credits",
|
|
25
|
+
playtest: "Let a model playtest your games"
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// ../../packages/contract/src/cli.ts
|
|
29
|
+
var CLI_VERSION_HEADER = "x-vg-cli";
|
|
30
|
+
var CLI_OAUTH_CLIENT_ID = "vibedgames-cli";
|
|
31
|
+
var CLI_OAUTH_SCOPES = [
|
|
32
|
+
"openid",
|
|
33
|
+
"profile",
|
|
34
|
+
"email",
|
|
35
|
+
"offline_access",
|
|
36
|
+
...Object.keys(OAUTH_SCOPES)
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
// src/lib/oauth.ts
|
|
40
|
+
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
41
|
+
var EXPIRY_MARGIN_MS = 6e4;
|
|
42
|
+
var apiResource = (baseUrl) => `${new URL(baseUrl).origin}/api`;
|
|
43
|
+
var authUrl = (baseUrl, path) => `${new URL(baseUrl).origin}/api/auth${path}`;
|
|
44
|
+
var OAuthError = class extends Error {
|
|
45
|
+
code;
|
|
46
|
+
constructor(code, description) {
|
|
47
|
+
super(description !== void 0 && description !== "" ? `${code}: ${description}` : code);
|
|
48
|
+
this.code = code;
|
|
49
|
+
this.name = "OAuthError";
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var postForm = async (url, body) => {
|
|
53
|
+
const res = await fetch(url, {
|
|
54
|
+
body: new URLSearchParams(body),
|
|
55
|
+
headers: { accept: "application/json" },
|
|
56
|
+
method: "POST"
|
|
57
|
+
});
|
|
58
|
+
const data = await res.text().then(parseJson).catch(() => null);
|
|
59
|
+
if (!isJsonObject(data)) {
|
|
60
|
+
throw new OAuthError("server_error", `HTTP ${res.status}`);
|
|
61
|
+
}
|
|
62
|
+
if (!res.ok) {
|
|
63
|
+
const { error, error_description: description } = data;
|
|
64
|
+
throw new OAuthError(
|
|
65
|
+
isJsonString(error) ? error : "server_error",
|
|
66
|
+
isJsonString(description) ? description : `HTTP ${res.status}`
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
return data;
|
|
70
|
+
};
|
|
71
|
+
var requestDeviceCode = async (baseUrl) => {
|
|
72
|
+
const data = await postForm(authUrl(baseUrl, "/device/code"), {
|
|
73
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
74
|
+
resource: apiResource(baseUrl),
|
|
75
|
+
scope: CLI_OAUTH_SCOPES.join(" ")
|
|
76
|
+
});
|
|
77
|
+
const {
|
|
78
|
+
device_code: deviceCode,
|
|
79
|
+
expires_in: expiresIn,
|
|
80
|
+
interval,
|
|
81
|
+
user_code: userCode,
|
|
82
|
+
verification_uri: verificationUri,
|
|
83
|
+
verification_uri_complete: verificationUriComplete
|
|
84
|
+
} = data;
|
|
85
|
+
if (!isJsonString(deviceCode) || !isJsonString(userCode) || !isJsonString(verificationUri)) {
|
|
86
|
+
throw new OAuthError("server_error", "malformed device authorization response");
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
deviceCode,
|
|
90
|
+
expiresIn: isJsonNumber(expiresIn) ? expiresIn : 600,
|
|
91
|
+
interval: isJsonNumber(interval) ? interval : 5,
|
|
92
|
+
userCode,
|
|
93
|
+
verificationUri,
|
|
94
|
+
verificationUriComplete: isJsonString(verificationUriComplete) ? verificationUriComplete : verificationUri
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
var toConfig = (baseUrl, data, previousRefresh) => {
|
|
98
|
+
const { access_token: token, expires_in: expiresIn, refresh_token: refreshToken } = data;
|
|
99
|
+
if (!isJsonString(token)) {
|
|
100
|
+
throw new OAuthError("server_error", "token response carries no access_token");
|
|
101
|
+
}
|
|
102
|
+
return {
|
|
103
|
+
baseUrl,
|
|
104
|
+
expiresAt: isJsonNumber(expiresIn) ? Date.now() + expiresIn * 1e3 : void 0,
|
|
105
|
+
refreshToken: isJsonString(refreshToken) ? refreshToken : previousRefresh,
|
|
106
|
+
token
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
var pollDeviceToken = async (baseUrl, deviceCode) => toConfig(
|
|
110
|
+
baseUrl,
|
|
111
|
+
await postForm(authUrl(baseUrl, "/oauth2/token"), {
|
|
112
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
113
|
+
device_code: deviceCode,
|
|
114
|
+
grant_type: DEVICE_CODE_GRANT_TYPE
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
var needsRefresh = (config, now = Date.now()) => config.refreshToken !== void 0 && config.refreshToken !== "" && config.expiresAt !== void 0 && config.expiresAt !== 0 && config.expiresAt - EXPIRY_MARGIN_MS <= now;
|
|
118
|
+
var refresh = async (config) => {
|
|
119
|
+
const next = toConfig(
|
|
120
|
+
config.baseUrl,
|
|
121
|
+
await postForm(authUrl(config.baseUrl, "/oauth2/token"), {
|
|
122
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
123
|
+
grant_type: "refresh_token",
|
|
124
|
+
refresh_token: config.refreshToken,
|
|
125
|
+
resource: apiResource(config.baseUrl)
|
|
126
|
+
}),
|
|
127
|
+
config.refreshToken
|
|
128
|
+
);
|
|
129
|
+
saveConfig(next);
|
|
130
|
+
return next;
|
|
131
|
+
};
|
|
132
|
+
var refreshing = null;
|
|
133
|
+
var getAccessToken = async () => {
|
|
134
|
+
if (process.env.VG_TOKEN !== void 0 && process.env.VG_TOKEN !== "") {
|
|
135
|
+
return process.env.VG_TOKEN;
|
|
136
|
+
}
|
|
137
|
+
const config = getConfig();
|
|
138
|
+
if (!config) {
|
|
139
|
+
return null;
|
|
140
|
+
}
|
|
141
|
+
if (!needsRefresh(config) || config.refreshToken === void 0 || config.refreshToken === "") {
|
|
142
|
+
return config.token;
|
|
143
|
+
}
|
|
144
|
+
refreshing ??= refresh({ ...config, refreshToken: config.refreshToken });
|
|
145
|
+
try {
|
|
146
|
+
const next = await refreshing;
|
|
147
|
+
return next.token;
|
|
148
|
+
} catch (error) {
|
|
149
|
+
if (error instanceof OAuthError && error.code === "invalid_grant") {
|
|
150
|
+
throw new Error("Your login has expired or was disconnected. Run `vg login` again.", {
|
|
151
|
+
cause: error
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
throw error;
|
|
155
|
+
} finally {
|
|
156
|
+
refreshing = null;
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
var revokeLogin = async (config) => {
|
|
160
|
+
if (config.refreshToken === void 0 || config.refreshToken === "") {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
await postForm(authUrl(config.baseUrl, "/oauth2/revoke"), {
|
|
164
|
+
client_id: CLI_OAUTH_CLIENT_ID,
|
|
165
|
+
token: config.refreshToken,
|
|
166
|
+
token_type_hint: "refresh_token"
|
|
167
|
+
}).catch(() => null);
|
|
168
|
+
};
|
|
169
|
+
|
|
170
|
+
export {
|
|
171
|
+
CLI_VERSION_HEADER,
|
|
172
|
+
OAuthError,
|
|
173
|
+
requestDeviceCode,
|
|
174
|
+
pollDeviceToken,
|
|
175
|
+
getAccessToken,
|
|
176
|
+
revokeLogin
|
|
177
|
+
};
|