🎨 Style(custom): format with prettier

This commit is contained in:
Kuingsmile
2024-06-15 19:37:50 +08:00
parent 096f564c31
commit 5af8a6b529
157 changed files with 21365 additions and 22952 deletions

View File

@@ -5,11 +5,17 @@ const AUTH_KEY_VALUE_RE = /(\w+)=["']?([^'"]{1,10000})["']?/
let NC = 0
const NC_PAD = '00000000'
function md5 (text: crypto.BinaryLike) {
function md5(text: crypto.BinaryLike) {
return crypto.createHash('md5').update(text).digest('hex')
}
export function digestAuthHeader (method: string, uri: string, wwwAuthenticate: string, username: string, password: string) {
export function digestAuthHeader(
method: string,
uri: string,
wwwAuthenticate: string,
username: string,
password: string
) {
const parts = wwwAuthenticate.split(',')
const opts = {} as IStringKeyMap
for (let i = 0; i < parts.length; i++) {
@@ -61,11 +67,9 @@ export function digestAuthHeader (method: string, uri: string, wwwAuthenticate:
return authstring
}
export async function getAuthHeader (method: string, host: string, uri: string, username: string, password: string) {
export async function getAuthHeader(method: string, host: string, uri: string, username: string, password: string) {
try {
await axios.get(
`${host}${uri}`
)
await axios.get(`${host}${uri}`)
} catch (error: any) {
if (error.response.status === 401 && error.response.headers['www-authenticate']) {
return digestAuthHeader(method, uri, error.response.headers['www-authenticate'], username, password)