Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (countryCode && countryCode !== this.selectedCountry.iso2) {
const newCountry = this.allCountries.find(c => c.iso2 === countryCode);
if (newCountry) {
this.selectedCountry = newCountry;
}
}
}
countryCode = countryCode ? countryCode : this.selectedCountry.iso2;
this.checkSeparateDialCodeStyle();
if (!this.value) {
// tslint:disable-next-line:no-null-keyword
this.propagateChange(null);
} else {
var intlNo = number ? this.phoneUtil.format(number, lpn.PhoneNumberFormat.INTERNATIONAL) : '';
// parse phoneNumber if separate dial code is needed
if (this.separateDialCode && intlNo) {
this.phoneNumber = this.removeDialCode(intlNo);
}
this.propagateChange({
number: this.value,
internationalNumber: intlNo,
nationalNumber: number ? this.phoneUtil.format(number, lpn.PhoneNumberFormat.NATIONAL) : '',
countryCode: countryCode.toUpperCase(),
dialCode: '+' + this.selectedCountry.dialCode
});
}
}
proxyUrl: config.proxyUrl,
});
// Linux seems to periodically let the event loop stop, so this is a global workaround
setInterval(() => {
window.nodeSetImmediate(() => {});
}, 1000);
const { autoOrientImage } = require('./js/modules/auto_orient_image');
window.autoOrientImage = autoOrientImage;
window.dataURLToBlobSync = require('blueimp-canvas-to-blob');
window.emojiData = require('emoji-datasource');
window.filesize = require('filesize');
window.libphonenumber = require('google-libphonenumber').PhoneNumberUtil.getInstance();
window.libphonenumber.PhoneNumberFormat = require('google-libphonenumber').PhoneNumberFormat;
window.loadImage = require('blueimp-load-image');
window.getGuid = require('uuid/v4');
window.React = require('react');
window.ReactDOM = require('react-dom');
window.moment = require('moment');
window.PQueue = require('p-queue');
const Signal = require('./js/modules/signal');
const i18n = require('./js/modules/i18n');
const Attachments = require('./app/attachments');
const { locale } = config;
window.i18n = i18n.setup(locale, localeMessages);
window.moment.updateLocale(locale, {
relativeTime: {
if (!this.value) {
// tslint:disable-next-line:no-null-keyword
this.propagateChange(null);
} else {
var intlNo = number ? this.phoneUtil.format(number, lpn.PhoneNumberFormat.INTERNATIONAL) : '';
// parse phoneNumber if separate dial code is needed
if (this.separateDialCode && intlNo) {
this.phoneNumber = this.removeDialCode(intlNo);
}
this.propagateChange({
number: this.value,
internationalNumber: intlNo,
nationalNumber: number ? this.phoneUtil.format(number, lpn.PhoneNumberFormat.NATIONAL) : '',
countryCode: countryCode.toUpperCase(),
dialCode: '+' + this.selectedCountry.dialCode
});
}
}
function getExampleNumber(countryCode, national, numberType) {
try {
var phoneUtil = libphonenumber.PhoneNumberUtil.getInstance();
var numberObj = phoneUtil.getExampleNumberForType(countryCode, numberType);
var format = (national) ? libphonenumber.PhoneNumberFormat.NATIONAL : libphonenumber.PhoneNumberFormat.INTERNATIONAL;
return phoneUtil.format(numberObj, format);
} catch (e) {
return "";
}
}
/**
* @module phone
*/
var phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance();
var PNF = require('google-libphonenumber').PhoneNumberFormat;
/**
* @description Cleans a phone number
* @example returns +5491156623011 for 1556623011
* @param {string} targetPhone phone number
* @param {string} areaCode area code, default is 11
* @returns {string} Cleaned phone number
*/
var clean = function (targetPhone, areaCode) {
var defaultCountry = 'AR';
areaCode = areaCode || '11';
var tel;
try {
tel = phoneUtil.parse(targetPhone, defaultCountry);
if (tel.getCountryCode() == '54') {
import {isMobile} from '../../constants/platform'
import libphonenumber from 'google-libphonenumber'
const PNF = libphonenumber.PhoneNumberFormat
export const PhoneNumberFormat = PNF
export const phoneUtil = libphonenumber.PhoneNumberUtil.getInstance()
export const ValidationResult = libphonenumber.PhoneNumberUtil.ValidationResult
const supported = phoneUtil.getSupportedRegions()
export type CountryData = {
alpha2: string
callingCode: string
emoji: string
emojiText: string
example: string
name: string
pickerText: string
}
const async = require('async')
, _ = require('lodash')
, utils = require('./util/common')
, Promise = require('bluebird')
, locale = require('./locale')
, phoneUtil = require('google-libphonenumber').PhoneNumberUtil.getInstance()
, PNF = require('google-libphonenumber').PhoneNumberFormat
, PNV = require('google-libphonenumber').PhoneNumberUtil.ValidationResult;
module.exports = {
/**
* Returns an array of possible phone number candidates for a specific country code
* @param {string} text - Text string from where the phone numbers are extracted
* @param {string} countryCode - au or us
* @param {boolean=} useGooglePhoneLib - When true uses Google LibPhoneNumber to format the result. https://github.com/googlei18n/libphonenumber
* @return {Promise}
*/
getCandidates: function(text, countryCode, useGooglePhoneLib){
const that = this,
resultsFormatted = [];
'use strict'
const libPhoneNumber = require('google-libphonenumber')
const PhoneNumberUtil = libPhoneNumber.PhoneNumberUtil
const PhoneNumberFormat = libPhoneNumber.PhoneNumberFormat
module.exports = (message, price) => {
let parseMessage = `Sorry, your message could not be parsed.`
let matches = message.body.trim().toLowerCase().match(/^.*?[send]{3,}.*?([0-9,.]+)[ \r\n\t]+([a-z]{3,})?[to \r\n\t]{0,}([^a-z]+)[a-z]*?/i)
let parsed = {
valid: false,
rawAmount: typeof matches[1] !== 'undefined' ? matches[1].trim() : null,
currency: typeof matches[2] !== 'undefined' ? matches[2].toUpperCase().trim() : null,
rawDestination: typeof matches[3] !== 'undefined' ? matches[3].trim() : null,
country: message.country,
amount: {},
destination: null
}
if (matches) {