@kcuf/fetcher-interceptor-login 0.2.6 → 0.2.9

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.
@@ -17,15 +17,15 @@ function createInterceptorResponseRejected(_ref) {
17
17
  return /*#__PURE__*/function () {
18
18
  var _ref2 = (0, _asyncToGenerator2.default)(/*#__PURE__*/(0, _regeneratorRuntime2.default)().mark(function _callee(error, fetcherConfig, _, requestByInterceptor) {
19
19
  var _error$code;
20
- return (0, _regeneratorRuntime2.default)().wrap(function _callee$(_context) {
20
+ return (0, _regeneratorRuntime2.default)().wrap(function (_context) {
21
21
  while (1) switch (_context.prev = _context.next) {
22
22
  case 0:
23
23
  if (needLogin((_error$code = error.code) !== null && _error$code !== void 0 ? _error$code : '', error)) {
24
- _context.next = 2;
24
+ _context.next = 1;
25
25
  break;
26
26
  }
27
27
  throw error;
28
- case 2:
28
+ case 1:
29
29
  return _context.abrupt("return", singletonLogin().then(function () {
30
30
  if (headerKeys) {
31
31
  (0, _fetcher.deleteConfigHeaders)(fetcherConfig, headerKeys);
@@ -36,7 +36,7 @@ function createInterceptorResponseRejected(_ref) {
36
36
  error.name = _fetcher.FetcherErrorName.LOGIN_CANCELLED;
37
37
  throw error; // 以新的 name 继续抛错
38
38
  }));
39
- case 3:
39
+ case 2:
40
40
  case "end":
41
41
  return _context.stop();
42
42
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../../../src/types/index.ts"],"sourcesContent":["import {\n FetcherError\n} from '@kcuf/fetcher';\n\nexport interface ICreateInterceptorOptions {\n needLogin(code: string, err: FetcherError): boolean;\n doLogin(): Promise<void>;\n headerKeys?: string[];\n}\n"],"mappings":"","ignoreList":[]}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../../src/types/index.ts"],"sourcesContent":["import {\n FetcherError\n} from '@kcuf/fetcher';\n\nexport interface ICreateInterceptorOptions {\n needLogin(code: string, err: FetcherError): boolean;\n doLogin(): Promise<unknown>;\n headerKeys?: string[];\n}\n"],"mappings":"","ignoreList":[]}
@@ -10,15 +10,15 @@ export default function createInterceptorResponseRejected(_ref) {
10
10
  return /*#__PURE__*/function () {
11
11
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(error, fetcherConfig, _, requestByInterceptor) {
12
12
  var _error$code;
13
- return _regeneratorRuntime().wrap(function _callee$(_context) {
13
+ return _regeneratorRuntime().wrap(function (_context) {
14
14
  while (1) switch (_context.prev = _context.next) {
15
15
  case 0:
16
16
  if (needLogin((_error$code = error.code) !== null && _error$code !== void 0 ? _error$code : '', error)) {
17
- _context.next = 2;
17
+ _context.next = 1;
18
18
  break;
19
19
  }
20
20
  throw error;
21
- case 2:
21
+ case 1:
22
22
  return _context.abrupt("return", singletonLogin().then(function () {
23
23
  if (headerKeys) {
24
24
  deleteConfigHeaders(fetcherConfig, headerKeys);
@@ -29,7 +29,7 @@ export default function createInterceptorResponseRejected(_ref) {
29
29
  error.name = FetcherErrorName.LOGIN_CANCELLED;
30
30
  throw error; // 以新的 name 继续抛错
31
31
  }));
32
- case 3:
32
+ case 2:
33
33
  case "end":
34
34
  return _context.stop();
35
35
  }
@@ -1 +1 @@
1
- {"version":3,"file":"create-interceptor-response-rejected.js","names":["FetcherErrorName","deleteConfigHeaders","singletonPromise","createInterceptorResponseRejected","_ref","needLogin","doLogin","headerKeys","singletonLogin","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","error","fetcherConfig","_","requestByInterceptor","_error$code","wrap","_callee$","_context","prev","next","code","abrupt","then","name","LOGIN_CANCELLED","stop","_x","_x2","_x3","_x4","apply","arguments"],"sources":["../../../src/util/create-interceptor-response-rejected.ts"],"sourcesContent":["import {\n FetcherErrorName,\n FetcherConfig,\n FetcherError,\n FetcherResponse,\n FetcherCallRequest,\n FetcherInterceptResponseRejected,\n deleteConfigHeaders\n} from '@kcuf/fetcher';\n\nimport {\n ICreateInterceptorOptions\n} from '../types';\n\nimport singletonPromise from './singleton-promise';\n\nexport default function createInterceptorResponseRejected({\n needLogin,\n doLogin,\n headerKeys\n}: ICreateInterceptorOptions): FetcherInterceptResponseRejected {\n const singletonLogin = singletonPromise(doLogin);\n \n return async (error: FetcherError, fetcherConfig: FetcherConfig, _: FetcherResponse<unknown> | undefined, requestByInterceptor: FetcherCallRequest) => {\n if (!needLogin(error.code ?? '', error)) {\n throw error;\n }\n \n return singletonLogin().then(() => {\n if (headerKeys) {\n deleteConfigHeaders(fetcherConfig, headerKeys);\n }\n \n return requestByInterceptor(fetcherConfig); // 登录完成,重新发起原请求\n }, () => {\n // 一般登录弹窗在登录成功之前是不应该被关闭或取消的,但若真允许取消,这里需要修改错误为「取消登录」\n error.name = FetcherErrorName.LOGIN_CANCELLED;\n \n throw error; // 以新的 name 继续抛错\n });\n };\n}\n"],"mappings":";;AAAA,SACEA,gBAAgB,EAMhBC,mBAAmB,QACd,eAAe;AAMtB,OAAOC,gBAAgB,MAAM,qBAAqB;AAElD,eAAe,SAASC,iCAAiCA,CAAAC,IAAA,EAIO;EAAA,IAH9DC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IACPC,UAAU,GAAAH,IAAA,CAAVG,UAAU;EAEV,IAAMC,cAAc,GAAGN,gBAAgB,CAACI,OAAO,CAAC;EAEhD;IAAA,IAAAG,KAAA,GAAAC,iBAAA,cAAAC,mBAAA,GAAAC,IAAA,CAAO,SAAAC,QAAOC,KAAmB,EAAEC,aAA4B,EAAEC,CAAuC,EAAEC,oBAAwC;MAAA,IAAAC,WAAA;MAAA,OAAAP,mBAAA,GAAAQ,IAAA,UAAAC,SAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,IAC3IlB,SAAS,EAAAa,WAAA,GAACJ,KAAK,CAACU,IAAI,cAAAN,WAAA,cAAAA,WAAA,GAAI,EAAE,EAAEJ,KAAK,CAAC;cAAAO,QAAA,CAAAE,IAAA;cAAA;YAAA;YAAA,MAC/BT,KAAK;UAAA;YAAA,OAAAO,QAAA,CAAAI,MAAA,WAGNjB,cAAc,CAAC,CAAC,CAACkB,IAAI,CAAC,YAAM;cACjC,IAAInB,UAAU,EAAE;gBACdN,mBAAmB,CAACc,aAAa,EAAER,UAAU,CAAC;cAChD;cAEA,OAAOU,oBAAoB,CAACF,aAAa,CAAC,CAAC,CAAC;YAC9C,CAAC,EAAE,YAAM;cACP;cACAD,KAAK,CAACa,IAAI,GAAG3B,gBAAgB,CAAC4B,eAAe;cAE7C,MAAMd,KAAK,CAAC,CAAC;YACf,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAO,QAAA,CAAAQ,IAAA;QAAA;MAAA,GAAAhB,OAAA;IAAA,CACH;IAAA,iBAAAiB,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA;MAAA,OAAAxB,KAAA,CAAAyB,KAAA,OAAAC,SAAA;IAAA;EAAA;AACH","ignoreList":[]}
1
+ {"version":3,"file":"create-interceptor-response-rejected.js","names":["FetcherErrorName","deleteConfigHeaders","singletonPromise","createInterceptorResponseRejected","_ref","needLogin","doLogin","headerKeys","singletonLogin","_ref2","_asyncToGenerator","_regeneratorRuntime","mark","_callee","error","fetcherConfig","_","requestByInterceptor","_error$code","wrap","_context","prev","next","code","abrupt","then","name","LOGIN_CANCELLED","stop","_x","_x2","_x3","_x4","apply","arguments"],"sources":["../../../src/util/create-interceptor-response-rejected.ts"],"sourcesContent":["import {\n FetcherErrorName,\n FetcherConfig,\n FetcherError,\n FetcherResponse,\n FetcherCallRequest,\n FetcherInterceptResponseRejected,\n deleteConfigHeaders\n} from '@kcuf/fetcher';\n\nimport {\n ICreateInterceptorOptions\n} from '../types';\n\nimport singletonPromise from './singleton-promise';\n\nexport default function createInterceptorResponseRejected({\n needLogin,\n doLogin,\n headerKeys\n}: ICreateInterceptorOptions): FetcherInterceptResponseRejected {\n const singletonLogin = singletonPromise(doLogin);\n \n return async (error: FetcherError, fetcherConfig: FetcherConfig, _: FetcherResponse | undefined, requestByInterceptor: FetcherCallRequest) => {\n if (!needLogin(error.code ?? '', error)) {\n throw error;\n }\n \n return singletonLogin().then(() => {\n if (headerKeys) {\n deleteConfigHeaders(fetcherConfig, headerKeys);\n }\n \n return requestByInterceptor(fetcherConfig); // 登录完成,重新发起原请求\n }, () => {\n // 一般登录弹窗在登录成功之前是不应该被关闭或取消的,但若真允许取消,这里需要修改错误为「取消登录」\n error.name = FetcherErrorName.LOGIN_CANCELLED;\n \n throw error; // 以新的 name 继续抛错\n });\n };\n}\n"],"mappings":";;AAAA,SACEA,gBAAgB,EAMhBC,mBAAmB,QACd,eAAe;AAMtB,OAAOC,gBAAgB,MAAM,qBAAqB;AAElD,eAAe,SAASC,iCAAiCA,CAAAC,IAAA,EAIO;EAAA,IAH9DC,SAAS,GAAAD,IAAA,CAATC,SAAS;IACTC,OAAO,GAAAF,IAAA,CAAPE,OAAO;IACPC,UAAU,GAAAH,IAAA,CAAVG,UAAU;EAEV,IAAMC,cAAc,GAAGN,gBAAgB,CAACI,OAAO,CAAC;EAEhD;IAAA,IAAAG,KAAA,GAAAC,iBAAA,cAAAC,mBAAA,GAAAC,IAAA,CAAO,SAAAC,QAAOC,KAAmB,EAAEC,aAA4B,EAAEC,CAA8B,EAAEC,oBAAwC;MAAA,IAAAC,WAAA;MAAA,OAAAP,mBAAA,GAAAQ,IAAA,WAAAC,QAAA;QAAA,kBAAAA,QAAA,CAAAC,IAAA,GAAAD,QAAA,CAAAE,IAAA;UAAA;YAAA,IAClIjB,SAAS,EAAAa,WAAA,GAACJ,KAAK,CAACS,IAAI,cAAAL,WAAA,cAAAA,WAAA,GAAI,EAAE,EAAEJ,KAAK,CAAC;cAAAM,QAAA,CAAAE,IAAA;cAAA;YAAA;YAAA,MAC/BR,KAAK;UAAA;YAAA,OAAAM,QAAA,CAAAI,MAAA,WAGNhB,cAAc,CAAC,CAAC,CAACiB,IAAI,CAAC,YAAM;cACjC,IAAIlB,UAAU,EAAE;gBACdN,mBAAmB,CAACc,aAAa,EAAER,UAAU,CAAC;cAChD;cAEA,OAAOU,oBAAoB,CAACF,aAAa,CAAC,CAAC,CAAC;YAC9C,CAAC,EAAE,YAAM;cACP;cACAD,KAAK,CAACY,IAAI,GAAG1B,gBAAgB,CAAC2B,eAAe;cAE7C,MAAMb,KAAK,CAAC,CAAC;YACf,CAAC,CAAC;UAAA;UAAA;YAAA,OAAAM,QAAA,CAAAQ,IAAA;QAAA;MAAA,GAAAf,OAAA;IAAA,CACH;IAAA,iBAAAgB,EAAA,EAAAC,GAAA,EAAAC,GAAA,EAAAC,GAAA;MAAA,OAAAvB,KAAA,CAAAwB,KAAA,OAAAC,SAAA;IAAA;EAAA;AACH","ignoreList":[]}
@@ -1,6 +1,6 @@
1
1
  import { FetcherError } from '@kcuf/fetcher';
2
2
  export interface ICreateInterceptorOptions {
3
3
  needLogin(code: string, err: FetcherError): boolean;
4
- doLogin(): Promise<void>;
4
+ doLogin(): Promise<unknown>;
5
5
  headerKeys?: string[];
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kcuf/fetcher-interceptor-login",
3
- "version": "0.2.6",
3
+ "version": "0.2.9",
4
4
  "description": "Fetcher interceptor seamless login and redo request.",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -12,7 +12,7 @@
12
12
  "type": "git",
13
13
  "url": "git+https://github.com/justnewbee/kcuf.git"
14
14
  },
15
- "homepage": "https://github.com/justnewbee/kcuf/tree/master/packages-fetcher/fetcher-interceptor-login",
15
+ "homepage": "https://github.com/justnewbee/kcuf/tree/main/packages-fetcher/fetcher-interceptor-login",
16
16
  "bugs": "https://github.com/justnewbee/kcuf/issues",
17
17
  "author": {
18
18
  "name": "Jianchun Wang",
@@ -22,24 +22,24 @@
22
22
  "access": "public"
23
23
  },
24
24
  "devDependencies": {
25
- "@babel/cli": "^7.27.0",
26
- "@babel/core": "^7.26.10",
27
- "@babel/plugin-transform-runtime": "^7.26.10",
28
- "@babel/preset-env": "^7.26.9",
29
- "@babel/preset-typescript": "^7.27.0",
30
- "@vitest/coverage-v8": "^3.1.1",
31
- "fetch-mock": "^12.5.2",
32
- "jsdom": "^26.1.0",
33
- "rimraf": "^6.0.1",
34
- "typescript": "^5.8.3",
35
- "vitest": "^3.1.1",
25
+ "@babel/cli": "^7.28.3",
26
+ "@babel/core": "^7.28.5",
27
+ "@babel/plugin-transform-runtime": "^7.28.5",
28
+ "@babel/preset-env": "^7.28.5",
29
+ "@babel/preset-typescript": "^7.28.5",
30
+ "@vitest/coverage-v8": "^4.0.13",
31
+ "fetch-mock": "^12.6.0",
32
+ "jsdom": "^27.2.0",
33
+ "rimraf": "^6.1.2",
34
+ "typescript": "^5.9.3",
35
+ "vitest": "^4.0.13",
36
36
  "@kcuf/ts-config": "^0.0.1"
37
37
  },
38
38
  "peerDependencies": {
39
39
  "@babel/runtime": "^7.x"
40
40
  },
41
41
  "dependencies": {
42
- "@kcuf/fetcher": "^0.2.8"
42
+ "@kcuf/fetcher": "^0.2.9"
43
43
  },
44
44
  "scripts": {
45
45
  "build:clean": "rimraf dist",