@typexim/aics-embed-sdk 0.0.21 → 0.0.23
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/index.es.js +1 -1
- package/dist/index.js +1 -1
- package/dist/types/feed/index.d.ts +2 -2
- package/dist/types/login/index.d.ts +8 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as t from"comlink";const n={},r=(t,r)=>{n[t]=r},e={callMethod:async(t,...r)=>{const e=n[t];if(!e)throw new Error(`method ${t} not found`);return await e(...r)}};let s=null;const o=async()=>{try{const{port:n}=await(async()=>new Promise((t,n)=>{const r=new MessageChannel;window.parent.postMessage({type:"INIT_CROSS_ORIGIN_PORT"},"*",[r.port1]),r.port2.start(),r.port2.addEventListener("message",e=>{"INIT_CROSS_ORIGIN_PORT"===e.data.type&&e.data.success?t({port:r.port2,isSuccess:!0}):n(new Error("初始化连接失败"))}),r.port2.addEventListener("messageerror",t=>{n(t)})}))();return s=t.wrap(n),(n=>{t.expose(e,n)})(n),!0}catch(t){return console.error("❌ iframe: 连接失败",t),!1}},a=()=>s,i=(n,r)=>{const e=a();if(!e)return()=>{};const s=t.proxy(t=>{r(t)}),o=`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`;return e.subscribe(n,s,o),()=>{((t,n)=>{const r=a();r&&r.unsubscribe(t,n)})(n,o)}},c=async t=>{const n=a();if(!n)return null;return await n.getCustomerInfo(t)},u=async()=>{const t=a();if(!t)return!1;return await t.isLogin()},f=async()=>{const t=a();if(!t)return null;return await t.getLoginInfo()},
|
|
1
|
+
import*as t from"comlink";const n={},r=(t,r)=>{n[t]=r},e={callMethod:async(t,...r)=>{const e=n[t];if(!e)throw new Error(`method ${t} not found`);return await e(...r)}};let s=null;const o=async()=>{try{const{port:n}=await(async()=>new Promise((t,n)=>{const r=new MessageChannel;window.parent.postMessage({type:"INIT_CROSS_ORIGIN_PORT"},"*",[r.port1]),r.port2.start(),r.port2.addEventListener("message",e=>{"INIT_CROSS_ORIGIN_PORT"===e.data.type&&e.data.success?t({port:r.port2,isSuccess:!0}):n(new Error("初始化连接失败"))}),r.port2.addEventListener("messageerror",t=>{n(t)})}))();return s=t.wrap(n),(n=>{t.expose(e,n)})(n),!0}catch(t){return console.error("❌ iframe: 连接失败",t),!1}},a=()=>s,i=(n,r)=>{const e=a();if(!e)return()=>{};const s=t.proxy(t=>{r(t)}),o=`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`;return e.subscribe(n,s,o),()=>{((t,n)=>{const r=a();r&&r.unsubscribe(t,n)})(n,o)}},c=async t=>{const n=a();if(!n)return null;return await n.getCustomerInfo(t)},u=async()=>{const t=a();if(!t)return!1;return await t.isLogin()},f=async()=>{const t=a();if(!t)return null;return await t.getLoginInfo()},w=async()=>{const t=a();if(!t)return!1;return await t.resetVerification()},l=async()=>{const t=a();if(!t)return null;return await t.getAuthority()},p=async t=>{const n=a();if(!n)return!1;return await n.sendMessage(t)};var g,d;!function(t){t.text="text"}(g||(g={})),function(t){t.feed="feed",t.login="login"}(d||(d={}));export{g as MessageType,d as SubscribeType,c as getCustomerInfo,f as getLoginInfo,l as getVerification,o as initialize,u as isLogin,r as registerCrossOriginApi,w as resetVerification,p as sendMessage,i as subscribe};
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function e(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var
|
|
1
|
+
"use strict";function e(e){var t=Object.create(null);return e&&Object.keys(e).forEach(function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var t=e(require("comlink"));const r={},n={callMethod:async(e,...t)=>{const n=r[e];if(!n)throw new Error(`method ${e} not found`);return await n(...t)}};let s=null;const o=()=>s;var i;exports.MessageType=void 0,(exports.MessageType||(exports.MessageType={})).text="text",exports.SubscribeType=void 0,(i=exports.SubscribeType||(exports.SubscribeType={})).feed="feed",i.login="login",exports.getCustomerInfo=async e=>{const t=o();if(!t)return null;return await t.getCustomerInfo(e)},exports.getLoginInfo=async()=>{const e=o();if(!e)return null;return await e.getLoginInfo()},exports.getVerification=async()=>{const e=o();if(!e)return null;return await e.getAuthority()},exports.initialize=async()=>{try{const{port:e}=await(async()=>new Promise((e,t)=>{const r=new MessageChannel;window.parent.postMessage({type:"INIT_CROSS_ORIGIN_PORT"},"*",[r.port1]),r.port2.start(),r.port2.addEventListener("message",n=>{"INIT_CROSS_ORIGIN_PORT"===n.data.type&&n.data.success?e({port:r.port2,isSuccess:!0}):t(new Error("初始化连接失败"))}),r.port2.addEventListener("messageerror",e=>{t(e)})}))();return s=t.wrap(e),(e=>{t.expose(n,e)})(e),!0}catch(e){return console.error("❌ iframe: 连接失败",e),!1}},exports.isLogin=async()=>{const e=o();if(!e)return!1;return await e.isLogin()},exports.registerCrossOriginApi=(e,t)=>{r[e]=t},exports.resetVerification=async()=>{const e=o();if(!e)return!1;return await e.resetVerification()},exports.sendMessage=async e=>{const t=o();if(!t)return!1;return await t.sendMessage(e)},exports.subscribe=(e,r)=>{const n=o();if(!n)return()=>{};const s=t.proxy(e=>{r(e)}),i=`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`;return n.subscribe(e,s,i),()=>{((e,t)=>{const r=o();r&&r.unsubscribe(e,t)})(e,i)}};
|
|
@@ -15,3 +15,11 @@ export declare const getLoginInfo: () => Promise<{
|
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
17
|
export declare const resetVerification: () => Promise<boolean>;
|
|
18
|
+
/**
|
|
19
|
+
* 获取授权票据
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export declare const getVerification: () => Promise<{
|
|
23
|
+
token: string;
|
|
24
|
+
expires_at: number;
|
|
25
|
+
} | null>;
|