poe-code 11.0.32 → 12.0.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/dist/cli/commands/auth.js +10 -44
- package/dist/cli/commands/auth.js.map +1 -1
- package/dist/cli/commands/doctor.js +4 -4
- package/dist/cli/commands/doctor.js.map +1 -1
- package/dist/cli/program.js +0 -1
- package/dist/cli/program.js.map +1 -1
- package/dist/index.js +122 -134
- package/dist/index.js.map +4 -4
- package/dist/metafile.json +1 -1
- package/dist/sdk/auth-check.d.ts +7 -0
- package/dist/sdk/auth-check.js +22 -0
- package/dist/sdk/auth-check.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ApiError } from "../cli/errors.js";
|
|
2
|
+
export async function checkPoeAuth(options) {
|
|
3
|
+
const response = await options.httpClient(createCurrentBalanceUrl(options.baseUrl), {
|
|
4
|
+
method: "GET",
|
|
5
|
+
headers: {
|
|
6
|
+
Authorization: `Bearer ${options.apiKey}`
|
|
7
|
+
}
|
|
8
|
+
});
|
|
9
|
+
if (!response.ok) {
|
|
10
|
+
throw new ApiError(`Failed to check authentication (HTTP ${response.status})`, {
|
|
11
|
+
httpStatus: response.status,
|
|
12
|
+
endpoint: "/usage/current_balance"
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
function createCurrentBalanceUrl(baseUrl) {
|
|
17
|
+
const url = new URL(baseUrl);
|
|
18
|
+
const path = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
|
|
19
|
+
url.pathname = `${path}/usage/current_balance`;
|
|
20
|
+
return url.toString();
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=auth-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth-check.js","sourceRoot":"","sources":["../../src/sdk/auth-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,OAA4B;IAC7D,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,UAAU,CAAC,uBAAuB,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QAClF,MAAM,EAAE,KAAK;QACb,OAAO,EAAE;YACP,aAAa,EAAE,UAAU,OAAO,CAAC,MAAM,EAAE;SAC1C;KACF,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,IAAI,QAAQ,CAAC,wCAAwC,QAAQ,CAAC,MAAM,GAAG,EAAE;YAC7E,UAAU,EAAE,QAAQ,CAAC,MAAM;YAC3B,QAAQ,EAAE,wBAAwB;SACnC,CAAC,CAAC;IACL,CAAC;AACH,CAAC;AAED,SAAS,uBAAuB,CAAC,OAAe;IAC9C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IAC7B,MAAM,IAAI,GAAG,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC;IACnF,GAAG,CAAC,QAAQ,GAAG,GAAG,IAAI,wBAAwB,CAAC;IAC/C,OAAO,GAAG,CAAC,QAAQ,EAAE,CAAC;AACxB,CAAC"}
|