@mercury-labs/nest-auth
Version:
Mercury framework auth library. It supports local auth, jwt with both bearer token and cookie, basic auth.
62 lines • 2.61 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var HashingModule_1;
Object.defineProperty(exports, "__esModule", { value: true });
exports.HashingModule = void 0;
const common_1 = require("@nestjs/common");
const index_1 = require("./index");
const HASHING_MODULE_OPTIONS = Symbol('HASHING_MODULE_OPTIONS');
let HashingModule = exports.HashingModule = HashingModule_1 = class HashingModule {
static forRoot(options) {
const { enabled = true } = options;
return {
module: HashingModule_1,
providers: [
{
provide: index_1.HashTextService,
useValue: enabled
? new index_1.HashTextService({ ...options, enabled })
: new index_1.NoHashTextService(),
},
],
exports: [index_1.HashTextService],
global: options.global || false,
};
}
static forRootAsync(options) {
const hashModuleProvider = {
provide: HASHING_MODULE_OPTIONS,
useFactory: options.useFactory,
inject: options.inject || [],
};
const hashTextProvider = {
provide: index_1.HashTextService,
useFactory: (options) => {
const { enabled = true } = options;
return enabled
? new index_1.HashTextService({
...options,
enabled,
})
: new index_1.NoHashTextService();
},
inject: [HASHING_MODULE_OPTIONS],
};
return {
module: HashingModule_1,
imports: [...(options.imports || [])],
providers: [hashModuleProvider, hashTextProvider],
exports: [index_1.HashTextService],
global: options.global || false,
};
}
};
exports.HashingModule = HashingModule = HashingModule_1 = __decorate([
(0, common_1.Module)({})
], HashingModule);
//# sourceMappingURL=hashing.module.js.map
;