/
device-profile-callback.ts
55 lines (48 loc) · 1.26 KB
/
device-profile-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
55
/*
* @forgerock/javascript-sdk
*
* device-profile-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 } from '../../auth/interfaces';
import type { DeviceProfileData } from '../../fr-device/interfaces';
/**
* Represents a callback used to collect device profile data.
*/
class DeviceProfileCallback extends FRCallback {
/**
* @param payload The raw payload returned by OpenAM
*/
constructor(public payload: Callback) {
super(payload);
}
/**
* Gets the callback's data.
*/
public getMessage(): string {
return this.getOutputByName<string>('message', '');
}
/**
* Does callback require metadata?
*/
public isMetadataRequired(): boolean {
return this.getOutputByName<boolean>('metadata', false);
}
/**
* Does callback require location data?
*/
public isLocationRequired(): boolean {
return this.getOutputByName<boolean>('location', false);
}
/**
* Sets the profile.
*/
public setProfile(profile: DeviceProfileData): void {
this.setInputValue(JSON.stringify(profile));
}
}
export default DeviceProfileCallback;