@adminforth/two-factors-auth 3.3.8 → 3.3.10
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/dist/index.d.ts +51 -0
- package/dist/types.d.ts +116 -0
- package/package.json +3 -3
- package/tsconfig.json +1 -1
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { AdminForthPlugin, HttpExtra } from "adminforth";
|
|
2
|
+
import type { AdminForthResource, AdminUser, IAdminForth, IHttpServer, IAdminForthAuth, IAdminForthHttpResponse } from "adminforth";
|
|
3
|
+
import { PluginOptions } from "./types.js";
|
|
4
|
+
export default class TwoFactorsAuthPlugin extends AdminForthPlugin {
|
|
5
|
+
options: PluginOptions;
|
|
6
|
+
adminforth: IAdminForth;
|
|
7
|
+
authResource: AdminForthResource;
|
|
8
|
+
connectors: any;
|
|
9
|
+
adminForthAuth: IAdminForthAuth;
|
|
10
|
+
constructor(options: PluginOptions);
|
|
11
|
+
instanceUniqueRepresentation(pluginOptions: any): string;
|
|
12
|
+
private parseIfNeeded;
|
|
13
|
+
private useChellenge;
|
|
14
|
+
private checkIfChellengeNotUsed;
|
|
15
|
+
private validateCookiesForPasskeyLogin;
|
|
16
|
+
checkIfSkipSetupAllowSkipVerify(adminUser: AdminUser): Promise<{
|
|
17
|
+
skipAllowed: boolean;
|
|
18
|
+
}>;
|
|
19
|
+
private generateHashForStepUpMfaGraceCookie;
|
|
20
|
+
private issueTempSkip2FAGraceJWT;
|
|
21
|
+
private isTempSkip2FAGraceValid;
|
|
22
|
+
private pending;
|
|
23
|
+
private waitForResponse;
|
|
24
|
+
private resolveResponse;
|
|
25
|
+
verifyAuto(adminUser: AdminUser): Promise<any>;
|
|
26
|
+
verify(confirmationResult: Record<string, any>, opts?: {
|
|
27
|
+
adminUser?: AdminUser;
|
|
28
|
+
userPk?: string;
|
|
29
|
+
cookies?: any;
|
|
30
|
+
response?: IAdminForthHttpResponse;
|
|
31
|
+
extra?: HttpExtra;
|
|
32
|
+
}): Promise<{
|
|
33
|
+
ok: true;
|
|
34
|
+
} | {
|
|
35
|
+
error: string;
|
|
36
|
+
}>;
|
|
37
|
+
parsePeriod(period?: string): number;
|
|
38
|
+
verifyPasskeyResponse(body: any, user_id: string, cookies: any): Promise<{
|
|
39
|
+
ok: boolean;
|
|
40
|
+
error: string;
|
|
41
|
+
passkeyConfirmed?: undefined;
|
|
42
|
+
} | {
|
|
43
|
+
ok: boolean;
|
|
44
|
+
passkeyConfirmed: boolean;
|
|
45
|
+
error?: undefined;
|
|
46
|
+
}>;
|
|
47
|
+
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
48
|
+
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
49
|
+
activate(resourceConfig: AdminForthResource, adminforth: IAdminForth): void;
|
|
50
|
+
setupEndpoints(server: IHttpServer): void;
|
|
51
|
+
}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { AdminUser, KeyValueAdapter } from "adminforth";
|
|
2
|
+
import { type PluginsCommonOptions } from "adminforth";
|
|
3
|
+
export interface PluginOptions extends PluginsCommonOptions {
|
|
4
|
+
/**
|
|
5
|
+
* Name of the field in the auth resource which will store 2FA secret.
|
|
6
|
+
*
|
|
7
|
+
* Resource mandatory should have one columns which defined {@link AdminForthResourceColumn} which
|
|
8
|
+
* name should be equal to the value .
|
|
9
|
+
*/
|
|
10
|
+
twoFaSecretFieldName: string;
|
|
11
|
+
/**
|
|
12
|
+
* Not-negative optional time step window for 2FA. This value means that the user will be able to enter the old code
|
|
13
|
+
* for the next 30 seconds after the new code was generated.
|
|
14
|
+
*/
|
|
15
|
+
timeStepWindow?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Number of seconds for step-up MFA grace period.
|
|
18
|
+
* During this period, user will not be challenged with 2FA on sensitive actions.
|
|
19
|
+
*/
|
|
20
|
+
stepUpMfaGracePeriodSeconds?: number;
|
|
21
|
+
customBrandPrefix?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Passkeys (WebAuthn) configuration.
|
|
24
|
+
*/
|
|
25
|
+
passkeys?: {
|
|
26
|
+
credentialResourceID: string;
|
|
27
|
+
credentialIdFieldName: string;
|
|
28
|
+
credentialMetaFieldName: string;
|
|
29
|
+
credentialUserIdFieldName: string;
|
|
30
|
+
/**
|
|
31
|
+
* KeyValueAdapter is required to make sure that generated challenge can't be reused more than once
|
|
32
|
+
*/
|
|
33
|
+
keyValueAdapter: KeyValueAdapter;
|
|
34
|
+
/**
|
|
35
|
+
* Allow login with Passkeys even if 2FA is not set up. Default is true.
|
|
36
|
+
*/
|
|
37
|
+
allowLoginWithPasskeys?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* Remember user for number of days after login with Passkey, so that user won't be challenged with 2FA on every login.
|
|
40
|
+
*/
|
|
41
|
+
rememberDaysAfterPasskeyLogin?: number;
|
|
42
|
+
/**
|
|
43
|
+
* Order of "Continue with passkey" button in under login button injection
|
|
44
|
+
*/
|
|
45
|
+
continueWithButtonsOrder?: number;
|
|
46
|
+
/**
|
|
47
|
+
* Period between showing alert suggesting to set up Passkeys if not set up yet.
|
|
48
|
+
*/
|
|
49
|
+
suggestionPeriod?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Challenge period for Passkeys authentication.
|
|
52
|
+
*/
|
|
53
|
+
challengeValidityPeriod?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Passkeys settings for WebAuthn API.
|
|
56
|
+
*/
|
|
57
|
+
settings: {
|
|
58
|
+
/**
|
|
59
|
+
* The origin that you expect the authentication to come from. (e.g. https://example.com or http://localhost:3000)
|
|
60
|
+
*/
|
|
61
|
+
expectedOrigin: string;
|
|
62
|
+
rp?: {
|
|
63
|
+
/**
|
|
64
|
+
* The Relying Party name.
|
|
65
|
+
*/
|
|
66
|
+
name?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The Relying Party ID. A domain or subdomain (e.g. example.com or login.example.com).
|
|
69
|
+
*/
|
|
70
|
+
id?: string;
|
|
71
|
+
};
|
|
72
|
+
user: {
|
|
73
|
+
/**
|
|
74
|
+
* Field in users resource, that user will recognize as unique user ID.(e.g. email or username)
|
|
75
|
+
*/
|
|
76
|
+
nameField: string;
|
|
77
|
+
/**
|
|
78
|
+
* Field in users resource, that user will recognize as display name.(e.g. full name)
|
|
79
|
+
*/
|
|
80
|
+
displayNameField?: string;
|
|
81
|
+
};
|
|
82
|
+
authenticatorSelection?: {
|
|
83
|
+
/**
|
|
84
|
+
* The preferred authenticator attachment. It can be either "platform", "cross-platform" or "both".
|
|
85
|
+
* Default to "platform".
|
|
86
|
+
*/
|
|
87
|
+
authenticatorAttachment?: 'platform' | 'cross-platform' | 'both';
|
|
88
|
+
/**
|
|
89
|
+
* Set it to a boolean true. A discoverable credential (resident key)
|
|
90
|
+
* stores user information to the passkey and lets users select the account upon authentication.
|
|
91
|
+
* Default to "True".
|
|
92
|
+
*/
|
|
93
|
+
requireResidentKey?: boolean;
|
|
94
|
+
/**
|
|
95
|
+
* Indicates whether a user verification using the device screen lock is "required" or "discouraged".
|
|
96
|
+
* The default is "required".
|
|
97
|
+
*/
|
|
98
|
+
userVerification?: 'required' | 'discouraged';
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
/**
|
|
103
|
+
* Optional function to filter users to apply 2FA.
|
|
104
|
+
* Should return true if 2FA should be applied to the user and false if AdminForth should not challenge the user with 2FA.
|
|
105
|
+
* @param adminUser
|
|
106
|
+
* @returns true if 2FA should be applied to the user and false if AdminForth should not challenge the user with 2FA.
|
|
107
|
+
*/
|
|
108
|
+
usersFilterToApply?: (adminUser: AdminUser) => boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Optional function to allow users to skip 2FA setup.
|
|
111
|
+
* Should return true if the user should be allowed to skip the 2FA setup and false if AdminForth should require the user to set up 2FA.
|
|
112
|
+
* @param adminUser
|
|
113
|
+
* @returns true if the user should be allowed to skip the 2FA setup and false if AdminForth should require the user to set up 2FA.
|
|
114
|
+
*/
|
|
115
|
+
usersFilterToAllowSkipSetup?: (adminUser: AdminUser) => boolean;
|
|
116
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adminforth/two-factors-auth",
|
|
3
|
-
"version": "3.3.
|
|
3
|
+
"version": "3.3.10",
|
|
4
4
|
"description": "AdminForth plugin for two factors authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"node-2fa": "^2.0.3"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"adminforth": "
|
|
31
|
+
"adminforth": "2.71.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/node": "^22.10.7",
|
|
35
|
-
"adminforth": "2.
|
|
35
|
+
"adminforth": "2.71.1",
|
|
36
36
|
"semantic-release": "^24.2.1",
|
|
37
37
|
"semantic-release-slack-bot": "^4.0.2",
|
|
38
38
|
"typescript": "^5.7.3"
|
package/tsconfig.json
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
// "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */
|
|
51
51
|
|
|
52
52
|
/* Emit */
|
|
53
|
-
|
|
53
|
+
"declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
|
|
54
54
|
// "declarationMap": true, /* Create sourcemaps for d.ts files. */
|
|
55
55
|
// "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
|
|
56
56
|
// "sourceMap": true, /* Create source map files for emitted JavaScript files. */
|