@powfix/core-js 0.9.22
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.
- package/browser.ts +73 -0
- package/dist/browser.d.ts +32 -0
- package/dist/browser.js +58 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -0
- package/dist/src/constants/COORDINATE.d.ts +7 -0
- package/dist/src/constants/COORDINATE.js +10 -0
- package/dist/src/constants/DISTANCE.d.ts +13 -0
- package/dist/src/constants/DISTANCE.js +18 -0
- package/dist/src/constants/DURATION.d.ts +16 -0
- package/dist/src/constants/DURATION.js +21 -0
- package/dist/src/interfaces/Coordinate.d.ts +8 -0
- package/dist/src/interfaces/Coordinate.js +2 -0
- package/dist/src/interfaces/Point2.d.ts +4 -0
- package/dist/src/interfaces/Point2.js +2 -0
- package/dist/src/interfaces/Point3.d.ts +4 -0
- package/dist/src/interfaces/Point3.js +2 -0
- package/dist/src/scripts/base64-polyfill.d.ts +1 -0
- package/dist/src/scripts/base64-polyfill.js +14 -0
- package/dist/src/services/Session.d.ts +27 -0
- package/dist/src/services/Session.js +140 -0
- package/dist/src/services/browser.d.ts +2 -0
- package/dist/src/services/browser.js +20 -0
- package/dist/src/services/index.d.ts +2 -0
- package/dist/src/services/index.js +19 -0
- package/dist/src/services/redis/RedisClient.d.ts +20 -0
- package/dist/src/services/redis/RedisClient.js +70 -0
- package/dist/src/services/redis/RedisPublisher.d.ts +13 -0
- package/dist/src/services/redis/RedisPublisher.js +61 -0
- package/dist/src/services/redis/RedisSubscriber.d.ts +11 -0
- package/dist/src/services/redis/RedisSubscriber.js +68 -0
- package/dist/src/services/redis/index.d.ts +3 -0
- package/dist/src/services/redis/index.js +20 -0
- package/dist/src/services/time/TimeService.d.ts +64 -0
- package/dist/src/services/time/TimeService.js +235 -0
- package/dist/src/services/time/index.d.ts +1 -0
- package/dist/src/services/time/index.js +17 -0
- package/dist/src/types/IntRage.d.ts +3 -0
- package/dist/src/types/IntRage.js +2 -0
- package/dist/src/utils/ArrayUtils.d.ts +10 -0
- package/dist/src/utils/ArrayUtils.js +20 -0
- package/dist/src/utils/BooleanUtils.d.ts +1 -0
- package/dist/src/utils/BooleanUtils.js +9 -0
- package/dist/src/utils/CoordinateUtils.d.ts +8 -0
- package/dist/src/utils/CoordinateUtils.js +42 -0
- package/dist/src/utils/DateUtils.d.ts +12 -0
- package/dist/src/utils/DateUtils.js +212 -0
- package/dist/src/utils/JuminNumberUtils.d.ts +4 -0
- package/dist/src/utils/JuminNumberUtils.js +50 -0
- package/dist/src/utils/NumberUtils.d.ts +4 -0
- package/dist/src/utils/NumberUtils.js +25 -0
- package/dist/src/utils/Point3Utils.d.ts +4 -0
- package/dist/src/utils/Point3Utils.js +12 -0
- package/dist/src/utils/RandomUtils.d.ts +8 -0
- package/dist/src/utils/RandomUtils.js +64 -0
- package/dist/src/utils/Sequencer.d.ts +39 -0
- package/dist/src/utils/Sequencer.js +148 -0
- package/dist/src/utils/StringUtils.d.ts +5 -0
- package/dist/src/utils/StringUtils.js +37 -0
- package/dist/src/utils/UuidUtils.d.ts +14 -0
- package/dist/src/utils/UuidUtils.js +49 -0
- package/dist/src/utils/Validator.d.ts +48 -0
- package/dist/src/utils/Validator.js +118 -0
- package/dist/src/utils/global/between.d.ts +1 -0
- package/dist/src/utils/global/between.js +7 -0
- package/dist/src/utils/global/sleep.d.ts +1 -0
- package/dist/src/utils/global/sleep.js +21 -0
- package/index.ts +5 -0
- package/package.json +42 -0
- package/src/constants/COORDINATE.ts +9 -0
- package/src/constants/DISTANCE.ts +15 -0
- package/src/constants/DURATION.ts +18 -0
- package/src/interfaces/Coordinate.ts +9 -0
- package/src/interfaces/Point2.ts +4 -0
- package/src/interfaces/Point3.ts +5 -0
- package/src/scripts/base64-polyfill.ts +13 -0
- package/src/services/Session.ts +141 -0
- package/src/services/browser.ts +5 -0
- package/src/services/index.ts +4 -0
- package/src/services/redis/RedisClient.ts +79 -0
- package/src/services/redis/RedisPublisher.ts +48 -0
- package/src/services/redis/RedisSubscriber.ts +49 -0
- package/src/services/redis/index.ts +4 -0
- package/src/services/time/TimeService.ts +304 -0
- package/src/services/time/index.ts +1 -0
- package/src/types/IntRage.ts +5 -0
- package/src/utils/ArrayUtils.ts +25 -0
- package/src/utils/BooleanUtils.ts +4 -0
- package/src/utils/CoordinateUtils.ts +50 -0
- package/src/utils/DateUtils.ts +213 -0
- package/src/utils/JuminNumberUtils.ts +47 -0
- package/src/utils/NumberUtils.ts +23 -0
- package/src/utils/Point3Utils.ts +11 -0
- package/src/utils/RandomUtils.ts +62 -0
- package/src/utils/Sequencer.ts +178 -0
- package/src/utils/StringUtils.ts +43 -0
- package/src/utils/UuidUtils.ts +46 -0
- package/src/utils/Validator.ts +162 -0
- package/src/utils/global/between.ts +3 -0
- package/src/utils/global/sleep.ts +6 -0
- package/tsconfig.json +103 -0
package/browser.ts
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** @constants */
|
|
2
|
+
import {DURATION} from "./src/constants/DURATION";
|
|
3
|
+
import {DISTANCE} from "./src/constants/DISTANCE";
|
|
4
|
+
export {
|
|
5
|
+
DISTANCE,
|
|
6
|
+
DURATION,
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
/** @model */
|
|
10
|
+
import {Coordinate, CoordinateM} from "./src/interfaces/Coordinate";
|
|
11
|
+
import {Point2} from "./src/interfaces/Point2";
|
|
12
|
+
import {Point3} from "./src/interfaces/Point3";
|
|
13
|
+
export {
|
|
14
|
+
Coordinate,
|
|
15
|
+
CoordinateM,
|
|
16
|
+
Point2,
|
|
17
|
+
Point3,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/** @service */
|
|
21
|
+
import {Session, SessionOptions, StorageProvider} from "./src/services/Session";
|
|
22
|
+
export {
|
|
23
|
+
Session,
|
|
24
|
+
SessionOptions,
|
|
25
|
+
StorageProvider,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @types */
|
|
29
|
+
import {IntRange} from "./src/types/IntRage";
|
|
30
|
+
export {
|
|
31
|
+
IntRange,
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/** @utils */
|
|
35
|
+
import {between} from "./src/utils/global/between";
|
|
36
|
+
import {sleep} from "./src/utils/global/sleep";
|
|
37
|
+
import {StringUtils} from "./src/utils/StringUtils";
|
|
38
|
+
import {NumberUtils} from "./src/utils/NumberUtils";
|
|
39
|
+
import {UuidUtils} from "./src/utils/UuidUtils";
|
|
40
|
+
import {ArrayUtils} from "./src/utils/ArrayUtils";
|
|
41
|
+
import {parseBoolean} from "./src/utils/BooleanUtils";
|
|
42
|
+
import {CoordinateUtils} from "./src/utils/CoordinateUtils";
|
|
43
|
+
import {DateUtils} from "./src/utils/DateUtils";
|
|
44
|
+
import {RandomUtils} from "./src/utils/RandomUtils";
|
|
45
|
+
import {Validator} from './src/utils/Validator';
|
|
46
|
+
import {JuminNumberUtils} from "./src/utils/JuminNumberUtils";
|
|
47
|
+
import {Sequence, Sequencer, SequencerEvent, SequencerOption, SequencerStatus} from "./src/utils/Sequencer";
|
|
48
|
+
import {base64Polyfill} from "./src/scripts/base64-polyfill";
|
|
49
|
+
export {
|
|
50
|
+
between,
|
|
51
|
+
sleep,
|
|
52
|
+
|
|
53
|
+
base64Polyfill,
|
|
54
|
+
UuidUtils,
|
|
55
|
+
ArrayUtils,
|
|
56
|
+
RandomUtils,
|
|
57
|
+
DateUtils,
|
|
58
|
+
StringUtils,
|
|
59
|
+
NumberUtils,
|
|
60
|
+
CoordinateUtils,
|
|
61
|
+
parseBoolean,
|
|
62
|
+
Validator,
|
|
63
|
+
JuminNumberUtils,
|
|
64
|
+
Sequence,
|
|
65
|
+
SequencerStatus,
|
|
66
|
+
SequencerOption,
|
|
67
|
+
SequencerEvent,
|
|
68
|
+
Sequencer,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
// Directories
|
|
73
|
+
export * from './src/services/browser';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/** @constants */
|
|
2
|
+
import { DURATION } from "./src/constants/DURATION";
|
|
3
|
+
import { DISTANCE } from "./src/constants/DISTANCE";
|
|
4
|
+
export { DISTANCE, DURATION, };
|
|
5
|
+
/** @model */
|
|
6
|
+
import { Coordinate, CoordinateM } from "./src/interfaces/Coordinate";
|
|
7
|
+
import { Point2 } from "./src/interfaces/Point2";
|
|
8
|
+
import { Point3 } from "./src/interfaces/Point3";
|
|
9
|
+
export { Coordinate, CoordinateM, Point2, Point3, };
|
|
10
|
+
/** @service */
|
|
11
|
+
import { Session, SessionOptions, StorageProvider } from "./src/services/Session";
|
|
12
|
+
export { Session, SessionOptions, StorageProvider, };
|
|
13
|
+
/** @types */
|
|
14
|
+
import { IntRange } from "./src/types/IntRage";
|
|
15
|
+
export { IntRange, };
|
|
16
|
+
/** @utils */
|
|
17
|
+
import { between } from "./src/utils/global/between";
|
|
18
|
+
import { sleep } from "./src/utils/global/sleep";
|
|
19
|
+
import { StringUtils } from "./src/utils/StringUtils";
|
|
20
|
+
import { NumberUtils } from "./src/utils/NumberUtils";
|
|
21
|
+
import { UuidUtils } from "./src/utils/UuidUtils";
|
|
22
|
+
import { ArrayUtils } from "./src/utils/ArrayUtils";
|
|
23
|
+
import { parseBoolean } from "./src/utils/BooleanUtils";
|
|
24
|
+
import { CoordinateUtils } from "./src/utils/CoordinateUtils";
|
|
25
|
+
import { DateUtils } from "./src/utils/DateUtils";
|
|
26
|
+
import { RandomUtils } from "./src/utils/RandomUtils";
|
|
27
|
+
import { Validator } from './src/utils/Validator';
|
|
28
|
+
import { JuminNumberUtils } from "./src/utils/JuminNumberUtils";
|
|
29
|
+
import { Sequence, Sequencer, SequencerEvent, SequencerOption, SequencerStatus } from "./src/utils/Sequencer";
|
|
30
|
+
import { base64Polyfill } from "./src/scripts/base64-polyfill";
|
|
31
|
+
export { between, sleep, base64Polyfill, UuidUtils, ArrayUtils, RandomUtils, DateUtils, StringUtils, NumberUtils, CoordinateUtils, parseBoolean, Validator, JuminNumberUtils, Sequence, SequencerStatus, SequencerOption, SequencerEvent, Sequencer, };
|
|
32
|
+
export * from './src/services/browser';
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.Sequencer = exports.SequencerEvent = exports.SequencerStatus = exports.JuminNumberUtils = exports.Validator = exports.parseBoolean = exports.CoordinateUtils = exports.NumberUtils = exports.StringUtils = exports.DateUtils = exports.RandomUtils = exports.ArrayUtils = exports.UuidUtils = exports.base64Polyfill = exports.sleep = exports.between = exports.Session = exports.DURATION = exports.DISTANCE = void 0;
|
|
18
|
+
/** @constants */
|
|
19
|
+
const DURATION_1 = require("./src/constants/DURATION");
|
|
20
|
+
Object.defineProperty(exports, "DURATION", { enumerable: true, get: function () { return DURATION_1.DURATION; } });
|
|
21
|
+
const DISTANCE_1 = require("./src/constants/DISTANCE");
|
|
22
|
+
Object.defineProperty(exports, "DISTANCE", { enumerable: true, get: function () { return DISTANCE_1.DISTANCE; } });
|
|
23
|
+
/** @service */
|
|
24
|
+
const Session_1 = require("./src/services/Session");
|
|
25
|
+
Object.defineProperty(exports, "Session", { enumerable: true, get: function () { return Session_1.Session; } });
|
|
26
|
+
/** @utils */
|
|
27
|
+
const between_1 = require("./src/utils/global/between");
|
|
28
|
+
Object.defineProperty(exports, "between", { enumerable: true, get: function () { return between_1.between; } });
|
|
29
|
+
const sleep_1 = require("./src/utils/global/sleep");
|
|
30
|
+
Object.defineProperty(exports, "sleep", { enumerable: true, get: function () { return sleep_1.sleep; } });
|
|
31
|
+
const StringUtils_1 = require("./src/utils/StringUtils");
|
|
32
|
+
Object.defineProperty(exports, "StringUtils", { enumerable: true, get: function () { return StringUtils_1.StringUtils; } });
|
|
33
|
+
const NumberUtils_1 = require("./src/utils/NumberUtils");
|
|
34
|
+
Object.defineProperty(exports, "NumberUtils", { enumerable: true, get: function () { return NumberUtils_1.NumberUtils; } });
|
|
35
|
+
const UuidUtils_1 = require("./src/utils/UuidUtils");
|
|
36
|
+
Object.defineProperty(exports, "UuidUtils", { enumerable: true, get: function () { return UuidUtils_1.UuidUtils; } });
|
|
37
|
+
const ArrayUtils_1 = require("./src/utils/ArrayUtils");
|
|
38
|
+
Object.defineProperty(exports, "ArrayUtils", { enumerable: true, get: function () { return ArrayUtils_1.ArrayUtils; } });
|
|
39
|
+
const BooleanUtils_1 = require("./src/utils/BooleanUtils");
|
|
40
|
+
Object.defineProperty(exports, "parseBoolean", { enumerable: true, get: function () { return BooleanUtils_1.parseBoolean; } });
|
|
41
|
+
const CoordinateUtils_1 = require("./src/utils/CoordinateUtils");
|
|
42
|
+
Object.defineProperty(exports, "CoordinateUtils", { enumerable: true, get: function () { return CoordinateUtils_1.CoordinateUtils; } });
|
|
43
|
+
const DateUtils_1 = require("./src/utils/DateUtils");
|
|
44
|
+
Object.defineProperty(exports, "DateUtils", { enumerable: true, get: function () { return DateUtils_1.DateUtils; } });
|
|
45
|
+
const RandomUtils_1 = require("./src/utils/RandomUtils");
|
|
46
|
+
Object.defineProperty(exports, "RandomUtils", { enumerable: true, get: function () { return RandomUtils_1.RandomUtils; } });
|
|
47
|
+
const Validator_1 = require("./src/utils/Validator");
|
|
48
|
+
Object.defineProperty(exports, "Validator", { enumerable: true, get: function () { return Validator_1.Validator; } });
|
|
49
|
+
const JuminNumberUtils_1 = require("./src/utils/JuminNumberUtils");
|
|
50
|
+
Object.defineProperty(exports, "JuminNumberUtils", { enumerable: true, get: function () { return JuminNumberUtils_1.JuminNumberUtils; } });
|
|
51
|
+
const Sequencer_1 = require("./src/utils/Sequencer");
|
|
52
|
+
Object.defineProperty(exports, "Sequencer", { enumerable: true, get: function () { return Sequencer_1.Sequencer; } });
|
|
53
|
+
Object.defineProperty(exports, "SequencerEvent", { enumerable: true, get: function () { return Sequencer_1.SequencerEvent; } });
|
|
54
|
+
Object.defineProperty(exports, "SequencerStatus", { enumerable: true, get: function () { return Sequencer_1.SequencerStatus; } });
|
|
55
|
+
const base64_polyfill_1 = require("./src/scripts/base64-polyfill");
|
|
56
|
+
Object.defineProperty(exports, "base64Polyfill", { enumerable: true, get: function () { return base64_polyfill_1.base64Polyfill; } });
|
|
57
|
+
// Directories
|
|
58
|
+
__exportStar(require("./src/services/browser"), exports);
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Extend browser imports & exports
|
|
18
|
+
__exportStar(require("./browser"), exports);
|
|
19
|
+
// services
|
|
20
|
+
__exportStar(require("./src/services"), exports);
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.COORDINATE = void 0;
|
|
4
|
+
class COORDINATE {
|
|
5
|
+
}
|
|
6
|
+
exports.COORDINATE = COORDINATE;
|
|
7
|
+
COORDINATE.LATITUDE_MIN_LENGTH = 1;
|
|
8
|
+
COORDINATE.LATITUDE_MAX_LENGTH = 10;
|
|
9
|
+
COORDINATE.LONGITUDE_MIN_LENGTH = 1;
|
|
10
|
+
COORDINATE.LONGITUDE_MAX_LENGTH = 11;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class DISTANCE {
|
|
2
|
+
}
|
|
3
|
+
export declare namespace DISTANCE {
|
|
4
|
+
enum UNIT {
|
|
5
|
+
FEET = "FEET",
|
|
6
|
+
KILOMETERS = "KILOMETERS",
|
|
7
|
+
MILLIMETERS = "MILLIMETERS",
|
|
8
|
+
CENTIMETERS = "CENTIMETERS",
|
|
9
|
+
METERS = "METERS",
|
|
10
|
+
MILES = "MILES",
|
|
11
|
+
YARDS = "YARDS"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DISTANCE = void 0;
|
|
4
|
+
class DISTANCE {
|
|
5
|
+
}
|
|
6
|
+
exports.DISTANCE = DISTANCE;
|
|
7
|
+
(function (DISTANCE) {
|
|
8
|
+
let UNIT;
|
|
9
|
+
(function (UNIT) {
|
|
10
|
+
UNIT["FEET"] = "FEET";
|
|
11
|
+
UNIT["KILOMETERS"] = "KILOMETERS";
|
|
12
|
+
UNIT["MILLIMETERS"] = "MILLIMETERS";
|
|
13
|
+
UNIT["CENTIMETERS"] = "CENTIMETERS";
|
|
14
|
+
UNIT["METERS"] = "METERS";
|
|
15
|
+
UNIT["MILES"] = "MILES";
|
|
16
|
+
UNIT["YARDS"] = "YARDS";
|
|
17
|
+
})(UNIT = DISTANCE.UNIT || (DISTANCE.UNIT = {}));
|
|
18
|
+
})(DISTANCE || (exports.DISTANCE = DISTANCE = {}));
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare class DURATION {
|
|
2
|
+
}
|
|
3
|
+
export declare namespace DURATION {
|
|
4
|
+
enum UNIT {
|
|
5
|
+
NANOSECONDS = "NANOSECONDS",
|
|
6
|
+
MICROSECONDS = "MICROSECONDS",
|
|
7
|
+
MILLISECONDS = "MILLISECONDS",
|
|
8
|
+
SECONDS = "SECONDS",
|
|
9
|
+
MINUTES = "MINUTES",
|
|
10
|
+
HOURS = "HOURS",
|
|
11
|
+
DAYS = "DAYS",
|
|
12
|
+
YEARS = "YEARS",
|
|
13
|
+
DECADES = "DECADES",
|
|
14
|
+
CENTURIES = "CENTURIES"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DURATION = void 0;
|
|
4
|
+
class DURATION {
|
|
5
|
+
}
|
|
6
|
+
exports.DURATION = DURATION;
|
|
7
|
+
(function (DURATION) {
|
|
8
|
+
let UNIT;
|
|
9
|
+
(function (UNIT) {
|
|
10
|
+
UNIT["NANOSECONDS"] = "NANOSECONDS";
|
|
11
|
+
UNIT["MICROSECONDS"] = "MICROSECONDS";
|
|
12
|
+
UNIT["MILLISECONDS"] = "MILLISECONDS";
|
|
13
|
+
UNIT["SECONDS"] = "SECONDS";
|
|
14
|
+
UNIT["MINUTES"] = "MINUTES";
|
|
15
|
+
UNIT["HOURS"] = "HOURS";
|
|
16
|
+
UNIT["DAYS"] = "DAYS";
|
|
17
|
+
UNIT["YEARS"] = "YEARS";
|
|
18
|
+
UNIT["DECADES"] = "DECADES";
|
|
19
|
+
UNIT["CENTURIES"] = "CENTURIES";
|
|
20
|
+
})(UNIT = DURATION.UNIT || (DURATION.UNIT = {}));
|
|
21
|
+
})(DURATION || (exports.DURATION = DURATION = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const base64Polyfill: () => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.base64Polyfill = void 0;
|
|
4
|
+
const base_64_1 = require("base-64");
|
|
5
|
+
const base64Polyfill = () => {
|
|
6
|
+
if (!global.btoa) {
|
|
7
|
+
global.btoa = base_64_1.encode;
|
|
8
|
+
}
|
|
9
|
+
if (!global.atob) {
|
|
10
|
+
global.atob = base_64_1.decode;
|
|
11
|
+
}
|
|
12
|
+
console.log('base64-polyfill initialized', Date.now());
|
|
13
|
+
};
|
|
14
|
+
exports.base64Polyfill = base64Polyfill;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { AxiosInstance } from "axios";
|
|
2
|
+
export interface SessionOptions {
|
|
3
|
+
api: AxiosInstance;
|
|
4
|
+
storageProvider: StorageProvider;
|
|
5
|
+
}
|
|
6
|
+
export interface StorageProvider {
|
|
7
|
+
key?: () => string;
|
|
8
|
+
set: (key: string, value: string) => Promise<void> | void;
|
|
9
|
+
get: (key: string) => Promise<string | null> | (string | null);
|
|
10
|
+
remove: (key: string) => Promise<void> | void;
|
|
11
|
+
clear?: () => Promise<void> | void;
|
|
12
|
+
}
|
|
13
|
+
export declare class Session {
|
|
14
|
+
protected api: AxiosInstance;
|
|
15
|
+
protected storageProvider: StorageProvider;
|
|
16
|
+
constructor(options: SessionOptions);
|
|
17
|
+
private getKey;
|
|
18
|
+
hasAuthorization(): Promise<boolean>;
|
|
19
|
+
getAuthorization(): Promise<string | null>;
|
|
20
|
+
setAuthorization(authorization?: string | null): Promise<string | null>;
|
|
21
|
+
removeAuthorization(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
export declare namespace Session {
|
|
24
|
+
enum STORAGE_KEY {
|
|
25
|
+
SESSION_AUTHORIZATION = "SESSION_AUTHORIZATION"
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Session = void 0;
|
|
16
|
+
const jwt_decode_1 = require("jwt-decode");
|
|
17
|
+
const moment_1 = __importDefault(require("moment"));
|
|
18
|
+
const logWithTs = (...p) => {
|
|
19
|
+
console.log(Date.now(), ...p);
|
|
20
|
+
};
|
|
21
|
+
class Session {
|
|
22
|
+
// Emitter
|
|
23
|
+
// private emitter = new EventEmitter({});
|
|
24
|
+
// public on = this.emitter.on;
|
|
25
|
+
// public off = this.emitter.off;
|
|
26
|
+
// private emit = this.emitter.emit;
|
|
27
|
+
constructor(options) {
|
|
28
|
+
// Init service parameters
|
|
29
|
+
console.log('Session initialized', Date.now(), options.api);
|
|
30
|
+
this.api = options.api;
|
|
31
|
+
this.storageProvider = options.storageProvider;
|
|
32
|
+
}
|
|
33
|
+
getKey() {
|
|
34
|
+
try {
|
|
35
|
+
if (this.storageProvider.key) {
|
|
36
|
+
return this.storageProvider.key();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
catch (e) {
|
|
40
|
+
console.error(e);
|
|
41
|
+
}
|
|
42
|
+
return Session.STORAGE_KEY.SESSION_AUTHORIZATION;
|
|
43
|
+
}
|
|
44
|
+
hasAuthorization() {
|
|
45
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
return !!(yield this.getAuthorization());
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
getAuthorization() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
return this.storageProvider.get(this.getKey());
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
setAuthorization(authorization) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
56
|
+
if (authorization === null) {
|
|
57
|
+
yield this.removeAuthorization();
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
let nextAuthorization = yield (() => __awaiter(this, void 0, void 0, function* () {
|
|
61
|
+
if (authorization === undefined) {
|
|
62
|
+
return yield this.getAuthorization();
|
|
63
|
+
}
|
|
64
|
+
return authorization;
|
|
65
|
+
}))();
|
|
66
|
+
if (!nextAuthorization) {
|
|
67
|
+
console.log('nextAuthorization is null or undefined');
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
// Replace Bearer prefix
|
|
72
|
+
nextAuthorization = nextAuthorization.replace(/^Bearer\s+/, '');
|
|
73
|
+
const decoded = (0, jwt_decode_1.jwtDecode)(nextAuthorization);
|
|
74
|
+
if (!decoded) {
|
|
75
|
+
console.warn('JWT decode failed');
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
console.log('Session:JWT decoded');
|
|
79
|
+
(() => {
|
|
80
|
+
console.log(' - User', decoded.uuid);
|
|
81
|
+
console.log(' - IAT', ...(() => {
|
|
82
|
+
if (!decoded.iat) {
|
|
83
|
+
return [decoded.iat];
|
|
84
|
+
}
|
|
85
|
+
const iat = moment_1.default.unix(decoded.iat);
|
|
86
|
+
if (!iat.isValid()) {
|
|
87
|
+
return [decoded.iat];
|
|
88
|
+
}
|
|
89
|
+
return [decoded.iat, iat.format(), iat.diff(Date.now(), 'days'), 'days left'];
|
|
90
|
+
})());
|
|
91
|
+
console.log(' - NBF', ...(() => {
|
|
92
|
+
if (!decoded.nbf) {
|
|
93
|
+
return [decoded.nbf];
|
|
94
|
+
}
|
|
95
|
+
const nbf = moment_1.default.unix(decoded.nbf);
|
|
96
|
+
if (!nbf.isValid()) {
|
|
97
|
+
return [decoded.nbf];
|
|
98
|
+
}
|
|
99
|
+
return [decoded.nbf, nbf.format(), nbf.diff(Date.now(), 'days'), 'days left'];
|
|
100
|
+
})());
|
|
101
|
+
console.log(' - EXP', ...(() => {
|
|
102
|
+
if (!decoded.exp) {
|
|
103
|
+
return [decoded.exp];
|
|
104
|
+
}
|
|
105
|
+
const exp = moment_1.default.unix(decoded.exp);
|
|
106
|
+
if (!exp.isValid()) {
|
|
107
|
+
return [decoded.exp];
|
|
108
|
+
}
|
|
109
|
+
return [decoded.exp, exp.format(), exp.diff(Date.now(), 'days'), 'days left'];
|
|
110
|
+
})());
|
|
111
|
+
})();
|
|
112
|
+
// AsyncStorage 에 토큰 저장
|
|
113
|
+
yield this.storageProvider.set(this.getKey(), nextAuthorization);
|
|
114
|
+
// API Instance header 설정
|
|
115
|
+
this.api.defaults.headers.common.Authorization = `Bearer ${nextAuthorization}`;
|
|
116
|
+
// Return
|
|
117
|
+
return nextAuthorization;
|
|
118
|
+
}
|
|
119
|
+
catch (e) {
|
|
120
|
+
console.error(e);
|
|
121
|
+
}
|
|
122
|
+
return null;
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
removeAuthorization() {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
127
|
+
// API Instance header 에서 토큰 제거
|
|
128
|
+
delete this.api.defaults.headers.common.Authorization;
|
|
129
|
+
// 스토리지에서 authorization 제거
|
|
130
|
+
yield this.storageProvider.remove(this.getKey());
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.Session = Session;
|
|
135
|
+
(function (Session) {
|
|
136
|
+
let STORAGE_KEY;
|
|
137
|
+
(function (STORAGE_KEY) {
|
|
138
|
+
STORAGE_KEY["SESSION_AUTHORIZATION"] = "SESSION_AUTHORIZATION";
|
|
139
|
+
})(STORAGE_KEY = Session.STORAGE_KEY || (Session.STORAGE_KEY = {}));
|
|
140
|
+
})(Session || (exports.Session = Session = {}));
|
|
@@ -0,0 +1,20 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
// Directories
|
|
18
|
+
__exportStar(require("./time"), exports);
|
|
19
|
+
// Files
|
|
20
|
+
__exportStar(require("./Session"), exports);
|
|
@@ -0,0 +1,19 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./browser"), exports);
|
|
18
|
+
// Directories
|
|
19
|
+
__exportStar(require("./redis"), exports);
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import redis, { RedisClientType, RedisDefaultModules, RedisFunctions, RedisModules, RedisScripts } from 'redis';
|
|
2
|
+
export declare class RedisClient {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private status;
|
|
5
|
+
readonly client: RedisClientType<RedisDefaultModules & RedisModules, RedisFunctions, RedisScripts>;
|
|
6
|
+
constructor(options?: RedisClient.RedisClientOptions);
|
|
7
|
+
start(): Promise<RedisClient.Status>;
|
|
8
|
+
stop(): Promise<RedisClient.Status>;
|
|
9
|
+
private handleOnConnect;
|
|
10
|
+
private handleOnError;
|
|
11
|
+
}
|
|
12
|
+
export declare namespace RedisClient {
|
|
13
|
+
enum Status {
|
|
14
|
+
RUNNING = 0,
|
|
15
|
+
STOPPED = 1
|
|
16
|
+
}
|
|
17
|
+
interface RedisClientOptions {
|
|
18
|
+
redisOptions?: redis.RedisClientOptions;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RedisClient = void 0;
|
|
13
|
+
const redis_1 = require("redis");
|
|
14
|
+
const LOG_PREFIX = 'RedisClient';
|
|
15
|
+
class RedisClient {
|
|
16
|
+
constructor(options) {
|
|
17
|
+
this.options = {};
|
|
18
|
+
this.status = RedisClient.Status.STOPPED;
|
|
19
|
+
console.log(Date.now(), LOG_PREFIX, 'initialized');
|
|
20
|
+
if (options) {
|
|
21
|
+
this.options = options;
|
|
22
|
+
}
|
|
23
|
+
if (options === null || options === void 0 ? void 0 : options.redisOptions) {
|
|
24
|
+
this.client = (0, redis_1.createClient)(options.redisOptions);
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.client = (0, redis_1.createClient)({});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
start() {
|
|
31
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
+
console.log(LOG_PREFIX, 'trying to start');
|
|
33
|
+
// register event callback
|
|
34
|
+
this.client.on('connect', this.handleOnConnect);
|
|
35
|
+
this.client.on('error', this.handleOnError);
|
|
36
|
+
yield this.client.connect();
|
|
37
|
+
this.status = RedisClient.Status.RUNNING;
|
|
38
|
+
console.log(LOG_PREFIX, 'now started');
|
|
39
|
+
return this.status;
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
stop() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
console.log(LOG_PREFIX, 'trying to stop');
|
|
45
|
+
// unregister event callback
|
|
46
|
+
this.client.off('connect', this.handleOnConnect);
|
|
47
|
+
this.client.off('error', this.handleOnError);
|
|
48
|
+
if (this.client.isOpen) {
|
|
49
|
+
yield this.client.disconnect();
|
|
50
|
+
}
|
|
51
|
+
this.status = RedisClient.Status.STOPPED;
|
|
52
|
+
console.log(LOG_PREFIX, 'now stopped');
|
|
53
|
+
return this.status;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
handleOnConnect() {
|
|
57
|
+
console.log(LOG_PREFIX, 'connected');
|
|
58
|
+
}
|
|
59
|
+
handleOnError(error) {
|
|
60
|
+
console.error(LOG_PREFIX, error);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
exports.RedisClient = RedisClient;
|
|
64
|
+
(function (RedisClient) {
|
|
65
|
+
let Status;
|
|
66
|
+
(function (Status) {
|
|
67
|
+
Status[Status["RUNNING"] = 0] = "RUNNING";
|
|
68
|
+
Status[Status["STOPPED"] = 1] = "STOPPED";
|
|
69
|
+
})(Status = RedisClient.Status || (RedisClient.Status = {}));
|
|
70
|
+
})(RedisClient || (exports.RedisClient = RedisClient = {}));
|