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

@liff/permission

Package Overview
Dependencies
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@liff/permission - npm Package Compare versions

Comparing version 2.22.2 to 2.22.3

2

lib/index.cjs.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("@liff/consts"),t=require("@liff/util"),n=require("@liff/store"),i=require("@liff/server-api"),o=require("@liff/is-in-client"),s=require("@liff/sub-window"),a=require("@liff/is-api-available"),c=require("@liff/use");function u(o){return e.__awaiter(this,void 0,void 0,(function(){var s,a,c,u,f,l,h;return e.__generator(this,(function(d){switch(d.label){case 0:return function(e){if(!r.PERMISSION_NAMES.includes(e))throw t.createLiffError(r.INVALID_ARGUMENT,"Unexpected permission name.");var i=n.getContext();return!!(null==i?void 0:i.scope.includes(e))}(o)?(s=n.getAccessToken())?[4,i.verifyAccessToken(s)]:[3,2]:[2,{state:"unavailable"}];case 1:a=d.sent(),c=unescape(a.scope).split(" ");try{for(u=e.__values(c),f=u.next();!f.done;f=u.next())if(f.value.includes(o))return[2,{state:"granted"}]}catch(p){l={error:p}}finally{try{f&&!f.done&&(h=u.return)&&h.call(u)}finally{if(l)throw l.error}}return[2,{state:"prompt"}];case 2:throw t.createLiffError(r.UNAUTHORIZED,"LiffId is not found.")}}))}))}function f(){var e,r,t=n.getContext();return!!t&&("square_chat"!==t.type&&(a.isApiAvailable("skipChannelVerificationScreen")||!o.isInClient()&&(null===(r=null===(e=t.availability)||void 0===e?void 0:e.skipChannelVerificationScreen)||void 0===r?void 0:r.permission)))}function l(){var e=n.getConfig().liffId;if(e)return i.fetch("".concat(i.getEndPoint("unauthorizedPermissions"),"?liffId=").concat(e),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(n.getAccessToken())}});throw t.createLiffError(r.UNAUTHORIZED,"liffId is required")}var h,d=s.subWindow.on,p=s.subWindow.off,v=s.subWindow.open,_=function(){function i(n,i){var o=this;this.onSubmit=function(n){var i=n.newAccessToken,s=n.ICA_ERROR;return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return i?this.resolve({newAccessToken:i}):s&&this.reject(t.createLiffError(r.UNKNOWN,s)),this.teardown(),[2]}))}))},this.onClose=function(){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(t.createLiffError(r.UNAUTHORIZED,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onCancel=function(){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(t.createLiffError(r.UNAUTHORIZED,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onError=function(r){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(r),this.teardown(),[2]}))}))},this.resolve=n,this.reject=i,this.setup()}return i.prototype.setup=function(){d("submit",this.onSubmit),d("close",this.onClose),d("cancel",this.onCancel),d("error",this.onError)},i.prototype.teardown=function(){p("submit",this.onSubmit),p("close",this.onClose),p("cancel",this.onCancel),p("error",this.onError),h=void 0},i.prototype.open=function(){var e=n.getConfig().liffId;e?v({url:"".concat("https://liff.line.me/1656032314-Xgrw5Pmk"),appData:{liffId:e,channelId:t.extractChannelIdFromLiffId(e),accessToken:n.getAccessToken()}}):this.reject(t.createLiffError(r.UNAUTHORIZED,"liffId is required"))},i}();function w(){return e.__awaiter(this,void 0,void 0,(function(){var i,s;return e.__generator(this,(function(e){switch(e.label){case 0:if(!f())throw t.createLiffError(r.FORBIDDEN,"SkipChannelVerificationScreen is unavailable.");return h&&h.teardown(),[4,l()];case 1:return i=e.sent(),(o.isInClient()?i:i.filter((function(e){return"chat_message.write"!==e}))).length>0?[4,new Promise((function(e,r){(h=new _(e,r)).open()}))]:[3,3];case 2:return s=e.sent().newAccessToken,n.setAccessToken(s),[3,4];case 3:throw t.createLiffError(r.FORBIDDEN,"All permissions have already been approved.");case 4:return[2]}}))}))}var g=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return e.__extends(t,r),Object.defineProperty(t.prototype,"name",{get:function(){return"permission"},enumerable:!1,configurable:!0}),t.prototype.install=function(){return{query:u,requestAll:w}},t}(c.LiffModule),m=new g;exports.PermissionModule=g,exports.attachChecker=function(n,i){var s=this;return function(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return e.__awaiter(s,void 0,void 0,(function(){var s,c,l;return e.__generator(this,(function(h){switch(h.label){case 0:return s=(a.length>0?a[a.length-1]:{}).ignorePermissionCheck,c=void 0!==s&&s,[4,u(i)];case 1:if("unavailable"!==(l=h.sent().state))return[3,2];throw t.createLiffError(r.FORBIDDEN,"The permission is not in LIFF app scope.");case 2:return"prompt"!==l||!f()||c||!o.isInClient()&&"chat_message.write"===i?[3,4]:[4,w()];case 3:return h.sent(),[3,5];case 4:c&&a.pop(),h.label=5;case 5:return[4,n.apply(void 0,e.__spreadArray([],e.__read(a),!1))];case 6:return[2,h.sent()]}}))}))}},exports.module=m;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("tslib"),r=require("@liff/consts"),t=require("@liff/util"),n=require("@liff/store"),i=require("@liff/server-api"),o=require("@liff/is-in-client"),s=require("@liff/sub-window"),a=require("@liff/is-api-available"),c=require("@liff/use");function u(o){return e.__awaiter(this,void 0,void 0,(function(){var s,a,c,u,f,l,h;return e.__generator(this,(function(d){switch(d.label){case 0:return function(e){if(!r.PERMISSION_NAMES.includes(e))throw t.createLiffError(r.INVALID_ARGUMENT,"Unexpected permission name.");var i=n.getContext();return!!(null==i?void 0:i.scope.includes(e))}(o)?(s=n.getAccessToken())?[4,i.verifyAccessToken(s)]:[3,2]:[2,{state:"unavailable"}];case 1:a=d.sent(),c=unescape(a.scope).split(" ");try{for(u=e.__values(c),f=u.next();!f.done;f=u.next())if(f.value.includes(o))return[2,{state:"granted"}]}catch(p){l={error:p}}finally{try{f&&!f.done&&(h=u.return)&&h.call(u)}finally{if(l)throw l.error}}return[2,{state:"prompt"}];case 2:throw t.createLiffError(r.UNAUTHORIZED,"LiffId is not found.")}}))}))}function f(){var e,r,t=n.getContext();return!!t&&("square_chat"!==t.type&&(a.isApiAvailable("skipChannelVerificationScreen")||!o.isInClient()&&(null===(r=null===(e=t.availability)||void 0===e?void 0:e.skipChannelVerificationScreen)||void 0===r?void 0:r.permission)))}function l(){var e=n.getConfig().liffId;if(e)return i.fetch("".concat(i.getEndPoint("unauthorizedPermissions"),"?liffId=").concat(e),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(n.getAccessToken())}});throw t.createLiffError(r.UNAUTHORIZED,"liffId is required")}var h,d=s.subWindow.on,p=s.subWindow.off,v=s.subWindow.open,_=function(){function i(n,i){var o=this;this.onSubmit=function(n){var i=n.newAccessToken,s=n.ICA_ERROR;return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return i?this.resolve({newAccessToken:i}):s&&this.reject(t.createLiffError(r.UNKNOWN,s)),this.teardown(),[2]}))}))},this.onClose=function(){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(t.createLiffError(r.UNAUTHORIZED,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onCancel=function(){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(t.createLiffError(r.UNAUTHORIZED,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onError=function(r){return e.__awaiter(o,void 0,void 0,(function(){return e.__generator(this,(function(e){return this.reject(r),this.teardown(),[2]}))}))},this.resolve=n,this.reject=i,this.setup()}return i.prototype.setup=function(){d("submit",this.onSubmit),d("close",this.onClose),d("cancel",this.onCancel),d("error",this.onError)},i.prototype.teardown=function(){p("submit",this.onSubmit),p("close",this.onClose),p("cancel",this.onCancel),p("error",this.onError),h=void 0},i.prototype.open=function(e){var i=n.getConfig().liffId;i?v({url:"".concat("https://liff.line.me/1656032314-Xgrw5Pmk"),appData:{liffId:i,channelId:t.extractChannelIdFromLiffId(i),accessToken:n.getAccessToken()},onBeforeTransition:e}).catch(this.reject):this.reject(t.createLiffError(r.UNAUTHORIZED,"liffId is required"))},i}();function w(){return e.__awaiter(this,void 0,void 0,(function(){var i,s,a=this;return e.__generator(this,(function(c){switch(c.label){case 0:if(!f())throw t.createLiffError(r.FORBIDDEN,"SkipChannelVerificationScreen is unavailable.");return h&&h.teardown(),i=function(){return e.__awaiter(a,void 0,void 0,(function(){var n;return e.__generator(this,(function(e){switch(e.label){case 0:return[4,l()];case 1:if(n=e.sent(),(o.isInClient()?n:n.filter((function(e){return"chat_message.write"!==e}))).length<=0)throw t.createLiffError(r.FORBIDDEN,"All permissions have already been approved.");return[2]}}))}))},[4,new Promise((function(e,r){(h=new _(e,r)).open(i)}))];case 1:return s=c.sent().newAccessToken,n.setAccessToken(s),[2]}}))}))}var g=function(r){function t(){return null!==r&&r.apply(this,arguments)||this}return e.__extends(t,r),Object.defineProperty(t.prototype,"name",{get:function(){return"permission"},enumerable:!1,configurable:!0}),t.prototype.install=function(){return{query:u,requestAll:w}},t}(c.LiffModule),m=new g;exports.PermissionModule=g,exports.attachChecker=function(n,i){var s=this;return function(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return e.__awaiter(s,void 0,void 0,(function(){var s,c,l;return e.__generator(this,(function(h){switch(h.label){case 0:return s=(a.length>0?a[a.length-1]:{}).ignorePermissionCheck,c=void 0!==s&&s,[4,u(i)];case 1:if("unavailable"!==(l=h.sent().state))return[3,2];throw t.createLiffError(r.FORBIDDEN,"The permission is not in LIFF app scope.");case 2:return"prompt"!==l||!f()||c||!o.isInClient()&&"chat_message.write"===i?[3,4]:[4,w()];case 3:return h.sent(),[3,5];case 4:c&&a.pop(),h.label=5;case 5:return[4,n.apply(void 0,e.__spreadArray([],e.__read(a),!1))];case 6:return[2,h.sent()]}}))}))}},exports.module=m;

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

import{__awaiter as e,__generator as t,__values as n,__spreadArray as r,__read as i,__extends as o}from"tslib";import{PERMISSION_NAMES as s,INVALID_ARGUMENT as a,UNAUTHORIZED as c,FORBIDDEN as u,UNKNOWN as f}from"@liff/consts";import{createLiffError as l,extractChannelIdFromLiffId as h}from"@liff/util";import{getContext as p,getAccessToken as d,getConfig as v,setAccessToken as m}from"@liff/store";import{verifyAccessToken as w,fetch as b,getEndPoint as y}from"@liff/server-api";import{isInClient as g}from"@liff/is-in-client";import{subWindow as C}from"@liff/sub-window";import{isApiAvailable as I}from"@liff/is-api-available";import{LiffModule as j}from"@liff/use";function k(r){return e(this,void 0,void 0,(function(){var e,i,o,u,f,h,v;return t(this,(function(t){switch(t.label){case 0:return function(e){if(!s.includes(e))throw l(a,"Unexpected permission name.");var t=p();return!!(null==t?void 0:t.scope.includes(e))}(r)?(e=d())?[4,w(e)]:[3,2]:[2,{state:"unavailable"}];case 1:i=t.sent(),o=unescape(i.scope).split(" ");try{for(u=n(o),f=u.next();!f.done;f=u.next())if(f.value.includes(r))return[2,{state:"granted"}]}catch(m){h={error:m}}finally{try{f&&!f.done&&(v=u.return)&&v.call(u)}finally{if(h)throw h.error}}return[2,{state:"prompt"}];case 2:throw l(c,"LiffId is not found.")}}))}))}function A(){var e,t,n=p();return!!n&&("square_chat"!==n.type&&(I("skipChannelVerificationScreen")||!g()&&(null===(t=null===(e=n.availability)||void 0===e?void 0:e.skipChannelVerificationScreen)||void 0===t?void 0:t.permission)))}function S(){var e=v().liffId;if(e)return b("".concat(y("unauthorizedPermissions"),"?liffId=").concat(e),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(d())}});throw l(c,"liffId is required")}var T,q=C.on,P=C.off,x=C.open,E=function(){function n(n,r){var i=this;this.onSubmit=function(n){var r=n.newAccessToken,o=n.ICA_ERROR;return e(i,void 0,void 0,(function(){return t(this,(function(e){return r?this.resolve({newAccessToken:r}):o&&this.reject(l(f,o)),this.teardown(),[2]}))}))},this.onClose=function(){return e(i,void 0,void 0,(function(){return t(this,(function(e){return this.reject(l(c,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onCancel=function(){return e(i,void 0,void 0,(function(){return t(this,(function(e){return this.reject(l(c,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onError=function(n){return e(i,void 0,void 0,(function(){return t(this,(function(e){return this.reject(n),this.teardown(),[2]}))}))},this.resolve=n,this.reject=r,this.setup()}return n.prototype.setup=function(){q("submit",this.onSubmit),q("close",this.onClose),q("cancel",this.onCancel),q("error",this.onError)},n.prototype.teardown=function(){P("submit",this.onSubmit),P("close",this.onClose),P("cancel",this.onCancel),P("error",this.onError),T=void 0},n.prototype.open=function(){var e=v().liffId;e?x({url:"".concat("https://liff.line.me/1656032314-Xgrw5Pmk"),appData:{liffId:e,channelId:h(e),accessToken:d()}}):this.reject(l(c,"liffId is required"))},n}();function _(){return e(this,void 0,void 0,(function(){var e,n;return t(this,(function(t){switch(t.label){case 0:if(!A())throw l(u,"SkipChannelVerificationScreen is unavailable.");return T&&T.teardown(),[4,S()];case 1:return e=t.sent(),(g()?e:e.filter((function(e){return"chat_message.write"!==e}))).length>0?[4,new Promise((function(e,t){(T=new E(e,t)).open()}))]:[3,3];case 2:return n=t.sent().newAccessToken,m(n),[3,4];case 3:throw l(u,"All permissions have already been approved.");case 4:return[2]}}))}))}function R(n,o){var s=this;return function(){for(var a=[],c=0;c<arguments.length;c++)a[c]=arguments[c];return e(s,void 0,void 0,(function(){var e,s,c;return t(this,(function(t){switch(t.label){case 0:return e=(a.length>0?a[a.length-1]:{}).ignorePermissionCheck,s=void 0!==e&&e,[4,k(o)];case 1:if("unavailable"!==(c=t.sent().state))return[3,2];throw l(u,"The permission is not in LIFF app scope.");case 2:return"prompt"!==c||!A()||s||!g()&&"chat_message.write"===o?[3,4]:[4,_()];case 3:return t.sent(),[3,5];case 4:s&&a.pop(),t.label=5;case 5:return[4,n.apply(void 0,r([],i(a),!1))];case 6:return[2,t.sent()]}}))}))}}var V=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return o(t,e),Object.defineProperty(t.prototype,"name",{get:function(){return"permission"},enumerable:!1,configurable:!0}),t.prototype.install=function(){return{query:k,requestAll:_}},t}(j),z=new V;export{V as PermissionModule,R as attachChecker,z as module};
import{__awaiter as t,__generator as n,__values as e,__spreadArray as r,__read as i,__extends as o}from"tslib";import{PERMISSION_NAMES as s,INVALID_ARGUMENT as c,UNAUTHORIZED as a,FORBIDDEN as u,UNKNOWN as f}from"@liff/consts";import{createLiffError as l,extractChannelIdFromLiffId as h}from"@liff/util";import{getContext as p,getAccessToken as d,getConfig as v,setAccessToken as m}from"@liff/store";import{verifyAccessToken as w,fetch as b,getEndPoint as y}from"@liff/server-api";import{isInClient as g}from"@liff/is-in-client";import{subWindow as C}from"@liff/sub-window";import{isApiAvailable as j}from"@liff/is-api-available";import{LiffModule as I}from"@liff/use";function k(r){return t(this,void 0,void 0,(function(){var t,i,o,u,f,h,v;return n(this,(function(n){switch(n.label){case 0:return function(t){if(!s.includes(t))throw l(c,"Unexpected permission name.");var n=p();return!!(null==n?void 0:n.scope.includes(t))}(r)?(t=d())?[4,w(t)]:[3,2]:[2,{state:"unavailable"}];case 1:i=n.sent(),o=unescape(i.scope).split(" ");try{for(u=e(o),f=u.next();!f.done;f=u.next())if(f.value.includes(r))return[2,{state:"granted"}]}catch(m){h={error:m}}finally{try{f&&!f.done&&(v=u.return)&&v.call(u)}finally{if(h)throw h.error}}return[2,{state:"prompt"}];case 2:throw l(a,"LiffId is not found.")}}))}))}function A(){var t,n,e=p();return!!e&&("square_chat"!==e.type&&(j("skipChannelVerificationScreen")||!g()&&(null===(n=null===(t=e.availability)||void 0===t?void 0:t.skipChannelVerificationScreen)||void 0===n?void 0:n.permission)))}function S(){var t=v().liffId;if(t)return b("".concat(y("unauthorizedPermissions"),"?liffId=").concat(t),{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(d())}});throw l(a,"liffId is required")}var T,q=C.on,P=C.off,x=C.open,E=function(){function e(e,r){var i=this;this.onSubmit=function(e){var r=e.newAccessToken,o=e.ICA_ERROR;return t(i,void 0,void 0,(function(){return n(this,(function(t){return r?this.resolve({newAccessToken:r}):o&&this.reject(l(f,o)),this.teardown(),[2]}))}))},this.onClose=function(){return t(i,void 0,void 0,(function(){return n(this,(function(t){return this.reject(l(a,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onCancel=function(){return t(i,void 0,void 0,(function(){return n(this,(function(t){return this.reject(l(a,"user didn't allow the agreement")),this.teardown(),[2]}))}))},this.onError=function(e){return t(i,void 0,void 0,(function(){return n(this,(function(t){return this.reject(e),this.teardown(),[2]}))}))},this.resolve=e,this.reject=r,this.setup()}return e.prototype.setup=function(){q("submit",this.onSubmit),q("close",this.onClose),q("cancel",this.onCancel),q("error",this.onError)},e.prototype.teardown=function(){P("submit",this.onSubmit),P("close",this.onClose),P("cancel",this.onCancel),P("error",this.onError),T=void 0},e.prototype.open=function(t){var n=v().liffId;n?x({url:"".concat("https://liff.line.me/1656032314-Xgrw5Pmk"),appData:{liffId:n,channelId:h(n),accessToken:d()},onBeforeTransition:t}).catch(this.reject):this.reject(l(a,"liffId is required"))},e}();function _(){return t(this,void 0,void 0,(function(){var e,r,i=this;return n(this,(function(o){switch(o.label){case 0:if(!A())throw l(u,"SkipChannelVerificationScreen is unavailable.");return T&&T.teardown(),e=function(){return t(i,void 0,void 0,(function(){var t;return n(this,(function(n){switch(n.label){case 0:return[4,S()];case 1:if(t=n.sent(),(g()?t:t.filter((function(t){return"chat_message.write"!==t}))).length<=0)throw l(u,"All permissions have already been approved.");return[2]}}))}))},[4,new Promise((function(t,n){(T=new E(t,n)).open(e)}))];case 1:return r=o.sent().newAccessToken,m(r),[2]}}))}))}function R(e,o){var s=this;return function(){for(var c=[],a=0;a<arguments.length;a++)c[a]=arguments[a];return t(s,void 0,void 0,(function(){var t,s,a;return n(this,(function(n){switch(n.label){case 0:return t=(c.length>0?c[c.length-1]:{}).ignorePermissionCheck,s=void 0!==t&&t,[4,k(o)];case 1:if("unavailable"!==(a=n.sent().state))return[3,2];throw l(u,"The permission is not in LIFF app scope.");case 2:return"prompt"!==a||!A()||s||!g()&&"chat_message.write"===o?[3,4]:[4,_()];case 3:return n.sent(),[3,5];case 4:s&&c.pop(),n.label=5;case 5:return[4,e.apply(void 0,r([],i(c),!1))];case 6:return[2,n.sent()]}}))}))}}var V=function(t){function n(){return null!==t&&t.apply(this,arguments)||this}return o(n,t),Object.defineProperty(n.prototype,"name",{get:function(){return"permission"},enumerable:!1,configurable:!0}),n.prototype.install=function(){return{query:k,requestAll:_}},n}(I),z=new V;export{V as PermissionModule,R as attachChecker,z as module};
{
"name": "@liff/permission",
"version": "2.22.2",
"version": "2.22.3",
"description": "@liff/permission",

@@ -34,11 +34,11 @@ "license": "SEE LICENSE IN README.md",

"dependencies": {
"@liff/consts": "2.22.2",
"@liff/is-api-available": "2.22.2",
"@liff/is-in-client": "2.22.2",
"@liff/server-api": "2.22.2",
"@liff/store": "2.22.2",
"@liff/sub-window": "2.22.2",
"@liff/use": "2.22.2",
"@liff/util": "2.22.2"
"@liff/consts": "2.22.3",
"@liff/is-api-available": "2.22.3",
"@liff/is-in-client": "2.22.3",
"@liff/server-api": "2.22.3",
"@liff/store": "2.22.3",
"@liff/sub-window": "2.22.3",
"@liff/use": "2.22.3",
"@liff/util": "2.22.3"
}
}
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