nuxt-auther 1.0.2 → 1.0.3

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.
Files changed (92) hide show
  1. package/dist/module.cjs +5 -0
  2. package/dist/module.d.mts +3 -0
  3. package/dist/module.d.ts +3 -0
  4. package/dist/module.json +8 -0
  5. package/dist/module.mjs +1007 -0
  6. package/dist/runtime/composables.d.ts +2 -0
  7. package/dist/runtime/composables.mjs +2 -0
  8. package/dist/runtime/core/auth.d.ts +53 -0
  9. package/dist/runtime/core/auth.mjs +387 -0
  10. package/dist/runtime/core/index.d.ts +3 -0
  11. package/dist/runtime/core/index.mjs +3 -0
  12. package/dist/runtime/core/middleware.d.ts +2 -0
  13. package/dist/runtime/core/middleware.mjs +41 -0
  14. package/dist/runtime/core/storage.d.ts +41 -0
  15. package/dist/runtime/core/storage.mjs +277 -0
  16. package/dist/runtime/inc/configuration-document-request-error.d.ts +3 -0
  17. package/dist/runtime/inc/configuration-document-request-error.mjs +6 -0
  18. package/dist/runtime/inc/configuration-document.d.ts +26 -0
  19. package/dist/runtime/inc/configuration-document.mjs +94 -0
  20. package/dist/runtime/inc/default-properties.d.ts +123 -0
  21. package/dist/runtime/inc/default-properties.mjs +132 -0
  22. package/dist/runtime/inc/expired-auth-session-error.d.ts +3 -0
  23. package/dist/runtime/inc/expired-auth-session-error.mjs +6 -0
  24. package/dist/runtime/inc/id-token.d.ts +15 -0
  25. package/dist/runtime/inc/id-token.mjs +81 -0
  26. package/dist/runtime/inc/index.d.ts +10 -0
  27. package/dist/runtime/inc/index.mjs +10 -0
  28. package/dist/runtime/inc/refresh-controller.d.ts +9 -0
  29. package/dist/runtime/inc/refresh-controller.mjs +29 -0
  30. package/dist/runtime/inc/refresh-token.d.ts +14 -0
  31. package/dist/runtime/inc/refresh-token.mjs +75 -0
  32. package/dist/runtime/inc/request-handler.d.ts +17 -0
  33. package/dist/runtime/inc/request-handler.mjs +93 -0
  34. package/dist/runtime/inc/token-status.d.ts +12 -0
  35. package/dist/runtime/inc/token-status.mjs +39 -0
  36. package/dist/runtime/inc/token.d.ts +14 -0
  37. package/dist/runtime/inc/token.mjs +83 -0
  38. package/dist/runtime/index.d.ts +3 -0
  39. package/dist/runtime/index.mjs +3 -0
  40. package/dist/runtime/providers/auth0.d.ts +7 -0
  41. package/dist/runtime/providers/auth0.mjs +15 -0
  42. package/dist/runtime/providers/discord.d.ts +6 -0
  43. package/dist/runtime/providers/discord.mjs +18 -0
  44. package/dist/runtime/providers/facebook.d.ts +6 -0
  45. package/dist/runtime/providers/facebook.mjs +13 -0
  46. package/dist/runtime/providers/github.d.ts +6 -0
  47. package/dist/runtime/providers/github.mjs +15 -0
  48. package/dist/runtime/providers/google.d.ts +6 -0
  49. package/dist/runtime/providers/google.mjs +13 -0
  50. package/dist/runtime/providers/index.d.ts +8 -0
  51. package/dist/runtime/providers/index.mjs +8 -0
  52. package/dist/runtime/providers/laravel-jwt.d.ts +7 -0
  53. package/dist/runtime/providers/laravel-jwt.mjs +47 -0
  54. package/dist/runtime/providers/laravel-passport.d.ts +12 -0
  55. package/dist/runtime/providers/laravel-passport.mjs +69 -0
  56. package/dist/runtime/providers/laravel-sanctum.d.ts +6 -0
  57. package/dist/runtime/providers/laravel-sanctum.mjs +52 -0
  58. package/dist/runtime/schemes/auth0.d.ts +4 -0
  59. package/dist/runtime/schemes/auth0.mjs +13 -0
  60. package/dist/runtime/schemes/base.d.ts +8 -0
  61. package/dist/runtime/schemes/base.mjs +11 -0
  62. package/dist/runtime/schemes/cookie.d.ts +23 -0
  63. package/dist/runtime/schemes/cookie.mjs +111 -0
  64. package/dist/runtime/schemes/index.d.ts +8 -0
  65. package/dist/runtime/schemes/index.mjs +8 -0
  66. package/dist/runtime/schemes/laravel-jwt.d.ts +5 -0
  67. package/dist/runtime/schemes/laravel-jwt.mjs +6 -0
  68. package/dist/runtime/schemes/local.d.ts +38 -0
  69. package/dist/runtime/schemes/local.mjs +160 -0
  70. package/dist/runtime/schemes/oauth2.d.ts +61 -0
  71. package/dist/runtime/schemes/oauth2.mjs +374 -0
  72. package/dist/runtime/schemes/openIDConnect.d.ts +24 -0
  73. package/dist/runtime/schemes/openIDConnect.mjs +190 -0
  74. package/dist/runtime/schemes/refresh.d.ts +26 -0
  75. package/dist/runtime/schemes/refresh.mjs +141 -0
  76. package/dist/runtime/token-nitro.d.ts +2 -0
  77. package/dist/runtime/token-nitro.mjs +9 -0
  78. package/dist/types/index.d.ts +42 -0
  79. package/dist/types/openIDConnectConfigurationDocument.d.ts +31 -0
  80. package/dist/types/options.d.ts +125 -0
  81. package/dist/types/provider.d.ts +21 -0
  82. package/dist/types/request.d.ts +8 -0
  83. package/dist/types/router.d.ts +7 -0
  84. package/dist/types/scheme.d.ts +108 -0
  85. package/dist/types/store.d.ts +30 -0
  86. package/dist/types/strategy.d.ts +16 -0
  87. package/dist/types/utils.d.ts +5 -0
  88. package/dist/utils/index.d.ts +28 -0
  89. package/dist/utils/index.mjs +123 -0
  90. package/dist/utils/provider.d.ts +13 -0
  91. package/dist/utils/provider.mjs +360 -0
  92. package/package.json +5 -3
