Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
SoleeChoi committed Dec 4, 2020
2 parents d404a55 + 14b78d6 commit 187a11b
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 9 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
NodeJS용 아임포트 REST API Client 입니다.

## 버전정보
최신 버전은 [v0.9.5](https://github.com/iamport/rest-client-nodejs/tree/v0.9.5)입니다.
최신 버전은 [v0.9.6](https://github.com/iamport/rest-client-nodejs/tree/v0.9.6)입니다.

## 설치하기
아래 명령어를 통해 `iamport-rest-client-nodejs`를 귀하의 nodeJS 프로젝트에 추가합니다.
Expand Down
13 changes: 8 additions & 5 deletions lib/Iamport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import * as Request from './request';
import * as Response from './response';
import * as Enum from './enum';

import { BASE_URL, EXPIRE_BUFFER } from './constants';
import { BASE_URL, EXPIRE_BUFFER, USER_AGENT } from './constants';
import { Headers } from './Interfaces';

interface IamportProperties {
Expand Down Expand Up @@ -56,7 +56,10 @@ export class Iamport {
}

const { access_token } = this.token;
return { Authorization: `Bearer ${access_token}` };
return {
Authorization: `Bearer ${access_token}`,
'User-Agent': USER_AGENT,
};
}

private getToken(): Promise<any> {
Expand All @@ -69,9 +72,9 @@ export class Iamport {

private isTokenValid(): boolean {
if (this.token && this.token.access_token) {
const { now, expired_at } = this.token;
// 토큰의 유효시각 > 아임포트 서버의 시각 + 서버 시차 고려한 버퍼 값(30초)
return expired_at > now + EXPIRE_BUFFER;
const { expired_at } = this.token;
// 토큰의 유효시각 > 가맹점 웹서버 시각 + 아임포트 서버와의 시차 고려한 버퍼 값(30초)
return expired_at * 1000 > new Date().getTime() + EXPIRE_BUFFER;
}
return false;
}
Expand Down
1 change: 1 addition & 0 deletions lib/Interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export type Method = 'GET' | 'POST' | 'PUT' | 'DELETE'

export interface Headers {
Authorization: string,
'User-Agent': string,
}

export interface Config {
Expand Down
3 changes: 2 additions & 1 deletion lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const BASE_URL: string = 'https://api.iamport.kr';
export const EXPIRE_BUFFER: number = 30;
export const EXPIRE_BUFFER: number = 30000;
export const USER_AGENT: string = 'iamport-rest-client-nodejs/v0.9.6';
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "iamport-rest-client-nodejs",
"version": "0.9.5",
"version": "0.9.6",
"description": "NodeJS용 아임포트 REST API Client 입니다.",
"main": "dist/Iamport.js",
"types": "dist/Iamport.d.ts",
Expand Down

0 comments on commit 187a11b

Please sign in to comment.