@adonisjs/auth 9.0.0-9 → 9.0.0

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 (125) hide show
  1. package/build/chunk-3HZHOWKL.js +8 -0
  2. package/build/chunk-3HZHOWKL.js.map +1 -0
  3. package/build/chunk-52DVKHJR.js +246 -0
  4. package/build/chunk-52DVKHJR.js.map +1 -0
  5. package/build/chunk-BHB55PBJ.js +197 -0
  6. package/build/chunk-BHB55PBJ.js.map +1 -0
  7. package/build/chunk-CZCFTIBB.js +21 -0
  8. package/build/chunk-CZCFTIBB.js.map +1 -0
  9. package/build/index.d.ts +7 -6
  10. package/build/index.js +146 -15
  11. package/build/index.js.map +1 -0
  12. package/build/modules/access_tokens_guard/access_token.d.ts +137 -0
  13. package/build/modules/access_tokens_guard/crc32.d.ts +16 -0
  14. package/build/modules/access_tokens_guard/define_config.d.ts +17 -0
  15. package/build/modules/access_tokens_guard/guard.d.ts +81 -0
  16. package/build/modules/access_tokens_guard/main.d.ts +5 -0
  17. package/build/modules/access_tokens_guard/main.js +929 -0
  18. package/build/modules/access_tokens_guard/main.js.map +1 -0
  19. package/build/modules/access_tokens_guard/token_providers/db.d.ts +76 -0
  20. package/build/modules/access_tokens_guard/types.d.ts +208 -0
  21. package/build/modules/access_tokens_guard/types.js +1 -0
  22. package/build/modules/access_tokens_guard/types.js.map +1 -0
  23. package/build/modules/access_tokens_guard/user_providers/lucid.d.ts +53 -0
  24. package/build/modules/session_guard/define_config.d.ts +17 -0
  25. package/build/modules/session_guard/guard.d.ts +98 -0
  26. package/build/modules/session_guard/main.d.ts +5 -0
  27. package/build/modules/session_guard/main.js +741 -0
  28. package/build/modules/session_guard/main.js.map +1 -0
  29. package/build/modules/session_guard/remember_me_token.d.ts +88 -0
  30. package/build/modules/session_guard/token_providers/db.d.ts +69 -0
  31. package/build/modules/session_guard/types.d.ts +243 -0
  32. package/build/modules/session_guard/types.js +1 -0
  33. package/build/modules/session_guard/types.js.map +1 -0
  34. package/build/modules/session_guard/user_providers/lucid.d.ts +57 -0
  35. package/build/providers/auth_provider.d.ts +1 -1
  36. package/build/providers/auth_provider.js +31 -27
  37. package/build/providers/auth_provider.js.map +1 -0
  38. package/build/services/auth.d.ts +1 -1
  39. package/build/services/auth.js +10 -15
  40. package/build/services/auth.js.map +1 -0
  41. package/build/src/{auth/auth_manager.d.ts → auth_manager.d.ts} +8 -3
  42. package/build/src/authenticator.d.ts +81 -0
  43. package/build/src/{auth/authenticator_client.d.ts → authenticator_client.d.ts} +4 -4
  44. package/build/src/{auth/define_config.d.ts → define_config.d.ts} +0 -10
  45. package/build/src/errors.d.ts +105 -0
  46. package/build/src/{auth/middleware → middleware}/initialize_auth_middleware.d.ts +3 -2
  47. package/build/src/middleware/initialize_auth_middleware.js +17 -0
  48. package/build/src/middleware/initialize_auth_middleware.js.map +1 -0
  49. package/build/src/mixins/with_auth_finder.d.ts +156 -0
  50. package/build/src/{auth/plugins → plugins}/japa/api_client.d.ts +8 -8
  51. package/build/src/plugins/japa/api_client.js +59 -0
  52. package/build/src/plugins/japa/api_client.js.map +1 -0
  53. package/build/src/{auth/plugins → plugins}/japa/browser_client.d.ts +10 -7
  54. package/build/src/plugins/japa/browser_client.js +67 -0
  55. package/build/src/plugins/japa/browser_client.js.map +1 -0
  56. package/build/src/{auth/types.d.ts → types.d.ts} +31 -26
  57. package/build/src/types.js +1 -0
  58. package/build/src/types.js.map +1 -0
  59. package/package.json +88 -68
  60. package/build/configure.js +0 -47
  61. package/build/factories/basic_auth_guard_factory.d.ts +0 -12
  62. package/build/factories/basic_auth_guard_factory.js +0 -22
  63. package/build/factories/database_token_factory.d.ts +0 -36
  64. package/build/factories/database_token_factory.js +0 -54
  65. package/build/factories/database_user_provider.d.ts +0 -14
  66. package/build/factories/database_user_provider.js +0 -27
  67. package/build/factories/lucid_user_provider.d.ts +0 -28
  68. package/build/factories/lucid_user_provider.js +0 -68
  69. package/build/factories/main.d.ts +0 -4
  70. package/build/factories/main.js +0 -12
  71. package/build/factories/session_guard_factory.d.ts +0 -13
  72. package/build/factories/session_guard_factory.js +0 -24
  73. package/build/src/auth/auth_manager.js +0 -41
  74. package/build/src/auth/authenticator.d.ts +0 -63
  75. package/build/src/auth/authenticator.js +0 -129
  76. package/build/src/auth/authenticator_client.js +0 -59
  77. package/build/src/auth/debug.js +0 -10
  78. package/build/src/auth/define_config.js +0 -54
  79. package/build/src/auth/errors.d.ts +0 -90
  80. package/build/src/auth/errors.js +0 -201
  81. package/build/src/auth/middleware/initialize_auth_middleware.js +0 -25
  82. package/build/src/auth/plugins/japa/api_client.js +0 -63
  83. package/build/src/auth/plugins/japa/browser_client.js +0 -64
  84. package/build/src/auth/symbols.js +0 -17
  85. package/build/src/auth/types.js +0 -9
  86. package/build/src/auth/user_providers/main.d.ts +0 -15
  87. package/build/src/auth/user_providers/main.js +0 -22
  88. package/build/src/core/guard_user.d.ts +0 -26
  89. package/build/src/core/guard_user.js +0 -29
  90. package/build/src/core/token.d.ts +0 -89
  91. package/build/src/core/token.js +0 -114
  92. package/build/src/core/token_providers/database.d.ts +0 -77
  93. package/build/src/core/token_providers/database.js +0 -113
  94. package/build/src/core/types.d.ts +0 -178
  95. package/build/src/core/types.js +0 -9
  96. package/build/src/core/user_providers/database.d.ts +0 -78
  97. package/build/src/core/user_providers/database.js +0 -117
  98. package/build/src/core/user_providers/lucid.d.ts +0 -61
  99. package/build/src/core/user_providers/lucid.js +0 -122
  100. package/build/src/guards/basic_auth/define_config.d.ts +0 -16
  101. package/build/src/guards/basic_auth/define_config.js +0 -38
  102. package/build/src/guards/basic_auth/guard.d.ts +0 -70
  103. package/build/src/guards/basic_auth/guard.js +0 -190
  104. package/build/src/guards/basic_auth/main.d.ts +0 -2
  105. package/build/src/guards/basic_auth/main.js +0 -10
  106. package/build/src/guards/basic_auth/types.d.ts +0 -35
  107. package/build/src/guards/basic_auth/types.js +0 -9
  108. package/build/src/guards/session/define_config.d.ts +0 -23
  109. package/build/src/guards/session/define_config.js +0 -56
  110. package/build/src/guards/session/guard.d.ts +0 -123
  111. package/build/src/guards/session/guard.js +0 -510
  112. package/build/src/guards/session/main.d.ts +0 -3
  113. package/build/src/guards/session/main.js +0 -11
  114. package/build/src/guards/session/token.d.ts +0 -57
  115. package/build/src/guards/session/token.js +0 -58
  116. package/build/src/guards/session/token_providers/main.d.ts +0 -33
  117. package/build/src/guards/session/token_providers/main.js +0 -42
  118. package/build/src/guards/session/types.d.ts +0 -104
  119. package/build/src/guards/session/types.js +0 -9
  120. package/build/stubs/main.d.ts +0 -1
  121. package/build/stubs/main.js +0 -10
  122. package/build/stubs/middleware/auth_middleware.stub +0 -30
  123. package/build/stubs/middleware/guest_middleware.stub +0 -36
  124. /package/build/src/{auth/debug.d.ts → debug.d.ts} +0 -0
  125. /package/build/src/{auth/symbols.d.ts → symbols.d.ts} +0 -0
