Skip to content

Commit d73516f

Browse files
authored
Merge pull request #384 from IncognitoTGT/main
Better password protect + update UV
2 parents e6c0a2e + 54cfe31 commit d73516f

File tree

8 files changed

+49
-32
lines changed

8 files changed

+49
-32
lines changed

config.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
const config = {
2-
passwordProtect: false,
3-
password: 'password',
2+
challenge: false,
3+
users: {
4+
// username: 'password', you can add multiple users.
5+
interstellar: 'password',
6+
}
47
}
58
export default config

index.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@ const server = http.createServer()
1010
const app = express(server)
1111
const bareServer = createBareServer('/v/')
1212
const PORT = 8080
13-
if (config.passwordProtect) {
14-
console.log("Password protection is enabled. Username is 'interstellar'.")
15-
console.log('Password is: ' + config.password)
16-
app.use(
17-
basicAuth({
18-
users: { interstellar: password },
19-
challenge: true,
20-
})
21-
)
13+
if (config.challenge) {
14+
console.log("Password protection is enabled. Usernames are: " + Object.keys(config.users))
15+
console.log("Passwords are: " + Object.values(config.users))
16+
app.use(basicAuth(config))
2217
}
2318
app.use(express.json())
2419
app.use(express.urlencoded({ extended: true }))

static/m/bundle.js

Lines changed: 26 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/m/client.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/m/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ self.__uv$config = {
44
encodeUrl: Ultraviolet.codec.xor.encode,
55
decodeUrl: Ultraviolet.codec.xor.decode,
66
handler: '/m/handler.js',
7+
client: '/m/client.js',
78
bundle: '/m/bundle.js',
89
config: '/m/config.js',
910
sw: '/m/sw.js',

static/m/handler.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/m/sw.js

Lines changed: 3 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

static/sw.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
importScripts('/m/bundle.js')
2-
importScripts('/m/config.js')
3-
importScripts('/m/sw.js')
1+
/*global UVServiceWorker,__uv$config*/
2+
importScripts('/m/bundle.js');
3+
importScripts('/m/config.js');
4+
importScripts(__uv$config.sw || '/m/sw.js');
45

5-
const sw = new UVServiceWorker()
6-
let userKey = new URL(location).searchParams.get('userkey')
6+
const sw = new UVServiceWorker();
77

8-
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)))
8+
self.addEventListener('fetch', (event) => event.respondWith(sw.fetch(event)));

0 commit comments

Comments
 (0)