nest-wrapper-kiwoom 1.0.9 → 1.0.11
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/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/services/oauth2.service.d.ts +19 -3
- package/dist/services/oauth2.service.js +30 -2
- package/dist/services/oauth2.service.js.map +1 -1
- package/package.json +3 -2
- package/dist/kiwoom.service.d.ts +0 -2
- package/dist/kiwoom.service.js +0 -20
- package/dist/kiwoom.service.js.map +0 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -15,6 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./kiwoom.module"), exports);
|
|
18
|
-
__exportStar(require("./kiwoom.service"), exports);
|
|
19
18
|
__exportStar(require("./services/oauth2.service"), exports);
|
|
20
19
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,4DAA0C"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
|
+
import { OnModuleInit } from '@nestjs/common';
|
|
1
2
|
import { KiwoomOptions } from '../interfaces';
|
|
2
3
|
import { HttpService } from '@nestjs/axios';
|
|
3
|
-
|
|
4
|
+
interface AU10001Response {
|
|
5
|
+
expires_dt: string;
|
|
6
|
+
return_msg: string;
|
|
7
|
+
token_type: string;
|
|
8
|
+
return_code: number;
|
|
9
|
+
token: string;
|
|
10
|
+
}
|
|
11
|
+
interface AU10002Response {
|
|
12
|
+
return_msg: string;
|
|
13
|
+
return_code: number;
|
|
14
|
+
}
|
|
15
|
+
export declare class Oauth2 implements OnModuleInit {
|
|
4
16
|
private readonly option;
|
|
5
17
|
private readonly httpService;
|
|
6
18
|
private readonly headers;
|
|
7
19
|
private readonly body;
|
|
20
|
+
private readonly auth;
|
|
8
21
|
constructor(option: KiwoomOptions, httpService: HttpService);
|
|
9
|
-
|
|
10
|
-
|
|
22
|
+
onModuleInit(): void;
|
|
23
|
+
getBearerToken(): Promise<string>;
|
|
24
|
+
au10001(): Promise<AU10001Response>;
|
|
25
|
+
au10002(token: string): Promise<AU10002Response>;
|
|
11
26
|
}
|
|
27
|
+
export {};
|
|
@@ -52,13 +52,39 @@ exports.Oauth2 = void 0;
|
|
|
52
52
|
var common_1 = require("@nestjs/common");
|
|
53
53
|
var kiwoom_constants_1 = require("../kiwoom.constants");
|
|
54
54
|
var axios_1 = require("@nestjs/axios");
|
|
55
|
+
var dayjs = require("dayjs");
|
|
55
56
|
var Oauth2 = (function () {
|
|
56
57
|
function Oauth2(option, httpService) {
|
|
57
58
|
this.option = option;
|
|
58
59
|
this.httpService = httpService;
|
|
59
60
|
this.headers = { 'Content-Type': 'application/json;charset=UTF-8' };
|
|
60
|
-
this.body = {
|
|
61
|
+
this.body = { appkey: this.option.appKey, secretkey: this.option.secretKey };
|
|
61
62
|
}
|
|
63
|
+
Oauth2.prototype.onModuleInit = function () {
|
|
64
|
+
this.auth.set('expires_dt', '0');
|
|
65
|
+
};
|
|
66
|
+
Oauth2.prototype.getBearerToken = function () {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
68
|
+
var expiresDt, nowDt, response, expiresDt_1, bearerToken;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
expiresDt = this.auth.get('expires_dt');
|
|
73
|
+
nowDt = dayjs().format('YYYYMMDDHHmmss');
|
|
74
|
+
if (!(parseInt(expiresDt) > parseInt(nowDt))) return [3, 1];
|
|
75
|
+
return [2, this.auth.get('bearer_token')];
|
|
76
|
+
case 1: return [4, this.au10001()];
|
|
77
|
+
case 2:
|
|
78
|
+
response = _a.sent();
|
|
79
|
+
expiresDt_1 = response.expires_dt;
|
|
80
|
+
bearerToken = "".concat(response.token_type, " ").concat(response.token);
|
|
81
|
+
this.auth.set('expires_dt', expiresDt_1);
|
|
82
|
+
this.auth.set('bearer_token', bearerToken);
|
|
83
|
+
return [2, bearerToken];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
};
|
|
62
88
|
Oauth2.prototype.au10001 = function () {
|
|
63
89
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
90
|
var response, e_1;
|
|
@@ -66,6 +92,7 @@ var Oauth2 = (function () {
|
|
|
66
92
|
switch (_a.label) {
|
|
67
93
|
case 0:
|
|
68
94
|
_a.trys.push([0, 2, , 3]);
|
|
95
|
+
this.body.grant_type = 'client_credentials';
|
|
69
96
|
return [4, this.httpService.axiosRef.post('https://api.kiwoom.com/oauth2/token', this.body, { headers: this.headers })];
|
|
70
97
|
case 1:
|
|
71
98
|
response = _a.sent();
|
|
@@ -78,13 +105,14 @@ var Oauth2 = (function () {
|
|
|
78
105
|
});
|
|
79
106
|
});
|
|
80
107
|
};
|
|
81
|
-
Oauth2.prototype.au10002 = function () {
|
|
108
|
+
Oauth2.prototype.au10002 = function (token) {
|
|
82
109
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
110
|
var response, e_2;
|
|
84
111
|
return __generator(this, function (_a) {
|
|
85
112
|
switch (_a.label) {
|
|
86
113
|
case 0:
|
|
87
114
|
_a.trys.push([0, 2, , 3]);
|
|
115
|
+
this.body.token = token;
|
|
88
116
|
return [4, this.httpService.axiosRef.post('https://api.kiwoom.com/oauth2/revoke', this.body, { headers: this.headers })];
|
|
89
117
|
case 1:
|
|
90
118
|
response = _a.sent();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"oauth2.service.js","sourceRoot":"","sources":["../../src/services/oauth2.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"oauth2.service.js","sourceRoot":"","sources":["../../src/services/oauth2.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yCAAgG;AAChG,wDAA4D;AAE5D,uCAA4C;AAC5C,6BAA+B;AAgB/B;IAKC,gBACiD,MAAqB,EACpD,WAAwB;QADO,WAAM,GAAN,MAAM,CAAe;QACpD,gBAAW,GAAX,WAAW,CAAa;QAEzC,IAAI,CAAC,OAAO,GAAG,EAAE,cAAc,EAAE,gCAAgC,EAAE,CAAC;QACpE,IAAI,CAAC,IAAI,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,EAAE,CAAC;IAC9E,CAAC;IAED,6BAAY,GAAZ;QACC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;IAEK,+BAAc,GAApB;;;;;;wBACO,SAAS,GAAW,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;wBAChD,KAAK,GAAW,KAAK,EAAE,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;6BAEnD,CAAA,QAAQ,CAAC,SAAS,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA,EAArC,cAAqC;wBACxC,WAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,cAAc,CAAC,EAAC;4BAEpB,WAAM,IAAI,CAAC,OAAO,EAAE,EAAA;;wBAA/B,QAAQ,GAAG,SAAoB;wBAC/B,cAAY,QAAQ,CAAC,UAAU,CAAC;wBAChC,WAAW,GA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 -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-wrapper-kiwoom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,7 +30,8 @@
|
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@nestjs/axios": "^4.0.1",
|
|
32
32
|
"@nestjs/common": "^11.1.8",
|
|
33
|
-
"axios": "^1.13.2"
|
|
33
|
+
"axios": "^1.13.2",
|
|
34
|
+
"dayjs": "^1.11.19"
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"build": "rimraf ./dist && tsc -p tsconfig.lib.json",
|
package/dist/kiwoom.service.d.ts
DELETED
package/dist/kiwoom.service.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
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;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.KiwoomService = void 0;
|
|
10
|
-
var common_1 = require("@nestjs/common");
|
|
11
|
-
var KiwoomService = (function () {
|
|
12
|
-
function KiwoomService() {
|
|
13
|
-
}
|
|
14
|
-
KiwoomService = __decorate([
|
|
15
|
-
(0, common_1.Injectable)()
|
|
16
|
-
], KiwoomService);
|
|
17
|
-
return KiwoomService;
|
|
18
|
-
}());
|
|
19
|
-
exports.KiwoomService = KiwoomService;
|
|
20
|
-
//# sourceMappingURL=kiwoom.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"kiwoom.service.js","sourceRoot":"","sources":["../src/kiwoom.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,yCAA4C;AAG5C;IAAA;IAA4B,CAAC;IAAhB,aAAa;QADzB,IAAA,mBAAU,GAAE;OACA,aAAa,CAAG;IAAD,oBAAC;CAAA,AAA7B,IAA6B;AAAhB,sCAAa"}
|