gityo 1.0.1 → 1.0.3
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 +28004 -19701
- package/dist/{token-xKhO8e74.js → token-Ch3pWfUV.js} +16 -8
- package/dist/{token-util-eghGY8Pt.js → token-util-Cx8VuowB.js} +92 -14
- package/dist/token-util-DzZvXcg5.js +3 -0
- package/package.json +6 -6
- package/dist/token-error-sREvYv2J.js +0 -38
- package/dist/token-util-v019NqSI.js +0 -4
- /package/dist/{v2-Do1AZu_P.js → v2-Cn49o08d.js} +0 -0
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { t as __commonJSMin } from "./chunk-CjLZ-eKX.js";
|
|
2
|
-
import {
|
|
3
|
-
import { t as require_token_util } from "./token-util-eghGY8Pt.js";
|
|
2
|
+
import { r as require_token_error, t as require_token_util } from "./token-util-Cx8VuowB.js";
|
|
4
3
|
var require_token = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
5
4
|
var __defProp = Object.defineProperty;
|
|
6
5
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -27,13 +26,22 @@ var require_token = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
27
26
|
module.exports = __toCommonJS(token_exports);
|
|
28
27
|
var import_token_error = require_token_error();
|
|
29
28
|
var import_token_util = require_token_util();
|
|
30
|
-
async function refreshToken() {
|
|
31
|
-
|
|
29
|
+
async function refreshToken(options) {
|
|
30
|
+
let projectId = options?.project;
|
|
31
|
+
let teamId = options?.team;
|
|
32
|
+
if (!projectId && !teamId) {
|
|
33
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
34
|
+
projectId = projectInfo.projectId;
|
|
35
|
+
teamId = projectInfo.teamId;
|
|
36
|
+
} else if (!projectId || !teamId) {
|
|
37
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
38
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
39
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
40
|
+
}
|
|
41
|
+
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
32
42
|
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
33
|
-
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {
|
|
34
|
-
const authToken = await (0, import_token_util.
|
|
35
|
-
if (!authToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: Log in to Vercel CLI and link your project with `vc link`");
|
|
36
|
-
if (!projectId) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: Try re-linking your project with `vc link`");
|
|
43
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
44
|
+
const authToken = await (0, import_token_util.getVercelToken)({ expirationBufferMs: options?.expirationBufferMs });
|
|
37
45
|
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
38
46
|
if (!maybeToken) throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
39
47
|
(0, import_token_util.saveToken)(maybeToken, projectId);
|
|
@@ -1,5 +1,80 @@
|
|
|
1
1
|
import { i as __require, t as __commonJSMin } from "./chunk-CjLZ-eKX.js";
|
|
2
|
-
|
|
2
|
+
var require_token_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3
|
+
var __defProp$5 = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc$5 = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames$5 = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export$5 = (target, all) => {
|
|
8
|
+
for (var name in all) __defProp$5(target, name, {
|
|
9
|
+
get: all[name],
|
|
10
|
+
enumerable: true
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
var __copyProps$5 = (to, from, except, desc) => {
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames$5(from)) if (!__hasOwnProp$5.call(to, key) && key !== except) __defProp$5(to, key, {
|
|
16
|
+
get: () => from[key],
|
|
17
|
+
enumerable: !(desc = __getOwnPropDesc$5(from, key)) || desc.enumerable
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return to;
|
|
21
|
+
};
|
|
22
|
+
var __toCommonJS$5 = (mod) => __copyProps$5(__defProp$5({}, "__esModule", { value: true }), mod);
|
|
23
|
+
var token_error_exports = {};
|
|
24
|
+
__export$5(token_error_exports, { VercelOidcTokenError: () => VercelOidcTokenError });
|
|
25
|
+
module.exports = __toCommonJS$5(token_error_exports);
|
|
26
|
+
var VercelOidcTokenError = class extends Error {
|
|
27
|
+
constructor(message, cause) {
|
|
28
|
+
super(message);
|
|
29
|
+
this.name = "VercelOidcTokenError";
|
|
30
|
+
this.cause = cause;
|
|
31
|
+
}
|
|
32
|
+
toString() {
|
|
33
|
+
if (this.cause) return `${this.name}: ${this.message}: ${this.cause}`;
|
|
34
|
+
return `${this.name}: ${this.message}`;
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}));
|
|
38
|
+
var require_auth_errors = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
39
|
+
var __defProp$4 = Object.defineProperty;
|
|
40
|
+
var __getOwnPropDesc$4 = Object.getOwnPropertyDescriptor;
|
|
41
|
+
var __getOwnPropNames$4 = Object.getOwnPropertyNames;
|
|
42
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
43
|
+
var __export$4 = (target, all) => {
|
|
44
|
+
for (var name in all) __defProp$4(target, name, {
|
|
45
|
+
get: all[name],
|
|
46
|
+
enumerable: true
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __copyProps$4 = (to, from, except, desc) => {
|
|
50
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
51
|
+
for (let key of __getOwnPropNames$4(from)) if (!__hasOwnProp$4.call(to, key) && key !== except) __defProp$4(to, key, {
|
|
52
|
+
get: () => from[key],
|
|
53
|
+
enumerable: !(desc = __getOwnPropDesc$4(from, key)) || desc.enumerable
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return to;
|
|
57
|
+
};
|
|
58
|
+
var __toCommonJS$4 = (mod) => __copyProps$4(__defProp$4({}, "__esModule", { value: true }), mod);
|
|
59
|
+
var auth_errors_exports = {};
|
|
60
|
+
__export$4(auth_errors_exports, {
|
|
61
|
+
AccessTokenMissingError: () => AccessTokenMissingError,
|
|
62
|
+
RefreshAccessTokenFailedError: () => RefreshAccessTokenFailedError
|
|
63
|
+
});
|
|
64
|
+
module.exports = __toCommonJS$4(auth_errors_exports);
|
|
65
|
+
var AccessTokenMissingError = class extends Error {
|
|
66
|
+
constructor() {
|
|
67
|
+
super("No authentication found. Please log in with the Vercel CLI (vercel login).");
|
|
68
|
+
this.name = "AccessTokenMissingError";
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var RefreshAccessTokenFailedError = class extends Error {
|
|
72
|
+
constructor(cause) {
|
|
73
|
+
super("Failed to refresh authentication token.", { cause });
|
|
74
|
+
this.name = "RefreshAccessTokenFailedError";
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}));
|
|
3
78
|
var require_token_io = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
4
79
|
var __create$2 = Object.create;
|
|
5
80
|
var __defProp$3 = Object.defineProperty;
|
|
@@ -124,11 +199,12 @@ var require_auth_config = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
124
199
|
});
|
|
125
200
|
fs$1.writeFileSync(authPath, JSON.stringify(config, null, 2), { mode: 384 });
|
|
126
201
|
}
|
|
127
|
-
function isValidAccessToken(authConfig) {
|
|
202
|
+
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
128
203
|
if (!authConfig.token) return false;
|
|
129
204
|
if (typeof authConfig.expiresAt !== "number") return true;
|
|
130
205
|
const nowInSeconds = Math.floor(Date.now() / 1e3);
|
|
131
|
-
|
|
206
|
+
const bufferInSeconds = expirationBufferMs / 1e3;
|
|
207
|
+
return authConfig.expiresAt >= nowInSeconds + bufferInSeconds;
|
|
132
208
|
}
|
|
133
209
|
}));
|
|
134
210
|
var require_oauth = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
@@ -234,9 +310,9 @@ var require_token_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
234
310
|
assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
|
|
235
311
|
findProjectInfo: () => findProjectInfo,
|
|
236
312
|
getTokenPayload: () => getTokenPayload,
|
|
237
|
-
getVercelCliToken: () => getVercelCliToken,
|
|
238
313
|
getVercelDataDir: () => getVercelDataDir,
|
|
239
314
|
getVercelOidcToken: () => getVercelOidcToken,
|
|
315
|
+
getVercelToken: () => getVercelToken,
|
|
240
316
|
isExpired: () => isExpired,
|
|
241
317
|
loadToken: () => loadToken,
|
|
242
318
|
saveToken: () => saveToken
|
|
@@ -248,26 +324,27 @@ var require_token_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
248
324
|
var import_token_io = require_token_io();
|
|
249
325
|
var import_auth_config = require_auth_config();
|
|
250
326
|
var import_oauth = require_oauth();
|
|
327
|
+
var import_auth_errors = require_auth_errors();
|
|
251
328
|
function getVercelDataDir() {
|
|
252
329
|
const vercelFolder = "com.vercel.cli";
|
|
253
330
|
const dataDir = (0, import_token_io.getUserDataDir)();
|
|
254
331
|
if (!dataDir) return null;
|
|
255
332
|
return path.join(dataDir, vercelFolder);
|
|
256
333
|
}
|
|
257
|
-
async function
|
|
334
|
+
async function getVercelToken(options) {
|
|
258
335
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
259
|
-
if (!authConfig)
|
|
260
|
-
if ((0, import_auth_config.isValidAccessToken)(authConfig)) return authConfig.token
|
|
336
|
+
if (!authConfig?.token) throw new import_auth_errors.AccessTokenMissingError();
|
|
337
|
+
if ((0, import_auth_config.isValidAccessToken)(authConfig, options?.expirationBufferMs)) return authConfig.token;
|
|
261
338
|
if (!authConfig.refreshToken) {
|
|
262
339
|
(0, import_auth_config.writeAuthConfig)({});
|
|
263
|
-
|
|
340
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError("No refresh token available");
|
|
264
341
|
}
|
|
265
342
|
try {
|
|
266
343
|
const tokenResponse = await (0, import_oauth.refreshTokenRequest)({ refresh_token: authConfig.refreshToken });
|
|
267
344
|
const [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
|
|
268
345
|
if (tokensError || !tokens) {
|
|
269
346
|
(0, import_auth_config.writeAuthConfig)({});
|
|
270
|
-
|
|
347
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError(tokensError);
|
|
271
348
|
}
|
|
272
349
|
const updatedConfig = {
|
|
273
350
|
token: tokens.access_token,
|
|
@@ -275,10 +352,11 @@ var require_token_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
275
352
|
};
|
|
276
353
|
if (tokens.refresh_token) updatedConfig.refreshToken = tokens.refresh_token;
|
|
277
354
|
(0, import_auth_config.writeAuthConfig)(updatedConfig);
|
|
278
|
-
return updatedConfig.token
|
|
355
|
+
return updatedConfig.token;
|
|
279
356
|
} catch (error) {
|
|
280
357
|
(0, import_auth_config.writeAuthConfig)({});
|
|
281
|
-
|
|
358
|
+
if (error instanceof import_auth_errors.AccessTokenMissingError || error instanceof import_auth_errors.RefreshAccessTokenFailedError) throw error;
|
|
359
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError(error);
|
|
282
360
|
}
|
|
283
361
|
}
|
|
284
362
|
async function getVercelOidcToken(authToken, projectId, teamId) {
|
|
@@ -336,8 +414,8 @@ var require_token_util = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
|
336
414
|
const padded = base64.padEnd(base64.length + (4 - base64.length % 4) % 4, "=");
|
|
337
415
|
return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
338
416
|
}
|
|
339
|
-
function isExpired(token) {
|
|
340
|
-
return token.exp * 1e3 < Date.now();
|
|
417
|
+
function isExpired(token, bufferMs = 0) {
|
|
418
|
+
return token.exp * 1e3 < Date.now() + bufferMs;
|
|
341
419
|
}
|
|
342
420
|
}));
|
|
343
|
-
export { require_token_util as t };
|
|
421
|
+
export { require_auth_errors as n, require_token_error as r, require_token_util as t };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gityo",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"devDependencies": {
|
|
19
19
|
"@ai-sdk/amazon-bedrock": "^5.0.40",
|
|
20
|
-
"@ai-sdk/anthropic": "^
|
|
20
|
+
"@ai-sdk/anthropic": "^4.0.27",
|
|
21
21
|
"@ai-sdk/azure": "^4.0.28",
|
|
22
22
|
"@ai-sdk/cerebras": "^3.0.20",
|
|
23
23
|
"@ai-sdk/cohere": "^4.0.18",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"@ai-sdk/deepseek": "^3.0.19",
|
|
26
26
|
"@ai-sdk/fal": "^3.0.19",
|
|
27
27
|
"@ai-sdk/fireworks": "^3.0.21",
|
|
28
|
-
"@ai-sdk/google": "^
|
|
28
|
+
"@ai-sdk/google": "^4.0.31",
|
|
29
29
|
"@ai-sdk/google-vertex": "^5.0.38",
|
|
30
30
|
"@ai-sdk/groq": "^4.0.19",
|
|
31
31
|
"@ai-sdk/luma": "^3.0.19",
|
|
32
32
|
"@ai-sdk/mistral": "^4.0.20",
|
|
33
|
-
"@ai-sdk/openai": "^
|
|
34
|
-
"@ai-sdk/openai-compatible": "^
|
|
33
|
+
"@ai-sdk/openai": "^4.0.27",
|
|
34
|
+
"@ai-sdk/openai-compatible": "^3.0.20",
|
|
35
35
|
"@ai-sdk/perplexity": "^4.0.20",
|
|
36
36
|
"@ai-sdk/togetherai": "^3.0.21",
|
|
37
37
|
"@ai-sdk/xai": "^4.0.25",
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
"@types/node": "^24.9.1",
|
|
49
49
|
"@typescript-eslint/eslint-plugin": "^8.46.1",
|
|
50
50
|
"@typescript-eslint/parser": "^8.46.1",
|
|
51
|
-
"ai": "^
|
|
51
|
+
"ai": "^7.0.47",
|
|
52
52
|
"ai-gateway-provider": "^4.0.0",
|
|
53
53
|
"ai-sdk-ollama": "^4.1.0",
|
|
54
54
|
"ai-sdk-provider-opencode-sdk": "^3.0.6",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { t as __commonJSMin } from "./chunk-CjLZ-eKX.js";
|
|
2
|
-
var require_token_error = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all) __defProp(target, name, {
|
|
9
|
-
get: all[name],
|
|
10
|
-
enumerable: true
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
16
|
-
get: () => from[key],
|
|
17
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return to;
|
|
21
|
-
};
|
|
22
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
|
-
var token_error_exports = {};
|
|
24
|
-
__export(token_error_exports, { VercelOidcTokenError: () => VercelOidcTokenError });
|
|
25
|
-
module.exports = __toCommonJS(token_error_exports);
|
|
26
|
-
var VercelOidcTokenError = class extends Error {
|
|
27
|
-
constructor(message, cause) {
|
|
28
|
-
super(message);
|
|
29
|
-
this.name = "VercelOidcTokenError";
|
|
30
|
-
this.cause = cause;
|
|
31
|
-
}
|
|
32
|
-
toString() {
|
|
33
|
-
if (this.cause) return `${this.name}: ${this.message}: ${this.cause}`;
|
|
34
|
-
return `${this.name}: ${this.message}`;
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
}));
|
|
38
|
-
export { require_token_error as t };
|
|
File without changes
|