Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bnfe/lark-utils

Package Overview
Dependencies
Maintainers
5
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bnfe/lark-utils - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

2

dist/lark-utils.cjs.js

@@ -1,1 +0,1 @@

"use strict";var t=require("axios");function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){void 0===t&&(t=[]);var e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src}));return t.filter((function(t){return e.includes((n=t).includes("http")?n:"".concat(location.protocol).concat(n));var n})).length===t.length?Promise.resolve():Promise.all(t.map((function(t){return function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))}(t)})))},o=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],i=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],a={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},c=function(e){return t.create({baseURL:a[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},s=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,s){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return s(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),s("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,o){var a=this;return new Promise((function(s,u){return e(a,void 0,void 0,(function(){var a=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(r){return e(a,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(o)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:r.code}})];case 1:return e=n.sent(),s(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,o,a){var c=this;return new Promise((function(s,u){return e(c,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,o,a)];case 2:return n.sent(),[4,this.baseLogin(t,o)];case 3:return e=n.sent(),s(e),[3,5];case 4:return c=n.sent(),u("[object Error]"===Object.prototype.toString.call(c)?null==c?void 0:c.message:JSON.stringify(c)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,i,a,c;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,r(o)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),i="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:i,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),c=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(i,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",c,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",c),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),u=new s;"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=u),module.exports=u;
"use strict";var t=require("axios");function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))},o=function(t){return void 0===t&&(t=[]),e(void 0,void 0,void 0,(function(){var e,o,i,a,c;return n(this,(function(n){switch(n.label){case 0:e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src})),o=t.filter((function(t){return!e.includes(function(t){return t.includes("http")?t:"".concat(location.protocol).concat(t)}(t))})),i=0,a=o,n.label=1;case 1:return i<a.length?(c=a[i],[4,r(c)]):[3,4];case 2:n.sent(),n.label=3;case 3:return i++,[3,1];case 4:return[2,Promise.resolve()]}}))}))},i=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],a=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],c={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},s=function(e){return t.create({baseURL:c[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},u=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,c){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return c(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),c("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,r){var i=this;return new Promise((function(c,u){return e(i,void 0,void 0,(function(){var i=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(o){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(r)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:o.code}})];case 1:return e=n.sent(),c(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,r,i){var c=this;return new Promise((function(s,u){return e(c,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,r,i)];case 2:return n.sent(),[4,this.baseLogin(t,r)];case 3:return e=n.sent(),s(e),[3,5];case 4:return c=n.sent(),u("[object Error]"===Object.prototype.toString.call(c)?null==c?void 0:c.message:JSON.stringify(c)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,r,a,c;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,o(i)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),r="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:r,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),c=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(r,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",c,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",c),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),d=new u;"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=d),module.exports=d;

@@ -1,1 +0,1 @@

import t from"axios";function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){void 0===t&&(t=[]);var e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src}));return t.filter((function(t){return e.includes((n=t).includes("http")?n:"".concat(location.protocol).concat(n));var n})).length===t.length?Promise.resolve():Promise.all(t.map((function(t){return function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))}(t)})))},o=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],i=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],a={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},c=function(e){return t.create({baseURL:a[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},s=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,s){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return s(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),s("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,o){var a=this;return new Promise((function(s,u){return e(a,void 0,void 0,(function(){var a=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(r){return e(a,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(o)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:r.code}})];case 1:return e=n.sent(),s(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,o,a){var c=this;return new Promise((function(s,u){return e(c,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,o,a)];case 2:return n.sent(),[4,this.baseLogin(t,o)];case 3:return e=n.sent(),s(e),[3,5];case 4:return c=n.sent(),u("[object Error]"===Object.prototype.toString.call(c)?null==c?void 0:c.message:JSON.stringify(c)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,i,a,c;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,r(o)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),i="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:i,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),c=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(i,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",c,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",c),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),u=new s;"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=u);export{u as default};
import t from"axios";function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,c)}s((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:c(0),throw:c(1),return:c(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){return function(c){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,c[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&c[0]?r.return:c[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,c[1])).done)return o;switch(r=0,o&&(c=[2&c[0],o.value]),c[0]){case 0:case 1:o=c;break;case 4:return a.label++,{value:c[1],done:!1};case 5:a.label++,r=c[1],c=[0];continue;case 7:c=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==c[0]&&2!==c[0])){a=0;continue}if(3===c[0]&&(!o||c[1]>o[0]&&c[1]<o[3])){a.label=c[1];break}if(6===c[0]&&a.label<o[1]){a.label=o[1],o=c;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(c);break}o[2]&&a.ops.pop(),a.trys.pop();continue}c=e.call(t,a)}catch(t){c=[6,t],r=0}finally{n=o=0}if(5&c[0])throw c[1];return{value:c[0]?c[1]:void 0,done:!0}}([c,s])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))},o=function(t){return void 0===t&&(t=[]),e(void 0,void 0,void 0,(function(){var e,o,i,a,c;return n(this,(function(n){switch(n.label){case 0:e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src})),o=t.filter((function(t){return!e.includes(function(t){return t.includes("http")?t:"".concat(location.protocol).concat(t)}(t))})),i=0,a=o,n.label=1;case 1:return i<a.length?(c=a[i],[4,r(c)]):[3,4];case 2:n.sent(),n.label=3;case 3:return i++,[3,1];case 4:return[2,Promise.resolve()]}}))}))},i=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],a=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],c={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},s=function(e){return t.create({baseURL:c[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},u=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,c){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return c(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),c("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,r){var i=this;return new Promise((function(c,u){return e(i,void 0,void 0,(function(){var i=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(o){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(r)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:o.code}})];case 1:return e=n.sent(),c(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,r,i){var c=this;return new Promise((function(s,u){return e(c,void 0,void 0,(function(){var e,c;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,r,i)];case 2:return n.sent(),[4,this.baseLogin(t,r)];case 3:return e=n.sent(),s(e),[3,5];case 4:return c=n.sent(),u("[object Error]"===Object.prototype.toString.call(c)?null==c?void 0:c.message:JSON.stringify(c)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,r,a,c;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,o(i)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),r="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:r,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),c=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(r,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",c,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",c),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),d=new u;"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=d);export{d as default};

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).larkSDK=e(t.axios)}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){void 0===t&&(t=[]);var e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src}));return t.filter((function(t){return e.includes((n=t).includes("http")?n:"".concat(location.protocol).concat(n));var n})).length===t.length?Promise.resolve():Promise.all(t.map((function(t){return function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))}(t)})))},o=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],i=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],a={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},s=function(e){return t.create({baseURL:a[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},c=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,c){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return c(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),c("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,o){var a=this;return new Promise((function(c,u){return e(a,void 0,void 0,(function(){var a=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(r){return e(a,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,s(o)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:r.code}})];case 1:return e=n.sent(),c(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,o,a){var s=this;return new Promise((function(c,u){return e(s,void 0,void 0,(function(){var e,s;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,r(i)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,o,a)];case 2:return n.sent(),[4,this.baseLogin(t,o)];case 3:return e=n.sent(),c(e),[3,5];case 4:return s=n.sent(),u("[object Error]"===Object.prototype.toString.call(s)?null==s?void 0:s.message:JSON.stringify(s)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,i,a,s;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,r(o)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),i="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:i,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),s=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(i,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",s,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",s),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),u=new c;return"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=u),u}));
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("axios")):"function"==typeof define&&define.amd?define(["axios"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).larkSDK=e(t.axios)}(this,(function(t){"use strict";function e(t,e,n,r){return new(n||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}))}function n(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(s){return function(c){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;i&&(i=0,s[0]&&(a=0)),a;)try{if(n=1,r&&(o=2&s[0]?r.return:s[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,s[1])).done)return o;switch(r=0,o&&(s=[2&s[0],o.value]),s[0]){case 0:case 1:o=s;break;case 4:return a.label++,{value:s[1],done:!1};case 5:a.label++,r=s[1],s=[0];continue;case 7:s=a.ops.pop(),a.trys.pop();continue;default:if(!(o=a.trys,(o=o.length>0&&o[o.length-1])||6!==s[0]&&2!==s[0])){a=0;continue}if(3===s[0]&&(!o||s[1]>o[0]&&s[1]<o[3])){a.label=s[1];break}if(6===s[0]&&a.label<o[1]){a.label=o[1],o=s;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(s);break}o[2]&&a.ops.pop(),a.trys.pop();continue}s=e.call(t,a)}catch(t){s=[6,t],r=0}finally{n=o=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,c])}}}"function"==typeof SuppressedError&&SuppressedError;var r=function(t){return new Promise((function(e,n){var r=document.createElement("script");r.src=t,r.onload=e,r.onerror=n,document.head.appendChild(r)}))},o=function(t){return void 0===t&&(t=[]),e(void 0,void 0,void 0,(function(){var e,o,i,a,s;return n(this,(function(n){switch(n.label){case 0:e=Array.from(document.getElementsByTagName("script")).map((function(t){return t.src})),o=t.filter((function(t){return!e.includes(function(t){return t.includes("http")?t:"".concat(location.protocol).concat(t)}(t))})),i=0,a=o,n.label=1;case 1:return i<a.length?(s=a[i],[4,r(s)]):[3,4];case 2:n.sent(),n.label=3;case 3:return i++,[3,1];case 4:return[2,Promise.resolve()]}}))}))},i=["//lf-package-cn.feishucdn.com/obj/feishu-static/lark/passport/qrcode/LarkSSOSDKWebQRCode-1.0.3.js"],a=["//lf1-cdn-tos.bytegoofy.com/goofy/lark/op/h5-js-sdk-1.5.19.js"],s={dev:{url:"https://wx-auth-beta.banu.cn"},prod:{url:"https://wx-auth.banu.cn"}},c=function(e){return t.create({baseURL:s[e].url,timeout:5e3,headers:{Accept:"application/json","Content-Type":"application/json; charset=utf-8"}})},u=function(){function t(){this.QREleId="lark-code",this.QRConfig={}}return t.prototype.injectConfig=function(t,r,o){var i=this;return new Promise((function(a,s){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(r)({url:"/api/fsMandate/sign",method:"post",data:{appId:t,url:encodeURI(location.href.split("#")[0])}})];case 1:if(200!==(e=n.sent().data).code)throw new Error("config注入失败:接口".concat(e.code));return window.h5sdk.config({appId:e.data.appId,timestamp:e.data.timestamp,nonceStr:e.data.nonceStr,signature:e.data.signature,jsApiList:o,onSuccess:function(t){return a(JSON.stringify(t))},onFail:function(t){return s(JSON.stringify(t))}}),[3,3];case 2:return i=n.sent(),s("[object Error]"===Object.prototype.toString.call(i)?null==i?void 0:i.message:JSON.stringify(i)),[3,3];case 3:return[2]}}))}))}))},t.prototype.baseLogin=function(t,r){var i=this;return new Promise((function(s,u){return e(i,void 0,void 0,(function(){var i=this;return n(this,(function(d){switch(d.label){case 0:if(!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(d.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return window.h5sdk.ready((function(){window.tt.requestAuthCode({appId:t,success:function(o){return e(i,void 0,void 0,(function(){var e,i;return n(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,c(r)({url:"/api/fsMandate/userToken",method:"post",data:{appId:t,code:o.code}})];case 1:return e=n.sent(),s(e.data),[3,3];case 2:return i=n.sent(),u(JSON.stringify(i)),[3,3];case 3:return[2]}}))}))},fail:function(t){u(JSON.stringify(t))}})})),window.h5sdk.error((function(t){u(JSON.stringify(t))})),[2]}}))}))}))},t.prototype.login=function(t,r,i){var s=this;return new Promise((function(c,u){return e(s,void 0,void 0,(function(){var e,s;return n(this,(function(n){switch(n.label){case 0:if(n.trys.push([0,4,,5]),!t)throw new Error("appId不可为空");return[4,o(a)];case 1:if(n.sent(),!(null===window||void 0===window?void 0:window.h5sdk))throw new Error("invalid h5sdk");return[4,this.injectConfig(t,r,i)];case 2:return n.sent(),[4,this.baseLogin(t,r)];case 3:return e=n.sent(),c(e),[3,5];case 4:return s=n.sent(),u("[object Error]"===Object.prototype.toString.call(s)?null==s?void 0:s.message:JSON.stringify(s)),[3,5];case 5:return[2]}}))}))}))},t.prototype.getQRCode=function(t){return void 0===t&&(t={}),e(this,void 0,void 0,(function(){var e,r,a,s;return n(this,(function(n){switch(n.label){case 0:if(!t.appId)throw new Error("appId不可为空");return this.QRConfig=t,[4,o(i)];case 1:return n.sent(),this.resetQRCode(),e=Object.entries({client_id:t.appId,redirect_uri:encodeURIComponent(location.href),response_type:"code",state:"STATE"}).map((function(t){var e=t[0],n=t[1];return"".concat(e,"=").concat(n)})).join("&"),r="https://passport.feishu.cn/suite/passport/oauth/authorize?".concat(e),a=window.QRLogin({goto:r,id:t.id||this.QREleId,width:t.width||"260",height:t.height||"260",style:"border-width:0;"}),s=function(t){if(a.matchOrigin(t.origin)&&a.matchData(t.data)){var e=t.data.tmp_code;window.location.href="".concat(r,"&tmp_code=").concat(e)}},void 0!==window.addEventListener?window.addEventListener("message",s,!1):void 0!==window.attachEvent&&window.attachEvent("onmessage",s),[2]}}))}))},t.prototype.resetQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);if(t&&t.parentNode){var e=document.createElement("div");e.id=this.QRConfig.id||this.QREleId,t.parentNode.replaceChild(e,t)}},t.prototype.clearQRCode=function(){var t=document.getElementById(this.QRConfig.id||this.QREleId);t&&t.parentNode&&t.parentNode.removeChild(t)},t}(),d=new u;return"undefined"!=typeof window&&(window.larkSDK?console.warn("window.larkSDK already exists"):window.larkSDK=d),d}));
{
"name": "@bnfe/lark-utils",
"version": "1.0.11",
"version": "1.0.12",
"description": "lark-utils",

@@ -5,0 +5,0 @@ "main": "dist/lark-utils.cjs.js",

@@ -48,2 +48,15 @@ ## @bnfe/lark-utils

> 也可以在window上获取larkSDK的方法
### 飞书扫码登录
[飞书二维码 SDK 接入文档](https://open.feishu.cn/document/common-capabilities/sso/web-application-sso/qr-sdk-documentation)
```js
/**
* @param {Record<string, any>}
* @param appId 应用id
* @param id 元素id(默认lark-code)
* @param width 二维码宽度(默认260)
* @param height 二维码高度(默认260)
*/
larkSDK.getQRCode({appId: "xxx"})
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc