@adonisjs/auth 8.2.3 → 9.0.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 (134) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +19 -40
  3. package/build/configure.d.ts +5 -0
  4. package/build/configure.js +41 -0
  5. package/build/factories/database_token_factory.d.ts +36 -0
  6. package/build/factories/database_token_factory.js +54 -0
  7. package/build/factories/database_user_provider.d.ts +14 -0
  8. package/build/factories/database_user_provider.js +27 -0
  9. package/build/factories/lucid_user_provider.d.ts +28 -0
  10. package/build/factories/lucid_user_provider.js +68 -0
  11. package/build/factories/main.d.ts +4 -0
  12. package/build/factories/main.js +12 -0
  13. package/build/factories/session_guard_factory.d.ts +13 -0
  14. package/build/factories/session_guard_factory.js +24 -0
  15. package/build/index.d.ts +7 -0
  16. package/build/index.js +15 -0
  17. package/build/providers/auth_provider.d.ts +12 -0
  18. package/build/providers/auth_provider.js +27 -0
  19. package/build/services/auth.d.ts +3 -0
  20. package/build/services/auth.js +17 -0
  21. package/build/src/auth/auth_manager.d.ts +18 -0
  22. package/build/src/auth/auth_manager.js +28 -0
  23. package/build/src/auth/authenticator.d.ts +18 -0
  24. package/build/src/auth/authenticator.js +55 -0
  25. package/build/src/auth/debug.d.ts +3 -0
  26. package/build/{adonis-typings/container.js → src/auth/debug.js} +3 -1
  27. package/build/src/auth/define_config.d.ts +30 -0
  28. package/build/src/auth/define_config.js +54 -0
  29. package/build/src/auth/errors.d.ts +8 -0
  30. package/build/src/auth/errors.js +17 -0
  31. package/build/src/auth/symbols.d.ts +9 -0
  32. package/build/src/auth/symbols.js +17 -0
  33. package/build/src/auth/types.d.ts +52 -0
  34. package/build/{adonis-typings/context.js → src/auth/types.js} +2 -1
  35. package/build/src/auth/user_providers/main.d.ts +15 -0
  36. package/build/src/auth/user_providers/main.js +22 -0
  37. package/build/src/core/guard_user.d.ts +26 -0
  38. package/build/src/core/guard_user.js +29 -0
  39. package/build/src/core/token.d.ts +86 -0
  40. package/build/src/core/token.js +112 -0
  41. package/build/src/core/token_providers/database.d.ts +77 -0
  42. package/build/src/core/token_providers/database.js +113 -0
  43. package/build/src/core/types.d.ts +178 -0
  44. package/build/{adonis-typings/auth.js → src/core/types.js} +2 -1
  45. package/build/src/core/user_providers/database.d.ts +78 -0
  46. package/build/src/core/user_providers/database.js +117 -0
  47. package/build/src/core/user_providers/lucid.d.ts +61 -0
  48. package/build/src/core/user_providers/lucid.js +122 -0
  49. package/build/src/guards/session/define_config.d.ts +23 -0
  50. package/build/src/guards/session/define_config.js +56 -0
  51. package/build/src/guards/session/guard.d.ts +92 -0
  52. package/build/src/guards/session/guard.js +380 -0
  53. package/build/src/guards/session/main.d.ts +3 -0
  54. package/build/src/guards/session/main.js +11 -0
  55. package/build/src/guards/session/token.d.ts +57 -0
  56. package/build/src/guards/session/token.js +58 -0
  57. package/build/src/guards/session/token_providers/main.d.ts +33 -0
  58. package/build/src/guards/session/token_providers/main.js +42 -0
  59. package/build/src/guards/session/types.d.ts +97 -0
  60. package/build/{adonis-typings/events.js → src/guards/session/types.js} +2 -1
  61. package/build/stubs/config/auth_middleware.stub +12 -0
  62. package/build/stubs/config.stub +35 -0
  63. package/build/stubs/main.d.ts +1 -0
  64. package/build/{adonis-typings/tests.js → stubs/main.js} +2 -3
  65. package/package.json +96 -91
  66. package/build/adonis-typings/auth.d.ts +0 -635
  67. package/build/adonis-typings/container.d.ts +0 -6
  68. package/build/adonis-typings/context.d.ts +0 -6
  69. package/build/adonis-typings/events.d.ts +0 -10
  70. package/build/adonis-typings/index.d.ts +0 -5
  71. package/build/adonis-typings/index.js +0 -13
  72. package/build/adonis-typings/tests.d.ts +0 -23
  73. package/build/instructions.js +0 -338
  74. package/build/providers/AuthProvider.d.ts +0 -30
  75. package/build/providers/AuthProvider.js +0 -69
  76. package/build/src/Auth/index.d.ts +0 -97
  77. package/build/src/Auth/index.js +0 -155
  78. package/build/src/AuthManager/index.d.ts +0 -117
  79. package/build/src/AuthManager/index.js +0 -262
  80. package/build/src/Bindings/Tests.d.ts +0 -6
  81. package/build/src/Bindings/Tests.js +0 -69
  82. package/build/src/Clients/Oat/index.d.ts +0 -50
  83. package/build/src/Clients/Oat/index.js +0 -123
  84. package/build/src/Clients/Session/index.d.ts +0 -34
  85. package/build/src/Clients/Session/index.js +0 -72
  86. package/build/src/Exceptions/AuthenticationException.d.ts +0 -47
  87. package/build/src/Exceptions/AuthenticationException.js +0 -142
  88. package/build/src/Exceptions/InvalidCredentialsException.d.ts +0 -34
  89. package/build/src/Exceptions/InvalidCredentialsException.js +0 -112
  90. package/build/src/Guards/Base/index.d.ts +0 -75
  91. package/build/src/Guards/Base/index.js +0 -138
  92. package/build/src/Guards/BasicAuth/index.d.ts +0 -67
  93. package/build/src/Guards/BasicAuth/index.js +0 -181
  94. package/build/src/Guards/Oat/index.d.ts +0 -149
  95. package/build/src/Guards/Oat/index.js +0 -347
  96. package/build/src/Guards/Session/index.d.ts +0 -127
  97. package/build/src/Guards/Session/index.js +0 -338
  98. package/build/src/TokenProviders/Database/index.d.ts +0 -43
  99. package/build/src/TokenProviders/Database/index.js +0 -126
  100. package/build/src/TokenProviders/Redis/index.d.ts +0 -44
  101. package/build/src/TokenProviders/Redis/index.js +0 -129
  102. package/build/src/Tokens/OpaqueToken/index.d.ts +0 -46
  103. package/build/src/Tokens/OpaqueToken/index.js +0 -43
  104. package/build/src/Tokens/ProviderToken/index.d.ts +0 -23
  105. package/build/src/Tokens/ProviderToken/index.js +0 -27
  106. package/build/src/UserProviders/Database/User.d.ts +0 -28
  107. package/build/src/UserProviders/Database/User.js +0 -74
  108. package/build/src/UserProviders/Database/index.d.ts +0 -75
  109. package/build/src/UserProviders/Database/index.js +0 -141
  110. package/build/src/UserProviders/Lucid/User.d.ts +0 -28
  111. package/build/src/UserProviders/Lucid/User.js +0 -74
  112. package/build/src/UserProviders/Lucid/index.d.ts +0 -72
  113. package/build/src/UserProviders/Lucid/index.js +0 -146
  114. package/build/standalone.d.ts +0 -1
  115. package/build/standalone.js +0 -13
  116. package/build/templates/config/auth.txt +0 -34
  117. package/build/templates/config/partials/api-guard.txt +0 -22
  118. package/build/templates/config/partials/basic-guard.txt +0 -19
  119. package/build/templates/config/partials/tokens-provider-database.txt +0 -19
  120. package/build/templates/config/partials/tokens-provider-redis.txt +0 -22
  121. package/build/templates/config/partials/user-provider-database.txt +0 -43
  122. package/build/templates/config/partials/user-provider-lucid.txt +0 -45
  123. package/build/templates/config/partials/web-guard.txt +0 -17
  124. package/build/templates/contract/auth.txt +0 -55
  125. package/build/templates/contract/partials/api-guard.txt +0 -14
  126. package/build/templates/contract/partials/basic-guard.txt +0 -14
  127. package/build/templates/contract/partials/user-provider-database.txt +0 -16
  128. package/build/templates/contract/partials/user-provider-lucid.txt +0 -16
  129. package/build/templates/contract/partials/web-guard.txt +0 -14
  130. package/build/templates/middleware/Auth.txt +0 -76
  131. package/build/templates/middleware/SilentAuth.txt +0 -21
  132. package/build/templates/migrations/api_tokens.txt +0 -25
  133. package/build/templates/migrations/auth.txt +0 -24
  134. package/build/templates/model.txt +0 -30
