Skip to content

Commit

Permalink
πŸ”πŸ’» hardcode mocked /auth endpoints (#241)
Browse files Browse the repository at this point in the history
* πŸ”πŸ’» hardcode mocked /auth endpoints
* πŸ“¦ add SIWE pkg
* πŸ’»πŸ” impl /nonce
  • Loading branch information
Flip-Liquid authored Apr 22, 2024
1 parent ca986f5 commit 1158013
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 14 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"react-is": "^18.2.0",
"react-markdown": "^8.0.7",
"react-responsive": "^9.0.2",
"siwe": "^2.3.2",
"swagger-ui-react": "5.16.2",
"tailwind-merge": "^1.13.2",
"tailwindcss": "3.3.2",
Expand Down
11 changes: 11 additions & 0 deletions src/app/api/v1/auth/nonce/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { generateNonce } from "siwe";

export async function GET(request: Request) {
const nonce = generateNonce();
const headers = new Headers();
headers.set("Content-Type", "text/plain");
return new Response(nonce, {
headers,
status: 200,
});
}
11 changes: 11 additions & 0 deletions src/app/api/v1/auth/verify/route.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export async function POST(request: Request) {
const responseBody = {
access_token:
"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
token_type: "JWT",
expires_in: 9999999999,
};
return new Response(JSON.stringify(responseBody), {
status: 200,
});
}
51 changes: 37 additions & 14 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,11 @@
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.3.2.tgz#6f26dbc8fbc7205873ce3cee2f690eba0d421b39"
integrity sha512-MVC8EAQp7MvEcm30KWENFjgR+Mkmf+D189XJTkFIlwohU5hcBbn1ZkKq7KVTi2Hme3PMGF390DaL52beVrIihQ==

"@noble/hashes@^1.1.2":
version "1.4.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.4.0.tgz#45814aa329f30e4fe0ba49426f49dfccdd066426"
integrity sha512-V1JJ1WTRUqHHrOSh597hURcMqVKVGL/ea3kv0gSnEdsEZ0/+VyPghM1lMNGc00z7CIQorSvbKpuJkxvuHbvdbg==

"@nodelib/[email protected]":
version "2.1.5"
resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5"
Expand Down Expand Up @@ -3355,6 +3360,16 @@
rpc-websockets "^7.5.1"
superstruct "^0.14.2"

"@spruceid/siwe-parser@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@spruceid/siwe-parser/-/siwe-parser-2.1.2.tgz#3e13e7d3ac0bfdaf109a07342590eb21daee2fc3"
integrity sha512-d/r3S1LwJyMaRAKQ0awmo9whfXeE88Qt00vRj91q5uv5ATtWIQEGJ67Yr5eSZw5zp1/fZCXZYuEckt8lSkereQ==
dependencies:
"@noble/hashes" "^1.1.2"
apg-js "^4.3.0"
uri-js "^4.4.1"
valid-url "^1.0.9"

"@stablelib/aead@^1.0.1":
version "1.0.1"
resolved "https://registry.yarnpkg.com/@stablelib/aead/-/aead-1.0.1.tgz#c4b1106df9c23d1b867eb9b276d8f42d5fc4c0c3"
Expand Down Expand Up @@ -5064,6 +5079,11 @@ anymatch@^3.1.3, anymatch@~3.1.2:
normalize-path "^3.0.0"
picomatch "^2.0.4"

apg-js@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/apg-js/-/apg-js-4.3.0.tgz#2c55d3f1aa6b90be5d3c6539f346cf2c726702c3"
integrity sha512-8U8MULS+JocCnm11bfrVS4zxtAcE3uOiCAI21SnjDrV9LNhMSGwTGGeko3QfyK1JLWwT7KebFqJMB2puzfdFMQ==

arch@^2.2.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/arch/-/arch-2.2.0.tgz#1bc47818f305764f23ab3306b0bfc086c5a29d11"
Expand Down Expand Up @@ -5517,7 +5537,7 @@ bufferutil@^4.0.1, bufferutil@^4.0.7:
dependencies:
node-gyp-build "^4.3.0"

[email protected], busboy@^1.6.0:
[email protected]:
version "1.6.0"
resolved "https://registry.yarnpkg.com/busboy/-/busboy-1.6.0.tgz#966ea36a9502e43cdb9146962523b92f531f6893"
integrity sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==
Expand Down Expand Up @@ -10657,6 +10677,16 @@ simple-get@^4.0.0:
once "^1.3.1"
simple-concat "^1.0.0"

siwe@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/siwe/-/siwe-2.3.2.tgz#0794ae25f734f3068de0ab093ddd2f7867bc2d67"
integrity sha512-aSf+6+Latyttbj5nMu6GF3doMfv2UYj83hhwZgUF20ky6fTS83uVhkQABdIVnEuS8y1bBdk7p6ltb9SmlhTTlA==
dependencies:
"@spruceid/siwe-parser" "^2.1.2"
"@stablelib/random" "^1.0.1"
uri-js "^4.4.1"
valid-url "^1.0.9"

slash@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/slash/-/slash-2.0.0.tgz#de552851a1759df3a8f206535442f5ec4ddeab44"
Expand Down Expand Up @@ -11030,11 +11060,6 @@ swagger-client@^3.27.0:
qs "^6.10.2"
traverse "~0.6.6"

swagger-ui-dist@^5.16.2:
version "5.16.2"
resolved "https://registry.yarnpkg.com/swagger-ui-dist/-/swagger-ui-dist-5.16.2.tgz#986cfac365ed2a93172612a71fdfbaa0e559c763"
integrity sha512-zcRXKnDi0605AOmkv5sOPvr1m4AE4gVFdTGhapPs7fylEwv4tv5k7vbtlPPcKJQThKafASJhErWX6RZK2Wbztg==

[email protected]:
version "5.16.2"
resolved "https://registry.yarnpkg.com/swagger-ui-react/-/swagger-ui-react-5.16.2.tgz#c78af7c2cdd8df29a5ef5632643ee71f67a2ef40"
Expand Down Expand Up @@ -11565,13 +11590,6 @@ undici-types@~5.26.4:
resolved "https://registry.yarnpkg.com/undici-types/-/undici-types-5.26.5.tgz#bcd539893d00b56e964fd2657a4866b221a65617"
integrity sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==

[email protected]:
version "5.24.0"
resolved "https://registry.yarnpkg.com/undici/-/undici-5.24.0.tgz#6133630372894cfeb3c3dab13b4c23866bd344b5"
integrity sha512-OKlckxBjFl0oXxcj9FU6oB8fDAaiRUq+D8jrFWGmOfI/gIyjk/IeS75LMzgYKUaeHzLUcYvf9bbJGSrUwTfwwQ==
dependencies:
busboy "^1.6.0"

unenv@^1.7.4:
version "1.8.0"
resolved "https://registry.yarnpkg.com/unenv/-/unenv-1.8.0.tgz#0f860d5278405700bd95d47b23bc01f3a735d68c"
Expand Down Expand Up @@ -11703,7 +11721,7 @@ uqr@^0.1.2:
resolved "https://registry.yarnpkg.com/uqr/-/uqr-0.1.2.tgz#5c6cd5dcff9581f9bb35b982cb89e2c483a41d7d"
integrity sha512-MJu7ypHq6QasgF5YRTjqscSzQp/W11zoUk6kvmlH+fmWEs63Y0Eib13hYFwAzagRJcVY8WVnlV+eBDUGMJ5IbA==

uri-js@^4.2.2:
uri-js@^4.2.2, uri-js@^4.4.1:
version "4.4.1"
resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e"
integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==
Expand Down Expand Up @@ -11793,6 +11811,11 @@ v8-compile-cache-lib@^3.0.1:
resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf"
integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==

valid-url@^1.0.9:
version "1.0.9"
resolved "https://registry.yarnpkg.com/valid-url/-/valid-url-1.0.9.tgz#1c14479b40f1397a75782f115e4086447433a200"
integrity sha512-QQDsV8OnSf5Uc30CKSwG9lnhMPe6exHtTXLRYX8uMwKENy640pU+2BgBL0LRbDh/eYRahNCS7aewCx0wf3NYVA==

[email protected]:
version "1.11.2"
resolved "https://registry.yarnpkg.com/valtio/-/valtio-1.11.2.tgz#b8049c02dfe65620635d23ebae9121a741bb6530"
Expand Down

0 comments on commit 1158013

Please sign in to comment.