UNPKG

diffusion

Version:

Diffusion JavaScript client

34 lines (26 loc) 826 B
var TypeCode = { DENY : 0, ABSTAIN : 1, ALLOW : 2, ALLOW_WITH_RESULT : 3 }; function AuthenticationResult(result) { var roles = result.roles || []; var properties = result.properties || {}; return { roles : roles, properties : properties }; } function AuthenticationResponse(typecode, result) { this.type = typecode; this.result = result; } module.exports = AuthenticationResponse; module.exports.allow = function(result) { return new AuthenticationResponse(TypeCode.ALLOW_WITH_RESULT, AuthenticationResult(result)); }; module.exports.TypeCode = TypeCode; module.exports.DENY = new AuthenticationResponse(TypeCode.DENY); module.exports.ALLOW = new AuthenticationResponse(TypeCode.ALLOW); module.exports.ABSTAIN = new AuthenticationResponse(TypeCode.ABSTAIN);