@@ -1,138 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/auth
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.BaseGuard = void 0;
12
- const utils_1 = require("@poppinss/utils");
13
- const InvalidCredentialsException_1 = require("../../Exceptions/InvalidCredentialsException");
14
- /**
15
- * Base guard with shared abilities
16
- */
17
- class BaseGuard {
18
- constructor(name, config, provider) {
19
- this.name = name;
20
- this.config = config;
21
- this.provider = provider;
22
- /**
23
- * Whether or not the authentication has been attempted
24
- * for the current request
25
- */
26
- this.authenticationAttempted = false;
27
- /**
28
- * Find if the user has been logged out in the current request
29
- */
30
- this.isLoggedOut = false;
31
- /**
32
- * A boolean to know if user is retrieved by authenticating
33
- * the current request or not
34
- */
35
- this.isAuthenticated = false;
36
- /**
37
- * A boolean to know if user is loggedin via remember me token
38
- * or not.
39
- */
40
- this.viaRemember = false;
41
- }
42
- /**
43
- * Reference to the name of the guard driver
44
- */
45
- get driver() {
46
- return this.config.driver;
47
- }
48
- /**
49
- * Accessor to know if user is logged in
50
- */
51
- get isLoggedIn() {
52
- return !!this.user;
53
- }
54
- /**
55
- * Accessor to know if user is a guest. It is always opposite
56
- * of [[isLoggedIn]]
57
- */
58
- get isGuest() {
59
- return !this.isLoggedIn;
60
- }
61
- /**
62
- * Lookup user using UID
63
- */
64
- async lookupUsingUid(uid) {
65
- const providerUser = await this.provider.findByUid(uid);
66
- if (!providerUser.user) {
67
- throw InvalidCredentialsException_1.InvalidCredentialsException.invalidUid(this.name);
68
- }
69
- return providerUser;
70
- }
71
- /**
72
- * Verify user password
73
- */
74
- async verifyPassword(providerUser, password) {
75
- /**
76
- * Verify password or raise exception
77
- */
78
- const verified = await providerUser.verifyPassword(password);
79
- if (!verified) {
80
- throw InvalidCredentialsException_1.InvalidCredentialsException.invalidPassword(this.name);
81
- }
82
- }
83
- /**
84
- * Finds user by their id and returns the provider user instance
85
- */
86
- async findById(id) {
87
- const providerUser = await this.provider.findById(id);
88
- if (!providerUser.user) {
89
- throw InvalidCredentialsException_1.InvalidCredentialsException.invalidUid(this.name);
90
- }
91
- return providerUser;
92
- }
93
- /**
94
- * Returns the provider user instance from the regular user details. Raises
95
- * exception when id is missing
96
- */
97
- async getUserForLogin(user, identifierKey) {
98
- const providerUser = await this.provider.getUserFor(user);
99
- /**
100
- * Ensure id exists on the user
101
- */
102
- const id = providerUser.getId();
103
- if (!id) {
104
- throw new utils_1.Exception(`Cannot login user. Value of "${identifierKey}" is not defined`);
105
- }
106
- return providerUser;
107
- }
108
- /**
109
- * Marks user as logged-in
110
- */
111
- markUserAsLoggedIn(user, authenticated, viaRemember) {
112
- this.user = user;
113
- this.isLoggedOut = false;
114
- authenticated && (this.isAuthenticated = true);
115
- viaRemember && (this.viaRemember = true);
116
- }
117
- /**
118
- * Marks the user as logged out
119
- */
120
- markUserAsLoggedOut() {
121
- this.isLoggedOut = true;
122
- this.isAuthenticated = false;
123
- this.viaRemember = false;
124
- this.user = null;
125
- }
126
- /**
127
- * Verifies user credentials
128
- */
129
- async verifyCredentials(uid, password) {
130
- if (!uid || !password) {
131
- throw InvalidCredentialsException_1.InvalidCredentialsException.invalidUid(this.name);
132
- }
133
- const providerUser = await this.lookupUsingUid(uid);
134
- await this.verifyPassword(providerUser, password);
135
- return providerUser.user;
136
- }
137
- }
138
- exports.BaseGuard = BaseGuard;
@@ -1,67 +0,0 @@
1
- /// <reference types="@adonisjs/events/build/adonis-typings" />
2
- import { EmitterContract } from '@ioc:Adonis/Core/Event';
3
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
4
- import { UserProviderContract, BasicAuthGuardConfig, BasicAuthGuardContract } from '@ioc:Adonis/Addons/Auth';
5
- import { BaseGuard } from '../Base';
6
- /**
7
- * Basic auth guard enables user login using basic auth headers.
8
- */
9
- export declare class BasicAuthGuard extends BaseGuard<any> implements BasicAuthGuardContract<any, any> {
10
- private emitter;
11
- private ctx;
12
- constructor(name: string, config: BasicAuthGuardConfig<any>, emitter: EmitterContract, provider: UserProviderContract<any>, ctx: HttpContextContract);
13
- /**
14
- * Returns data packet for the authenticate event. Arguments are
15
- *
16
- * - The mapping identifier
17
- * - Logged in user
18
- * - HTTP context
19
- */
20
- private getAuthenticateEventData;
21
- /**
22
- * Returns user credentials by parsing the HTTP "Authorization" header
23
- */
24
- private getCredentials;
25
- /**
26
- * Returns user for the uid and password.
27
- */
28
- private getUser;
29
- /**
30
- * Implemented method to raise exception when someone calls this method
31
- * without selecting the guard explicitly
32
- */
33
- attempt(): Promise<any>;
34
- /**
35
- * Implemented method to raise exception when someone calls this method
36
- * without selecting the guard explicitly
37
- */
38
- loginViaId(): Promise<void>;
39
- /**
40
- * Implemented method to raise exception when someone calls this method
41
- * without selecting the guard explicitly
42
- */
43
- login(): Promise<void>;
44
- /**
45
- * Authenticates the current HTTP request by checking for the HTTP
46
- * "Authorization" header
47
- */
48
- authenticate(): Promise<any>;
49
- /**
50
- * Same as [[authenticate]] but returns a boolean over raising exceptions
51
- */
52
- check(): Promise<boolean>;
53
- /**
54
- * Logout by clearing session and cookies
55
- */
56
- logout(): Promise<void>;
57
- /**
58
- * Serialize toJSON for JSON.stringify
59
- */
60
- toJSON(): {
61
- isLoggedIn: boolean;
62
- isGuest: boolean;
63
- authenticationAttempted: boolean;
64
- isAuthenticated: boolean;
65
- user: any;
66
- };
67
- }
@@ -1,181 +0,0 @@
1
- "use strict";
2
- /*
3
- * @adonisjs/auth
4
- *
5
- * (c) Harminder Virk <virk@adonisjs.com>
6
- *
7
- * For the full copyright and license information, please view the LICENSE
8
- * file that was distributed with this source code.
9
- */
10
- Object.defineProperty(exports, "__esModule", { value: true });
11
- exports.BasicAuthGuard = void 0;
12
- const utils_1 = require("@poppinss/utils");
13
- const helpers_1 = require("@poppinss/utils/build/helpers");
14
- const Base_1 = require("../Base");
15
- const AuthenticationException_1 = require("../../Exceptions/AuthenticationException");
16
- /**
17
- * RegExp for basic auth credentials.
18
- * Copy/pasted from https://github.com/jshttp/basic-auth/blob/master/index.js
19
- *
20
- * credentials = auth-scheme 1*SP token68
21
- * auth-scheme = "Basic" ; case insensitive
22
- * token68 = 1*( ALPHA / DIGIT / "-" / "." / "_" / "~" / "+" / "/" ) *"="
23
- */
24
- const CREDENTIALS_REGEXP = /^ *(?:[Bb][Aa][Ss][Ii][Cc]) +([A-Za-z0-9._~+/-]+=*) *$/;
25
- /**
26
- * RegExp for basic auth user/pass
27
- * Copy/pasted from https://github.com/jshttp/basic-auth/blob/master/index.js
28
- *
29
- * user-pass = userid ":" password
30
- * userid = *<TEXT excluding ":">
31
- * password = *TEXT
32
- */
33
- const USER_PASS_REGEXP = /^([^:]*):(.*)$/;
34
- /**
35
- * Basic auth guard enables user login using basic auth headers.
36
- */
37
- class BasicAuthGuard extends Base_1.BaseGuard {
38
- constructor(name, config, emitter, provider, ctx) {
39
- super(name, config, provider);
40
- this.emitter = emitter;
41
- this.ctx = ctx;
42
- }
43
- /**
44
- * Returns data packet for the authenticate event. Arguments are
45
- *
46
- * - The mapping identifier
47
- * - Logged in user
48
- * - HTTP context
49
- */
50
- getAuthenticateEventData(user) {
51
- return {
52
- name: this.name,
53
- ctx: this.ctx,
54
- user,
55
- };
56
- }
57
- /**
58
- * Returns user credentials by parsing the HTTP "Authorization" header
59
- */
60
- getCredentials() {
61
- /**
62
- * Ensure the "Authorization" header value exists
63
- */
64
- const credentials = this.ctx.request.header('Authorization');
65
- if (!credentials) {
66
- throw AuthenticationException_1.AuthenticationException.invalidBasicCredentials(this.name);
67
- }
68
- /**
69
- * Ensure credentials are in correct format
70
- */
71
- const match = CREDENTIALS_REGEXP.exec(credentials);
72
- if (!match) {
73
- throw AuthenticationException_1.AuthenticationException.invalidBasicCredentials(this.name);
74
- }
75
- /**
76
- * Ensure credentials are base64 encoded
77
- */
78
- const decoded = helpers_1.base64.decode(match[1], 'utf-8', true);
79
- if (!decoded) {
80
- throw AuthenticationException_1.AuthenticationException.invalidBasicCredentials(this.name);
81
- }
82
- /**
83
- * Ensure decoded credentials are in correct format
84
- */
85
- const user = USER_PASS_REGEXP.exec(decoded);
86
- if (!user) {
87
- throw AuthenticationException_1.AuthenticationException.invalidBasicCredentials(this.name);
88
- }
89
- return { uid: user[1], password: user[2] };
90
- }
91
- /**
92
- * Returns user for the uid and password.
93
- */
94
- async getUser(uid, password) {
95
- try {
96
- return await this.verifyCredentials(uid, password);
97
- }
98
- catch {
99
- throw AuthenticationException_1.AuthenticationException.invalidBasicCredentials(this.name);
100
- }
101
- }
102
- /**
103
- * Implemented method to raise exception when someone calls this method
104
- * without selecting the guard explicitly
105
- */
106
- async attempt() {
107
- return this.login();
108
- }
109
- /**
110
- * Implemented method to raise exception when someone calls this method
111
- * without selecting the guard explicitly
112
- */
113
- async loginViaId() {
114
- return this.login();
115
- }
116
- /**
117
- * Implemented method to raise exception when someone calls this method
118
- * without selecting the guard explicitly
119
- */
120
- async login() {
121
- throw new utils_1.Exception('There is no concept of login in basic auth', 500);
122
- }
123
- /**
124
- * Authenticates the current HTTP request by checking for the HTTP
125
- * "Authorization" header
126
- */
127
- async authenticate() {
128
- if (this.authenticationAttempted) {
129
- return this.user;
130
- }
131
- this.authenticationAttempted = true;
132
- /**
133
- * Parse HTTP "Authorization" header to get credentials
134
- */
135
- const credentials = this.getCredentials();
136
- /**
137
- * Pull user from credentials
138
- */
139
- const user = await this.getUser(credentials.uid, credentials.password);
140
- /**
141
- * Mark user a logged in
142
- */
143
- this.markUserAsLoggedIn(user, true);
144
- /**
145
- * Emit event
146
- */
147
- this.emitter.emit('adonis:basic:authenticate', this.getAuthenticateEventData(user));
148
- return this.user;
149
- }
150
- /**
151
- * Same as [[authenticate]] but returns a boolean over raising exceptions
152
- */
153
- async check() {
154
- try {
155
- await this.authenticate();
156
- }
157
- catch (error) {
158
- this.ctx.logger.trace(error, 'Authentication failure');
159
- }
160
- return this.isAuthenticated;
161
- }
162
- /**
163
- * Logout by clearing session and cookies
164
- */
165
- async logout() {
166
- throw new utils_1.Exception('There is no concept of logout in basic auth', 500);
167
- }
168
- /**
169
- * Serialize toJSON for JSON.stringify
170
- */
171
- toJSON() {
172
- return {
173
- isLoggedIn: this.isLoggedIn,
174
- isGuest: this.isGuest,
175
- authenticationAttempted: this.authenticationAttempted,
176
- isAuthenticated: this.isAuthenticated,
177
- user: this.user,
178
- };
179
- }
180
- }
181
- exports.BasicAuthGuard = BasicAuthGuard;
@@ -1,149 +0,0 @@
1
- /// <reference types="@adonisjs/events/build/adonis-typings" />
2
- import { EmitterContract } from '@ioc:Adonis/Core/Event';
3
- import { HttpContextContract } from '@ioc:Adonis/Core/HttpContext';
4
- import { OATGuardConfig, OATLoginOptions, OATGuardContract, UserProviderContract, ProviderTokenContract, TokenProviderContract } from '@ioc:Adonis/Addons/Auth';
5
- import { BaseGuard } from '../Base';
6
- /**
7
- * Exposes the API to generate and authenticate HTTP request using
8
- * opaque tokens
9
- */
10
- export declare class OATGuard extends BaseGuard<any> implements OATGuardContract<any, any> {
11
- config: OATGuardConfig<any>;
12
- private emitter;
13
- private ctx;
14
- tokenProvider: TokenProviderContract;
15
- constructor(name: string, config: OATGuardConfig<any>, emitter: EmitterContract, provider: UserProviderContract<any>, ctx: HttpContextContract, tokenProvider: TokenProviderContract);
16
- /**
17
- * Reference to the parsed token
18
- */
19
- private parsedToken?;
20
- /**
21
- * Length of the raw token. The hash length will vary
22
- */
23
- private tokenLength;
24
- /**
25
- * Token type for the persistance store
26
- */
27
- private tokenType;
28
- /**
29
- * Whether or not the authentication has been attempted
30
- * for the current request
31
- */
32
- authenticationAttempted: boolean;
33
- /**
34
- * Find if the user has been logged out in the current request
35
- */
36
- isLoggedOut: boolean;
37
- /**
38
- * A boolean to know if user is retrieved by authenticating
39
- * the current request or not
40
- */
41
- isAuthenticated: boolean;
42
- /**
43
- * Logged in or authenticated user
44
- */
45
- user?: any;
46
- /**
47
- * Token fetched as part of the authenticate or the login
48
- * call
49
- */
50
- token?: ProviderTokenContract;
51
- /**
52
- * Accessor to know if user is logged in
53
- */
54
- get isLoggedIn(): boolean;
55
- /**
56
- * Accessor to know if user is a guest. It is always opposite
57
- * of [[isLoggedIn]]
58
- */
59
- get isGuest(): boolean;
60
- /**
61
- * Converts value to a sha256 hash
62
- */
63
- private generateHash;
64
- /**
65
- * Converts expiry duration to an absolute date/time value
66
- */
67
- private getExpiresAtDate;
68
- /**
69
- * Generates a new token + hash for the persistance
70
- */
71
- private generateTokenForPersistance;
72
- /**
73
- * Returns data packet for the login event. Arguments are
74
- *
75
- * - The mapping identifier
76
- * - Logged in user
77
- * - HTTP context
78
- * - API token
79
- */
80
- private getLoginEventData;
81
- /**
82
- * Returns data packet for the authenticate event. Arguments are
83
- *
84
- * - The mapping identifier
85
- * - Logged in user
86
- * - HTTP context
87
- * - A boolean to tell if logged in viaRemember or not
88
- */
89
- private getAuthenticateEventData;
90
- /**
91
- * Parses the token received in the request. The method also performs
92
- * some initial level of sanity checks.
93
- */
94
- private parsePublicToken;
95
- /**
96
- * Returns the bearer token
97
- */
98
- private getBearerToken;
99
- /**
100
- * Returns the token by reading it from the token provider
101
- */
102
- private getProviderToken;
103
- /**
104
- * Returns user from the user session id
105
- */
106
- private getUserById;
107
- /**
108
- * Verify user credentials and perform login
109
- */
110
- attempt(uid: string, password: string, options?: OATLoginOptions): Promise<any>;
111
- /**
112
- * Login user using their id
113
- */
114
- loginViaId(id: string | number, options?: OATLoginOptions): Promise<any>;
115
- /**
116
- * Generate token for a user. It is merely an alias for `login`
117
- */
118
- generate(user: any, options?: OATLoginOptions): Promise<any>;
119
- /**
120
- * Login a user
121
- */
122
- login(user: any, options?: OATLoginOptions): Promise<any>;
123
- /**
124
- * Authenticates the current HTTP request by checking for the bearer token
125
- */
126
- authenticate(): Promise<any>;
127
- /**
128
- * Same as [[authenticate]] but returns a boolean over raising exceptions
129
- */
130
- check(): Promise<boolean>;
131
- /**
132
- * Alias for the logout method
133
- */
134
- revoke(): Promise<void>;
135
- /**
136
- * Logout by removing the token from the storage
137
- */
138
- logout(): Promise<void>;
139
- /**
140
- * Serialize toJSON for JSON.stringify
141
- */
142
- toJSON(): {
143
- isLoggedIn: boolean;
144
- isGuest: boolean;
145
- authenticationAttempted: boolean;
146
- isAuthenticated: boolean;
147
- user: any;
148
- };
149
- }