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 { ...@@ -18,6 +18,11 @@ export enum HttpMethod {
DELETE = 'DELETE', DELETE = 'DELETE',
} }
export enum ClientType {
WEB = 'WEB',
NATIVE = 'NATIVE',
}
/** /**
* Resource Structure * Resource Structure
*/ */
...@@ -124,6 +129,7 @@ function base64DecodeUtf8(b64: string): string { ...@@ -124,6 +129,7 @@ function base64DecodeUtf8(b64: string): string {
export interface PolicyRequestInstanceConfig { export interface PolicyRequestInstanceConfig {
subject: Subject; subject: Subject;
clientName: string; clientName: string;
clientType?: ClientType
ipVerify?: boolean; ipVerify?: boolean;
} }
...@@ -133,6 +139,7 @@ export interface PolicyRequestInstanceConfig { ...@@ -133,6 +139,7 @@ export interface PolicyRequestInstanceConfig {
export class PolicyRequest { export class PolicyRequest {
private subject: Subject; private subject: Subject;
private clientName: string; private clientName: string;
private clientType: string;
private ipVerify: boolean; private ipVerify: boolean;
/** /**
...@@ -142,6 +149,7 @@ export class PolicyRequest { ...@@ -142,6 +149,7 @@ export class PolicyRequest {
constructor(config: PolicyRequestInstanceConfig) { constructor(config: PolicyRequestInstanceConfig) {
this.subject = config.subject; this.subject = config.subject;
this.clientName = config.clientName; this.clientName = config.clientName;
this.clientType = config.clientType ?? ClientType.WEB as string
this.ipVerify = config.ipVerify ?? false; this.ipVerify = config.ipVerify ?? false;
} }
...@@ -159,6 +167,21 @@ export class PolicyRequest { ...@@ -159,6 +167,21 @@ export class PolicyRequest {
return this.clientName; 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 * Get IP Verify
*/ */
...@@ -190,7 +213,7 @@ export class PolicyRequest { ...@@ -190,7 +213,7 @@ export class PolicyRequest {
async create(config: Omit<PolicyConfig, 'subject'> = {}): Promise<string> { async create(config: Omit<PolicyConfig, 'subject'> = {}): Promise<string> {
let environment: Environment = { let environment: Environment = {
"resource": { "resource": {
"type": "WEB", "type": this.clientType,
"name": this.clientName, "name": this.clientName,
"timestamp": new Date(), "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