@k-msg/channel 0.27.2 → 0.29.0
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/README.md +3 -2
- package/dist/toolkit/index.d.ts +0 -1
- package/dist/toolkit/index.js +23 -23
- package/dist/toolkit/index.mjs +23 -23
- package/dist/toolkit/kakao/sender-number.d.ts +0 -7
- package/dist/toolkit/services/channel.service.d.ts +1 -2
- package/dist/types/channel.types.d.ts +39 -46
- package/package.json +4 -2
- package/dist/toolkit/verification/number.verify.d.ts +0 -189
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
import { type SenderNumber, type SenderNumberCategory, type SenderNumberCreateRequest, SenderNumberStatus } from "../../types/channel.types";
|
|
2
2
|
export declare class KakaoSenderNumberManager {
|
|
3
3
|
private senderNumbers;
|
|
4
|
-
private verificationCodes;
|
|
5
4
|
addSenderNumber(channelId: string, request: SenderNumberCreateRequest): Promise<SenderNumber>;
|
|
6
5
|
private validatePhoneNumber;
|
|
7
6
|
private findSenderNumberByPhone;
|
|
8
|
-
private initiateVerification;
|
|
9
|
-
private sendVerificationSMS;
|
|
10
|
-
verifySenderNumber(senderNumberId: string, code: string): Promise<boolean>;
|
|
11
|
-
resendVerificationCode(senderNumberId: string): Promise<void>;
|
|
12
7
|
getSenderNumber(senderNumberId: string): Promise<SenderNumber | null>;
|
|
13
8
|
listSenderNumbers(filters?: {
|
|
14
9
|
channelId?: string;
|
|
@@ -26,6 +21,4 @@ export declare class KakaoSenderNumberManager {
|
|
|
26
21
|
errors: string[];
|
|
27
22
|
}>;
|
|
28
23
|
private generateSenderNumberId;
|
|
29
|
-
private generateVerificationCode;
|
|
30
|
-
cleanup(): void;
|
|
31
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ChannelConfig
|
|
1
|
+
import type { ChannelConfig } from "../../types/channel.types";
|
|
2
2
|
import { SenderNumberStatus } from "../../types/channel.types";
|
|
3
3
|
export interface ServiceSenderNumber {
|
|
4
4
|
phoneNumber: string;
|
|
@@ -16,7 +16,6 @@ export declare class ChannelService {
|
|
|
16
16
|
updateChannel(channelId: string, updates: Partial<ChannelConfig>): Promise<ChannelConfig>;
|
|
17
17
|
deleteChannel(channelId: string): Promise<void>;
|
|
18
18
|
addSenderNumber(channelId: string, phoneNumber: string, name?: string): Promise<ServiceSenderNumber>;
|
|
19
|
-
verifySenderNumber(phoneNumber: string): Promise<ChannelVerificationResult>;
|
|
20
19
|
getSenderNumbers(channelId?: string): Promise<ServiceSenderNumber[]>;
|
|
21
20
|
private generateChannelId;
|
|
22
21
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { z } from "zod";
|
|
1
|
+
import { z } from "zod/mini";
|
|
2
2
|
export interface Channel {
|
|
3
3
|
id: string;
|
|
4
4
|
name: string;
|
|
@@ -36,7 +36,6 @@ export interface SenderNumber {
|
|
|
36
36
|
channelId?: string;
|
|
37
37
|
phoneNumber: string;
|
|
38
38
|
status: SenderNumberStatus;
|
|
39
|
-
verificationCode?: string;
|
|
40
39
|
verifiedAt?: Date;
|
|
41
40
|
category: SenderNumberCategory;
|
|
42
41
|
metadata: {
|
|
@@ -167,49 +166,49 @@ export interface SenderNumberFilters {
|
|
|
167
166
|
category?: SenderNumberCategory;
|
|
168
167
|
verified?: boolean;
|
|
169
168
|
}
|
|
170
|
-
export declare const ChannelCreateRequestSchema: z.
|
|
171
|
-
name: z.
|
|
172
|
-
type: z.
|
|
173
|
-
provider: z.
|
|
174
|
-
profileKey: z.
|
|
175
|
-
businessInfo: z.
|
|
176
|
-
name: z.
|
|
177
|
-
registrationNumber: z.
|
|
178
|
-
category: z.
|
|
179
|
-
contactPerson: z.
|
|
180
|
-
contactEmail: z.
|
|
181
|
-
contactPhone: z.
|
|
169
|
+
export declare const ChannelCreateRequestSchema: z.ZodMiniObject<{
|
|
170
|
+
name: z.ZodMiniString<string>;
|
|
171
|
+
type: z.ZodMiniEnum<typeof ChannelType>;
|
|
172
|
+
provider: z.ZodMiniString<string>;
|
|
173
|
+
profileKey: z.ZodMiniString<string>;
|
|
174
|
+
businessInfo: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
175
|
+
name: z.ZodMiniString<string>;
|
|
176
|
+
registrationNumber: z.ZodMiniString<string>;
|
|
177
|
+
category: z.ZodMiniString<string>;
|
|
178
|
+
contactPerson: z.ZodMiniString<string>;
|
|
179
|
+
contactEmail: z.ZodMiniEmail;
|
|
180
|
+
contactPhone: z.ZodMiniString<string>;
|
|
182
181
|
}, z.core.$strip>>;
|
|
183
|
-
kakaoInfo: z.
|
|
184
|
-
plusFriendId: z.
|
|
185
|
-
brandName: z.
|
|
186
|
-
logoUrl: z.
|
|
187
|
-
description: z.
|
|
182
|
+
kakaoInfo: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
183
|
+
plusFriendId: z.ZodMiniString<string>;
|
|
184
|
+
brandName: z.ZodMiniString<string>;
|
|
185
|
+
logoUrl: z.ZodMiniOptional<z.ZodMiniURL>;
|
|
186
|
+
description: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
188
187
|
}, z.core.$strip>>;
|
|
189
188
|
}, z.core.$strip>;
|
|
190
|
-
export declare const SenderNumberCreateRequestSchema: z.
|
|
191
|
-
phoneNumber: z.
|
|
192
|
-
category: z.
|
|
193
|
-
businessInfo: z.
|
|
194
|
-
businessName: z.
|
|
195
|
-
businessRegistrationNumber: z.
|
|
196
|
-
contactPerson: z.
|
|
197
|
-
contactEmail: z.
|
|
189
|
+
export declare const SenderNumberCreateRequestSchema: z.ZodMiniObject<{
|
|
190
|
+
phoneNumber: z.ZodMiniString<string>;
|
|
191
|
+
category: z.ZodMiniEnum<typeof SenderNumberCategory>;
|
|
192
|
+
businessInfo: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
193
|
+
businessName: z.ZodMiniString<string>;
|
|
194
|
+
businessRegistrationNumber: z.ZodMiniString<string>;
|
|
195
|
+
contactPerson: z.ZodMiniString<string>;
|
|
196
|
+
contactEmail: z.ZodMiniEmail;
|
|
198
197
|
}, z.core.$strip>>;
|
|
199
198
|
}, z.core.$strip>;
|
|
200
|
-
export declare const ChannelFiltersSchema: z.
|
|
201
|
-
provider: z.
|
|
202
|
-
type: z.
|
|
203
|
-
status: z.
|
|
204
|
-
verified: z.
|
|
205
|
-
createdAfter: z.
|
|
206
|
-
createdBefore: z.
|
|
199
|
+
export declare const ChannelFiltersSchema: z.ZodMiniObject<{
|
|
200
|
+
provider: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
201
|
+
type: z.ZodMiniOptional<z.ZodMiniEnum<typeof ChannelType>>;
|
|
202
|
+
status: z.ZodMiniOptional<z.ZodMiniEnum<typeof ChannelStatus>>;
|
|
203
|
+
verified: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
204
|
+
createdAfter: z.ZodMiniOptional<z.ZodMiniDate<Date>>;
|
|
205
|
+
createdBefore: z.ZodMiniOptional<z.ZodMiniDate<Date>>;
|
|
207
206
|
}, z.core.$strip>;
|
|
208
|
-
export declare const SenderNumberFiltersSchema: z.
|
|
209
|
-
channelId: z.
|
|
210
|
-
status: z.
|
|
211
|
-
category: z.
|
|
212
|
-
verified: z.
|
|
207
|
+
export declare const SenderNumberFiltersSchema: z.ZodMiniObject<{
|
|
208
|
+
channelId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
209
|
+
status: z.ZodMiniOptional<z.ZodMiniEnum<typeof SenderNumberStatus>>;
|
|
210
|
+
category: z.ZodMiniOptional<z.ZodMiniEnum<typeof SenderNumberCategory>>;
|
|
211
|
+
verified: z.ZodMiniOptional<z.ZodMiniBoolean<boolean>>;
|
|
213
212
|
}, z.core.$strip>;
|
|
214
213
|
export type ChannelCreateRequestType = z.infer<typeof ChannelCreateRequestSchema>;
|
|
215
214
|
export type SenderNumberCreateRequestType = z.infer<typeof SenderNumberCreateRequestSchema>;
|
|
@@ -221,13 +220,7 @@ export interface ChannelConfig {
|
|
|
221
220
|
type: "alimtalk" | "sms" | "lms" | "friendtalk";
|
|
222
221
|
providerId: string;
|
|
223
222
|
active: boolean;
|
|
224
|
-
settings: Record<string,
|
|
223
|
+
settings: Record<string, unknown>;
|
|
225
224
|
createdAt: Date;
|
|
226
225
|
updatedAt: Date;
|
|
227
226
|
}
|
|
228
|
-
export interface ChannelVerificationResult {
|
|
229
|
-
success: boolean;
|
|
230
|
-
status: string;
|
|
231
|
-
verificationCode?: string;
|
|
232
|
-
error?: string;
|
|
233
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@k-msg/channel",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.29.0",
|
|
4
4
|
"packageManager": "bun@1.3.8",
|
|
5
5
|
"description": "AlimTalk channel and sender number management",
|
|
6
6
|
"type": "module",
|
|
@@ -29,12 +29,14 @@
|
|
|
29
29
|
"build:types": "tsc",
|
|
30
30
|
"dev": "tsc --watch",
|
|
31
31
|
"test": "bun test",
|
|
32
|
+
"test:unit": "bun test --testPathPattern='.*\\.test\\.(ts|js)$' --testTimeout=5000",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
32
34
|
"clean": "rm -rf dist tsconfig.tsbuildinfo",
|
|
33
35
|
"pack": "bun pm pack",
|
|
34
36
|
"publish": "bun publish --access public"
|
|
35
37
|
},
|
|
36
38
|
"dependencies": {
|
|
37
|
-
"@k-msg/core": "0.
|
|
39
|
+
"@k-msg/core": "0.29.0",
|
|
38
40
|
"zod": "^4.0.14"
|
|
39
41
|
},
|
|
40
42
|
"devDependencies": {
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Phone Number Verification System
|
|
3
|
-
* 발신번호 인증 및 검증 시스템
|
|
4
|
-
*/
|
|
5
|
-
import { EventEmitter } from "../shared/event-emitter";
|
|
6
|
-
export interface PhoneVerificationRequest {
|
|
7
|
-
id: string;
|
|
8
|
-
senderNumberId: string;
|
|
9
|
-
phoneNumber: string;
|
|
10
|
-
verificationType: VerificationType;
|
|
11
|
-
verificationCode: string;
|
|
12
|
-
status: PhoneVerificationStatus;
|
|
13
|
-
attempts: VerificationAttempt[];
|
|
14
|
-
expiresAt: Date;
|
|
15
|
-
createdAt: Date;
|
|
16
|
-
completedAt?: Date;
|
|
17
|
-
metadata: {
|
|
18
|
-
userAgent?: string;
|
|
19
|
-
ipAddress?: string;
|
|
20
|
-
deviceId?: string;
|
|
21
|
-
smsProvider?: string;
|
|
22
|
-
callProvider?: string;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
|
-
export interface VerificationAttempt {
|
|
26
|
-
/**
|
|
27
|
-
* Distinguish provider/send attempts from user verification attempts.
|
|
28
|
-
* This prevents send failures from consuming user attempt limits.
|
|
29
|
-
*/
|
|
30
|
-
purpose?: "send" | "verify";
|
|
31
|
-
attemptNumber: number;
|
|
32
|
-
attemptedAt: Date;
|
|
33
|
-
method: VerificationMethod;
|
|
34
|
-
status: "sent" | "delivered" | "failed" | "verified" | "expired";
|
|
35
|
-
failureReason?: string;
|
|
36
|
-
responseTime?: number;
|
|
37
|
-
}
|
|
38
|
-
export declare enum VerificationType {
|
|
39
|
-
SMS = "sms",
|
|
40
|
-
VOICE_CALL = "voice_call",
|
|
41
|
-
HYBRID = "hybrid"
|
|
42
|
-
}
|
|
43
|
-
export declare enum VerificationMethod {
|
|
44
|
-
SMS = "sms",
|
|
45
|
-
VOICE_CALL = "voice_call",
|
|
46
|
-
MISSED_CALL = "missed_call"
|
|
47
|
-
}
|
|
48
|
-
export declare enum PhoneVerificationStatus {
|
|
49
|
-
PENDING = "pending",
|
|
50
|
-
CODE_SENT = "code_sent",
|
|
51
|
-
VERIFIED = "verified",
|
|
52
|
-
FAILED = "failed",
|
|
53
|
-
EXPIRED = "expired",
|
|
54
|
-
BLOCKED = "blocked"
|
|
55
|
-
}
|
|
56
|
-
export interface NumberVerifierOptions {
|
|
57
|
-
codeLength: number;
|
|
58
|
-
codeExpiryMinutes: number;
|
|
59
|
-
maxAttempts: number;
|
|
60
|
-
maxDailyAttempts: number;
|
|
61
|
-
smsTemplate: string;
|
|
62
|
-
voiceTemplate: string;
|
|
63
|
-
rateLimitMinutes: number;
|
|
64
|
-
enableVoiceFallback: boolean;
|
|
65
|
-
enableMissedCallVerification: boolean;
|
|
66
|
-
blockedNumbers: string[];
|
|
67
|
-
allowedCountries: string[];
|
|
68
|
-
smsProvider?: SMSProvider;
|
|
69
|
-
voiceProvider?: VoiceProvider;
|
|
70
|
-
}
|
|
71
|
-
export interface SMSProvider {
|
|
72
|
-
id: string;
|
|
73
|
-
name: string;
|
|
74
|
-
sendSMS(phoneNumber: string, message: string, options?: unknown): Promise<SMSResult>;
|
|
75
|
-
getDeliveryStatus?(messageId: string): Promise<DeliveryStatus>;
|
|
76
|
-
}
|
|
77
|
-
export interface VoiceProvider {
|
|
78
|
-
id: string;
|
|
79
|
-
name: string;
|
|
80
|
-
makeCall(phoneNumber: string, message: string, options?: unknown): Promise<VoiceResult>;
|
|
81
|
-
makeMissedCall?(phoneNumber: string, options?: unknown): Promise<MissedCallResult>;
|
|
82
|
-
}
|
|
83
|
-
export interface SMSResult {
|
|
84
|
-
messageId: string;
|
|
85
|
-
status: "sent" | "failed";
|
|
86
|
-
cost?: number;
|
|
87
|
-
error?: string;
|
|
88
|
-
}
|
|
89
|
-
export interface VoiceResult {
|
|
90
|
-
callId: string;
|
|
91
|
-
status: "initiated" | "answered" | "failed" | "busy" | "no_answer";
|
|
92
|
-
duration?: number;
|
|
93
|
-
cost?: number;
|
|
94
|
-
error?: string;
|
|
95
|
-
}
|
|
96
|
-
export interface MissedCallResult {
|
|
97
|
-
callId: string;
|
|
98
|
-
status: "initiated" | "completed" | "failed";
|
|
99
|
-
missedCallNumber?: string;
|
|
100
|
-
error?: string;
|
|
101
|
-
}
|
|
102
|
-
export interface DeliveryStatus {
|
|
103
|
-
messageId: string;
|
|
104
|
-
status: "pending" | "delivered" | "failed" | "expired";
|
|
105
|
-
deliveredAt?: Date;
|
|
106
|
-
failureReason?: string;
|
|
107
|
-
}
|
|
108
|
-
export interface PhoneNumberInfo {
|
|
109
|
-
phoneNumber: string;
|
|
110
|
-
countryCode: string;
|
|
111
|
-
nationalNumber: string;
|
|
112
|
-
carrier?: string;
|
|
113
|
-
lineType?: "mobile" | "landline" | "voip" | "unknown";
|
|
114
|
-
isValid: boolean;
|
|
115
|
-
isPossible: boolean;
|
|
116
|
-
region?: string;
|
|
117
|
-
}
|
|
118
|
-
export declare class NumberVerifier extends EventEmitter {
|
|
119
|
-
private options;
|
|
120
|
-
private verificationRequests;
|
|
121
|
-
private phoneNumberCache;
|
|
122
|
-
private rateLimitTracker;
|
|
123
|
-
private dailyAttemptTracker;
|
|
124
|
-
private blockedNumbers;
|
|
125
|
-
private defaultOptions;
|
|
126
|
-
constructor(options?: Partial<NumberVerifierOptions>);
|
|
127
|
-
/**
|
|
128
|
-
* Start phone number verification process
|
|
129
|
-
*/
|
|
130
|
-
startVerification(senderNumberId: string, phoneNumber: string, verificationType?: VerificationType, metadata?: PhoneVerificationRequest["metadata"]): Promise<PhoneVerificationRequest>;
|
|
131
|
-
/**
|
|
132
|
-
* Verify the provided code
|
|
133
|
-
*/
|
|
134
|
-
verifyCode(requestId: string, providedCode: string): Promise<{
|
|
135
|
-
success: boolean;
|
|
136
|
-
status: PhoneVerificationStatus;
|
|
137
|
-
message: string;
|
|
138
|
-
}>;
|
|
139
|
-
/**
|
|
140
|
-
* Resend verification code
|
|
141
|
-
*/
|
|
142
|
-
resendCode(requestId: string, method?: VerificationMethod): Promise<PhoneVerificationRequest>;
|
|
143
|
-
/**
|
|
144
|
-
* Get verification request status
|
|
145
|
-
*/
|
|
146
|
-
getVerificationStatus(requestId: string): PhoneVerificationRequest | null;
|
|
147
|
-
/**
|
|
148
|
-
* Cancel verification request
|
|
149
|
-
*/
|
|
150
|
-
cancelVerification(requestId: string): Promise<boolean>;
|
|
151
|
-
/**
|
|
152
|
-
* Block a phone number from verification
|
|
153
|
-
*/
|
|
154
|
-
blockPhoneNumber(phoneNumber: string, reason?: string): void;
|
|
155
|
-
/**
|
|
156
|
-
* Unblock a phone number
|
|
157
|
-
*/
|
|
158
|
-
unblockPhoneNumber(phoneNumber: string): void;
|
|
159
|
-
/**
|
|
160
|
-
* Get verification statistics
|
|
161
|
-
*/
|
|
162
|
-
getVerificationStats(): {
|
|
163
|
-
total: number;
|
|
164
|
-
byStatus: Record<string, number>;
|
|
165
|
-
byMethod: Record<string, number>;
|
|
166
|
-
successRate: number;
|
|
167
|
-
averageCompletionTime: number;
|
|
168
|
-
};
|
|
169
|
-
/**
|
|
170
|
-
* Clean up expired verification requests
|
|
171
|
-
*/
|
|
172
|
-
cleanup(): number;
|
|
173
|
-
private sendVerificationCode;
|
|
174
|
-
private sendVerificationByMethod;
|
|
175
|
-
private sendSMS;
|
|
176
|
-
private sendVoiceCall;
|
|
177
|
-
private sendMissedCall;
|
|
178
|
-
private getPhoneNumberInfo;
|
|
179
|
-
private parseKoreanPhoneNumber;
|
|
180
|
-
private isNumberBlocked;
|
|
181
|
-
private isRateLimited;
|
|
182
|
-
private isDailyLimitExceeded;
|
|
183
|
-
private updateRateLimit;
|
|
184
|
-
private updateDailyAttempts;
|
|
185
|
-
private normalizePhoneNumber;
|
|
186
|
-
private validateCode;
|
|
187
|
-
private generateVerificationCode;
|
|
188
|
-
private generateRequestId;
|
|
189
|
-
}
|