paperplane-sdk 1.0.1 → 1.0.2
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.ts +14 -26
- package/dist/index.js +13 -44
- package/dist/index.mjs +13 -44
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1,19 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Paperplane —
|
|
3
|
-
*
|
|
2
|
+
* Paperplane — Official zero-dependency client SDK for Paperplane passwordless OTP engine.
|
|
3
|
+
* Automatically delivers OTPs via Amazon SES Email or Meta WhatsApp ($0.00 verification fee).
|
|
4
4
|
*/
|
|
5
|
-
export type DeliveryChannel = "whatsapp" | "email" | "sms";
|
|
6
|
-
export interface SendOtpOptions {
|
|
7
|
-
to: string;
|
|
8
|
-
channel?: DeliveryChannel;
|
|
9
|
-
appName?: string;
|
|
10
|
-
code?: string;
|
|
11
|
-
otp?: string;
|
|
12
|
-
tenantId?: string;
|
|
13
|
-
}
|
|
14
5
|
export interface SendOtpResult {
|
|
15
6
|
status: string;
|
|
16
|
-
channel: string;
|
|
17
7
|
to: string;
|
|
8
|
+
channel?: string;
|
|
9
|
+
id?: string;
|
|
10
|
+
expires_in?: number;
|
|
18
11
|
error?: string;
|
|
19
12
|
[key: string]: any;
|
|
20
13
|
}
|
|
21
|
-
export interface VerifyOtpOptions {
|
|
22
|
-
to: string;
|
|
23
|
-
otp: string;
|
|
24
|
-
code?: string;
|
|
25
|
-
tenantId?: string;
|
|
26
|
-
}
|
|
27
14
|
export interface VerifyOtpResult {
|
|
28
15
|
verified: boolean;
|
|
29
|
-
|
|
16
|
+
recipient?: string;
|
|
30
17
|
error?: string;
|
|
31
18
|
[key: string]: any;
|
|
32
19
|
}
|
|
@@ -37,7 +24,7 @@ export interface LogFilterOptions {
|
|
|
37
24
|
export interface DeliveryLogItem {
|
|
38
25
|
id: string;
|
|
39
26
|
to: string;
|
|
40
|
-
channel
|
|
27
|
+
channel?: string;
|
|
41
28
|
status: string;
|
|
42
29
|
createdAt: string;
|
|
43
30
|
[key: string]: any;
|
|
@@ -57,18 +44,19 @@ export declare class PaperplaneClient {
|
|
|
57
44
|
baseUrl: string;
|
|
58
45
|
constructor(apiKeyOrConfig?: string | PaperplaneConfig);
|
|
59
46
|
/**
|
|
60
|
-
* 1. Send OTP
|
|
47
|
+
* 1. Send OTP
|
|
48
|
+
* The API automatically routes to Email (if 'to' contains '@') or WhatsApp (if mobile number).
|
|
61
49
|
* @param to Phone number "+918279012305" or email "user@example.com"
|
|
62
|
-
* @param channel "whatsapp" (default), "email", or "sms"
|
|
63
|
-
* @param appName Brand name shown in the copy-code template
|
|
64
50
|
*/
|
|
65
|
-
send(
|
|
51
|
+
send(to: string | {
|
|
52
|
+
to: string;
|
|
53
|
+
}): Promise<SendOtpResult>;
|
|
66
54
|
/**
|
|
67
|
-
* 2. Verify OTP
|
|
55
|
+
* 2. Verify OTP ($0.00 verification fee forever)
|
|
68
56
|
* @param to Recipient phone or email originally sent to
|
|
69
57
|
* @param otp 6-digit verification code entered by user
|
|
70
58
|
*/
|
|
71
|
-
verify(
|
|
59
|
+
verify(to: string, otp: string): Promise<VerifyOtpResult>;
|
|
72
60
|
/**
|
|
73
61
|
* 3. Fetch real-time delivery logs
|
|
74
62
|
* @param optionsOrLimit Limit number or options object { date: "YYYY-MM-DD", limit: 50 }
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
* Paperplane —
|
|
4
|
-
*
|
|
3
|
+
* Paperplane — Official zero-dependency client SDK for Paperplane passwordless OTP engine.
|
|
4
|
+
* Automatically delivers OTPs via Amazon SES Email or Meta WhatsApp ($0.00 verification fee).
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.pp = exports.PaperplaneClient = void 0;
|
|
@@ -30,33 +30,13 @@ class PaperplaneClient {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
/**
|
|
33
|
-
* 1. Send OTP
|
|
33
|
+
* 1. Send OTP
|
|
34
|
+
* The API automatically routes to Email (if 'to' contains '@') or WhatsApp (if mobile number).
|
|
34
35
|
* @param to Phone number "+918279012305" or email "user@example.com"
|
|
35
|
-
* @param channel "whatsapp" (default), "email", or "sms"
|
|
36
|
-
* @param appName Brand name shown in the copy-code template
|
|
37
36
|
*/
|
|
38
|
-
async send(
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
payload = {
|
|
42
|
-
to: toOrOptions,
|
|
43
|
-
channel,
|
|
44
|
-
app_name: appName,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
payload = {
|
|
49
|
-
to: toOrOptions.to,
|
|
50
|
-
channel: toOrOptions.channel || "whatsapp",
|
|
51
|
-
app_name: toOrOptions.appName || "Paperplane",
|
|
52
|
-
};
|
|
53
|
-
if (toOrOptions.code)
|
|
54
|
-
payload.code = toOrOptions.code;
|
|
55
|
-
if (toOrOptions.otp)
|
|
56
|
-
payload.otp = toOrOptions.otp;
|
|
57
|
-
if (toOrOptions.tenantId)
|
|
58
|
-
payload.tenant_id = toOrOptions.tenantId;
|
|
59
|
-
}
|
|
37
|
+
async send(to) {
|
|
38
|
+
const recipient = typeof to === "string" ? to : to.to;
|
|
39
|
+
const payload = { to: recipient };
|
|
60
40
|
const headers = {
|
|
61
41
|
"Content-Type": "application/json",
|
|
62
42
|
};
|
|
@@ -72,26 +52,15 @@ class PaperplaneClient {
|
|
|
72
52
|
return res.json();
|
|
73
53
|
}
|
|
74
54
|
/**
|
|
75
|
-
* 2. Verify OTP
|
|
55
|
+
* 2. Verify OTP ($0.00 verification fee forever)
|
|
76
56
|
* @param to Recipient phone or email originally sent to
|
|
77
57
|
* @param otp 6-digit verification code entered by user
|
|
78
58
|
*/
|
|
79
|
-
async verify(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
otp: otp || "",
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
payload = {
|
|
89
|
-
to: toOrOptions.to,
|
|
90
|
-
otp: toOrOptions.otp || toOrOptions.code || "",
|
|
91
|
-
};
|
|
92
|
-
if (toOrOptions.tenantId)
|
|
93
|
-
payload.tenant_id = toOrOptions.tenantId;
|
|
94
|
-
}
|
|
59
|
+
async verify(to, otp) {
|
|
60
|
+
const payload = {
|
|
61
|
+
to,
|
|
62
|
+
otp: otp || "",
|
|
63
|
+
};
|
|
95
64
|
const headers = {
|
|
96
65
|
"Content-Type": "application/json",
|
|
97
66
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Paperplane —
|
|
3
|
-
*
|
|
2
|
+
* Paperplane — Official zero-dependency client SDK for Paperplane passwordless OTP engine.
|
|
3
|
+
* Automatically delivers OTPs via Amazon SES Email or Meta WhatsApp ($0.00 verification fee).
|
|
4
4
|
*/
|
|
5
5
|
const DEFAULT_API_BASE = (typeof process !== "undefined" && (process.env.NEXT_PUBLIC_PAPERPLANE_URL || process.env.PAPERPLANE_URL)) ||
|
|
6
6
|
"https://api.arcopscloud.in";
|
|
@@ -26,33 +26,13 @@ export class PaperplaneClient {
|
|
|
26
26
|
}
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
-
* 1. Send OTP
|
|
29
|
+
* 1. Send OTP
|
|
30
|
+
* The API automatically routes to Email (if 'to' contains '@') or WhatsApp (if mobile number).
|
|
30
31
|
* @param to Phone number "+918279012305" or email "user@example.com"
|
|
31
|
-
* @param channel "whatsapp" (default), "email", or "sms"
|
|
32
|
-
* @param appName Brand name shown in the copy-code template
|
|
33
32
|
*/
|
|
34
|
-
async send(
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
payload = {
|
|
38
|
-
to: toOrOptions,
|
|
39
|
-
channel,
|
|
40
|
-
app_name: appName,
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
payload = {
|
|
45
|
-
to: toOrOptions.to,
|
|
46
|
-
channel: toOrOptions.channel || "whatsapp",
|
|
47
|
-
app_name: toOrOptions.appName || "Paperplane",
|
|
48
|
-
};
|
|
49
|
-
if (toOrOptions.code)
|
|
50
|
-
payload.code = toOrOptions.code;
|
|
51
|
-
if (toOrOptions.otp)
|
|
52
|
-
payload.otp = toOrOptions.otp;
|
|
53
|
-
if (toOrOptions.tenantId)
|
|
54
|
-
payload.tenant_id = toOrOptions.tenantId;
|
|
55
|
-
}
|
|
33
|
+
async send(to) {
|
|
34
|
+
const recipient = typeof to === "string" ? to : to.to;
|
|
35
|
+
const payload = { to: recipient };
|
|
56
36
|
const headers = {
|
|
57
37
|
"Content-Type": "application/json",
|
|
58
38
|
};
|
|
@@ -68,26 +48,15 @@ export class PaperplaneClient {
|
|
|
68
48
|
return res.json();
|
|
69
49
|
}
|
|
70
50
|
/**
|
|
71
|
-
* 2. Verify OTP
|
|
51
|
+
* 2. Verify OTP ($0.00 verification fee forever)
|
|
72
52
|
* @param to Recipient phone or email originally sent to
|
|
73
53
|
* @param otp 6-digit verification code entered by user
|
|
74
54
|
*/
|
|
75
|
-
async verify(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
otp: otp || "",
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
payload = {
|
|
85
|
-
to: toOrOptions.to,
|
|
86
|
-
otp: toOrOptions.otp || toOrOptions.code || "",
|
|
87
|
-
};
|
|
88
|
-
if (toOrOptions.tenantId)
|
|
89
|
-
payload.tenant_id = toOrOptions.tenantId;
|
|
90
|
-
}
|
|
55
|
+
async verify(to, otp) {
|
|
56
|
+
const payload = {
|
|
57
|
+
to,
|
|
58
|
+
otp: otp || "",
|
|
59
|
+
};
|
|
91
60
|
const headers = {
|
|
92
61
|
"Content-Type": "application/json",
|
|
93
62
|
};
|