@dynamic-labs/react-native-extension 2.1.0-alpha.24 → 2.1.0-alpha.26
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/{index.js → index.cjs} +109 -84
- package/package.json +9 -8
- package/src/ReactNativeExtension/index.d.ts +1 -0
- package/src/ReactNativeExtension/setupPlatformHandler/index.d.ts +1 -0
- package/src/ReactNativeExtension/setupPlatformHandler/setupPlatformHandler.d.ts +2 -0
- package/src/components/WebView/index.d.ts +1 -0
- package/src/index.d.ts +1 -1
- package/src/lib/components/WebView/index.d.ts +0 -1
- /package/src/{lib → ReactNativeExtension}/ReactNativeExtension.d.ts +0 -0
- /package/src/{lib/utils → ReactNativeExtension}/setupFetchHandler/index.d.ts +0 -0
- /package/src/{lib/utils → ReactNativeExtension}/setupFetchHandler/setupFetchHandler.d.ts +0 -0
- /package/src/{lib/utils → ReactNativeExtension}/setupPasskeyHandler/index.d.ts +0 -0
- /package/src/{lib/utils → ReactNativeExtension}/setupPasskeyHandler/setupPasskeyHandler.d.ts +0 -0
- /package/src/{lib/components → components}/WebView/WebView.d.ts +0 -0
- /package/src/{lib/components → components}/WebView/WebView.styles.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView}/useMessageTransportWebViewBridge/index.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView/useMessageTransportWebViewBridge}/useIsMounted/index.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView/useMessageTransportWebViewBridge}/useIsMounted/useIsMounted.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView}/useMessageTransportWebViewBridge/useMessageTransportWebViewBridge.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView}/useWebViewVisibility/index.d.ts +0 -0
- /package/src/{lib/hooks → components/WebView}/useWebViewVisibility/useWebViewVisibility.d.ts +0 -0
- /package/src/{lib/utils → utils}/logger.d.ts +0 -0
package/{index.js → index.cjs}
RENAMED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import { WebView as WebView$1 } from 'react-native-webview';
|
|
3
|
-
import { parseMessageTransportData, createRequestChannel } from '@dynamic-labs/message-transport';
|
|
4
|
-
import { Logger } from '@dynamic-labs/logger';
|
|
5
|
-
import { StyleSheet } from 'react-native';
|
|
6
|
-
import { jsx } from 'react/jsx-runtime';
|
|
7
|
-
import { createPasskey, PasskeyStamper } from '@turnkey/react-native-passkey-stamper';
|
|
1
|
+
'use strict';
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var reactNativeWebview = require('react-native-webview');
|
|
7
|
+
var messageTransport = require('@dynamic-labs/message-transport');
|
|
8
|
+
var logger$1 = require('@dynamic-labs/logger');
|
|
9
|
+
var reactNative = require('react-native');
|
|
10
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
11
|
+
var expoLinking = require('expo-linking');
|
|
12
|
+
var reactNativePasskeyStamper = require('@turnkey/react-native-passkey-stamper');
|
|
13
|
+
|
|
14
|
+
var version$1 = "2.1.0-alpha.26";
|
|
10
15
|
|
|
11
16
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
12
17
|
|
|
@@ -1092,14 +1097,14 @@ $$8({ target: 'Object', stat: true, arity: 2, forced: Object.assign !== assign }
|
|
|
1092
1097
|
assign: assign
|
|
1093
1098
|
});
|
|
1094
1099
|
|
|
1095
|
-
const logger = new Logger('react-native-extension');
|
|
1100
|
+
const logger = new logger$1.Logger('react-native-extension');
|
|
1096
1101
|
|
|
1097
1102
|
const useIsMounted = () => {
|
|
1098
|
-
const isMountedRef = useRef(true);
|
|
1099
|
-
useEffect(() => () => {
|
|
1103
|
+
const isMountedRef = react.useRef(true);
|
|
1104
|
+
react.useEffect(() => () => {
|
|
1100
1105
|
isMountedRef.current = false;
|
|
1101
1106
|
}, []);
|
|
1102
|
-
return useCallback(() => isMountedRef.current, [isMountedRef]);
|
|
1107
|
+
return react.useCallback(() => isMountedRef.current, [isMountedRef]);
|
|
1103
1108
|
};
|
|
1104
1109
|
|
|
1105
1110
|
const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
@@ -1117,7 +1122,7 @@ const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
|
1117
1122
|
logger.debug('error parsing data', err);
|
|
1118
1123
|
return;
|
|
1119
1124
|
}
|
|
1120
|
-
const message = parseMessageTransportData(parsedData);
|
|
1125
|
+
const message = messageTransport.parseMessageTransportData(parsedData);
|
|
1121
1126
|
if (!message) {
|
|
1122
1127
|
logger.debug('invalid message', message);
|
|
1123
1128
|
return;
|
|
@@ -1132,7 +1137,7 @@ const useMessageTransportWebViewBridge = (core, webViewRef) => {
|
|
|
1132
1137
|
/**
|
|
1133
1138
|
* Send messages created by the client to the webview
|
|
1134
1139
|
*/
|
|
1135
|
-
useEffect(() => {
|
|
1140
|
+
react.useEffect(() => {
|
|
1136
1141
|
const sendMessageToWebView = message => {
|
|
1137
1142
|
if (!canBroadcastMessages()) return;
|
|
1138
1143
|
/**
|
|
@@ -1681,15 +1686,15 @@ for (var COLLECTION_NAME in DOMIterables) {
|
|
|
1681
1686
|
handlePrototype(DOMTokenListPrototype, 'DOMTokenList');
|
|
1682
1687
|
|
|
1683
1688
|
const useWebViewVisibility = core => {
|
|
1684
|
-
const webViewVisibilityRequestChannelRef = useRef(createRequestChannel(core.messageTransport));
|
|
1685
|
-
const [visible, setVisible] = useState(false);
|
|
1686
|
-
useEffect(() => webViewVisibilityRequestChannelRef.current.handle('setVisibility', setVisible), [setVisible]);
|
|
1689
|
+
const webViewVisibilityRequestChannelRef = react.useRef(messageTransport.createRequestChannel(core.messageTransport));
|
|
1690
|
+
const [visible, setVisible] = react.useState(false);
|
|
1691
|
+
react.useEffect(() => webViewVisibilityRequestChannelRef.current.handle('setVisibility', setVisible), [setVisible]);
|
|
1687
1692
|
return {
|
|
1688
1693
|
visible
|
|
1689
1694
|
};
|
|
1690
1695
|
};
|
|
1691
1696
|
|
|
1692
|
-
const styles = StyleSheet.create({
|
|
1697
|
+
const styles = reactNative.StyleSheet.create({
|
|
1693
1698
|
container: {
|
|
1694
1699
|
backgroundColor: 'transparent',
|
|
1695
1700
|
bottom: 0,
|
|
@@ -1721,7 +1726,7 @@ const WebView = ({
|
|
|
1721
1726
|
core,
|
|
1722
1727
|
webviewDebuggingEnabled: _webviewDebuggingEnabled = false
|
|
1723
1728
|
}) => {
|
|
1724
|
-
const webViewRef = useRef(null);
|
|
1729
|
+
const webViewRef = react.useRef(null);
|
|
1725
1730
|
const {
|
|
1726
1731
|
visible
|
|
1727
1732
|
} = useWebViewVisibility(core);
|
|
@@ -1729,7 +1734,7 @@ const WebView = ({
|
|
|
1729
1734
|
onMessageHandler
|
|
1730
1735
|
} = useMessageTransportWebViewBridge(core, webViewRef);
|
|
1731
1736
|
const containerStyles = [styles['container'], visible ? styles.show : styles.hide];
|
|
1732
|
-
return /*#__PURE__*/jsx(WebView
|
|
1737
|
+
return /*#__PURE__*/jsxRuntime.jsx(reactNativeWebview.WebView, {
|
|
1733
1738
|
ref: webViewRef,
|
|
1734
1739
|
source: {
|
|
1735
1740
|
uri: webviewUrl
|
|
@@ -1743,71 +1748,10 @@ const WebView = ({
|
|
|
1743
1748
|
}, 'webview');
|
|
1744
1749
|
};
|
|
1745
1750
|
const createWebView = props => {
|
|
1746
|
-
const WebViewWrapper = () => /*#__PURE__*/jsx(WebView, Object.assign({}, props));
|
|
1751
|
+
const WebViewWrapper = () => /*#__PURE__*/jsxRuntime.jsx(WebView, Object.assign({}, props));
|
|
1747
1752
|
return WebViewWrapper;
|
|
1748
1753
|
};
|
|
1749
1754
|
|
|
1750
|
-
/******************************************************************************
|
|
1751
|
-
Copyright (c) Microsoft Corporation.
|
|
1752
|
-
|
|
1753
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
1754
|
-
purpose with or without fee is hereby granted.
|
|
1755
|
-
|
|
1756
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
1757
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
1758
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
1759
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
1760
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
1761
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1762
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
1763
|
-
***************************************************************************** */
|
|
1764
|
-
|
|
1765
|
-
function __awaiter(thisArg, _arguments, P, generator) {
|
|
1766
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
1767
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
1768
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
1769
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
1770
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
1771
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
1772
|
-
});
|
|
1773
|
-
}
|
|
1774
|
-
|
|
1775
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
1776
|
-
var e = new Error(message);
|
|
1777
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
1778
|
-
};
|
|
1779
|
-
|
|
1780
|
-
const setupPasskeyHandler = core => {
|
|
1781
|
-
const passkeysRequestChannel = createRequestChannel(core.messageTransport);
|
|
1782
|
-
passkeysRequestChannel.handle('createPasskey', _a => __awaiter(void 0, [_a], void 0, function* ({
|
|
1783
|
-
publicKey
|
|
1784
|
-
}) {
|
|
1785
|
-
try {
|
|
1786
|
-
const {
|
|
1787
|
-
attestation
|
|
1788
|
-
} = yield createPasskey(publicKey);
|
|
1789
|
-
return {
|
|
1790
|
-
attestation
|
|
1791
|
-
};
|
|
1792
|
-
} catch (err) {
|
|
1793
|
-
logger.error(err);
|
|
1794
|
-
throw err;
|
|
1795
|
-
}
|
|
1796
|
-
}));
|
|
1797
|
-
passkeysRequestChannel.handle('passkeyStamp', (rpId, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
1798
|
-
try {
|
|
1799
|
-
const stamper = new PasskeyStamper({
|
|
1800
|
-
rpId
|
|
1801
|
-
});
|
|
1802
|
-
const stamped = yield stamper.stamp(payload);
|
|
1803
|
-
return stamped;
|
|
1804
|
-
} catch (err) {
|
|
1805
|
-
logger.error(err);
|
|
1806
|
-
throw err;
|
|
1807
|
-
}
|
|
1808
|
-
}));
|
|
1809
|
-
};
|
|
1810
|
-
|
|
1811
1755
|
var classof$3 = classofRaw$2;
|
|
1812
1756
|
var global$8 = global$j;
|
|
1813
1757
|
|
|
@@ -2970,8 +2914,38 @@ $({ target: 'Object', stat: true }, {
|
|
|
2970
2914
|
}
|
|
2971
2915
|
});
|
|
2972
2916
|
|
|
2917
|
+
/******************************************************************************
|
|
2918
|
+
Copyright (c) Microsoft Corporation.
|
|
2919
|
+
|
|
2920
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2921
|
+
purpose with or without fee is hereby granted.
|
|
2922
|
+
|
|
2923
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2924
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2925
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2926
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2927
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2928
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2929
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2930
|
+
***************************************************************************** */
|
|
2931
|
+
|
|
2932
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
2933
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
2934
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
2935
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
2936
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
2937
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
2938
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
2939
|
+
});
|
|
2940
|
+
}
|
|
2941
|
+
|
|
2942
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
2943
|
+
var e = new Error(message);
|
|
2944
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
2945
|
+
};
|
|
2946
|
+
|
|
2973
2947
|
const setupFetchHandler = core => {
|
|
2974
|
-
const fetchRequestChannel = createRequestChannel(core.messageTransport);
|
|
2948
|
+
const fetchRequestChannel = messageTransport.createRequestChannel(core.messageTransport);
|
|
2975
2949
|
fetchRequestChannel.handle('fetch', (input, init) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2976
2950
|
const response = yield fetch(input, init);
|
|
2977
2951
|
const responseBody = yield response.text();
|
|
@@ -2985,6 +2959,56 @@ const setupFetchHandler = core => {
|
|
|
2985
2959
|
}));
|
|
2986
2960
|
};
|
|
2987
2961
|
|
|
2962
|
+
const setupPlatformHandler = core => {
|
|
2963
|
+
const platformChannel = messageTransport.createRequestChannel(core.messageTransport);
|
|
2964
|
+
core.manifest.setPlatform('react-native');
|
|
2965
|
+
platformChannel.handle('openURL', url => __awaiter(void 0, void 0, void 0, function* () {
|
|
2966
|
+
yield expoLinking.openURL(url);
|
|
2967
|
+
}));
|
|
2968
|
+
platformChannel.handle('openNewWindow', url => __awaiter(void 0, void 0, void 0, function* () {
|
|
2969
|
+
const error = new Error('openNewWindow message handler not implemented');
|
|
2970
|
+
logger.error(error);
|
|
2971
|
+
core.initialization.error = error;
|
|
2972
|
+
throw error;
|
|
2973
|
+
}));
|
|
2974
|
+
// TODO: this is temporary and should be removed once we are able to get the redirect URL from
|
|
2975
|
+
// dashboard as provided from the customer
|
|
2976
|
+
platformChannel.handle('getRedirectUrl', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
2977
|
+
return expoLinking.createURL('');
|
|
2978
|
+
}));
|
|
2979
|
+
};
|
|
2980
|
+
|
|
2981
|
+
const setupPasskeyHandler = core => {
|
|
2982
|
+
const passkeysRequestChannel = messageTransport.createRequestChannel(core.messageTransport);
|
|
2983
|
+
passkeysRequestChannel.handle('createPasskey', _a => __awaiter(void 0, [_a], void 0, function* ({
|
|
2984
|
+
publicKey
|
|
2985
|
+
}) {
|
|
2986
|
+
try {
|
|
2987
|
+
const {
|
|
2988
|
+
attestation
|
|
2989
|
+
} = yield reactNativePasskeyStamper.createPasskey(publicKey);
|
|
2990
|
+
return {
|
|
2991
|
+
attestation
|
|
2992
|
+
};
|
|
2993
|
+
} catch (err) {
|
|
2994
|
+
logger.error(err);
|
|
2995
|
+
throw err;
|
|
2996
|
+
}
|
|
2997
|
+
}));
|
|
2998
|
+
passkeysRequestChannel.handle('passkeyStamp', (rpId, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
2999
|
+
try {
|
|
3000
|
+
const stamper = new reactNativePasskeyStamper.PasskeyStamper({
|
|
3001
|
+
rpId
|
|
3002
|
+
});
|
|
3003
|
+
const stamped = yield stamper.stamp(payload);
|
|
3004
|
+
return stamped;
|
|
3005
|
+
} catch (err) {
|
|
3006
|
+
logger.error(err);
|
|
3007
|
+
throw err;
|
|
3008
|
+
}
|
|
3009
|
+
}));
|
|
3010
|
+
};
|
|
3011
|
+
|
|
2988
3012
|
const defaultWebviewUrl = `https://webview.dynamicauth.com/${version$1}`;
|
|
2989
3013
|
const ReactNativeExtension = ({
|
|
2990
3014
|
webviewUrl: _webviewUrl = defaultWebviewUrl,
|
|
@@ -2994,6 +3018,7 @@ const ReactNativeExtension = ({
|
|
|
2994
3018
|
if (appOrigin) core.manifest.setAppOrigin(appOrigin);
|
|
2995
3019
|
setupPasskeyHandler(core);
|
|
2996
3020
|
setupFetchHandler(core);
|
|
3021
|
+
setupPlatformHandler(core);
|
|
2997
3022
|
return {
|
|
2998
3023
|
reactNative: {
|
|
2999
3024
|
WebView: createWebView({
|
|
@@ -3005,4 +3030,4 @@ const ReactNativeExtension = ({
|
|
|
3005
3030
|
};
|
|
3006
3031
|
};
|
|
3007
3032
|
|
|
3008
|
-
|
|
3033
|
+
exports.ReactNativeExtension = ReactNativeExtension;
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/react-native-extension",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
4
|
-
"main": "./index.
|
|
5
|
-
"module": "./index.js",
|
|
3
|
+
"version": "2.1.0-alpha.26",
|
|
4
|
+
"main": "./index.cjs",
|
|
5
|
+
"module": "./src/index.js",
|
|
6
6
|
"types": "./src/index.d.ts",
|
|
7
|
-
"type": "
|
|
7
|
+
"type": "commonjs",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./src/index.d.ts",
|
|
@@ -14,14 +14,15 @@
|
|
|
14
14
|
"./package.json": "./package.json"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@dynamic-labs/message-transport": "2.1.0-alpha.
|
|
18
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
19
|
-
"@turnkey/react-native-passkey-stamper": "0.2.5"
|
|
17
|
+
"@dynamic-labs/message-transport": "2.1.0-alpha.26",
|
|
18
|
+
"@dynamic-labs/logger": "2.1.0-alpha.26",
|
|
19
|
+
"@turnkey/react-native-passkey-stamper": "0.2.5",
|
|
20
|
+
"expo-linking": "6.3.1"
|
|
20
21
|
},
|
|
21
22
|
"peerDependencies": {
|
|
22
23
|
"react": "^18.2.0",
|
|
23
24
|
"react-native": "^0.73.6",
|
|
24
25
|
"react-native-webview": "^13.6.4",
|
|
25
|
-
"@dynamic-labs/client": "2.1.0-alpha.
|
|
26
|
+
"@dynamic-labs/client": "2.1.0-alpha.26"
|
|
26
27
|
}
|
|
27
28
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ReactNativeExtension';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './setupPlatformHandler';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './WebView';
|
package/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ReactNativeExtension, type IReactNativeExtension, } from './
|
|
1
|
+
export { ReactNativeExtension, type IReactNativeExtension, } from './ReactNativeExtension';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { WebView, createWebView } from './WebView';
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{lib/utils → ReactNativeExtension}/setupPasskeyHandler/setupPasskeyHandler.d.ts
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/src/{lib/hooks → components/WebView}/useWebViewVisibility/useWebViewVisibility.d.ts
RENAMED
|
File without changes
|
|
File without changes
|