nuxt-auth-utils 0.5.34 → 0.6.1
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/README.md +118 -15
- package/dist/module.d.mts +3 -3
- package/dist/module.json +4 -1
- package/dist/module.mjs +18 -31
- package/dist/runtime/app/composables/session.js +3 -2
- package/dist/runtime/server/api/session.delete.d.ts +1 -1
- package/dist/runtime/server/api/session.delete.js +2 -2
- package/dist/runtime/server/api/session.get.d.ts +1 -1
- package/dist/runtime/server/api/session.get.js +6 -2
- package/dist/runtime/server/lib/atproto/bluesky.d.ts +3 -3
- package/dist/runtime/server/lib/atproto/bluesky.js +6 -6
- package/dist/runtime/server/lib/oauth/apple.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/apple.js +3 -4
- package/dist/runtime/server/lib/oauth/atlassian.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/atlassian.js +8 -8
- package/dist/runtime/server/lib/oauth/auth0.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/auth0.js +4 -4
- package/dist/runtime/server/lib/oauth/authentik.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/authentik.js +6 -6
- package/dist/runtime/server/lib/oauth/azureb2c.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/azureb2c.js +5 -5
- package/dist/runtime/server/lib/oauth/battledotnet.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/battledotnet.js +6 -6
- package/dist/runtime/server/lib/oauth/box.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/box.js +5 -5
- package/dist/runtime/server/lib/oauth/cloudflare.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/cloudflare.js +5 -5
- package/dist/runtime/server/lib/oauth/cognito.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/cognito.js +4 -4
- package/dist/runtime/server/lib/oauth/discord.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/discord.js +4 -4
- package/dist/runtime/server/lib/oauth/dropbox.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/dropbox.js +5 -5
- package/dist/runtime/server/lib/oauth/facebook.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/facebook.js +7 -7
- package/dist/runtime/server/lib/oauth/gitea.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/gitea.js +5 -5
- package/dist/runtime/server/lib/oauth/github.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/github.js +6 -6
- package/dist/runtime/server/lib/oauth/gitlab.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/gitlab.js +5 -5
- package/dist/runtime/server/lib/oauth/google.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/google.js +4 -4
- package/dist/runtime/server/lib/oauth/heroku.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/heroku.js +5 -5
- package/dist/runtime/server/lib/oauth/hubspot.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/hubspot.js +4 -4
- package/dist/runtime/server/lib/oauth/instagram.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/instagram.js +6 -6
- package/dist/runtime/server/lib/oauth/keycloak.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/keycloak.js +6 -6
- package/dist/runtime/server/lib/oauth/kick.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/kick.js +5 -5
- package/dist/runtime/server/lib/oauth/line.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/line.js +6 -6
- package/dist/runtime/server/lib/oauth/linear.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/linear.js +6 -6
- package/dist/runtime/server/lib/oauth/linkedin.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/linkedin.js +4 -4
- package/dist/runtime/server/lib/oauth/livechat.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/livechat.js +4 -4
- package/dist/runtime/server/lib/oauth/mastodon.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/mastodon.js +10 -11
- package/dist/runtime/server/lib/oauth/microsoft.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/microsoft.js +5 -5
- package/dist/runtime/server/lib/oauth/oidc.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/oidc.js +6 -6
- package/dist/runtime/server/lib/oauth/okta.d.ts +4 -4
- package/dist/runtime/server/lib/oauth/okta.js +8 -8
- package/dist/runtime/server/lib/oauth/ory.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/ory.js +6 -6
- package/dist/runtime/server/lib/oauth/osu.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/osu.js +4 -4
- package/dist/runtime/server/lib/oauth/paypal.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/paypal.js +5 -5
- package/dist/runtime/server/lib/oauth/polar.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/polar.js +5 -5
- package/dist/runtime/server/lib/oauth/riotgames.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/riotgames.js +5 -5
- package/dist/runtime/server/lib/oauth/roblox.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/roblox.js +4 -4
- package/dist/runtime/server/lib/oauth/salesforce.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/salesforce.js +5 -5
- package/dist/runtime/server/lib/oauth/seznam.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/seznam.js +4 -4
- package/dist/runtime/server/lib/oauth/shopifyCustomer.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/shopifyCustomer.js +7 -7
- package/dist/runtime/server/lib/oauth/slack.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/slack.js +5 -5
- package/dist/runtime/server/lib/oauth/spotify.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/spotify.js +4 -4
- package/dist/runtime/server/lib/oauth/steam.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/steam.js +9 -9
- package/dist/runtime/server/lib/oauth/strava.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/strava.js +5 -5
- package/dist/runtime/server/lib/oauth/tiktok.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/tiktok.js +5 -5
- package/dist/runtime/server/lib/oauth/twitch.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/twitch.js +5 -5
- package/dist/runtime/server/lib/oauth/vk.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/vk.js +5 -5
- package/dist/runtime/server/lib/oauth/wechat.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/wechat.js +7 -7
- package/dist/runtime/server/lib/oauth/workos.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/workos.js +3 -4
- package/dist/runtime/server/lib/oauth/x.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/x.js +4 -4
- package/dist/runtime/server/lib/oauth/xsuaa.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/xsuaa.js +4 -4
- package/dist/runtime/server/lib/oauth/yandex.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/yandex.js +4 -4
- package/dist/runtime/server/lib/oauth/zendesk.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/zendesk.js +4 -4
- package/dist/runtime/server/lib/oauth/zitadel.d.ts +1 -1
- package/dist/runtime/server/lib/oauth/zitadel.js +6 -6
- package/dist/runtime/server/lib/session.d.ts +11 -0
- package/dist/runtime/server/lib/session.js +33 -0
- package/dist/runtime/server/lib/utils.d.ts +9 -8
- package/dist/runtime/server/lib/utils.js +13 -11
- package/dist/runtime/server/lib/webauthn/authenticate.d.ts +1 -1
- package/dist/runtime/server/lib/webauthn/authenticate.js +8 -9
- package/dist/runtime/server/lib/webauthn/register.d.ts +2 -2
- package/dist/runtime/server/lib/webauthn/register.js +10 -11
- package/dist/runtime/server/plugins/oauth-hash.d.ts +2 -0
- package/dist/runtime/server/plugins/oauth-hash.js +8 -0
- package/dist/runtime/server/routes/atproto/client-metadata.json.get.d.ts +1 -1
- package/dist/runtime/server/routes/atproto/client-metadata.json.get.js +5 -5
- package/dist/runtime/server/utils/atproto.d.ts +2 -2
- package/dist/runtime/server/utils/atproto.js +3 -4
- package/dist/runtime/server/utils/password.js +1 -1
- package/dist/runtime/server/utils/session.d.ts +26 -17
- package/dist/runtime/server/utils/session.js +49 -29
- package/dist/runtime/types/event.d.ts +27 -3
- package/dist/runtime/types/index.d.ts +1 -1
- package/dist/runtime/types/oauth-config.d.ts +3 -3
- package/dist/runtime/types/session.d.ts +5 -2
- package/dist/runtime/types/webauthn.d.ts +14 -17
- package/package.json +10 -6
- package/dist/runtime/server/plugins/oauth.d.ts +0 -2
- package/dist/runtime/server/plugins/oauth.js +0 -16
- package/dist/runtime/server/plugins/ws.d.ts +0 -2
- package/dist/runtime/server/plugins/ws.js +0 -7
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { NuxtError, RequestEvent } from 'nuxt/server';
|
|
2
2
|
export type ATProtoProvider = 'bluesky';
|
|
3
3
|
export type OAuthProvider = ATProtoProvider | 'atlassian' | 'auth0' | 'authentik' | 'azureb2c' | 'battledotnet' | 'cloudflare' | 'cognito' | 'discord' | 'dropbox' | 'facebook' | 'gitea' | 'github' | 'gitlab' | 'google' | 'hubspot' | 'instagram' | 'kick' | 'keycloak' | 'line' | 'linear' | 'linkedin' | 'mastodon' | 'microsoft' | 'paypal' | 'polar' | 'spotify' | 'seznam' | 'steam' | 'strava' | 'tiktok' | 'twitch' | 'vk' | 'wechat' | 'workos' | 'x' | 'xsuaa' | 'yandex' | 'zitadel' | 'apple' | 'livechat' | 'salesforce' | 'slack' | 'heroku' | 'roblox' | 'okta' | 'ory' | 'shopifyCustomer' | 'oidc' | 'osu' | 'riotgames' | 'box' | 'zendesk' | (string & {});
|
|
4
|
-
export type OnError = (event:
|
|
4
|
+
export type OnError = (event: RequestEvent, error: NuxtError) => unknown;
|
|
5
5
|
export interface OAuthConfig<TConfig, TResult = {
|
|
6
6
|
user: any;
|
|
7
7
|
tokens: any;
|
|
8
8
|
}> {
|
|
9
9
|
config?: TConfig;
|
|
10
|
-
onSuccess: (event:
|
|
10
|
+
onSuccess: (event: RequestEvent, result: TResult) => unknown;
|
|
11
11
|
onError?: OnError;
|
|
12
12
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import type { OmitWithIndexSignature } from './utils.js';
|
|
2
3
|
export interface User {
|
|
3
4
|
}
|
|
4
5
|
export interface SecureSessionData {
|
|
@@ -38,9 +39,11 @@ export interface UserSessionComposable {
|
|
|
38
39
|
*/
|
|
39
40
|
user: ComputedRef<User | null>;
|
|
40
41
|
/**
|
|
41
|
-
* The session object.
|
|
42
|
+
* The session object, without `id` for a visitor who has no session yet.
|
|
42
43
|
*/
|
|
43
|
-
session: Ref<UserSession
|
|
44
|
+
session: Ref<(OmitWithIndexSignature<UserSession, 'id'> & {
|
|
45
|
+
id?: string;
|
|
46
|
+
}) | null>;
|
|
44
47
|
/**
|
|
45
48
|
* Fetch the user session from the server.
|
|
46
49
|
*/
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import type { Ref } from 'vue';
|
|
2
|
-
import type {
|
|
3
|
-
import type { GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, VerifiedAuthenticationResponse, VerifiedRegistrationResponse
|
|
4
|
-
type RegistrationResponseJSON = Parameters<typeof verifyRegistrationResponse>[0]['response'];
|
|
5
|
-
type AuthenticationResponseJSON = Parameters<typeof verifyAuthenticationResponse>[0]['response'];
|
|
6
|
-
type AuthenticatorTransportFuture = NonNullable<Parameters<typeof verifyAuthenticationResponse>[0]['credential']['transports']>[number];
|
|
2
|
+
import type { NuxtError, RequestEvent, ValidateResult } from 'nuxt/server';
|
|
3
|
+
import type { AuthenticationResponseJSON, AuthenticatorTransportFuture, GenerateAuthenticationOptionsOpts, GenerateRegistrationOptionsOpts, RegistrationResponseJSON, VerifiedAuthenticationResponse, VerifiedRegistrationResponse } from '@simplewebauthn/server';
|
|
7
4
|
export interface WebAuthnCredential {
|
|
8
5
|
id: string;
|
|
9
6
|
publicKey: string;
|
|
@@ -20,15 +17,15 @@ export interface WebAuthnUser {
|
|
|
20
17
|
}
|
|
21
18
|
type CredentialsList = NonNullable<GenerateAuthenticationOptionsOpts['allowCredentials']>;
|
|
22
19
|
type WebAuthnEventHandlerBase<T extends Record<PropertyKey, unknown>> = {
|
|
23
|
-
storeChallenge: (event:
|
|
24
|
-
getChallenge: (event:
|
|
25
|
-
onSuccess: (event:
|
|
26
|
-
onError?: (event:
|
|
20
|
+
storeChallenge: (event: RequestEvent, challenge: string, attemptId: string) => void | Promise<void>;
|
|
21
|
+
getChallenge: (event: RequestEvent, attemptId: string) => string | Promise<string>;
|
|
22
|
+
onSuccess: (event: RequestEvent, data: T) => unknown;
|
|
23
|
+
onError?: (event: RequestEvent, error: NuxtError) => unknown;
|
|
27
24
|
} | {
|
|
28
25
|
storeChallenge?: undefined;
|
|
29
26
|
getChallenge?: undefined;
|
|
30
|
-
onSuccess: (event:
|
|
31
|
-
onError?: (event:
|
|
27
|
+
onSuccess: (event: RequestEvent, data: T) => unknown;
|
|
28
|
+
onError?: (event: RequestEvent, error: NuxtError) => unknown;
|
|
32
29
|
};
|
|
33
30
|
export type RegistrationBody<T extends WebAuthnUser> = {
|
|
34
31
|
user: T;
|
|
@@ -39,15 +36,15 @@ export type RegistrationBody<T extends WebAuthnUser> = {
|
|
|
39
36
|
attemptId: string;
|
|
40
37
|
response: RegistrationResponseJSON;
|
|
41
38
|
};
|
|
42
|
-
export type ValidateUserFunction<T> = (userBody: WebAuthnUser, event:
|
|
39
|
+
export type ValidateUserFunction<T> = (userBody: WebAuthnUser, event: RequestEvent) => ValidateResult<T> | Promise<ValidateResult<T>>;
|
|
43
40
|
export type WebAuthnRegisterEventHandlerOptions<T extends WebAuthnUser> = WebAuthnEventHandlerBase<{
|
|
44
41
|
user: T;
|
|
45
42
|
credential: WebAuthnCredential;
|
|
46
43
|
registrationInfo: Exclude<VerifiedRegistrationResponse['registrationInfo'], undefined>;
|
|
47
44
|
}> & {
|
|
48
|
-
getOptions?: (event:
|
|
45
|
+
getOptions?: (event: RequestEvent, body: RegistrationBody<T>) => Partial<GenerateRegistrationOptionsOpts> | Promise<Partial<GenerateRegistrationOptionsOpts>>;
|
|
49
46
|
validateUser?: ValidateUserFunction<T>;
|
|
50
|
-
excludeCredentials?: (event:
|
|
47
|
+
excludeCredentials?: (event: RequestEvent, userName: string) => CredentialsList | Promise<CredentialsList>;
|
|
51
48
|
};
|
|
52
49
|
export type AuthenticationBody = {
|
|
53
50
|
verify: false;
|
|
@@ -62,9 +59,9 @@ export type WebAuthnAuthenticateEventHandlerOptions<T extends WebAuthnCredential
|
|
|
62
59
|
credential: T;
|
|
63
60
|
authenticationInfo: Exclude<VerifiedAuthenticationResponse['authenticationInfo'], undefined>;
|
|
64
61
|
}> & {
|
|
65
|
-
getOptions?: (event:
|
|
66
|
-
getCredential: (event:
|
|
67
|
-
allowCredentials?: (event:
|
|
62
|
+
getOptions?: (event: RequestEvent, body: AuthenticationBody) => Partial<GenerateAuthenticationOptionsOpts> | Promise<Partial<GenerateAuthenticationOptionsOpts>>;
|
|
63
|
+
getCredential: (event: RequestEvent, credentialID: string) => T | Promise<T>;
|
|
64
|
+
allowCredentials?: (event: RequestEvent, userName: string) => CredentialsList | Promise<CredentialsList>;
|
|
68
65
|
};
|
|
69
66
|
export interface WebAuthnComposable {
|
|
70
67
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nuxt-auth-utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "Add Authentication to Nuxt applications with secured & sealed cookies sessions.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,25 +25,27 @@
|
|
|
25
25
|
"files": [
|
|
26
26
|
"dist"
|
|
27
27
|
],
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": "^22.22.3 || ^24.15.0 || >=26.0.0"
|
|
30
|
+
},
|
|
28
31
|
"dependencies": {
|
|
29
32
|
"@adonisjs/hash": "^9.1.1",
|
|
30
|
-
"@nuxt/kit": "^4.
|
|
33
|
+
"@nuxt/kit": "^4.6.0",
|
|
31
34
|
"@nuxt/schema": "^4.6.0",
|
|
32
35
|
"defu": "^6.1.5",
|
|
33
|
-
"h3": "^1.15.9",
|
|
34
36
|
"hookable": "^6.0.1",
|
|
35
37
|
"jose": "^6.1.3",
|
|
36
38
|
"ofetch": "^1.5.1",
|
|
37
39
|
"openid-client": "^6.8.2",
|
|
38
|
-
"pathe": "^2.0.3",
|
|
39
40
|
"scule": "^1.3.0",
|
|
41
|
+
"ufo": "^1.6.4",
|
|
40
42
|
"uncrypto": "^0.1.3"
|
|
41
43
|
},
|
|
42
44
|
"peerDependencies": {
|
|
43
45
|
"@atproto/api": "^0.13.15",
|
|
44
46
|
"@atproto/oauth-client-node": "^0.2.0",
|
|
45
|
-
"@simplewebauthn/browser": "^
|
|
46
|
-
"@simplewebauthn/server": "^
|
|
47
|
+
"@simplewebauthn/browser": "^13.0.0",
|
|
48
|
+
"@simplewebauthn/server": "^13.3.2"
|
|
47
49
|
},
|
|
48
50
|
"peerDependenciesMeta": {
|
|
49
51
|
"@simplewebauthn/browser": {
|
|
@@ -77,6 +79,8 @@
|
|
|
77
79
|
"dev": "nuxi dev playground",
|
|
78
80
|
"dev:build": "nuxi build playground",
|
|
79
81
|
"dev:prepare": "nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground",
|
|
82
|
+
"dev:v5": "pnpm install:nuxt5 && nuxt-module-build build --stub && nuxt-module-build prepare && nuxi prepare playground && nuxi dev playground",
|
|
83
|
+
"install:nuxt5": "pnpm install --config.pnpmfile=scripts/nuxt-nightly.cjs --config.lockfile=false --config.minimum-release-age-exclude=*-nightly",
|
|
80
84
|
"lint": "eslint .",
|
|
81
85
|
"lint:fix": "eslint . --fix",
|
|
82
86
|
"test": "vitest run",
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { defineNitroPlugin } from "nitropack/runtime";
|
|
2
|
-
export default defineNitroPlugin((nitroApp) => {
|
|
3
|
-
if (process.env.NUXT_OAUTH_FACEBOOK_CLIENT_ID && process.env.NUXT_OAUTH_FACEBOOK_CLIENT_SECRET || process.env.NUXT_OAUTH_INSTAGRAM_CLIENT_ID && process.env.NUXT_OAUTH_INSTAGRAM_CLIENT_SECRET) {
|
|
4
|
-
nitroApp.hooks.hook("render:html", (html) => {
|
|
5
|
-
html.head.unshift(`
|
|
6
|
-
<script>
|
|
7
|
-
if (window.location.hash === "#_=_"){
|
|
8
|
-
history.replaceState
|
|
9
|
-
? history.replaceState(null, null, window.location.href.split("#")[0])
|
|
10
|
-
: window.location.hash = "";
|
|
11
|
-
}
|
|
12
|
-
<\/script>
|
|
13
|
-
`);
|
|
14
|
-
});
|
|
15
|
-
}
|
|
16
|
-
});
|