@stream-io/feeds-client 0.3.14 → 0.3.16
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/CHANGELOG.md +18 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/react-bindings.js +12 -6
- package/dist/cjs/react-bindings.js.map +1 -1
- package/dist/es/index.mjs +2 -2
- package/dist/es/index.mjs.map +1 -1
- package/dist/es/react-bindings.mjs +12 -6
- package/dist/es/react-bindings.mjs.map +1 -1
- package/dist/{feeds-client-YbhVg6cF.js → feeds-client-B6L006tr.js} +42 -9
- package/dist/feeds-client-B6L006tr.js.map +1 -0
- package/dist/{feeds-client-DoDAKYaV.mjs → feeds-client-Bh01VLai.mjs} +42 -9
- package/dist/feeds-client-Bh01VLai.mjs.map +1 -0
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.d.ts +1 -1
- package/dist/types/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.d.ts.map +1 -1
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts +3 -3
- package/dist/types/bindings/react/hooks/useCreateFeedsClient.d.ts.map +1 -1
- package/dist/types/common/ApiClient.d.ts.map +1 -1
- package/dist/types/common/ConnectionIdManager.d.ts +3 -3
- package/dist/types/common/ConnectionIdManager.d.ts.map +1 -1
- package/dist/types/common/TokenManager.d.ts +3 -3
- package/dist/types/common/TokenManager.d.ts.map +1 -1
- package/dist/types/feeds-client/feeds-client.d.ts +5 -1
- package/dist/types/feeds-client/feeds-client.d.ts.map +1 -1
- package/dist/types/gen/models/index.d.ts +2 -0
- package/dist/types/gen/models/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/bindings/react/hooks/feed-state-hooks/useOwnCapabilities.ts +2 -2
- package/src/bindings/react/hooks/useCreateFeedsClient.ts +23 -12
- package/src/common/ApiClient.ts +4 -2
- package/src/common/ConnectionIdManager.ts +9 -7
- package/src/common/TokenManager.ts +19 -3
- package/src/common/real-time/StableWSConnection.ts +1 -1
- package/src/feeds-client/feeds-client.ts +22 -1
- package/src/gen/models/index.ts +4 -0
- package/dist/feeds-client-DoDAKYaV.mjs.map +0 -1
- package/dist/feeds-client-YbhVg6cF.js.map +0 -1
|
@@ -3217,8 +3217,15 @@ const capitalize = (s) => {
|
|
|
3217
3217
|
};
|
|
3218
3218
|
class TokenManager {
|
|
3219
3219
|
constructor() {
|
|
3220
|
+
this._isAnonymous = false;
|
|
3220
3221
|
this.logger = feedsLoggerSystem.getLogger("token-manager");
|
|
3221
3222
|
this.setTokenOrProvider = (tokenOrProvider) => {
|
|
3223
|
+
if (tokenOrProvider === void 0) {
|
|
3224
|
+
this._isAnonymous = true;
|
|
3225
|
+
tokenOrProvider = "";
|
|
3226
|
+
} else {
|
|
3227
|
+
this._isAnonymous = false;
|
|
3228
|
+
}
|
|
3222
3229
|
if (isFunction(tokenOrProvider)) {
|
|
3223
3230
|
this.tokenProvider = tokenOrProvider;
|
|
3224
3231
|
this.type = "provider";
|
|
@@ -3229,7 +3236,9 @@ class TokenManager {
|
|
|
3229
3236
|
}
|
|
3230
3237
|
};
|
|
3231
3238
|
this.reset = () => {
|
|
3239
|
+
this._isAnonymous = false;
|
|
3232
3240
|
this.token = void 0;
|
|
3241
|
+
this.tokenProvider = void 0;
|
|
3233
3242
|
this.loadTokenPromise = null;
|
|
3234
3243
|
};
|
|
3235
3244
|
this.loadToken = () => {
|
|
@@ -3272,6 +3281,9 @@ class TokenManager {
|
|
|
3272
3281
|
return this.loadTokenPromise;
|
|
3273
3282
|
};
|
|
3274
3283
|
this.getToken = () => {
|
|
3284
|
+
if (this._isAnonymous) {
|
|
3285
|
+
return "";
|
|
3286
|
+
}
|
|
3275
3287
|
if (this.token) {
|
|
3276
3288
|
return this.token;
|
|
3277
3289
|
}
|
|
@@ -3288,6 +3300,9 @@ class TokenManager {
|
|
|
3288
3300
|
this.loadTokenPromise = null;
|
|
3289
3301
|
this.type = "static";
|
|
3290
3302
|
}
|
|
3303
|
+
get isAnonymous() {
|
|
3304
|
+
return this._isAnonymous;
|
|
3305
|
+
}
|
|
3291
3306
|
}
|
|
3292
3307
|
class ConnectionIdManager {
|
|
3293
3308
|
constructor() {
|
|
@@ -3299,10 +3314,12 @@ class ConnectionIdManager {
|
|
|
3299
3314
|
};
|
|
3300
3315
|
this.resetConnectionIdPromise = () => {
|
|
3301
3316
|
this.connectionId = void 0;
|
|
3302
|
-
this.loadConnectionIdPromise = new Promise(
|
|
3303
|
-
|
|
3304
|
-
|
|
3305
|
-
|
|
3317
|
+
this.loadConnectionIdPromise = new Promise(
|
|
3318
|
+
(resolve, reject) => {
|
|
3319
|
+
this.resolve = resolve;
|
|
3320
|
+
this.reject = reject;
|
|
3321
|
+
}
|
|
3322
|
+
);
|
|
3306
3323
|
};
|
|
3307
3324
|
this.resolveConnectionidPromise = (connectionId) => {
|
|
3308
3325
|
this.connectionId = connectionId;
|
|
@@ -3404,7 +3421,7 @@ class StableWSConnection {
|
|
|
3404
3421
|
return;
|
|
3405
3422
|
}
|
|
3406
3423
|
const token = await this.tokenManager.getToken();
|
|
3407
|
-
if (!token) {
|
|
3424
|
+
if (!token && !this.tokenManager.isAnonymous) {
|
|
3408
3425
|
logger.warn(`Token not set, can't connect authenticate`);
|
|
3409
3426
|
return;
|
|
3410
3427
|
}
|
|
@@ -3887,7 +3904,7 @@ const getRateLimitFromResponseHeader = (response_headers) => {
|
|
|
3887
3904
|
};
|
|
3888
3905
|
return result;
|
|
3889
3906
|
};
|
|
3890
|
-
const version = "0.3.
|
|
3907
|
+
const version = "0.3.16";
|
|
3891
3908
|
class ApiClient {
|
|
3892
3909
|
constructor(apiKey, tokenManager, connectionIdManager, options) {
|
|
3893
3910
|
this.apiKey = apiKey;
|
|
@@ -3901,7 +3918,9 @@ class ApiClient {
|
|
|
3901
3918
|
if (queryParams?.watch || queryParams?.presence || queryParams?.payload?.watch || queryParams?.payload?.presence || body?.watch || body?.presence) {
|
|
3902
3919
|
this.logger.info("Getting connection_id for watch or presence request");
|
|
3903
3920
|
const connectionId = await this.connectionIdManager.getConnectionId();
|
|
3904
|
-
|
|
3921
|
+
if (connectionId) {
|
|
3922
|
+
queryParams.connection_id = connectionId;
|
|
3923
|
+
}
|
|
3905
3924
|
}
|
|
3906
3925
|
let requestUrl = url;
|
|
3907
3926
|
if (pathParams) {
|
|
@@ -4049,7 +4068,7 @@ class ApiClient {
|
|
|
4049
4068
|
}
|
|
4050
4069
|
get commonHeaders() {
|
|
4051
4070
|
return {
|
|
4052
|
-
"stream-auth-type": "jwt",
|
|
4071
|
+
"stream-auth-type": this.tokenManager.isAnonymous ? "anonymous" : "jwt",
|
|
4053
4072
|
"X-Stream-Client": this.generateStreamClientHeader()
|
|
4054
4073
|
};
|
|
4055
4074
|
}
|
|
@@ -7143,6 +7162,19 @@ class FeedsClient extends FeedsApi {
|
|
|
7143
7162
|
}
|
|
7144
7163
|
};
|
|
7145
7164
|
this.pollFromState = (id) => this.polls_by_id.get(id);
|
|
7165
|
+
this.connectAnonymous = () => {
|
|
7166
|
+
this.connectionIdManager.resolveConnectionidPromise();
|
|
7167
|
+
this.tokenManager.setTokenOrProvider(void 0);
|
|
7168
|
+
this.setGetBatchOwnCapabilitiesThrottlingInterval(
|
|
7169
|
+
this.query_batch_own_capabilties_throttling_interval
|
|
7170
|
+
);
|
|
7171
|
+
this.state.partialNext({
|
|
7172
|
+
connected_user: void 0,
|
|
7173
|
+
is_anonymous: true,
|
|
7174
|
+
is_ws_connection_healthy: false
|
|
7175
|
+
});
|
|
7176
|
+
return Promise.resolve();
|
|
7177
|
+
};
|
|
7146
7178
|
this.connectUser = async (user, tokenProvider) => {
|
|
7147
7179
|
if (this.state.getLatestValue().connected_user !== void 0 || this.wsConnection) {
|
|
7148
7180
|
throw new Error(`Can't connect a new user, call "disconnectUser" first`);
|
|
@@ -7377,6 +7409,7 @@ class FeedsClient extends FeedsApi {
|
|
|
7377
7409
|
};
|
|
7378
7410
|
this.state = new StateStore({
|
|
7379
7411
|
connected_user: void 0,
|
|
7412
|
+
is_anonymous: false,
|
|
7380
7413
|
is_ws_connection_healthy: false,
|
|
7381
7414
|
own_capabilities_by_fid: {}
|
|
7382
7415
|
});
|
|
@@ -7700,4 +7733,4 @@ export {
|
|
|
7700
7733
|
shouldUpdateState as s,
|
|
7701
7734
|
uniqueArrayMerge as u
|
|
7702
7735
|
};
|
|
7703
|
-
//# sourceMappingURL=feeds-client-
|
|
7736
|
+
//# sourceMappingURL=feeds-client-Bh01VLai.mjs.map
|