@oneblink/apps-react 11.0.0-beta.1 → 11.0.0-beta.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.
- package/dist/apps/auth-service.d.ts +3 -3
- package/dist/apps/auth-service.js +2 -2
- package/dist/apps/auth-service.js.map +1 -1
- package/dist/apps/index.d.ts +10 -0
- package/dist/apps/index.js +10 -0
- package/dist/apps/index.js.map +1 -1
- package/dist/apps/mfa-service.d.ts +29 -0
- package/dist/apps/mfa-service.js +30 -0
- package/dist/apps/mfa-service.js.map +1 -0
- package/dist/apps/services/AWSCognitoClient.d.ts +7 -6
- package/dist/apps/services/AWSCognitoClient.js +26 -33
- package/dist/apps/services/AWSCognitoClient.js.map +1 -1
- package/dist/apps/services/cognito.d.ts +5 -24
- package/dist/apps/services/cognito.js +3 -32
- package/dist/apps/services/cognito.js.map +1 -1
- package/dist/components/mfa/MfaAuthenticatorAppDialog.js +2 -2
- package/dist/components/mfa/MfaAuthenticatorAppDialog.js.map +1 -1
- package/dist/components/mfa/MfaMethodRow.d.ts +2 -1
- package/dist/components/mfa/MfaMethodRow.js +3 -3
- package/dist/components/mfa/MfaMethodRow.js.map +1 -1
- package/dist/components/mfa/MfaPhoneNumberDialog.js +10 -14
- package/dist/components/mfa/MfaPhoneNumberDialog.js.map +1 -1
- package/dist/components/mfa/MultiFactorAuthentication.d.ts +11 -10
- package/dist/components/mfa/MultiFactorAuthentication.js +20 -14
- package/dist/components/mfa/MultiFactorAuthentication.js.map +1 -1
- package/dist/hooks/useLogin.d.ts +2 -2
- package/dist/hooks/useLogin.js.map +1 -1
- package/dist/hooks/useMfa.d.ts +66 -31
- package/dist/hooks/useMfa.js +84 -61
- package/dist/hooks/useMfa.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/utils/joinArray.d.ts +1 -0
- package/dist/utils/joinArray.js +7 -0
- package/dist/utils/joinArray.js.map +1 -0
- package/dist/utils/mfa-requirement.d.ts +12 -0
- package/dist/utils/mfa-requirement.js +100 -0
- package/dist/utils/mfa-requirement.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DEFAULT_MFA_SETTINGS, LoginAttemptResponse, MfaMethod,
|
|
1
|
+
import { DEFAULT_MFA_SETTINGS, LoginAttemptResponse, MfaMethod, MfaSettings } from './AWSCognitoClient';
|
|
2
2
|
import { MiscTypes } from '@oneblink/types';
|
|
3
3
|
interface CognitoServiceData {
|
|
4
4
|
oAuthClientId: string;
|
|
@@ -243,7 +243,7 @@ declare function getUserFriendlyName(): string | undefined;
|
|
|
243
243
|
*
|
|
244
244
|
* ```js
|
|
245
245
|
* const mfaAuthenticatorAppSetupQrCodeUrl =
|
|
246
|
-
*
|
|
246
|
+
* mfaService.generateMfaAuthenticatorAppQrCodeUrl()
|
|
247
247
|
* if (mfaAuthenticatorAppSetupQrCodeUrl) {
|
|
248
248
|
* // use mfaAuthenticatorAppSetupQrCodeUrl to display QR code to user
|
|
249
249
|
* }
|
|
@@ -252,30 +252,11 @@ declare function getUserFriendlyName(): string | undefined;
|
|
|
252
252
|
* @returns
|
|
253
253
|
*/
|
|
254
254
|
declare function generateMfaAuthenticatorAppQrCodeUrl(mfaAuthenticatorAppSetup: Awaited<ReturnType<typeof setupMfaAuthenticatorApp>>): string | undefined;
|
|
255
|
-
/**
|
|
256
|
-
* Check if the current user meets an MFA requirement.
|
|
257
|
-
*
|
|
258
|
-
* #### Example
|
|
259
|
-
*
|
|
260
|
-
* ```js
|
|
261
|
-
* const { mfaSettings, userMeetsMfaRequirement } =
|
|
262
|
-
* await authService.checkIsMfaEnabled('any')
|
|
263
|
-
* if (userMeetsMfaRequirement) {
|
|
264
|
-
* // User has met the MFA requirement
|
|
265
|
-
* } else {
|
|
266
|
-
* // Prompt user to set up MFA
|
|
267
|
-
* }
|
|
268
|
-
* ```
|
|
269
|
-
*
|
|
270
|
-
* @returns
|
|
271
|
-
*/
|
|
272
|
-
declare function checkIsMfaEnabled(mfaRequirement: MiscTypes.MfaRequirement | undefined): Promise<MfaRequirementCheckResult>;
|
|
273
255
|
declare function getMfaSettings(abortSignal?: AbortSignal): Promise<MfaSettings>;
|
|
274
256
|
declare function updateUserPhoneNumber(phoneNumber: string): Promise<{
|
|
275
257
|
isPhoneNumberVerified: boolean;
|
|
276
258
|
}>;
|
|
277
259
|
declare function removeUserPhoneNumber(): Promise<void>;
|
|
278
|
-
declare function sendPhoneNumberVerificationCode(): Promise<import("@aws-sdk/client-cognito-identity-provider").GetUserAttributeVerificationCodeCommandOutput | undefined>;
|
|
279
260
|
declare function verifyUserPhoneNumber(code: string): Promise<void>;
|
|
280
261
|
declare function setupSmsMfa(options?: {
|
|
281
262
|
preferred?: boolean;
|
|
@@ -291,7 +272,7 @@ declare function setPreferredMfaMethod(method: MfaMethod): Promise<void>;
|
|
|
291
272
|
*
|
|
292
273
|
* ```js
|
|
293
274
|
* const { secretCode, mfaCodeCallback } =
|
|
294
|
-
* await
|
|
275
|
+
* await mfaService.setupMfaAuthenticatorApp()
|
|
295
276
|
* // Prompt the user to enter an MFA code
|
|
296
277
|
* const code = prompt(
|
|
297
278
|
* `Please enter a one-time code from your MFA app after creating a new entry with secret: ${secretCode}.`,
|
|
@@ -307,5 +288,5 @@ declare function setupMfaAuthenticatorApp(options?: {
|
|
|
307
288
|
secretCode: string | undefined;
|
|
308
289
|
mfaCodeCallback: (code: string) => Promise<void>;
|
|
309
290
|
} | undefined>;
|
|
310
|
-
export { init, registerAuthListener, loginUsernamePassword, loginHostedUI, handleAuthentication, changePassword, forgotPassword, logoutHostedUI, logout, isLoggedIn, getCognitoIdToken, getUserProfile, getUserFriendlyName,
|
|
311
|
-
export type { LoginAttemptResponse, MfaMethod,
|
|
291
|
+
export { init, registerAuthListener, loginUsernamePassword, loginHostedUI, handleAuthentication, changePassword, forgotPassword, logoutHostedUI, logout, isLoggedIn, getCognitoIdToken, getUserProfile, getUserFriendlyName, getMfaSettings, updateUserPhoneNumber, removeUserPhoneNumber, verifyUserPhoneNumber, disableMfaMethod, setPreferredMfaMethod, setupSmsMfa, setupMfaAuthenticatorApp, generateMfaAuthenticatorAppQrCodeUrl, DEFAULT_MFA_SETTINGS, };
|
|
292
|
+
export type { LoginAttemptResponse, MfaMethod, MfaSettings };
|
|
@@ -363,7 +363,7 @@ function getUserFriendlyName() {
|
|
|
363
363
|
*
|
|
364
364
|
* ```js
|
|
365
365
|
* const mfaAuthenticatorAppSetupQrCodeUrl =
|
|
366
|
-
*
|
|
366
|
+
* mfaService.generateMfaAuthenticatorAppQrCodeUrl()
|
|
367
367
|
* if (mfaAuthenticatorAppSetupQrCodeUrl) {
|
|
368
368
|
* // use mfaAuthenticatorAppSetupQrCodeUrl to display QR code to user
|
|
369
369
|
* }
|
|
@@ -378,29 +378,6 @@ function generateMfaAuthenticatorAppQrCodeUrl(mfaAuthenticatorAppSetup) {
|
|
|
378
378
|
}
|
|
379
379
|
return `otpauth://totp/${tenants.current.productShortName}:${profile.email}?secret=${mfaAuthenticatorAppSetup.secretCode}&issuer=${tenants.current.productShortName}`;
|
|
380
380
|
}
|
|
381
|
-
/**
|
|
382
|
-
* Check if the current user meets an MFA requirement.
|
|
383
|
-
*
|
|
384
|
-
* #### Example
|
|
385
|
-
*
|
|
386
|
-
* ```js
|
|
387
|
-
* const { mfaSettings, userMeetsMfaRequirement } =
|
|
388
|
-
* await authService.checkIsMfaEnabled('any')
|
|
389
|
-
* if (userMeetsMfaRequirement) {
|
|
390
|
-
* // User has met the MFA requirement
|
|
391
|
-
* } else {
|
|
392
|
-
* // Prompt user to set up MFA
|
|
393
|
-
* }
|
|
394
|
-
* ```
|
|
395
|
-
*
|
|
396
|
-
* @returns
|
|
397
|
-
*/
|
|
398
|
-
async function checkIsMfaEnabled(mfaRequirement) {
|
|
399
|
-
if (!awsCognitoClient) {
|
|
400
|
-
throw new Error('"authService" has not been initiated. You must call the init() function before checking if the current user has MFA enabled.');
|
|
401
|
-
}
|
|
402
|
-
return await awsCognitoClient.checkIsMfaEnabled(mfaRequirement);
|
|
403
|
-
}
|
|
404
381
|
async function getMfaSettings(abortSignal) {
|
|
405
382
|
if (!awsCognitoClient) {
|
|
406
383
|
throw new Error('"authService" has not been initiated. You must call the init() function before checking MFA settings.');
|
|
@@ -419,12 +396,6 @@ async function removeUserPhoneNumber() {
|
|
|
419
396
|
}
|
|
420
397
|
return await awsCognitoClient.removeUserPhoneNumber();
|
|
421
398
|
}
|
|
422
|
-
async function sendPhoneNumberVerificationCode() {
|
|
423
|
-
if (!awsCognitoClient) {
|
|
424
|
-
throw new Error('"authService" has not been initiated. You must call the init() function before sending a phone number verification code.');
|
|
425
|
-
}
|
|
426
|
-
return await awsCognitoClient.sendPhoneNumberVerificationCode();
|
|
427
|
-
}
|
|
428
399
|
async function verifyUserPhoneNumber(code) {
|
|
429
400
|
if (!awsCognitoClient) {
|
|
430
401
|
throw new Error('"authService" has not been initiated. You must call the init() function before verifying the user phone number.');
|
|
@@ -458,7 +429,7 @@ async function setPreferredMfaMethod(method) {
|
|
|
458
429
|
*
|
|
459
430
|
* ```js
|
|
460
431
|
* const { secretCode, mfaCodeCallback } =
|
|
461
|
-
* await
|
|
432
|
+
* await mfaService.setupMfaAuthenticatorApp()
|
|
462
433
|
* // Prompt the user to enter an MFA code
|
|
463
434
|
* const code = prompt(
|
|
464
435
|
* `Please enter a one-time code from your MFA app after creating a new entry with secret: ${secretCode}.`,
|
|
@@ -474,5 +445,5 @@ async function setupMfaAuthenticatorApp(options) {
|
|
|
474
445
|
}
|
|
475
446
|
return await awsCognitoClient.setupMfaAuthenticatorApp(options);
|
|
476
447
|
}
|
|
477
|
-
export { init, registerAuthListener, loginUsernamePassword, loginHostedUI, handleAuthentication, changePassword, forgotPassword, logoutHostedUI, logout, isLoggedIn, getCognitoIdToken, getUserProfile, getUserFriendlyName,
|
|
448
|
+
export { init, registerAuthListener, loginUsernamePassword, loginHostedUI, handleAuthentication, changePassword, forgotPassword, logoutHostedUI, logout, isLoggedIn, getCognitoIdToken, getUserProfile, getUserFriendlyName, getMfaSettings, updateUserPhoneNumber, removeUserPhoneNumber, verifyUserPhoneNumber, disableMfaMethod, setPreferredMfaMethod, setupSmsMfa, setupMfaAuthenticatorApp, generateMfaAuthenticatorAppQrCodeUrl, DEFAULT_MFA_SETTINGS, };
|
|
478
449
|
//# sourceMappingURL=cognito.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cognito.js","sourceRoot":"","sources":["../../../src/apps/services/cognito.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,gBAAgB,EAAE,EACvB,oBAAoB,GAKrB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAa,WAAW,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,OAAO,MAAM,YAAY,CAAA;AAChC,OAAO,iBAAiB,MAAM,4BAA4B,CAAA;AAU1D,MAAM,WAAW,GAAG,YAAY,CAAA;AAEhC,IAAI,gBAAgB,GAA4B,IAAI,CAAA;AAEpD,SAAS,IAAI,CAAC,kBAAsC;IAClD,OAAO,CAAC,GAAG,CAAC,2CAA2C,EAAE,kBAAkB,CAAC,CAAA;IAE5E,gBAAgB,GAAG,IAAI,gBAAgB,CAAC;QACtC,QAAQ,EAAE,kBAAkB,CAAC,aAAa;QAC1C,MAAM,EAAE,kBAAkB,CAAC,MAAM;QACjC,WAAW,EAAE,kBAAkB,CAAC,WAAW;QAC3C,WAAW,EAAE,kBAAkB,CAAC,WAAW;QAC3C,SAAS,EAAE,kBAAkB,CAAC,SAAS;KACxC,CAAC,CAAA;AACJ,CAAC;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,SAAS,oBAAoB,CAAC,QAAuB;IACnD,IA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MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;AACxD,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,MAAiB;IACpD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,4HAA4H,CAC7H,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,KAAK,UAAU,wBAAwB,CAAC,OAAiC;IACvE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;AACjE,CAAC;AAED,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,cAAc,EACd,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,wBAAwB,EACxB,oCAAoC,EACpC,oBAAoB,GACrB,CAAA","sourcesContent":["import { jwtDecode } from 'jwt-decode'\n\nimport AWSCognitoClient, {\n DEFAULT_MFA_SETTINGS,\n LoginAttemptResponse,\n MfaMethod,\n MfaRequirementCheckResult,\n MfaSettings,\n} from './AWSCognitoClient'\n\nimport * as offlineService from '../offline-service'\nimport { userService } from '@oneblink/sdk-core'\nimport { MiscTypes } from '@oneblink/types'\nimport { HTTPError, postRequest } from './fetch'\nimport tenants from '../tenants'\nimport OneBlinkAppsError from './errors/oneBlinkAppsError'\n\ninterface CognitoServiceData {\n oAuthClientId: string\n loginDomain: string\n region: string\n redirectUri: string\n logoutUri: string\n}\n\nconst CONTINUE_TO = 'continueTo'\n\nlet awsCognitoClient: null | AWSCognitoClient = null\n\nfunction init(cognitoServiceData: CognitoServiceData) {\n console.log('Initiating CognitoIdentityServiceProvider', cognitoServiceData)\n\n awsCognitoClient = new AWSCognitoClient({\n clientId: cognitoServiceData.oAuthClientId,\n region: cognitoServiceData.region,\n loginDomain: cognitoServiceData.loginDomain,\n redirectUri: cognitoServiceData.redirectUri,\n logoutUri: cognitoServiceData.logoutUri,\n })\n}\n\n/**\n * Register a listener function that will be call when authentication tokens are\n * updated or removed.\n *\n * #### Example\n *\n * ```js\n * const listener = async () => {\n * // Check if the user is logged in still\n * const isLoggedIn = authService.isLoggedIn()\n * }\n * const deregister = await authService.registerAuthListener(listener)\n *\n * // When no longer needed, remember to deregister the listener\n * deregister()\n * ```\n *\n * @param listener\n * @returns\n */\nfunction registerAuthListener(listener: () => unknown): () => void {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to register a listener.',\n )\n }\n return awsCognitoClient.registerListener(listener)\n}\n\n/**\n * Create a session for a user by entering a username and password. If the user\n * requires a password reset, the \"resetPasswordCallback\" property will be\n * returned. This function should be called with the new password once entered\n * by the user. If the user requires an MFA token, the \"mfa\" property will be\n * returned. Its \"codeCallback\" should be called with the one-time token. The\n * functions returned are recursive and the result from each of them is the same\n * result from the loginUsernamePassword() function. Each time the response\n * includes a callback, you will need to begin the process again until all\n * callbacks are handled.\n *\n * #### Example\n *\n * ```js\n * async function handleLoginAttemptResponse({\n * resetPasswordCallback,\n * mfa,\n * }) {\n * // \"resetPasswordCallback\" will be undefined if a password reset was not required.\n * if (resetPasswordCallback) {\n * // Prompt the user to enter a new password\n * const newPassword = prompt(\n * 'The password you entered was only temporary, and must be reset for security purposes. Please enter your new password below to continue.',\n * )\n * const resetPasswordResponse =\n * await resetPasswordCallback(newPassword)\n * return await handleLoginAttemptResponse(resetPasswordResponse)\n * }\n *\n * // \"mfa\" will be undefined if MFA is not setup.\n * if (mfa) {\n * // Prompt the user to enter an MFA code\n * const code = prompt(\n * mfa.method === 'email'\n * ? 'Please enter the one-time code sent to your email.'\n * : 'Please enter a one-time code from your MFA app.',\n * )\n * const mfaCodeResponse = await mfa.codeCallback(code)\n * return await handleLoginAttemptResponse(mfaCodeResponse)\n * }\n * }\n *\n * const username = 'user@email.io'\n * const password = 'P@$5w0rd'\n *\n * const loginAttemptResponse = await authService.loginUsernamePassword(\n * username,\n * password,\n * )\n *\n * await handleLoginAttemptResponse(loginAttemptResponse)\n * ```\n *\n * @param username\n * @param password\n * @returns\n */\nasync function loginUsernamePassword(username: string, password: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to login.',\n )\n }\n console.log('Attempting sign using username', username)\n return awsCognitoClient.loginUsernamePassword(\n username.toLowerCase(),\n password,\n )\n}\n\n/**\n * Redirect the user to the login screen. Passing an `identityProvider` is\n * optionally, it will allow users to skip the login page and be directed\n * straight to that providers login page\n *\n * #### Example\n *\n * ```js\n * // OPtionally pass a\n * const identityProvider = 'Google'\n * await authService.loginHostedUI(identityProvider)\n * // User will be redirected to login page or promise will resolve\n * ```\n *\n * @param identityProviderName\n * @returns\n */\nasync function loginHostedUI(identityProviderName?: string): Promise<void> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to login.',\n )\n }\n const continueTo = `${window.location.pathname}${window.location.search}`\n localStorage.setItem(CONTINUE_TO, continueTo)\n\n return awsCognitoClient.loginHostedUI(identityProviderName)\n}\n\n/**\n * This function should be called when the user is redirected back to your app\n * after a login attempt. It will use the query string add the redirect URL to\n * create a session for the current user. It will return a URL as a `string`\n * that should be redirected to within your app.\n *\n * #### Example\n *\n * ```js\n * try {\n * const continueTo = await authService.handleAuthentication()\n * // Redirect the user back to where they were before attempting to login\n * window.location.href = continueTo\n * } catch (error) {\n * // handle failed login attempts here.\n * }\n * ```\n *\n * @returns\n */\nasync function handleAuthentication(): Promise<string> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to handle authentication in URL.',\n )\n }\n\n const continueTo = localStorage.getItem(CONTINUE_TO) || '/'\n if (isLoggedIn()) {\n console.log('Already authenticated, redirecting to:', continueTo)\n } else {\n await awsCognitoClient.handleAuthentication()\n }\n\n localStorage.removeItem(CONTINUE_TO)\n\n return continueTo\n}\n\n/**\n * Allow the currently logged in user to change their password by passing their\n * existing password and a new password.\n *\n * #### Example\n *\n * ```js\n * const currentPassword = 'P@$5w0rd'\n * const newPassword = 'P@$5w0rD'\n * await authService.changePassword(currentPassword, newPassword)\n * ```\n *\n * @param existingPassword\n * @param newPassword\n * @returns\n */\nasync function changePassword(existingPassword: string, newPassword: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to change passwords.',\n )\n }\n\n return await awsCognitoClient.changePassword(existingPassword, newPassword)\n}\n\n/**\n * Allow a user to start the forgot password process. The user will be emailed a\n * temporary code that must be passed with a new password to the function\n * returned.\n *\n * #### Example\n *\n * ```js\n * const username = 'user@email.io'\n * const finishForgotPassword = await authService.forgotPassword(username)\n *\n * // Prompt the user to enter the code and a new password\n * const code = prompt(\n * 'You have been emailed a verification code, please enter it here.',\n * )\n * const newPassword = prompt('Please enter a new password to continue.')\n * await finishForgotPassword(code, newPassword)\n * ```\n *\n * @param username\n * @param formsAppId Used to give the resulting email sent to the user\n * associated forms app branding and sending address\n * @returns\n */\nasync function forgotPassword(\n username: string,\n /**\n * Used to give the resulting email sent to the user associated forms app\n * branding and sending address\n */\n formsAppId?: number,\n): Promise<(code: string, password: string) => Promise<void>> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before starting the forgot password process.',\n )\n }\n\n try {\n const url = `${tenants.current.apiOrigin}/authentication/reset-password`\n await postRequest(url, {\n username,\n formsAppId,\n })\n } catch (err) {\n const error = err as HTTPError\n switch (error.status) {\n case 400: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n\n return async (code, password) => {\n await awsCognitoClient?.confirmForgotPassword({\n username,\n code,\n password,\n })\n }\n}\n\n/**\n * Redirect the user to the logout screen to clear the users session on the\n * hosted login page. User will then be redirected to `/logout`. After being\n * redirected back to the application, the `logout()` function should be called\n * to clear the session data from browser storage.\n *\n * #### Example\n *\n * ```js\n * authService.logoutHostedUI()\n * ```\n */\nfunction logoutHostedUI(): void {\n if (awsCognitoClient) {\n awsCognitoClient.logoutHostedUI()\n }\n}\n\nasync function logout() {\n if (awsCognitoClient) {\n await awsCognitoClient.logout()\n }\n}\n\n/**\n * Check if the user is currently logged in\n *\n * #### Example\n *\n * ```js\n * const isLoggedIn = authService.isLoggedIn()\n * // handle user being logged in or not\n * ```\n *\n * @returns\n */\nfunction isLoggedIn(): boolean {\n return !!(awsCognitoClient && awsCognitoClient._getRefreshToken())\n}\n\nasync function getCognitoIdToken(): Promise<string | undefined> {\n if (!awsCognitoClient) {\n return\n }\n\n if (offlineService.isOffline()) {\n return awsCognitoClient._getIdToken()\n }\n\n return await awsCognitoClient.getIdToken()\n}\n\n/**\n * Get current users profile based on there Id Token payload. This will return\n * `null` if the the current user is not logged in.\n *\n * #### Example\n *\n * ```js\n * const profile = authService.getUserProfile()\n * if (profile) {\n * // Use profile here\n * }\n * ```\n *\n * @returns\n */\nfunction getUserProfile(): MiscTypes.UserProfile | null {\n if (!awsCognitoClient) {\n return null\n }\n const idToken = awsCognitoClient._getIdToken()\n if (!idToken) {\n return null\n }\n\n const jwtToken = jwtDecode(idToken)\n return userService.parseUserProfile(jwtToken) || null\n}\n\nexport function getUsername(): string | undefined {\n const profile = getUserProfile()\n if (!profile) {\n return undefined\n }\n\n return profile.username\n}\n\n/**\n * A friendly `string` that represents the current user. Uses first name, last\n * name, full name and username. This will return `null` the current user is not\n * logged in.\n *\n * #### Example\n *\n * ```js\n * const name = authService.getUserFriendlyName()\n * if (name) {\n * // Display current user's name\n * }\n * ```\n *\n * @returns\n */\nfunction getUserFriendlyName(): string | undefined {\n const profile = getUserProfile()\n if (!profile) {\n return\n }\n\n return userService.getUserFriendlyName(profile)\n}\n\n/**\n * Generate a QR code link to display to a user after they have initiated\n * authenticator app MFA setup.\n *\n * #### Example\n *\n * ```js\n * const mfaAuthenticatorAppSetupQrCodeUrl =\n * authService.generateMfaAuthenticatorAppQrCodeUrl()\n * if (mfaAuthenticatorAppSetupQrCodeUrl) {\n * // use mfaAuthenticatorAppSetupQrCodeUrl to display QR code to user\n * }\n * ```\n *\n * @returns\n */\nfunction generateMfaAuthenticatorAppQrCodeUrl(\n mfaAuthenticatorAppSetup: Awaited<\n ReturnType<typeof setupMfaAuthenticatorApp>\n >,\n): string | undefined {\n const profile = getUserProfile()\n if (!profile || !mfaAuthenticatorAppSetup) {\n return\n }\n\n return `otpauth://totp/${tenants.current.productShortName}:${profile.email}?secret=${mfaAuthenticatorAppSetup.secretCode}&issuer=${tenants.current.productShortName}`\n}\n\n/**\n * Check if the current user meets an MFA requirement.\n *\n * #### Example\n *\n * ```js\n * const { mfaSettings, userMeetsMfaRequirement } =\n * await authService.checkIsMfaEnabled('any')\n * if (userMeetsMfaRequirement) {\n * // User has met the MFA requirement\n * } else {\n * // Prompt user to set up MFA\n * }\n * ```\n *\n * @returns\n */\nasync function checkIsMfaEnabled(\n mfaRequirement: MiscTypes.MfaRequirement | undefined,\n): Promise<MfaRequirementCheckResult> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before checking if the current user has MFA enabled.',\n )\n }\n\n return await awsCognitoClient.checkIsMfaEnabled(mfaRequirement)\n}\n\nasync function getMfaSettings(abortSignal?: AbortSignal) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before checking MFA settings.',\n )\n }\n\n return await awsCognitoClient.getMfaSettings(abortSignal)\n}\n\nasync function updateUserPhoneNumber(phoneNumber: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before updating the user phone number.',\n )\n }\n\n return await awsCognitoClient.updateUserPhoneNumber(phoneNumber)\n}\n\nasync function removeUserPhoneNumber() {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before removing the user phone number.',\n )\n }\n\n return await awsCognitoClient.removeUserPhoneNumber()\n}\n\nasync function sendPhoneNumberVerificationCode() {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before sending a phone number verification code.',\n )\n }\n\n return await awsCognitoClient.sendPhoneNumberVerificationCode()\n}\n\nasync function verifyUserPhoneNumber(code: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before verifying the user phone number.',\n )\n }\n\n return await awsCognitoClient.verifyUserPhoneNumber(code)\n}\n\nasync function setupSmsMfa(options?: { preferred?: boolean }) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to setup SMS MFA.',\n )\n }\n\n return await awsCognitoClient.setupSmsMfa(options)\n}\n\nasync function disableMfaMethod(method: MfaMethod) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to disable an MFA method.',\n )\n }\n\n return await awsCognitoClient.disableMfaMethod(method)\n}\n\nasync function setPreferredMfaMethod(method: MfaMethod) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to set the preferred MFA method.',\n )\n }\n\n return await awsCognitoClient.setPreferredMfaMethod(method)\n}\n\n/**\n * Setup authenticator app MFA for the current user. The result will include a\n * callback that should be called with the valid TOTP from an authenticator\n * app.\n *\n * #### Example\n *\n * ```js\n * const { secretCode, mfaCodeCallback } =\n * await authService.setupMfaAuthenticatorApp()\n * // Prompt the user to enter an MFA code\n * const code = prompt(\n * `Please enter a one-time code from your MFA app after creating a new entry with secret: ${secretCode}.`,\n * )\n * await mfaCodeCallback(code)\n * ```\n *\n * @returns\n */\nasync function setupMfaAuthenticatorApp(options?: { preferred?: boolean }) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to setup authenticator app MFA.',\n )\n }\n\n return await awsCognitoClient.setupMfaAuthenticatorApp(options)\n}\n\nexport {\n init,\n registerAuthListener,\n loginUsernamePassword,\n loginHostedUI,\n handleAuthentication,\n changePassword,\n forgotPassword,\n logoutHostedUI,\n logout,\n isLoggedIn,\n getCognitoIdToken,\n getUserProfile,\n getUserFriendlyName,\n checkIsMfaEnabled,\n getMfaSettings,\n updateUserPhoneNumber,\n removeUserPhoneNumber,\n sendPhoneNumberVerificationCode,\n verifyUserPhoneNumber,\n disableMfaMethod,\n setPreferredMfaMethod,\n setupSmsMfa,\n setupMfaAuthenticatorApp,\n generateMfaAuthenticatorAppQrCodeUrl,\n DEFAULT_MFA_SETTINGS,\n}\nexport type {\n LoginAttemptResponse,\n MfaMethod,\n MfaRequirementCheckResult,\n MfaSettings,\n}\n"]}
|
|
1
|
+
{"version":3,"file":"cognito.js","sourceRoot":"","sources":["../../../src/apps/services/cognito.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtC,OAAO,gBAAgB,EAAE,EACvB,oBAAoB,GAIrB,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,cAAc,MAAM,oBAAoB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAa,WAAW,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,OAAO,MAAM,YAAY,CAAA;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AAW,CAAC,OAAO,CAAC,CAAA;AACpD,CAAC;AAED,KAAK,UAAU,gBAAgB,CAAC,MAAiB;IAC/C,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,qHAAqH,CACtH,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;AACxD,CAAC;AAED,KAAK,UAAU,qBAAqB,CAAC,MAAiB;IACpD,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,4HAA4H,CAC7H,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAC7D,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,KAAK,UAAU,wBAAwB,CAAC,OAAiC;IACvE,IAAI,CAAC,gBAAgB,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CACb,2HAA2H,CAC5H,CAAA;IACH,CAAC;IAED,OAAO,MAAM,gBAAgB,CAAC,wBAAwB,CAAC,OAAO,CAAC,CAAA;AACjE,CAAC;AAED,OAAO,EACL,IAAI,EACJ,oBAAoB,EACpB,qBAAqB,EACrB,aAAa,EACb,oBAAoB,EACpB,cAAc,EACd,cAAc,EACd,cAAc,EACd,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,cAAc,EACd,mBAAmB,EACnB,cAAc,EACd,qBAAqB,EACrB,qBAAqB,EACrB,qBAAqB,EACrB,gBAAgB,EAChB,qBAAqB,EACrB,WAAW,EACX,wBAAwB,EACxB,oCAAoC,EACpC,oBAAoB,GACrB,CAAA","sourcesContent":["import { jwtDecode } from 'jwt-decode'\n\nimport AWSCognitoClient, {\n DEFAULT_MFA_SETTINGS,\n LoginAttemptResponse,\n MfaMethod,\n MfaSettings,\n} from './AWSCognitoClient'\n\nimport * as offlineService from '../offline-service'\nimport { userService } from '@oneblink/sdk-core'\nimport { MiscTypes } from '@oneblink/types'\nimport { HTTPError, postRequest } from './fetch'\nimport tenants from '../tenants'\nimport OneBlinkAppsError from './errors/oneBlinkAppsError'\n\ninterface CognitoServiceData {\n oAuthClientId: string\n loginDomain: string\n region: string\n redirectUri: string\n logoutUri: string\n}\n\nconst CONTINUE_TO = 'continueTo'\n\nlet awsCognitoClient: null | AWSCognitoClient = null\n\nfunction init(cognitoServiceData: CognitoServiceData) {\n console.log('Initiating CognitoIdentityServiceProvider', cognitoServiceData)\n\n awsCognitoClient = new AWSCognitoClient({\n clientId: cognitoServiceData.oAuthClientId,\n region: cognitoServiceData.region,\n loginDomain: cognitoServiceData.loginDomain,\n redirectUri: cognitoServiceData.redirectUri,\n logoutUri: cognitoServiceData.logoutUri,\n })\n}\n\n/**\n * Register a listener function that will be call when authentication tokens are\n * updated or removed.\n *\n * #### Example\n *\n * ```js\n * const listener = async () => {\n * // Check if the user is logged in still\n * const isLoggedIn = authService.isLoggedIn()\n * }\n * const deregister = await authService.registerAuthListener(listener)\n *\n * // When no longer needed, remember to deregister the listener\n * deregister()\n * ```\n *\n * @param listener\n * @returns\n */\nfunction registerAuthListener(listener: () => unknown): () => void {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to register a listener.',\n )\n }\n return awsCognitoClient.registerListener(listener)\n}\n\n/**\n * Create a session for a user by entering a username and password. If the user\n * requires a password reset, the \"resetPasswordCallback\" property will be\n * returned. This function should be called with the new password once entered\n * by the user. If the user requires an MFA token, the \"mfa\" property will be\n * returned. Its \"codeCallback\" should be called with the one-time token. The\n * functions returned are recursive and the result from each of them is the same\n * result from the loginUsernamePassword() function. Each time the response\n * includes a callback, you will need to begin the process again until all\n * callbacks are handled.\n *\n * #### Example\n *\n * ```js\n * async function handleLoginAttemptResponse({\n * resetPasswordCallback,\n * mfa,\n * }) {\n * // \"resetPasswordCallback\" will be undefined if a password reset was not required.\n * if (resetPasswordCallback) {\n * // Prompt the user to enter a new password\n * const newPassword = prompt(\n * 'The password you entered was only temporary, and must be reset for security purposes. Please enter your new password below to continue.',\n * )\n * const resetPasswordResponse =\n * await resetPasswordCallback(newPassword)\n * return await handleLoginAttemptResponse(resetPasswordResponse)\n * }\n *\n * // \"mfa\" will be undefined if MFA is not setup.\n * if (mfa) {\n * // Prompt the user to enter an MFA code\n * const code = prompt(\n * mfa.method === 'email'\n * ? 'Please enter the one-time code sent to your email.'\n * : 'Please enter a one-time code from your MFA app.',\n * )\n * const mfaCodeResponse = await mfa.codeCallback(code)\n * return await handleLoginAttemptResponse(mfaCodeResponse)\n * }\n * }\n *\n * const username = 'user@email.io'\n * const password = 'P@$5w0rd'\n *\n * const loginAttemptResponse = await authService.loginUsernamePassword(\n * username,\n * password,\n * )\n *\n * await handleLoginAttemptResponse(loginAttemptResponse)\n * ```\n *\n * @param username\n * @param password\n * @returns\n */\nasync function loginUsernamePassword(username: string, password: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to login.',\n )\n }\n console.log('Attempting sign using username', username)\n return awsCognitoClient.loginUsernamePassword(\n username.toLowerCase(),\n password,\n )\n}\n\n/**\n * Redirect the user to the login screen. Passing an `identityProvider` is\n * optionally, it will allow users to skip the login page and be directed\n * straight to that providers login page\n *\n * #### Example\n *\n * ```js\n * // OPtionally pass a\n * const identityProvider = 'Google'\n * await authService.loginHostedUI(identityProvider)\n * // User will be redirected to login page or promise will resolve\n * ```\n *\n * @param identityProviderName\n * @returns\n */\nasync function loginHostedUI(identityProviderName?: string): Promise<void> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to login.',\n )\n }\n const continueTo = `${window.location.pathname}${window.location.search}`\n localStorage.setItem(CONTINUE_TO, continueTo)\n\n return awsCognitoClient.loginHostedUI(identityProviderName)\n}\n\n/**\n * This function should be called when the user is redirected back to your app\n * after a login attempt. It will use the query string add the redirect URL to\n * create a session for the current user. It will return a URL as a `string`\n * that should be redirected to within your app.\n *\n * #### Example\n *\n * ```js\n * try {\n * const continueTo = await authService.handleAuthentication()\n * // Redirect the user back to where they were before attempting to login\n * window.location.href = continueTo\n * } catch (error) {\n * // handle failed login attempts here.\n * }\n * ```\n *\n * @returns\n */\nasync function handleAuthentication(): Promise<string> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to handle authentication in URL.',\n )\n }\n\n const continueTo = localStorage.getItem(CONTINUE_TO) || '/'\n if (isLoggedIn()) {\n console.log('Already authenticated, redirecting to:', continueTo)\n } else {\n await awsCognitoClient.handleAuthentication()\n }\n\n localStorage.removeItem(CONTINUE_TO)\n\n return continueTo\n}\n\n/**\n * Allow the currently logged in user to change their password by passing their\n * existing password and a new password.\n *\n * #### Example\n *\n * ```js\n * const currentPassword = 'P@$5w0rd'\n * const newPassword = 'P@$5w0rD'\n * await authService.changePassword(currentPassword, newPassword)\n * ```\n *\n * @param existingPassword\n * @param newPassword\n * @returns\n */\nasync function changePassword(existingPassword: string, newPassword: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to change passwords.',\n )\n }\n\n return await awsCognitoClient.changePassword(existingPassword, newPassword)\n}\n\n/**\n * Allow a user to start the forgot password process. The user will be emailed a\n * temporary code that must be passed with a new password to the function\n * returned.\n *\n * #### Example\n *\n * ```js\n * const username = 'user@email.io'\n * const finishForgotPassword = await authService.forgotPassword(username)\n *\n * // Prompt the user to enter the code and a new password\n * const code = prompt(\n * 'You have been emailed a verification code, please enter it here.',\n * )\n * const newPassword = prompt('Please enter a new password to continue.')\n * await finishForgotPassword(code, newPassword)\n * ```\n *\n * @param username\n * @param formsAppId Used to give the resulting email sent to the user\n * associated forms app branding and sending address\n * @returns\n */\nasync function forgotPassword(\n username: string,\n /**\n * Used to give the resulting email sent to the user associated forms app\n * branding and sending address\n */\n formsAppId?: number,\n): Promise<(code: string, password: string) => Promise<void>> {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before starting the forgot password process.',\n )\n }\n\n try {\n const url = `${tenants.current.apiOrigin}/authentication/reset-password`\n await postRequest(url, {\n username,\n formsAppId,\n })\n } catch (err) {\n const error = err as HTTPError\n switch (error.status) {\n case 400: {\n throw new OneBlinkAppsError(error.message, {\n title: 'Invalid Request',\n httpStatusCode: error.status,\n })\n }\n default: {\n throw new OneBlinkAppsError(\n 'An unknown error has occurred. Please contact support if the problem persists.',\n {\n originalError: error,\n httpStatusCode: error.status,\n },\n )\n }\n }\n }\n\n return async (code, password) => {\n await awsCognitoClient?.confirmForgotPassword({\n username,\n code,\n password,\n })\n }\n}\n\n/**\n * Redirect the user to the logout screen to clear the users session on the\n * hosted login page. User will then be redirected to `/logout`. After being\n * redirected back to the application, the `logout()` function should be called\n * to clear the session data from browser storage.\n *\n * #### Example\n *\n * ```js\n * authService.logoutHostedUI()\n * ```\n */\nfunction logoutHostedUI(): void {\n if (awsCognitoClient) {\n awsCognitoClient.logoutHostedUI()\n }\n}\n\nasync function logout() {\n if (awsCognitoClient) {\n await awsCognitoClient.logout()\n }\n}\n\n/**\n * Check if the user is currently logged in\n *\n * #### Example\n *\n * ```js\n * const isLoggedIn = authService.isLoggedIn()\n * // handle user being logged in or not\n * ```\n *\n * @returns\n */\nfunction isLoggedIn(): boolean {\n return !!(awsCognitoClient && awsCognitoClient._getRefreshToken())\n}\n\nasync function getCognitoIdToken(): Promise<string | undefined> {\n if (!awsCognitoClient) {\n return\n }\n\n if (offlineService.isOffline()) {\n return awsCognitoClient._getIdToken()\n }\n\n return await awsCognitoClient.getIdToken()\n}\n\n/**\n * Get current users profile based on there Id Token payload. This will return\n * `null` if the the current user is not logged in.\n *\n * #### Example\n *\n * ```js\n * const profile = authService.getUserProfile()\n * if (profile) {\n * // Use profile here\n * }\n * ```\n *\n * @returns\n */\nfunction getUserProfile(): MiscTypes.UserProfile | null {\n if (!awsCognitoClient) {\n return null\n }\n const idToken = awsCognitoClient._getIdToken()\n if (!idToken) {\n return null\n }\n\n const jwtToken = jwtDecode(idToken)\n return userService.parseUserProfile(jwtToken) || null\n}\n\nexport function getUsername(): string | undefined {\n const profile = getUserProfile()\n if (!profile) {\n return undefined\n }\n\n return profile.username\n}\n\n/**\n * A friendly `string` that represents the current user. Uses first name, last\n * name, full name and username. This will return `null` the current user is not\n * logged in.\n *\n * #### Example\n *\n * ```js\n * const name = authService.getUserFriendlyName()\n * if (name) {\n * // Display current user's name\n * }\n * ```\n *\n * @returns\n */\nfunction getUserFriendlyName(): string | undefined {\n const profile = getUserProfile()\n if (!profile) {\n return\n }\n\n return userService.getUserFriendlyName(profile)\n}\n\n/**\n * Generate a QR code link to display to a user after they have initiated\n * authenticator app MFA setup.\n *\n * #### Example\n *\n * ```js\n * const mfaAuthenticatorAppSetupQrCodeUrl =\n * mfaService.generateMfaAuthenticatorAppQrCodeUrl()\n * if (mfaAuthenticatorAppSetupQrCodeUrl) {\n * // use mfaAuthenticatorAppSetupQrCodeUrl to display QR code to user\n * }\n * ```\n *\n * @returns\n */\nfunction generateMfaAuthenticatorAppQrCodeUrl(\n mfaAuthenticatorAppSetup: Awaited<\n ReturnType<typeof setupMfaAuthenticatorApp>\n >,\n): string | undefined {\n const profile = getUserProfile()\n if (!profile || !mfaAuthenticatorAppSetup) {\n return\n }\n\n return `otpauth://totp/${tenants.current.productShortName}:${profile.email}?secret=${mfaAuthenticatorAppSetup.secretCode}&issuer=${tenants.current.productShortName}`\n}\n\nasync function getMfaSettings(abortSignal?: AbortSignal) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before checking MFA settings.',\n )\n }\n\n return await awsCognitoClient.getMfaSettings(abortSignal)\n}\n\nasync function updateUserPhoneNumber(phoneNumber: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before updating the user phone number.',\n )\n }\n\n return await awsCognitoClient.updateUserPhoneNumber(phoneNumber)\n}\n\nasync function removeUserPhoneNumber() {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before removing the user phone number.',\n )\n }\n\n return await awsCognitoClient.removeUserPhoneNumber()\n}\n\nasync function verifyUserPhoneNumber(code: string) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before verifying the user phone number.',\n )\n }\n\n return await awsCognitoClient.verifyUserPhoneNumber(code)\n}\n\nasync function setupSmsMfa(options?: { preferred?: boolean }) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to setup SMS MFA.',\n )\n }\n\n return await awsCognitoClient.setupSmsMfa(options)\n}\n\nasync function disableMfaMethod(method: MfaMethod) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to disable an MFA method.',\n )\n }\n\n return await awsCognitoClient.disableMfaMethod(method)\n}\n\nasync function setPreferredMfaMethod(method: MfaMethod) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to set the preferred MFA method.',\n )\n }\n\n return await awsCognitoClient.setPreferredMfaMethod(method)\n}\n\n/**\n * Setup authenticator app MFA for the current user. The result will include a\n * callback that should be called with the valid TOTP from an authenticator\n * app.\n *\n * #### Example\n *\n * ```js\n * const { secretCode, mfaCodeCallback } =\n * await mfaService.setupMfaAuthenticatorApp()\n * // Prompt the user to enter an MFA code\n * const code = prompt(\n * `Please enter a one-time code from your MFA app after creating a new entry with secret: ${secretCode}.`,\n * )\n * await mfaCodeCallback(code)\n * ```\n *\n * @returns\n */\nasync function setupMfaAuthenticatorApp(options?: { preferred?: boolean }) {\n if (!awsCognitoClient) {\n throw new Error(\n '\"authService\" has not been initiated. You must call the init() function before attempting to setup authenticator app MFA.',\n )\n }\n\n return await awsCognitoClient.setupMfaAuthenticatorApp(options)\n}\n\nexport {\n init,\n registerAuthListener,\n loginUsernamePassword,\n loginHostedUI,\n handleAuthentication,\n changePassword,\n forgotPassword,\n logoutHostedUI,\n logout,\n isLoggedIn,\n getCognitoIdToken,\n getUserProfile,\n getUserFriendlyName,\n getMfaSettings,\n updateUserPhoneNumber,\n removeUserPhoneNumber,\n verifyUserPhoneNumber,\n disableMfaMethod,\n setPreferredMfaMethod,\n setupSmsMfa,\n setupMfaAuthenticatorApp,\n generateMfaAuthenticatorAppQrCodeUrl,\n DEFAULT_MFA_SETTINGS,\n}\nexport type { LoginAttemptResponse, MfaMethod, MfaSettings }\n"]}
|
|
@@ -2,7 +2,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import { QRCodeSVG } from 'qrcode.react';
|
|
4
4
|
import { Box, Collapse, Dialog, Grid, Link, Typography, DialogContent, DialogActions, Button, DialogTitle, } from '@mui/material';
|
|
5
|
-
import {
|
|
5
|
+
import { mfaService } from '../../apps';
|
|
6
6
|
import useBooleanState from '../../hooks/useBooleanState';
|
|
7
7
|
import useMfa from '../../hooks/useMfa';
|
|
8
8
|
import { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton';
|
|
@@ -13,7 +13,7 @@ function MfaAuthenticatorAppDialog() {
|
|
|
13
13
|
const [isShowingSecretCode, showSecretCode, hideSecretCode] = useBooleanState(false);
|
|
14
14
|
const qrcodeValue = React.useMemo(() => {
|
|
15
15
|
if (mfaAuthenticatorAppSetup) {
|
|
16
|
-
return
|
|
16
|
+
return mfaService.generateMfaAuthenticatorAppQrCodeUrl(mfaAuthenticatorAppSetup);
|
|
17
17
|
}
|
|
18
18
|
}, [mfaAuthenticatorAppSetup]);
|
|
19
19
|
const [isSaving, startSaving, stopSaving] = useBooleanState(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MfaAuthenticatorAppDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaAuthenticatorAppDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OA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,WAAW,EAAC,YAAY,iCAE/B,EACb,KAAC,UAAU,IAAC,OAAO,EAAC,OAAO,EAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,wEAE5B,EAEb,KAAC,UAAU,IACT,SAAS,QACT,MAAM,EAAC,MAAM,EACb,IAAI,EAAC,MAAM,EACX,KAAK,EAAC,MAAM,EACZ,SAAS,QACT,WAAW,EAAC,QAAQ,EACpB,OAAO,EAAC,UAAU,EAClB,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oCAClB,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAA;oCACnC,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,CAAC,CAAA;gCAC1B,CAAC,EACD,QAAQ,EAAE,QAAQ,kBACL,4BAA4B,GACzC,IACY,EAChB,MAAC,aAAa,eACZ,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,8BAA8B,EACvC,QAAQ,EAAE,QAAQ,uBAGX,EACT,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,KAAK,EAAC,SAAS,EACf,QAAQ,EAAE,CAAC,IAAI,IAAI,QAAQ,qBAGpB,IACK,IACX,GACA,GACM,CAClB,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { QRCodeSVG } from 'qrcode.react'\nimport {\n Box,\n Collapse,\n Dialog,\n Grid,\n Link,\n Typography,\n DialogContent,\n DialogActions,\n Button,\n DialogTitle,\n} from '@mui/material'\nimport { authService } from '../../apps'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useMfa from '../../hooks/useMfa'\nimport { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton'\nimport InputField from '../InputField'\n\nfunction MfaAuthenticatorAppDialog() {\n const {\n mfaAuthenticatorAppSetup,\n cancelMfaAuthenticatorAppSetup,\n completeMfaAuthenticatorAppSetup,\n } = useMfa()\n\n const [code, setState] = React.useState('')\n const [isShowingSecretCode, showSecretCode, hideSecretCode] =\n useBooleanState(false)\n\n const qrcodeValue = React.useMemo(() => {\n if (mfaAuthenticatorAppSetup) {\n return authService.generateMfaAuthenticatorAppQrCodeUrl(\n mfaAuthenticatorAppSetup,\n )\n }\n }, [mfaAuthenticatorAppSetup])\n\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n const handleSubmit = React.useCallback(\n async (event: React.SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n if (!code || !mfaAuthenticatorAppSetup || isSaving) {\n return\n }\n\n startSaving()\n try {\n await mfaAuthenticatorAppSetup.mfaCodeCallback(code)\n await completeMfaAuthenticatorAppSetup()\n } finally {\n stopSaving()\n }\n },\n [\n code,\n completeMfaAuthenticatorAppSetup,\n isSaving,\n mfaAuthenticatorAppSetup,\n startSaving,\n stopSaving,\n ],\n )\n\n return (\n <React.Fragment>\n <Dialog\n open={!!mfaAuthenticatorAppSetup}\n onClose={cancelMfaAuthenticatorAppSetup}\n title=\"Complete MFA Setup\"\n >\n <form onSubmit={handleSubmit}>\n <DialogTitle>Authenticator App Setup</DialogTitle>\n <DialogContent dividers>\n <Typography variant=\"body2\" component=\"p\" sx={{ mb: 2 }}>\n Authenticator apps like{' '}\n <Link\n href=\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Google Authenticator\n </Link>{' '}\n and{' '}\n <Link\n href=\"https://www.microsoft.com/en-us/security/mobile-authenticator-app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Microsoft Authenticator\n </Link>{' '}\n generate one-time passwords that are used as a second factor to\n verify your identity when prompted during sign-in.\n </Typography>\n <Typography variant=\"subtitle2\" gutterBottom>\n Scan the QR code\n </Typography>\n <Typography variant=\"body2\" sx={{ mb: 2 }}>\n Use an authenticator app or browser extension to scan the QR code\n below.\n </Typography>\n\n <Box marginBottom={2}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid>\n <Box\n border={1}\n padding={2}\n borderRadius={1}\n borderColor=\"divider\"\n display=\"inline-block\"\n lineHeight={0}\n >\n <QRCodeSVG value={qrcodeValue || ''} />\n </Box>\n </Grid>\n <Grid size={{ xs: 'grow' }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n Having trouble scanning the QR code?{' '}\n <Link\n type=\"button\"\n onClick={showSecretCode}\n component=\"button\"\n >\n Click here\n </Link>{' '}\n to display the setup key which can be manually entered in\n your authenticator app.\n </Typography>\n </Grid>\n </Grid>\n </Box>\n\n <Collapse in={isShowingSecretCode}>\n <Box marginBottom={2}>\n <InputField\n label=\"Setup Key\"\n value={mfaAuthenticatorAppSetup?.secretCode || ''}\n variant=\"filled\"\n focused={false}\n sx={{\n input: {\n cursor: 'default !important',\n },\n }}\n fullWidth\n slotProps={{\n input: {\n readOnly: true,\n endAdornment: (\n <CopyToClipBoardIconButton\n text={mfaAuthenticatorAppSetup?.secretCode || ''}\n />\n ),\n },\n }}\n helperText={\n <>\n <Link\n type=\"button\"\n onClick={hideSecretCode}\n component=\"button\"\n >\n Click here\n </Link>{' '}\n to hide the setup key\n </>\n }\n />\n </Box>\n </Collapse>\n\n <Typography variant=\"subtitle2\" gutterBottom>\n Verify App\n </Typography>\n <Typography variant=\"body2\" sx={{ mb: 2 }}>\n Enter the 6-digit code found in your authenticator app.\n </Typography>\n\n <InputField\n autoFocus\n margin=\"none\"\n name=\"code\"\n label=\"Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={code}\n onChange={(event) => {\n const newValue = event.target.value\n setState(() => newValue)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-authenticator-app-code\"\n />\n </DialogContent>\n <DialogActions>\n <Button\n type=\"button\"\n onClick={cancelMfaAuthenticatorAppSetup}\n disabled={isSaving}\n >\n Cancel\n </Button>\n <Button\n type=\"submit\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!code || isSaving}\n >\n Save\n </Button>\n </DialogActions>\n </form>\n </Dialog>\n </React.Fragment>\n )\n}\n\n/**\n * React Component that guides users through authenticator app MFA setup,\n * including QR code scanning and verification code entry. Typically rendered by\n * `<MultiFactorAuthentication />` within an\n * `<MfaProvider />` tree.\n *\n * @returns\n */\nexport default React.memo(MfaAuthenticatorAppDialog)\n"]}
|
|
1
|
+
{"version":3,"file":"MfaAuthenticatorAppDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaAuthenticatorAppDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EACL,GAAG,EACH,QAAQ,EACR,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,UAAU,EACV,aAAa,EACb,aAAa,EACb,MAAM,EACN,WAAW,GACZ,MAAM,eAAe,CAAA;AACtB,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AACvC,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,EAAE,yBAAyB,EAAE,MAAM,8BAA8B,CAAA;AACxE,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,SAAS,yBAAyB;IAChC,MAAM,EACJ,wBAAwB,EACxB,8BAA8B,EAC9B,gCAAgC,GACjC,GAAG,MAAM,EAAE,CAAA;IAEZ,MAAM,CAAC,IAAI,EAAE,QAAQ,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;IAC3C,MAAM,CAAC,mBAAmB,EAAE,cAAc,EAAE,cAAc,CAAC,GACzD,eAAe,CAAC,KAAK,CAAC,CAAA;IAExB,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;QACrC,IAAI,wBAAwB,EAAE,C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A,GACM,CAClB,CAAA;AACH,CAAC;AAED;;;;;;;GAOG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport { QRCodeSVG } from 'qrcode.react'\nimport {\n Box,\n Collapse,\n Dialog,\n Grid,\n Link,\n Typography,\n DialogContent,\n DialogActions,\n Button,\n DialogTitle,\n} from '@mui/material'\nimport { mfaService } from '../../apps'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useMfa from '../../hooks/useMfa'\nimport { CopyToClipBoardIconButton } from '../CopyToClipboardIconButton'\nimport InputField from '../InputField'\n\nfunction MfaAuthenticatorAppDialog() {\n const {\n mfaAuthenticatorAppSetup,\n cancelMfaAuthenticatorAppSetup,\n completeMfaAuthenticatorAppSetup,\n } = useMfa()\n\n const [code, setState] = React.useState('')\n const [isShowingSecretCode, showSecretCode, hideSecretCode] =\n useBooleanState(false)\n\n const qrcodeValue = React.useMemo(() => {\n if (mfaAuthenticatorAppSetup) {\n return mfaService.generateMfaAuthenticatorAppQrCodeUrl(\n mfaAuthenticatorAppSetup,\n )\n }\n }, [mfaAuthenticatorAppSetup])\n\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n const handleSubmit = React.useCallback(\n async (event: React.SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n if (!code || !mfaAuthenticatorAppSetup || isSaving) {\n return\n }\n\n startSaving()\n try {\n await mfaAuthenticatorAppSetup.mfaCodeCallback(code)\n await completeMfaAuthenticatorAppSetup()\n } finally {\n stopSaving()\n }\n },\n [\n code,\n completeMfaAuthenticatorAppSetup,\n isSaving,\n mfaAuthenticatorAppSetup,\n startSaving,\n stopSaving,\n ],\n )\n\n return (\n <React.Fragment>\n <Dialog\n open={!!mfaAuthenticatorAppSetup}\n onClose={cancelMfaAuthenticatorAppSetup}\n title=\"Complete MFA Setup\"\n >\n <form onSubmit={handleSubmit}>\n <DialogTitle>Authenticator App Setup</DialogTitle>\n <DialogContent dividers>\n <Typography variant=\"body2\" component=\"p\" sx={{ mb: 2 }}>\n Authenticator apps like{' '}\n <Link\n href=\"https://play.google.com/store/apps/details?id=com.google.android.apps.authenticator2\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Google Authenticator\n </Link>{' '}\n and{' '}\n <Link\n href=\"https://www.microsoft.com/en-us/security/mobile-authenticator-app\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n >\n Microsoft Authenticator\n </Link>{' '}\n generate one-time passwords that are used as a second factor to\n verify your identity when prompted during sign-in.\n </Typography>\n <Typography variant=\"subtitle2\" gutterBottom>\n Scan the QR code\n </Typography>\n <Typography variant=\"body2\" sx={{ mb: 2 }}>\n Use an authenticator app or browser extension to scan the QR code\n below.\n </Typography>\n\n <Box marginBottom={2}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid>\n <Box\n border={1}\n padding={2}\n borderRadius={1}\n borderColor=\"divider\"\n display=\"inline-block\"\n lineHeight={0}\n >\n <QRCodeSVG value={qrcodeValue || ''} />\n </Box>\n </Grid>\n <Grid size={{ xs: 'grow' }}>\n <Typography variant=\"caption\" color=\"text.secondary\">\n Having trouble scanning the QR code?{' '}\n <Link\n type=\"button\"\n onClick={showSecretCode}\n component=\"button\"\n >\n Click here\n </Link>{' '}\n to display the setup key which can be manually entered in\n your authenticator app.\n </Typography>\n </Grid>\n </Grid>\n </Box>\n\n <Collapse in={isShowingSecretCode}>\n <Box marginBottom={2}>\n <InputField\n label=\"Setup Key\"\n value={mfaAuthenticatorAppSetup?.secretCode || ''}\n variant=\"filled\"\n focused={false}\n sx={{\n input: {\n cursor: 'default !important',\n },\n }}\n fullWidth\n slotProps={{\n input: {\n readOnly: true,\n endAdornment: (\n <CopyToClipBoardIconButton\n text={mfaAuthenticatorAppSetup?.secretCode || ''}\n />\n ),\n },\n }}\n helperText={\n <>\n <Link\n type=\"button\"\n onClick={hideSecretCode}\n component=\"button\"\n >\n Click here\n </Link>{' '}\n to hide the setup key\n </>\n }\n />\n </Box>\n </Collapse>\n\n <Typography variant=\"subtitle2\" gutterBottom>\n Verify App\n </Typography>\n <Typography variant=\"body2\" sx={{ mb: 2 }}>\n Enter the 6-digit code found in your authenticator app.\n </Typography>\n\n <InputField\n autoFocus\n margin=\"none\"\n name=\"code\"\n label=\"Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={code}\n onChange={(event) => {\n const newValue = event.target.value\n setState(() => newValue)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-authenticator-app-code\"\n />\n </DialogContent>\n <DialogActions>\n <Button\n type=\"button\"\n onClick={cancelMfaAuthenticatorAppSetup}\n disabled={isSaving}\n >\n Cancel\n </Button>\n <Button\n type=\"submit\"\n variant=\"contained\"\n color=\"primary\"\n disabled={!code || isSaving}\n >\n Save\n </Button>\n </DialogActions>\n </form>\n </Dialog>\n </React.Fragment>\n )\n}\n\n/**\n * React Component that guides users through authenticator app MFA setup,\n * including QR code scanning and verification code entry. Typically rendered by\n * `<MultiFactorAuthentication />` within an\n * `<MfaProvider />` tree.\n *\n * @returns\n */\nexport default React.memo(MfaAuthenticatorAppDialog)\n"]}
|
|
@@ -8,12 +8,13 @@ type Props = {
|
|
|
8
8
|
title: string;
|
|
9
9
|
description: string;
|
|
10
10
|
detail?: string;
|
|
11
|
+
mfaRequirementMessage?: string;
|
|
11
12
|
cypressPrefix: string;
|
|
12
13
|
extraButtons?: React.ReactNode;
|
|
13
14
|
onSetup: () => void;
|
|
14
15
|
onDisable: () => void;
|
|
15
16
|
onSetPreferred: () => void;
|
|
16
17
|
};
|
|
17
|
-
declare function MfaMethodRow({ isEnabled, isPreferred, isSettingUp, isSettingPreferredMfaMethod, isSetupDisabled, showSetupErrorTooltip, title, description, detail, cypressPrefix, extraButtons, onSetup, onDisable, onSetPreferred, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
18
|
+
declare function MfaMethodRow({ isEnabled, isPreferred, isSettingUp, isSettingPreferredMfaMethod, isSetupDisabled, showSetupErrorTooltip, title, description, detail, mfaRequirementMessage, cypressPrefix, extraButtons, onSetup, onDisable, onSetPreferred, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
18
19
|
declare const _default: import("react").MemoExoticComponent<typeof MfaMethodRow>;
|
|
19
20
|
export default _default;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
-
import { Box, Button, Chip, Grid, Tooltip, Typography } from '@mui/material';
|
|
4
|
-
function MfaMethodRow({ isEnabled, isPreferred, isSettingUp, isSettingPreferredMfaMethod, isSetupDisabled, showSetupErrorTooltip, title, description, detail, cypressPrefix, extraButtons, onSetup, onDisable, onSetPreferred, }) {
|
|
5
|
-
return (_jsx(Box, { "data-cypress": `${cypressPrefix}-method-row`, children: _jsxs(Grid, { container: true, spacing: 2, alignItems: "center", children: [_jsxs(Grid, { size: { xs: 'grow' }, children: [_jsxs(Box, { sx: { mb: 1 }, children: [_jsx(Typography, { variant: "subtitle1", component: "span", children: title }), isEnabled && (_jsx(Chip, { size: "small", label: "Enabled", color: "info", sx: { ml: 1 }, "data-cypress": `${cypressPrefix}-status-chip` })), isPreferred && (_jsx(Chip, { size: "small", label: "Preferred", color: "success", sx: { ml: 1 }, "data-cypress": `${cypressPrefix}-preferred-chip` }))] }), _jsx(Typography, { variant: "body2", color: "text.secondary", children: description }), !!detail && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 1 }, children: detail }))] }), _jsx(Grid, { size: "auto", children: _jsxs(Box, { display: "flex", gap: 1, flexWrap: "wrap", justifyContent: "flex-end", children: [extraButtons, isEnabled ? (_jsxs(_Fragment, { children: [!isPreferred && (_jsx(Button, { size: "small", variant: "outlined", loading: isSettingPreferredMfaMethod, disabled: isSettingPreferredMfaMethod, onClick: onSetPreferred, "data-cypress": `${cypressPrefix}-set-preferred-button`, children: "Set as Preferred" })), _jsx(Button, { size: "small", variant: "outlined", onClick: onDisable, "data-cypress": `${cypressPrefix}-disable-button`, children: "Disable" })] })) : (_jsx(Tooltip, { title: showSetupErrorTooltip
|
|
3
|
+
import { Alert, Box, Button, Chip, Grid, Tooltip, Typography, } from '@mui/material';
|
|
4
|
+
function MfaMethodRow({ isEnabled, isPreferred, isSettingUp, isSettingPreferredMfaMethod, isSetupDisabled, showSetupErrorTooltip, title, description, detail, mfaRequirementMessage, cypressPrefix, extraButtons, onSetup, onDisable, onSetPreferred, }) {
|
|
5
|
+
return (_jsx(Box, { "data-cypress": `${cypressPrefix}-method-row`, children: _jsxs(Grid, { container: true, spacing: 2, alignItems: "center", children: [_jsxs(Grid, { size: { xs: 'grow' }, children: [_jsxs(Box, { sx: { mb: 1 }, children: [_jsx(Typography, { variant: "subtitle1", component: "span", children: title }), isEnabled && (_jsx(Chip, { size: "small", label: "Enabled", color: "info", sx: { ml: 1 }, "data-cypress": `${cypressPrefix}-status-chip` })), isPreferred && (_jsx(Chip, { size: "small", label: "Preferred", color: "success", sx: { ml: 1 }, "data-cypress": `${cypressPrefix}-preferred-chip` }))] }), _jsx(Typography, { variant: "body2", color: "text.secondary", children: description }), !!detail && (_jsx(Typography, { variant: "body2", color: "text.secondary", sx: { mt: 1 }, children: detail })), !!mfaRequirementMessage && (_jsx(Alert, { severity: isEnabled && isPreferred ? 'warning' : 'info', sx: { mt: 1 }, "data-cypress": `${cypressPrefix}-mfa-requirement-message`, children: mfaRequirementMessage }))] }), _jsx(Grid, { size: "auto", children: _jsxs(Box, { display: "flex", gap: 1, flexWrap: "wrap", justifyContent: "flex-end", children: [extraButtons, isEnabled ? (_jsxs(_Fragment, { children: [!isPreferred && (_jsx(Button, { size: "small", variant: "outlined", loading: isSettingPreferredMfaMethod, disabled: isSettingPreferredMfaMethod, onClick: onSetPreferred, "data-cypress": `${cypressPrefix}-set-preferred-button`, children: "Set as Preferred" })), _jsx(Button, { size: "small", variant: "outlined", onClick: onDisable, "data-cypress": `${cypressPrefix}-disable-button`, children: "Disable" })] })) : (_jsx(Tooltip, { title: showSetupErrorTooltip
|
|
6
6
|
? 'We are unable to load your MFA status. Please try again by clicking the reload button on the chip above.'
|
|
7
7
|
: '', children: _jsx("span", { children: _jsx(Button, { size: "small", variant: "contained", loading: isSettingUp, disabled: isSetupDisabled, onClick: onSetup, "data-cypress": `${cypressPrefix}-setup-button`, children: "Setup" }) }) }))] }) })] }) }));
|
|
8
8
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MfaMethodRow.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaMethodRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,
|
|
1
|
+
{"version":3,"file":"MfaMethodRow.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaMethodRow.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,OAAO,CAAA;AAC5B,OAAO,EACL,KAAK,EACL,GAAG,EACH,MAAM,EACN,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,UAAU,GACX,MAAM,eAAe,CAAA;AAoBtB,SAAS,YAAY,CAAC,EACpB,SAAS,EACT,WAAW,EACX,WAAW,EACX,2BAA2B,EAC3B,eAAe,EACf,qBAAqB,EACrB,KAAK,EACL,WAAW,EACX,MAAM,EACN,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,OAAO,EACP,SAAS,EACT,cAAc,GACR;IACN,OAAO,CACL,KAAC,GAAG,oBAAe,GAAG,aAAa,aAAa,YAC9C,MAAC,IAAI,IAAC,SAAS,QAAC,OAAO,EAAE,CAAC,EAAE,UAAU,EAAC,QAAQ,aAC7C,MAAC,IAAI,IAAC,IAAI,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,aACxB,MAAC,GAAG,IAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE,aAChB,KAAC,UAAU,IAAC,OAAO,EAAC,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AAE,2BAA2B,EACpC,QAAQ,EAAE,2BAA2B,EACrC,OAAO,EAAE,cAAc,kBACT,GAAG,aAAa,uBAAuB,iCAG9C,CACV,EACD,KAAC,MAAM,IACL,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,UAAU,EAClB,OAAO,EAAE,SAAS,kBACJ,GAAG,aAAa,iBAAiB,wBAGxC,IACR,CACJ,CAAC,CAAC,CAAC,CACF,KAAC,OAAO,IACN,KAAK,EACH,qBAAqB;oCACnB,CAAC,CAAC,0GAA0G;oCAC5G,CAAC,CAAC,EAAE,YAGR,yBACE,KAAC,MAAM,IACL,IAAI,EAAC,OAAO,EACZ,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,WAAW,EACpB,QAAQ,EAAE,eAAe,EACzB,OAAO,EAAE,OAAO,kBACF,GAAG,aAAa,eAAe,sBAGtC,GACJ,GACC,CACX,IACG,GACD,IACF,GACH,CACP,CAAA;AACH,CAAC;AAED,eAAe,IAAI,CAAC,YAAY,CAAC,CAAA","sourcesContent":["import { memo } from 'react'\nimport {\n Alert,\n Box,\n Button,\n Chip,\n Grid,\n Tooltip,\n Typography,\n} from '@mui/material'\n\ntype Props = {\n isEnabled: boolean\n isPreferred: boolean\n isSettingUp: boolean\n isSettingPreferredMfaMethod: boolean\n isSetupDisabled: boolean\n showSetupErrorTooltip?: boolean\n title: string\n description: string\n detail?: string\n mfaRequirementMessage?: string\n cypressPrefix: string\n extraButtons?: React.ReactNode\n onSetup: () => void\n onDisable: () => void\n onSetPreferred: () => void\n}\n\nfunction MfaMethodRow({\n isEnabled,\n isPreferred,\n isSettingUp,\n isSettingPreferredMfaMethod,\n isSetupDisabled,\n showSetupErrorTooltip,\n title,\n description,\n detail,\n mfaRequirementMessage,\n cypressPrefix,\n extraButtons,\n onSetup,\n onDisable,\n onSetPreferred,\n}: Props) {\n return (\n <Box data-cypress={`${cypressPrefix}-method-row`}>\n <Grid container spacing={2} alignItems=\"center\">\n <Grid size={{ xs: 'grow' }}>\n <Box sx={{ mb: 1 }}>\n <Typography variant=\"subtitle1\" component=\"span\">\n {title}\n </Typography>\n {isEnabled && (\n <Chip\n size=\"small\"\n label=\"Enabled\"\n color=\"info\"\n sx={{ ml: 1 }}\n data-cypress={`${cypressPrefix}-status-chip`}\n />\n )}\n {isPreferred && (\n <Chip\n size=\"small\"\n label=\"Preferred\"\n color=\"success\"\n sx={{ ml: 1 }}\n data-cypress={`${cypressPrefix}-preferred-chip`}\n />\n )}\n </Box>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {description}\n </Typography>\n {!!detail && (\n <Typography variant=\"body2\" color=\"text.secondary\" sx={{ mt: 1 }}>\n {detail}\n </Typography>\n )}\n {!!mfaRequirementMessage && (\n <Alert\n severity={isEnabled && isPreferred ? 'warning' : 'info'}\n sx={{ mt: 1 }}\n data-cypress={`${cypressPrefix}-mfa-requirement-message`}\n >\n {mfaRequirementMessage}\n </Alert>\n )}\n </Grid>\n <Grid size=\"auto\">\n <Box display=\"flex\" gap={1} flexWrap=\"wrap\" justifyContent=\"flex-end\">\n {extraButtons}\n {isEnabled ? (\n <>\n {!isPreferred && (\n <Button\n size=\"small\"\n variant=\"outlined\"\n loading={isSettingPreferredMfaMethod}\n disabled={isSettingPreferredMfaMethod}\n onClick={onSetPreferred}\n data-cypress={`${cypressPrefix}-set-preferred-button`}\n >\n Set as Preferred\n </Button>\n )}\n <Button\n size=\"small\"\n variant=\"outlined\"\n onClick={onDisable}\n data-cypress={`${cypressPrefix}-disable-button`}\n >\n Disable\n </Button>\n </>\n ) : (\n <Tooltip\n title={\n showSetupErrorTooltip\n ? 'We are unable to load your MFA status. Please try again by clicking the reload button on the chip above.'\n : ''\n }\n >\n <span>\n <Button\n size=\"small\"\n variant=\"contained\"\n loading={isSettingUp}\n disabled={isSetupDisabled}\n onClick={onSetup}\n data-cypress={`${cypressPrefix}-setup-button`}\n >\n Setup\n </Button>\n </span>\n </Tooltip>\n )}\n </Box>\n </Grid>\n </Grid>\n </Box>\n )\n}\n\nexport default memo(MfaMethodRow)\n"]}
|
|
@@ -9,7 +9,7 @@ function getResendCoolDownRemainingSeconds(sentAt, now) {
|
|
|
9
9
|
if (!sentAt) {
|
|
10
10
|
return 0;
|
|
11
11
|
}
|
|
12
|
-
const elapsedSeconds = Math.floor((now - sentAt) / 1000);
|
|
12
|
+
const elapsedSeconds = Math.max(0, Math.floor((now - sentAt) / 1000));
|
|
13
13
|
return Math.max(0, PHONE_VERIFICATION_RESEND_COOL_DOWN_SECONDS - elapsedSeconds);
|
|
14
14
|
}
|
|
15
15
|
function usePhoneVerificationResendCoolDown(sentAt) {
|
|
@@ -19,10 +19,7 @@ function usePhoneVerificationResendCoolDown(sentAt) {
|
|
|
19
19
|
if (!sentAt) {
|
|
20
20
|
return;
|
|
21
21
|
}
|
|
22
|
-
|
|
23
|
-
if (remaining <= 0) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
22
|
+
setNow(Date.now());
|
|
26
23
|
const intervalId = window.setInterval(() => {
|
|
27
24
|
setNow(Date.now());
|
|
28
25
|
}, 1000);
|
|
@@ -31,13 +28,12 @@ function usePhoneVerificationResendCoolDown(sentAt) {
|
|
|
31
28
|
return remainingSeconds;
|
|
32
29
|
}
|
|
33
30
|
function MfaPhoneNumberDialog() {
|
|
34
|
-
const { isPhoneNumberDialogOpen, mfaSettings, phoneVerificationCodeSentAt, closePhoneNumberDialog, savePhoneNumber, verifyPhoneNumber,
|
|
31
|
+
const { isPhoneNumberDialogOpen, mfaSettings, phoneVerificationCodeSentAt, closePhoneNumberDialog, savePhoneNumber, verifyPhoneNumber, } = useMfa();
|
|
35
32
|
const isPhoneVerificationRequired = phoneVerificationCodeSentAt !== undefined;
|
|
36
33
|
const [phoneNumber, setPhoneNumber] = React.useState('');
|
|
37
34
|
const [verificationCode, setVerificationCode] = React.useState('');
|
|
38
35
|
const resendCoolDownSeconds = usePhoneVerificationResendCoolDown(phoneVerificationCodeSentAt);
|
|
39
36
|
const [isSaving, startSaving, stopSaving] = useBooleanState(false);
|
|
40
|
-
const [isResending, startResending, stopResending] = useBooleanState(false);
|
|
41
37
|
React.useEffect(() => {
|
|
42
38
|
if (isPhoneNumberDialogOpen) {
|
|
43
39
|
setPhoneNumber(mfaSettings.sms.phoneNumber || '');
|
|
@@ -87,14 +83,14 @@ function MfaPhoneNumberDialog() {
|
|
|
87
83
|
verificationCode,
|
|
88
84
|
]);
|
|
89
85
|
const handleResendVerificationCode = React.useCallback(async () => {
|
|
90
|
-
|
|
86
|
+
startSaving();
|
|
91
87
|
try {
|
|
92
|
-
await
|
|
88
|
+
await savePhoneNumber(phoneNumber);
|
|
93
89
|
}
|
|
94
90
|
finally {
|
|
95
|
-
|
|
91
|
+
stopSaving();
|
|
96
92
|
}
|
|
97
|
-
}, [
|
|
93
|
+
}, [phoneNumber, savePhoneNumber, startSaving, stopSaving]);
|
|
98
94
|
return (_jsx(Dialog, { open: isPhoneNumberDialogOpen, onClose: () => {
|
|
99
95
|
if (!isSaving) {
|
|
100
96
|
closePhoneNumberDialog();
|
|
@@ -103,9 +99,9 @@ function MfaPhoneNumberDialog() {
|
|
|
103
99
|
? 'Verify Phone Number'
|
|
104
100
|
: 'Save Phone Number' }), _jsx(DialogContent, { dividers: true, children: isPhoneVerificationRequired ? (_jsxs(_Fragment, { children: [_jsxs(Typography, { variant: "body2", paragraph: true, children: ["Enter the verification code sent to ", phoneNumber, "."] }), _jsx(InputField, { autoFocus: true, margin: "none", name: "verificationCode", label: "Verification Code", fullWidth: true, placeholder: "XXXXXX", variant: "outlined", value: verificationCode, onChange: (event) => {
|
|
105
101
|
setVerificationCode(event.target.value);
|
|
106
|
-
}, disabled: isSaving, "data-cypress": "mfa-phone-verification-code" }, "verification-code"), _jsx(Box, { marginTop: 1, children: _jsx(Button, { type: "button", variant: "text", size: "small", disabled: resendCoolDownSeconds > 0 || isSaving
|
|
107
|
-
? `Send
|
|
108
|
-
: 'Send
|
|
102
|
+
}, disabled: isSaving, "data-cypress": "mfa-phone-verification-code" }, "verification-code"), _jsx(Box, { marginTop: 1, children: _jsx(Button, { type: "button", variant: "text", size: "small", sx: { textTransform: 'none' }, disabled: resendCoolDownSeconds > 0 || isSaving, onClick: handleResendVerificationCode, "data-cypress": "mfa-phone-resend-button", children: resendCoolDownSeconds > 0
|
|
103
|
+
? `Send Again (${resendCoolDownSeconds}s)`
|
|
104
|
+
: 'Send Again' }) })] })) : (_jsxs(_Fragment, { children: [_jsx(Typography, { variant: "body2", paragraph: true, children: "Enter your phone number to receive SMS verification codes when signing in." }), _jsx(InputField, { autoFocus: true, margin: "none", name: "phoneNumber", label: "Phone Number", fullWidth: true, placeholder: "+61400000000", variant: "outlined", value: phoneNumber, onChange: (event) => {
|
|
109
105
|
setPhoneNumber(event.target.value);
|
|
110
106
|
}, disabled: isSaving, helperText: "Include your country code, for example +61400000000.", "data-cypress": "mfa-phone-number" }, "phone-number")] })) }), _jsxs(DialogActions, { children: [_jsx(Button, { type: "button", onClick: closePhoneNumberDialog, disabled: isSaving, children: "Cancel" }), isPhoneVerificationRequired ? (_jsx(Button, { type: "submit", variant: "contained", disabled: !verificationCode || isSaving, "data-cypress": "mfa-phone-verify-button", children: "Verify" })) : (_jsx(Button, { type: "submit", variant: "contained", disabled: !phoneNumber || isSaving, "data-cypress": "mfa-phone-save-button", children: "Save" }))] })] }) }));
|
|
111
107
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MfaPhoneNumberDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaPhoneNumberDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,MAAM,EACN,aAAa,EACb,aAAa,EACb,WAAW,EACX,MAAM,EACN,UAAU,EACV,GAAG,GACJ,MAAM,eAAe,CAAA;AACtB,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,UAAU,MAAM,eAAe,CAA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,WAAW,EAClB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE;oCAClB,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;gCACpC,CAAC,EACD,QAAQ,EAAE,QAAQ,EAClB,UAAU,EAAC,sDAAsD,kBACpD,kBAAkB,IAd3B,cAAc,CAelB,IACD,CACJ,GACa,EAChB,MAAC,aAAa,eACZ,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,sBAAsB,EAC/B,QAAQ,EAAE,QAAQ,uBAGX,EACR,2BAA2B,CAAC,CAAC,CAAC,CAC7B,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,CAAC,gBAAgB,IAAI,QAAQ,kBAC1B,yBAAyB,uBAG/B,CACV,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,CAAC,WAAW,IAAI,QAAQ,kBACrB,uBAAuB,qBAG7B,CACV,IACa,IACX,GACA,CACV,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Button,\n Typography,\n Box,\n} from '@mui/material'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useMfa from '../../hooks/useMfa'\nimport InputField from '../InputField'\n\nconst PHONE_VERIFICATION_RESEND_COOL_DOWN_SECONDS = 60\n\nfunction getResendCoolDownRemainingSeconds(\n sentAt: number | undefined,\n now: number,\n) {\n if (!sentAt) {\n return 0\n }\n\n const elapsedSeconds = Math.floor((now - sentAt) / 1000)\n return Math.max(\n 0,\n PHONE_VERIFICATION_RESEND_COOL_DOWN_SECONDS - elapsedSeconds,\n )\n}\n\nfunction usePhoneVerificationResendCoolDown(sentAt: number | undefined) {\n const [now, setNow] = React.useState(() => Date.now())\n\n const remainingSeconds = getResendCoolDownRemainingSeconds(sentAt, now)\n\n React.useEffect(() => {\n if (!sentAt) {\n return\n }\n\n const remaining = getResendCoolDownRemainingSeconds(sentAt, Date.now())\n if (remaining <= 0) {\n return\n }\n\n const intervalId = window.setInterval(() => {\n setNow(Date.now())\n }, 1000)\n\n return () => window.clearInterval(intervalId)\n }, [sentAt])\n\n return remainingSeconds\n}\n\nfunction MfaPhoneNumberDialog() {\n const {\n isPhoneNumberDialogOpen,\n mfaSettings,\n phoneVerificationCodeSentAt,\n closePhoneNumberDialog,\n savePhoneNumber,\n verifyPhoneNumber,\n resendPhoneNumberVerificationCode,\n } = useMfa()\n\n const isPhoneVerificationRequired = phoneVerificationCodeSentAt !== undefined\n\n const [phoneNumber, setPhoneNumber] = React.useState('')\n const [verificationCode, setVerificationCode] = React.useState('')\n const resendCoolDownSeconds = usePhoneVerificationResendCoolDown(\n phoneVerificationCodeSentAt,\n )\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n const [isResending, startResending, stopResending] = useBooleanState(false)\n\n React.useEffect(() => {\n if (isPhoneNumberDialogOpen) {\n setPhoneNumber(mfaSettings.sms.phoneNumber || '')\n setVerificationCode('')\n }\n }, [isPhoneNumberDialogOpen, mfaSettings.sms.phoneNumber])\n\n const handleSavePhoneNumber = React.useCallback(async () => {\n startSaving()\n try {\n await savePhoneNumber(phoneNumber)\n } finally {\n stopSaving()\n }\n }, [phoneNumber, savePhoneNumber, startSaving, stopSaving])\n\n const handleVerifyPhoneNumber = React.useCallback(async () => {\n startSaving()\n try {\n await verifyPhoneNumber(verificationCode)\n } finally {\n stopSaving()\n }\n }, [verificationCode, verifyPhoneNumber, startSaving, stopSaving])\n\n const handleSubmit = React.useCallback(\n (event: React.SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n if (isSaving) {\n return\n }\n\n if (isPhoneVerificationRequired) {\n if (!verificationCode) {\n return\n }\n\n void handleVerifyPhoneNumber()\n return\n }\n\n if (!phoneNumber) {\n return\n }\n\n void handleSavePhoneNumber()\n },\n [\n handleSavePhoneNumber,\n handleVerifyPhoneNumber,\n isPhoneVerificationRequired,\n isSaving,\n phoneNumber,\n verificationCode,\n ],\n )\n\n const handleResendVerificationCode = React.useCallback(async () => {\n startResending()\n try {\n await resendPhoneNumberVerificationCode()\n } finally {\n stopResending()\n }\n }, [resendPhoneNumberVerificationCode, startResending, stopResending])\n\n return (\n <Dialog\n open={isPhoneNumberDialogOpen}\n onClose={() => {\n if (!isSaving) {\n closePhoneNumberDialog()\n }\n }}\n fullWidth\n maxWidth=\"sm\"\n >\n <form onSubmit={handleSubmit}>\n <DialogTitle>\n {isPhoneVerificationRequired\n ? 'Verify Phone Number'\n : 'Save Phone Number'}\n </DialogTitle>\n <DialogContent dividers>\n {isPhoneVerificationRequired ? (\n <>\n <Typography variant=\"body2\" paragraph>\n Enter the verification code sent to {phoneNumber}.\n </Typography>\n <InputField\n key=\"verification-code\"\n autoFocus\n margin=\"none\"\n name=\"verificationCode\"\n label=\"Verification Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={verificationCode}\n onChange={(event) => {\n setVerificationCode(event.target.value)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-phone-verification-code\"\n />\n <Box marginTop={1}>\n <Button\n type=\"button\"\n variant=\"text\"\n size=\"small\"\n disabled={\n resendCoolDownSeconds > 0 || isSaving || isResending\n }\n onClick={handleResendVerificationCode}\n data-cypress=\"mfa-phone-resend-button\"\n >\n {resendCoolDownSeconds > 0\n ? `Send again (${resendCoolDownSeconds}s)`\n : 'Send again'}\n </Button>\n </Box>\n </>\n ) : (\n <>\n <Typography variant=\"body2\" paragraph>\n Enter your phone number to receive SMS verification codes when\n signing in.\n </Typography>\n <InputField\n key=\"phone-number\"\n autoFocus\n margin=\"none\"\n name=\"phoneNumber\"\n label=\"Phone Number\"\n fullWidth\n placeholder=\"+61400000000\"\n variant=\"outlined\"\n value={phoneNumber}\n onChange={(event) => {\n setPhoneNumber(event.target.value)\n }}\n disabled={isSaving}\n helperText=\"Include your country code, for example +61400000000.\"\n data-cypress=\"mfa-phone-number\"\n />\n </>\n )}\n </DialogContent>\n <DialogActions>\n <Button\n type=\"button\"\n onClick={closePhoneNumberDialog}\n disabled={isSaving}\n >\n Cancel\n </Button>\n {isPhoneVerificationRequired ? (\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!verificationCode || isSaving}\n data-cypress=\"mfa-phone-verify-button\"\n >\n Verify\n </Button>\n ) : (\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!phoneNumber || isSaving}\n data-cypress=\"mfa-phone-save-button\"\n >\n Save\n </Button>\n )}\n </DialogActions>\n </form>\n </Dialog>\n )\n}\n\n/**\n * React Component that lets users enter and verify a phone number for SMS MFA.\n * Typically rendered by `<MultiFactorAuthentication />` within an `<MfaProvider\n * />` tree.\n *\n * @returns\n */\nexport default React.memo(MfaPhoneNumberDialog)\n"]}
|
|
1
|
+
{"version":3,"file":"MfaPhoneNumberDialog.js","sourceRoot":"","sources":["../../../src/components/mfa/MfaPhoneNumberDialog.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,EACL,MAAM,EACN,aAAa,EACb,aAAa,EACb,WAAW,EACX,MAAM,EACN,UAAU,EACV,GAAG,GACJ,MAAM,eAAe,CAAA;AACtB,OAAO,eAAe,MAAM,6BAA6B,CAAA;AACzD,OAAO,MAAM,MAAM,oBAAoB,CAAA;AACvC,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,MAAM,2CAA2C,GAAG,EAAE,CAAA;AAEtD,SAAS,iCAAiC,CACxC,MAA0B,EAC1B,GAAW;IAEX,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,CAAA;IACV,CAAC;IAED,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,C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QAAQ,uBAGX,EACR,2BAA2B,CAAC,CAAC,CAAC,CAC7B,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,CAAC,gBAAgB,IAAI,QAAQ,kBAC1B,yBAAyB,uBAG/B,CACV,CAAC,CAAC,CAAC,CACF,KAAC,MAAM,IACL,IAAI,EAAC,QAAQ,EACb,OAAO,EAAC,WAAW,EACnB,QAAQ,EAAE,CAAC,WAAW,IAAI,QAAQ,kBACrB,uBAAuB,qBAG7B,CACV,IACa,IACX,GACA,CACV,CAAA;AACH,CAAC;AAED;;;;;;GAMG;AACH,eAAe,KAAK,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAA","sourcesContent":["import * as React from 'react'\nimport {\n Dialog,\n DialogActions,\n DialogContent,\n DialogTitle,\n Button,\n Typography,\n Box,\n} from '@mui/material'\nimport useBooleanState from '../../hooks/useBooleanState'\nimport useMfa from '../../hooks/useMfa'\nimport InputField from '../InputField'\n\nconst PHONE_VERIFICATION_RESEND_COOL_DOWN_SECONDS = 60\n\nfunction getResendCoolDownRemainingSeconds(\n sentAt: number | undefined,\n now: number,\n) {\n if (!sentAt) {\n return 0\n }\n\n const elapsedSeconds = Math.max(0, Math.floor((now - sentAt) / 1000))\n return Math.max(\n 0,\n PHONE_VERIFICATION_RESEND_COOL_DOWN_SECONDS - elapsedSeconds,\n )\n}\n\nfunction usePhoneVerificationResendCoolDown(sentAt: number | undefined) {\n const [now, setNow] = React.useState(() => Date.now())\n\n const remainingSeconds = getResendCoolDownRemainingSeconds(sentAt, now)\n\n React.useEffect(() => {\n if (!sentAt) {\n return\n }\n\n setNow(Date.now())\n\n const intervalId = window.setInterval(() => {\n setNow(Date.now())\n }, 1000)\n\n return () => window.clearInterval(intervalId)\n }, [sentAt])\n\n return remainingSeconds\n}\n\nfunction MfaPhoneNumberDialog() {\n const {\n isPhoneNumberDialogOpen,\n mfaSettings,\n phoneVerificationCodeSentAt,\n closePhoneNumberDialog,\n savePhoneNumber,\n verifyPhoneNumber,\n } = useMfa()\n\n const isPhoneVerificationRequired = phoneVerificationCodeSentAt !== undefined\n\n const [phoneNumber, setPhoneNumber] = React.useState('')\n const [verificationCode, setVerificationCode] = React.useState('')\n const resendCoolDownSeconds = usePhoneVerificationResendCoolDown(\n phoneVerificationCodeSentAt,\n )\n const [isSaving, startSaving, stopSaving] = useBooleanState(false)\n\n React.useEffect(() => {\n if (isPhoneNumberDialogOpen) {\n setPhoneNumber(mfaSettings.sms.phoneNumber || '')\n setVerificationCode('')\n }\n }, [isPhoneNumberDialogOpen, mfaSettings.sms.phoneNumber])\n\n const handleSavePhoneNumber = React.useCallback(async () => {\n startSaving()\n try {\n await savePhoneNumber(phoneNumber)\n } finally {\n stopSaving()\n }\n }, [phoneNumber, savePhoneNumber, startSaving, stopSaving])\n\n const handleVerifyPhoneNumber = React.useCallback(async () => {\n startSaving()\n try {\n await verifyPhoneNumber(verificationCode)\n } finally {\n stopSaving()\n }\n }, [verificationCode, verifyPhoneNumber, startSaving, stopSaving])\n\n const handleSubmit = React.useCallback(\n (event: React.SubmitEvent<HTMLFormElement>) => {\n event.preventDefault()\n\n if (isSaving) {\n return\n }\n\n if (isPhoneVerificationRequired) {\n if (!verificationCode) {\n return\n }\n\n void handleVerifyPhoneNumber()\n return\n }\n\n if (!phoneNumber) {\n return\n }\n\n void handleSavePhoneNumber()\n },\n [\n handleSavePhoneNumber,\n handleVerifyPhoneNumber,\n isPhoneVerificationRequired,\n isSaving,\n phoneNumber,\n verificationCode,\n ],\n )\n\n const handleResendVerificationCode = React.useCallback(async () => {\n startSaving()\n try {\n await savePhoneNumber(phoneNumber)\n } finally {\n stopSaving()\n }\n }, [phoneNumber, savePhoneNumber, startSaving, stopSaving])\n\n return (\n <Dialog\n open={isPhoneNumberDialogOpen}\n onClose={() => {\n if (!isSaving) {\n closePhoneNumberDialog()\n }\n }}\n fullWidth\n maxWidth=\"sm\"\n >\n <form onSubmit={handleSubmit}>\n <DialogTitle>\n {isPhoneVerificationRequired\n ? 'Verify Phone Number'\n : 'Save Phone Number'}\n </DialogTitle>\n <DialogContent dividers>\n {isPhoneVerificationRequired ? (\n <>\n <Typography variant=\"body2\" paragraph>\n Enter the verification code sent to {phoneNumber}.\n </Typography>\n <InputField\n key=\"verification-code\"\n autoFocus\n margin=\"none\"\n name=\"verificationCode\"\n label=\"Verification Code\"\n fullWidth\n placeholder=\"XXXXXX\"\n variant=\"outlined\"\n value={verificationCode}\n onChange={(event) => {\n setVerificationCode(event.target.value)\n }}\n disabled={isSaving}\n data-cypress=\"mfa-phone-verification-code\"\n />\n <Box marginTop={1}>\n <Button\n type=\"button\"\n variant=\"text\"\n size=\"small\"\n sx={{ textTransform: 'none' }}\n disabled={resendCoolDownSeconds > 0 || isSaving}\n onClick={handleResendVerificationCode}\n data-cypress=\"mfa-phone-resend-button\"\n >\n {resendCoolDownSeconds > 0\n ? `Send Again (${resendCoolDownSeconds}s)`\n : 'Send Again'}\n </Button>\n </Box>\n </>\n ) : (\n <>\n <Typography variant=\"body2\" paragraph>\n Enter your phone number to receive SMS verification codes when\n signing in.\n </Typography>\n <InputField\n key=\"phone-number\"\n autoFocus\n margin=\"none\"\n name=\"phoneNumber\"\n label=\"Phone Number\"\n fullWidth\n placeholder=\"+61400000000\"\n variant=\"outlined\"\n value={phoneNumber}\n onChange={(event) => {\n setPhoneNumber(event.target.value)\n }}\n disabled={isSaving}\n helperText=\"Include your country code, for example +61400000000.\"\n data-cypress=\"mfa-phone-number\"\n />\n </>\n )}\n </DialogContent>\n <DialogActions>\n <Button\n type=\"button\"\n onClick={closePhoneNumberDialog}\n disabled={isSaving}\n >\n Cancel\n </Button>\n {isPhoneVerificationRequired ? (\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!verificationCode || isSaving}\n data-cypress=\"mfa-phone-verify-button\"\n >\n Verify\n </Button>\n ) : (\n <Button\n type=\"submit\"\n variant=\"contained\"\n disabled={!phoneNumber || isSaving}\n data-cypress=\"mfa-phone-save-button\"\n >\n Save\n </Button>\n )}\n </DialogActions>\n </form>\n </Dialog>\n )\n}\n\n/**\n * React Component that lets users enter and verify a phone number for SMS MFA.\n * Typically rendered by `<MultiFactorAuthentication />` within an `<MfaProvider\n * />` tree.\n *\n * @returns\n */\nexport default React.memo(MfaPhoneNumberDialog)\n"]}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { MiscTypes } from '@oneblink/types';
|
|
1
2
|
type Props = {
|
|
2
|
-
|
|
3
|
+
mfaRequirement: MiscTypes.MfaRequirement | undefined;
|
|
4
|
+
ssoSetupUrl?: string;
|
|
3
5
|
};
|
|
4
6
|
/**
|
|
5
7
|
* React Component that provides a mechanism for app users to configure Multi
|
|
@@ -16,26 +18,25 @@ type Props = {
|
|
|
16
18
|
* } from '@oneblink/apps-react'
|
|
17
19
|
*
|
|
18
20
|
* function Component() {
|
|
19
|
-
* return <MultiFactorAuthentication />
|
|
21
|
+
* return <MultiFactorAuthentication mfaRequirement={undefined} />
|
|
20
22
|
* }
|
|
21
23
|
*
|
|
22
|
-
* function
|
|
24
|
+
* function AppWithMfaRequirement({ mfaRequirement }) {
|
|
23
25
|
* return (
|
|
24
26
|
* <MfaProvider>
|
|
25
|
-
* <
|
|
27
|
+
* <MultiFactorAuthentication mfaRequirement={mfaRequirement} />
|
|
26
28
|
* </MfaProvider>
|
|
27
29
|
* )
|
|
28
30
|
* }
|
|
29
|
-
*
|
|
30
|
-
* const root = document.getElementById('root')
|
|
31
|
-
* if (root) {
|
|
32
|
-
* ReactDOM.render(<App />, root)
|
|
33
|
-
* }
|
|
34
31
|
* ```
|
|
35
32
|
*
|
|
36
33
|
* @param props
|
|
34
|
+
* @param props.mfaRequirement - The MFA methods allowed by your administrator
|
|
35
|
+
* for using this app. Pass `undefined` when the app has no MFA requirement.
|
|
36
|
+
* Users can still enable other methods, but will be warned when their
|
|
37
|
+
* configuration does not meet this requirement.
|
|
37
38
|
* @returns
|
|
38
39
|
* @group Components
|
|
39
40
|
*/
|
|
40
|
-
export default function MultiFactorAuthentication({ ssoSetupUrl }: Props): import("react/jsx-runtime").JSX.Element;
|
|
41
|
+
export default function MultiFactorAuthentication({ mfaRequirement, ssoSetupUrl, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
41
42
|
export {};
|