@dynamic-labs-sdk/client 0.26.4 → 0.26.7
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/{InvalidParamError-D745dtMS.cjs → InvalidParamError-DFpM4bIX.cjs} +4 -4
- package/dist/{InvalidParamError-D745dtMS.cjs.map → InvalidParamError-DFpM4bIX.cjs.map} +1 -1
- package/dist/{InvalidParamError-CB0LQwcO.native.esm.js → InvalidParamError-F90z0K5r.native.esm.js} +3 -3
- package/dist/{InvalidParamError-CB0LQwcO.native.esm.js.map → InvalidParamError-F90z0K5r.native.esm.js.map} +1 -1
- package/dist/{InvalidParamError-CaO8zuAt.esm.js → InvalidParamError-WXK434H2.esm.js} +3 -3
- package/dist/{InvalidParamError-CaO8zuAt.esm.js.map → InvalidParamError-WXK434H2.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-D9HOBza_.esm.js → NotWaasWalletAccountError-D_qlVMCG.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-D9HOBza_.esm.js.map → NotWaasWalletAccountError-D_qlVMCG.esm.js.map} +1 -1
- package/dist/{NotWaasWalletAccountError-DEZeNnLy.cjs → NotWaasWalletAccountError-DbzO2LzZ.cjs} +3 -3
- package/dist/{NotWaasWalletAccountError-DEZeNnLy.cjs.map → NotWaasWalletAccountError-DbzO2LzZ.cjs.map} +1 -1
- package/dist/{NotWaasWalletAccountError-VxTJzIUw.native.esm.js → NotWaasWalletAccountError-QZZmjyhq.native.esm.js} +3 -3
- package/dist/{NotWaasWalletAccountError-VxTJzIUw.native.esm.js.map → NotWaasWalletAccountError-QZZmjyhq.native.esm.js.map} +1 -1
- package/dist/core.cjs +5 -5
- package/dist/core.esm.js +7 -7
- package/dist/core.esm.js.map +1 -1
- package/dist/core.native.esm.js +5 -5
- package/dist/core.native.esm.js.map +1 -1
- package/dist/{getNetworkProviderFromNetworkId-C0hhJBuw.cjs → getNetworkProviderFromNetworkId-BV9lOcuP.cjs} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-C0hhJBuw.cjs.map → getNetworkProviderFromNetworkId-BV9lOcuP.cjs.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-DS1xtXK3.esm.js → getNetworkProviderFromNetworkId-BVurb9VE.esm.js} +7 -7
- package/dist/{getNetworkProviderFromNetworkId-DS1xtXK3.esm.js.map → getNetworkProviderFromNetworkId-BVurb9VE.esm.js.map} +1 -1
- package/dist/{getNetworkProviderFromNetworkId-De1Y__cK.native.esm.js → getNetworkProviderFromNetworkId-DbR2qejA.native.esm.js} +3 -3
- package/dist/{getNetworkProviderFromNetworkId-De1Y__cK.native.esm.js.map → getNetworkProviderFromNetworkId-DbR2qejA.native.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-BEHO1AHh.cjs → getSignedSessionId-CNkcX15D.cjs} +3 -3
- package/dist/{getSignedSessionId-BEHO1AHh.cjs.map → getSignedSessionId-CNkcX15D.cjs.map} +1 -1
- package/dist/{getSignedSessionId-DrqGRbMx.esm.js → getSignedSessionId-DFiqF8_b.esm.js} +3 -3
- package/dist/{getSignedSessionId-DrqGRbMx.esm.js.map → getSignedSessionId-DFiqF8_b.esm.js.map} +1 -1
- package/dist/{getSignedSessionId-Dez0C64D.native.esm.js → getSignedSessionId-DXtxIjxF.native.esm.js} +3 -3
- package/dist/{getSignedSessionId-Dez0C64D.native.esm.js.map → getSignedSessionId-DXtxIjxF.native.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-C-21KB51.cjs → getVerifiedCredentialForWalletAccount-4eVkx2ZN.cjs} +3 -3
- package/dist/{getVerifiedCredentialForWalletAccount-C-21KB51.cjs.map → getVerifiedCredentialForWalletAccount-4eVkx2ZN.cjs.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-BHVopHZ0.esm.js → getVerifiedCredentialForWalletAccount-6di80gqF.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-BHVopHZ0.esm.js.map → getVerifiedCredentialForWalletAccount-6di80gqF.esm.js.map} +1 -1
- package/dist/{getVerifiedCredentialForWalletAccount-DPdNYxR1.native.esm.js → getVerifiedCredentialForWalletAccount-CHIZTYim.native.esm.js} +2 -2
- package/dist/{getVerifiedCredentialForWalletAccount-DPdNYxR1.native.esm.js.map → getVerifiedCredentialForWalletAccount-CHIZTYim.native.esm.js.map} +1 -1
- package/dist/index.cjs +5 -5
- package/dist/index.esm.js +8 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.native.esm.js +5 -5
- package/dist/{isMfaRequiredForAction-CUnqNQlh.esm.js → isMfaRequiredForAction-DKSH9YEU.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-CUnqNQlh.esm.js.map → isMfaRequiredForAction-DKSH9YEU.esm.js.map} +1 -1
- package/dist/{isMfaRequiredForAction-DQPdh-pT.cjs → isMfaRequiredForAction-ZwjmqVg-.cjs} +2 -2
- package/dist/{isMfaRequiredForAction-DQPdh-pT.cjs.map → isMfaRequiredForAction-ZwjmqVg-.cjs.map} +1 -1
- package/dist/{isMfaRequiredForAction-BCmIa8zG.native.esm.js → isMfaRequiredForAction-cJ294BGH.native.esm.js} +2 -2
- package/dist/{isMfaRequiredForAction-BCmIa8zG.native.esm.js.map → isMfaRequiredForAction-cJ294BGH.native.esm.js.map} +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/dist/waas.cjs +4 -4
- package/dist/waas.esm.js +3 -3
- package/dist/waas.native.esm.js +3 -3
- package/dist/waasCore.cjs +4 -4
- package/dist/waasCore.esm.js +3 -3
- package/dist/waasCore.native.esm.js +3 -3
- package/package.json +5 -4
- package/src/turboModules/NativeKeychain.native.spec.ts +45 -0
- package/src/turboModules/NativeKeychain.ts +21 -0
- package/src/turboModules/NativeReactNativeManifest.native.spec.ts +55 -0
- package/src/turboModules/NativeReactNativeManifest.ts +29 -0
package/dist/waas.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
2
|
-
const require_InvalidParamError = require('./InvalidParamError-
|
|
3
|
-
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-
|
|
4
|
-
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-BV9lOcuP.cjs');
|
|
2
|
+
const require_InvalidParamError = require('./InvalidParamError-DFpM4bIX.cjs');
|
|
3
|
+
const require_getVerifiedCredentialForWalletAccount = require('./getVerifiedCredentialForWalletAccount-4eVkx2ZN.cjs');
|
|
4
|
+
const require_NotWaasWalletAccountError = require('./NotWaasWalletAccountError-DbzO2LzZ.cjs');
|
|
5
5
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
6
6
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
7
7
|
|
package/dist/waas.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as name, F as getDefaultClient, R as BaseError, V as version, i as DYNAMIC_WAAS_METADATA, s as __getChainFromVerifiedCredentialChain_wrapped, w as assertDefined } from "./InvalidParamError-
|
|
2
|
-
import { c as findWaasWalletProviderByChain, h as __getWalletProviderFromWalletAccount_wrapped, l as isWaasWalletProvider, n as getWalletProviderByKey, s as isWaasWalletAccount, t as __getVerifiedCredentialForWalletAccount_wrapped, x as formatWalletProviderKey, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-
|
|
3
|
-
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-
|
|
1
|
+
import { B as name, F as getDefaultClient, R as BaseError, V as version, i as DYNAMIC_WAAS_METADATA, s as __getChainFromVerifiedCredentialChain_wrapped, w as assertDefined } from "./InvalidParamError-WXK434H2.esm.js";
|
|
2
|
+
import { c as findWaasWalletProviderByChain, h as __getWalletProviderFromWalletAccount_wrapped, l as isWaasWalletProvider, n as getWalletProviderByKey, s as isWaasWalletAccount, t as __getVerifiedCredentialForWalletAccount_wrapped, x as formatWalletProviderKey, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-6di80gqF.esm.js";
|
|
3
|
+
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-D_qlVMCG.esm.js";
|
|
4
4
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
5
|
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
6
6
|
|
package/dist/waas.native.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as name, F as getDefaultClient, R as BaseError, V as version, i as DYNAMIC_WAAS_METADATA, s as __getChainFromVerifiedCredentialChain_wrapped, w as assertDefined } from "./InvalidParamError-
|
|
2
|
-
import { c as findWaasWalletProviderByChain, h as __getWalletProviderFromWalletAccount_wrapped, l as isWaasWalletProvider, n as getWalletProviderByKey, s as isWaasWalletAccount, t as __getVerifiedCredentialForWalletAccount_wrapped, x as formatWalletProviderKey, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-
|
|
3
|
-
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-
|
|
1
|
+
import { B as name, F as getDefaultClient, R as BaseError, V as version, i as DYNAMIC_WAAS_METADATA, s as __getChainFromVerifiedCredentialChain_wrapped, w as assertDefined } from "./InvalidParamError-F90z0K5r.native.esm.js";
|
|
2
|
+
import { c as findWaasWalletProviderByChain, h as __getWalletProviderFromWalletAccount_wrapped, l as isWaasWalletProvider, n as getWalletProviderByKey, s as isWaasWalletAccount, t as __getVerifiedCredentialForWalletAccount_wrapped, x as formatWalletProviderKey, y as NoWalletProviderFoundError } from "./getVerifiedCredentialForWalletAccount-CHIZTYim.native.esm.js";
|
|
3
|
+
import { n as __refreshAuth_wrapped, t as NotWaasWalletAccountError } from "./NotWaasWalletAccountError-QZZmjyhq.native.esm.js";
|
|
4
4
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
5
|
import { EmbeddedWalletVersionEnum, JwtVerifiedCredentialFormatEnum, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
6
6
|
|
package/dist/waasCore.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-
|
|
2
|
-
const require_InvalidParamError = require('./InvalidParamError-
|
|
3
|
-
require('./isMfaRequiredForAction-
|
|
4
|
-
const require_getSignedSessionId = require('./getSignedSessionId-
|
|
1
|
+
const require_getNetworkProviderFromNetworkId = require('./getNetworkProviderFromNetworkId-BV9lOcuP.cjs');
|
|
2
|
+
const require_InvalidParamError = require('./InvalidParamError-DFpM4bIX.cjs');
|
|
3
|
+
require('./isMfaRequiredForAction-ZwjmqVg-.cjs');
|
|
4
|
+
const require_getSignedSessionId = require('./getSignedSessionId-CNkcX15D.cjs');
|
|
5
5
|
let _dynamic_labs_sdk_assert_package_version = require("@dynamic-labs-sdk/assert-package-version");
|
|
6
6
|
let _dynamic_labs_sdk_api_core = require("@dynamic-labs/sdk-api-core");
|
|
7
7
|
let _dynamic_labs_wallet_browser_wallet_client = require("@dynamic-labs-wallet/browser-wallet-client");
|
package/dist/waasCore.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as name, C as isCookieEnabled, M as CLIENT_SDK_NAME, V as version, c as CHAINS_INFO_MAP, i as DYNAMIC_WAAS_METADATA, n as DEFAULT_WAAS_BASE_API_URL, r as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, z as getCore } from "./InvalidParamError-
|
|
2
|
-
import "./isMfaRequiredForAction-
|
|
3
|
-
import { n as __consumeMfaTokenIfRequiredForAction_wrapped, t as __getSignedSessionId_wrapped } from "./getSignedSessionId-
|
|
1
|
+
import { B as name, C as isCookieEnabled, M as CLIENT_SDK_NAME, V as version, c as CHAINS_INFO_MAP, i as DYNAMIC_WAAS_METADATA, n as DEFAULT_WAAS_BASE_API_URL, r as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, z as getCore } from "./InvalidParamError-WXK434H2.esm.js";
|
|
2
|
+
import "./isMfaRequiredForAction-DKSH9YEU.esm.js";
|
|
3
|
+
import { n as __consumeMfaTokenIfRequiredForAction_wrapped, t as __getSignedSessionId_wrapped } from "./getSignedSessionId-DFiqF8_b.esm.js";
|
|
4
4
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
5
|
import { MFAAction, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
6
6
|
import { DynamicWalletClient, ThresholdSignatureScheme, WalletOperation } from "@dynamic-labs-wallet/browser-wallet-client";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { B as name, C as isCookieEnabled, M as CLIENT_SDK_NAME, V as version, c as CHAINS_INFO_MAP, i as DYNAMIC_WAAS_METADATA, n as DEFAULT_WAAS_BASE_API_URL, r as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, z as getCore } from "./InvalidParamError-
|
|
2
|
-
import "./isMfaRequiredForAction-
|
|
3
|
-
import { n as __consumeMfaTokenIfRequiredForAction_wrapped, t as __getSignedSessionId_wrapped } from "./getSignedSessionId-
|
|
1
|
+
import { B as name, C as isCookieEnabled, M as CLIENT_SDK_NAME, V as version, c as CHAINS_INFO_MAP, i as DYNAMIC_WAAS_METADATA, n as DEFAULT_WAAS_BASE_API_URL, r as DEFAULT_WAAS_BASE_MPC_RELAY_API_URL, s as __getChainFromVerifiedCredentialChain_wrapped, t as InvalidParamError, z as getCore } from "./InvalidParamError-F90z0K5r.native.esm.js";
|
|
2
|
+
import "./isMfaRequiredForAction-cJ294BGH.native.esm.js";
|
|
3
|
+
import { n as __consumeMfaTokenIfRequiredForAction_wrapped, t as __getSignedSessionId_wrapped } from "./getSignedSessionId-DXtxIjxF.native.esm.js";
|
|
4
4
|
import { assertPackageVersion } from "@dynamic-labs-sdk/assert-package-version";
|
|
5
5
|
import { MFAAction, WalletProviderEnum } from "@dynamic-labs/sdk-api-core";
|
|
6
6
|
import { DynamicWalletClient, ThresholdSignatureScheme, WalletOperation } from "@dynamic-labs-wallet/browser-wallet-client";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-sdk/client",
|
|
3
|
-
"version": "0.26.
|
|
3
|
+
"version": "0.26.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"ios",
|
|
11
11
|
"android",
|
|
12
12
|
"dynamic-labs-sdk-client.podspec",
|
|
13
|
-
"react-native.config.cjs"
|
|
13
|
+
"react-native.config.cjs",
|
|
14
|
+
"src/turboModules"
|
|
14
15
|
],
|
|
15
16
|
"exports": {
|
|
16
17
|
"./package.json": "./package.json",
|
|
@@ -41,13 +42,13 @@
|
|
|
41
42
|
},
|
|
42
43
|
"dependencies": {
|
|
43
44
|
"@dynamic-labs-wallet/browser-wallet-client": "0.0.325",
|
|
44
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
45
|
+
"@dynamic-labs/sdk-api-core": "0.0.958",
|
|
45
46
|
"@simplewebauthn/browser": "13.1.0",
|
|
46
47
|
"ably": "2.17.1",
|
|
47
48
|
"buffer": "6.0.3",
|
|
48
49
|
"eventemitter3": "5.0.1",
|
|
49
50
|
"zod": "4.0.5",
|
|
50
|
-
"@dynamic-labs-sdk/assert-package-version": "0.26.
|
|
51
|
+
"@dynamic-labs-sdk/assert-package-version": "0.26.7"
|
|
51
52
|
},
|
|
52
53
|
"devDependencies": {
|
|
53
54
|
"@inrupt/jest-jsdom-polyfills": "4.0.5",
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/// <reference types="vitest/globals" />
|
|
2
|
+
|
|
3
|
+
const turboModuleGetEnforcingMock = vi.fn();
|
|
4
|
+
|
|
5
|
+
vi.mock('react-native', () => ({
|
|
6
|
+
TurboModuleRegistry: {
|
|
7
|
+
get getEnforcing() {
|
|
8
|
+
return turboModuleGetEnforcingMock;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('NativeKeychain', () => {
|
|
14
|
+
const resolvedModule = {
|
|
15
|
+
deleteKey: vi.fn(),
|
|
16
|
+
generateKeyPair: vi.fn(),
|
|
17
|
+
getPublicKey: vi.fn(),
|
|
18
|
+
hasKey: vi.fn(),
|
|
19
|
+
isAvailable: vi.fn(),
|
|
20
|
+
sign: vi.fn(),
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
vi.resetModules();
|
|
25
|
+
turboModuleGetEnforcingMock.mockReturnValue(resolvedModule);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('should expose the resolved module as the default export', async () => {
|
|
29
|
+
const imported = await import('./NativeKeychain');
|
|
30
|
+
|
|
31
|
+
expect(imported.default).toBe(resolvedModule);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it("should look up the native module under the 'Keychain' key that matches the iOS and Android registration", async () => {
|
|
35
|
+
await import('./NativeKeychain');
|
|
36
|
+
|
|
37
|
+
expect(turboModuleGetEnforcingMock).toHaveBeenCalledWith('Keychain');
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('should resolve the native module exactly once at import time', async () => {
|
|
41
|
+
await import('./NativeKeychain');
|
|
42
|
+
|
|
43
|
+
expect(turboModuleGetEnforcingMock).toHaveBeenCalledOnce();
|
|
44
|
+
});
|
|
45
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// This file is a TurboModule spec consumed by React Native codegen.
|
|
2
|
+
// The `interface`, `default export`, and `react-native` import are hard
|
|
3
|
+
// requirements of the codegen parser and intentionally deviate from the
|
|
4
|
+
// project's conventions. Codegen discovers specs by the `Native*` filename
|
|
5
|
+
// prefix, so this file cannot be renamed to `.native.ts`.
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
import { type TurboModule, TurboModuleRegistry } from 'react-native';
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
export interface Spec extends TurboModule {
|
|
12
|
+
deleteKey(key: string): Promise<void>;
|
|
13
|
+
generateKeyPair(key: string): Promise<{ publicKey: string }>;
|
|
14
|
+
getPublicKey(key: string): Promise<{ publicKey: string } | null>;
|
|
15
|
+
hasKey(key: string): Promise<boolean>;
|
|
16
|
+
isAvailable(): Promise<boolean>;
|
|
17
|
+
sign(key: string, payload: string): Promise<{ signature: string }>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// eslint-disable-next-line import/no-default-export
|
|
21
|
+
export default TurboModuleRegistry.getEnforcing<Spec>('Keychain');
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/// <reference types="vitest/globals" />
|
|
2
|
+
|
|
3
|
+
const turboModuleGetMock = vi.fn();
|
|
4
|
+
|
|
5
|
+
vi.mock('react-native', () => ({
|
|
6
|
+
TurboModuleRegistry: {
|
|
7
|
+
get get() {
|
|
8
|
+
return turboModuleGetMock;
|
|
9
|
+
},
|
|
10
|
+
},
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
describe('NativeReactNativeManifest', () => {
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
vi.resetModules();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
describe('when the TurboModuleRegistry resolves the native module', () => {
|
|
19
|
+
const resolvedModule = { getManifest: vi.fn() };
|
|
20
|
+
|
|
21
|
+
beforeEach(() => {
|
|
22
|
+
turboModuleGetMock.mockReturnValue(resolvedModule);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('should expose the resolved module as the default export', async () => {
|
|
26
|
+
const imported = await import('./NativeReactNativeManifest');
|
|
27
|
+
|
|
28
|
+
expect(imported.default).toBe(resolvedModule);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("should look up the native module under the 'ReactNativeManifest' key that matches the iOS and Android registration", async () => {
|
|
32
|
+
await import('./NativeReactNativeManifest');
|
|
33
|
+
|
|
34
|
+
expect(turboModuleGetMock).toHaveBeenCalledWith('ReactNativeManifest');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should resolve the native module exactly once at import time', async () => {
|
|
38
|
+
await import('./NativeReactNativeManifest');
|
|
39
|
+
|
|
40
|
+
expect(turboModuleGetMock).toHaveBeenCalledOnce();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('when the TurboModuleRegistry cannot resolve the native module', () => {
|
|
45
|
+
beforeEach(() => {
|
|
46
|
+
turboModuleGetMock.mockReturnValue(null);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('should expose null as the default export so consumers can surface a linking error', async () => {
|
|
50
|
+
const imported = await import('./NativeReactNativeManifest');
|
|
51
|
+
|
|
52
|
+
expect(imported.default).toBeNull();
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React Native TurboModule spec for the `ReactNativeManifest` native module.
|
|
3
|
+
*
|
|
4
|
+
* Consumed by React Native codegen to emit the Android/iOS native interfaces.
|
|
5
|
+
* The filename must stay prefixed with `Native` — codegen's parser discovers
|
|
6
|
+
* spec files by that convention and will silently skip anything else, leaving
|
|
7
|
+
* the native module uncompiled. Do not rename this file.
|
|
8
|
+
*
|
|
9
|
+
* The `interface` keyword, the `default export`, and the locally-declared
|
|
10
|
+
* `ReactNativeManifest` type are hard requirements of the codegen parser and
|
|
11
|
+
* intentionally deviate from project conventions: codegen parses this file
|
|
12
|
+
* statically and does NOT follow imported type aliases, so the return shape
|
|
13
|
+
* must be defined inline here. The canonical type lives in
|
|
14
|
+
* `nativeManifest.types.ts`; the `assertSameShape` line below is a TS-only
|
|
15
|
+
* check that fails the build if the two definitions drift.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { type TurboModule, TurboModuleRegistry } from 'react-native';
|
|
19
|
+
|
|
20
|
+
export type ReactNativeManifest = {
|
|
21
|
+
sdkVersion: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface Spec extends TurboModule {
|
|
25
|
+
getManifest(): ReactNativeManifest;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// eslint-disable-next-line import/no-default-export -- codegen requires a default export of the TurboModule spec
|
|
29
|
+
export default TurboModuleRegistry.get<Spec>('ReactNativeManifest');
|