@@ -1,58 +0,0 @@
1
- /*
2
- * @adonisjs/auth
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { Token } from '../../core/token.js';
10
- /**
11
- * Remember me token represents a remember me token created
12
- * for a peristed login flow.
13
- */
14
- export class RememberMeToken extends Token {
15
- userId;
16
- series;
17
- value;
18
- hash;
19
- /**
20
- * Static name for the token to uniquely identify a
21
- * bucket of tokens
22
- */
23
- type = 'remember_me_token';
24
- constructor(
25
- /**
26
- * Reference to the user id for whom the token
27
- * is generated
28
- */
29
- userId,
30
- /**
31
- * Series is a random number stored inside the database as it is
32
- */
33
- series,
34
- /**
35
- * Value is a random number only available at the time of issuing
36
- * the token. Afterwards, the value is undefined.
37
- */
38
- value,
39
- /**
40
- * Hash reference to the token hash
41
- */
42
- hash) {
43
- super(series, value, hash);
44
- this.userId = userId;
45
- this.series = series;
46
- this.value = value;
47
- this.hash = hash;
48
- }
49
- /**
50
- * Create remember me token instance for a user
51
- */
52
- static create(userId, expiry, size) {
53
- const { series, value, hash } = this.seed(size);
54
- const token = new RememberMeToken(userId, series, value, hash);
55
- token.setExpiry(expiry);
56
- return token;
57
- }
58
- }
@@ -1,33 +0,0 @@
1
- import { RememberMeToken } from '../token.js';
2
- import type { RememberMeProviderContract } from '../types.js';
3
- import { DatabaseTokenProvider } from '../../../core/token_providers/database.js';
4
- /**
5
- * Remember me token provider to persist tokens inside the database
6
- * using db query builder.
7
- */
8
- export declare class DatabaseRememberTokenProvider extends DatabaseTokenProvider<RememberMeToken> implements RememberMeProviderContract {
9
- /**
10
- * Prepares a token from the database result
11
- */
12
- protected prepareToken(dbRow: {
13
- series: string;
14
- user_id: string | number;
15
- type: string;
16
- token: string;
17
- created_at: Date;
18
- updated_at: Date;
19
- expires_at: Date | null;
20
- }): RememberMeToken;
21
- /**
22
- * Converts the remember me token into a database row
23
- */
24
- protected parseToken(token: RememberMeToken): {
25
- series: string;
26
- user_id: string | number;
27
- type: string;
28
- token: string;
29
- created_at: Date;
30
- updated_at: Date;
31
- expires_at: Date | null;
32
- };
33
- }
@@ -1,42 +0,0 @@
1
- /*
2
- * @adonisjs/auth
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { RememberMeToken } from '../token.js';
10
- import { DatabaseTokenProvider } from '../../../core/token_providers/database.js';
11
- /**
12
- * Remember me token provider to persist tokens inside the database
13
- * using db query builder.
14
- */
15
- export class DatabaseRememberTokenProvider extends DatabaseTokenProvider {
16
- /**
17
- * Prepares a token from the database result
18
- */
19
- prepareToken(dbRow) {
20
- const token = new RememberMeToken(dbRow.user_id, dbRow.series, undefined, dbRow.token);
21
- if (dbRow.expires_at) {
22
- token.expiresAt = dbRow.expires_at;
23
- }
24
- token.createdAt = dbRow.created_at;
25
- token.updatedAt = dbRow.updated_at;
26
- return token;
27
- }
28
- /**
29
- * Converts the remember me token into a database row
30
- */
31
- parseToken(token) {
32
- return {
33
- series: token.series,
34
- user_id: token.userId,
35
- type: token.type,
36
- token: token.hash,
37
- created_at: token.createdAt,
38
- updated_at: token.updatedAt,
39
- expires_at: token.expiresAt,
40
- };
41
- }
42
- }
@@ -1,104 +0,0 @@
1
- import type { Exception } from '@poppinss/utils';
2
- import type { RememberMeToken } from './token.js';
3
- import type { UserProviderContract, TokenProviderContract, DatabaseTokenProviderOptions } from '../../core/types.js';
4
- /**
5
- * The SessionUserProvider is used to lookup a user for session based authentication.
6
- */
7
- export interface SessionUserProviderContract<RealUser> extends UserProviderContract<RealUser> {
8
- }
9
- /**
10
- * The RememberMeProviderContract is used to persist and lookup tokens for
11
- * session based authentication with remember me option.
12
- */
13
- export interface RememberMeProviderContract extends TokenProviderContract<RememberMeToken> {
14
- }
15
- /**
16
- * Config accepted by the session guard
17
- */
18
- export type SessionGuardConfig = {
19
- /**
20
- * The expiry for the remember me cookie.
21
- *
22
- * Defaults to "5 years"
23
- */
24
- rememberMeTokenAge?: string | number;
25
- };
26
- /**
27
- * Events emitted by the session guard
28
- */
29
- export type SessionGuardEvents<User> = {
30
- /**
31
- * The event is emitted when the user credentials
32
- * have been verified successfully.
33
- */
34
- 'session_auth:credentials_verified': {
35
- guardName: string;
36
- uid: string;
37
- user: User;
38
- };
39
- /**
40
- * The event is emitted when unable to login the
41
- * user.
42
- */
43
- 'session_auth:login_failed': {
44
- guardName: string;
45
- error: Exception;
46
- user: User | null;
47
- };
48
- /**
49
- * The event is emitted when login is attempted for
50
- * a given user.
51
- */
52
- 'session_auth:login_attempted': {
53
- guardName: string;
54
- user: User;
55
- };
56
- /**
57
- * The event is emitted when user has been logged in
58
- * successfully
59
- */
60
- 'session_auth:login_succeeded': {
61
- guardName: string;
62
- user: User;
63
- sessionId: string;
64
- rememberMeToken?: RememberMeToken;
65
- };
66
- /**
67
- * Attempting to authenticate the user
68
- */
69
- 'session_auth:authentication_attempted': {
70
- guardName: string;
71
- sessionId: string;
72
- };
73
- /**
74
- * Authentication was successful
75
- */
76
- 'session_auth:authentication_succeeded': {
77
- guardName: string;
78
- user: User;
79
- sessionId: string;
80
- rememberMeToken?: RememberMeToken;
81
- };
82
- /**
83
- * Authentication failed
84
- */
85
- 'session_auth:authentication_failed': {
86
- guardName: string;
87
- error: Exception;
88
- sessionId: string;
89
- };
90
- /**
91
- * The event is emitted when user has been logged out
92
- * sucessfully
93
- */
94
- 'session_auth:logged_out': {
95
- guardName: string;
96
- user: User | null;
97
- sessionId: string;
98
- };
99
- };
100
- /**
101
- * Options accepted by the database implementation of the
102
- * RememberMeProvider
103
- */
104
- export type DatabaseRememberMeProviderOptions = DatabaseTokenProviderOptions;
@@ -1,9 +0,0 @@
1
- /*
2
- * @adonisjs/auth
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- export {};
@@ -1 +0,0 @@
1
- export declare const stubsRoot: string;
@@ -1,10 +0,0 @@
1
- /*
2
- * @adonisjs/auth
3
- *
4
- * (c) AdonisJS
5
- *
6
- * For the full copyright and license information, please view the LICENSE
7
- * file that was distributed with this source code.
8
- */
9
- import { getDirname } from '@poppinss/utils';
10
- export const stubsRoot = getDirname(import.meta.url);
@@ -1,30 +0,0 @@
1
- {{#var middlewareName = generators.middlewareName(entity.name)}}
2
- {{#var middlewareFileName = generators.middlewareFileName(entity.name)}}
3
- {{{
4
- exports({ to: app.middlewarePath(entity.path, middlewareFileName) })
5
- }}}
6
- import type { HttpContext } from '@adonisjs/core/http'
7
- import type { NextFn } from '@adonisjs/core/types/http'
8
- import type { Authenticators } from '@adonisjs/auth/types'
9
-
10
- /**
11
- * Auth middleware is used authenticate HTTP requests and deny
12
- * access to unauthenticated users.
13
- */
14
- export default class {{ middlewareName }} {
15
- /**
16
- * The URL to redirect to, when authentication fails
17
- */
18
- redirectTo = '/login'
19
-
20
- async handle(
21
- ctx: HttpContext,
22
- next: NextFn,
23
- options: {
24
- guards?: (keyof Authenticators)[]
25
- } = {}
26
- ) {
27
- await ctx.auth.authenticateUsing(options.guards, { loginRoute: this.redirectTo })
28
- return next()
29
- }
30
- }
@@ -1,36 +0,0 @@
1
- {{#var middlewareName = generators.middlewareName(entity.name)}}
2
- {{#var middlewareFileName = generators.middlewareFileName(entity.name)}}
3
- {{{
4
- exports({ to: app.middlewarePath(entity.path, middlewareFileName) })
5
- }}}
6
- import type { HttpContext } from '@adonisjs/core/http'
7
- import type { NextFn } from '@adonisjs/core/types/http'
8
- import type { Authenticators } from '@adonisjs/auth/types'
9
-
10
- /**
11
- * Guest middleware is used to deny access to routes that should
12
- * be accessed by unauthenticated users.
13
- *
14
- * For example, the login page should not be accessible if the user
15
- * is already logged-in
16
- */
17
- export default class {{ middlewareName }} {
18
- /**
19
- * The URL to redirect to when user is logged-in
20
- */
21
- redirectTo = '/'
22
-
23
- async handle(
24
- ctx: HttpContext,
25
- next: NextFn,
26
- options: { guards?: (keyof Authenticators)[] } = {}
27
- ) {
28
- for (let guard of options.guards || [ctx.auth.defaultGuard]) {
29
- if (await ctx.auth.use(guard).check()) {
30
- return ctx.response.redirect(this.redirectTo, true)
31
- }
32
- }
33
-
34
- return next()
35
- }
36
- }
File without changes
File without changes