@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 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()},p=async()=>{const t=a();if(!t)return!1;return await t.resetVerification()},w=async t=>{const n=a();if(!n)return!1;return await n.sendMessage(t)};var d,g;!function(t){t.text="text"}(d||(d={})),function(t){t.feed="feed",t.login="login"}(g||(g={}));export{d as MessageType,g as SubscribeType,c as getCustomerInfo,f as getLoginInfo,o as initialize,u as isLogin,r as registerCrossOriginApi,p as resetVerification,w as sendMessage,i as subscribe};
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 s=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,s.get?s:{enumerable:!0,get:function(){return e[r]}})}}),t.default=e,Object.freeze(t)}var t=e(require("comlink"));const r={},s={callMethod:async(e,...t)=>{const s=r[e];if(!s)throw new Error(`method ${e} not found`);return await s(...t)}};let n=null;const o=()=>n;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.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",s=>{"INIT_CROSS_ORIGIN_PORT"===s.data.type&&s.data.success?e({port:r.port2,isSuccess:!0}):t(new Error("初始化连接失败"))}),r.port2.addEventListener("messageerror",e=>{t(e)})}))();return n=t.wrap(e),(e=>{t.expose(s,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 s=o();if(!s)return()=>{};const n=t.proxy(e=>{r(e)}),i=`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`;return s.subscribe(e,n,i),()=>{((e,t)=>{const r=o();r&&r.unsubscribe(e,t)})(e,i)}};
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)}};
@@ -3,6 +3,6 @@
3
3
  * @param feedId
4
4
  * @returns
5
5
  */
6
- export declare const getCustomerInfo: (feedId: string) => Promise<{
6
+ export declare const getCustomerInfo: (feedId: string) => Promise<Array<{
7
7
  userId: string;
8
- } | null>;
8
+ }> | null>;
@@ -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>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typexim/aics-embed-sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",