@microsoft/useragent-sdk
Version:
SDK for building decentralized identity wallets and enterprise agents.
46 lines • 1.81 kB
JavaScript
;
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
const ServiceEndpoint_1 = require("./ServiceEndpoint");
const cloneDeep = require('lodash/fp/cloneDeep');
const type = 'HostServiceEndpoint';
/**
* class to represent a host service endpoint.
*/
class HostServiceEndpoint extends ServiceEndpoint_1.default {
constructor(context, locations) {
super(context, type);
this.locations = locations;
}
/**
* Used to control the the properties that are
* output by JSON.stringify.
*/
toJSON() {
// Clone the current instance. Note the use of
// a deep clone to ensure immutability of
// the instance being cloned for serialization
const clonedServiceReference = cloneDeep(this);
if (this.context) {
clonedServiceReference['@context'] = this.context;
delete clonedServiceReference.context;
}
if (this.type) {
clonedServiceReference['@type'] = this.type;
delete clonedServiceReference.type;
}
return clonedServiceReference;
}
/**
* Used to control the the properties that are
* output by JSON.parse.
*/
static fromJSON(object) {
return new HostServiceEndpoint(object['@context'], object['locations']);
}
}
exports.default = HostServiceEndpoint;
//# sourceMappingURL=HostServiceEndpoint.js.map