@powfix/core-js 0.14.2 → 0.14.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { AxiosInstance } from "axios";
|
|
2
2
|
import { StorageProvider } from "../interfaces/StorageProvider";
|
|
3
|
-
import
|
|
4
|
-
export declare class SessionService {
|
|
3
|
+
import EventEmitter from 'eventemitter3';
|
|
4
|
+
export declare class SessionService extends EventEmitter<SessionService.Event> {
|
|
5
5
|
private static readonly DEFAULT_AUTHORIZATION_STORAGE_KEY;
|
|
6
6
|
protected api: AxiosInstance;
|
|
7
7
|
protected storageProvider: StorageProvider;
|
|
8
|
-
private emitter;
|
|
9
|
-
readonly on: <T extends "AUTHORIZATION_CHANGED">(event: T, fn: (...args: EventEmitter3.ArgumentMap<SessionService.Event>[Extract<T, "AUTHORIZATION_CHANGED">]) => void, context?: any) => EventEmitter3<SessionService.Event, any>;
|
|
10
|
-
readonly off: <T extends "AUTHORIZATION_CHANGED">(event: T, fn?: ((...args: EventEmitter3.ArgumentMap<SessionService.Event>[Extract<T, "AUTHORIZATION_CHANGED">]) => void) | undefined, context?: any, once?: boolean) => EventEmitter3<SessionService.Event, any>;
|
|
11
|
-
protected readonly emit: <T extends "AUTHORIZATION_CHANGED">(event: T, ...args: EventEmitter3.ArgumentMap<SessionService.Event>[Extract<T, "AUTHORIZATION_CHANGED">]) => boolean;
|
|
12
8
|
constructor(options: SessionService.Options);
|
|
13
9
|
private get key();
|
|
14
10
|
hasAuthorization(): Promise<boolean>;
|
|
@@ -16,13 +16,9 @@ exports.SessionService = void 0;
|
|
|
16
16
|
const jwt_decode_1 = require("jwt-decode");
|
|
17
17
|
const moment_1 = __importDefault(require("moment"));
|
|
18
18
|
const eventemitter3_1 = __importDefault(require("eventemitter3"));
|
|
19
|
-
class SessionService {
|
|
19
|
+
class SessionService extends eventemitter3_1.default {
|
|
20
20
|
constructor(options) {
|
|
21
|
-
|
|
22
|
-
this.emitter = new eventemitter3_1.default();
|
|
23
|
-
this.on = this.emitter.on.bind(this.emitter);
|
|
24
|
-
this.off = this.emitter.off.bind(this.emitter);
|
|
25
|
-
this.emit = this.emitter.emit.bind(this.emitter);
|
|
21
|
+
super();
|
|
26
22
|
// Init service parameters
|
|
27
23
|
console.log('Session initialized', Date.now(), options.api);
|
|
28
24
|
this.api = options.api;
|
|
@@ -8,7 +8,7 @@ export declare class TimeService extends EventEmitter<TimeServiceEvent> {
|
|
|
8
8
|
protected clientTimeProvider?: TimeServiceClientTimeProvider;
|
|
9
9
|
protected serverTimeProvider?: TimeServiceServerTimeProvider;
|
|
10
10
|
static calculateNTPResultOffset(ntpResult: TimeServiceNtpResult): TimeServiceOffset;
|
|
11
|
-
constructor(
|
|
11
|
+
constructor(options?: TimeServiceOptions);
|
|
12
12
|
getOffset(defaultValue: TimeServiceOffset): TimeServiceOffset;
|
|
13
13
|
getOffset(): TimeServiceOffset | undefined;
|
|
14
14
|
setOffset(offset: TimeServiceOffset): TimeServiceOffset;
|
|
@@ -26,6 +26,6 @@ export declare class TimeService extends EventEmitter<TimeServiceEvent> {
|
|
|
26
26
|
getTime(): number;
|
|
27
27
|
private fetchServerNTPResult;
|
|
28
28
|
sync(): Promise<TimeServiceOffset | null>;
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
startSync(): void;
|
|
30
|
+
stopSync(): void;
|
|
31
31
|
}
|
|
@@ -20,12 +20,12 @@ class TimeService extends eventemitter3_1.default {
|
|
|
20
20
|
const { t1, t2, t3, t4 } = ntpResult;
|
|
21
21
|
return ((t2 - t1) + (t3 - t4)) / 2;
|
|
22
22
|
}
|
|
23
|
-
constructor(
|
|
23
|
+
constructor(options) {
|
|
24
24
|
super();
|
|
25
25
|
// Options
|
|
26
|
-
this.syncInterval =
|
|
27
|
-
this.clientTimeProvider =
|
|
28
|
-
this.serverTimeProvider =
|
|
26
|
+
this.syncInterval = options === null || options === void 0 ? void 0 : options.syncInterval;
|
|
27
|
+
this.clientTimeProvider = options === null || options === void 0 ? void 0 : options.clientTimeProvider;
|
|
28
|
+
this.serverTimeProvider = options === null || options === void 0 ? void 0 : options.serverTimeProvider;
|
|
29
29
|
// Bind
|
|
30
30
|
this.sync = this.sync.bind(this);
|
|
31
31
|
this.fetchServerNTPResult = this.fetchServerNTPResult.bind(this);
|