mirror of
https://github.com/bitwarden/browser
synced 2025-12-14 23:33:31 +00:00
vendors for background. clean out gulp.
This commit is contained in:
3
src/background.d.ts
vendored
3
src/background.d.ts
vendored
@@ -1,4 +1,5 @@
|
||||
declare function escape(s: string): string;
|
||||
declare function unescape(s: string): string;
|
||||
declare var forge: any;
|
||||
declare var opr: any;
|
||||
declare var tldjs: any;
|
||||
declare var forge: any;
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
<html>
|
||||
<head>
|
||||
<script type="text/javascript" src="lib/jquery/jquery.js"></script>
|
||||
<script type="text/javascript" src="lib/tldjs/tld.js"></script>
|
||||
<script type="text/javascript" src="lib/forge/forge.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
require('jquery');
|
||||
require('node-forge');
|
||||
require('tldjs');
|
||||
|
||||
// Service imports
|
||||
import ApiService from './services/api.service';
|
||||
import AppIdService from './services/appId.service';
|
||||
|
||||
@@ -120,6 +120,15 @@ export default class UtilsService {
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static fromUtf8ToArray(str: string): Uint8Array {
|
||||
const strUtf8 = unescape(encodeURIComponent(str));
|
||||
const arr = new Uint8Array(strUtf8.length);
|
||||
for (let i = 0; i < strUtf8.length; i++) {
|
||||
arr[i] = strUtf8.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
static fromBufferToB64(buffer: ArrayBuffer): string {
|
||||
let binary = '';
|
||||
const bytes = new Uint8Array(buffer);
|
||||
@@ -135,15 +144,6 @@ export default class UtilsService {
|
||||
return decodeURIComponent(escape(encodedString));
|
||||
}
|
||||
|
||||
static fromUtf8ToArray(str: string): Uint8Array {
|
||||
const strUtf8 = unescape(encodeURIComponent(str));
|
||||
const arr = new Uint8Array(strUtf8.length);
|
||||
for (let i = 0; i < strUtf8.length; i++) {
|
||||
arr[i] = strUtf8.charCodeAt(i);
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
|
||||
static saveObjToStorage(key: string, obj: any) {
|
||||
return new Promise((resolve) => {
|
||||
chrome.storage.local.set({ [key]: obj }, () => {
|
||||
@@ -185,7 +185,7 @@ export default class UtilsService {
|
||||
if (uriString.startsWith('http://') || uriString.startsWith('https://')) {
|
||||
try {
|
||||
const url = new URL(uriString);
|
||||
if (!url || !url.hostname) {
|
||||
if (!url.hostname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -193,17 +193,17 @@ export default class UtilsService {
|
||||
return url.hostname;
|
||||
}
|
||||
|
||||
if ((window as any).tldjs) {
|
||||
const domain = (window as any).tldjs.getDomain(uriString);
|
||||
if (domain) {
|
||||
if (typeof tldjs !== 'undefined' && tldjs) {
|
||||
const domain = tldjs.getDomain(url.hostname);
|
||||
if (domain != null) {
|
||||
return domain;
|
||||
}
|
||||
}
|
||||
|
||||
return url.hostname;
|
||||
} catch (e) { }
|
||||
} else if ((window as any).tldjs) {
|
||||
const domain: string = (window as any).tldjs.getDomain(uriString);
|
||||
} else if (typeof tldjs !== 'undefined' && tldjs) {
|
||||
const domain = tldjs.getDomain(uriString);
|
||||
if (domain != null) {
|
||||
return domain;
|
||||
}
|
||||
@@ -212,12 +212,6 @@ export default class UtilsService {
|
||||
return null;
|
||||
}
|
||||
|
||||
static validIpAddress(ipString: string): boolean {
|
||||
// tslint:disable-next-line
|
||||
const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||||
return ipRegex.test(ipString);
|
||||
}
|
||||
|
||||
static getHostname(uriString: string): string {
|
||||
if (uriString == null) {
|
||||
return null;
|
||||
@@ -231,7 +225,7 @@ export default class UtilsService {
|
||||
if (uriString.startsWith('http://') || uriString.startsWith('https://')) {
|
||||
try {
|
||||
const url = new URL(uriString);
|
||||
if (!url || !url.hostname) {
|
||||
if (!url.hostname) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -242,6 +236,12 @@ export default class UtilsService {
|
||||
return null;
|
||||
}
|
||||
|
||||
private static validIpAddress(ipString: string): boolean {
|
||||
// tslint:disable-next-line
|
||||
const ipRegex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
|
||||
return ipRegex.test(ipString);
|
||||
}
|
||||
|
||||
private browserCache: BrowserType = null;
|
||||
private analyticsIdCache: string = null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user