@@ -0,0 +1,277 @@
1
+ import { defineStore } from "pinia";
2
+ import { isUnset, isSet, decodeValue, encodeValue, setH3Cookie } from "../../utils";
3
+ import { parse, serialize } from "cookie-es";
4
+ import { watch } from "vue";
5
+ import { useState } from "#imports";
6
+ export class Storage {
7
+ ctx;
8
+ options;
9
+ #PiniaStore;
10
+ #initPiniaStore;
11
+ #initStore;
12
+ state;
13
+ #internal;
14
+ memory;
15
+ #piniaEnabled = false;
16
+ constructor(ctx, options) {
17
+ this.ctx = ctx;
18
+ this.options = options;
19
+ this.state = options.initialState;
20
+ this.#initState();
21
+ }
22
+ // ------------------------------------
23
+ // Universal
24
+ // ------------------------------------
25
+ setUniversal(key, value, include = { cookie: true, session: true, local: true }) {
26
+ if (isUnset(value)) {
27
+ return this.removeUniversal(key);
28
+ }
29
+ const storeMethods = {
30
+ cookie: (k, v, o) => this.setCookie(k, v, o),
31
+ session: (k, v) => this.setSessionStorage(k, v),
32
+ local: (k, v) => this.setLocalStorage(k, v)
33
+ };
34
+ Object.entries(include).filter(([_, shouldInclude]) => shouldInclude).forEach(([method, opts]) => {
35
+ if (method === "cookie" && typeof opts === "object") {
36
+ return storeMethods[method]?.(key, value, opts);
37
+ }
38
+ return storeMethods[method]?.(key, value);
39
+ });
40
+ this.setState(key, value);
41
+ return value;
42
+ }
43
+ getUniversal(key) {
44
+ const sourceOrder = [
45
+ () => this.getCookie(key),
46
+ () => this.getLocalStorage(key),
47
+ () => this.getSessionStorage(key),
48
+ () => this.getState(key)
49
+ ];
50
+ if (process.server) {
51
+ sourceOrder.unshift(() => this.getState(key));
52
+ }
53
+ for (let getter of sourceOrder) {
54
+ const value = getter();
55
+ if (!isUnset(value)) {
56
+ return value;
57
+ }
58
+ }
59
+ }
60
+ syncUniversal(key, defaultValue, include = { cookie: true, session: true, local: true }) {
61
+ let value = this.getUniversal(key);
62
+ if (isUnset(value) && isSet(defaultValue)) {
63
+ value = defaultValue;
64
+ }
65
+ if (isSet(value)) {
66
+ this.getCookie(key) ? this.setUniversal(key, value, { ...include, cookie: false }) : this.setUniversal(key, value, include);
67
+ }
68
+ return value;
69
+ }
70
+ removeUniversal(key) {
71
+ this.removeState(key);
72
+ this.removeCookie(key);
73
+ this.removeLocalStorage(key);
74
+ this.removeSessionStorage(key);
75
+ }
76
+ // ------------------------------------
77
+ // Local state (reactive)
78
+ // ------------------------------------
79
+ async #initState() {
80
+ const pinia = this.ctx.$pinia;
81
+ this.#piniaEnabled = this.options.stores.pinia?.enabled && !!pinia;
82
+ if (this.#piniaEnabled) {
83
+ this.#PiniaStore = defineStore(this.options.stores.pinia?.namespace, {
84
+ state: () => ({ ...this.options.initialState })
85
+ });
86
+ this.#initPiniaStore = this.#PiniaStore(pinia);
87
+ this.state = this.#initPiniaStore;
88
+ } else {
89
+ this.#initStore = useState(this.options.stores.state?.namespace, () => ({
90
+ ...this.options.initialState
91
+ }));
92
+ this.state = this.#initStore.value;
93
+ }
94
+ this.#internal = useState("auth-internal", () => ({}));
95
+ this.memory = this.#internal.value;
96
+ }
97
+ get pinia() {
98
+ return this.#initPiniaStore;
99
+ }
100
+ get store() {
101
+ return this.#initStore;
102
+ }
103
+ setState(key, value) {
104
+ if (key.startsWith("_")) {
105
+ this.memory[key] = value;
106
+ } else if (this.#piniaEnabled) {
107
+ this.#initPiniaStore.$patch({ [key]: value });
108
+ } else {
109
+ this.state[key] = value;
110
+ }
111
+ return this.state[key];
112
+ }
113
+ getState(key) {
114
+ if (!key.startsWith("_")) {
115
+ return this.state[key];
116
+ } else {
117
+ return this.memory[key];
118
+ }
119
+ }
120
+ watchState(watchKey, fn) {
121
+ if (this.#piniaEnabled) {
122
+ watch(() => this.#initPiniaStore?.[watchKey], (modified) => {
123
+ fn(modified);
124
+ }, { deep: true });
125
+ } else {
126
+ watch(() => this.#initStore?.value?.[watchKey], (modified) => {
127
+ fn(modified);
128
+ }, { deep: true });
129
+ }
130
+ }
131
+ removeState(key) {
132
+ this.setState(key, void 0);
133
+ }
134
+ // ------------------------------------
135
+ // Local storage
136
+ // ------------------------------------
137
+ setLocalStorage(key, value) {
138
+ if (isUnset(value)) {
139
+ return this.removeLocalStorage(key);
140
+ }
141
+ if (!this.isLocalStorageEnabled()) return;
142
+ try {
143
+ const prefixedKey = `${this.options.stores.local?.prefix}${key}`;
144
+ localStorage.setItem(prefixedKey, encodeValue(value));
145
+ } catch (e) {
146
+ if (!this.options.ignoreExceptions) throw e;
147
+ }
148
+ return value;
149
+ }
150
+ getLocalStorage(key) {
151
+ if (!this.isLocalStorageEnabled()) {
152
+ return;
153
+ }
154
+ const prefixedKey = `${this.options.stores.local?.prefix}${key}`;
155
+ return decodeValue(localStorage.getItem(prefixedKey));
156
+ }
157
+ removeLocalStorage(key) {
158
+ if (!this.isLocalStorageEnabled()) {
159
+ return;
160
+ }
161
+ const prefixedKey = `${this.options.stores.local?.prefix}${key}`;
162
+ localStorage.removeItem(prefixedKey);
163
+ }
164
+ isLocalStorageEnabled() {
165
+ const isNotServer = !process.server;
166
+ const isConfigEnabled = this.options.stores.local?.enabled;
167
+ const localTest = "test";
168
+ if (isNotServer && isConfigEnabled) {
169
+ try {
170
+ localStorage.setItem(localTest, localTest);
171
+ localStorage.removeItem(localTest);
172
+ return true;
173
+ } catch (e) {
174
+ if (!this.options.ignoreExceptions) {
175
+ console.warn("[AUTH] Local storage is enabled in config, but the browser does not support it.");
176
+ }
177
+ }
178
+ }
179
+ return false;
180
+ }
181
+ // ------------------------------------
182
+ // Session storage
183
+ // ------------------------------------
184
+ setSessionStorage(key, value) {
185
+ if (isUnset(value)) {
186
+ return this.removeSessionStorage(key);
187
+ }
188
+ if (!this.isSessionStorageEnabled()) return;
189
+ try {
190
+ const prefixedKey = `${this.options.stores.session.prefix}${key}`;
191
+ sessionStorage.setItem(prefixedKey, encodeValue(value));
192
+ } catch (e) {
193
+ if (!this.options.ignoreExceptions) throw e;
194
+ }
195
+ return value;
196
+ }
197
+ getSessionStorage(key) {
198
+ if (!this.isSessionStorageEnabled()) {
199
+ return;
200
+ }
201
+ const prefixedKey = this.options.stores.session.prefix + key;
202
+ const value = sessionStorage.getItem(prefixedKey);
203
+ return decodeValue(value);
204
+ }
205
+ removeSessionStorage(key) {
206
+ if (!this.isSessionStorageEnabled()) {
207
+ return;
208
+ }
209
+ const prefixedKey = this.options.stores.session.prefix + key;
210
+ sessionStorage.removeItem(prefixedKey);
211
+ }
212
+ isSessionStorageEnabled() {
213
+ const isNotServer = !process.server;
214
+ const isConfigEnabled = this.options.stores.session?.enabled;
215
+ const testKey = "test";
216
+ if (isNotServer && isConfigEnabled) {
217
+ try {
218
+ sessionStorage.setItem(testKey, testKey);
219
+ sessionStorage.removeItem(testKey);
220
+ return true;
221
+ } catch (e) {
222
+ if (!this.options.ignoreExceptions) {
223
+ console.warn("[AUTH] Session storage is enabled in config, but the browser does not support it.");
224
+ }
225
+ }
226
+ }
227
+ return false;
228
+ }
229
+ // ------------------------------------
230
+ // Cookie Storage
231
+ // ------------------------------------
232
+ setCookie(key, value, options = {}) {
233
+ if (!this.isCookiesEnabled()) {
234
+ return;
235
+ }
236
+ const prefix = this.options.stores.cookie?.prefix;
237
+ const prefixedKey = `${prefix}${key}`;
238
+ const $value = encodeValue(value);
239
+ const $options = { ...this.options.stores.cookie?.options, ...options };
240
+ if (isUnset(value)) {
241
+ $options.maxAge = -1;
242
+ }
243
+ const cookieString = serialize(prefixedKey, $value, $options);
244
+ if (process.client) {
245
+ document.cookie = cookieString;
246
+ } else if (process.server && this.ctx.ssrContext?.event.node.res) {
247
+ setH3Cookie(this.ctx.ssrContext.event, cookieString);
248
+ }
249
+ }
250
+ getCookies() {
251
+ if (!this.isCookiesEnabled()) {
252
+ return;
253
+ }
254
+ const cookieStr = process.client ? document.cookie : this.ctx.ssrContext.event.node.req.headers.cookie;
255
+ return parse(cookieStr || "") || {};
256
+ }
257
+ getCookie(key) {
258
+ if (!this.isCookiesEnabled()) {
259
+ return;
260
+ }
261
+ const prefixedKey = this.options.stores.cookie?.prefix + key;
262
+ const cookies = this.getCookies();
263
+ return decodeValue(cookies[prefixedKey] ? decodeURIComponent(cookies[prefixedKey]) : void 0);
264
+ }
265
+ removeCookie(key, options) {
266
+ this.setCookie(key, void 0, options);
267
+ }
268
+ isCookiesEnabled() {
269
+ const isNotClient = process.server;
270
+ const isConfigEnabled = this.options.stores.cookie?.enabled;
271
+ if (isConfigEnabled) {
272
+ if (isNotClient || window.navigator.cookieEnabled) return true;
273
+ console.warn("[AUTH] Cookies are enabled in config, but the browser does not support it.");
274
+ }
275
+ return false;
276
+ }
277
+ }
@@ -0,0 +1,3 @@
1
+ export declare class ConfigurationDocumentRequestError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,6 @@
1
+ export class ConfigurationDocumentRequestError extends Error {
2
+ constructor() {
3
+ super("Error loading OpenIDConnect configuration document");
4
+ this.name = "ConfigurationDocumentRequestError";
5
+ }
6
+ }
@@ -0,0 +1,26 @@
1
+ import { OpenIDConnectScheme } from '../schemes';
2
+ import { type OpenIDConnectConfigurationDocument } from '../../types';
3
+ import { Storage } from '../core/storage';
4
+ /**
5
+ * A metadata document that contains most of the OpenID Provider's information,
6
+ * such as the URLs to use and the location of the service's public signing keys.
7
+ * You can find this document by appending the discovery document path
8
+ * (/.well-known/openid-configuration) to the authority URL(https://example.com)
9
+ * Eg. https://example.com/.well-known/openid-configuration
10
+ *
11
+ * More info: https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderConfig
12
+ */
13
+ export declare class ConfigurationDocument {
14
+ #private;
15
+ scheme: OpenIDConnectScheme;
16
+ $storage: Storage;
17
+ key: string;
18
+ constructor(scheme: OpenIDConnectScheme, storage: Storage);
19
+ get(): OpenIDConnectConfigurationDocument;
20
+ set(value: OpenIDConnectConfigurationDocument | boolean): boolean | OpenIDConnectConfigurationDocument;
21
+ request(): Promise<void>;
22
+ validate(): void;
23
+ init(): Promise<void>;
24
+ setSchemeEndpoints(): void;
25
+ reset(): void;
26
+ }
@@ -0,0 +1,94 @@
1
+ import { ConfigurationDocumentRequestError } from "./configuration-document-request-error.mjs";
2
+ import { defu } from "defu";
3
+ const ConfigurationDocumentWarning = (message) => console.warn(`[AUTH] [OPENID CONNECT] Invalid configuration. ${message}`);
4
+ export class ConfigurationDocument {
5
+ scheme;
6
+ $storage;
7
+ key;
8
+ constructor(scheme, storage) {
9
+ this.scheme = scheme;
10
+ this.$storage = storage;
11
+ this.key = "_configuration_document." + this.scheme.name;
12
+ }
13
+ #set(value) {
14
+ return this.$storage.setState(this.key, value);
15
+ }
16
+ get() {
17
+ return this.$storage.getState(this.key);
18
+ }
19
+ set(value) {
20
+ this.#set(value);
21
+ return value;
22
+ }
23
+ async request() {
24
+ const serverDoc = this.scheme.$auth.ctx.payload.data.$auth?.openIDConnect?.configurationDocument;
25
+ if (process.client && serverDoc) {
26
+ this.set(serverDoc);
27
+ }
28
+ if (!this.get()) {
29
+ const configurationDocument = await this.scheme.requestHandler.http.$get(this.scheme.options.endpoints.configuration).catch((e) => Promise.reject(e));
30
+ if (process.server) {
31
+ this.scheme.$auth.ctx.payload.data = {
32
+ ...this.scheme.$auth.ctx.payload.data,
33
+ $auth: {
34
+ /* use `openIDConnect` instead of `oidc` because it could not be picked up by `serverDoc` */
35
+ openIDConnect: {
36
+ configurationDocument
37
+ }
38
+ }
39
+ };
40
+ }
41
+ this.set(configurationDocument);
42
+ }
43
+ }
44
+ validate() {
45
+ const mapping = {
46
+ responseType: "response_types_supported",
47
+ scope: "scopes_supported",
48
+ grantType: "grant_types_supported",
49
+ acrValues: "acr_values_supported"
50
+ };
51
+ Object.keys(mapping).forEach((optionsKey) => {
52
+ const configDocument = this.get();
53
+ const configDocumentKey = mapping[optionsKey];
54
+ const configDocumentValues = configDocument[configDocumentKey];
55
+ const optionsValues = this.scheme.options[optionsKey];
56
+ if (typeof configDocumentValues !== "undefined") {
57
+ if (Array.isArray(optionsValues) && Array.isArray(configDocumentValues)) {
58
+ optionsValues.forEach((optionsValue) => {
59
+ if (!configDocumentValues.includes(optionsValue)) {
60
+ ConfigurationDocumentWarning(
61
+ `A value of scheme options ${optionsKey} is not supported by ${configDocumentKey} of by Authorization Server.`
62
+ );
63
+ }
64
+ });
65
+ }
66
+ if (!Array.isArray(optionsValues) && Array.isArray(configDocumentValues) && !configDocumentValues.includes(optionsValues)) {
67
+ ConfigurationDocumentWarning(`Value of scheme option ${optionsKey} is not supported by ${configDocumentKey} of by Authorization Server.`);
68
+ }
69
+ if (!Array.isArray(optionsValues) && !Array.isArray(configDocumentValues) && configDocumentValues !== optionsValues) {
70
+ ConfigurationDocumentWarning(`Value of scheme option ${optionsKey} is not supported by ${configDocumentKey} of by Authorization Server.`);
71
+ }
72
+ }
73
+ });
74
+ }
75
+ async init() {
76
+ await this.request().catch(() => {
77
+ throw new ConfigurationDocumentRequestError();
78
+ });
79
+ this.validate();
80
+ this.setSchemeEndpoints();
81
+ }
82
+ setSchemeEndpoints() {
83
+ const configurationDocument = this.get();
84
+ this.scheme.options.endpoints = defu(this.scheme.options.endpoints, {
85
+ authorization: configurationDocument.authorization_endpoint,
86
+ token: configurationDocument.token_endpoint,
87
+ userInfo: configurationDocument.userinfo_endpoint,
88
+ logout: configurationDocument.end_session_endpoint
89
+ });
90
+ }
91
+ reset() {
92
+ this.#set(false);
93
+ }
94
+ }
@@ -0,0 +1,123 @@
1
+ export declare const OAUTH2DEFAULTS: {
2
+ accessType: undefined;
3
+ redirectUri: undefined;
4
+ logoutRedirectUri: undefined;
5
+ clientId: undefined;
6
+ clientSecretTransport: string;
7
+ audience: undefined;
8
+ grantType: undefined;
9
+ responseMode: undefined;
10
+ acrValues: undefined;
11
+ autoLogout: boolean;
12
+ endpoints: {
13
+ logout: undefined;
14
+ authorization: undefined;
15
+ token: undefined;
16
+ userInfo: undefined;
17
+ };
18
+ scope: never[];
19
+ token: {
20
+ property: string;
21
+ expiresProperty: string;
22
+ type: string;
23
+ name: string;
24
+ maxAge: boolean;
25
+ global: boolean;
26
+ prefix: string;
27
+ expirationPrefix: string;
28
+ };
29
+ idToken: {
30
+ property: string;
31
+ maxAge: number;
32
+ prefix: string;
33
+ expirationPrefix: string;
34
+ httpOnly: boolean;
35
+ };
36
+ refreshToken: {
37
+ property: string;
38
+ maxAge: number;
39
+ prefix: string;
40
+ expirationPrefix: string;
41
+ httpOnly: boolean;
42
+ };
43
+ user: {
44
+ property: boolean;
45
+ };
46
+ responseType: string;
47
+ codeChallengeMethod: boolean;
48
+ clientWindow: boolean;
49
+ clientWindowWidth: number;
50
+ clientWindowHeight: number;
51
+ };
52
+ export declare const LOCALDEFAULTS: {
53
+ cookie: {
54
+ name: undefined;
55
+ };
56
+ endpoints: {
57
+ csrf: {
58
+ url: string;
59
+ };
60
+ login: {
61
+ url: string;
62
+ method: string;
63
+ };
64
+ logout: {
65
+ url: string;
66
+ method: string;
67
+ };
68
+ user: {
69
+ url: string;
70
+ method: string;
71
+ };
72
+ refresh: {
73
+ url: string;
74
+ method: string;
75
+ };
76
+ };
77
+ token: {
78
+ expiresProperty: string;
79
+ property: string;
80
+ type: string;
81
+ name: string;
82
+ maxAge: boolean;
83
+ global: boolean;
84
+ required: boolean;
85
+ prefix: string;
86
+ expirationPrefix: string;
87
+ httpOnly: boolean;
88
+ };
89
+ refreshToken: {
90
+ property: string;
91
+ data: string;
92
+ maxAge: number;
93
+ required: boolean;
94
+ tokenRequired: boolean;
95
+ prefix: string;
96
+ expirationPrefix: string;
97
+ httpOnly: boolean;
98
+ };
99
+ autoLogout: boolean;
100
+ user: {
101
+ property: string;
102
+ autoFetch: boolean;
103
+ };
104
+ clientId: undefined;
105
+ grantType: undefined;
106
+ scope: undefined;
107
+ };
108
+ export declare const ProviderAliases: {
109
+ 'laravel/jwt': string;
110
+ 'laravel/passport': string;
111
+ 'laravel/sanctum': string;
112
+ };
113
+ export declare const BuiltinSchemes: {
114
+ local: string;
115
+ cookie: string;
116
+ refresh: string;
117
+ laravelJWT: string;
118
+ oauth2: string;
119
+ openIDConnect: string;
120
+ auth0: string;
121
+ };
122
+ export declare const LocalSchemes: string[];
123
+ export declare const OAuth2Schemes: string[];
@@ -0,0 +1,132 @@
1
+ export const OAUTH2DEFAULTS = {
2
+ accessType: void 0,
3
+ redirectUri: void 0,
4
+ logoutRedirectUri: void 0,
5
+ clientId: void 0,
6
+ clientSecretTransport: "body",
7
+ audience: void 0,
8
+ grantType: void 0,
9
+ responseMode: void 0,
10
+ acrValues: void 0,
11
+ autoLogout: false,
12
+ endpoints: {
13
+ logout: void 0,
14
+ authorization: void 0,
15
+ token: void 0,
16
+ userInfo: void 0
17
+ },
18
+ scope: [],
19
+ token: {
20
+ property: "access_token",
21
+ expiresProperty: "expires_in",
22
+ type: "Bearer",
23
+ name: "Authorization",
24
+ maxAge: false,
25
+ global: true,
26
+ prefix: "_token.",
27
+ expirationPrefix: "_token_expiration."
28
+ },
29
+ idToken: {
30
+ property: "id_token",
31
+ maxAge: 1800,
32
+ prefix: "_id_token.",
33
+ expirationPrefix: "_id_token_expiration.",
34
+ httpOnly: false
35
+ },
36
+ refreshToken: {
37
+ property: "refresh_token",
38
+ maxAge: 60 * 60 * 24 * 30,
39
+ prefix: "_refresh_token.",
40
+ expirationPrefix: "_refresh_token_expiration.",
41
+ httpOnly: false
42
+ },
43
+ user: {
44
+ property: false
45
+ },
46
+ responseType: "token",
47
+ codeChallengeMethod: false,
48
+ clientWindow: false,
49
+ clientWindowWidth: 400,
50
+ clientWindowHeight: 600
51
+ };
52
+ export const LOCALDEFAULTS = {
53
+ cookie: {
54
+ name: void 0
55
+ },
56
+ endpoints: {
57
+ csrf: {
58
+ url: "/api/csrf-cookie"
59
+ },
60
+ login: {
61
+ url: "/api/auth/login",
62
+ method: "post"
63
+ },
64
+ logout: {
65
+ url: "/api/auth/logout",
66
+ method: "post"
67
+ },
68
+ user: {
69
+ url: "/api/auth/user",
70
+ method: "get"
71
+ },
72
+ refresh: {
73
+ url: "/api/auth/refresh",
74
+ method: "post"
75
+ }
76
+ },
77
+ token: {
78
+ expiresProperty: "expires_in",
79
+ property: "token",
80
+ type: "Bearer",
81
+ name: "Authorization",
82
+ maxAge: false,
83
+ global: true,
84
+ required: true,
85
+ prefix: "_token.",
86
+ expirationPrefix: "_token_expiration.",
87
+ httpOnly: false
88
+ },
89
+ refreshToken: {
90
+ property: "refresh_token",
91
+ data: "refresh_token",
92
+ maxAge: 60 * 60 * 24 * 30,
93
+ required: true,
94
+ tokenRequired: false,
95
+ prefix: "_refresh_token.",
96
+ expirationPrefix: "_refresh_token_expiration.",
97
+ httpOnly: false
98
+ },
99
+ autoLogout: false,
100
+ user: {
101
+ property: "user",
102
+ autoFetch: true
103
+ },
104
+ clientId: void 0,
105
+ grantType: void 0,
106
+ scope: void 0
107
+ };
108
+ export const ProviderAliases = {
109
+ "laravel/jwt": "laravelJWT",
110
+ "laravel/passport": "laravelPassport",
111
+ "laravel/sanctum": "laravelSanctum"
112
+ };
113
+ export const BuiltinSchemes = {
114
+ local: "LocalScheme",
115
+ cookie: "CookieScheme",
116
+ refresh: "RefreshScheme",
117
+ laravelJWT: "LaravelJWTScheme",
118
+ oauth2: "Oauth2Scheme",
119
+ openIDConnect: "OpenIDConnectScheme",
120
+ auth0: "Auth0Scheme"
121
+ };
122
+ export const LocalSchemes = [
123
+ "local",
124
+ "cookie",
125
+ "refresh",
126
+ "laravelJWT"
127
+ ];
128
+ export const OAuth2Schemes = [
129
+ "oauth",
130
+ "openIDConnect",
131
+ "auth0"
132
+ ];
@@ -0,0 +1,3 @@
1
+ export declare class ExpiredAuthSessionError extends Error {
2
+ constructor();
3
+ }
@@ -0,0 +1,6 @@
1
+ export class ExpiredAuthSessionError extends Error {
2
+ constructor() {
3
+ super("Both token and refresh token have expired. Your request was aborted.");
4
+ this.name = "ExpiredAuthSessionError";
5
+ }
6
+ }
@@ -0,0 +1,15 @@
1
+ import type { IdTokenableScheme } from '../../types';
2
+ import type { Storage } from '../core';
3
+ import { TokenStatus } from './token-status';
4
+ export declare class IdToken {
5
+ #private;
6
+ scheme: IdTokenableScheme;
7
+ $storage: Storage;
8
+ constructor(scheme: IdTokenableScheme, storage: Storage);
9
+ get(): string | boolean;
10
+ set(tokenValue: string | boolean): string | boolean;
11
+ sync(): string | boolean | void | null | undefined;
12
+ reset(): void;
13
+ status(): TokenStatus;
14
+ userInfo(): import("../../types").UserInfo | undefined;
15
+ }