nest-wrapper-kiwoom 1.0.8 → 1.0.10
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 +16 -2
- package/dist/services/oauth2.service.js +27 -2
- package/dist/services/oauth2.service.js.map +1 -1
- package/package.json +4 -3
- 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,25 @@
|
|
|
1
1
|
import { KiwoomOptions } from '../interfaces';
|
|
2
2
|
import { HttpService } from '@nestjs/axios';
|
|
3
|
+
interface AU10001Response {
|
|
4
|
+
expires_dt: string;
|
|
5
|
+
return_msg: string;
|
|
6
|
+
token_type: string;
|
|
7
|
+
return_code: number;
|
|
8
|
+
token: string;
|
|
9
|
+
}
|
|
10
|
+
interface AU10002Response {
|
|
11
|
+
return_msg: string;
|
|
12
|
+
return_code: number;
|
|
13
|
+
}
|
|
3
14
|
export declare class Oauth2 {
|
|
4
15
|
private readonly option;
|
|
5
16
|
private readonly httpService;
|
|
6
17
|
private readonly headers;
|
|
7
18
|
private readonly body;
|
|
19
|
+
private readonly auth;
|
|
8
20
|
constructor(option: KiwoomOptions, httpService: HttpService);
|
|
9
|
-
|
|
10
|
-
|
|
21
|
+
getBearerToken(): Promise<string>;
|
|
22
|
+
au10001(): Promise<AU10001Response>;
|
|
23
|
+
au10002(token: string): Promise<AU10002Response>;
|
|
11
24
|
}
|
|
25
|
+
export {};
|
|
@@ -52,13 +52,36 @@ 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.getBearerToken = function () {
|
|
64
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
65
|
+
var expiresDt, nowDt, response, expiresDt_1, bearerToken;
|
|
66
|
+
return __generator(this, function (_a) {
|
|
67
|
+
switch (_a.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
expiresDt = this.auth.get('expires_dt');
|
|
70
|
+
nowDt = dayjs().format('YYYYMMDDHHmmss');
|
|
71
|
+
if (!(parseInt(expiresDt) > parseInt(nowDt))) return [3, 1];
|
|
72
|
+
return [2, this.auth.get('bearer_token')];
|
|
73
|
+
case 1: return [4, this.au10001()];
|
|
74
|
+
case 2:
|
|
75
|
+
response = _a.sent();
|
|
76
|
+
expiresDt_1 = response.expires_dt;
|
|
77
|
+
bearerToken = "".concat(response.token_type, " ").concat(response.token);
|
|
78
|
+
this.auth.set('expires_dt', expiresDt_1);
|
|
79
|
+
this.auth.set('bearer_token', bearerToken);
|
|
80
|
+
return [2, bearerToken];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
};
|
|
62
85
|
Oauth2.prototype.au10001 = function () {
|
|
63
86
|
return __awaiter(this, void 0, void 0, function () {
|
|
64
87
|
var response, e_1;
|
|
@@ -66,6 +89,7 @@ var Oauth2 = (function () {
|
|
|
66
89
|
switch (_a.label) {
|
|
67
90
|
case 0:
|
|
68
91
|
_a.trys.push([0, 2, , 3]);
|
|
92
|
+
this.body.grant_type = 'client_credentials';
|
|
69
93
|
return [4, this.httpService.axiosRef.post('https://api.kiwoom.com/oauth2/token', this.body, { headers: this.headers })];
|
|
70
94
|
case 1:
|
|
71
95
|
response = _a.sent();
|
|
@@ -78,13 +102,14 @@ var Oauth2 = (function () {
|
|
|
78
102
|
});
|
|
79
103
|
});
|
|
80
104
|
};
|
|
81
|
-
Oauth2.prototype.au10002 = function () {
|
|
105
|
+
Oauth2.prototype.au10002 = function (token) {
|
|
82
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
83
107
|
var response, e_2;
|
|
84
108
|
return __generator(this, function (_a) {
|
|
85
109
|
switch (_a.label) {
|
|
86
110
|
case 0:
|
|
87
111
|
_a.trys.push([0, 2, , 3]);
|
|
112
|
+
this.body.token = token;
|
|
88
113
|
return [4, this.httpService.axiosRef.post('https://api.kiwoom.com/oauth2/revoke', this.body, { headers: this.headers })];
|
|
89
114
|
case 1:
|
|
90
115
|
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":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;;;;;wBAEE,IAAI,CAAC,IAAI,CAAC,UAAU,GAAG,oBAAoB,CAAC;wBAE3B,WAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,qCAAqC,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,EAAA;;wBAA5H,QAAQ,GAAG,SAAiH;wBAClI,WAAO,QAAQ,CAAC,IAAuB,EAAC;;;wBAExC,MAAM,IAAI,qCAA4B,CAAC,GAAC,CAAC,OAAO,CAAC,CAAC;;;;;KAEnD;IAEK,wBAAO,GAAb,UAAc,KAAa;;;;;;;wBAEzB,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;wBAEP,WAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,sCAAsC,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC,EAAA;;wBAA7H,QAAQ,GAAG,SAAkH;wBACnI,WAAO,QAAQ,CAAC,IAAuB,EAAC;;;wBAExC,MAAM,IAAI,qCAA4B,CAAC,GAAC,CAAC,OAAO,CAAC,CAAC;;;;;KAEnD;IAjDW,MAAM;QADlB,IAAA,mBAAU,GAAE;QAOV,WAAA,IAAA,eAAM,EAAC,wCAAqB,CAAC,CAAA;iDACA,mBAAW;OAP9B,MAAM,CAkDlB;IAAD,aAAC;CAAA,AAnDD,IAmDC;AAlDY,wBAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nest-wrapper-kiwoom",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -30,12 +30,13 @@
|
|
|
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",
|
|
37
38
|
"lint": "eslint .",
|
|
38
39
|
"format": "prettier --write 'src/**/*.ts'",
|
|
39
|
-
"release": "pnpm publish --access public"
|
|
40
|
+
"release": "pnpm build && pnpm publish --access public"
|
|
40
41
|
}
|
|
41
42
|
}
|
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"}
|