🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

ifapi

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ifapi - npm Package Compare versions

Comparing version
1.1.6
to
1.1.8
+5
-2
main.js

@@ -59,4 +59,7 @@ function response(id, data, error = "") {

const frame = window.frames[frameID];
if (!frame)
if (!frame) {
reject(`iframe not found: ${frameID}`);
return;
}
;
const id = uuid();

@@ -88,4 +91,4 @@ function listener(e) {

const requestData = { id, actionName, params };
(_a = frame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(requestData), frame.src);
(_a = frame.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify(requestData), "*");
});
}

@@ -62,3 +62,6 @@ function response(id: string, data: any, error = "") {

const frame: HTMLIFrameElement = (window.frames as any)[frameID];
if (!frame) return;
if (!frame) {
reject(`iframe not found: ${frameID}`);
return;
};
const id = uuid();

@@ -87,4 +90,4 @@ function listener(e: any) {

const requestData = { id, actionName, params };
frame.contentWindow?.postMessage(JSON.stringify(requestData), frame.src);
frame.contentWindow?.postMessage(JSON.stringify(requestData), "*");
});
}
{
"name": "ifapi",
"version": "1.1.6",
"version": "1.1.8",
"type": "module",

@@ -5,0 +5,0 @@ "main": "main.js",

@@ -15,3 +15,3 @@ ## 说明

#### 1. iframe 内嵌页面导出 api
#### 1. iframe 页面导出 api

@@ -33,17 +33,4 @@ ```ts

#### 2. 父级页面调用 api
```ts
import { excute } from 'ifapi';
#### 2. 导出的 api 被调用时校验 origin
// <iframe id="my-frame" src="http://www.test.com/iframe.html"></iframe>
excute("my-frame", "greet");
excute("my-frame", "sum", 1, 2)
.then((data) => console.log(data))
.catch((error) => console.error(error));
```
#### 3. 导出的 api 被调用时校验 origin
```ts

@@ -59,10 +46,10 @@ import { expose } from 'ifapi';

#### 4. 取消导出
#### 3. parent 页面调用 api
```ts
import { expose } from 'ifapi';
import { excute } from 'ifapi';
const unExpose = expose(handlers);
unExpose(); // 取消导出
// <iframe id="my-frame" src="http://www.test.com/iframe.html"></iframe>
excute("my-frame", "sum", 1, 2)
.then((data) => console.log(data))
.catch((error) => console.error(error));
```