Skip to content

Commit 8b4656c

Browse files
committed
feat(javascript-sdk): recaptcha-enterprise
initial setup for recaptcha enterprise callback
1 parent 6893d3b commit 8b4656c

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

packages/javascript-sdk/src/auth/enums.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ enum CallbackType {
3636
PingOneProtectInitializeCallback = 'PingOneProtectInitializeCallback',
3737
PollingWaitCallback = 'PollingWaitCallback',
3838
ReCaptchaCallback = 'ReCaptchaCallback',
39+
ReCaptchaEnterpriseCallback = 'ReCaptchaEnterpriseCallback ',
3940
RedirectCallback = 'RedirectCallback',
4041
SelectIdPCallback = 'SelectIdPCallback',
4142
StringAttributeInputCallback = 'StringAttributeInputCallback',

packages/javascript-sdk/src/fr-auth/callbacks/factory.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import PingOneProtectEvaluationCallback from './ping-protect-evaluation-callback
2424
import PingOneProtectInitializeCallback from './ping-protect-initialize-callback';
2525
import PollingWaitCallback from './polling-wait-callback';
2626
import ReCaptchaCallback from './recaptcha-callback';
27+
import ReCaptchaEnterpriseCallback from './recaptcha-enterprise-callback';
2728
import RedirectCallback from './redirect-callback';
2829
import SelectIdPCallback from './select-idp-callback';
2930
import SuspendedTextOutputCallback from './suspended-text-output-callback';
@@ -68,6 +69,8 @@ function createCallback(callback: Callback): FRCallback {
6869
return new PollingWaitCallback(callback);
6970
case CallbackType.ReCaptchaCallback:
7071
return new ReCaptchaCallback(callback);
72+
case CallbackType.ReCaptchaEnterpriseCallback:
73+
return new ReCaptchaEnterpriseCallback(callback);
7174
case CallbackType.RedirectCallback:
7275
return new RedirectCallback(callback);
7376
case CallbackType.SelectIdPCallback:
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* @forgerock/javascript-sdk
3+
*
4+
* recaptcha-callback.ts
5+
*
6+
* Copyright (c) 2020 ForgeRock. All rights reserved.
7+
* This software may be modified and distributed under the terms
8+
* of the MIT license. See the LICENSE file for details.
9+
*/
10+
11+
import FRCallback from '.';
12+
import type { Callback } from '../../auth/interfaces';
13+
14+
/**
15+
* Represents a callback used to integrate reCAPTCHA.
16+
*/
17+
class ReCaptchaEnterpriseCallback extends FRCallback {
18+
/**
19+
* @param payload The raw payload returned by OpenAM
20+
*/
21+
constructor(public payload: Callback) {
22+
super(payload);
23+
}
24+
25+
/**
26+
* Gets the reCAPTCHA site key.
27+
*/
28+
public getSiteKey(): string {
29+
return this.getOutputByName<string>('recaptchaSiteKey', '');
30+
}
31+
32+
/**
33+
* Sets the reCAPTCHA result.
34+
*/
35+
public setResult(result: string): void {
36+
this.setInputValue(result);
37+
}
38+
}
39+
40+
export default ReCaptchaEnterpriseCallback;

0 commit comments

Comments
 (0)