@authup/client-web-nuxt
Advanced tools
+1
-1
| { | ||
| "name": "@authup/client-web-nuxt", | ||
| "configKey": "authup", | ||
| "version": "1.0.0-beta.46", | ||
| "version": "1.0.0-beta.47", | ||
| "builder": { | ||
@@ -6,0 +6,0 @@ "@nuxt/module-builder": "1.0.2", |
| import { | ||
| clearAuthorizationRequest, | ||
| injectStore, | ||
| loadAuthorizationRequest, | ||
| storeToRefs | ||
@@ -23,10 +25,42 @@ } from "@authup/client-web-kit"; | ||
| if (code) { | ||
| if (import.meta.server) { | ||
| return void 0; | ||
| } | ||
| const request = loadAuthorizationRequest(); | ||
| try { | ||
| await this.store.exchangeAuthorizationCode(code); | ||
| if (request) { | ||
| const state = typeof to.query.state === "string" ? to.query.state : void 0; | ||
| if (request.state !== state) { | ||
| throw new Error("The authorization request state does not match."); | ||
| } | ||
| await this.store.exchangeAuthorizationCode(code, { | ||
| code_verifier: request.code_verifier, | ||
| redirect_uri: request.redirect_uri, | ||
| client_id: request.client_id, | ||
| realm_id: request.realm_id | ||
| }); | ||
| } else { | ||
| await this.store.exchangeAuthorizationCode(code); | ||
| } | ||
| clearAuthorizationRequest(); | ||
| if (request?.target) { | ||
| const url = new URL(request.target, "http://localhost"); | ||
| return { | ||
| path: url.pathname, | ||
| query: Object.fromEntries(url.searchParams.entries()), | ||
| hash: url.hash | ||
| }; | ||
| } | ||
| return { | ||
| path: to.path, | ||
| query: omitRecord(to.query, ["code"]), | ||
| query: omitRecord(to.query, ["code", "state"]), | ||
| hash: to.hash | ||
| }; | ||
| } catch { | ||
| clearAuthorizationRequest(); | ||
| return { | ||
| path: to.path, | ||
| query: omitRecord(to.query, ["code", "state"]), | ||
| hash: to.hash | ||
| }; | ||
| } | ||
@@ -33,0 +67,0 @@ } |
+4
-4
| { | ||
| "name": "@authup/client-web-nuxt", | ||
| "type": "module", | ||
| "version": "1.0.0-beta.46", | ||
| "version": "1.0.0-beta.47", | ||
| "description": "Nuxt module for the authup ecosystem", | ||
@@ -33,5 +33,5 @@ "license": "Apache-2.0", | ||
| "dependencies": { | ||
| "@authup/access": "^1.0.0-beta.46", | ||
| "@authup/client-web-kit": "^1.0.0-beta.46", | ||
| "@authup/kit": "^1.0.0-beta.46", | ||
| "@authup/access": "^1.0.0-beta.47", | ||
| "@authup/client-web-kit": "^1.0.0-beta.47", | ||
| "@authup/kit": "^1.0.0-beta.47", | ||
| "@nuxt/kit": "^4.0.0", | ||
@@ -38,0 +38,0 @@ "pathtrace": "^2.2.0", |
28216
4.36%445
8.27%