@sendly/node 3.9.0 → 3.11.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/dist/index.d.mts CHANGED
@@ -1042,6 +1042,39 @@ interface TemplatePreview {
1042
1042
  /** Variables detected */
1043
1043
  variables: TemplateVariable[];
1044
1044
  }
1045
+ type VerifySessionStatus = "pending" | "phone_submitted" | "code_sent" | "verified" | "expired" | "cancelled";
1046
+ interface CreateVerifySessionRequest {
1047
+ successUrl: string;
1048
+ cancelUrl?: string;
1049
+ brandName?: string;
1050
+ brandColor?: string;
1051
+ metadata?: Record<string, unknown>;
1052
+ }
1053
+ interface VerifySession {
1054
+ id: string;
1055
+ url: string;
1056
+ status: VerifySessionStatus;
1057
+ successUrl: string;
1058
+ cancelUrl?: string;
1059
+ brandName?: string;
1060
+ brandColor?: string;
1061
+ phone?: string;
1062
+ verificationId?: string;
1063
+ token?: string;
1064
+ metadata?: Record<string, unknown>;
1065
+ expiresAt: string;
1066
+ createdAt: string;
1067
+ }
1068
+ interface ValidateSessionTokenRequest {
1069
+ token: string;
1070
+ }
1071
+ interface ValidateSessionTokenResponse {
1072
+ valid: boolean;
1073
+ sessionId?: string;
1074
+ phone?: string;
1075
+ verifiedAt?: string;
1076
+ metadata?: Record<string, unknown>;
1077
+ }
1045
1078
 
1046
1079
  /**
1047
1080
  * HTTP Client Utility
@@ -1739,6 +1772,12 @@ declare class AccountResource {
1739
1772
  * @packageDocumentation
1740
1773
  */
1741
1774
 
1775
+ declare class SessionsResource {
1776
+ private readonly http;
1777
+ constructor(http: HttpClient);
1778
+ create(request: CreateVerifySessionRequest): Promise<VerifySession>;
1779
+ validate(request: ValidateSessionTokenRequest): Promise<ValidateSessionTokenResponse>;
1780
+ }
1742
1781
  /**
1743
1782
  * Verify API resource for OTP verification
1744
1783
  *
@@ -1762,6 +1801,7 @@ declare class AccountResource {
1762
1801
  */
