68 lines
1.3 KiB
TypeScript
68 lines
1.3 KiB
TypeScript
import { Jsonify } from "type-fest";
|
|
|
|
import { UriMatchType } from "../../enums/uriMatchType";
|
|
import { LoginUriData } from "../data/login-uri.data";
|
|
import { LoginUriView } from "../view/login-uri.view";
|
|
|
|
import Domain from "./domain-base";
|
|
import { EncString } from "./enc-string";
|
|
import { SymmetricCryptoKey } from "./symmetric-crypto-key";
|
|
|
|
export class LoginUri extends Domain {
|
|
uri: EncString;
|
|
match: UriMatchType;
|
|
|
|
constructor(obj?: LoginUriData) {
|
|
super();
|
|
if (obj == null) {
|
|
return;
|
|
}
|
|
|
|
this.match = obj.match;
|
|
this.buildDomainModel(
|
|
this,
|
|
obj,
|
|
{
|
|
uri: null,
|
|
},
|
|
[]
|
|
);
|
|
}
|
|
|
|
decrypt(orgId: string, encKey?: SymmetricCryptoKey): Promise<LoginUriView> {
|
|
return this.decryptObj(
|
|
new LoginUriView(this),
|
|
{
|
|
uri: null,
|
|
},
|
|
orgId,
|
|
encKey
|
|
);
|
|
}
|
|
|
|
toLoginUriData(): LoginUriData {
|
|
const u = new LoginUriData();
|
|
this.buildDataModel(
|
|
this,
|
|
u,
|
|
{
|
|
uri: null,
|
|
match: null,
|
|
},
|
|
["match"]
|
|
);
|
|
return u;
|
|
}
|
|
|
|
static fromJSON(obj: Jsonify<LoginUri>): LoginUri {
|
|
if (obj == null) {
|
|
return null;
|
|
}
|
|
|
|
const uri = EncString.fromJSON(obj.uri);
|
|
return Object.assign(new LoginUri(), obj, {
|
|
uri,
|
|
});
|
|
}
|
|
}
|