@nauth-toolkit/sms-console 0.1.14 → 0.1.18
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/console-sms.provider.d.ts +77 -0
- package/dist/console-sms.provider.d.ts.map +1 -1
- package/dist/console-sms.provider.js +89 -0
- package/dist/console-sms.provider.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/test-sms-storage.provider.d.ts +12 -0
- package/dist/test-sms-storage.provider.d.ts.map +1 -1
- package/dist/test-sms-storage.provider.js +10 -0
- package/dist/test-sms-storage.provider.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,15 +1,92 @@
|
|
|
1
1
|
import { SMSProvider, NAuthLogger, SMSTemplateEngine, SMSTemplateVariables } from '@nauth-toolkit/core';
|
|
2
|
+
/**
|
|
3
|
+
* Console SMS Provider (Platform-Agnostic)
|
|
4
|
+
*
|
|
5
|
+
* Development-only SMS provider that logs messages to console instead of sending real SMS.
|
|
6
|
+
*
|
|
7
|
+
* This is a plain TypeScript class with no framework dependencies.
|
|
8
|
+
* Works with any framework (NestJS, Express, Fastify, etc.)
|
|
9
|
+
*
|
|
10
|
+
* **Use Case:**
|
|
11
|
+
* - Development and testing environments
|
|
12
|
+
* - No external dependencies required
|
|
13
|
+
* - See SMS content without sending actual messages
|
|
14
|
+
*
|
|
15
|
+
* **Security Note:**
|
|
16
|
+
* - NEVER use in production (exposes sensitive codes in logs)
|
|
17
|
+
* - For production, use real SMS providers like Twilio, AWS SNS, MessageBird
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```typescript
|
|
21
|
+
* // In AuthModule configuration
|
|
22
|
+
* AuthModule.forRoot({
|
|
23
|
+
* sms: {
|
|
24
|
+
* provider: new ConsoleSMSProvider(),
|
|
25
|
+
* },
|
|
26
|
+
* })
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
2
29
|
export declare class ConsoleSMSProvider implements SMSProvider {
|
|
3
30
|
private logger;
|
|
4
31
|
private storageCallback?;
|
|
32
|
+
/**
|
|
33
|
+
* Optional SMS template engine for customizing message content
|
|
34
|
+
*/
|
|
5
35
|
private templateEngine?;
|
|
36
|
+
/**
|
|
37
|
+
* Global variables available to all SMS templates
|
|
38
|
+
*/
|
|
6
39
|
private globalVariables;
|
|
7
40
|
constructor(logger?: NAuthLogger);
|
|
41
|
+
/**
|
|
42
|
+
* Set logger for this provider
|
|
43
|
+
* Used by auth module to inject the configured logger
|
|
44
|
+
*/
|
|
8
45
|
setLogger(logger: NAuthLogger): void;
|
|
46
|
+
/**
|
|
47
|
+
* Set storage callback for test mode
|
|
48
|
+
* Used to store SMS codes in test database for E2E testing
|
|
49
|
+
*/
|
|
9
50
|
setStorageCallback(callback: (phone: string, code: string) => Promise<void>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Set template engine for SMS message customization
|
|
53
|
+
*
|
|
54
|
+
* @param engine - SMS template engine instance
|
|
55
|
+
*/
|
|
10
56
|
setTemplateEngine(engine: SMSTemplateEngine): void;
|
|
57
|
+
/**
|
|
58
|
+
* Set global variables for SMS templates
|
|
59
|
+
*
|
|
60
|
+
* @param variables - Global template variables (appName, companyName, etc.)
|
|
61
|
+
*/
|
|
11
62
|
setGlobalVariables(variables: SMSTemplateVariables): void;
|
|
63
|
+
/**
|
|
64
|
+
* Send OTP code via SMS (console output)
|
|
65
|
+
*
|
|
66
|
+
* If template engine is configured, uses template to format message.
|
|
67
|
+
* Otherwise, falls back to hard-coded default message for backward compatibility.
|
|
68
|
+
*
|
|
69
|
+
* @param phone - Recipient phone number
|
|
70
|
+
* @param code - OTP code to send
|
|
71
|
+
* @param templateType - Optional template type (verification, mfa, passwordReset)
|
|
72
|
+
* @param variables - Optional template variables (expiryMinutes, appName, etc.)
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* // Without templates (backward compatible)
|
|
77
|
+
* await smsProvider.sendOTP('+1234567890', '123456');
|
|
78
|
+
*
|
|
79
|
+
* // With templates
|
|
80
|
+
* await smsProvider.sendOTP('+1234567890', '123456', 'verification', { expiryMinutes: 5 });
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
12
83
|
sendOTP(phone: string, code: string, templateType?: string, variables?: Record<string, unknown>): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* Send verification code via SMS (console output)
|
|
86
|
+
*
|
|
87
|
+
* @param phone - Recipient phone number
|
|
88
|
+
* @param code - Verification code to send
|
|
89
|
+
*/
|
|
13
90
|
sendVerificationCode(phone: string, code: string): Promise<void>;
|
|
14
91
|
}
|
|
15
92
|
//# sourceMappingURL=console-sms.provider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console-sms.provider.d.ts","sourceRoot":"","sources":["../src/console-sms.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"console-sms.provider.d.ts","sourceRoot":"","sources":["../src/console-sms.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AAExG;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,qBAAa,kBAAmB,YAAW,WAAW;IACpD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,eAAe,CAAC,CAAiD;IAEzE;;OAEG;IACH,OAAO,CAAC,cAAc,CAAC,CAAoB;IAE3C;;OAEG;IACH,OAAO,CAAC,eAAe,CAA4B;gBAEvC,MAAM,CAAC,EAAE,WAAW;IAIhC;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAIpC;;;OAGG;IACH,kBAAkB,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI;IAIlF;;;;OAIG;IACH,iBAAiB,CAAC,MAAM,EAAE,iBAAiB,GAAG,IAAI;IAIlD;;;;OAIG;IACH,kBAAkB,CAAC,SAAS,EAAE,oBAAoB,GAAG,IAAI;IAIzD;;;;;;;;;;;;;;;;;;;OAmBG;IACG,OAAO,CACX,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,YAAY,CAAC,EAAE,MAAM,EACrB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAClC,OAAO,CAAC,IAAI,CAAC;IAqDhB;;;;;OAKG;IACG,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAIvE"}
|
|
@@ -2,27 +2,99 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ConsoleSMSProvider = void 0;
|
|
4
4
|
const core_1 = require("@nauth-toolkit/core");
|
|
5
|
+
/**
|
|
6
|
+
* Console SMS Provider (Platform-Agnostic)
|
|
7
|
+
*
|
|
8
|
+
* Development-only SMS provider that logs messages to console instead of sending real SMS.
|
|
9
|
+
*
|
|
10
|
+
* This is a plain TypeScript class with no framework dependencies.
|
|
11
|
+
* Works with any framework (NestJS, Express, Fastify, etc.)
|
|
12
|
+
*
|
|
13
|
+
* **Use Case:**
|
|
14
|
+
* - Development and testing environments
|
|
15
|
+
* - No external dependencies required
|
|
16
|
+
* - See SMS content without sending actual messages
|
|
17
|
+
*
|
|
18
|
+
* **Security Note:**
|
|
19
|
+
* - NEVER use in production (exposes sensitive codes in logs)
|
|
20
|
+
* - For production, use real SMS providers like Twilio, AWS SNS, MessageBird
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // In AuthModule configuration
|
|
25
|
+
* AuthModule.forRoot({
|
|
26
|
+
* sms: {
|
|
27
|
+
* provider: new ConsoleSMSProvider(),
|
|
28
|
+
* },
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
5
32
|
class ConsoleSMSProvider {
|
|
6
33
|
logger;
|
|
7
34
|
storageCallback;
|
|
35
|
+
/**
|
|
36
|
+
* Optional SMS template engine for customizing message content
|
|
37
|
+
*/
|
|
8
38
|
templateEngine;
|
|
39
|
+
/**
|
|
40
|
+
* Global variables available to all SMS templates
|
|
41
|
+
*/
|
|
9
42
|
globalVariables = {};
|
|
10
43
|
constructor(logger) {
|
|
11
44
|
this.logger = logger || new core_1.NAuthLogger();
|
|
12
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Set logger for this provider
|
|
48
|
+
* Used by auth module to inject the configured logger
|
|
49
|
+
*/
|
|
13
50
|
setLogger(logger) {
|
|
14
51
|
this.logger = logger;
|
|
15
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Set storage callback for test mode
|
|
55
|
+
* Used to store SMS codes in test database for E2E testing
|
|
56
|
+
*/
|
|
16
57
|
setStorageCallback(callback) {
|
|
17
58
|
this.storageCallback = callback;
|
|
18
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Set template engine for SMS message customization
|
|
62
|
+
*
|
|
63
|
+
* @param engine - SMS template engine instance
|
|
64
|
+
*/
|
|
19
65
|
setTemplateEngine(engine) {
|
|
20
66
|
this.templateEngine = engine;
|
|
21
67
|
}
|
|
68
|
+
/**
|
|
69
|
+
* Set global variables for SMS templates
|
|
70
|
+
*
|
|
71
|
+
* @param variables - Global template variables (appName, companyName, etc.)
|
|
72
|
+
*/
|
|
22
73
|
setGlobalVariables(variables) {
|
|
23
74
|
this.globalVariables = variables || {};
|
|
24
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* Send OTP code via SMS (console output)
|
|
78
|
+
*
|
|
79
|
+
* If template engine is configured, uses template to format message.
|
|
80
|
+
* Otherwise, falls back to hard-coded default message for backward compatibility.
|
|
81
|
+
*
|
|
82
|
+
* @param phone - Recipient phone number
|
|
83
|
+
* @param code - OTP code to send
|
|
84
|
+
* @param templateType - Optional template type (verification, mfa, passwordReset)
|
|
85
|
+
* @param variables - Optional template variables (expiryMinutes, appName, etc.)
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* // Without templates (backward compatible)
|
|
90
|
+
* await smsProvider.sendOTP('+1234567890', '123456');
|
|
91
|
+
*
|
|
92
|
+
* // With templates
|
|
93
|
+
* await smsProvider.sendOTP('+1234567890', '123456', 'verification', { expiryMinutes: 5 });
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
25
96
|
async sendOTP(phone, code, templateType, variables) {
|
|
97
|
+
// Store in test database if callback provided (test mode)
|
|
26
98
|
if (this.storageCallback) {
|
|
27
99
|
try {
|
|
28
100
|
await this.storageCallback(phone, code);
|
|
@@ -33,25 +105,35 @@ class ConsoleSMSProvider {
|
|
|
33
105
|
}
|
|
34
106
|
this.logger.log(`Sending SMS to: ${phone}`);
|
|
35
107
|
let message;
|
|
108
|
+
// ============================================================================
|
|
109
|
+
// Template-based message rendering
|
|
110
|
+
// ============================================================================
|
|
36
111
|
if (this.templateEngine && templateType) {
|
|
37
112
|
try {
|
|
113
|
+
// Merge global variables with template-specific variables
|
|
38
114
|
const allVariables = {
|
|
39
115
|
...this.globalVariables,
|
|
40
116
|
code,
|
|
41
117
|
...variables,
|
|
42
118
|
};
|
|
119
|
+
// Render template
|
|
43
120
|
const template = await this.templateEngine.render(templateType, allVariables);
|
|
44
121
|
message = template.content;
|
|
45
122
|
}
|
|
46
123
|
catch (error) {
|
|
47
124
|
const errorMessage = error instanceof Error ? error.message : 'Unknown error';
|
|
48
125
|
this.logger.error?.(`Failed to render SMS template: ${errorMessage}`);
|
|
126
|
+
// Fall back to hard-coded message on template rendering error
|
|
49
127
|
message = `Your verification code is: ${code}`;
|
|
50
128
|
}
|
|
51
129
|
}
|
|
52
130
|
else {
|
|
131
|
+
// ============================================================================
|
|
132
|
+
// Backward compatibility: hard-coded default message
|
|
133
|
+
// ============================================================================
|
|
53
134
|
message = `Your verification code is: ${code}`;
|
|
54
135
|
}
|
|
136
|
+
// Log SMS content in a visually distinct format
|
|
55
137
|
this.logger.log(`\n${'='.repeat(60)}`);
|
|
56
138
|
this.logger.log('SMS MESSAGE');
|
|
57
139
|
this.logger.log('='.repeat(60));
|
|
@@ -60,7 +142,14 @@ class ConsoleSMSProvider {
|
|
|
60
142
|
this.logger.log(`${'='.repeat(60)}\n`);
|
|
61
143
|
this.logger.log(`SMS sent successfully to: ${phone}`);
|
|
62
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Send verification code via SMS (console output)
|
|
147
|
+
*
|
|
148
|
+
* @param phone - Recipient phone number
|
|
149
|
+
* @param code - Verification code to send
|
|
150
|
+
*/
|
|
63
151
|
async sendVerificationCode(phone, code) {
|
|
152
|
+
// Use the same implementation as sendOTP
|
|
64
153
|
await this.sendOTP(phone, code);
|
|
65
154
|
}
|
|
66
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"console-sms.provider.js","sourceRoot":"","sources":["../src/console-sms.provider.ts"],"names":[],"mappings":";;;AAAA,8CAAwG;
|
|
1
|
+
{"version":3,"file":"console-sms.provider.js","sourceRoot":"","sources":["../src/console-sms.provider.ts"],"names":[],"mappings":";;;AAAA,8CAAwG;AAExG;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAa,kBAAkB;IACrB,MAAM,CAAc;IACpB,eAAe,CAAkD;IAEzE;;OAEG;IACK,cAAc,CAAqB;IAE3C;;OAEG;IACK,eAAe,GAAyB,EAAE,CAAC;IAEnD,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,kBAAW,EAAE,CAAC;IAC5C,CAAC;IAED;;;OAGG;IACH,SAAS,CAAC,MAAmB;Q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package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @nauth-toolkit/sms-console
|
|
4
|
+
*
|
|
5
|
+
* Console SMS provider for nauth-toolkit.
|
|
6
|
+
* Logs SMS messages to console for development and testing.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.ConsoleSMSProvider = void 0;
|
|
4
10
|
var console_sms_provider_1 = require("./console-sms.provider");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,+DAA4D;AAAnD,0HAAA,kBAAkB,OAAA"}
|
|
@@ -1,9 +1,21 @@
|
|
|
1
1
|
import { SMSProvider, NAuthLogger } from '@nauth-toolkit/core';
|
|
2
|
+
/**
|
|
3
|
+
* Test SMS Storage Interface
|
|
4
|
+
* Stores SMS codes in a test database table for retrieval during E2E tests
|
|
5
|
+
*/
|
|
2
6
|
export interface TestSMSStorage {
|
|
3
7
|
storeCode(phone: string, code: string): Promise<void>;
|
|
4
8
|
getLatestCode(phone: string): Promise<string | null>;
|
|
5
9
|
clearCodes(phone?: string): Promise<void>;
|
|
6
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* Test SMS Provider with Database Storage
|
|
13
|
+
*
|
|
14
|
+
* Stores SMS codes in a test database table for E2E testing.
|
|
15
|
+
* Allows tests to retrieve verification codes via test endpoints.
|
|
16
|
+
*
|
|
17
|
+
* TEST MODE ONLY - Only use when NAUTH_TEST_MODE=true
|
|
18
|
+
*/
|
|
7
19
|
export declare class TestSMSStorageProvider implements SMSProvider {
|
|
8
20
|
private logger;
|
|
9
21
|
private storage;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-sms-storage.provider.d.ts","sourceRoot":"","sources":["../src/test-sms-storage.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"test-sms-storage.provider.d.ts","sourceRoot":"","sources":["../src/test-sms-storage.provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IACrD,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3C;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAuB,YAAW,WAAW;IACxD,OAAO,CAAC,MAAM,CAAc;IAC5B,OAAO,CAAC,OAAO,CAAiB;gBAEpB,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,cAAc;IAKxD,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI;IAI9B,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAenD,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGvE"}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.TestSMSStorageProvider = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Test SMS Provider with Database Storage
|
|
6
|
+
*
|
|
7
|
+
* Stores SMS codes in a test database table for E2E testing.
|
|
8
|
+
* Allows tests to retrieve verification codes via test endpoints.
|
|
9
|
+
*
|
|
10
|
+
* TEST MODE ONLY - Only use when NAUTH_TEST_MODE=true
|
|
11
|
+
*/
|
|
4
12
|
class TestSMSStorageProvider {
|
|
5
13
|
logger;
|
|
6
14
|
storage;
|
|
@@ -13,7 +21,9 @@ class TestSMSStorageProvider {
|
|
|
13
21
|
}
|
|
14
22
|
async sendOTP(phone, code) {
|
|
15
23
|
this.logger.log(`[TEST SMS] Sending OTP to: ${phone}, code: ${code}`);
|
|
24
|
+
// Store code in test database
|
|
16
25
|
await this.storage.storeCode(phone, code);
|
|
26
|
+
// Also log to console for visibility
|
|
17
27
|
this.logger.log(`\n${'='.repeat(60)}`);
|
|
18
28
|
this.logger.log('SMS MESSAGE (TEST MODE - Stored in DB)');
|
|
19
29
|
this.logger.log('='.repeat(60));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-sms-storage.provider.js","sourceRoot":"","sources":["../src/test-sms-storage.provider.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"test-sms-storage.provider.js","sourceRoot":"","sources":["../src/test-sms-storage.provider.ts"],"names":[],"mappings":";;;AAYA;;;;;;;GAOG;AACH,MAAa,sBAAsB;IACzB,MAAM,CAAc;IACpB,OAAO,CAAiB;IAEhC,YAAY,MAAmB,EAAE,OAAuB;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,SAAS,CAAC,MAAmB;QAC3B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,KAAa,EAAE,IAAY;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,8BAA8B,KAAK,WAAW,IAAI,EAAE,CAAC,CAAC;QAEtE,8BAA8B;QAC9B,MAAM,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAE1C,qCAAqC;QACrC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;QACvC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;QAC1D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,OAAO,KAAK,EAAE,CAAC,CAAC;QAChC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,uCAAuC,IAAI,EAAE,CAAC,CAAC;QAC/D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,KAAa,EAAE,IAAY;QACpD,MAAM,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;IAClC,CAAC;CACF;AA/BD,wDA+BC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nauth-toolkit/sms-console",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.18",
|
|
4
4
|
"description": "Console SMS provider for nauth-toolkit (dev/test)",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"format:check": "prettier --check \"src/**/*.ts\""
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
|
-
"@nauth-toolkit/core": "^0.1.
|
|
17
|
+
"@nauth-toolkit/core": "^0.1.18"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@types/jest": "^29.5.0",
|