@typexim/aics-embed-sdk 0.0.20 → 0.0.22

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/README.md CHANGED
@@ -59,3 +59,11 @@ sendMessage 1、参数:1.1 message:Message 2、返回值:void 3、说明
59
59
  ### 获取登录信息
60
60
 
61
61
  getLoginInfo 1、返回值:{userId:string}|null 2、说明:获取当前用户登录信息 3、注意:3.1 如果用户未登录,返回null
62
+
63
+ ### 获取客户信息
64
+
65
+ getCustomerInfo 1、参数:1.1 feedId:string 2、返回值:{userId:string}|null 3、说明:获取feed的客户信息 4、注意:4.1 如果feed不存在,返回null
66
+
67
+ ### 重置票据
68
+
69
+ resetVerification 1、返回值:boolean 2、说明:重置票据 3、注意:3.1 如果重置票据,返回true,
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 o=null;const s=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 o=t.wrap(n),(n=>{t.expose(e,n)})(n),!0}catch(t){return console.error("❌ iframe: 连接失败",t),!1}},a=()=>o,c=(n,r)=>{const e=a();if(!e)return()=>{};const o=t.proxy(t=>{r(t)}),s=`${Date.now().toString(36)}-${Math.random().toString(36).substring(2,8)}`;return e.subscribe(n,o,s),()=>{((t,n)=>{const r=a();r&&r.unsubscribe(t,n)})(n,s)}},i=async()=>{const t=a();if(!t)return!1;return await t.isLogin()},u=async()=>{const t=a();if(!t)return null;return await t.getLoginInfo()},p=async t=>{const n=a();if(!n)return!1;return await n.sendMessage(t)};var d,w;!function(t){t.text="text"}(d||(d={})),function(t){t.feed="feed",t.login="login"}(w||(w={}));export{d as MessageType,w as SubscribeType,u as getLoginInfo,s as initialize,i as isLogin,r as registerCrossOriginApi,p as sendMessage,c 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.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.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)}};
@@ -0,0 +1,8 @@
1
+ /**
2
+ * 获取feed的客户信息
3
+ * @param feedId
4
+ * @returns
5
+ */
6
+ export declare const getCustomerInfo: (feedId: string) => Promise<{
7
+ userId: string;
8
+ } | null>;
@@ -1,4 +1,5 @@
1
1
  export { registerCrossOriginApi } from './expose';
2
+ export * from './feed';
2
3
  export { initialize, subscribe } from './init';
3
4
  export * from './login';
4
5
  export * from './message';
@@ -10,3 +10,13 @@ export declare const isLogin: () => Promise<boolean>;
10
10
  export declare const getLoginInfo: () => Promise<{
11
11
  userId: string;
12
12
  } | null>;
13
+ /**
14
+ * 重置票据
15
+ * @returns
16
+ */
17
+ export declare const resetVerification: () => Promise<boolean>;
18
+ /**
19
+ * 获取授权票据
20
+ * @returns
21
+ */
22
+ export declare const getVerification: () => Promise<string | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@typexim/aics-embed-sdk",
3
- "version": "0.0.20",
3
+ "version": "0.0.22",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -44,4 +44,4 @@
44
44
  "access": "public",
45
45
  "registry": "https://registry.npmjs.org/"
46
46
  }
47
- }
47
+ }