Commit de337d9c authored by Jukkrapong Ponharn's avatar Jukkrapong Ponharn

Enhance PolicyRequest class to include clientType property and methods for...

Enhance PolicyRequest class to include clientType property and methods for getting and setting client type
parent 9464eaa4
......@@ -18,6 +18,11 @@ export enum HttpMethod {
DELETE = 'DELETE',
}
export enum ClientType {
WEB = 'WEB',
NATIVE = 'NATIVE',
}
/**
* Resource Structure
*/
......@@ -124,6 +129,7 @@ function base64DecodeUtf8(b64: string): string {
export interface PolicyRequestInstanceConfig {
subject: Subject;
clientName: string;
clientType?: ClientType
ipVerify?: boolean;
}
......@@ -133,6 +139,7 @@ export interface PolicyRequestInstanceConfig {
export class PolicyRequest {
private subject: Subject;
private clientName: string;
private clientType: string;
private ipVerify: boolean;
/**
......@@ -142,6 +149,7 @@ export class PolicyRequest {
constructor(config: PolicyRequestInstanceConfig) {
this.subject = config.subject;
this.clientName = config.clientName;
this.clientType = config.clientType ?? ClientType.WEB as string
this.ipVerify = config.ipVerify ?? false;
}
......@@ -159,6 +167,21 @@ export class PolicyRequest {
return this.clientName;
}
/**
* Get client type
*/
getClientType(): string {
return this.clientType;
}
/**
* Set client type
* @param clientType - client type
*/
setClirntType(clientType: string): void {
this.clientType = clientType;
}
/**
* Get IP Verify
*/
......@@ -190,7 +213,7 @@ export class PolicyRequest {
async create(config: Omit<PolicyConfig, 'subject'> = {}): Promise<string> {
let environment: Environment = {
"resource": {
"type": "WEB",
"type": this.clientType,
"name": this.clientName,
"timestamp": new Date(),
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment