|
1 | 1 | import { KEYUTIL } from 'jsrsasign'; |
2 | 2 | import log from 'loglevel'; |
3 | 3 | import clipboard from 'clipboard-polyfill'; |
4 | | -import { isToken } from './editor/jwt.js'; |
5 | 4 |
|
6 | 5 | export function httpGet(url, cache = true) { |
7 | 6 | return new Promise((resolve, reject) => { |
@@ -31,36 +30,6 @@ export function httpGet(url, cache = true) { |
31 | 30 | }); |
32 | 31 | } |
33 | 32 |
|
34 | | -export function isValidBase64String(s, urlOnly) { |
35 | | - try { |
36 | | - const validChars = urlOnly ? |
37 | | - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=' : |
38 | | - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_+/='; |
39 | | - |
40 | | - let hasPadding = false; |
41 | | - for(let i = 0; i < s.length; ++i) { |
42 | | - hasPadding |= s.charAt(i) === '='; |
43 | | - if(validChars.indexOf(s.charAt(i)) === -1) { |
44 | | - return false; |
45 | | - } |
46 | | - } |
47 | | - |
48 | | - if(hasPadding) { |
49 | | - for(let i = s.indexOf('='); i < s.length; ++i) { |
50 | | - if(s.charAt(i) !== '=') { |
51 | | - return false; |
52 | | - } |
53 | | - } |
54 | | - |
55 | | - return s.length % 4 === 0; |
56 | | - } |
57 | | - |
58 | | - return true; |
59 | | - } catch (e) { |
60 | | - return false; |
61 | | - } |
62 | | -}; |
63 | | - |
64 | 33 | export function isValidKey(key) { |
65 | 34 | // Four tries: no header, header for cert, header for pub key, |
66 | 35 | // header for priv key |
@@ -118,45 +87,6 @@ export function copyTokenLink(token, publicKeyOptional) { |
118 | 87 | return url; |
119 | 88 | } |
120 | 89 |
|
121 | | -function regexp(body, flag) { |
122 | | - return new RegExp("[?&#]" + body + "(?:=([^&#]*)|&|#|$)", flag); |
123 | | -} |
124 | | - |
125 | | -const tokenRegexp = regexp('((?:id_|access_)?token|value)', 'g'); |
126 | | - |
127 | | -export function getTokensFromLocation() { |
128 | | - const { href } = window.location; |
129 | | - let name, value; |
130 | | - const val = {}; |
131 | | - |
132 | | - try { |
133 | | - while ([, name, value] = tokenRegexp.exec(href)) { |
134 | | - if(isToken(value)) val[name] = value; |
135 | | - } |
136 | | - } catch (err) {} |
137 | | - return val; |
138 | | -} |
139 | | - |
140 | | -// https://stackoverflow.com/questions/901115/how-can-i-get-query-string-values-in-javascript |
141 | | -export function getParameterByName(name, url) { |
142 | | - if(!url) { |
143 | | - url = window.location.href; |
144 | | - } |
145 | | - |
146 | | - name = name.replace(/[\[\]]/g, "\\$&"); |
147 | | - |
148 | | - const regex = regexp(name); |
149 | | - const results = regex.exec(url); |
150 | | - if(!results) { |
151 | | - return null; |
152 | | - } |
153 | | - if(!results[1]) { |
154 | | - return ''; |
155 | | - } |
156 | | - |
157 | | - return decodeURIComponent(results[1].replace(/\+/g, " ")); |
158 | | -} |
159 | | - |
160 | 90 | export function isWideScreen() { |
161 | 91 | return window.matchMedia('(min-width: 768px)').matches; |
162 | 92 | } |
|
0 commit comments