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

@liff/util

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/util - npm Package Compare versions

Comparing version 2.23.1 to 2.23.2

7

lib/errors.d.ts

@@ -8,8 +8,11 @@ import { UNAUTHORIZED, INVALID_ARGUMENT, INIT_FAILED, FORBIDDEN, INVALID_CONFIG, INVALID_ID_TOKEN, CREATE_SUBWINDOW_FAILED, EXCEPTION_IN_SUBWINDOW } from '@liff/consts';

type UnpublishedErrorCode = 'LIFF.STATE_INVALID' | AdErrorValue;
type ErrorOptions = {
cause?: unknown;
};
export type ErrorCode = PublicErrorCode | InternalErrorCode | UnpublishedErrorCode;
export declare class LiffError extends Error {
code: string | number;
constructor(code: ErrorCode, message: string);
constructor(code: ErrorCode, message: string, options: ErrorOptions);
}
export declare function createLiffError(code: ErrorCode, message?: string): LiffError;
export declare function createLiffError(code: ErrorCode, message?: string, options?: ErrorOptions): LiffError;
export {};

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@liff/logger"),e=require("tslib"),t=require("@liff/consts");function n(r){return window.atob(r.replace(/-/g,"+").replace(/_/g,"/"))}var o={decode:n,encode:function(r){return window.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},decodeUnicode:function(r){var e=n(r).split("").map((function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)})).join("");return decodeURIComponent(e)}};function i(r){return parseInt(r,16)}var a={get:function(r){var e=new RegExp("(?:(?:^|.*;\\s*)".concat(r,"\\s*\\=\\s*([^;]*).*$)|^.*$"));return document.cookie.replace(e,"$1")},set:function(e,t,n){var o=e+"="+t;if(n)for(var i in n){var a=n[i]?"=".concat(n[i]):"";o+="; ".concat(i).concat(a)}r.logger.debug("set cookie",o),document.cookie=o},remove:function(r,e){var t="".concat(r,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT");if(e)for(var n in e)t+="; ".concat(n,"=").concat(e[n]);document.cookie=t}},c=new Set(["400","401","403","404","429","500"]),u=function(r){function t(e,t){var n=r.call(this,t)||this;return n.code=e,n}return e.__extends(t,r),t}(Error);var s=function(){function r(){this.map={}}return r.prototype.clear=function(){this.map={}},r.prototype.getItem=function(r){var e=this.map[r];return void 0===e?null:e},r.prototype.setItem=function(r,e){this.map[r]=e},r.prototype.removeItem=function(r){delete this.map[r]},r.prototype.key=function(r){var e=Object.keys(this.map)[r];return void 0===e?null:e},Object.defineProperty(r.prototype,"length",{get:function(){return Object.keys(this.map).length},enumerable:!1,configurable:!0}),r}();var p,f={parse:function(r){return r.replace(/^\?/,"").replace(/^#\/?/,"").split(/&+/).filter((function(r){return r.length>0})).reduce((function(r,t){var n=e.__read(t.split("=").map(decodeURIComponent),2),o=n[0],i=n[1],a=r[o];return Array.isArray(a)?a.push(i):Object.prototype.hasOwnProperty.call(r,o)?r[o]=[a,i]:r[o]=i,r}),{})},stringify:function(r){return Object.keys(r).map((function(e){var t=r[e],n=function(r){return void 0!==r?"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r)):encodeURIComponent(e)};return Array.isArray(t)?t.map((function(r){return n(r)})).join("&"):n(t)})).join("&")}},d="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(){return window.crypto.getRandomValues(new Uint32Array(1))[0]/4294967296}function v(r){var e=new URL(r),n=e.hash.slice(1).split("&").filter((function(r){return!t.CREDENTIAL_KEYS.some((function(e){return r.includes("".concat(e,"="))}))})).join("&");return e.hash=n,e.toString()}function g(r){var t=new URL(r);return t.toString().replace(new RegExp(String.raw(m||(m=e.__makeTemplateObject(["^",""],["^",""])),t.origin)),"")}var m,w=((p={})[t.PERMANENT_LINK_ORIGIN]=function(){var r=h(t.PERMANENT_LINK_ORIGIN);return new RegExp("^".concat(r,"(\\d+-\\w+)"))},p[t.PERMANENT_LINK_ORIGIN_MINI]=function(){var r=h(t.PERMANENT_LINK_ORIGIN_MINI);return new RegExp("^".concat(r,"((\\d+-\\w+)|(\\w+$))"))},p);function h(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.HTTPStatusCodes=c,exports.InMemoryStorage=s,exports.LiffError=u,exports.addParamsToUrl=function(r,t){if(!r)throw new Error("addParamsToUrl: invalid URL");var n=new URL(r);return Object.entries(t).forEach((function(r){var t=e.__read(r,2),o=t[0],i=t[1];n.searchParams.set(o,i)})),n.toString()},exports.base64Url=o,exports.compareVersion=function(r,e){if(r===e)return 0;for(var t=r.split("."),n=e.split("."),o=Math.max(t.length,n.length),i=0;i<o;i++){t[i]||(t[i]="0"),n[i]||(n[i]="0");var a=parseInt(t[i])-parseInt(n[i]);if(0!==a)return a>0?1:-1}return 0},exports.convertArgbToRgba=function(e){var t=e.replace("#","").match(/.{2}/g)||[];if(4!==t.length)return r.logger.warn("convertArgbToRgba: Received invalid ARGB color"),"";var n=function(r){var e=i(r);return Math.round(e/255*100)/100}(t[0]),o=i(t[1]),a=i(t[2]),c=i(t[3]);return"rgba(".concat(o,", ").concat(a,", ").concat(c,", ").concat(n,")")},exports.convertArrayBuffer=function(r){for(var e=r.length,t=new ArrayBuffer(e),n=new Uint8Array(t),o=0;o<e;o++)n[o]=r.charCodeAt(o);return t},exports.convertHexToRgb=function(e){var t=e.replace("#","").match(/.{2}/g)||[];if(3!==t.length)return r.logger.warn("convertArgbToRgba: Received invalid hex color"),"";var n=i(t[0]),o=i(t[1]),a=i(t[2]);return"".concat(n,", ").concat(o,", ").concat(a)},exports.cookie=a,exports.createLiffError=function(r,e){return new u(r,e||"")},exports.extractChannelIdFromLiffId=function(r){var e=r.match(/([^-]+)-[^-]+/);return e&&e[1]},exports.extractLiffId=function(r){for(var e in w){var t=r.match(w[e]());if(t)return t[1]}return null},exports.getOriginOfUrl=function(r){var e=r.match(/^(https?:\/\/.*?)\//);return e&&e[1]||""},exports.getRandomValue=l,exports.hexToBase64=function(r){var e="";return r.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ").forEach((function(r){e+=String.fromCharCode(parseInt(r))})),window.btoa(e)},exports.isIE=function(r){void 0===r&&(r=window.navigator.userAgent);var e=r.toLowerCase();return-1!==e.indexOf("msie")||-1!==e.indexOf("trident")},exports.isIpad=function(r){return void 0===r&&(r=window.navigator.userAgent),/ipad/.test(r.toLowerCase())},exports.isLIFFBrowser=function(r){return void 0===r&&(r=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+ LIFF/.test(r)},exports.isLINEBrowser=function(r){return void 0===r&&(r=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+/.test(r)},exports.isLineCustomUrlScheme=function(r){return r.startsWith("line:")},exports.isNonBrowserEnvironment=function(){return"undefined"==typeof window},exports.isSubWindow=function(r){return void 0===r&&(r=window.navigator.userAgent),/LIFF\/SubWindow/.test(r)},exports.qs=f,exports.randomAlphaNumericString=function(r){for(var e="",t=0;t<r;t++)e+=d[Math.floor(l()*d.length)];return e},exports.removeCredential=v,exports.removeOrigin=g,exports.replaceUrlCredentialRemoved=function(r){var e=g(v(r));window.history.replaceState(history.state,"",e)};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var r=require("@liff/logger"),e=require("tslib"),t=require("@liff/consts");function n(r){return window.atob(r.replace(/-/g,"+").replace(/_/g,"/"))}var o={decode:n,encode:function(r){return window.btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},decodeUnicode:function(r){var e=n(r).split("").map((function(r){return"%"+("00"+r.charCodeAt(0).toString(16)).slice(-2)})).join("");return decodeURIComponent(e)}};function i(r){return parseInt(r,16)}var a={get:function(r){var e=new RegExp("(?:(?:^|.*;\\s*)".concat(r,"\\s*\\=\\s*([^;]*).*$)|^.*$"));return document.cookie.replace(e,"$1")},set:function(e,t,n){var o=e+"="+t;if(n)for(var i in n){var a=n[i]?"=".concat(n[i]):"";o+="; ".concat(i).concat(a)}r.logger.debug("set cookie",o),document.cookie=o},remove:function(r,e){var t="".concat(r,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT");if(e)for(var n in e)t+="; ".concat(n,"=").concat(e[n]);document.cookie=t}},c=new Set(["400","401","403","404","429","500"]),u=function(r){function t(e,t,n){var o=r.call(this,t,n)||this;return o.code=e,o}return e.__extends(t,r),t}(Error);var s=function(){function r(){this.map={}}return r.prototype.clear=function(){this.map={}},r.prototype.getItem=function(r){var e=this.map[r];return void 0===e?null:e},r.prototype.setItem=function(r,e){this.map[r]=e},r.prototype.removeItem=function(r){delete this.map[r]},r.prototype.key=function(r){var e=Object.keys(this.map)[r];return void 0===e?null:e},Object.defineProperty(r.prototype,"length",{get:function(){return Object.keys(this.map).length},enumerable:!1,configurable:!0}),r}();var p,f={parse:function(r){return r.replace(/^\?/,"").replace(/^#\/?/,"").split(/&+/).filter((function(r){return r.length>0})).reduce((function(r,t){var n=e.__read(t.split("=").map(decodeURIComponent),2),o=n[0],i=n[1],a=r[o];return Array.isArray(a)?a.push(i):Object.prototype.hasOwnProperty.call(r,o)?r[o]=[a,i]:r[o]=i,r}),{})},stringify:function(r){return Object.keys(r).map((function(e){var t=r[e],n=function(r){return void 0!==r?"".concat(encodeURIComponent(e),"=").concat(encodeURIComponent(r)):encodeURIComponent(e)};return Array.isArray(t)?t.map((function(r){return n(r)})).join("&"):n(t)})).join("&")}},d="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function l(){return window.crypto.getRandomValues(new Uint32Array(1))[0]/4294967296}function v(r){var e=new URL(r),n=e.hash.slice(1).split("&").filter((function(r){return!t.CREDENTIAL_KEYS.some((function(e){return r.startsWith("".concat(e,"="))}))})).join("&");return e.hash=n,e.toString()}function g(r){var t=new URL(r);return t.toString().replace(new RegExp(String.raw(h||(h=e.__makeTemplateObject(["^",""],["^",""])),t.origin)),"")}var h,m=((p={})[t.PERMANENT_LINK_ORIGIN]=function(){var r=w(t.PERMANENT_LINK_ORIGIN);return new RegExp("^".concat(r,"(\\d+-\\w+)"))},p[t.PERMANENT_LINK_ORIGIN_MINI]=function(){var r=w(t.PERMANENT_LINK_ORIGIN_MINI);return new RegExp("^".concat(r,"((\\d+-\\w+)|(\\w+$))"))},p);function w(r){return r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}exports.HTTPStatusCodes=c,exports.InMemoryStorage=s,exports.LiffError=u,exports.addParamsToUrl=function(r,t){if(!r)throw new Error("addParamsToUrl: invalid URL");var n=new URL(r);return Object.entries(t).forEach((function(r){var t=e.__read(r,2),o=t[0],i=t[1];n.searchParams.set(o,i)})),n.toString()},exports.base64Url=o,exports.compareVersion=function(r,e){if(r===e)return 0;for(var t=r.split("."),n=e.split("."),o=Math.max(t.length,n.length),i=0;i<o;i++){t[i]||(t[i]="0"),n[i]||(n[i]="0");var a=parseInt(t[i])-parseInt(n[i]);if(0!==a)return a>0?1:-1}return 0},exports.convertArgbToRgba=function(e){var t=e.replace("#","").match(/.{2}/g)||[];if(4!==t.length)return r.logger.warn("convertArgbToRgba: Received invalid ARGB color"),"";var n=function(r){var e=i(r);return Math.round(e/255*100)/100}(t[0]),o=i(t[1]),a=i(t[2]),c=i(t[3]);return"rgba(".concat(o,", ").concat(a,", ").concat(c,", ").concat(n,")")},exports.convertArrayBuffer=function(r){for(var e=r.length,t=new ArrayBuffer(e),n=new Uint8Array(t),o=0;o<e;o++)n[o]=r.charCodeAt(o);return t},exports.convertHexToRgb=function(e){var t=e.replace("#","").match(/.{2}/g)||[];if(3!==t.length)return r.logger.warn("convertArgbToRgba: Received invalid hex color"),"";var n=i(t[0]),o=i(t[1]),a=i(t[2]);return"".concat(n,", ").concat(o,", ").concat(a)},exports.cookie=a,exports.createLiffError=function(r,e,t){return(null==t?void 0:t.cause)&&console.error("This is the cause of LiffError described below.",t.cause),new u(r,e||"",t||{})},exports.extractChannelIdFromLiffId=function(r){var e=r.match(/([^-]+)-[^-]+/);return e&&e[1]},exports.extractLiffId=function(r){for(var e in m){var t=r.match(m[e]());if(t)return t[1]}return null},exports.getOriginOfUrl=function(r){var e=r.match(/^(https?:\/\/.*?)\//);return e&&e[1]||""},exports.getRandomValue=l,exports.hexToBase64=function(r){var e="";return r.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ").forEach((function(r){e+=String.fromCharCode(parseInt(r))})),window.btoa(e)},exports.isIE=function(r){void 0===r&&(r=window.navigator.userAgent);var e=r.toLowerCase();return-1!==e.indexOf("msie")||-1!==e.indexOf("trident")},exports.isIpad=function(r){return void 0===r&&(r=window.navigator.userAgent),/ipad/.test(r.toLowerCase())},exports.isLIFFBrowser=function(r){return void 0===r&&(r=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+ LIFF/.test(r)},exports.isLINEBrowser=function(r){return void 0===r&&(r=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+/.test(r)},exports.isLineCustomUrlScheme=function(r){return r.startsWith("line:")},exports.isNonBrowserEnvironment=function(){return"undefined"==typeof window},exports.isSubWindow=function(r){return void 0===r&&(r=window.navigator.userAgent),/LIFF\/SubWindow/.test(r)},exports.qs=f,exports.randomAlphaNumericString=function(r){for(var e="",t=0;t<r;t++)e+=d[Math.floor(l()*d.length)];return e},exports.removeCredential=v,exports.removeOrigin=g,exports.replaceUrlCredentialRemoved=function(r){var e=g(v(r));window.history.replaceState(history.state,"",e)};

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

import{logger as n}from"@liff/logger";import{__extends as t,__read as r,__makeTemplateObject as e}from"tslib";import{PERMANENT_LINK_ORIGIN as o,PERMANENT_LINK_ORIGIN_MINI as i,CREDENTIAL_KEYS as a}from"@liff/consts";function c(n){return window.atob(n.replace(/-/g,"+").replace(/_/g,"/"))}var u={decode:c,encode:function(n){return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},decodeUnicode:function(n){var t=c(n).split("").map((function(n){return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)})).join("");return decodeURIComponent(t)}};function f(n,t){if(n===t)return 0;for(var r=n.split("."),e=t.split("."),o=Math.max(r.length,e.length),i=0;i<o;i++){r[i]||(r[i]="0"),e[i]||(e[i]="0");var a=parseInt(r[i])-parseInt(e[i]);if(0!==a)return a>0?1:-1}return 0}function p(t){var r=t.replace("#","").match(/.{2}/g)||[];if(4!==r.length)return n.warn("convertArgbToRgba: Received invalid ARGB color"),"";var e=function(n){var t=d(n);return Math.round(t/255*100)/100}(r[0]),o=d(r[1]),i=d(r[2]),a=d(r[3]);return"rgba(".concat(o,", ").concat(i,", ").concat(a,", ").concat(e,")")}function d(n){return parseInt(n,16)}function s(t){var r=t.replace("#","").match(/.{2}/g)||[];if(3!==r.length)return n.warn("convertArgbToRgba: Received invalid hex color"),"";var e=d(r[0]),o=d(r[1]),i=d(r[2]);return"".concat(e,", ").concat(o,", ").concat(i)}function l(n){for(var t=n.length,r=new ArrayBuffer(t),e=new Uint8Array(r),o=0;o<t;o++)e[o]=n.charCodeAt(o);return r}var v={get:function(n){var t=new RegExp("(?:(?:^|.*;\\s*)".concat(n,"\\s*\\=\\s*([^;]*).*$)|^.*$"));return document.cookie.replace(t,"$1")},set:function(t,r,e){var o=t+"="+r;if(e)for(var i in e){var a=e[i]?"=".concat(e[i]):"";o+="; ".concat(i).concat(a)}n.debug("set cookie",o),document.cookie=o},remove:function(n,t){var r="".concat(n,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT");if(t)for(var e in t)r+="; ".concat(e,"=").concat(t[e]);document.cookie=r}},g=new Set(["400","401","403","404","429","500"]),w=function(n){function r(t,r){var e=n.call(this,r)||this;return e.code=t,e}return t(r,n),r}(Error);function h(n,t){return new w(n,t||"")}function m(n){var t=n.match(/([^-]+)-[^-]+/);return t&&t[1]}function y(n){var t="";return n.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ").forEach((function(n){t+=String.fromCharCode(parseInt(n))})),window.btoa(t)}var b=function(){function n(){this.map={}}return n.prototype.clear=function(){this.map={}},n.prototype.getItem=function(n){var t=this.map[n];return void 0===t?null:t},n.prototype.setItem=function(n,t){this.map[n]=t},n.prototype.removeItem=function(n){delete this.map[n]},n.prototype.key=function(n){var t=Object.keys(this.map)[n];return void 0===t?null:t},Object.defineProperty(n.prototype,"length",{get:function(){return Object.keys(this.map).length},enumerable:!1,configurable:!0}),n}();var R,A={parse:function(n){return n.replace(/^\?/,"").replace(/^#\/?/,"").split(/&+/).filter((function(n){return n.length>0})).reduce((function(n,t){var e=r(t.split("=").map(decodeURIComponent),2),o=e[0],i=e[1],a=n[o];return Array.isArray(a)?a.push(i):Object.prototype.hasOwnProperty.call(n,o)?n[o]=[a,i]:n[o]=i,n}),{})},stringify:function(n){return Object.keys(n).map((function(t){var r=n[t],e=function(n){return void 0!==n?"".concat(encodeURIComponent(t),"=").concat(encodeURIComponent(n)):encodeURIComponent(t)};return Array.isArray(r)?r.map((function(n){return e(n)})).join("&"):e(r)})).join("&")}},I="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function U(){return window.crypto.getRandomValues(new Uint32Array(1))[0]/4294967296}function x(n){for(var t="",r=0;r<n;r++)t+=I[Math.floor(U()*I.length)];return t}function C(n){var t=new URL(n),r=t.hash.slice(1).split("&").filter((function(n){return!a.some((function(t){return n.includes("".concat(t,"="))}))})).join("&");return t.hash=r,t.toString()}function j(n){var t=new URL(n);return t.toString().replace(new RegExp(String.raw(S||(S=e(["^",""],["^",""])),t.origin)),"")}var L=function(n){var t=j(C(n));window.history.replaceState(history.state,"",t)};function O(n,t){if(!n)throw new Error("addParamsToUrl: invalid URL");var e=new URL(n);return Object.entries(t).forEach((function(n){var t=r(n,2),o=t[0],i=t[1];e.searchParams.set(o,i)})),e.toString()}var S,k=((R={})[o]=function(){var n=$(o);return new RegExp("^".concat(n,"(\\d+-\\w+)"))},R[i]=function(){var n=$(i);return new RegExp("^".concat(n,"((\\d+-\\w+)|(\\w+$))"))},R);function E(n){for(var t in k){var r=n.match(k[t]());if(r)return r[1]}return null}function $(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function F(n){var t=n.match(/^(https?:\/\/.*?)\//);return t&&t[1]||""}function T(n){return n.startsWith("line:")}function M(n){void 0===n&&(n=window.navigator.userAgent);var t=n.toLowerCase();return-1!==t.indexOf("msie")||-1!==t.indexOf("trident")}function P(n){return void 0===n&&(n=window.navigator.userAgent),/ipad/.test(n.toLowerCase())}function B(n){return void 0===n&&(n=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+/.test(n)}function G(n){return void 0===n&&(n=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+ LIFF/.test(n)}function W(n){return void 0===n&&(n=window.navigator.userAgent),/LIFF\/SubWindow/.test(n)}var J=function(){return"undefined"==typeof window};export{g as HTTPStatusCodes,b as InMemoryStorage,w as LiffError,O as addParamsToUrl,u as base64Url,f as compareVersion,p as convertArgbToRgba,l as convertArrayBuffer,s as convertHexToRgb,v as cookie,h as createLiffError,m as extractChannelIdFromLiffId,E as extractLiffId,F as getOriginOfUrl,U as getRandomValue,y as hexToBase64,M as isIE,P as isIpad,G as isLIFFBrowser,B as isLINEBrowser,T as isLineCustomUrlScheme,J as isNonBrowserEnvironment,W as isSubWindow,A as qs,x as randomAlphaNumericString,C as removeCredential,j as removeOrigin,L as replaceUrlCredentialRemoved};
import{logger as n}from"@liff/logger";import{__extends as r,__read as t,__makeTemplateObject as e}from"tslib";import{PERMANENT_LINK_ORIGIN as o,PERMANENT_LINK_ORIGIN_MINI as i,CREDENTIAL_KEYS as a}from"@liff/consts";function c(n){return window.atob(n.replace(/-/g,"+").replace(/_/g,"/"))}var u={decode:c,encode:function(n){return window.btoa(n).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")},decodeUnicode:function(n){var r=c(n).split("").map((function(n){return"%"+("00"+n.charCodeAt(0).toString(16)).slice(-2)})).join("");return decodeURIComponent(r)}};function f(n,r){if(n===r)return 0;for(var t=n.split("."),e=r.split("."),o=Math.max(t.length,e.length),i=0;i<o;i++){t[i]||(t[i]="0"),e[i]||(e[i]="0");var a=parseInt(t[i])-parseInt(e[i]);if(0!==a)return a>0?1:-1}return 0}function s(r){var t=r.replace("#","").match(/.{2}/g)||[];if(4!==t.length)return n.warn("convertArgbToRgba: Received invalid ARGB color"),"";var e=function(n){var r=p(n);return Math.round(r/255*100)/100}(t[0]),o=p(t[1]),i=p(t[2]),a=p(t[3]);return"rgba(".concat(o,", ").concat(i,", ").concat(a,", ").concat(e,")")}function p(n){return parseInt(n,16)}function d(r){var t=r.replace("#","").match(/.{2}/g)||[];if(3!==t.length)return n.warn("convertArgbToRgba: Received invalid hex color"),"";var e=p(t[0]),o=p(t[1]),i=p(t[2]);return"".concat(e,", ").concat(o,", ").concat(i)}function l(n){for(var r=n.length,t=new ArrayBuffer(r),e=new Uint8Array(t),o=0;o<r;o++)e[o]=n.charCodeAt(o);return t}var v={get:function(n){var r=new RegExp("(?:(?:^|.*;\\s*)".concat(n,"\\s*\\=\\s*([^;]*).*$)|^.*$"));return document.cookie.replace(r,"$1")},set:function(r,t,e){var o=r+"="+t;if(e)for(var i in e){var a=e[i]?"=".concat(e[i]):"";o+="; ".concat(i).concat(a)}n.debug("set cookie",o),document.cookie=o},remove:function(n,r){var t="".concat(n,"=; expires=Thu, 01 Jan 1970 00:00:00 GMT");if(r)for(var e in r)t+="; ".concat(e,"=").concat(r[e]);document.cookie=t}},g=new Set(["400","401","403","404","429","500"]),h=function(n){function t(r,t,e){var o=n.call(this,t,e)||this;return o.code=r,o}return r(t,n),t}(Error);function w(n,r,t){return(null==t?void 0:t.cause)&&console.error("This is the cause of LiffError described below.",t.cause),new h(n,r||"",t||{})}function m(n){var r=n.match(/([^-]+)-[^-]+/);return r&&r[1]}function y(n){var r="";return n.replace(/\r|\n/g,"").replace(/([\da-fA-F]{2}) ?/g,"0x$1 ").replace(/ +$/,"").split(" ").forEach((function(n){r+=String.fromCharCode(parseInt(n))})),window.btoa(r)}var b=function(){function n(){this.map={}}return n.prototype.clear=function(){this.map={}},n.prototype.getItem=function(n){var r=this.map[n];return void 0===r?null:r},n.prototype.setItem=function(n,r){this.map[n]=r},n.prototype.removeItem=function(n){delete this.map[n]},n.prototype.key=function(n){var r=Object.keys(this.map)[n];return void 0===r?null:r},Object.defineProperty(n.prototype,"length",{get:function(){return Object.keys(this.map).length},enumerable:!1,configurable:!0}),n}();var R,A={parse:function(n){return n.replace(/^\?/,"").replace(/^#\/?/,"").split(/&+/).filter((function(n){return n.length>0})).reduce((function(n,r){var e=t(r.split("=").map(decodeURIComponent),2),o=e[0],i=e[1],a=n[o];return Array.isArray(a)?a.push(i):Object.prototype.hasOwnProperty.call(n,o)?n[o]=[a,i]:n[o]=i,n}),{})},stringify:function(n){return Object.keys(n).map((function(r){var t=n[r],e=function(n){return void 0!==n?"".concat(encodeURIComponent(r),"=").concat(encodeURIComponent(n)):encodeURIComponent(r)};return Array.isArray(t)?t.map((function(n){return e(n)})).join("&"):e(t)})).join("&")}},I="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function U(){return window.crypto.getRandomValues(new Uint32Array(1))[0]/4294967296}function x(n){for(var r="",t=0;t<n;t++)r+=I[Math.floor(U()*I.length)];return r}function C(n){var r=new URL(n),t=r.hash.slice(1).split("&").filter((function(n){return!a.some((function(r){return n.startsWith("".concat(r,"="))}))})).join("&");return r.hash=t,r.toString()}function L(n){var r=new URL(n);return r.toString().replace(new RegExp(String.raw(O||(O=e(["^",""],["^",""])),r.origin)),"")}var j=function(n){var r=L(C(n));window.history.replaceState(history.state,"",r)};function E(n,r){if(!n)throw new Error("addParamsToUrl: invalid URL");var e=new URL(n);return Object.entries(r).forEach((function(n){var r=t(n,2),o=r[0],i=r[1];e.searchParams.set(o,i)})),e.toString()}var O,S=((R={})[o]=function(){var n=$(o);return new RegExp("^".concat(n,"(\\d+-\\w+)"))},R[i]=function(){var n=$(i);return new RegExp("^".concat(n,"((\\d+-\\w+)|(\\w+$))"))},R);function k(n){for(var r in S){var t=n.match(S[r]());if(t)return t[1]}return null}function $(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function T(n){var r=n.match(/^(https?:\/\/.*?)\//);return r&&r[1]||""}function F(n){return n.startsWith("line:")}function M(n){void 0===n&&(n=window.navigator.userAgent);var r=n.toLowerCase();return-1!==r.indexOf("msie")||-1!==r.indexOf("trident")}function P(n){return void 0===n&&(n=window.navigator.userAgent),/ipad/.test(n.toLowerCase())}function W(n){return void 0===n&&(n=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+/.test(n)}function B(n){return void 0===n&&(n=window.navigator.userAgent),/Line\/\d+\.\d+\.\d+ LIFF/.test(n)}function G(n){return void 0===n&&(n=window.navigator.userAgent),/LIFF\/SubWindow/.test(n)}var J=function(){return"undefined"==typeof window};export{g as HTTPStatusCodes,b as InMemoryStorage,h as LiffError,E as addParamsToUrl,u as base64Url,f as compareVersion,s as convertArgbToRgba,l as convertArrayBuffer,d as convertHexToRgb,v as cookie,w as createLiffError,m as extractChannelIdFromLiffId,k as extractLiffId,T as getOriginOfUrl,U as getRandomValue,y as hexToBase64,M as isIE,P as isIpad,B as isLIFFBrowser,W as isLINEBrowser,F as isLineCustomUrlScheme,J as isNonBrowserEnvironment,G as isSubWindow,A as qs,x as randomAlphaNumericString,C as removeCredential,L as removeOrigin,j as replaceUrlCredentialRemoved};
{
"name": "@liff/util",
"version": "2.23.1",
"version": "2.23.2",
"description": "@liff/util",

@@ -31,4 +31,4 @@ "license": "SEE LICENSE IN README.md",

"dependencies": {
"@liff/consts": "2.23.1",
"@liff/logger": "2.23.1"
"@liff/consts": "2.23.2",
"@liff/logger": "2.23.2"
},

@@ -35,0 +35,0 @@ "peerDependencies": {

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