diffusion
Version:
Diffusion JavaScript client
75 lines (74 loc) • 3.53 kB
JavaScript
;
/**
* @module Services.Authentication
*/
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.SessionPropertyValidationSerialiser = exports.SessionPropertyValidationSerialiserClass = void 0;
var matches_property_validation_1 = require("./../../features/security/matches-property-validation");
var values_property_validation_1 = require("./../../features/security/values-property-validation");
var Codec = require("./../../io/codec");
var BEES = require("./../../serialisers/byte-encoded-enum-serialiser");
var serialiser_1 = require("./../../serialisers/serialiser");
var security_1 = require("../../../features/security");
/**
* Serialiser for {@link SessionPropertyValidation}
*/
var SessionPropertyValidationSerialiserClass = /** @class */ (function (_super) {
__extends(SessionPropertyValidationSerialiserClass, _super);
function SessionPropertyValidationSerialiserClass() {
return _super !== null && _super.apply(this, arguments) || this;
}
/**
* Read a {@link SessionPropertyValidation} from the stream
*
* @param bis the input stream
* @return the {@link SessionPropertyValidation} that was read
*/
SessionPropertyValidationSerialiserClass.prototype.read = function (bis) {
var type = BEES.read(bis, security_1.ValidationType);
if (type === security_1.ValidationType.REGEX) {
return new matches_property_validation_1.MatchesSessionPropertyValidationImpl(Codec.readString(bis));
}
var values = Codec.readCollection(bis, Codec.readString);
return new values_property_validation_1.ValuesSessionPropertyValidationImpl(values);
};
/**
* Write a {@link SessionPropertyValidation} to the stream
*
* @param bis the input stream
* @param value the {@link SessionPropertyValidation} to be written
*/
SessionPropertyValidationSerialiserClass.prototype.write = function (bos, value) {
var type = value.type;
Codec.writeByte(bos, type);
if (type === security_1.ValidationType.REGEX) {
var regexValidation = value;
Codec.writeString(bos, regexValidation.regex);
}
else {
var valuesValidation = value;
Codec.writeCollection(bos, valuesValidation.values, Codec.writeString);
}
};
return SessionPropertyValidationSerialiserClass;
}(serialiser_1.AbstractSerialiser));
exports.SessionPropertyValidationSerialiserClass = SessionPropertyValidationSerialiserClass;
/**
* The {@link SessionPropertyValidationSerialiser} singleton
*/ // eslint-disable-next-line @typescript-eslint/naming-convention
exports.SessionPropertyValidationSerialiser = new SessionPropertyValidationSerialiserClass();