@launchdarkly/react-native-client-sdk 10.8.0 → 10.8.1-beta.1
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/package.json +2 -2
- package/dist/src/MobileDataManager.d.ts +4 -4
- package/dist/src/MobileDataManager.d.ts.map +1 -1
- package/dist/src/MobileDataManager.js +18 -16
- package/dist/src/MobileDataManager.js.map +1 -1
- package/dist/src/RNStateDetector.js +6 -6
- package/dist/src/RNStateDetector.js.map +1 -1
- package/dist/src/ReactNativeLDClient.d.ts +1 -1
- package/dist/src/ReactNativeLDClient.d.ts.map +1 -1
- package/dist/src/ReactNativeLDClient.js +11 -3
- package/dist/src/ReactNativeLDClient.js.map +1 -1
- package/dist/src/fromExternal/react-native-sse/EventSource.d.ts +21 -21
- package/dist/src/fromExternal/react-native-sse/EventSource.d.ts.map +1 -1
- package/dist/src/fromExternal/react-native-sse/EventSource.js +104 -104
- package/dist/src/fromExternal/react-native-sse/EventSource.js.map +1 -1
- package/dist/src/platform/ConnectionManager.js +41 -41
- package/dist/src/platform/ConnectionManager.js.map +1 -1
- package/dist/src/platform/PlatformInfo.d.ts +2 -2
- package/dist/src/platform/PlatformInfo.d.ts.map +1 -1
- package/dist/src/platform/PlatformInfo.js +4 -4
- package/dist/src/platform/PlatformInfo.js.map +1 -1
- package/dist/src/platform/PlatformRequests.d.ts +2 -2
- package/dist/src/platform/PlatformRequests.d.ts.map +1 -1
- package/dist/src/platform/PlatformRequests.js +3 -3
- package/dist/src/platform/PlatformRequests.js.map +1 -1
- package/dist/src/platform/PlatformStorage.d.ts +2 -2
- package/dist/src/platform/PlatformStorage.d.ts.map +1 -1
- package/dist/src/platform/PlatformStorage.js +4 -4
- package/dist/src/platform/PlatformStorage.js.map +1 -1
- package/dist/src/platform/crypto/PlatformHasher.d.ts +1 -1
- package/dist/src/platform/crypto/PlatformHasher.d.ts.map +1 -1
- package/dist/src/platform/crypto/PlatformHasher.js +4 -4
- package/dist/src/platform/crypto/PlatformHasher.js.map +1 -1
- package/package.json +2 -2
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/react-native-client-sdk",
|
|
3
|
-
"version": "10.8.
|
|
3
|
+
"version": "10.8.1-beta.1",
|
|
4
4
|
"description": "React Native LaunchDarkly SDK",
|
|
5
5
|
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-native": "*"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@launchdarkly/js-client-sdk-common": "1.9.
|
|
44
|
+
"@launchdarkly/js-client-sdk-common": "1.9.1-beta.1",
|
|
45
45
|
"@react-native-async-storage/async-storage": "^1.21.0",
|
|
46
46
|
"base64-js": "^1.5.1"
|
|
47
47
|
},
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { BaseDataManager, Configuration, ConnectionMode, Context, DataSourcePaths, FlagManager, internal, LDEmitter, LDHeaders, LDIdentifyOptions, Platform } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
import { ValidatedOptions } from './options';
|
|
3
3
|
export default class MobileDataManager extends BaseDataManager {
|
|
4
|
-
private readonly
|
|
4
|
+
private readonly _rnConfig;
|
|
5
5
|
protected networkAvailable: boolean;
|
|
6
6
|
protected connectionMode: ConnectionMode;
|
|
7
|
-
constructor(platform: Platform, flagManager: FlagManager, credential: string, config: Configuration,
|
|
8
|
-
private
|
|
7
|
+
constructor(platform: Platform, flagManager: FlagManager, credential: string, config: Configuration, _rnConfig: ValidatedOptions, getPollingPaths: () => DataSourcePaths, getStreamingPaths: () => DataSourcePaths, baseHeaders: LDHeaders, emitter: LDEmitter, diagnosticsManager?: internal.DiagnosticsManager);
|
|
8
|
+
private _debugLog;
|
|
9
9
|
identify(identifyResolve: () => void, identifyReject: (err: Error) => void, context: Context, identifyOptions?: LDIdentifyOptions): Promise<void>;
|
|
10
|
-
private
|
|
10
|
+
private _setupConnection;
|
|
11
11
|
setNetworkAvailability(available: boolean): void;
|
|
12
12
|
setConnectionMode(mode: ConnectionMode): Promise<void>;
|
|
13
13
|
getConnectionMode(): ConnectionMode;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileDataManager.d.ts","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,EACP,eAAe,EACf,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,
|
|
1
|
+
{"version":3,"file":"MobileDataManager.d.ts","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,aAAa,EACb,cAAc,EACd,OAAO,EACP,eAAe,EACf,WAAW,EACX,QAAQ,EACR,SAAS,EACT,SAAS,EACT,iBAAiB,EAEjB,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAE5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAI7C,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,eAAe;IAU1D,OAAO,CAAC,QAAQ,CAAC,SAAS;IAR5B,SAAS,CAAC,gBAAgB,EAAE,OAAO,CAAQ;IAC3C,SAAS,CAAC,cAAc,EAAE,cAAc,CAAe;gBAGrD,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,EACxB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,aAAa,EACJ,SAAS,EAAE,gBAAgB,EAC5C,eAAe,EAAE,MAAM,eAAe,EACtC,iBAAiB,EAAE,MAAM,eAAe,EACxC,WAAW,EAAE,SAAS,EACtB,OAAO,EAAE,SAAS,EAClB,kBAAkB,CAAC,EAAE,QAAQ,CAAC,kBAAkB;IAgBlD,OAAO,CAAC,SAAS;IAIF,QAAQ,CACrB,eAAe,EAAE,MAAM,IAAI,EAC3B,cAAc,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,IAAI,EACpC,OAAO,EAAE,OAAO,EAChB,eAAe,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,IAAI,CAAC;IAgChB,OAAO,CAAC,gBAAgB;IA8CxB,sBAAsB,CAAC,SAAS,EAAE,OAAO,GAAG,IAAI;IAI1C,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IA6B5D,iBAAiB,IAAI,cAAc;CAGpC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { BaseDataManager, Context, } from '@launchdarkly/js-client-sdk-common';
|
|
1
|
+
import { BaseDataManager, Context, makeRequestor, } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
const logTag = '[MobileDataManager]';
|
|
3
3
|
export default class MobileDataManager extends BaseDataManager {
|
|
4
|
-
constructor(platform, flagManager, credential, config,
|
|
4
|
+
constructor(platform, flagManager, credential, config, _rnConfig, getPollingPaths, getStreamingPaths, baseHeaders, emitter, diagnosticsManager) {
|
|
5
5
|
super(platform, flagManager, credential, config, getPollingPaths, getStreamingPaths, baseHeaders, emitter, diagnosticsManager);
|
|
6
|
-
this.
|
|
6
|
+
this._rnConfig = _rnConfig;
|
|
7
7
|
// Not implemented yet.
|
|
8
8
|
this.networkAvailable = true;
|
|
9
9
|
this.connectionMode = 'streaming';
|
|
10
|
-
this.connectionMode =
|
|
10
|
+
this.connectionMode = _rnConfig.initialConnectionMode;
|
|
11
11
|
}
|
|
12
|
-
|
|
12
|
+
_debugLog(message, ...args) {
|
|
13
13
|
this.logger.debug(`${logTag} ${message}`, ...args);
|
|
14
14
|
}
|
|
15
15
|
async identify(identifyResolve, identifyReject, context, identifyOptions) {
|
|
@@ -19,36 +19,38 @@ export default class MobileDataManager extends BaseDataManager {
|
|
|
19
19
|
const waitForNetworkResults = !!(identifyOptions === null || identifyOptions === void 0 ? void 0 : identifyOptions.waitForNetworkResults) && !offline;
|
|
20
20
|
const loadedFromCache = await this.flagManager.loadCached(context);
|
|
21
21
|
if (loadedFromCache && !waitForNetworkResults) {
|
|
22
|
-
this.
|
|
22
|
+
this._debugLog('Identify completing with cached flags');
|
|
23
23
|
identifyResolve();
|
|
24
24
|
}
|
|
25
25
|
if (loadedFromCache && waitForNetworkResults) {
|
|
26
|
-
this.
|
|
26
|
+
this._debugLog('Identify - Flags loaded from cache, but identify was requested with "waitForNetworkResults"');
|
|
27
27
|
}
|
|
28
28
|
if (this.connectionMode === 'offline') {
|
|
29
29
|
if (loadedFromCache) {
|
|
30
|
-
this.
|
|
30
|
+
this._debugLog('Offline identify - using cached flags.');
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
this.
|
|
33
|
+
this._debugLog('Offline identify - no cached flags, using defaults or already loaded flags.');
|
|
34
34
|
identifyResolve();
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
37
|
else {
|
|
38
38
|
// Context has been validated in LDClientImpl.identify
|
|
39
|
-
this.
|
|
39
|
+
this._setupConnection(context, identifyResolve, identifyReject);
|
|
40
40
|
}
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
_setupConnection(context, identifyResolve, identifyReject) {
|
|
43
43
|
var _a;
|
|
44
44
|
const rawContext = Context.toLDContext(context);
|
|
45
|
+
const plainContextString = JSON.stringify(Context.toLDContext(context));
|
|
46
|
+
const requestor = makeRequestor(plainContextString, this.config.serviceEndpoints, this.getPollingPaths(), this.platform.requests, this.platform.encoding, this.baseHeaders, [], this.config.useReport, this.config.withReasons);
|
|
45
47
|
(_a = this.updateProcessor) === null || _a === void 0 ? void 0 : _a.close();
|
|
46
48
|
switch (this.connectionMode) {
|
|
47
49
|
case 'streaming':
|
|
48
|
-
this.createStreamingProcessor(rawContext, context, identifyResolve, identifyReject);
|
|
50
|
+
this.createStreamingProcessor(rawContext, context, requestor, identifyResolve, identifyReject);
|
|
49
51
|
break;
|
|
50
52
|
case 'polling':
|
|
51
|
-
this.createPollingProcessor(rawContext, context, identifyResolve, identifyReject);
|
|
53
|
+
this.createPollingProcessor(rawContext, context, requestor, identifyResolve, identifyReject);
|
|
52
54
|
break;
|
|
53
55
|
default:
|
|
54
56
|
break;
|
|
@@ -61,11 +63,11 @@ export default class MobileDataManager extends BaseDataManager {
|
|
|
61
63
|
async setConnectionMode(mode) {
|
|
62
64
|
var _a;
|
|
63
65
|
if (this.connectionMode === mode) {
|
|
64
|
-
this.
|
|
66
|
+
this._debugLog(`setConnectionMode ignored. Mode is already '${mode}'.`);
|
|
65
67
|
return;
|
|
66
68
|
}
|
|
67
69
|
this.connectionMode = mode;
|
|
68
|
-
this.
|
|
70
|
+
this._debugLog(`setConnectionMode ${mode}.`);
|
|
69
71
|
switch (mode) {
|
|
70
72
|
case 'offline':
|
|
71
73
|
(_a = this.updateProcessor) === null || _a === void 0 ? void 0 : _a.close();
|
|
@@ -74,7 +76,7 @@ export default class MobileDataManager extends BaseDataManager {
|
|
|
74
76
|
case 'streaming':
|
|
75
77
|
if (this.context) {
|
|
76
78
|
// identify will start the update processor
|
|
77
|
-
this.
|
|
79
|
+
this._setupConnection(this.context);
|
|
78
80
|
}
|
|
79
81
|
break;
|
|
80
82
|
default:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MobileDataManager.js","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGf,OAAO,
|
|
1
|
+
{"version":3,"file":"MobileDataManager.js","sourceRoot":"","sources":["../../src/MobileDataManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EAGf,OAAO,EAOP,aAAa,GAEd,MAAM,oCAAoC,CAAC;AAI5C,MAAM,MAAM,GAAG,qBAAqB,CAAC;AAErC,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,eAAe;IAK5D,YACE,QAAkB,EAClB,WAAwB,EACxB,UAAkB,EAClB,MAAqB,EACJ,SAA2B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BAAsB,CAAC,SAAkB;QACvC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAoB;;QAC1C,IAAI,IAAI,CAAC,cAAc,KAAK,IAAI,EAAE;YAChC,IAAI,CAAC,SAAS,CAAC,+CAA+C,IAAI,IAAI,CAAC,CAAC;YACxE,OAAO;SACR;QAED,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,SAAS,CAAC,qBAAqB,IAAI,GAAG,CAAC,CAAC;QAE7C,QAAQ,IAAI,EAAE;YACZ,KAAK,SAAS;gBACZ,MAAA,IAAI,CAAC,eAAe,0CAAE,KAAK,EAAE,CAAC;gBAC9B,MAAM;YACR,KAAK,SAAS,CAAC;YACf,KAAK,WAAW;gBACd,IAAI,IAAI,CAAC,OAAO,EAAE;oBAChB,2CAA2C;oBAC3C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;iBACrC;gBAED,MAAM;YACR;gBACE,IAAI,CAAC,MAAM,CAAC,IAAI,CACd,2BAA2B,IAAI,6DAA6D,CAC7F,CAAC;gBACF,MAAM;SACT;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -21,21 +21,21 @@ export default class RNStateDetector {
|
|
|
21
21
|
constructor() {
|
|
22
22
|
AppState.addEventListener('change', (state) => {
|
|
23
23
|
var _a;
|
|
24
|
-
(_a = this.
|
|
24
|
+
(_a = this._applicationStateListener) === null || _a === void 0 ? void 0 : _a.call(this, translateAppState(state));
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
setApplicationStateListener(fn) {
|
|
28
|
-
this.
|
|
28
|
+
this._applicationStateListener = fn;
|
|
29
29
|
// When you listen provide the current state immediately.
|
|
30
|
-
this.
|
|
30
|
+
this._applicationStateListener(translateAppState(AppState.currentState));
|
|
31
31
|
}
|
|
32
32
|
setNetworkStateListener(fn) {
|
|
33
|
-
this.
|
|
33
|
+
this._networkStateListener = fn;
|
|
34
34
|
// Not implemented.
|
|
35
35
|
}
|
|
36
36
|
stopListening() {
|
|
37
|
-
this.
|
|
38
|
-
this.
|
|
37
|
+
this._applicationStateListener = undefined;
|
|
38
|
+
this._networkStateListener = undefined;
|
|
39
39
|
}
|
|
40
40
|
}
|
|
41
41
|
//# sourceMappingURL=RNStateDetector.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RNStateDetector.js","sourceRoot":"","sources":["../../src/RNStateDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAA+B,MAAM,8BAA8B,CAAC;AAE7F;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAqB;IAC9C,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC,UAAU,CAAC;QACrC,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,WAAW,CAAC;QACjB;YACE,OAAO,gBAAgB,CAAC,UAAU,CAAC;KACtC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAIlC;QACE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAqB,EAAE,EAAE;;YAC5D,MAAA,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"RNStateDetector.js","sourceRoot":"","sources":["../../src/RNStateDetector.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAkB,MAAM,cAAc,CAAC;AAExD,OAAO,EAAE,gBAAgB,EAA+B,MAAM,8BAA8B,CAAC;AAE7F;;GAEG;AACH,SAAS,iBAAiB,CAAC,KAAqB;IAC9C,QAAQ,KAAK,EAAE;QACb,KAAK,QAAQ;YACX,OAAO,gBAAgB,CAAC,UAAU,CAAC;QACrC,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,WAAW,CAAC;QACjB;YACE,OAAO,gBAAgB,CAAC,UAAU,CAAC;KACtC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,eAAe;IAIlC;QACE,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,CAAC,KAAqB,EAAE,EAAE;;YAC5D,MAAA,IAAI,CAAC,yBAAyB,qDAAG,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;IACL,CAAC;IAED,2BAA2B,CAAC,EAAqC;QAC/D,IAAI,CAAC,yBAAyB,GAAG,EAAE,CAAC;QACpC,yDAAyD;QACzD,IAAI,CAAC,yBAAyB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,uBAAuB,CAAC,EAAiC;QACvD,IAAI,CAAC,qBAAqB,GAAG,EAAE,CAAC;QAChC,mBAAmB;IACrB,CAAC;IAED,aAAa;QACX,IAAI,CAAC,yBAAyB,GAAG,SAAS,CAAC;QAC3C,IAAI,CAAC,qBAAqB,GAAG,SAAS,CAAC;IACzC,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAIjB,cAAc,EAId,YAAY,EAGb,MAAM,oCAAoC,CAAC;AAM5C,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EAIjB,cAAc,EAId,YAAY,EAGb,MAAM,oCAAoC,CAAC;AAM5C,OAAO,SAAS,MAAM,aAAa,CAAC;AAGpC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D,OAAO,CAAC,kBAAkB,CAAoB;IAC9C;;;;;;;;;OASG;gBACS,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,GAAE,SAAc;IAmGnF,iBAAiB,CAAC,IAAI,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAQ5D;;OAEG;IACH,iBAAiB,IAAI,cAAc;IAKnC,SAAS;CAIV"}
|
|
@@ -51,6 +51,11 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
51
51
|
pathReport(_encoding, _plainContextString) {
|
|
52
52
|
return `/msdk/evalx/context`;
|
|
53
53
|
},
|
|
54
|
+
pathPing(_encoding, _plainContextString) {
|
|
55
|
+
// Note: if you are seeing this error, it is a coding error. This DataSourcePaths implementation is for polling endpoints. /ping is not currently
|
|
56
|
+
// used in a polling situation. It is probably the case that this was called by streaming logic erroneously.
|
|
57
|
+
throw new Error('Ping for polling unsupported.');
|
|
58
|
+
},
|
|
54
59
|
}), () => ({
|
|
55
60
|
pathGet(encoding, _plainContextString) {
|
|
56
61
|
return `/meval/${base64UrlEncode(_plainContextString, encoding)}`;
|
|
@@ -58,6 +63,9 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
58
63
|
pathReport(_encoding, _plainContextString) {
|
|
59
64
|
return `/meval`;
|
|
60
65
|
},
|
|
66
|
+
pathPing(_encoding, _plainContextString) {
|
|
67
|
+
return `/mping`;
|
|
68
|
+
},
|
|
61
69
|
}), baseHeaders, emitter, diagnosticsManager), internalOptions);
|
|
62
70
|
this.setEventSendingEnabled(!this.isOffline(), false);
|
|
63
71
|
const dataManager = this.dataManager;
|
|
@@ -75,7 +83,7 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
75
83
|
},
|
|
76
84
|
};
|
|
77
85
|
const initialConnectionMode = (_a = options.initialConnectionMode) !== null && _a !== void 0 ? _a : 'streaming';
|
|
78
|
-
this.
|
|
86
|
+
this._connectionManager = new ConnectionManager(logger, {
|
|
79
87
|
initialConnectionMode,
|
|
80
88
|
automaticNetworkHandling: validatedRnOptions.automaticNetworkHandling,
|
|
81
89
|
automaticBackgroundHandling: validatedRnOptions.automaticBackgroundHandling,
|
|
@@ -85,9 +93,9 @@ export default class ReactNativeLDClient extends LDClientImpl {
|
|
|
85
93
|
async setConnectionMode(mode) {
|
|
86
94
|
// Set the connection mode before setting offline, in case there is any mode transition work
|
|
87
95
|
// such as flushing on entering the background.
|
|
88
|
-
this.
|
|
96
|
+
this._connectionManager.setConnectionMode(mode);
|
|
89
97
|
// For now the data source connection and the event processing state are connected.
|
|
90
|
-
this.
|
|
98
|
+
this._connectionManager.setOffline(mode === 'offline');
|
|
91
99
|
}
|
|
92
100
|
/**
|
|
93
101
|
* Gets the SDK connection mode.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ReactNativeLDClient.js","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAEL,eAAe,EACf,WAAW,EAMX,YAAY,GAGb,MAAM,oCAAoC,CAAC;AAE5C,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,eAAe,EAAE,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,cAAc,MAAM,YAAY,CAAC;AACxC,OAAO,EAAyB,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAExF,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAEhD;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAE3D;;;;;;;;;OASG;IACH,YAAY,MAAc,EAAE,iBAAoC,EAAE,UAAqB,EAAE;;QACvF,MAAM,EAAE,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A2B,EAAE,kBAAkB,CAAC,2BAA2B;YAC3E,eAAe,EAAE,kBAAkB,CAAC,eAAe;SACpD,EACD,WAAW,EACX,IAAI,eAAe,EAAE,CACtB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAoB;QAC1C,4FAA4F;QAC5F,+CAA+C;QAC/C,IAAI,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,IAAI,CAAC,CAAC;QAChD,mFAAmF;QACnF,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACzD,CAAC;IAED;;OAEG;IACH,iBAAiB;QACf,MAAM,WAAW,GAAG,IAAI,CAAC,WAAgC,CAAC;QAC1D,OAAO,WAAW,CAAC,iBAAiB,EAAE,CAAC;IACzC,CAAC;IAED,SAAS;QACP,MAAM,WAAW,GAAG,IAAI,CAAC,WAAgC,CAAC;QAC1D,OAAO,WAAW,CAAC,iBAAiB,EAAE,KAAK,SAAS,CAAC;IACvD,CAAC;CACF"}
|
|
@@ -14,28 +14,28 @@ export default class EventSource<E extends string = never> {
|
|
|
14
14
|
CONNECTING: number;
|
|
15
15
|
OPEN: number;
|
|
16
16
|
CLOSED: number;
|
|
17
|
-
private
|
|
18
|
-
private
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private
|
|
23
|
-
private
|
|
24
|
-
private
|
|
25
|
-
private
|
|
26
|
-
private
|
|
27
|
-
private
|
|
28
|
-
private
|
|
29
|
-
private
|
|
30
|
-
private
|
|
31
|
-
private
|
|
32
|
-
private
|
|
33
|
-
private
|
|
17
|
+
private _lastEventId;
|
|
18
|
+
private _lastIndexProcessed;
|
|
19
|
+
private _eventType;
|
|
20
|
+
private _status;
|
|
21
|
+
private _eventHandlers;
|
|
22
|
+
private _method;
|
|
23
|
+
private _timeout;
|
|
24
|
+
private _withCredentials;
|
|
25
|
+
private _headers;
|
|
26
|
+
private _body;
|
|
27
|
+
private _url;
|
|
28
|
+
private _xhr;
|
|
29
|
+
private _connectTimer;
|
|
30
|
+
private _retryAndHandleError?;
|
|
31
|
+
private _initialRetryDelayMillis;
|
|
32
|
+
private _retryCount;
|
|
33
|
+
private _logger?;
|
|
34
34
|
constructor(url: string, options?: EventSourceOptions);
|
|
35
|
-
private
|
|
36
|
-
private
|
|
37
|
-
private
|
|
38
|
-
private
|
|
35
|
+
private _getNextRetryDelay;
|
|
36
|
+
private _tryConnect;
|
|
37
|
+
private _open;
|
|
38
|
+
private _handleEvent;
|
|
39
39
|
addEventListener<T extends EventType<E>>(type: T, listener: EventSourceListener<E, T>): void;
|
|
40
40
|
removeEventListener<T extends EventType<E>>(type: T, listener: EventSourceListener<E, T>): void;
|
|
41
41
|
removeAllEventListeners<T extends EventType<E>>(type?: T): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSource.d.ts","sourceRoot":"","sources":["../../../../src/fromExternal/react-native-sse/EventSource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAkBpG,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,UAGvD;AAED,wBAAgB,MAAM,CAAC,mBAAmB,EAAE,MAAM,UAEjD;AAED,MAAM,CAAC,OAAO,OAAO,WAAW,CAAC,CAAC,SAAS,MAAM,GAAG,KAAK;IACvD,KAAK,SAAM;IACX,UAAU,SAAK;IACf,IAAI,SAAK;IACT,MAAM,SAAK;IAEX,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"EventSource.d.ts","sourceRoot":"","sources":["../../../../src/fromExternal/react-native-sse/EventSource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,SAAS,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AQ,EAAE,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,IAAI;IAQ/F,uBAAuB,CAAC,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,EAAE,CAAC;IAgBxD,QAAQ,CAAC,CAAC,SAAS,SAAS,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAsBnE,KAAK;IAUL,SAAS;IAIT,MAAM;IACN,OAAO;IACP,OAAO,CAAC,IAAI,EAAE,GAAG;IACjB,UAAU,CAAC,EAAE,EAAE,GAAG;CACnB"}
|
|
@@ -24,151 +24,151 @@ export default class EventSource {
|
|
|
24
24
|
this.CONNECTING = 0;
|
|
25
25
|
this.OPEN = 1;
|
|
26
26
|
this.CLOSED = 2;
|
|
27
|
-
this.
|
|
28
|
-
this.
|
|
29
|
-
this.
|
|
27
|
+
this._lastIndexProcessed = 0;
|
|
28
|
+
this._status = this.CONNECTING;
|
|
29
|
+
this._eventHandlers = {
|
|
30
30
|
open: [],
|
|
31
31
|
message: [],
|
|
32
32
|
error: [],
|
|
33
33
|
close: [],
|
|
34
34
|
};
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
35
|
+
this._xhr = new XMLHttpRequest();
|
|
36
|
+
this._initialRetryDelayMillis = 1000;
|
|
37
|
+
this._retryCount = 0;
|
|
38
38
|
const opts = Object.assign(Object.assign({}, defaultOptions), options);
|
|
39
|
-
this.
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
this.
|
|
45
|
-
this.
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
48
|
-
this.
|
|
39
|
+
this._url = url;
|
|
40
|
+
this._method = opts.method;
|
|
41
|
+
this._timeout = opts.timeout;
|
|
42
|
+
this._withCredentials = opts.withCredentials;
|
|
43
|
+
this._headers = opts.headers;
|
|
44
|
+
this._body = opts.body;
|
|
45
|
+
this._retryAndHandleError = opts.retryAndHandleError;
|
|
46
|
+
this._initialRetryDelayMillis = opts.initialRetryDelayMillis;
|
|
47
|
+
this._logger = opts.logger;
|
|
48
|
+
this._tryConnect(true);
|
|
49
49
|
}
|
|
50
|
-
|
|
51
|
-
const delay = jitter(backoff(this.
|
|
52
|
-
this.
|
|
50
|
+
_getNextRetryDelay() {
|
|
51
|
+
const delay = jitter(backoff(this._initialRetryDelayMillis, this._retryCount));
|
|
52
|
+
this._retryCount += 1;
|
|
53
53
|
return delay;
|
|
54
54
|
}
|
|
55
|
-
|
|
55
|
+
_tryConnect(initialConnection = false) {
|
|
56
56
|
var _a, _b;
|
|
57
|
-
let delay = initialConnection ? 0 : this.
|
|
57
|
+
let delay = initialConnection ? 0 : this._getNextRetryDelay();
|
|
58
58
|
if (initialConnection) {
|
|
59
|
-
(_a = this.
|
|
59
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug(`[EventSource] opening new connection.`);
|
|
60
60
|
}
|
|
61
61
|
else {
|
|
62
|
-
(_b = this.
|
|
62
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(`[EventSource] Will open new connection in ${delay} ms.`);
|
|
63
63
|
this.dispatch('retry', { type: 'retry', delayMillis: delay });
|
|
64
64
|
}
|
|
65
|
-
this.
|
|
65
|
+
this._connectTimer = setTimeout(() => {
|
|
66
66
|
if (!initialConnection) {
|
|
67
67
|
this.close();
|
|
68
68
|
}
|
|
69
|
-
this.
|
|
69
|
+
this._open();
|
|
70
70
|
}, delay);
|
|
71
71
|
}
|
|
72
|
-
|
|
72
|
+
_open() {
|
|
73
73
|
try {
|
|
74
|
-
this.
|
|
75
|
-
this.
|
|
76
|
-
this.
|
|
77
|
-
if (this.
|
|
78
|
-
this.
|
|
74
|
+
this._lastIndexProcessed = 0;
|
|
75
|
+
this._status = this.CONNECTING;
|
|
76
|
+
this._xhr.open(this._method, this._url, true);
|
|
77
|
+
if (this._withCredentials) {
|
|
78
|
+
this._xhr.withCredentials = true;
|
|
79
79
|
}
|
|
80
|
-
this.
|
|
81
|
-
this.
|
|
82
|
-
this.
|
|
83
|
-
if (this.
|
|
84
|
-
Object.entries(this.
|
|
85
|
-
this.
|
|
80
|
+
this._xhr.setRequestHeader('Accept', 'text/event-stream');
|
|
81
|
+
this._xhr.setRequestHeader('Cache-Control', 'no-cache');
|
|
82
|
+
this._xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
|
|
83
|
+
if (this._headers) {
|
|
84
|
+
Object.entries(this._headers).forEach(([key, value]) => {
|
|
85
|
+
this._xhr.setRequestHeader(key, value);
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
if (typeof this.
|
|
89
|
-
this.
|
|
88
|
+
if (typeof this._lastEventId !== 'undefined') {
|
|
89
|
+
this._xhr.setRequestHeader('Last-Event-ID', this._lastEventId);
|
|
90
90
|
}
|
|
91
|
-
this.
|
|
92
|
-
this.
|
|
91
|
+
this._xhr.timeout = this._timeout;
|
|
92
|
+
this._xhr.onreadystatechange = () => {
|
|
93
93
|
var _a, _b, _c, _d;
|
|
94
|
-
if (this.
|
|
94
|
+
if (this._status === this.CLOSED) {
|
|
95
95
|
return;
|
|
96
96
|
}
|
|
97
|
-
(_a = this.
|
|
98
|
-
if (this.
|
|
99
|
-
this.
|
|
97
|
+
(_a = this._logger) === null || _a === void 0 ? void 0 : _a.debug(`[EventSource][onreadystatechange] ReadyState: ${XMLReadyStateMap[this._xhr.readyState] || 'Unknown'}(${this._xhr.readyState}), status: ${this._xhr.status}`);
|
|
98
|
+
if (this._xhr.readyState !== XMLHttpRequest.DONE &&
|
|
99
|
+
this._xhr.readyState !== XMLHttpRequest.LOADING) {
|
|
100
100
|
return;
|
|
101
101
|
}
|
|
102
|
-
if (this.
|
|
103
|
-
if (this.
|
|
104
|
-
this.
|
|
105
|
-
this.
|
|
102
|
+
if (this._xhr.status >= 200 && this._xhr.status < 400) {
|
|
103
|
+
if (this._status === this.CONNECTING) {
|
|
104
|
+
this._retryCount = 0;
|
|
105
|
+
this._status = this.OPEN;
|
|
106
106
|
this.dispatch('open', { type: 'open' });
|
|
107
|
-
(_b = this.
|
|
107
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug('[EventSource][onreadystatechange][OPEN] Connection opened.');
|
|
108
108
|
}
|
|
109
109
|
// retry from server gets set here
|
|
110
|
-
this.
|
|
111
|
-
if (this.
|
|
112
|
-
(_c = this.
|
|
113
|
-
this.
|
|
110
|
+
this._handleEvent(this._xhr.responseText || '');
|
|
111
|
+
if (this._xhr.readyState === XMLHttpRequest.DONE) {
|
|
112
|
+
(_c = this._logger) === null || _c === void 0 ? void 0 : _c.debug('[EventSource][onreadystatechange][DONE] Operation done.');
|
|
113
|
+
this._tryConnect();
|
|
114
114
|
}
|
|
115
115
|
}
|
|
116
116
|
else {
|
|
117
|
-
this.
|
|
117
|
+
this._status = this.ERROR;
|
|
118
118
|
this.dispatch('error', {
|
|
119
119
|
type: 'error',
|
|
120
|
-
message: this.
|
|
121
|
-
xhrStatus: this.
|
|
122
|
-
xhrState: this.
|
|
120
|
+
message: this._xhr.responseText,
|
|
121
|
+
xhrStatus: this._xhr.status,
|
|
122
|
+
xhrState: this._xhr.readyState,
|
|
123
123
|
});
|
|
124
|
-
if (this.
|
|
125
|
-
(_d = this.
|
|
126
|
-
if (!this.
|
|
124
|
+
if (this._xhr.readyState === XMLHttpRequest.DONE) {
|
|
125
|
+
(_d = this._logger) === null || _d === void 0 ? void 0 : _d.debug('[EventSource][onreadystatechange][ERROR] Response status error.');
|
|
126
|
+
if (!this._retryAndHandleError) {
|
|
127
127
|
// by default just try and reconnect if there's an error.
|
|
128
|
-
this.
|
|
128
|
+
this._tryConnect();
|
|
129
129
|
}
|
|
130
130
|
else {
|
|
131
131
|
// custom retry logic taking into account status codes.
|
|
132
|
-
const shouldRetry = this.
|
|
133
|
-
status: this.
|
|
134
|
-
message: this.
|
|
132
|
+
const shouldRetry = this._retryAndHandleError({
|
|
133
|
+
status: this._xhr.status,
|
|
134
|
+
message: this._xhr.responseText,
|
|
135
135
|
});
|
|
136
136
|
if (shouldRetry) {
|
|
137
|
-
this.
|
|
137
|
+
this._tryConnect();
|
|
138
138
|
}
|
|
139
139
|
}
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
};
|
|
143
|
-
this.
|
|
144
|
-
if (this.
|
|
143
|
+
this._xhr.onerror = () => {
|
|
144
|
+
if (this._status === this.CLOSED) {
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
this.
|
|
147
|
+
this._status = this.ERROR;
|
|
148
148
|
this.dispatch('error', {
|
|
149
149
|
type: 'error',
|
|
150
|
-
message: this.
|
|
151
|
-
xhrStatus: this.
|
|
152
|
-
xhrState: this.
|
|
150
|
+
message: this._xhr.responseText,
|
|
151
|
+
xhrStatus: this._xhr.status,
|
|
152
|
+
xhrState: this._xhr.readyState,
|
|
153
153
|
});
|
|
154
154
|
};
|
|
155
|
-
if (this.
|
|
156
|
-
this.
|
|
155
|
+
if (this._body) {
|
|
156
|
+
this._xhr.send(this._body);
|
|
157
157
|
}
|
|
158
158
|
else {
|
|
159
|
-
this.
|
|
159
|
+
this._xhr.send();
|
|
160
160
|
}
|
|
161
|
-
if (this.
|
|
161
|
+
if (this._timeout > 0) {
|
|
162
162
|
setTimeout(() => {
|
|
163
|
-
if (this.
|
|
163
|
+
if (this._xhr.readyState === XMLHttpRequest.LOADING) {
|
|
164
164
|
this.dispatch('error', { type: 'timeout' });
|
|
165
165
|
this.close();
|
|
166
166
|
}
|
|
167
|
-
}, this.
|
|
167
|
+
}, this._timeout);
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
170
|
catch (e) {
|
|
171
|
-
this.
|
|
171
|
+
this._status = this.ERROR;
|
|
172
172
|
this.dispatch('error', {
|
|
173
173
|
type: 'exception',
|
|
174
174
|
message: e.message,
|
|
@@ -176,11 +176,11 @@ export default class EventSource {
|
|
|
176
176
|
});
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
|
-
|
|
180
|
-
const parts = response.slice(this.
|
|
179
|
+
_handleEvent(response) {
|
|
180
|
+
const parts = response.slice(this._lastIndexProcessed).split('\n');
|
|
181
181
|
const indexOfDoubleNewline = response.lastIndexOf('\n\n');
|
|
182
182
|
if (indexOfDoubleNewline !== -1) {
|
|
183
|
-
this.
|
|
183
|
+
this._lastIndexProcessed = indexOfDoubleNewline + 2;
|
|
184
184
|
}
|
|
185
185
|
let data = [];
|
|
186
186
|
let retry = 0;
|
|
@@ -189,7 +189,7 @@ export default class EventSource {
|
|
|
189
189
|
for (let i = 0; i < parts.length; i++) {
|
|
190
190
|
line = parts[i].replace(/^(\s|\u00A0)+|(\s|\u00A0)+$/g, '');
|
|
191
191
|
if (line.indexOf('event') === 0) {
|
|
192
|
-
this.
|
|
192
|
+
this._eventType = line.replace(/event:?\s*/, '');
|
|
193
193
|
}
|
|
194
194
|
else if (line.indexOf('retry') === 0) {
|
|
195
195
|
retry = parseInt(line.replace(/retry:?\s*/, ''), 10);
|
|
@@ -202,55 +202,55 @@ export default class EventSource {
|
|
|
202
202
|
data.push(line.replace(/data:?\s*/, ''));
|
|
203
203
|
}
|
|
204
204
|
else if (line.indexOf('id:') === 0) {
|
|
205
|
-
this.
|
|
205
|
+
this._lastEventId = line.replace(/id:?\s*/, '');
|
|
206
206
|
}
|
|
207
207
|
else if (line.indexOf('id') === 0) {
|
|
208
|
-
this.
|
|
208
|
+
this._lastEventId = undefined;
|
|
209
209
|
}
|
|
210
210
|
else if (line === '') {
|
|
211
211
|
if (data.length > 0) {
|
|
212
|
-
const eventType = this.
|
|
212
|
+
const eventType = this._eventType || 'message';
|
|
213
213
|
const event = {
|
|
214
214
|
type: eventType,
|
|
215
215
|
data: data.join('\n'),
|
|
216
|
-
url: this.
|
|
217
|
-
lastEventId: this.
|
|
216
|
+
url: this._url,
|
|
217
|
+
lastEventId: this._lastEventId,
|
|
218
218
|
};
|
|
219
219
|
this.dispatch(eventType, event);
|
|
220
220
|
data = [];
|
|
221
|
-
this.
|
|
221
|
+
this._eventType = undefined;
|
|
222
222
|
}
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
225
|
}
|
|
226
226
|
addEventListener(type, listener) {
|
|
227
|
-
if (this.
|
|
228
|
-
this.
|
|
227
|
+
if (this._eventHandlers[type] === undefined) {
|
|
228
|
+
this._eventHandlers[type] = [];
|
|
229
229
|
}
|
|
230
|
-
this.
|
|
230
|
+
this._eventHandlers[type].push(listener);
|
|
231
231
|
}
|
|
232
232
|
removeEventListener(type, listener) {
|
|
233
|
-
if (this.
|
|
234
|
-
this.
|
|
233
|
+
if (this._eventHandlers[type] !== undefined) {
|
|
234
|
+
this._eventHandlers[type] = this._eventHandlers[type].filter((handler) => handler !== listener);
|
|
235
235
|
}
|
|
236
236
|
}
|
|
237
237
|
removeAllEventListeners(type) {
|
|
238
|
-
const availableTypes = Object.keys(this.
|
|
238
|
+
const availableTypes = Object.keys(this._eventHandlers);
|
|
239
239
|
if (type === undefined) {
|
|
240
240
|
availableTypes.forEach((eventType) => {
|
|
241
|
-
this.
|
|
241
|
+
this._eventHandlers[eventType] = [];
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
244
|
else {
|
|
245
245
|
if (!availableTypes.includes(type)) {
|
|
246
246
|
throw Error(`[EventSource] '${type}' type is not supported event type.`);
|
|
247
247
|
}
|
|
248
|
-
this.
|
|
248
|
+
this._eventHandlers[type] = [];
|
|
249
249
|
}
|
|
250
250
|
}
|
|
251
251
|
dispatch(type, data) {
|
|
252
252
|
var _a, _b;
|
|
253
|
-
(_a = this.
|
|
253
|
+
(_a = this._eventHandlers[type]) === null || _a === void 0 ? void 0 : _a.forEach((handler) => handler(data));
|
|
254
254
|
switch (type) {
|
|
255
255
|
case 'open':
|
|
256
256
|
this.onopen();
|
|
@@ -259,7 +259,7 @@ export default class EventSource {
|
|
|
259
259
|
this.onclose();
|
|
260
260
|
break;
|
|
261
261
|
case 'error':
|
|
262
|
-
(_b = this.
|
|
262
|
+
(_b = this._logger) === null || _b === void 0 ? void 0 : _b.debug(`[EventSource][dispatch][ERROR]: ${JSON.stringify(data)}`);
|
|
263
263
|
this.onerror(data);
|
|
264
264
|
break;
|
|
265
265
|
case 'retry':
|
|
@@ -270,15 +270,15 @@ export default class EventSource {
|
|
|
270
270
|
}
|
|
271
271
|
}
|
|
272
272
|
close() {
|
|
273
|
-
this.
|
|
274
|
-
clearTimeout(this.
|
|
275
|
-
if (this.
|
|
276
|
-
this.
|
|
273
|
+
this._status = this.CLOSED;
|
|
274
|
+
clearTimeout(this._connectTimer);
|
|
275
|
+
if (this._xhr) {
|
|
276
|
+
this._xhr.abort();
|
|
277
277
|
}
|
|
278
278
|
this.dispatch('close', { type: 'close' });
|
|
279
279
|
}
|
|
280
280
|
getStatus() {
|
|
281
|
-
return this.
|
|
281
|
+
return this._status;
|
|
282
282
|
}
|
|
283
283
|
onopen() { }
|
|
284
284
|
onclose() { }
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EventSource.js","sourceRoot":"","sources":["../../../../src/fromExternal/react-native-sse/EventSource.ts"],"names":[],"mappings":"AAUA,MAAM,gBAAgB,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,kBAAkB,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;AAErF,MAAM,cAAc,GAAuB;IACzC,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,EAAE;IACX,MAAM,EAAE,KAAK;IACb,OAAO,EAAE,CAAC;IACV,eAAe,EAAE,KAAK;IACtB,mBAAmB,EAAE,SAAS;IAC9B,uBAAuB,EAAE,IAAI;IAC7B,MAAM,EAAE,SAAS;CAClB,CAAC;AAEF,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,kCAAkC;AACnE,MAAM,WAAW,GAAG,GAAG,CAAC,CAAC,+CAA+C;AAExE,MAAM,UAAU,OAAO,CAAC,IAAY,EAAE,UAAkB;IACtD,MAAM,KA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AC;gBACd,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,CAAC,OAAO,EAAE,CAAC;gBACf,MAAM;YACR,KAAK,OAAO;gBACV,MAAA,IAAI,CAAC,OAAO,0CAAE,KAAK,CAAC,mCAAmC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC/E,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;gBACnB,MAAM;YACR,KAAK,OAAO;gBACV,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;gBACtB,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;IAED,KAAK;QACH,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC;QAC3B,YAAY,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QACjC,IAAI,IAAI,CAAC,IAAI,EAAE;YACb,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;SACnB;QAED,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC;IAC5C,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,MAAM,KAAI,CAAC;IACX,OAAO,KAAI,CAAC;IACZ,OAAO,CAAC,IAAS,IAAG,CAAC;IACrB,UAAU,CAAC,EAAO,IAAG,CAAC;CACvB"}
|
|
@@ -26,53 +26,53 @@ export var NetworkState;
|
|
|
26
26
|
* @internal
|
|
27
27
|
*/
|
|
28
28
|
export class ConnectionManager {
|
|
29
|
-
constructor(
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
this.
|
|
33
|
-
this.
|
|
34
|
-
this.
|
|
35
|
-
this.
|
|
36
|
-
this.
|
|
37
|
-
this.
|
|
38
|
-
if (
|
|
39
|
-
|
|
40
|
-
this.
|
|
41
|
-
this.
|
|
29
|
+
constructor(_logger, _config, _destination, _detector) {
|
|
30
|
+
this._logger = _logger;
|
|
31
|
+
this._config = _config;
|
|
32
|
+
this._destination = _destination;
|
|
33
|
+
this._detector = _detector;
|
|
34
|
+
this._applicationState = ApplicationState.Foreground;
|
|
35
|
+
this._networkState = NetworkState.Available;
|
|
36
|
+
this._offline = false;
|
|
37
|
+
this._currentConnectionMode = _config.initialConnectionMode;
|
|
38
|
+
if (_config.automaticBackgroundHandling) {
|
|
39
|
+
_detector.setApplicationStateListener((state) => {
|
|
40
|
+
this._applicationState = state;
|
|
41
|
+
this._handleState();
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
-
if (
|
|
45
|
-
|
|
46
|
-
this.
|
|
47
|
-
this.
|
|
44
|
+
if (_config.automaticNetworkHandling) {
|
|
45
|
+
_detector.setNetworkStateListener((state) => {
|
|
46
|
+
this._networkState = state;
|
|
47
|
+
this._handleState();
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
51
|
setOffline(offline) {
|
|
52
|
-
this.
|
|
53
|
-
this.
|
|
52
|
+
this._offline = offline;
|
|
53
|
+
this._handleState();
|
|
54
54
|
}
|
|
55
55
|
setConnectionMode(mode) {
|
|
56
|
-
this.
|
|
57
|
-
this.
|
|
56
|
+
this._currentConnectionMode = mode;
|
|
57
|
+
this._handleState();
|
|
58
58
|
}
|
|
59
59
|
close() {
|
|
60
|
-
this.
|
|
60
|
+
this._detector.stopListening();
|
|
61
61
|
}
|
|
62
|
-
|
|
63
|
-
this.
|
|
64
|
-
switch (this.
|
|
62
|
+
_handleState() {
|
|
63
|
+
this._logger.debug(`Handling state: ${this._applicationState}:${this._networkState}`);
|
|
64
|
+
switch (this._networkState) {
|
|
65
65
|
case NetworkState.Unavailable:
|
|
66
|
-
this.
|
|
66
|
+
this._destination.setNetworkAvailability(false);
|
|
67
67
|
break;
|
|
68
68
|
case NetworkState.Available:
|
|
69
|
-
this.
|
|
70
|
-
switch (this.
|
|
69
|
+
this._destination.setNetworkAvailability(true);
|
|
70
|
+
switch (this._applicationState) {
|
|
71
71
|
case ApplicationState.Foreground:
|
|
72
|
-
this.
|
|
72
|
+
this._setForegroundAvailable();
|
|
73
73
|
break;
|
|
74
74
|
case ApplicationState.Background:
|
|
75
|
-
this.
|
|
75
|
+
this._setBackgroundAvailable();
|
|
76
76
|
break;
|
|
77
77
|
default:
|
|
78
78
|
break;
|
|
@@ -82,29 +82,29 @@ export class ConnectionManager {
|
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
if (this.
|
|
87
|
-
this.
|
|
85
|
+
_setForegroundAvailable() {
|
|
86
|
+
if (this._offline) {
|
|
87
|
+
this._destination.setConnectionMode('offline');
|
|
88
88
|
// Don't attempt to flush. If the user wants to flush when entering offline
|
|
89
89
|
// mode, then they can do that directly.
|
|
90
|
-
this.
|
|
90
|
+
this._destination.setEventSendingEnabled(false, false);
|
|
91
91
|
return;
|
|
92
92
|
}
|
|
93
93
|
// Currently the foreground mode will always be whatever the last active
|
|
94
94
|
// connection mode was.
|
|
95
|
-
this.
|
|
96
|
-
this.
|
|
95
|
+
this._destination.setConnectionMode(this._currentConnectionMode);
|
|
96
|
+
this._destination.setEventSendingEnabled(true, false);
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
if (!this.
|
|
100
|
-
this.
|
|
101
|
-
this.
|
|
98
|
+
_setBackgroundAvailable() {
|
|
99
|
+
if (!this._config.runInBackground) {
|
|
100
|
+
this._destination.setConnectionMode('offline');
|
|
101
|
+
this._destination.setEventSendingEnabled(false, true);
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
// This SDK doesn't currently support automatic background polling.
|
|
105
105
|
// If connections in the background are allowed, then use the same mode
|
|
106
106
|
// as is configured for the foreground.
|
|
107
|
-
this.
|
|
107
|
+
this._setForegroundAvailable();
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
//# sourceMappingURL=ConnectionManager.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../src/platform/ConnectionManager.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,yCAAyC;IACzC,6CAAyB,CAAA;IAEzB,yCAAyC;IACzC,GAAG;IACH,yEAAyE;IACzE,oEAAoE;IACpE,6CAAyB,CAAA;AAC3B,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,qDAAqD;IACrD,2CAA2B,CAAA;IAE3B,uEAAuE;IACvE,sBAAsB;IACtB,uCAAuB,CAAA;AACzB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAgDD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAM5B,YACmB,
|
|
1
|
+
{"version":3,"file":"ConnectionManager.js","sourceRoot":"","sources":["../../../src/platform/ConnectionManager.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,CAAN,IAAY,gBASX;AATD,WAAY,gBAAgB;IAC1B,yCAAyC;IACzC,6CAAyB,CAAA;IAEzB,yCAAyC;IACzC,GAAG;IACH,yEAAyE;IACzE,oEAAoE;IACpE,6CAAyB,CAAA;AAC3B,CAAC,EATW,gBAAgB,KAAhB,gBAAgB,QAS3B;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,YAOX;AAPD,WAAY,YAAY;IACtB,qDAAqD;IACrD,2CAA2B,CAAA;IAE3B,uEAAuE;IACvE,sBAAsB;IACtB,uCAAuB,CAAA;AACzB,CAAC,EAPW,YAAY,KAAZ,YAAY,QAOvB;AAgDD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAM5B,YACmB,OAAiB,EACjB,OAAgC,EAChC,YAAmC,EACnC,SAAwB;QAHxB,YAAO,GAAP,OAAO,CAAU;QACjB,YAAO,GAAP,OAAO,CAAyB;QAChC,iBAAY,GAAZ,YAAY,CAAuB;QACnC,cAAS,GAAT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AAS;gBACzB,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC;gBAC/C,QAAQ,IAAI,CAAC,iBAAiB,EAAE;oBAC9B,KAAK,gBAAgB,CAAC,UAAU;wBAC9B,IAAI,CAAC,uBAAuB,EAAE,CAAC;wBAC/B,MAAM;oBACR,KAAK,gBAAgB,CAAC,UAAU;wBAC9B,IAAI,CAAC,uBAAuB,EAAE,CAAC;wBAC/B,MAAM;oBACR;wBACE,MAAM;iBACT;gBACD,MAAM;YACR;gBACE,MAAM;SACT;IACH,CAAC;IAEO,uBAAuB;QAC7B,IAAI,IAAI,CAAC,QAAQ,EAAE;YACjB,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC/C,2EAA2E;YAC3E,wCAAwC;YACxC,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YACvD,OAAO;SACR;QAED,wEAAwE;QACxE,uBAAuB;QACvB,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC;QACjE,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC;IAEO,uBAAuB;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,eAAe,EAAE;YACjC,IAAI,CAAC,YAAY,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC;YAC/C,IAAI,CAAC,YAAY,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;YACtD,OAAO;SACR;QAED,mEAAmE;QAEnE,uEAAuE;QACvE,uCAAuC;QACvC,IAAI,CAAC,uBAAuB,EAAE,CAAC;IACjC,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Info, LDLogger, PlatformData, SdkData } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformInfo implements Info {
|
|
3
|
-
private readonly
|
|
4
|
-
constructor(
|
|
3
|
+
private readonly _logger;
|
|
4
|
+
constructor(_logger: LDLogger);
|
|
5
5
|
platformData(): PlatformData;
|
|
6
6
|
sdkData(): SdkData;
|
|
7
7
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAKhG,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IACnC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformInfo.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAKhG,MAAM,CAAC,OAAO,OAAO,YAAa,YAAW,IAAI;IACnC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IAE9C,YAAY,IAAI,YAAY;IAW5B,OAAO,IAAI,OAAO;CAUnB"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { name, version } from '../../package.json';
|
|
2
2
|
import { ldApplication, ldDevice } from './autoEnv';
|
|
3
3
|
export default class PlatformInfo {
|
|
4
|
-
constructor(
|
|
5
|
-
this.
|
|
4
|
+
constructor(_logger) {
|
|
5
|
+
this._logger = _logger;
|
|
6
6
|
}
|
|
7
7
|
platformData() {
|
|
8
8
|
const data = {
|
|
@@ -10,7 +10,7 @@ export default class PlatformInfo {
|
|
|
10
10
|
ld_application: ldApplication,
|
|
11
11
|
ld_device: ldDevice,
|
|
12
12
|
};
|
|
13
|
-
this.
|
|
13
|
+
this._logger.debug(`platformData: ${JSON.stringify(data, null, 2)}`);
|
|
14
14
|
return data;
|
|
15
15
|
}
|
|
16
16
|
sdkData() {
|
|
@@ -19,7 +19,7 @@ export default class PlatformInfo {
|
|
|
19
19
|
version,
|
|
20
20
|
userAgentBase: 'ReactNativeClient',
|
|
21
21
|
};
|
|
22
|
-
this.
|
|
22
|
+
this._logger.debug(`sdkData: ${JSON.stringify(data, null, 2)}`);
|
|
23
23
|
return data;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformInfo.js","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,YAA6B,
|
|
1
|
+
{"version":3,"file":"PlatformInfo.js","sourceRoot":"","sources":["../../../src/platform/PlatformInfo.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEpD,MAAM,CAAC,OAAO,OAAO,YAAY;IAC/B,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAElD,YAAY;QACV,MAAM,IAAI,GAAG;YACX,IAAI,EAAE,cAAc;YACpB,cAAc,EAAE,aAAa;YAC7B,SAAS,EAAE,QAAQ;SACpB,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,iBAAiB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,MAAM,IAAI,GAAG;YACX,IAAI;YACJ,OAAO;YACP,aAAa,EAAE,mBAAmB;SACnC,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;QAChE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { EventSource, EventSourceCapabilities, EventSourceInitDict, LDLogger, Options, Requests, Response } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformRequests implements Requests {
|
|
3
|
-
private readonly
|
|
4
|
-
constructor(
|
|
3
|
+
private readonly _logger;
|
|
4
|
+
constructor(_logger: LDLogger);
|
|
5
5
|
createEventSource(url: string, eventSourceInitDict: EventSourceInitDict): EventSource;
|
|
6
6
|
getEventSourceCapabilities(): EventSourceCapabilities;
|
|
7
7
|
fetch(url: string, options?: Options): Promise<Response>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformRequests.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,WAAW,EACX,uBAAuB,EACvB,mBAAmB,EACnB,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,EACT,MAAM,oCAAoC,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,gBAAiB,YAAW,QAAQ;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IAE9C,iBAAiB,CAAC,GAAG,EAAE,MAAM,EAAE,mBAAmB,EAAE,mBAAmB,GAAG,WAAW;IAUrF,0BAA0B,IAAI,uBAAuB;IAQrD,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;CAIzD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import RNEventSource from '../fromExternal/react-native-sse';
|
|
2
2
|
export default class PlatformRequests {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
3
|
+
constructor(_logger) {
|
|
4
|
+
this._logger = _logger;
|
|
5
5
|
}
|
|
6
6
|
createEventSource(url, eventSourceInitDict) {
|
|
7
7
|
var _a;
|
|
@@ -10,7 +10,7 @@ export default class PlatformRequests {
|
|
|
10
10
|
headers: eventSourceInitDict.headers,
|
|
11
11
|
body: eventSourceInitDict.body,
|
|
12
12
|
retryAndHandleError: eventSourceInitDict.errorFilter,
|
|
13
|
-
logger: this.
|
|
13
|
+
logger: this._logger,
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
getEventSourceCapabilities() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformRequests.js","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAWA,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,YAA6B,
|
|
1
|
+
{"version":3,"file":"PlatformRequests.js","sourceRoot":"","sources":["../../../src/platform/PlatformRequests.ts"],"names":[],"mappings":"AAWA,OAAO,aAAa,MAAM,kCAAkC,CAAC;AAE7D,MAAM,CAAC,OAAO,OAAO,gBAAgB;IACnC,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAElD,iBAAiB,CAAC,GAAW,EAAE,mBAAwC;;QACrE,OAAO,IAAI,aAAa,CAAY,GAAG,EAAE;YACvC,MAAM,EAAE,MAAA,mBAAmB,CAAC,MAAM,mCAAI,KAAK;YAC3C,OAAO,EAAE,mBAAmB,CAAC,OAAO;YACpC,IAAI,EAAE,mBAAmB,CAAC,IAAI;YAC9B,mBAAmB,EAAE,mBAAmB,CAAC,WAAW;YACpD,MAAM,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC,CAAC;IACL,CAAC;IAED,0BAA0B;QACxB,OAAO;YACL,WAAW,EAAE,KAAK;YAClB,OAAO,EAAE,IAAI;YACb,YAAY,EAAE,IAAI;SACnB,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,GAAW,EAAE,OAAiB;QAClC,aAAa;QACb,OAAO,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LDLogger, Storage } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
export default class PlatformStorage implements Storage {
|
|
3
|
-
private readonly
|
|
4
|
-
constructor(
|
|
3
|
+
private readonly _logger;
|
|
4
|
+
constructor(_logger: LDLogger);
|
|
5
5
|
clear(key: string): Promise<void>;
|
|
6
6
|
get(key: string): Promise<string | null>;
|
|
7
7
|
set(key: string, value: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformStorage.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAI5E,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,OAAO;IACzC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformStorage.d.ts","sourceRoot":"","sources":["../../../src/platform/PlatformStorage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAI5E,MAAM,CAAC,OAAO,OAAO,eAAgB,YAAW,OAAO;IACzC,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,QAAQ;IACxC,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAUxC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAOrD"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import AsyncStorage from './ConditionalAsyncStorage';
|
|
2
2
|
export default class PlatformStorage {
|
|
3
|
-
constructor(
|
|
4
|
-
this.
|
|
3
|
+
constructor(_logger) {
|
|
4
|
+
this._logger = _logger;
|
|
5
5
|
}
|
|
6
6
|
async clear(key) {
|
|
7
7
|
await AsyncStorage.removeItem(key);
|
|
@@ -12,7 +12,7 @@ export default class PlatformStorage {
|
|
|
12
12
|
return value !== null && value !== void 0 ? value : null;
|
|
13
13
|
}
|
|
14
14
|
catch (error) {
|
|
15
|
-
this.
|
|
15
|
+
this._logger.debug(`Error getting AsyncStorage key: ${key}, error: ${error}`);
|
|
16
16
|
return null;
|
|
17
17
|
}
|
|
18
18
|
}
|
|
@@ -21,7 +21,7 @@ export default class PlatformStorage {
|
|
|
21
21
|
await AsyncStorage.setItem(key, value);
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
|
-
this.
|
|
24
|
+
this._logger.debug(`Error saving AsyncStorage key: ${key}, value: ${value}, error: ${error}`);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformStorage.js","sourceRoot":"","sources":["../../../src/platform/PlatformStorage.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,YAA6B,
|
|
1
|
+
{"version":3,"file":"PlatformStorage.js","sourceRoot":"","sources":["../../../src/platform/PlatformStorage.ts"],"names":[],"mappings":"AAEA,OAAO,YAAY,MAAM,2BAA2B,CAAC;AAErD,MAAM,CAAC,OAAO,OAAO,eAAe;IAClC,YAA6B,OAAiB;QAAjB,YAAO,GAAP,OAAO,CAAU;IAAG,CAAC;IAClD,KAAK,CAAC,KAAK,CAAC,GAAW;QACrB,MAAM,YAAY,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC;IACrC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,IAAI;YACF,MAAM,KAAK,GAAG,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC9C,OAAO,KAAK,aAAL,KAAK,cAAL,KAAK,GAAI,IAAI,CAAC;SACtB;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,mCAAmC,GAAG,YAAY,KAAK,EAAE,CAAC,CAAC;YAC9E,OAAO,IAAI,CAAC;SACb;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,KAAa;QAClC,IAAI;YACF,MAAM,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;SACxC;QAAC,OAAO,KAAK,EAAE;YACd,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,kCAAkC,GAAG,YAAY,KAAK,YAAY,KAAK,EAAE,CAAC,CAAC;SAC/F;IACH,CAAC;CACF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Hasher as LDHasher } from '@launchdarkly/js-client-sdk-common';
|
|
2
2
|
import { SupportedHashAlgorithm, SupportedOutputEncoding } from './types';
|
|
3
3
|
export default class PlatformHasher implements LDHasher {
|
|
4
|
-
private
|
|
4
|
+
private _hasher;
|
|
5
5
|
constructor(algorithm: SupportedHashAlgorithm, hmacKey?: string);
|
|
6
6
|
digest(encoding: SupportedOutputEncoding): string;
|
|
7
7
|
update(data: string): this;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformHasher.d.ts","sourceRoot":"","sources":["../../../../src/platform/crypto/PlatformHasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAIxE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ;IACrD,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformHasher.d.ts","sourceRoot":"","sources":["../../../../src/platform/crypto/PlatformHasher.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,QAAQ,EAAE,MAAM,oCAAoC,CAAC;AAIxE,OAAO,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,SAAS,CAAC;AAE1E,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ;IACrD,OAAO,CAAC,OAAO,CAAS;gBAEZ,SAAS,EAAE,sBAAsB,EAAE,OAAO,CAAC,EAAE,MAAM;IAU/D,MAAM,CAAC,QAAQ,EAAE,uBAAuB,GAAG,MAAM;IAajD,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;CAI3B"}
|
|
@@ -4,7 +4,7 @@ export default class PlatformHasher {
|
|
|
4
4
|
constructor(algorithm, hmacKey) {
|
|
5
5
|
switch (algorithm) {
|
|
6
6
|
case 'sha256':
|
|
7
|
-
this.
|
|
7
|
+
this._hasher = hmacKey ? sha256.hmac.create(hmacKey) : sha256.create();
|
|
8
8
|
break;
|
|
9
9
|
default:
|
|
10
10
|
throw new Error(`Unsupported hash algorithm: ${algorithm}. Only sha256 is supported.`);
|
|
@@ -13,15 +13,15 @@ export default class PlatformHasher {
|
|
|
13
13
|
digest(encoding) {
|
|
14
14
|
switch (encoding) {
|
|
15
15
|
case 'base64':
|
|
16
|
-
return base64FromByteArray(new Uint8Array(this.
|
|
16
|
+
return base64FromByteArray(new Uint8Array(this._hasher.arrayBuffer()));
|
|
17
17
|
case 'hex':
|
|
18
|
-
return this.
|
|
18
|
+
return this._hasher.hex();
|
|
19
19
|
default:
|
|
20
20
|
throw new Error(`unsupported output encoding: ${encoding}. Only base64 and hex are supported.`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
update(data) {
|
|
24
|
-
this.
|
|
24
|
+
this._hasher.update(data);
|
|
25
25
|
return this;
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PlatformHasher.js","sourceRoot":"","sources":["../../../../src/platform/crypto/PlatformHasher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,MAAM,CAAC,OAAO,OAAO,cAAc;IAGjC,YAAY,SAAiC,EAAE,OAAgB;QAC7D,QAAQ,SAAS,EAAE;YACjB,KAAK,QAAQ;gBACX,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"PlatformHasher.js","sourceRoot":"","sources":["../../../../src/platform/crypto/PlatformHasher.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAGtD,MAAM,CAAC,OAAO,OAAO,cAAc;IAGjC,YAAY,SAAiC,EAAE,OAAgB;QAC7D,QAAQ,SAAS,EAAE;YACjB,KAAK,QAAQ;gBACX,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;gBACvE,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,+BAA+B,SAAS,6BAA6B,CAAC,CAAC;SAC1F;IACH,CAAC;IAED,MAAM,CAAC,QAAiC;QACtC,QAAQ,QAAQ,EAAE;YAChB,KAAK,QAAQ;gBACX,OAAO,mBAAmB,CAAC,IAAI,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC;YACzE,KAAK,KAAK;gBACR,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;YAC5B;gBACE,MAAM,IAAI,KAAK,CACb,gCAAgC,QAAQ,sCAAsC,CAC/E,CAAC;SACL;IACH,CAAC;IAED,MAAM,CAAC,IAAY;QACjB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC1B,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@launchdarkly/react-native-client-sdk",
|
|
3
|
-
"version": "10.8.
|
|
3
|
+
"version": "10.8.1-beta.1",
|
|
4
4
|
"description": "React Native LaunchDarkly SDK",
|
|
5
5
|
"homepage": "https://github.com/launchdarkly/js-core/tree/main/packages/sdk/react-native",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"react-native": "*"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@launchdarkly/js-client-sdk-common": "1.9.
|
|
44
|
+
"@launchdarkly/js-client-sdk-common": "1.9.1-beta.1",
|
|
45
45
|
"@react-native-async-storage/async-storage": "^1.21.0",
|
|
46
46
|
"base64-js": "^1.5.1"
|
|
47
47
|
},
|