Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

global-input-react

Package Overview
Dependencies
Maintainers
1
Versions
185
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

global-input-react - npm Package Compare versions

Comparing version 4.2.3 to 4.3.0

62

dist/globalinput.js

@@ -6,3 +6,3 @@ "use strict";

});
exports.displayQRCode = exports.qrCodeLabel = exports.loading = exports.reducer = exports.startConnect = exports.sendInitData = exports.isValidInitData = exports.sendValue = exports.disconnect = exports.initialState = void 0;
exports.displayQRCode = exports.qrCodeLabel = exports.loading = exports.reducer = exports.getParingCode = exports.startConnect = exports.sendInitData = exports.isValidInitData = exports.sendValue = exports.disconnect = exports.initialState = void 0;

@@ -49,3 +49,4 @@ var _react = _interopRequireWildcard(require("react"));

isConnected: false,
initData: null
initData: null,
connected: []
};

@@ -59,4 +60,4 @@ exports.initialState = initialState;

setters: [],
clients: [],
client: null,
senders: [],
sender: null,
mobileConfig: null

@@ -228,7 +229,7 @@ };

},
onSenderConnected: (client, clients) => {
onSenderConnected: (sender, senders) => {
mobileData.mobileState = MobileState.MOBILE_CONNECTED;
mobileData.clients = clients;
mobileData.client = client;
options && options.onSenderConnected && options.onSenderConnected(client, clients);
mobileData.senders = senders;
mobileData.sender = sender;
options && options.onSenderConnected && options.onSenderConnected(sender, senders);
notify({

@@ -238,15 +239,15 @@ type: ACTION_TYPES.SENDER_CONNECTED

},
onSenderDisconnected: (client, clients) => {
mobileData.clients = clients;
mobileData.client = client;
onSenderDisconnected: (sender, senders) => {
mobileData.senders = senders;
mobileData.sender = sender;
if (clients && clients.length) {
console.log("-multi-client-");
if (senders && senders.length) {
console.log("-multi-senders-");
} else {
mobileData.mobileState = MobileState.INITIALIZING;
mobileData.session.connect(mobileData.mobileConfig);
console.log("-client-disconnected-");
console.log("-sender-disconnected-");
}
options && options.onSenderDisconnected && options.onSenderDisconnected(client, clients);
options && options.onSenderDisconnected && options.onSenderDisconnected(sender, senders);
notify({

@@ -256,2 +257,7 @@ type: ACTION_TYPES.SENDER_DISCONNECTED

},
onInputPermission: (permissionMessage, senders, deny) => {
if (options && options.onInputPermission) {
options.onInputPermission(permissionMessage, senders, deny);
}
},
onError: errorMessage => {

@@ -267,6 +273,3 @@ closeConnection();

apikey: options && options.apikey,
securityGroup: options && options.securityGroup,
aes: options && options.aes,
onInput: options && options.onInput,
onInputPermissionResult: options && options.onInputPermissionResult
securityGroup: options && options.securityGroup
};

@@ -321,2 +324,6 @@ };

if (config.codeAES) {
mobileData.session.setCodeAES(config.codeAES);
}
mobileData.session.connect(mobileData.mobileConfig);

@@ -330,2 +337,8 @@ notify({

const getParingCode = () => {
return mobileData.session && mobileData.session.buildPairingData();
};
exports.getParingCode = getParingCode;
const reducer = (state, action) => {

@@ -376,3 +389,4 @@ switch (action.type) {

isConnected: mobileData.mobileState === MobileState.MOBILE_CONNECTED,
initData: mobileData.mobileConfig && mobileData.mobileConfig.initData
initData: mobileData.mobileConfig && mobileData.mobileConfig.initData,
senders: mobileData.senders
};

@@ -419,4 +433,4 @@ };

const displayQRCode = (connectionCode, level, size, label, maxSize, marginTop, marginLeft) => {
if (!connectionCode || size === 0) {
const displayQRCode = (codeContent, level, size, label, maxSize, marginTop, marginLeft) => {
if (!codeContent || size === 0) {
return null;

@@ -427,3 +441,3 @@ }

return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_qrcode.default, {
value: connectionCode,
value: codeContent,
level: level,

@@ -434,3 +448,3 @@ size: size

return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(ResizeQRCode, {
value: connectionCode,
value: codeContent,
level: level,

@@ -437,0 +451,0 @@ maxSize: maxSize,

@@ -43,3 +43,4 @@ "use strict";

isConnected,
initData
initData,
senders
}, dispatch] = (0, _react.useReducer)(globalInput.reducer, globalInput.initialState);

@@ -82,2 +83,3 @@ const attached = (0, _react.useRef)(true);

if (!attached.current) {
console.log(" -restart-not-attached- ");
return;

@@ -144,4 +146,30 @@ }

}, [connectionCode, isReady, isLoading]);
const PairingQR = (0, _react.useCallback)(({
level = 'H',
size,
label = globalInput.qrCodeLabel,
loading = globalInput.loading,
maxSize = 400,
marginTop = 90,
marginLeft = 10
}) => {
if (isLoading) {
return loading;
}
if (!isReady) {
return null;
}
const pairingCode = globalInput.getParingCode();
if (!pairingCode || size === 0) {
return null;
}
return globalInput.displayQRCode(pairingCode, level, size, label, maxSize, marginTop, marginLeft);
}, [isReady, isLoading]);
return {
ConnectQR,
PairingQR,
connectionCode,

@@ -156,2 +184,3 @@ field,

initData,
senders,
sendValue,

@@ -158,0 +187,0 @@ sendInitData,

import React from 'react';
import { InitData, FormField, FieldValue } from 'global-input-message';
import { InitData, FormField, FieldValue, Sender, PermissionRequestMessage } from 'global-input-message';
export * from 'global-input-message';

@@ -12,8 +12,15 @@ export function useGlobalInputApp(config: ConfigData | (() => ConfigData)): GlobalInputData;

options?: ConnectOptions;
codeAES?: string;
}
export interface ConnectOptions {
apikey?: string;
url?: string;
securityGroup?: string;
client?: string;
url?: string;
onRegistered?: (connectionCode: string) => void;
onRegisterFailed?: () => void;
onSenderConnected?: (sender: Sender, senders: Sender[]) => void;
onSenderDisconnected?: (sender: Sender, senders: Sender[]) => void;
onInputPermission?: (permissionMessage: PermissionRequestMessage, senders: Sender[], deny: (reason?: string) => void) => void;
onError?: (message: string) => void;
}

@@ -41,2 +48,3 @@ interface FieldChanged {

ConnectQR: React.FC<ConnectQRProps>,
PairingQR: React.FC<ConnectQRProps>,
connectionCode: string;

@@ -51,2 +59,3 @@ field: FormField;

initData: InitData;
senders: Sender[];
sendValue: SendValueFunction;

@@ -53,0 +62,0 @@ sendInitData: SendInitDataFunction;

{
"name": "global-input-react",
"version": "4.2.3",
"version": "4.3.0",
"description": "global input react component",

@@ -72,5 +72,5 @@ "main": "./dist/index",

"dependencies": {
"global-input-message": "^2.0.9",
"global-input-message": "^2.1.0",
"qrcode.react": "^1.0.0"
}
}

@@ -37,2 +37,3 @@

initData: null,
connected: []
};

@@ -47,4 +48,4 @@

setters: [],
clients: [],
client: null,
senders: [],
sender: null,
mobileConfig: null

@@ -185,14 +186,14 @@ };

},
onSenderConnected: (client, clients) => {
onSenderConnected: (sender, senders) => {
mobileData.mobileState = MobileState.MOBILE_CONNECTED;
mobileData.clients = clients;
mobileData.client = client;
options && options.onSenderConnected && options.onSenderConnected(client, clients);
mobileData.senders = senders;
mobileData.sender = sender;
options && options.onSenderConnected && options.onSenderConnected(sender, senders);
notify({ type: ACTION_TYPES.SENDER_CONNECTED });
},
onSenderDisconnected: (client, clients) => {
mobileData.clients = clients;
mobileData.client = client;
if (clients && clients.length) {
console.log("-multi-client-");
onSenderDisconnected: (sender, senders) => {
mobileData.senders = senders;
mobileData.sender = sender;
if (senders && senders.length) {
console.log("-multi-senders-");
}

@@ -202,8 +203,13 @@ else {

mobileData.session.connect(mobileData.mobileConfig);
console.log("-client-disconnected-");
console.log("-sender-disconnected-");
}
options && options.onSenderDisconnected && options.onSenderDisconnected(client, clients);
options && options.onSenderDisconnected && options.onSenderDisconnected(sender, senders);
notify({ type: ACTION_TYPES.SENDER_DISCONNECTED });
},
onInputPermission: (permissionMessage, senders, deny) => {
if (options && options.onInputPermission) {
options.onInputPermission(permissionMessage, senders, deny);
}
},
onError: errorMessage => {

@@ -216,6 +222,3 @@ closeConnection();

apikey: options && options.apikey,
securityGroup: options && options.securityGroup,
aes: options && options.aes,
onInput: options && options.onInput,
onInputPermissionResult: options && options.onInputPermissionResult
securityGroup: options && options.securityGroup
};

@@ -250,2 +253,5 @@ };

}
if (config.codeAES) {
mobileData.session.setCodeAES(config.codeAES);
}
mobileData.session.connect(mobileData.mobileConfig);

@@ -255,5 +261,7 @@ notify({ type: ACTION_TYPES.START_CONNECT });

export const getParingCode = () => {
return mobileData.session && mobileData.session.buildPairingData();
};
export const reducer = (state, action) => {

@@ -288,3 +296,4 @@ switch (action.type) {

isConnected: mobileData.mobileState === MobileState.MOBILE_CONNECTED,
initData: mobileData.mobileConfig && mobileData.mobileConfig.initData
initData: mobileData.mobileConfig && mobileData.mobileConfig.initData,
senders: mobileData.senders
};

@@ -315,4 +324,4 @@ };

export const displayQRCode = (connectionCode, level, size, label, maxSize, marginTop, marginLeft) => {
if ((!connectionCode) || size === 0) {
export const displayQRCode = (codeContent, level, size, label, maxSize, marginTop, marginLeft) => {
if ((!codeContent) || size === 0) {
return null;

@@ -323,3 +332,3 @@ }

<>
<QRCode value={connectionCode} level={level} size={size} />
<QRCode value={codeContent} level={level} size={size} />
{label}

@@ -332,3 +341,3 @@ </>

<>
<ResizeQRCode value={connectionCode} level={level} maxSize={maxSize} marginTop={marginTop} marginLeft={marginLeft} />
<ResizeQRCode value={codeContent} level={level} maxSize={maxSize} marginTop={marginTop} marginLeft={marginLeft} />
{label}

@@ -335,0 +344,0 @@ </>

@@ -16,2 +16,3 @@

initData,
senders
}, dispatch] = useReducer(globalInput.reducer, globalInput.initialState);

@@ -51,2 +52,3 @@

if (!attached.current) {
console.log(" -restart-not-attached- ");
return;

@@ -106,7 +108,20 @@ }

}, [connectionCode, isReady, isLoading]);
const PairingQR = useCallback(({ level = 'H', size, label = globalInput.qrCodeLabel, loading = globalInput.loading, maxSize = 400, marginTop = 90, marginLeft = 10 }) => {
if (isLoading) {
return loading;
}
if (!isReady) {
return null;
}
const pairingCode = globalInput.getParingCode();
if ((!pairingCode) || size === 0) {
return null;
}
return globalInput.displayQRCode(pairingCode, level, size, label, maxSize, marginTop, marginLeft);
}, [isReady, isLoading]);
return {
ConnectQR,
PairingQR,
connectionCode,

@@ -121,2 +136,3 @@ field,

initData,
senders,
sendValue,

@@ -123,0 +139,0 @@ sendInitData,

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc