@kevisual/kv-login 0.1.17 → 0.1.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.
package/dist/app.js CHANGED
@@ -3150,7 +3150,7 @@ UnsafeHTMLDirective.directiveName = "unsafeHTML";
3150
3150
  UnsafeHTMLDirective.resultType = HTML_RESULT2;
3151
3151
  var unsafeHTML = directive(UnsafeHTMLDirective);
3152
3152
 
3153
- // node_modules/.pnpm/@kevisual+query@0.0.52/node_modules/@kevisual/query/dist/query-browser.js
3153
+ // node_modules/.pnpm/@kevisual+query@0.0.53/node_modules/@kevisual/query/dist/query-browser.js
3154
3154
  var isTextForContentType = (contentType) => {
3155
3155
  if (!contentType)
3156
3156
  return false;
@@ -3353,6 +3353,10 @@ class Query {
3353
3353
  });
3354
3354
  }
3355
3355
  }
3356
+ const headers2 = req.headers || {};
3357
+ if (options?.token && !headers2["Authorization"]) {
3358
+ headers2["Authorization"] = `Bearer ${options.token}`;
3359
+ }
3356
3360
  } catch (e) {
3357
3361
  console.error("request beforeFn error", e, req);
3358
3362
  return wrapperError({
@@ -3413,20 +3417,20 @@ class Query {
3413
3417
  this.afterResponse = fn;
3414
3418
  }
3415
3419
  async fetchText(urlOrOptions, options) {
3416
- let _options = { ...options };
3420
+ let _options = { method: "GET", ...options };
3417
3421
  if (typeof urlOrOptions === "string" && !_options.url) {
3418
3422
  _options.url = urlOrOptions;
3419
3423
  }
3420
3424
  if (typeof urlOrOptions === "object") {
3421
3425
  _options = { ...urlOrOptions, ..._options };
3422
3426
  }
3427
+ const headers = { ...this.headers, ..._options.headers };
3428
+ if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
3429
+ headers["Authorization"] = `Bearer ${options.token}`;
3430
+ }
3423
3431
  const res = await adapter({
3424
- method: "GET",
3425
3432
  ..._options,
3426
- headers: {
3427
- ...this.headers,
3428
- ..._options?.headers || {}
3429
- }
3433
+ headers
3430
3434
  });
3431
3435
  if (res && !res.code) {
3432
3436
  return {
@@ -3463,7 +3467,7 @@ class BaseQuery {
3463
3467
  }
3464
3468
  }
3465
3469
 
3466
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/dist/query-login.js
3470
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/dist/query-login.js
3467
3471
  var __create2 = Object.create;
3468
3472
  var __getProtoOf2 = Object.getPrototypeOf;
3469
3473
  var __defProp2 = Object.defineProperty;
@@ -3859,6 +3863,10 @@ class Query2 {
3859
3863
  });
3860
3864
  }
3861
3865
  }
3866
+ const headers2 = req.headers || {};
3867
+ if (options?.token && !headers2["Authorization"]) {
3868
+ headers2["Authorization"] = `Bearer ${options.token}`;
3869
+ }
3862
3870
  } catch (e) {
3863
3871
  console.error("request beforeFn error", e, req);
3864
3872
  return wrapperError2({
@@ -3919,20 +3927,20 @@ class Query2 {
3919
3927
  this.afterResponse = fn;
3920
3928
  }
3921
3929
  async fetchText(urlOrOptions, options) {
3922
- let _options = { ...options };
3930
+ let _options = { method: "GET", ...options };
3923
3931
  if (typeof urlOrOptions === "string" && !_options.url) {
3924
3932
  _options.url = urlOrOptions;
3925
3933
  }
3926
3934
  if (typeof urlOrOptions === "object") {
3927
3935
  _options = { ...urlOrOptions, ..._options };
3928
3936
  }
3937
+ const headers = { ...this.headers, ..._options.headers };
3938
+ if (options?.token && !headers["Authorization"] && _options.method !== "GET") {
3939
+ headers["Authorization"] = `Bearer ${options.token}`;
3940
+ }
3929
3941
  const res = await adapter2({
3930
- method: "GET",
3931
3942
  ..._options,
3932
- headers: {
3933
- ...this.headers,
3934
- ..._options?.headers || {}
3935
- }
3943
+ headers
3936
3944
  });
3937
3945
  if (res && !res.code) {
3938
3946
  return {
@@ -5549,7 +5557,7 @@ class EventEmitter2 {
5549
5557
  var eventEmitter = new EventEmitter2;
5550
5558
  var emit = (event) => eventEmitter.emit(event);
5551
5559
 
5552
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-cache.ts
5560
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/login-cache.ts
5553
5561
  var defaultCacheData2 = {
5554
5562
  loginUsers: [],
5555
5563
  user: undefined,
@@ -6120,7 +6128,7 @@ class BaseLoad2 {
6120
6128
  // node_modules/.pnpm/eventemitter3@5.0.4/node_modules/eventemitter3/index.mjs
6121
6129
  var import__2 = __toESM(require_eventemitter32(), 1);
6122
6130
 
6123
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login.ts
6131
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login.ts
6124
6132
  class QueryLogin2 extends BaseQuery {
6125
6133
  cacheStore;
6126
6134
  isBrowser;
@@ -6646,7 +6654,7 @@ function entries2(customStore = defaultGetStore2()) {
6646
6654
  });
6647
6655
  }
6648
6656
 
6649
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/browser-cache/cache-store.ts
6657
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/browser-cache/cache-store.ts
6650
6658
  class BaseCacheStore2 {
6651
6659
  store;
6652
6660
  constructor(opts) {
@@ -6735,7 +6743,7 @@ class CacheStore3 extends BaseCacheStore2 {
6735
6743
  return this.del(key);
6736
6744
  }
6737
6745
  }
6738
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/browser-cache/cache.ts
6746
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/browser-cache/cache.ts
6739
6747
  class MyCache2 extends CacheStore3 {
6740
6748
  key;
6741
6749
  constructor(opts) {
@@ -6754,7 +6762,7 @@ class MyCache2 extends CacheStore3 {
6754
6762
  }
6755
6763
  }
6756
6764
 
6757
- // node_modules/.pnpm/@kevisual+api@0.0.62_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login-browser.ts
6765
+ // node_modules/.pnpm/@kevisual+api@0.0.64_react-dom@19.2.4_react@19.2.4__react@19.2.4/node_modules/@kevisual/api/query/query-login/query-login-browser.ts
6758
6766
  class QueryLoginBrowser2 extends QueryLogin2 {
6759
6767
  constructor(opts) {
6760
6768
  super({
@@ -7738,7 +7746,10 @@ var getLoginMethodByDomain = () => {
7738
7746
  methods = ["password", "web", "phone", "wechat", "wechat-mp", "wechat-mp-ticket"];
7739
7747
  break;
7740
7748
  }
7741
- return DefaultLoginMethods.filter((method) => methods.includes(method.id));
7749
+ return methods.map((m) => {
7750
+ const finded = findLoginMethod(m);
7751
+ return finded;
7752
+ }).filter(Boolean);
7742
7753
  };
7743
7754
  var findLoginMethod = (methodId) => {
7744
7755
  return DefaultLoginMethods.find((method) => method.id === methodId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kevisual/kv-login",
3
- "version": "0.1.17",
3
+ "version": "0.1.18",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "dev": "vite",
@@ -29,12 +29,12 @@
29
29
  "devDependencies": {
30
30
  "@kevisual/cache": "^0.0.5",
31
31
  "@kevisual/context": "^0.0.8",
32
- "@kevisual/query": "^0.0.52",
32
+ "@kevisual/query": "^0.0.53",
33
33
  "crypto-js": "^4.2.0",
34
34
  "lit-html": "^3.3.2",
35
35
  "qrcode": "^1.5.4",
36
- "@kevisual/api": "^0.0.62",
36
+ "@kevisual/api": "^0.0.64",
37
37
  "@types/bun": "^1.3.10",
38
- "vite": "^7.3.1"
38
+ "vite": "^8.0.0"
39
39
  }
40
40
  }
@@ -69,7 +69,10 @@ const getLoginMethodByDomain = (): LoginMethod[] => {
69
69
  methods = ['password', 'web', 'phone', 'wechat', 'wechat-mp', 'wechat-mp-ticket']
70
70
  break;
71
71
  }
72
- return DefaultLoginMethods.filter(method => methods.includes(method.id))
72
+ return methods.map(m => {
73
+ const finded = findLoginMethod(m);
74
+ return finded;
75
+ }).filter(Boolean) as LoginMethod[];
73
76
  }
74
77
  const getLoginMethod = (methods: LoginMethods[]): LoginMethod[] => {
75
78
  return DefaultLoginMethods.filter(method => methods.includes(method.id))