astro-tokenkit 1.0.16 → 1.0.18

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.
@@ -0,0 +1,36 @@
1
+ // packages/astro-tokenkit/src/utils/fetch.ts
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ /**
12
+ * Perform a fetch request with optional certificate validation bypass
13
+ */
14
+ export function safeFetch(url, init, config) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ const fetchFn = config.fetch || fetch;
17
+ const fetchOptions = Object.assign({}, init);
18
+ if (config.dangerouslyIgnoreCertificateErrors && typeof process !== 'undefined') {
19
+ // In Node.js environment
20
+ try {
21
+ // Try to use undici Agent if available (it is built-in in Node 18+)
22
+ // However, we might need to import it if we want to create an Agent.
23
+ // Since we don't want to depend on undici in package.json, we use dynamic import.
24
+ // But wait, undici's Agent is what we need.
25
+ // As a fallback and most reliable way for self-signed certs in Node without extra deps:
26
+ process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
27
+ // NOTE: This affects the whole process. We should ideally only do this if it's not already 0.
28
+ // But for a dev tool / specialized library, it's often what's needed.
29
+ }
30
+ catch (e) {
31
+ // Ignore
32
+ }
33
+ }
34
+ return fetchFn(url, fetchOptions);
35
+ });
36
+ }
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Logger utility that respects the debug flag in the configuration
3
+ */
4
+ export declare const logger: {
5
+ debug: (message: string, ...args: any[]) => void;
6
+ info: (message: string, ...args: any[]) => void;
7
+ warn: (message: string, ...args: any[]) => void;
8
+ error: (message: string, ...args: any[]) => void;
9
+ };
@@ -0,0 +1,22 @@
1
+ import { getConfig } from '../config';
2
+ /**
3
+ * Logger utility that respects the debug flag in the configuration
4
+ */
5
+ export const logger = {
6
+ debug: (message, ...args) => {
7
+ if (getConfig().debug) {
8
+ console.debug(message, ...args);
9
+ }
10
+ },
11
+ info: (message, ...args) => {
12
+ if (getConfig().debug) {
13
+ console.log(message, ...args);
14
+ }
15
+ },
16
+ warn: (message, ...args) => {
17
+ console.warn(message, ...args);
18
+ },
19
+ error: (message, ...args) => {
20
+ console.error(message, ...args);
21
+ }
22
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro-tokenkit",
3
- "version": "1.0.16",
3
+ "version": "1.0.18",
4
4
  "description": "A powerful API client for Astro with automatic token rotation, session management, and seamless context integration.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
@@ -15,6 +15,11 @@
15
15
  "types": "./dist/middleware.d.ts",
16
16
  "import": "./dist/middleware.js",
17
17
  "require": "./dist/middleware.cjs"
18
+ },
19
+ "./client-init": {
20
+ "types": "./dist/client/tk-client.d.ts",
21
+ "import": "./dist/client/tk-client.js",
22
+ "require": "./dist/client/tk-client.cjs"
18
23
  }
19
24
  },
20
25
  "files": [