@liquid-js/qr-code-styling 5.5.0-3 → 5.5.0
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/lib/wifi-plugin.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var i,p=i||={};p.wep="WEP",p.wpa="WPA",p.wpaEap="WPA2-EAP";var n=new Set(["\\",";",",",":",'"']);function t(i,p=!1){return i=i.split("").map(i=>n.has(i)?"\\"+i:i).join(""),p&&i.match(/^[0-9a-f]+$/i)?`"${i}"`:i}export default class{pluginOptions;constructor(i){this.pluginOptions=i}configure(i){return i.data=this.generateWiFi(),i.qrOptions.mode=void 0,i}generateWiFi(){var{ssid:p,hidden:n}=this.pluginOptions,e=[];return e.push({key:"S",value:t(p)}),"encryption"in this.pluginOptions&&this.pluginOptions.encryption?(e.push({key:"T",value:t(this.pluginOptions.encryption)},{key:"P",value:t(this.pluginOptions.password||"",!0)}),this.pluginOptions.encryption==i.wpaEap&&(this.pluginOptions.eapMethod&&e.push({key:"E",value:t(this.pluginOptions.eapMethod)}),this.pluginOptions.eapIdentity&&e.push({key:"I",value:t(this.pluginOptions.eapIdentity)}),this.pluginOptions.eapAnonymousIdentity&&e.push({key:"A",value:t(this.pluginOptions.eapAnonymousIdentity)}),this.pluginOptions.eapPhase2Method&&e.push({key:"PH2",value:t(this.pluginOptions.eapPhase2Method)}))):e.push({key:"T",value:"nopass"}),e.push({key:"H",value:n?"true":"false"}),`WIFI:${e.map(({key:i,value:p})=>[i,p].join(":")).join(";")};;`}}export{i as EncryptionType};
|
|
1
|
+
var i,p=i||={};p.wep="WEP",p.wpa="WPA",p.wpaEap="WPA2-EAP";var n=new Set(["\\",";",",",":",'"']);function t(i,p=!1){return i=i.split("").map(i=>n.has(i)?"\\"+i:i).join(""),p&&i.match(/^[0-9a-f]+$/i)?`"${i}"`:i}export default class{pluginOptions;constructor(i){this.pluginOptions=i}configure(i){return i.data=this.generateWiFi(),i.qrOptions.mode=void 0,i}generateWiFi(){var{ssid:p,hidden:n}=this.pluginOptions,e=[];return e.push({key:"S",value:t(p||"",!0)}),"encryption"in this.pluginOptions&&this.pluginOptions.encryption?(e.push({key:"T",value:t(this.pluginOptions.encryption)},{key:"P",value:t(this.pluginOptions.password||"",!0)}),this.pluginOptions.encryption==i.wpaEap&&(this.pluginOptions.eapMethod&&e.push({key:"E",value:t(this.pluginOptions.eapMethod)}),this.pluginOptions.eapIdentity&&e.push({key:"I",value:t(this.pluginOptions.eapIdentity)}),this.pluginOptions.eapAnonymousIdentity&&e.push({key:"A",value:t(this.pluginOptions.eapAnonymousIdentity)}),this.pluginOptions.eapPhase2Method&&e.push({key:"PH2",value:t(this.pluginOptions.eapPhase2Method)}))):e.push({key:"T",value:"nopass"}),e.push({key:"H",value:n?"true":"false"}),`WIFI:${e.map(({key:i,value:p})=>[i,p].join(":")).join(";")};;`}}export{i as EncryptionType};
|
|
2
2
|
//# sourceMappingURL=wifi-plugin.js.map
|
package/lib/wifi-plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wifi-plugin.js","sources":["../src/plugins/wifi.ts"],"sourcesContent":["import { Options, Plugin } from '../utils/options.js'\r\n\r\nexport enum EncryptionType {\r\n wep = 'WEP',\r\n wpa = 'WPA',\r\n wpaEap = 'WPA2-EAP'\r\n}\r\n\r\nexport type WiFiPluginOptions = {\r\n ssid: string\r\n hidden?: boolean\r\n} & ({\r\n encryption: `${EncryptionType.wep | EncryptionType.wpa}`\r\n password: string\r\n} | {}) & (({\r\n encryption: `${EncryptionType.wpaEap}`\r\n password?: string\r\n /** EAP method, like PEAP, TTLS or PWD */\r\n eapMethod?: string\r\n /** EAP identity */\r\n eapIdentity?: string\r\n /** EAP anonymous identity */\r\n eapAnonymousIdentity?: string\r\n /** EAP phase 2 method, like MSCHAPV2 or TLS */\r\n eapPhase2Method?: string\r\n} & {}) | {})\r\n\r\nexport default class WiFiPlugin implements Plugin {\r\n\r\n constructor(\r\n private readonly pluginOptions: WiFiPluginOptions\r\n ) { }\r\n\r\n configure(options: Options): Options | undefined | void {\r\n options.data = this.generateWiFi()\r\n // Auto mode\r\n options.qrOptions.mode = undefined\r\n return options\r\n }\r\n\r\n private generateWiFi() {\r\n // https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11\r\n\r\n const { ssid, hidden } = this.pluginOptions\r\n\r\n const parts = new Array<{ key: 'T' | 'S' | 'P' | 'H' | 'E' | 'A' | 'I' | 'PH2', value: string }>()\r\n parts.push({\r\n key: 'S',\r\n value: escape_string(ssid)\r\n })\r\n if ('encryption' in this.pluginOptions && this.pluginOptions.encryption) {\r\n parts.push({\r\n key: 'T',\r\n value: escape_string(this.pluginOptions.encryption)\r\n }, {\r\n key: 'P',\r\n value: escape_string(this.pluginOptions.password || '', true)\r\n })\r\n if (this.pluginOptions.encryption == EncryptionType.wpaEap) {\r\n if (this.pluginOptions.eapMethod)\r\n parts.push({\r\n key: 'E',\r\n value: escape_string(this.pluginOptions.eapMethod)\r\n })\r\n if (this.pluginOptions.eapIdentity)\r\n parts.push({\r\n key: 'I',\r\n value: escape_string(this.pluginOptions.eapIdentity)\r\n })\r\n if (this.pluginOptions.eapAnonymousIdentity)\r\n parts.push({\r\n key: 'A',\r\n value: escape_string(this.pluginOptions.eapAnonymousIdentity)\r\n })\r\n if (this.pluginOptions.eapPhase2Method)\r\n parts.push({\r\n key: 'PH2',\r\n value: escape_string(this.pluginOptions.eapPhase2Method)\r\n })\r\n }\r\n } else\r\n parts.push({\r\n key: 'T',\r\n value: 'nopass'\r\n })\r\n\r\n parts.push({\r\n key: 'H',\r\n value: hidden ? 'true' : 'false'\r\n })\r\n\r\n const content = parts.map(({ key, value }) => [key, value].join(':')).join(';')\r\n\r\n return `WIFI:${content};;`\r\n }\r\n\r\n}\r\n\r\nconst to_escape = new Set(['\\\\', ';', ',', ':', '\"'])\r\n\r\nfunction escape_string(val: string, quoteHex = false) {\r\n const value = val.split('').map(v => to_escape.has(v) ? '\\\\' + v : v).join('')\r\n if (quoteHex && value.match(/^[0-9a-f]+$/i))\r\n return `\"${value}\"`\r\n return value\r\n};\r\n"],"names":["EncryptionType","d","wep","wpa","wpaEap","to_escape","Set","escape_string","val","quoteHex","value","split","map","v","has","join","match","WiFiPlugin","pluginOptions","constructor","this","configure","options","data","generateWiFi","qrOptions","mode","
|
|
1
|
+
{"version":3,"file":"wifi-plugin.js","sources":["../src/plugins/wifi.ts"],"sourcesContent":["import { Options, Plugin } from '../utils/options.js'\r\n\r\nexport enum EncryptionType {\r\n wep = 'WEP',\r\n wpa = 'WPA',\r\n wpaEap = 'WPA2-EAP'\r\n}\r\n\r\nexport type WiFiPluginOptions = {\r\n ssid: string\r\n hidden?: boolean\r\n} & ({\r\n encryption: `${EncryptionType.wep | EncryptionType.wpa}`\r\n password: string\r\n} | {}) & (({\r\n encryption: `${EncryptionType.wpaEap}`\r\n password?: string\r\n /** EAP method, like PEAP, TTLS or PWD */\r\n eapMethod?: string\r\n /** EAP identity */\r\n eapIdentity?: string\r\n /** EAP anonymous identity */\r\n eapAnonymousIdentity?: string\r\n /** EAP phase 2 method, like MSCHAPV2 or TLS */\r\n eapPhase2Method?: string\r\n} & {}) | {})\r\n\r\nexport default class WiFiPlugin implements Plugin {\r\n\r\n constructor(\r\n private readonly pluginOptions: WiFiPluginOptions\r\n ) { }\r\n\r\n configure(options: Options): Options | undefined | void {\r\n options.data = this.generateWiFi()\r\n // Auto mode\r\n options.qrOptions.mode = undefined\r\n return options\r\n }\r\n\r\n private generateWiFi() {\r\n // https://github.com/zxing/zxing/wiki/Barcode-Contents#wi-fi-network-config-android-ios-11\r\n\r\n const { ssid, hidden } = this.pluginOptions\r\n\r\n const parts = new Array<{ key: 'T' | 'S' | 'P' | 'H' | 'E' | 'A' | 'I' | 'PH2', value: string }>()\r\n parts.push({\r\n key: 'S',\r\n value: escape_string(ssid || '', true)\r\n })\r\n if ('encryption' in this.pluginOptions && this.pluginOptions.encryption) {\r\n parts.push({\r\n key: 'T',\r\n value: escape_string(this.pluginOptions.encryption)\r\n }, {\r\n key: 'P',\r\n value: escape_string(this.pluginOptions.password || '', true)\r\n })\r\n if (this.pluginOptions.encryption == EncryptionType.wpaEap) {\r\n if (this.pluginOptions.eapMethod)\r\n parts.push({\r\n key: 'E',\r\n value: escape_string(this.pluginOptions.eapMethod)\r\n })\r\n if (this.pluginOptions.eapIdentity)\r\n parts.push({\r\n key: 'I',\r\n value: escape_string(this.pluginOptions.eapIdentity)\r\n })\r\n if (this.pluginOptions.eapAnonymousIdentity)\r\n parts.push({\r\n key: 'A',\r\n value: escape_string(this.pluginOptions.eapAnonymousIdentity)\r\n })\r\n if (this.pluginOptions.eapPhase2Method)\r\n parts.push({\r\n key: 'PH2',\r\n value: escape_string(this.pluginOptions.eapPhase2Method)\r\n })\r\n }\r\n } else\r\n parts.push({\r\n key: 'T',\r\n value: 'nopass'\r\n })\r\n\r\n parts.push({\r\n key: 'H',\r\n value: hidden ? 'true' : 'false'\r\n })\r\n\r\n const content = parts.map(({ key, value }) => [key, value].join(':')).join(';')\r\n\r\n return `WIFI:${content};;`\r\n }\r\n\r\n}\r\n\r\nconst to_escape = new Set(['\\\\', ';', ',', ':', '\"'])\r\n\r\nfunction escape_string(val: string, quoteHex = false) {\r\n const value = val.split('').map(v => to_escape.has(v) ? '\\\\' + v : v).join('')\r\n if (quoteHex && value.match(/^[0-9a-f]+$/i))\r\n return `\"${value}\"`\r\n return value\r\n};\r\n"],"names":["EncryptionType","d","wep","wpa","wpaEap","to_escape","Set","escape_string","val","quoteHex","value","split","map","v","has","join","match","WiFiPlugin","pluginOptions","constructor","this","configure","options","data","generateWiFi","qrOptions","mode","ssid","hidden","parts","push","key","encryption","password","eapMethod","eapIdentity","eapAnonymousIdentity","eapPhase2Method"],"mappings":"IAEYA,EAAAC,EAAAD,IAAc,CAAA,EACtBA,EAAAE,IAAA,MACAF,EAAAG,IAAA,QACAC,OAAA,WA6FJ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