@atproto/oauth-client-browser-example 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +111 -0
- package/bin.js +39 -0
- package/dist/assets/index-Bs3fK2WL.js +62 -0
- package/dist/assets/index-Bs3fK2WL.js.map +1 -0
- package/dist/files.json +8 -8
- package/dist/index.html +1 -1
- package/files.d.ts +3 -0
- package/package.json +28 -17
- package/server.js +35 -0
- package/dist/assets/index-Bihnsipt.js +0 -62
- package/dist/assets/index-Bihnsipt.js.map +0 -1
- package/server.cjs +0 -52
package/server.cjs
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/* eslint-env node, commonjs */
|
|
2
|
-
|
|
3
|
-
'use strict'
|
|
4
|
-
|
|
5
|
-
const { once } = require('node:events')
|
|
6
|
-
const { createServer } = require('node:http')
|
|
7
|
-
const files = require('./dist/files.json')
|
|
8
|
-
|
|
9
|
-
exports.middleware = middleware
|
|
10
|
-
function middleware(
|
|
11
|
-
req,
|
|
12
|
-
res,
|
|
13
|
-
next = (err) => {
|
|
14
|
-
if (err) console.error(err)
|
|
15
|
-
|
|
16
|
-
const { statusCode, statusMessage } = err
|
|
17
|
-
? { statusCode: 404, statusMessage: 'Not Found' }
|
|
18
|
-
: { statusCode: 500, statusMessage: 'Internal Server Error' }
|
|
19
|
-
|
|
20
|
-
res
|
|
21
|
-
.writeHead(statusCode, statusMessage, { 'content-type': 'text/plain' })
|
|
22
|
-
.end(statusMessage)
|
|
23
|
-
},
|
|
24
|
-
) {
|
|
25
|
-
const path = req.url?.split('?')[0].slice(1) || 'index.html'
|
|
26
|
-
const file = Object.hasOwn(files, path) ? files[path] : null
|
|
27
|
-
|
|
28
|
-
if (file) {
|
|
29
|
-
res
|
|
30
|
-
.writeHead(200, 'OK', { 'content-type': file.mime })
|
|
31
|
-
.end(Buffer.from(file.data, 'base64'))
|
|
32
|
-
} else {
|
|
33
|
-
next()
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
exports.start = start
|
|
38
|
-
async function start(port = 0) {
|
|
39
|
-
const server = createServer(middleware)
|
|
40
|
-
server.listen(port)
|
|
41
|
-
await once(server, 'listening')
|
|
42
|
-
return server
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (require.main === module) {
|
|
46
|
-
const port = Number(process.argv[2] || process.env.PORT || 0)
|
|
47
|
-
start(port).then((server) => {
|
|
48
|
-
const address = server.address()
|
|
49
|
-
const port = typeof address === 'string' ? address : address && address.port
|
|
50
|
-
console.log(`Listening on http://127.0.0.1:${port}/`)
|
|
51
|
-
})
|
|
52
|
-
}
|