@atproto/oauth-client-browser-example 0.0.8 → 0.0.9

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/dist/index.html CHANGED
@@ -1,15 +1,13 @@
1
-
2
- <!DOCTYPE html>
3
- <html lang="en">
4
- <head>
5
- <meta charset="utf-8">
6
- <meta name="viewport" content="width=device-width, initial-scale=1">
7
- <title>OAuth Client Example</title>
8
- <link rel="stylesheet" href="index.css">
9
- </head>
10
- <body class="bg-slate-100 dark:bg-slate-800 min-h-screen">
11
- <div id="root"></div>
12
- <script src="index.js"></script>
13
- </body>
14
- </html>
15
-
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>OAuth Client Example</title>
7
+ <script type="module" crossorigin src="/assets/index-BMIlQ6jR.js"></script>
8
+ <link rel="stylesheet" crossorigin href="/assets/index-D_2JLQTh.css">
9
+ </head>
10
+ <body class="min-h-screen bg-slate-100 dark:bg-slate-800">
11
+ <div id="root"></div>
12
+ </body>
13
+ </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-client-browser-example",
3
- "version": "0.0.8",
3
+ "version": "0.0.9",
4
4
  "license": "MIT",
5
5
  "description": "Example single page application app using ATPROTO OAuth",
6
6
  "keywords": [
@@ -17,41 +17,37 @@
17
17
  "url": "https://github.com/bluesky-social/atproto",
18
18
  "directory": "packages/oauth/oauth-client-browser"
19
19
  },
20
+ "bin": "./server.js",
20
21
  "type": "commonjs",
22
+ "main": "./dist/files.json",
21
23
  "exports": {
22
- ".": {
23
- "default": "./dist/files.json"
24
+ ".": "./dist/files.json",
25
+ "./server": {
26
+ "import": "./server.js"
24
27
  }
25
28
  },
26
29
  "files": [
30
+ "server.js",
27
31
  "dist"
28
32
  ],
29
33
  "devDependencies": {
30
- "@rollup/plugin-commonjs": "^25.0.7",
31
- "@rollup/plugin-html": "^1.0.4",
32
- "@rollup/plugin-json": "^6.1.0",
33
- "@rollup/plugin-node-resolve": "^15.2.3",
34
- "@rollup/plugin-swc": "^0.4.0",
35
- "@swc/helpers": "^0.5.15",
34
+ "@tailwindcss/vite": "^4.1.3",
36
35
  "@tanstack/react-query": "^5.71.10",
37
36
  "@types/react": "^19.0.10",
38
37
  "@types/react-dom": "^19.0.4",
39
- "autoprefixer": "^10.4.17",
40
- "postcss": "^8.4.33",
38
+ "@vitejs/plugin-react-swc": "^3.8.0",
41
39
  "react": "^19.0.0",
42
40
  "react-dom": "^19.0.0",
43
41
  "react-json-view": "^1.21.3",
44
- "rollup": "^4.13.0",
45
- "rollup-plugin-postcss": "^4.0.2",
46
- "rollup-plugin-serve": "^1.1.1",
47
- "tailwindcss": "^3.4.1",
48
- "typescript": "^5.6.3",
42
+ "tailwindcss": "^4.1.3",
43
+ "vite": "^6.2.0",
49
44
  "@atproto-labs/rollup-plugin-bundle-manifest": "0.2.0",
50
- "@atproto/api": "0.18.0",
51
- "@atproto/oauth-client-browser": "0.3.34"
45
+ "@atproto/lex": "0.0.7",
46
+ "@atproto/oauth-client-browser": "0.3.38"
52
47
  },
53
48
  "scripts": {
54
- "build": "rollup --config rollup.config.js",
55
- "dev": "rollup --config rollup.config.js --watch"
49
+ "prebuild": "lex build --clear --lexicons ../../../lexicons --out ./src/lexicons",
50
+ "build": "vite build --emptyOutDir -- ignore additional npm args",
51
+ "dev": "vite --port 8080 --host 127.0.0.1"
56
52
  }
57
53
  }
package/server.js ADDED
@@ -0,0 +1,52 @@
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
+ }