@kevisual/cnb 0.0.17 → 0.0.19
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/opencode.js +13 -2
- package/dist/routes.d.ts +1 -0
- package/dist/routes.js +13 -2
- package/package.json +4 -3
- package/src/cnb-core.ts +13 -3
package/dist/opencode.js
CHANGED
|
@@ -22517,6 +22517,7 @@ class CNBCore {
|
|
|
22517
22517
|
hackURL = API_HACK_URL;
|
|
22518
22518
|
token;
|
|
22519
22519
|
cookie;
|
|
22520
|
+
isCors;
|
|
22520
22521
|
constructor(options) {
|
|
22521
22522
|
this.token = options.token;
|
|
22522
22523
|
this.cookie = options.cookie;
|
|
@@ -22532,6 +22533,7 @@ class CNBCore {
|
|
|
22532
22533
|
this.baseURL = options.cors.baseUrl + "/" + API_BASER_URL.replace("https://", "");
|
|
22533
22534
|
this.hackURL = options.cors.baseUrl + "/" + API_HACK_URL.replace("https://", "");
|
|
22534
22535
|
}
|
|
22536
|
+
this.isCors = !!options?.cors?.baseUrl;
|
|
22535
22537
|
}
|
|
22536
22538
|
async request({ url: url2, method = "GET", data, params, headers, body, useCookie, useOrigin }) {
|
|
22537
22539
|
const defaultHeaders = {
|
|
@@ -22558,9 +22560,14 @@ class CNBCore {
|
|
|
22558
22560
|
delete _headers.Authorization;
|
|
22559
22561
|
}
|
|
22560
22562
|
if (useCookie) {
|
|
22561
|
-
|
|
22563
|
+
if (this.isCors) {
|
|
22564
|
+
_headers["app-cookie"] = this.cookie || "";
|
|
22565
|
+
} else {
|
|
22566
|
+
_headers["Cookie"] = this.cookie || "";
|
|
22567
|
+
}
|
|
22562
22568
|
delete _headers.Authorization;
|
|
22563
22569
|
}
|
|
22570
|
+
console.log("Request URL:", url2, data, _headers);
|
|
22564
22571
|
const response = await fetch(url2 || "", {
|
|
22565
22572
|
method,
|
|
22566
22573
|
headers: _headers,
|
|
@@ -22595,7 +22602,11 @@ class CNBCore {
|
|
|
22595
22602
|
if (url2 && url2.startsWith("http")) {
|
|
22596
22603
|
return url2;
|
|
22597
22604
|
}
|
|
22598
|
-
|
|
22605
|
+
console.log("url", url2, this.baseURL);
|
|
22606
|
+
if (url2.startsWith("/")) {
|
|
22607
|
+
return this.baseURL + url2;
|
|
22608
|
+
}
|
|
22609
|
+
return this.baseURL + "/" + url2;
|
|
22599
22610
|
}
|
|
22600
22611
|
get({ url: url2, ...REST }) {
|
|
22601
22612
|
const fullUrl = this.makeUrl(url2);
|
package/dist/routes.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ declare class CNBCore {
|
|
|
28
28
|
hackURL: string;
|
|
29
29
|
token: string;
|
|
30
30
|
cookie?: string;
|
|
31
|
+
isCors: boolean;
|
|
31
32
|
constructor(options: CNBCoreOptions);
|
|
32
33
|
request({ url, method, data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any>;
|
|
33
34
|
makeUrl(url?: string): string;
|
package/dist/routes.js
CHANGED
|
@@ -22517,6 +22517,7 @@ class CNBCore {
|
|
|
22517
22517
|
hackURL = API_HACK_URL;
|
|
22518
22518
|
token;
|
|
22519
22519
|
cookie;
|
|
22520
|
+
isCors;
|
|
22520
22521
|
constructor(options) {
|
|
22521
22522
|
this.token = options.token;
|
|
22522
22523
|
this.cookie = options.cookie;
|
|
@@ -22532,6 +22533,7 @@ class CNBCore {
|
|
|
22532
22533
|
this.baseURL = options.cors.baseUrl + "/" + API_BASER_URL.replace("https://", "");
|
|
22533
22534
|
this.hackURL = options.cors.baseUrl + "/" + API_HACK_URL.replace("https://", "");
|
|
22534
22535
|
}
|
|
22536
|
+
this.isCors = !!options?.cors?.baseUrl;
|
|
22535
22537
|
}
|
|
22536
22538
|
async request({ url: url2, method = "GET", data, params, headers, body, useCookie, useOrigin }) {
|
|
22537
22539
|
const defaultHeaders = {
|
|
@@ -22558,9 +22560,14 @@ class CNBCore {
|
|
|
22558
22560
|
delete _headers.Authorization;
|
|
22559
22561
|
}
|
|
22560
22562
|
if (useCookie) {
|
|
22561
|
-
|
|
22563
|
+
if (this.isCors) {
|
|
22564
|
+
_headers["app-cookie"] = this.cookie || "";
|
|
22565
|
+
} else {
|
|
22566
|
+
_headers["Cookie"] = this.cookie || "";
|
|
22567
|
+
}
|
|
22562
22568
|
delete _headers.Authorization;
|
|
22563
22569
|
}
|
|
22570
|
+
console.log("Request URL:", url2, data, _headers);
|
|
22564
22571
|
const response = await fetch(url2 || "", {
|
|
22565
22572
|
method,
|
|
22566
22573
|
headers: _headers,
|
|
@@ -22595,7 +22602,11 @@ class CNBCore {
|
|
|
22595
22602
|
if (url2 && url2.startsWith("http")) {
|
|
22596
22603
|
return url2;
|
|
22597
22604
|
}
|
|
22598
|
-
|
|
22605
|
+
console.log("url", url2, this.baseURL);
|
|
22606
|
+
if (url2.startsWith("/")) {
|
|
22607
|
+
return this.baseURL + url2;
|
|
22608
|
+
}
|
|
22609
|
+
return this.baseURL + "/" + url2;
|
|
22599
22610
|
}
|
|
22600
22611
|
get({ url: url2, ...REST }) {
|
|
22601
22612
|
const fullUrl = this.makeUrl(url2);
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kevisual/cnb",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.19",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "bun
|
|
7
|
+
"build": "bun bun.config.ts",
|
|
8
|
+
"flow":"ev npm patch && pnpm build && ev npm publish npm -p"
|
|
8
9
|
},
|
|
9
10
|
"keywords": [],
|
|
10
11
|
"files": [
|
|
@@ -24,7 +25,7 @@
|
|
|
24
25
|
"@kevisual/types": "^0.0.12",
|
|
25
26
|
"@opencode-ai/plugin": "^1.1.51",
|
|
26
27
|
"@types/bun": "^1.3.8",
|
|
27
|
-
"@types/node": "^25.2.
|
|
28
|
+
"@types/node": "^25.2.1",
|
|
28
29
|
"@types/ws": "^8.18.1",
|
|
29
30
|
"dayjs": "^1.11.19",
|
|
30
31
|
"dotenv": "^17.2.3"
|
package/src/cnb-core.ts
CHANGED
|
@@ -27,6 +27,7 @@ export class CNBCore {
|
|
|
27
27
|
hackURL = API_HACK_URL;
|
|
28
28
|
public token: string;
|
|
29
29
|
public cookie?: string;
|
|
30
|
+
isCors: boolean;
|
|
30
31
|
constructor(options: CNBCoreOptions) {
|
|
31
32
|
this.token = options.token;
|
|
32
33
|
this.cookie = options.cookie;
|
|
@@ -42,6 +43,7 @@ export class CNBCore {
|
|
|
42
43
|
this.baseURL = options.cors.baseUrl + '/' + API_BASER_URL.replace('https://', '');
|
|
43
44
|
this.hackURL = options.cors.baseUrl + '/' + API_HACK_URL.replace('https://', '');
|
|
44
45
|
}
|
|
46
|
+
this.isCors = !!options?.cors?.baseUrl;
|
|
45
47
|
}
|
|
46
48
|
|
|
47
49
|
async request({ url, method = 'GET', data, params, headers, body, useCookie, useOrigin }: RequestOptions): Promise<any> {
|
|
@@ -70,10 +72,14 @@ export class CNBCore {
|
|
|
70
72
|
delete _headers.Authorization;
|
|
71
73
|
}
|
|
72
74
|
if (useCookie) {
|
|
73
|
-
|
|
75
|
+
if (this.isCors) {
|
|
76
|
+
_headers['app-cookie'] = this.cookie || "";
|
|
77
|
+
} else {
|
|
78
|
+
_headers['Cookie'] = this.cookie || "";
|
|
79
|
+
}
|
|
74
80
|
delete _headers.Authorization;
|
|
75
81
|
}
|
|
76
|
-
|
|
82
|
+
console.log('Request URL:', url, data, _headers);
|
|
77
83
|
const response = await fetch(url || '', {
|
|
78
84
|
method,
|
|
79
85
|
headers: _headers,
|
|
@@ -109,7 +115,11 @@ export class CNBCore {
|
|
|
109
115
|
if (url && url.startsWith('http')) {
|
|
110
116
|
return url;
|
|
111
117
|
}
|
|
112
|
-
|
|
118
|
+
console.log('url', url, this.baseURL)
|
|
119
|
+
if (url.startsWith('/')) {
|
|
120
|
+
return this.baseURL + url;
|
|
121
|
+
}
|
|
122
|
+
return this.baseURL + '/' + url;
|
|
113
123
|
}
|
|
114
124
|
get<T = any>({ url, ...REST }: RequestOptions): Promise<T> {
|
|
115
125
|
const fullUrl = this.makeUrl(url);
|