MCPcopy Create free account
hub / github.com/VirtualHotBar/NetMount / getOpenlistToken

Function getOpenlistToken

src/utils/openlist/openlist.ts:89–112  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87}
88
89async function getOpenlistToken(): Promise<string> {
90 if (openlistInfo.endpoint.auth.token) {
91 return openlistInfo.endpoint.auth.token
92 }
93 const username = nmConfig.framework.openlist.user
94 const password = nmConfig.framework.openlist.password
95
96 const maxAttempts = 3
97 let lastError: unknown
98 for (let attempt = 1; attempt <= maxAttempts; attempt++) {
99 try {
100 const token = await openlist_login(username, password)
101 openlistInfo.endpoint.auth.token = token
102 return token
103 } catch (e) {
104 lastError = e
105 if (attempt < maxAttempts) {
106 await new Promise(resolve => setTimeout(resolve, 500))
107 }
108 }
109 }
110
111 throw new Error(`OpenList login failed after ${maxAttempts} attempts: ${String(lastError)}`)
112}
113
114async function setOpenlistPass(pass: string) {
115 // v1.1.2 行为:每次启动都无条件写入 admin 密码,避免升级/迁移导致的"密码不一致"卡死。

Callers 1

startOpenlistFunction · 0.90

Calls 1

openlist_loginFunction · 0.85

Tested by

no test coverage detected