@launchdarkly/react-native-client-sdk 0.1.5 → 0.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.
Files changed (77) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/README.md +2 -2
  3. package/dist/babel.config.d.ts +2 -0
  4. package/dist/babel.config.d.ts.map +1 -0
  5. package/dist/babel.config.js +5 -0
  6. package/dist/babel.config.js.map +1 -0
  7. package/dist/package.json +8 -5
  8. package/dist/src/ReactNativeLDClient.d.ts +7 -3
  9. package/dist/src/ReactNativeLDClient.d.ts.map +1 -1
  10. package/dist/src/ReactNativeLDClient.js +10 -6
  11. package/dist/src/ReactNativeLDClient.js.map +1 -1
  12. package/dist/src/fromExternal/js-sha256/index.d.ts +17 -0
  13. package/dist/src/fromExternal/js-sha256/index.d.ts.map +1 -0
  14. package/dist/src/fromExternal/js-sha256/index.js +572 -0
  15. package/dist/src/fromExternal/js-sha256/index.js.map +1 -0
  16. package/dist/src/{react-native-sse → fromExternal/react-native-sse}/EventSource.d.ts +8 -5
  17. package/dist/src/fromExternal/react-native-sse/EventSource.d.ts.map +1 -0
  18. package/dist/src/{react-native-sse → fromExternal/react-native-sse}/EventSource.js +47 -32
  19. package/dist/src/fromExternal/react-native-sse/EventSource.js.map +1 -0
  20. package/dist/src/fromExternal/react-native-sse/index.d.ts.map +1 -0
  21. package/dist/src/fromExternal/react-native-sse/index.js.map +1 -0
  22. package/dist/src/{react-native-sse → fromExternal/react-native-sse}/types.d.ts +3 -3
  23. package/dist/src/fromExternal/react-native-sse/types.d.ts.map +1 -0
  24. package/dist/src/fromExternal/react-native-sse/types.js.map +1 -0
  25. package/dist/src/platform/autoEnv.d.ts +4 -0
  26. package/dist/src/platform/autoEnv.d.ts.map +1 -0
  27. package/dist/src/platform/autoEnv.js +36 -0
  28. package/dist/src/platform/autoEnv.js.map +1 -0
  29. package/dist/src/platform/crypto/PlatformHasher.d.ts +9 -0
  30. package/dist/src/platform/crypto/PlatformHasher.d.ts.map +1 -0
  31. package/dist/src/platform/crypto/PlatformHasher.js +28 -0
  32. package/dist/src/platform/crypto/PlatformHasher.js.map +1 -0
  33. package/dist/src/platform/crypto/index.d.ts +14 -0
  34. package/dist/src/platform/crypto/index.d.ts.map +1 -0
  35. package/dist/src/platform/crypto/index.js +34 -0
  36. package/dist/src/platform/crypto/index.js.map +1 -0
  37. package/dist/src/platform/crypto/types.d.ts +3 -0
  38. package/dist/src/platform/crypto/types.d.ts.map +1 -0
  39. package/dist/src/platform/crypto/types.js +2 -0
  40. package/dist/src/{react-native-sse → platform/crypto}/types.js.map +1 -1
  41. package/dist/src/platform/index.d.ts +9 -1
  42. package/dist/src/platform/index.d.ts.map +1 -1
  43. package/dist/src/platform/index.js +24 -19
  44. package/dist/src/platform/index.js.map +1 -1
  45. package/dist/src/platform/locale.d.ts +7 -0
  46. package/dist/src/platform/locale.d.ts.map +1 -0
  47. package/dist/src/platform/locale.js +10 -0
  48. package/dist/src/platform/locale.js.map +1 -0
  49. package/dist/src/polyfills/btoa.d.ts +2 -1
  50. package/dist/src/polyfills/btoa.d.ts.map +1 -1
  51. package/dist/src/polyfills/btoa.js +4 -1
  52. package/dist/src/polyfills/btoa.js.map +1 -1
  53. package/dist/src/polyfills/index.d.ts +3 -3
  54. package/dist/src/polyfills/index.d.ts.map +1 -1
  55. package/dist/src/polyfills/index.js +3 -3
  56. package/dist/src/polyfills/index.js.map +1 -1
  57. package/dist/src/provider/LDProvider.d.ts +2 -6
  58. package/dist/src/provider/LDProvider.d.ts.map +1 -1
  59. package/dist/src/provider/LDProvider.js +4 -9
  60. package/dist/src/provider/LDProvider.js.map +1 -1
  61. package/dist/src/provider/useAppState.d.ts +13 -0
  62. package/dist/src/provider/useAppState.d.ts.map +1 -0
  63. package/dist/src/provider/useAppState.js +50 -0
  64. package/dist/src/provider/useAppState.js.map +1 -0
  65. package/package.json +8 -5
  66. package/dist/jest.config.d.ts +0 -4
  67. package/dist/jest.config.d.ts.map +0 -1
  68. package/dist/jest.config.js +0 -15
  69. package/dist/jest.config.js.map +0 -1
  70. package/dist/src/react-native-sse/EventSource.d.ts.map +0 -1
  71. package/dist/src/react-native-sse/EventSource.js.map +0 -1
  72. package/dist/src/react-native-sse/index.d.ts.map +0 -1
  73. package/dist/src/react-native-sse/index.js.map +0 -1
  74. package/dist/src/react-native-sse/types.d.ts.map +0 -1
  75. /package/dist/src/{react-native-sse → fromExternal/react-native-sse}/index.d.ts +0 -0
  76. /package/dist/src/{react-native-sse → fromExternal/react-native-sse}/index.js +0 -0
  77. /package/dist/src/{react-native-sse → fromExternal/react-native-sse}/types.js +0 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/launchdarkly/js-core/compare/react-native-client-sdk-v0.1.5...react-native-client-sdk-v0.2.0) (2024-02-06)
