@antelopejs/auth-jwt
Version:
Authentication and authorization module that implements the Auth interface of antelopejs with JWT
28 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AttachAuthDecorator = exports.Sign = exports.Verify = void 0;
const index_1 = require("../../index");
const dev_1 = require("@ajs/api/dev");
const dev_2 = require("@ajs.local/auth/dev");
const Verify = (data, options) => {
return (0, index_1.getJWTHandler)().verify(data, options);
};
exports.Verify = Verify;
const Sign = (data, options) => {
return (0, index_1.getJWTHandler)().sign(data, options);
};
exports.Sign = Sign;
const AttachAuthDecorator = (target, key, index, callbacks, validator) => {
const source = callbacks.source || dev_2.defaultSource;
const authenticator = callbacks.authenticator || dev_2.defaultAuthenticator;
const authenticatorOptions = callbacks.authenticatorOptions || {};
const defaultValidator = callbacks.validator;
if (typeof index === 'object' || key === undefined) {
(0, dev_1.SetParameterProvider)(target, Symbol(''), undefined, (context) => (0, dev_2.CheckAuthentication)(context.rawRequest, context.rawResponse, source, authenticator, authenticatorOptions, validator || defaultValidator));
}
else {
(0, dev_1.SetParameterProvider)(target, key, index, (context) => (0, dev_2.CheckAuthentication)(context.rawRequest, context.rawResponse, source, authenticator, authenticatorOptions, validator || defaultValidator));
}
};
exports.AttachAuthDecorator = AttachAuthDecorator;
//# sourceMappingURL=dev.js.map