Skip to content

Commit d0c77a6

Browse files
Merge pull request #64 from Palbahngmiyine/master
SOLAPI 5.4.0-beta.0
2 parents 4d4de0c + ee1c193 commit d0c77a6

File tree

17 files changed

+3620
-2909
lines changed

17 files changed

+3620
-2909
lines changed

.eslintrc

Lines changed: 0 additions & 40 deletions
This file was deleted.

.yarn/releases/yarn-3.2.3.cjs

Lines changed: 0 additions & 783 deletions
This file was deleted.

.yarn/releases/yarn-4.6.0.cjs

Lines changed: 934 additions & 0 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
4+
15
nodeLinker: node-modules
26

3-
yarnPath: .yarn/releases/yarn-3.2.3.cjs
7+
yarnPath: .yarn/releases/yarn-4.6.0.cjs

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
MIT License
22
-----------
33

4-
Copyright (c) 2022~ Nurigo Inc (https://solapi.com)
4+
Copyright (c) 2022~ SOLAPI Inc (https://solapi.com)
55
Permission is hereby granted, free of charge, to any person
66
obtaining a copy of this software and associated documentation
77
files (the "Software"), to deal in the Software without

eslint.config.mjs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import typescriptEslintEslintPlugin from '@typescript-eslint/eslint-plugin';
2+
import tsdoc from 'eslint-plugin-tsdoc';
3+
import unusedImports from 'eslint-plugin-unused-imports';
4+
import globals from 'globals';
5+
import tsParser from '@typescript-eslint/parser';
6+
import path from 'node:path';
7+
import {fileURLToPath} from 'node:url';
8+
import js from '@eslint/js';
9+
import {FlatCompat} from '@eslint/eslintrc';
10+
11+
const __filename = fileURLToPath(import.meta.url);
12+
const __dirname = path.dirname(__filename);
13+
const compat = new FlatCompat({
14+
baseDirectory: __dirname,
15+
recommendedConfig: js.configs.recommended,
16+
allConfig: js.configs.all,
17+
});
18+
19+
export default [
20+
{
21+
ignores: ['dist/**/*', 'examples/**/*', 'debug/**/*', 'docs/**/*'],
22+
},
23+
...compat.extends('plugin:@typescript-eslint/recommended'),
24+
{
25+
plugins: {
26+
'@typescript-eslint': typescriptEslintEslintPlugin,
27+
tsdoc,
28+
'unused-imports': unusedImports,
29+
},
30+
31+
languageOptions: {
32+
globals: {
33+
...globals.node,
34+
},
35+
parser: tsParser,
36+
ecmaVersion: 2018,
37+
sourceType: 'module',
38+
},
39+
40+
rules: {
41+
quotes: ['error', 'single'],
42+
semi: [2, 'always'],
43+
'@typescript-eslint/explicit-function-return-type': 'off',
44+
'@typescript-eslint/no-explicit-any': 1,
45+
46+
'@typescript-eslint/no-inferrable-types': [
47+
'warn',
48+
{
49+
ignoreParameters: true,
50+
},
51+
],
52+
53+
'@typescript-eslint/no-unused-vars': 'warn',
54+
'unused-imports/no-unused-imports': 'warn',
55+
},
56+
},
57+
];

package.json

Lines changed: 60 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
{
22
"name": "solapi",
3-
"version": "5.3.1",
3+
"version": "5.4.0-beta.0",
44
"description": "SOLAPI SDK for Node.js(Server Side Only)",
5-
"repository": {
6-
"type": "git",
7-
"url": "git+https://github.com/solapi/solapi-nodejs.git"
8-
},
95
"keywords": [
106
"solapi",
117
"sms",
@@ -15,56 +11,76 @@
1511
"sdk",
1612
"korean sms"
1713
],
14+
"homepage": "https://solapi.com",
15+
"bugs": {
16+
"url": "https://github.com/solapi/solapi-nodejs/issues"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/solapi/solapi-nodejs.git"
21+
},
22+
"license": "MIT",
1823
"author": {
19-
"name": "Nurigo Team",
20-
"email": "contact@nurigo.net"
24+
"name": "SOLAPI Team",
25+
"email": "contact@solapi.com"
2126
},
27+
"type": "commonjs",
2228
"source": "src/solapi.ts",
2329
"main": "dist/index.js",
2430
"types": "dist/index.d.ts",
25-
"license": "MIT",
26-
"bugs": {
27-
"url": "https://github.com/solapi/solapi-nodejs/issues"
28-
},
29-
"homepage": "https://solapi.github.io/solapi-nodejs",
31+
"module": "dist/index.module.js",
32+
"files": [
33+
"/dist"
34+
],
3035
"scripts": {
36+
"build": "yarn clean && yarn lint && parcel build",
3137
"clean": "rimraf dist",
32-
"build": "yarn clean && parcel build --no-source-maps",
33-
"watch": "parcel watch",
34-
"docs": "typedoc --entryPointStrategy expand ./src"
35-
},
36-
"engines": {
37-
"node": ">=14",
38-
"parcel": "2.x"
38+
"docs": "typedoc --entryPointStrategy expand ./src",
39+
"format": "prettier ./**/*.ts ./**/*.js ./**/*.mjs",
40+
"lint": "eslint .",
41+
"watch": "parcel watch"
3942
},
4043
"dependencies": {
41-
"cross-fetch": "^3.1.5",
42-
"crypto-js": "^4.1.1",
43-
"date-fns": "^2.29.3",
44+
"date-fns": "^4.1.0",
4445
"image-to-base64": "^2.2.0",
45-
"nanoid": "^3.3.4",
46-
"qs": "^6.11.0"
46+
"qs": "^6.14.0"
4747
},
4848
"devDependencies": {
49-
"@parcel/packager-ts": "2.8.1",
50-
"@parcel/transformer-typescript-types": "2.8.1",
51-
"@types/crypto-js": "^4.1.1",
52-
"@types/image-to-base64": "^2.1.0",
53-
"@types/node": "^18.11.13",
54-
"@types/qs": "^6.9.7",
55-
"@typescript-eslint/eslint-plugin": "^5.46.1",
56-
"@typescript-eslint/parser": "^5.46.1",
57-
"eslint": "^8.29.0",
58-
"eslint-plugin-tsdoc": "^0.2.17",
59-
"eslint-plugin-unused-imports": "^2.0.0",
60-
"parcel": "^2.8.1",
61-
"prettier": "^2.8.1",
62-
"rimraf": "^3.0.2",
63-
"typedoc": "^0.23.22",
64-
"typescript": "^4.9.4"
49+
"@eslint/eslintrc": "^3.3.0",
50+
"@eslint/js": "^9.21.0",
51+
"@parcel/packager-ts": "^2.13.3",
52+
"@parcel/transformer-typescript-tsc": "^2.13.3",
53+
"@parcel/transformer-typescript-types": "^2.13.3",
54+
"@parcel/validator-typescript": "^2.13.3",
55+
"@types/crypto-js": "^4.2.2",
56+
"@types/image-to-base64": "^2.1.2",
57+
"@types/node": "^22.13.5",
58+
"@types/qs": "^6.9.18",
59+
"@typescript-eslint/eslint-plugin": "^8.25.0",
60+
"@typescript-eslint/parser": "^8.25.0",
61+
"eslint": "^9.21.0",
62+
"eslint-plugin-tsdoc": "^0.4.0",
63+
"eslint-plugin-unused-imports": "^4.1.4",
64+
"globals": "^16.0.0",
65+
"parcel": "^2.13.3",
66+
"prettier": "^3.5.2",
67+
"rimraf": "^6.0.1",
68+
"typedoc": "^0.27.9",
69+
"typescript": "^5.7.3"
6570
},
66-
"files": [
67-
"/dist"
68-
],
69-
"packageManager": "yarn@3.2.3"
71+
"packageManager": "yarn@4.6.0",
72+
"engines": {
73+
"node": ">=18",
74+
"parcel": "2.x"
75+
},
76+
"targets": {
77+
"main": {
78+
"outputFormat": "commonjs",
79+
"optimize": true
80+
},
81+
"module": {
82+
"outputFormat": "esmodule",
83+
"optimize": true
84+
}
85+
}
7086
}

src/lib/authenticator.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
import {customAlphabet} from 'nanoid';
21
import {formatISO} from 'date-fns';
3-
import {HmacSHA256} from 'crypto-js';
2+
import {createHmac, randomBytes} from 'node:crypto';
43
import {ApiKeyError} from '../errors/defaultError';
54

65
enum AuthenticateType {
@@ -12,6 +11,20 @@ export type AuthenticationParameter = {
1211
apiSecret?: string;
1312
};
1413

14+
/**
15+
* 특정 사이즈의 텍스트를 생성합니다.
16+
* @param alphabet 지정할 알파벳/숫자 문자열
17+
* @param size 지정할 문자 길이
18+
*/
19+
function genCustomText(alphabet: string, size: number): string {
20+
const bytes = randomBytes(size);
21+
let genRandomText = '';
22+
for (let i = 0; i < size; i++) {
23+
genRandomText += alphabet[bytes[i] % alphabet.length];
24+
}
25+
return genRandomText;
26+
}
27+
1528
/**
1629
* Get Authenticate Information for SOLAPI Requests
1730
* @param authenticationParameter
@@ -26,16 +39,18 @@ export default function getAuthInfo(
2639
switch (authType) {
2740
case AuthenticateType.API_KEY:
2841
default:
29-
const salt = customAlphabet(
42+
const salt = genCustomText(
3043
'1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
3144
32,
32-
)();
45+
);
3346
const date = formatISO(new Date());
3447
const hmacData = date + salt;
3548
if (!apiKey || !apiSecret || apiKey === '' || apiSecret === '') {
3649
throw new ApiKeyError('Invalid API Key Error');
3750
}
38-
const signature = HmacSHA256(hmacData, apiSecret).toString();
51+
const genHmac = createHmac('sha256', apiSecret);
52+
genHmac.update(hmacData);
53+
const signature = genHmac.digest('hex');
3954
return `HMAC-SHA256 apiKey=${apiKey}, date=${date}, salt=${salt}, signature=${signature}`;
4055
}
4156
}

src/lib/defaultFetcher.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import getAuthInfo, {AuthenticationParameter} from './authenticator';
2-
import fetch from 'cross-fetch';
32
import {DefaultError, ErrorResponse} from '../errors/defaultError';
43

54
type DefaultRequest = {
@@ -36,11 +35,12 @@ export default async function defaultFetcher<T, R>(
3635
);
3736
} else if (res.status >= 500) {
3837
const responseText = await res.text();
39-
throw new DefaultError('UnknownException', responseText);
38+
throw new DefaultError('UnknownError', responseText);
4039
}
4140
try {
4241
return res.json();
4342
} catch (exception) {
43+
console.error(exception);
4444
throw new Error(await res.text());
4545
}
4646
});

src/models/kakao/kakaoOption.ts

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,5 @@
11
import {KakaoButton} from './kakaoButton';
2-
3-
export type kakaoOptionRequest = {
4-
pfId: string;
5-
templateId?: string;
6-
variables?: Record<string, string>;
7-
disableSms?: boolean;
8-
adFlag?: boolean;
9-
buttons?: Array<KakaoButton>;
10-
imageId?: string;
11-
};
2+
import {kakaoOptionRequest} from '../../requests/kakao/kakaoOptionRequest';
123

134
export class KakaoOption {
145
pfId: string;

0 commit comments

Comments
 (0)