4
+
5
+
6
+ ### Features
7
+
8
+ * React-native support for auto-env attributes. Only affects react-native package. ([deea99c](https://github.com/launchdarkly/js-core/commit/deea99ca2fbb3865f2ce55a83b2cf12e0ae2db5e))
9
+ * Update eslint jest configuration and versions. ([deea99c](https://github.com/launchdarkly/js-core/commit/deea99ca2fbb3865f2ce55a83b2cf12e0ae2db5e))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * Add RN SDK offline support through ConnectionMode. ([#361](https://github.com/launchdarkly/js-core/issues/361)) ([d97ce82](https://github.com/launchdarkly/js-core/commit/d97ce82861438a1b79b93799a9d061cdfa1ab027))
15
+ * Implement RN SDK EventSource jitter backoff. ([#359](https://github.com/launchdarkly/js-core/issues/359)) ([95e58bd](https://github.com/launchdarkly/js-core/commit/95e58bd666772b30b31ac98a462ca19407bc2bac))
16
+ * Improvements and fixes from docs review. ([#362](https://github.com/launchdarkly/js-core/issues/362)) ([ba07fbf](https://github.com/launchdarkly/js-core/commit/ba07fbf4ea0b505c4bdc6376b6b36d7a9c1e5fda))
17
+ * RN streamer connection in background and foreground. ([#360](https://github.com/launchdarkly/js-core/issues/360)) ([c69b768](https://github.com/launchdarkly/js-core/commit/c69b7686eed1971288adfbe527b4bf53ba5fe2b7))
18
+
19
+
20
+ ### Dependencies
21
+
22
+ * The following workspace dependencies were updated
23
+ * dependencies
24
+ * @launchdarkly/js-client-sdk-common bumped from 0.1.2 to 0.2.0
25
+
3
26
  ## [0.1.5](https://github.com/launchdarkly/js-core/compare/react-native-client-sdk-v0.1.4...react-native-client-sdk-v0.1.5) (2024-01-16)
4
27
 
5
28
 
package/README.md CHANGED
@@ -42,7 +42,7 @@ and re-run pod install for [auto-linking to work](https://github.com/react-nativ
42
42
  // App.tsx
43
43
  import { LDProvider, ReactNativeLDClient } from '@launchdarkly/react-native-client-sdk';
44
44
 
45
- const featureClient = new ReactNativeLDClient('mobile-key');
45
+ const featureClient = new ReactNativeLDClient('mobile-key', AutoEnvAttributes.Enabled);
46
46
  const userContext = { kind: 'user', key: 'test-user-1' };
47
47
 
48
48
  const App = () => (
@@ -100,7 +100,7 @@ yarn && yarn ios-go
100
100
 
101
101
  ## Verifying SDK build provenance with the SLSA framework
102
102
 
103
- LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
103
+ LaunchDarkly uses the [SLSA framework](https://slsa.dev/spec/v1.0/about) (Supply-chain Levels for Software Artifacts) to help developers make their supply chain more secure by ensuring the authenticity and build integrity of our published SDK packages. To learn more, see the [provenance guide](PROVENANCE.md).
104
104
 
105
105
  ## About LaunchDarkly
106
106
 
@@ -0,0 +1,2 @@
1
+ export let presets: string[];
2
+ //# sourceMappingURL=babel.config.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.config.d.ts","sourceRoot":"","sources":["../babel.config.js"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ module.exports = {
3
+ presets: ['module:metro-react-native-babel-preset'],
4
+ };
5
+ //# sourceMappingURL=babel.config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"babel.config.js","sourceRoot":"","sources":["../babel.config.js"],"names":[],"mappings":";AAAA,MAAM,CAAC,OAAO,GAAG;IACf,OAAO,EAAE,CAAC,wCAAwC,CAAC;CACpD,CAAC"}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/react-native-client-sdk",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
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": {
@@ -30,7 +30,7 @@
30
30
  "build": "npx tsc && yarn link-dev",
31
31
  "tsw": "yarn tsc --watch",
32
32
  "start": "rimraf dist && yarn tsw",
33
- "lint": "eslint . --ext .ts",
33
+ "lint": "eslint . --ext .ts,.tsx",
34
34
  "prettier": "prettier --write '**/*.@(js|ts|tsx|json|css)' --ignore-path ../../../.prettierignore",
35
35
  "test": "jest",
36
36
  "coverage": "yarn test --coverage",
@@ -44,26 +44,29 @@
44
44
  "react-native": "*"
45
45
  },
46
46
  "dependencies": {
47
- "@launchdarkly/js-client-sdk-common": "0.1.2",
47
+ "@launchdarkly/js-client-sdk-common": "0.2.0",
48
48
  "@react-native-async-storage/async-storage": "^1.21.0",
49
49
  "base64-js": "^1.5.1",
50
50
  "event-target-shim": "^6.0.2"
51
51
  },
52
52
  "devDependencies": {
53
+ "@launchdarkly/private-js-mocks": "0.0.1",
53
54
  "@testing-library/react": "^14.1.2",
54
55
  "@trivago/prettier-plugin-sort-imports": "^4.1.1",
55
56
  "@types/jest": "^29.5.11",
56
57
  "@types/react": "^18.2.31",
57
- "@typescript-eslint/eslint-plugin": "^6.1.0",
58
- "@typescript-eslint/parser": "^6.1.0",
58
+ "@typescript-eslint/eslint-plugin": "^6.20.0",
59
+ "@typescript-eslint/parser": "^6.20.0",
59
60
  "eslint": "^8.45.0",
60
61
  "eslint-config-airbnb-base": "^15.0.0",
61
62
  "eslint-config-airbnb-typescript": "^17.1.0",
62
63
  "eslint-config-prettier": "^8.8.0",
63
64
  "eslint-plugin-import": "^2.27.5",
65
+ "eslint-plugin-jest": "^27.6.3",
64
66
  "eslint-plugin-prettier": "^5.0.0",
65
67
  "jest": "^29.7.0",
66
68
  "launchdarkly-js-test-helpers": "^2.2.0",
69
+ "metro-react-native-babel-preset": "^0.77.0",
67
70
  "prettier": "^3.0.0",
68
71
  "react": "^18.2.0",
69
72
  "react-dom": "^18.2.0",
@@ -1,11 +1,11 @@
1
- import { LDClientImpl, type LDContext, type LDOptions } from '@launchdarkly/js-client-sdk-common';
1
+ import { AutoEnvAttributes, LDClientImpl, type LDContext, type LDOptions } from '@launchdarkly/js-client-sdk-common';
2
2
  /**
3
3
  * The React Native LaunchDarkly client. Instantiate this class to create an
4
4
  * instance of the ReactNativeLDClient and pass it to the {@link LDProvider}.
5
5
  *
6
6
  * @example
7
7
  * ```tsx
8
- * const featureClient = new ReactNativeLDClient(MOBILE_KEY);
8
+ * const featureClient = new ReactNativeLDClient(MOBILE_KEY, AutoEnvAttributes.Enabled);
9
9
  *
10
10
  * <LDProvider client={featureClient}>
11
11
  * <Welcome />
@@ -17,9 +17,13 @@ export default class ReactNativeLDClient extends LDClientImpl {
17
17
  * Creates an instance of the LaunchDarkly client.
18
18
  *
19
19
  * @param sdkKey The LaunchDarkly mobile key.
20
+ * @param autoEnvAttributes Enable / disable Auto environment attributes. When enabled, the SDK will automatically
21
+ * provide data about the mobile environment where the application is running. To learn more,
22
+ * read [Automatic environment attributes](https://docs.launchdarkly.com/sdk/features/environment-attributes).
23
+ * for more documentation.
20
24
  * @param options {@link LDOptions} to initialize the client with.
21
25
  */
22
- constructor(sdkKey: string, options?: LDOptions);
26
+ constructor(sdkKey: string, autoEnvAttributes: AutoEnvAttributes, options?: LDOptions);
23
27
  createStreamUriPath(context: LDContext): string;
24
28
  }
25
29
  //# sourceMappingURL=ReactNativeLDClient.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,oCAAoC,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D;;;;;OAKG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,SAAc;IAiB1C,mBAAmB,CAAC,OAAO,EAAE,SAAS;CAGhD"}
1
+ {"version":3,"file":"ReactNativeLDClient.d.ts","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAIjB,YAAY,EACZ,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,oCAAoC,CAAC;AAI5C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D;;;;;;;;;OASG;gBACS,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,GAAE,SAAc;IAwBhF,mBAAmB,CAAC,OAAO,EAAE,SAAS;CAGhD"}
@@ -6,7 +6,7 @@ import createPlatform from './platform';
6
6
  *
7
7
  * @example
8
8
  * ```tsx
9
- * const featureClient = new ReactNativeLDClient(MOBILE_KEY);
9
+ * const featureClient = new ReactNativeLDClient(MOBILE_KEY, AutoEnvAttributes.Enabled);
10
10
  *
11
11
  * <LDProvider client={featureClient}>
12
12
  * <Welcome />
@@ -18,12 +18,16 @@ export default class ReactNativeLDClient extends LDClientImpl {
18
18
  * Creates an instance of the LaunchDarkly client.
19
19
  *
20
20
  * @param sdkKey The LaunchDarkly mobile key.
21
+ * @param autoEnvAttributes Enable / disable Auto environment attributes. When enabled, the SDK will automatically
22
+ * provide data about the mobile environment where the application is running. To learn more,
23
+ * read [Automatic environment attributes](https://docs.launchdarkly.com/sdk/features/environment-attributes).
24
+ * for more documentation.
21
25
  * @param options {@link LDOptions} to initialize the client with.
22
26
  */
23
- constructor(sdkKey, options = {}) {
24
- var _a;
25
- const logger = (_a = options.logger) !== null && _a !== void 0 ? _a : new BasicLogger({
26
- level: 'debug',
27
+ constructor(sdkKey, autoEnvAttributes, options = {}) {
28
+ const { logger: customLogger, debug } = options;
29
+ const logger = customLogger !== null && customLogger !== void 0 ? customLogger : new BasicLogger({
30
+ level: debug ? 'debug' : 'info',
27
31
  // eslint-disable-next-line no-console
28
32
  destination: console.log,
29
33
  });
@@ -31,7 +35,7 @@ export default class ReactNativeLDClient extends LDClientImpl {
31
35
  analyticsEventPath: `/mobile`,
32
36
  diagnosticEventPath: `/mobile/events/diagnostic`,
33
37
  };
34
- super(sdkKey, createPlatform(logger), Object.assign(Object.assign({}, options), { logger }), internalOptions);
38
+ super(sdkKey, autoEnvAttributes, createPlatform(logger), Object.assign(Object.assign({}, options), { logger }), internalOptions);
35
39
  }
36
40
  createStreamUriPath(context) {
37
41
  return `/meval/${base64UrlEncode(JSON.stringify(context), this.platform.encoding)}`;
@@ -1 +1 @@
1
- {"version":3,"file":"ReactNativeLDClient.js","sourceRoot":"","sources":["../../src/ReactNativeLDClient.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,WAAW,EAEX,YAAY,GAGb,MAAM,oCAAoC,CAAC;AAE5C,OAAO,cAAc,MAAM,YAAY,CAAC;AAExC;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,YAAY;IAC3D;;;;;OAKG;IACH,YAAY,MAAc,EAAE,UAAqB,EAAE;;QACjD,MAAM,MAAM,GACV,MAAA,OAAO,CAAC,MAAM,mCACd,IAAI,WAAW,CAAC;YACd,KAAK,EAAE,OAAO;YACd,sCAAsC;YACtC,WAAW,EAAE,OAAO,CAAC,GAAG;SACz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,CAAC;IACJ,CAAC;IAEQ,mBAAmB,CAAC,OAAkB;QAC7C,OAAO,UAAU,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAS,CAAC,EAAE,CAAC;IACvF,CAAC;CACF"}
@@ -0,0 +1,17 @@
1
+ export = sha256;
2
+ declare function exports(message: any): any;
3
+ declare namespace exports {
4
+ export { exports as sha256, sha224 };
5
+ }
6
+ declare namespace ___home_runner_work_js_core_js_core_packages_sdk_react_native_src_fromExternal_js_sha256_index_ {
7
+ export namespace sha256 {
8
+ function hmac(key: any, message: any): any;
9
+ }
10
+ export { exports as sha256 };
11
+ export function sha224(message: any): any;
12
+ export namespace sha224 {
13
+ export function hmac_1(key: any, message: any): any;
14
+ export { hmac_1 as hmac };
15
+ }
16
+ }
17
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/fromExternal/js-sha256/index.js"],"names":[],"mappings":";AA8DW,4CAEN;;;;;;QAmBM,2CAEN;;;IAvBM,0CAEN;;QAmBM,oDAEN"}