@ahoo-wang/fetcher-cosec 3.1.8 → 3.2.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/authorizationRequestInterceptor.d.ts.map +1 -1
- package/dist/authorizationResponseInterceptor.d.ts.map +1 -1
- package/dist/cosecConfigurer.d.ts.map +1 -1
- package/dist/cosecRequestInterceptor.d.ts.map +1 -1
- package/dist/deviceIdStorage.d.ts.map +1 -1
- package/dist/forbiddenErrorInterceptor.d.ts.map +1 -1
- package/dist/index.es.js +71 -67
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/index.umd.js.map +1 -1
- package/dist/jwtToken.d.ts.map +1 -1
- package/dist/jwtTokenManager.d.ts.map +1 -1
- package/dist/resourceAttributionRequestInterceptor.d.ts.map +1 -1
- package/dist/tokenRefresher.d.ts.map +1 -1
- package/dist/tokenStorage.d.ts.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/dist/unauthorizedErrorInterceptor.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizationRequestInterceptor.d.ts","sourceRoot":"","sources":["../src/authorizationRequestInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAKvE,OAAO,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG/D,MAAM,WAAW,+BACf,SAAQ,sBAAsB;
|
|
1
|
+
{"version":3,"file":"authorizationRequestInterceptor.d.ts","sourceRoot":"","sources":["../src/authorizationRequestInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAKvE,OAAO,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG/D,MAAM,WAAW,+BACf,SAAQ,sBAAsB;CAAG;AAEnC,eAAO,MAAM,sCAAsC,oCAChB,CAAC;AACpC,eAAO,MAAM,uCAAuC,QACZ,CAAC;AAEzC;;;;;;;;;GASG;AACH,qBAAa,+BAAgC,YAAW,kBAAkB;IAS5D,OAAO,CAAC,QAAQ,CAAC,OAAO;IARpC,QAAQ,CAAC,IAAI,qCAA0C;IACvD,QAAQ,CAAC,KAAK,SAA2C;IAEzD;;;;OAIG;gBAC0B,OAAO,EAAE,+BAA+B;IAErE;;;;;;;;;;OAUG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CA6BxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"authorizationResponseInterceptor.d.ts","sourceRoot":"","sources":["../src/authorizationResponseInterceptor.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,uCAAuC,qCAChB,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,wCAAwC,QACrB,CAAC;AAEjC;;;;;;;;;GASG;AACH,qBAAa,gCAAiC,YAAW,mBAAmB;IAQ9D,OAAO,CAAC,OAAO;IAP3B,QAAQ,CAAC,IAAI,sCAA2C;IACxD,QAAQ,CAAC,KAAK,SAA4C;IAE1D;;;OAGG;gBACiB,OAAO,EAAE,+BAA+B;
|
|
1
|
+
{"version":3,"file":"authorizationResponseInterceptor.d.ts","sourceRoot":"","sources":["../src/authorizationResponseInterceptor.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAE,+BAA+B,EAAE,MAAM,mCAAmC,CAAC;AAEpF;;GAEG;AACH,eAAO,MAAM,uCAAuC,qCAChB,CAAC;AAErC;;;GAGG;AACH,eAAO,MAAM,wCAAwC,QACrB,CAAC;AAEjC;;;;;;;;;GASG;AACH,qBAAa,gCAAiC,YAAW,mBAAmB;IAQ9D,OAAO,CAAC,OAAO;IAP3B,QAAQ,CAAC,IAAI,sCAA2C;IACxD,QAAQ,CAAC,KAAK,SAA4C;IAE1D;;;OAGG;gBACiB,OAAO,EAAE,+BAA+B;IAE5D;;;OAGG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAyBxD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosecConfigurer.d.ts","sourceRoot":"","sources":["../src/cosecConfigurer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAI/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"cosecConfigurer.d.ts","sourceRoot":"","sources":["../src/cosecConfigurer.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAI/E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,WACf,SAAQ,YAAY,EAClB,OAAO,CAAC,sBAAsB,CAAC;IACjC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IAEd;;;;OAIG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;OAIG;IACH,eAAe,CAAC,EAAE,eAAe,CAAC;IAElC;;;;OAIG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAEhC;;;OAGG;IACH,cAAc,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;IAEnE;;;OAGG;IACH,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1D;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+CG;AACH,qBAAa,eAAgB,YAAW,iBAAiB;aA0C3B,MAAM,EAAE,WAAW;IAzC/C;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAC;IAEpC;;OAEG;IACH,QAAQ,CAAC,eAAe,EAAE,eAAe,CAAC;IAE1C;;;OAGG;IACH,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC;IAExC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;gBACyB,MAAM,EAAE,WAAW;IAc/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAgCG;IACH,OAAO,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CA0ChC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cosecRequestInterceptor.d.ts","sourceRoot":"","sources":["../src/cosecRequestInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,aAAa,EAEb,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG7E,MAAM,WAAW,mBACf,SAAQ,YAAY,EAClB,sBAAsB;
|
|
1
|
+
{"version":3,"file":"cosecRequestInterceptor.d.ts","sourceRoot":"","sources":["../src/cosecRequestInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,aAAa,EAEb,KAAK,kBAAkB,EACxB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,YAAY,EAAgB,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAG7E,MAAM,WAAW,mBACf,SAAQ,YAAY,EAClB,sBAAsB;CAAG;AAE7B;;GAEG;AACH,eAAO,MAAM,8BAA8B,4BAA4B,CAAC;AAExE;;;GAGG;AACH,eAAO,MAAM,+BAA+B,QACL,CAAC;AAExC,eAAO,MAAM,kCAAkC,yBAAyB,CAAC;AAEzE;;;;;;;;;;;;;;;GAeG;AACH,qBAAa,uBAAwB,YAAW,kBAAkB;IAChE,QAAQ,CAAC,IAAI,6BAAkC;IAC/C,QAAQ,CAAC,KAAK,SAAmC;IACjD,OAAO,CAAC,OAAO,CAAsB;IAErC;;;OAGG;gBACS,OAAO,EAAE,mBAAmB;IAIxC;;;;;;;;;;;;;;;;;;;;;OAqBG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa;CAexC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deviceIdStorage.d.ts","sourceRoot":"","sources":["../src/deviceIdStorage.ts"],"names":[],"mappings":"AAcA,OAAO,
|
|
1
|
+
{"version":3,"file":"deviceIdStorage.d.ts","sourceRoot":"","sources":["../src/deviceIdStorage.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAA2B,MAAM,4BAA4B,CAAC;AAMpG,eAAO,MAAM,2BAA2B,oBAAoB,CAAC;AAG7D,MAAM,WAAW,sBACf,SAAQ,OAAO,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,UAAU,CAAC,MAAM,CAAC;gBACzC,EACE,GAAiC,EACjC,QAEE,EACF,GAAG,KAAK,EACT,GAAE,sBAA2B;IAI1C;;;;OAIG;IACH,gBAAgB,IAAI,MAAM;IAI1B;;;;OAIG;IACH,WAAW,IAAI,MAAM;CAWtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"forbiddenErrorInterceptor.d.ts","sourceRoot":"","sources":["../src/forbiddenErrorInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,8BAA8B,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,yBAA0B,YAAW,gBAAgB;IA+BpD,OAAO,CAAC,OAAO;IA9B3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,+BAAoC;IAEjD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,KAAqC;IAEnD;;;;;;;;;;;;;;;;OAgBG;gBACiB,OAAO,EAAE,gCAAgC;
|
|
1
|
+
{"version":3,"file":"forbiddenErrorInterceptor.d.ts","sourceRoot":"","sources":["../src/forbiddenErrorInterceptor.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAGrE;;;GAGG;AACH,eAAO,MAAM,gCAAgC,8BAA8B,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,iCAAiC,IAAI,CAAC;AAEnD;;GAEG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,WAAW,EAAE,CAAC,QAAQ,EAAE,aAAa,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACzD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuDG;AACH,qBAAa,yBAA0B,YAAW,gBAAgB;IA+BpD,OAAO,CAAC,OAAO;IA9B3B;;;OAGG;IACH,QAAQ,CAAC,IAAI,+BAAoC;IAEjD;;;;OAIG;IACH,QAAQ,CAAC,KAAK,KAAqC;IAEnD;;;;;;;;;;;;;;;;OAgBG;gBACiB,OAAO,EAAE,gCAAgC;IAE7D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAmCG;IACG,SAAS,CAAC,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;CAQxD"}
|
package/dist/index.es.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { REQUEST_BODY_INTERCEPTOR_ORDER as w, FetcherError as D, ResultExtractors as U } from "@ahoo-wang/fetcher";
|
|
2
2
|
import { nanoid as y } from "nanoid";
|
|
3
|
-
import { KeyStorage as f } from "@ahoo-wang/fetcher-storage";
|
|
3
|
+
import { KeyStorage as f, typedIdentitySerializer as C } from "@ahoo-wang/fetcher-storage";
|
|
4
4
|
import { BroadcastTypedEventBus as O, SerialTypedEventBus as _ } from "@ahoo-wang/fetcher-eventbus";
|
|
5
5
|
const a = class a {
|
|
6
6
|
};
|
|
@@ -10,14 +10,14 @@ const u = class u {
|
|
|
10
10
|
};
|
|
11
11
|
u.UNAUTHORIZED = 401, u.FORBIDDEN = 403;
|
|
12
12
|
let h = u;
|
|
13
|
-
const
|
|
13
|
+
const ie = {
|
|
14
14
|
ALLOW: { authorized: !0, reason: "Allow" },
|
|
15
15
|
EXPLICIT_DENY: { authorized: !1, reason: "Explicit Deny" },
|
|
16
16
|
IMPLICIT_DENY: { authorized: !1, reason: "Implicit Deny" },
|
|
17
17
|
TOKEN_EXPIRED: { authorized: !1, reason: "Token Expired" },
|
|
18
18
|
TOO_MANY_REQUESTS: { authorized: !1, reason: "Too Many Requests" }
|
|
19
19
|
};
|
|
20
|
-
class
|
|
20
|
+
class m {
|
|
21
21
|
/**
|
|
22
22
|
* Generate a unique request ID.
|
|
23
23
|
*
|
|
@@ -27,14 +27,14 @@ class C {
|
|
|
27
27
|
return y();
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const N = new
|
|
31
|
-
class
|
|
30
|
+
const N = new m(), b = "CoSecRequestInterceptor", g = w + 1e3, k = "Ignore-Refresh-Token";
|
|
31
|
+
class M {
|
|
32
32
|
/**
|
|
33
33
|
* Creates a new CoSecRequestInterceptor instance.
|
|
34
34
|
* @param options - The CoSec configuration options including appId, deviceIdStorage, and tokenManager
|
|
35
35
|
*/
|
|
36
36
|
constructor(e) {
|
|
37
|
-
this.name =
|
|
37
|
+
this.name = b, this.order = g, this.options = e;
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
40
|
* Intercept requests to add CoSec authentication headers.
|
|
@@ -63,15 +63,15 @@ class b {
|
|
|
63
63
|
o[n.APP_ID] = this.options.appId, o[n.DEVICE_ID] = r, o[n.REQUEST_ID] = t;
|
|
64
64
|
}
|
|
65
65
|
}
|
|
66
|
-
const
|
|
67
|
-
class
|
|
66
|
+
const z = "AuthorizationRequestInterceptor", q = g + 1e3;
|
|
67
|
+
class v {
|
|
68
68
|
/**
|
|
69
69
|
* Creates an AuthorizationRequestInterceptor instance.
|
|
70
70
|
*
|
|
71
71
|
* @param options - Configuration options containing the token manager
|
|
72
72
|
*/
|
|
73
73
|
constructor(e) {
|
|
74
|
-
this.options = e, this.name =
|
|
74
|
+
this.options = e, this.name = z, this.order = q;
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
77
|
* Intercepts the request exchange to add authorization headers.
|
|
@@ -90,14 +90,14 @@ class q {
|
|
|
90
90
|
!t || r[n.AUTHORIZATION] || (!e.attributes.has(k) && t.isRefreshNeeded && t.isRefreshable && await this.options.tokenManager.refresh(), t = this.options.tokenManager.currentToken, t && (r[n.AUTHORIZATION] = `Bearer ${t.access.token}`));
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
|
-
const
|
|
94
|
-
class
|
|
93
|
+
const F = "AuthorizationResponseInterceptor", K = Number.MIN_SAFE_INTEGER + 1e3;
|
|
94
|
+
class B {
|
|
95
95
|
/**
|
|
96
96
|
* Creates a new AuthorizationResponseInterceptor instance.
|
|
97
97
|
* @param options - The CoSec configuration options including token storage and refresher
|
|
98
98
|
*/
|
|
99
99
|
constructor(e) {
|
|
100
|
-
this.options = e, this.name =
|
|
100
|
+
this.options = e, this.name = F, this.order = K;
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* Intercepts the response and handles unauthorized responses by refreshing tokens.
|
|
@@ -114,13 +114,15 @@ class K {
|
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
const p = "cosec-device-id";
|
|
117
|
-
class
|
|
117
|
+
class H extends f {
|
|
118
118
|
constructor({
|
|
119
119
|
key: e = p,
|
|
120
|
-
eventBus: t = new O({
|
|
120
|
+
eventBus: t = new O({
|
|
121
|
+
delegate: new _(p)
|
|
122
|
+
}),
|
|
121
123
|
...r
|
|
122
124
|
} = {}) {
|
|
123
|
-
super({ key: e, eventBus: t, ...r });
|
|
125
|
+
super({ key: e, eventBus: t, ...r, serializer: C() });
|
|
124
126
|
}
|
|
125
127
|
/**
|
|
126
128
|
* Generate a new device ID.
|
|
@@ -140,8 +142,8 @@ class B extends f {
|
|
|
140
142
|
return e || (e = this.generateDeviceId(), this.set(e)), e;
|
|
141
143
|
}
|
|
142
144
|
}
|
|
143
|
-
const
|
|
144
|
-
class
|
|
145
|
+
const Z = "ForbiddenErrorInterceptor", J = 0;
|
|
146
|
+
class Q {
|
|
145
147
|
/**
|
|
146
148
|
* Creates a new ForbiddenErrorInterceptor instance.
|
|
147
149
|
*
|
|
@@ -160,7 +162,7 @@ class J {
|
|
|
160
162
|
* ```
|
|
161
163
|
*/
|
|
162
164
|
constructor(e) {
|
|
163
|
-
this.options = e, this.name =
|
|
165
|
+
this.options = e, this.name = Z, this.order = J;
|
|
164
166
|
}
|
|
165
167
|
/**
|
|
166
168
|
* Intercepts fetch exchanges to detect and handle forbidden (403) responses.
|
|
@@ -207,7 +209,7 @@ class E extends D {
|
|
|
207
209
|
super("Refresh token failed.", t), this.token = e, this.name = "RefreshTokenError", Object.setPrototypeOf(this, E.prototype);
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
|
-
class
|
|
212
|
+
class x {
|
|
211
213
|
/**
|
|
212
214
|
* Creates a new JwtTokenManager instance
|
|
213
215
|
* @param tokenStorage The storage used to persist tokens
|
|
@@ -255,18 +257,18 @@ class Q {
|
|
|
255
257
|
return this.currentToken ? this.currentToken.isRefreshable : !1;
|
|
256
258
|
}
|
|
257
259
|
}
|
|
258
|
-
const
|
|
259
|
-
class
|
|
260
|
+
const Y = "tenantId", L = "ownerId", j = "ResourceAttributionRequestInterceptor", G = Number.MAX_SAFE_INTEGER;
|
|
261
|
+
class V {
|
|
260
262
|
/**
|
|
261
263
|
* Creates a new ResourceAttributionRequestInterceptor
|
|
262
264
|
* @param options - Configuration options for resource attribution including tenantId, ownerId and tokenStorage
|
|
263
265
|
*/
|
|
264
266
|
constructor({
|
|
265
|
-
tenantId: e =
|
|
266
|
-
ownerId: t =
|
|
267
|
+
tenantId: e = Y,
|
|
268
|
+
ownerId: t = L,
|
|
267
269
|
tokenStorage: r
|
|
268
270
|
}) {
|
|
269
|
-
this.name =
|
|
271
|
+
this.name = j, this.order = G, this.tenantIdPathKey = e, this.ownerIdPathKey = t, this.tokenStorage = r;
|
|
270
272
|
}
|
|
271
273
|
/**
|
|
272
274
|
* Intercepts outgoing requests and automatically adds tenant and owner ID path parameters
|
|
@@ -308,7 +310,7 @@ function S(s) {
|
|
|
308
310
|
return console.error("Failed to parse JWT token", e), null;
|
|
309
311
|
}
|
|
310
312
|
}
|
|
311
|
-
function
|
|
313
|
+
function W(s, e = 0) {
|
|
312
314
|
const t = typeof s == "string" ? S(s) : s;
|
|
313
315
|
if (!t)
|
|
314
316
|
return !0;
|
|
@@ -327,7 +329,7 @@ class T {
|
|
|
327
329
|
* @returns true if the token is expired, false otherwise
|
|
328
330
|
*/
|
|
329
331
|
get isExpired() {
|
|
330
|
-
return this.payload ?
|
|
332
|
+
return this.payload ? W(this.payload, this.earlyPeriod) : !0;
|
|
331
333
|
}
|
|
332
334
|
}
|
|
333
335
|
class A {
|
|
@@ -374,11 +376,13 @@ class P {
|
|
|
374
376
|
return JSON.stringify(e.token);
|
|
375
377
|
}
|
|
376
378
|
}
|
|
377
|
-
const
|
|
378
|
-
class
|
|
379
|
+
const ae = new P(), l = "cosec-token";
|
|
380
|
+
class X extends f {
|
|
379
381
|
constructor({
|
|
380
382
|
key: e = l,
|
|
381
|
-
eventBus: t = new O({
|
|
383
|
+
eventBus: t = new O({
|
|
384
|
+
delegate: new _(l)
|
|
385
|
+
}),
|
|
382
386
|
earlyPeriod: r = 0,
|
|
383
387
|
...o
|
|
384
388
|
} = {}) {
|
|
@@ -393,15 +397,15 @@ class W extends f {
|
|
|
393
397
|
this.set(new A(e, this.earlyPeriod));
|
|
394
398
|
}
|
|
395
399
|
}
|
|
396
|
-
const
|
|
397
|
-
class
|
|
400
|
+
const $ = "UnauthorizedErrorInterceptor", ee = 0;
|
|
401
|
+
class te {
|
|
398
402
|
/**
|
|
399
403
|
* Creates a new UnauthorizedErrorInterceptor instance.
|
|
400
404
|
*
|
|
401
405
|
* @param options - Configuration options containing the callback to handle unauthorized responses
|
|
402
406
|
*/
|
|
403
407
|
constructor(e) {
|
|
404
|
-
this.options = e, this.name =
|
|
408
|
+
this.options = e, this.name = $, this.order = ee;
|
|
405
409
|
}
|
|
406
410
|
/**
|
|
407
411
|
* Intercepts fetch exchanges to detect and handle unauthorized (401) responses
|
|
@@ -430,7 +434,7 @@ class ee {
|
|
|
430
434
|
(e.response?.status === h.UNAUTHORIZED || e.error instanceof E) && await this.options.onUnauthorized(e);
|
|
431
435
|
}
|
|
432
436
|
}
|
|
433
|
-
class
|
|
437
|
+
class ce {
|
|
434
438
|
/**
|
|
435
439
|
* Creates a new CoSecConfigurer instance with the provided configuration.
|
|
436
440
|
*
|
|
@@ -457,7 +461,7 @@ class ae {
|
|
|
457
461
|
* ```
|
|
458
462
|
*/
|
|
459
463
|
constructor(e) {
|
|
460
|
-
this.config = e, this.tokenStorage = e.tokenStorage ?? new
|
|
464
|
+
this.config = e, this.tokenStorage = e.tokenStorage ?? new X(), this.deviceIdStorage = e.deviceIdStorage ?? new H(), e.tokenRefresher && (this.tokenManager = new x(
|
|
461
465
|
this.tokenStorage,
|
|
462
466
|
e.tokenRefresher
|
|
463
467
|
));
|
|
@@ -497,34 +501,34 @@ class ae {
|
|
|
497
501
|
*/
|
|
498
502
|
applyTo(e) {
|
|
499
503
|
e.interceptors.request.use(
|
|
500
|
-
new
|
|
504
|
+
new M({
|
|
501
505
|
appId: this.config.appId,
|
|
502
506
|
deviceIdStorage: this.deviceIdStorage
|
|
503
507
|
})
|
|
504
508
|
), e.interceptors.request.use(
|
|
505
|
-
new
|
|
509
|
+
new V({
|
|
506
510
|
tokenStorage: this.tokenStorage
|
|
507
511
|
})
|
|
508
512
|
), this.tokenManager && (e.interceptors.request.use(
|
|
509
|
-
new
|
|
513
|
+
new v({
|
|
510
514
|
tokenManager: this.tokenManager
|
|
511
515
|
})
|
|
512
516
|
), e.interceptors.response.use(
|
|
513
|
-
new
|
|
517
|
+
new B({
|
|
514
518
|
tokenManager: this.tokenManager
|
|
515
519
|
})
|
|
516
520
|
)), this.config.onUnauthorized && e.interceptors.error.use(
|
|
517
|
-
new
|
|
521
|
+
new te({
|
|
518
522
|
onUnauthorized: this.config.onUnauthorized
|
|
519
523
|
})
|
|
520
524
|
), this.config.onForbidden && e.interceptors.error.use(
|
|
521
|
-
new
|
|
525
|
+
new Q({
|
|
522
526
|
onForbidden: this.config.onForbidden
|
|
523
527
|
})
|
|
524
528
|
);
|
|
525
529
|
}
|
|
526
530
|
}
|
|
527
|
-
class
|
|
531
|
+
class he {
|
|
528
532
|
/**
|
|
529
533
|
* Creates a new instance of CoSecTokenRefresher.
|
|
530
534
|
*
|
|
@@ -553,43 +557,43 @@ class ce {
|
|
|
553
557
|
}
|
|
554
558
|
}
|
|
555
559
|
export {
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
560
|
+
z as AUTHORIZATION_REQUEST_INTERCEPTOR_NAME,
|
|
561
|
+
q as AUTHORIZATION_REQUEST_INTERCEPTOR_ORDER,
|
|
562
|
+
F as AUTHORIZATION_RESPONSE_INTERCEPTOR_NAME,
|
|
563
|
+
K as AUTHORIZATION_RESPONSE_INTERCEPTOR_ORDER,
|
|
564
|
+
v as AuthorizationRequestInterceptor,
|
|
565
|
+
B as AuthorizationResponseInterceptor,
|
|
566
|
+
ie as AuthorizeResults,
|
|
567
|
+
b as COSEC_REQUEST_INTERCEPTOR_NAME,
|
|
564
568
|
g as COSEC_REQUEST_INTERCEPTOR_ORDER,
|
|
565
|
-
|
|
569
|
+
ce as CoSecConfigurer,
|
|
566
570
|
n as CoSecHeaders,
|
|
567
|
-
|
|
568
|
-
|
|
571
|
+
M as CoSecRequestInterceptor,
|
|
572
|
+
he as CoSecTokenRefresher,
|
|
569
573
|
p as DEFAULT_COSEC_DEVICE_ID_KEY,
|
|
570
574
|
l as DEFAULT_COSEC_TOKEN_KEY,
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
+
H as DeviceIdStorage,
|
|
576
|
+
Z as FORBIDDEN_ERROR_INTERCEPTOR_NAME,
|
|
577
|
+
J as FORBIDDEN_ERROR_INTERCEPTOR_ORDER,
|
|
578
|
+
Q as ForbiddenErrorInterceptor,
|
|
575
579
|
k as IGNORE_REFRESH_TOKEN_ATTRIBUTE_KEY,
|
|
576
580
|
A as JwtCompositeToken,
|
|
577
581
|
P as JwtCompositeTokenSerializer,
|
|
578
582
|
T as JwtToken,
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
+
x as JwtTokenManager,
|
|
584
|
+
m as NanoIdGenerator,
|
|
585
|
+
j as RESOURCE_ATTRIBUTION_REQUEST_INTERCEPTOR_NAME,
|
|
586
|
+
G as RESOURCE_ATTRIBUTION_REQUEST_INTERCEPTOR_ORDER,
|
|
583
587
|
E as RefreshTokenError,
|
|
584
|
-
|
|
588
|
+
V as ResourceAttributionRequestInterceptor,
|
|
585
589
|
h as ResponseCodes,
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
+
X as TokenStorage,
|
|
591
|
+
$ as UNAUTHORIZED_ERROR_INTERCEPTOR_NAME,
|
|
592
|
+
ee as UNAUTHORIZED_ERROR_INTERCEPTOR_ORDER,
|
|
593
|
+
te as UnauthorizedErrorInterceptor,
|
|
590
594
|
N as idGenerator,
|
|
591
|
-
|
|
592
|
-
|
|
595
|
+
W as isTokenExpired,
|
|
596
|
+
ae as jwtCompositeTokenSerializer,
|
|
593
597
|
S as parseJwtPayload
|
|
594
598
|
};
|
|
595
599
|
//# sourceMappingURL=index.es.js.map
|