Security News
Supply Chain Attack Detected in Solana's web3.js Library
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
iframe-interface
Advanced tools
iframe-interface
helps you to register and call api between iframe
. Support async.
English | 中文
yarn add iframe-interface
iframe-interface
separate api into 3 stage: factory => interface => call. Which is inherited from axios-interface
(Another helpful api tool widely used by our team).
import {createFactory} from 'iframe-interface';
const {setIframe, createCall} = createFactory({side: 'host'});
const Component = () => <iframe src="https://example.com" ref={setIframe} />;
// define api
const getUsersFromIframe = createCall<Params, Result>('getUsers');
// call
const result = await getUsers({companyId: '1', keyword: 'jack'});
import {useCallback, useEffect} from 'react';
import {createFactory} from 'iframe-interface';
const {registerCallHandler} = createFactory({side: 'guest'});
// register api at global
registerCallHandler('getUsers', handle);
// or register api at component
const Component = () => {
const handle = useCallback(
async (params: Params) => {
const result = await something();
return result;
},
[],
)
useEffect(
() => {
registerCallHandler('getUsers', handle);
},
[],
);
return null;
}
registerCallHandler
at host side andcreateCall
at guest side is also allowed. Put them at the opposite sides and it will work.
Lifecycles like onResolve
are not implemented yet since I think it may not be necessary. If you have some common issue and you want it be implemented in iframe-interface
, please open an issue.
FAQs
create interface from iframe
We found that iframe-interface demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A supply chain attack has been detected in versions 1.95.6 and 1.95.7 of the popular @solana/web3.js library.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.