1763
1802
  declare class VerifyResource {
1764
1803
  private readonly http;
1804
+ readonly sessions: SessionsResource;
1765
1805
  constructor(http: HttpClient);
1766
1806
  /**
1767
1807
  * Send an OTP verification code
@@ -1791,6 +1831,20 @@ declare class VerifyResource {
1791
1831
  * ```
1792
1832
  */
1793
1833
  send(request: SendVerificationRequest): Promise<SendVerificationResponse>;
1834
+ /**
1835
+ * Resend an OTP verification code
1836
+ *
1837
+ * @param id - Verification ID
1838
+ * @returns Updated verification with new expiry
1839
+ *
1840
+ * @example
1841
+ * ```typescript
1842
+ * // Resend when delivery failed or code expired
1843
+ * const result = await sendly.verify.resend('ver_xxx');
1844
+ * console.log('New code expires at:', result.expiresAt);
1845
+ * ```
1846
+ */
1847
+ resend(id: string): Promise<SendVerificationResponse>;
1794
1848
  /**
1795
1849
  * Check/verify an OTP code
1796
1850
  *
@@ -2573,4 +2627,4 @@ declare class Webhooks {
2573
2627
  */
2574
2628
  type WebhookMessageData = WebhookMessageObject;
2575
2629
 
2576
- export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type CreateTemplateRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateTemplateRequest, type UpdateWebhookOptions, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
2630
+ export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
package/dist/index.d.ts CHANGED
@@ -1042,6 +1042,39 @@ interface TemplatePreview {
1042
1042
  /** Variables detected */
1043
1043
  variables: TemplateVariable[];
1044
1044
  }
1045
+ type VerifySessionStatus = "pending" | "phone_submitted" | "code_sent" | "verified" | "expired" | "cancelled";
1046
+ interface CreateVerifySessionRequest {
1047
+ successUrl: string;
1048
+ cancelUrl?: string;
1049
+ brandName?: string;
1050
+ brandColor?: string;
1051
+ metadata?: Record<string, unknown>;
1052
+ }
1053
+ interface VerifySession {
1054
+ id: string;
1055
+ url: string;
1056
+ status: VerifySessionStatus;
1057
+ successUrl: string;
1058
+ cancelUrl?: string;
1059
+ brandName?: string;
1060
+ brandColor?: string;
1061
+ phone?: string;
1062
+ verificationId?: string;
1063
+ token?: string;
1064
+ metadata?: Record<string, unknown>;
1065
+ expiresAt: string;
1066
+ createdAt: string;
1067
+ }
1068
+ interface ValidateSessionTokenRequest {
1069
+ token: string;
1070
+ }
1071
+ interface ValidateSessionTokenResponse {
1072
+ valid: boolean;
1073
+ sessionId?: string;
1074
+ phone?: string;
1075
+ verifiedAt?: string;
1076
+ metadata?: Record<string, unknown>;
1077
+ }
1045
1078
 
1046
1079
  /**
1047
1080
  * HTTP Client Utility
@@ -1739,6 +1772,12 @@ declare class AccountResource {
1739
1772
  * @packageDocumentation
1740
1773
  */
1741
1774
 
1775
+ declare class SessionsResource {
1776
+ private readonly http;
1777
+ constructor(http: HttpClient);
1778
+ create(request: CreateVerifySessionRequest): Promise<VerifySession>;
1779
+ validate(request: ValidateSessionTokenRequest): Promise<ValidateSessionTokenResponse>;
1780
+ }
1742
1781
  /**
1743
1782
  * Verify API resource for OTP verification
1744
1783
  *
@@ -1762,6 +1801,7 @@ declare class AccountResource {
1762
1801
  */
1763
1802
  declare class VerifyResource {
1764
1803
  private readonly http;
1804
+ readonly sessions: SessionsResource;
1765
1805
  constructor(http: HttpClient);
1766
1806
  /**
1767
1807
  * Send an OTP verification code
@@ -1791,6 +1831,20 @@ declare class VerifyResource {
1791
1831
  * ```
1792
1832
  */
1793
1833
  send(request: SendVerificationRequest): Promise<SendVerificationResponse>;
1834
+ /**
1835
+ * Resend an OTP verification code
1836
+ *
1837
+ * @param id - Verification ID
1838
+ * @returns Updated verification with new expiry
1839
+ *
1840
+ * @example
1841
+ * ```typescript
1842
+ * // Resend when delivery failed or code expired
1843
+ * const result = await sendly.verify.resend('ver_xxx');
1844
+ * console.log('New code expires at:', result.expiresAt);
1845
+ * ```
1846
+ */
1847
+ resend(id: string): Promise<SendVerificationResponse>;
1794
1848
  /**
1795
1849
  * Check/verify an OTP code
1796
1850
  *
@@ -2573,4 +2627,4 @@ declare class Webhooks {
2573
2627
  */
2574
2628
  type WebhookMessageData = WebhookMessageObject;
2575
2629
 
2576
- export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type CreateTemplateRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateTemplateRequest, type UpdateWebhookOptions, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
2630
+ export { ALL_SUPPORTED_COUNTRIES, type Account, type ApiErrorResponse, type ApiKey, AuthenticationError, type BatchListResponse, type BatchMessageItem, type BatchMessageRequest, type BatchMessageResponse, type BatchMessageResult, type BatchStatus, CREDITS_PER_SMS, type CancelledMessageResponse, type CheckVerificationRequest, type CheckVerificationResponse, type CircuitState, type CreateTemplateRequest, type CreateVerifySessionRequest, type CreateWebhookOptions, type CreditTransaction, type Credits, type DeliveryStatus, InsufficientCreditsError, type ListBatchesOptions, type ListMessagesOptions, type ListScheduledMessagesOptions, type ListVerificationsOptions, type Message, type MessageListResponse, type MessageStatus, type MessageType, NetworkError, NotFoundError, type PricingTier, RateLimitError, type RateLimitInfo, SANDBOX_TEST_NUMBERS, SUPPORTED_COUNTRIES, type ScheduleMessageRequest, type ScheduledMessage, type ScheduledMessageListResponse, type ScheduledMessageStatus, type SendMessageRequest, type SendVerificationRequest, type SendVerificationResponse, type SenderType, Sendly, type SendlyConfig, SendlyError, type SendlyErrorCode, type Template, type TemplateListResponse, type TemplatePreview, type TemplateStatus, type TemplateVariable, TimeoutError, type UpdateTemplateRequest, type UpdateWebhookOptions, type ValidateSessionTokenRequest, type ValidateSessionTokenResponse, ValidationError, type Verification, type VerificationDeliveryStatus, type VerificationListResponse, type VerificationStatus, type VerifySession, type VerifySessionStatus, type Webhook, type WebhookCreatedResponse, type WebhookDelivery, type WebhookEvent, type WebhookEventType, type WebhookMessageData, type WebhookMessageStatus, type WebhookSecretRotation, WebhookSignatureError, type WebhookTestResult, Webhooks, calculateSegments, Sendly as default, generateWebhookSignature, getCountryFromPhone, isCountrySupported, parseWebhookEvent, validateMessageText, validatePhoneNumber, validateSenderId, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1523,10 +1523,60 @@ var AccountResource = class {
1523
1523
  };
1524
1524
 
1525
1525
  // src/resources/verify.ts
1526
+ var SessionsResource = class {
1527
+ http;
1528
+ constructor(http) {
1529
+ this.http = http;
1530
+ }
1531
+ async create(request) {
1532
+ const response = await this.http.request({
1533
+ method: "POST",
1534
+ path: "/verify/sessions",
1535
+ body: {
1536
+ success_url: request.successUrl,
1537
+ ...request.cancelUrl && { cancel_url: request.cancelUrl },
1538
+ ...request.brandName && { brand_name: request.brandName },
1539
+ ...request.brandColor && { brand_color: request.brandColor },
1540
+ ...request.metadata && { metadata: request.metadata }
1541
+ }
1542
+ });
1543
+ return {
1544
+ id: response.id,
1545
+ url: response.url,
1546
+ status: response.status,
1547
+ successUrl: response.success_url,
1548
+ cancelUrl: response.cancel_url,
1549
+ brandName: response.brand_name,
1550
+ brandColor: response.brand_color,
1551
+ phone: response.phone,
1552
+ verificationId: response.verification_id,
1553
+ token: response.token,
1554
+ metadata: response.metadata,
1555
+ expiresAt: response.expires_at,
1556
+ createdAt: response.created_at
1557
+ };
1558
+ }
1559
+ async validate(request) {
1560
+ const response = await this.http.request({
1561
+ method: "POST",
1562
+ path: "/verify/sessions/validate",
1563
+ body: { token: request.token }
1564
+ });
1565
+ return {
1566
+ valid: response.valid,
1567
+ sessionId: response.session_id,
1568
+ phone: response.phone,
1569
+ verifiedAt: response.verified_at,
1570
+ metadata: response.metadata
1571
+ };
1572
+ }
1573
+ };
1526
1574
  var VerifyResource = class {
1527
1575
  http;
1576
+ sessions;
1528
1577
  constructor(http) {
1529
1578
  this.http = http;
1579
+ this.sessions = new SessionsResource(http);
1530
1580
  }
1531
1581
  /**
1532
1582
  * Send an OTP verification code
@@ -1579,6 +1629,34 @@ var VerifyResource = class {
1579
1629
  message: response.message
1580
1630
  };
1581
1631
  }
1632
+ /**
1633
+ * Resend an OTP verification code
1634
+ *
1635
+ * @param id - Verification ID
1636
+ * @returns Updated verification with new expiry
1637
+ *
1638
+ * @example
1639
+ * ```typescript
1640
+ * // Resend when delivery failed or code expired
1641
+ * const result = await sendly.verify.resend('ver_xxx');
1642
+ * console.log('New code expires at:', result.expiresAt);
1643
+ * ```
1644
+ */
1645
+ async resend(id) {
1646
+ const response = await this.http.request({
1647
+ method: "POST",
1648
+ path: `/verify/${id}/resend`
1649
+ });
1650
+ return {
1651
+ id: response.id,
1652
+ status: response.status,
1653
+ phone: response.phone,
1654
+ expiresAt: response.expires_at,
1655
+ sandbox: response.sandbox,
1656
+ sandboxCode: response.sandbox_code,
1657
+ message: response.message
1658
+ };
1659
+ }
1582
1660
  /**
1583
1661
  * Check/verify an OTP code
1584
1662
  *
package/dist/index.mjs CHANGED
@@ -1463,10 +1463,60 @@ var AccountResource = class {
1463
1463
  };
1464
1464
 
1465
1465
  // src/resources/verify.ts
1466
+ var SessionsResource = class {
1467
+ http;
1468
+ constructor(http) {
1469
+ this.http = http;
1470
+ }
1471
+ async create(request) {
1472
+ const response = await this.http.request({
1473
+ method: "POST",
1474
+ path: "/verify/sessions",
1475
+ body: {
1476
+ success_url: request.successUrl,
1477
+ ...request.cancelUrl && { cancel_url: request.cancelUrl },
1478
+ ...request.brandName && { brand_name: request.brandName },
1479
+ ...request.brandColor && { brand_color: request.brandColor },
1480
+ ...request.metadata && { metadata: request.metadata }
1481
+ }
1482
+ });
1483
+ return {
1484
+ id: response.id,
1485
+ url: response.url,
1486
+ status: response.status,
1487
+ successUrl: response.success_url,
1488
+ cancelUrl: response.cancel_url,
1489
+ brandName: response.brand_name,
1490
+ brandColor: response.brand_color,
1491
+ phone: response.phone,
1492
+ verificationId: response.verification_id,
1493
+ token: response.token,
1494
+ metadata: response.metadata,
1495
+ expiresAt: response.expires_at,
1496
+ createdAt: response.created_at
1497
+ };
1498
+ }
1499
+ async validate(request) {
1500
+ const response = await this.http.request({
1501
+ method: "POST",
1502
+ path: "/verify/sessions/validate",
1503
+ body: { token: request.token }
1504
+ });
1505
+ return {
1506
+ valid: response.valid,
1507
+ sessionId: response.session_id,
1508
+ phone: response.phone,
1509
+ verifiedAt: response.verified_at,
1510
+ metadata: response.metadata
1511
+ };
1512
+ }
1513
+ };
1466
1514
  var VerifyResource = class {
1467
1515
  http;
1516
+ sessions;
1468
1517
  constructor(http) {
1469
1518
  this.http = http;
1519
+ this.sessions = new SessionsResource(http);
1470
1520
  }
1471
1521
  /**
1472
1522
  * Send an OTP verification code
@@ -1519,6 +1569,34 @@ var VerifyResource = class {
1519
1569
  message: response.message
1520
1570
  };
1521
1571
  }
1572
+ /**
1573
+ * Resend an OTP verification code
1574
+ *
1575
+ * @param id - Verification ID
1576
+ * @returns Updated verification with new expiry
1577
+ *
1578
+ * @example
1579
+ * ```typescript
1580
+ * // Resend when delivery failed or code expired
1581
+ * const result = await sendly.verify.resend('ver_xxx');
1582
+ * console.log('New code expires at:', result.expiresAt);
1583
+ * ```
1584
+ */
1585
+ async resend(id) {
1586
+ const response = await this.http.request({
1587
+ method: "POST",
1588
+ path: `/verify/${id}/resend`
1589
+ });
1590
+ return {
1591
+ id: response.id,
1592
+ status: response.status,
1593
+ phone: response.phone,
1594
+ expiresAt: response.expires_at,
1595
+ sandbox: response.sandbox,
1596
+ sandboxCode: response.sandbox_code,
1597
+ message: response.message
1598
+ };
1599
+ }
1522
1600
  /**
1523
1601
  * Check/verify an OTP code
1524
1602
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sendly/node",
3
- "version": "3.9.0",
3
+ "version": "3.11.0",
4
4
  "description": "Official Sendly Node.js SDK for SMS messaging",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",