-
Notifications
You must be signed in to change notification settings - Fork 46
/
password-callback.ts
54 lines (47 loc) · 1.19 KB
/
password-callback.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
* @forgerock/javascript-sdk
*
* password-callback.ts
*
* Copyright (c) 2020 ForgeRock. All rights reserved.
* This software may be modified and distributed under the terms
* of the MIT license. See the LICENSE file for details.
*/
import FRCallback from '.';
import type { Callback, PolicyRequirement } from '../../auth/interfaces';
/**
* Represents a callback used to collect a password.
*/
class PasswordCallback extends FRCallback {
/**
* @param payload The raw payload returned by OpenAM
*/
constructor(public payload: Callback) {
super(payload);
}
/**
* Gets the callback's failed policies.
*/
public getFailedPolicies(): PolicyRequirement[] {
return this.getOutputByName<PolicyRequirement[]>('failedPolicies', []);
}
/**
* Gets the callback's applicable policies.
*/
public getPolicies(): string[] {
return this.getOutputByName<string[]>('policies', []);
}
/**
* Gets the callback's prompt.
*/
public getPrompt(): string {
return this.getOutputByName<string>('prompt', '');
}
/**
* Sets the password.
*/
public setPassword(password: string): void {
this.setInputValue(password);
}
}
export default PasswordCallback;