1 | "use strict";
|
2 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3 | if (k2 === undefined) k2 = k;
|
4 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
5 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6 | desc = { enumerable: true, get: function() { return m[k]; } };
|
7 | }
|
8 | Object.defineProperty(o, k2, desc);
|
9 | }) : (function(o, m, k, k2) {
|
10 | if (k2 === undefined) k2 = k;
|
11 | o[k2] = m[k];
|
12 | }));
|
13 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15 | }) : function(o, v) {
|
16 | o["default"] = v;
|
17 | });
|
18 | var __importStar = (this && this.__importStar) || function (mod) {
|
19 | if (mod && mod.__esModule) return mod;
|
20 | var result = {};
|
21 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
22 | __setModuleDefault(result, mod);
|
23 | return result;
|
24 | };
|
25 | Object.defineProperty(exports, "__esModule", { value: true });
|
26 | exports.defaults = exports.defaultStorage = exports.hooks = exports.MemoryStorage = exports.AuthenticationClient = exports.getDefaultStorage = void 0;
|
27 | const core_1 = require("./core");
|
28 | Object.defineProperty(exports, "AuthenticationClient", { enumerable: true, get: function () { return core_1.AuthenticationClient; } });
|
29 | const hooks = __importStar(require("./hooks"));
|
30 | exports.hooks = hooks;
|
31 | const storage_1 = require("./storage");
|
32 | Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function () { return storage_1.MemoryStorage; } });
|
33 | const getDefaultStorage = () => {
|
34 | try {
|
35 | return new storage_1.StorageWrapper(window.localStorage);
|
36 | }
|
37 | catch (error) { }
|
38 | return new storage_1.MemoryStorage();
|
39 | };
|
40 | exports.getDefaultStorage = getDefaultStorage;
|
41 | exports.defaultStorage = (0, exports.getDefaultStorage)();
|
42 | exports.defaults = {
|
43 | header: 'Authorization',
|
44 | scheme: 'Bearer',
|
45 | storageKey: 'feathers-jwt',
|
46 | locationKey: 'access_token',
|
47 | locationErrorKey: 'error',
|
48 | jwtStrategy: 'jwt',
|
49 | path: '/authentication',
|
50 | Authentication: core_1.AuthenticationClient,
|
51 | storage: exports.defaultStorage
|
52 | };
|
53 | const init = (_options = {}) => {
|
54 | const options = Object.assign({}, exports.defaults, _options);
|
55 | const { Authentication } = options;
|
56 | return (app) => {
|
57 | const authentication = new Authentication(app, options);
|
58 | app.authentication = authentication;
|
59 | app.authenticate = authentication.authenticate.bind(authentication);
|
60 | app.reAuthenticate = authentication.reAuthenticate.bind(authentication);
|
61 | app.logout = authentication.logout.bind(authentication);
|
62 | app.hooks([hooks.authentication(), hooks.populateHeader()]);
|
63 | };
|
64 | };
|
65 | exports.default = init;
|
66 | if (typeof module !== 'undefined') {
|
67 | module.exports = Object.assign(init, module.exports);
|
68 | }
|
69 |
|
\ | No newline at end of file |