Skip to content

Commit 0ca83e0

Browse files
authored
Merge pull request #253 from privy-open-source/release/1.0.1
release: `1.0.1`
2 parents abb898f + 8a5d229 commit 0ca83e0

File tree

9 files changed

+99
-111
lines changed

9 files changed

+99
-111
lines changed

README.md

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,15 +186,19 @@ Or you can set auth profile using it
186186
</script>
187187
```
188188

189-
To prevent auto redirect to OAuth login page when access app
189+
Or if you want disable redirect on every pages:
190190

191-
```
191+
```ts
192192
// nuxt.config.ts
193193

194-
nuauth: {
195-
middleware: false
194+
export default defineNuxtConfig({
196195
// ...
197-
}
196+
nuauth: {
197+
// ...
198+
middleware: false,
199+
// ...
200+
}
201+
})
198202
```
199203

200204
## Contribution

build.config.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@ export default defineBuildConfig({
77
builder: 'mkdist',
88
outDir : 'dist/core',
99
},
10-
{
11-
input : './src/utils.ts',
12-
outDir: 'dist/',
13-
},
1410
],
1511
externals : ['#imports'],
1612
declaration: true,

package.json

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313
"./core": {
1414
"import": "./dist/core/index.mjs",
1515
"types": "./dist/core/index.d.ts"
16-
},
17-
"./utils": {
18-
"import": "./dist/utils.mjs",
19-
"require": "./dist/utils.cjs",
20-
"types": "./dist/utils.d.ts"
2116
}
2217
},
2318
"typesVersions": {
@@ -43,10 +38,10 @@
4338
"lint": "eslint . --ext .js,.vue,.ts --format pretty",
4439
"fix": "yarn lint --fix",
4540
"dev:build": "nuxi build playground",
46-
"dev:prepare": "nuxt-module-build --stub && nuxi prepare playground"
41+
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground"
4742
},
4843
"dependencies": {
49-
"@nuxt/kit": "^3.3.3",
44+
"@nuxt/kit": "^3.13.1",
5045
"cookie-es": "^1.0.0",
5146
"defu": "^6.1.2",
5247
"destr": "^2.0.0",
@@ -59,7 +54,7 @@
5954
"ufo": "^1.0.1"
6055
},
6156
"devDependencies": {
62-
"@nuxt/module-builder": "0.6.0",
57+
"@nuxt/module-builder": "0.8.4",
6358
"@nuxt/schema": "3.13.1",
6459
"@privyid/eslint-config-persona": "0.27.0",
6560
"@types/html-escaper": "3.0.2",
@@ -79,7 +74,7 @@
7974
"eslint-plugin-varspacing": "1.2.2",
8075
"eslint-plugin-vue": "9.28.0",
8176
"nuxt": "3.13.1",
82-
"typescript": "5.5.4"
77+
"typescript": "5.6.2"
8378
},
8479
"publishConfig": {
8580
"access": "public"

playground/nuxt.config.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { fileURLToPath } from 'node:url'
22
import { defineNuxtConfig } from 'nuxt/config'
3-
import MyModule from '../src/module'
43

54
export default defineNuxtConfig({
6-
modules : [MyModule],
5+
modules : ['../src/module'],
76
alias : { '@privyid/nuauth/core': fileURLToPath(new URL('../src/core', import.meta.url)) },
87
typescript: {
98
tsConfig: {
@@ -14,4 +13,6 @@ export default defineNuxtConfig({
1413
},
1514
},
1615
nuauth: { profile: { names: ['oauth', 'gitlab'] } },
16+
17+
compatibilityDate: '2024-09-13',
1718
})

src/core/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import {
33
encodePath,
44
joinURL,
55
} from 'ufo'
6-
import { ofetch } from 'ofetch'
6+
import { createFetch } from 'ofetch'
77
import getURL from 'requrl'
88
import { getCookie } from 'h3'
99
import { hash } from 'ohash'
@@ -28,6 +28,8 @@ interface AuthRefreshResponse {
2828

2929
type NavigateResult = ReturnType<typeof navigateTo>
3030

31+
const $fetch = globalThis.$fetch ?? createFetch({ fetch: globalThis.fetch })
32+
3133
export interface NuAuth {
3234
/**
3335
* Access token
@@ -97,7 +99,7 @@ export function useNuAuth (authProfile?: string): NuAuth {
9799
}
98100

99101
async function refresh (): Promise<string> {
100-
const response = await ofetch<AuthRefreshResponse>('/auth/refresh', {
102+
const response = await $fetch<AuthRefreshResponse>('/auth/refresh', {
101103
baseURL,
102104
headers,
103105
query: { profile },

src/core/redirect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export default async function sendRedirectPage (event: H3Event, url: string, coo
119119
120120
<footer>
121121
<p>
122-
If you are not redirect automaticaly, <a href="${escape(url)}">click here</a>.
122+
If you are not redirect automatically, <a href="${escape(url)}">click here</a>.
123123
</p>
124124
</footer>
125125
</div>

src/module.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ export default defineNuxtModule<ModuleOptions>({
8484
nuxt.options.runtimeConfig.nuauth = defu(nuxt.options.runtimeConfig.nuauth, options)
8585
nuxt.options.runtimeConfig.public.defaultProfile = options.profile.default as string
8686

87+
if (!nuxt.options.build.transpile.includes('@privyid/nuauth'))
88+
nuxt.options.build.transpile.push('@privyid/nuauth')
89+
8790
addServerHandler({ route: '/auth/login', handler: resolve('./runtime/login') })
8891
addServerHandler({ route: '/auth/callback', handler: resolve('./runtime/callback') })
8992
addServerHandler({ route: '/auth/refresh', handler: resolve('./runtime/refresh') })

src/utils.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)