paperplane-sdk 0.0.0-stage → 1.0.1

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/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ArcOps
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
package/README.md CHANGED
@@ -1,3 +1,51 @@
1
- # Temporary Holding Version
1
+ # Paperplane Client SDK (`paperplane-sdk`)
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Official zero-dependency JavaScript & TypeScript client library for Paperplane passwordless OTP and messaging engine.
4
+
5
+ Supports **WhatsApp**, **SMS**, and **Amazon SES Email** OTP dispatch and stateless verification with **$0.00 verification fee**.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install paperplane-sdk
11
+ ```
12
+
13
+ ## Quickstart
14
+
15
+ ```typescript
16
+ import { pp } from "paperplane-sdk";
17
+
18
+ // 1. Send WhatsApp OTP
19
+ const sent = await pp.send("+918279012305");
20
+ console.log(sent); // => { status: "queued", channel: "whatsapp", to: "+918279012305" }
21
+
22
+ // 2. Verify 6-digit Code ($0.00 fee)
23
+ const res = await pp.verify("+918279012305", "375666");
24
+ if (res.verified) {
25
+ console.log("Logged in successfully!");
26
+ }
27
+
28
+ // 3. Inspect Delivery Logs
29
+ const logs = await pp.logs();
30
+ ```
31
+
32
+ ## Configuration
33
+
34
+ By default, Paperplane automatically reads `PAPERPLANE_API_KEY` (or `NEXT_PUBLIC_PAPERPLANE_KEY`) and `PAPERPLANE_URL` from your environment (falls back to `https://api.arcopscloud.in`).
35
+
36
+ You can also pass custom keys programmatically:
37
+
38
+ ```typescript
39
+ import { PaperplaneClient } from "paperplane-sdk";
40
+
41
+ const client = new PaperplaneClient({
42
+ apiKey: "pp_live_your_key_here",
43
+ baseUrl: "https://api.arcopscloud.in",
44
+ });
45
+
46
+ await client.send("+918279012305");
47
+ ```
48
+
49
+ ## License
50
+
51
+ MIT
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Paperplane — Zero-dependency client library for the Paperplane passwordless OTP engine.
3
+ * Supports WhatsApp, SMS, and Amazon SES Email with $0.00 verification fees.
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
+ export interface SendOtpResult {
15
+ status: string;
16
+ channel: string;
17
+ to: string;
18
+ error?: string;
19
+ [key: string]: any;
20
+ }
21
+ export interface VerifyOtpOptions {
22
+ to: string;
23
+ otp: string;
24
+ code?: string;
25
+ tenantId?: string;
26
+ }
27
+ export interface VerifyOtpResult {
28
+ verified: boolean;
29
+ channel?: string;
30
+ error?: string;
31
+ [key: string]: any;
32
+ }
33
+ export interface LogFilterOptions {
34
+ date?: string;
35
+ limit?: number;
36
+ }
37
+ export interface DeliveryLogItem {
38
+ id: string;
39
+ to: string;
40
+ channel: string;
41
+ status: string;
42
+ createdAt: string;
43
+ [key: string]: any;
44
+ }
45
+ export interface LogsResponse {
46
+ date?: string;
47
+ count: number;
48
+ logs: DeliveryLogItem[];
49
+ tenant_id?: string;
50
+ }
51
+ export interface PaperplaneConfig {
52
+ apiKey?: string;
53
+ baseUrl?: string;
54
+ }
55
+ export declare class PaperplaneClient {
56
+ apiKey: string;
57
+ baseUrl: string;
58
+ constructor(apiKeyOrConfig?: string | PaperplaneConfig);
59
+ /**
60
+ * 1. Send OTP via WhatsApp, Email, or SMS
61
+ * @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
+ */
65
+ send(toOrOptions: string | SendOtpOptions, channel?: DeliveryChannel, appName?: string): Promise<SendOtpResult>;
66
+ /**
67
+ * 2. Verify OTP code ($0.00 verification fee forever)
68
+ * @param to Recipient phone or email originally sent to
69
+ * @param otp 6-digit verification code entered by user
70
+ */
71
+ verify(toOrOptions: string | VerifyOtpOptions, otp?: string): Promise<VerifyOtpResult>;
72
+ /**
73
+ * 3. Fetch real-time delivery logs
74
+ * @param optionsOrLimit Limit number or options object { date: "YYYY-MM-DD", limit: 50 }
75
+ */
76
+ logs(optionsOrLimit?: number | LogFilterOptions): Promise<LogsResponse>;
77
+ }
78
+ export declare const pp: PaperplaneClient;
79
+ export declare function createPaperplane(apiKeyOrConfig?: string | PaperplaneConfig): PaperplaneClient;
80
+ export default pp;
package/dist/index.js ADDED
@@ -0,0 +1,150 @@
1
+ "use strict";
2
+ /**
3
+ * Paperplane — Zero-dependency client library for the Paperplane passwordless OTP engine.
4
+ * Supports WhatsApp, SMS, and Amazon SES Email with $0.00 verification fees.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.pp = exports.PaperplaneClient = void 0;
8
+ exports.createPaperplane = createPaperplane;
9
+ const DEFAULT_API_BASE = (typeof process !== "undefined" && (process.env.NEXT_PUBLIC_PAPERPLANE_URL || process.env.PAPERPLANE_URL)) ||
10
+ "https://api.arcopscloud.in";
11
+ class PaperplaneClient {
12
+ constructor(apiKeyOrConfig) {
13
+ if (typeof apiKeyOrConfig === "string") {
14
+ this.apiKey = apiKeyOrConfig;
15
+ this.baseUrl = DEFAULT_API_BASE;
16
+ }
17
+ else if (apiKeyOrConfig && typeof apiKeyOrConfig === "object") {
18
+ this.apiKey = apiKeyOrConfig.apiKey || "";
19
+ this.baseUrl = apiKeyOrConfig.baseUrl || DEFAULT_API_BASE;
20
+ }
21
+ else {
22
+ this.apiKey =
23
+ typeof process !== "undefined"
24
+ ? process.env.NEXT_PUBLIC_PAPERPLANE_KEY ||
25
+ process.env.PAPERPLANE_API_KEY ||
26
+ process.env.ARCOPS_API_KEY ||
27
+ ""
28
+ : "";
29
+ this.baseUrl = DEFAULT_API_BASE;
30
+ }
31
+ }
32
+ /**
33
+ * 1. Send OTP via WhatsApp, Email, or SMS
34
+ * @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
+ */
38
+ async send(toOrOptions, channel = "whatsapp", appName = "Paperplane") {
39
+ let payload;
40
+ if (typeof toOrOptions === "string") {
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
+ }
60
+ const headers = {
61
+ "Content-Type": "application/json",
62
+ };
63
+ if (this.apiKey) {
64
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
65
+ }
66
+ const url = `${this.baseUrl.replace(/\/$/, "")}/send`;
67
+ const res = await fetch(url, {
68
+ method: "POST",
69
+ headers,
70
+ body: JSON.stringify(payload),
71
+ });
72
+ return res.json();
73
+ }
74
+ /**
75
+ * 2. Verify OTP code ($0.00 verification fee forever)
76
+ * @param to Recipient phone or email originally sent to
77
+ * @param otp 6-digit verification code entered by user
78
+ */
79
+ async verify(toOrOptions, otp) {
80
+ let payload;
81
+ if (typeof toOrOptions === "string") {
82
+ payload = {
83
+ to: toOrOptions,
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
+ }
95
+ const headers = {
96
+ "Content-Type": "application/json",
97
+ };
98
+ if (this.apiKey) {
99
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
100
+ }
101
+ const url = `${this.baseUrl.replace(/\/$/, "")}/verify`;
102
+ const res = await fetch(url, {
103
+ method: "POST",
104
+ headers,
105
+ body: JSON.stringify(payload),
106
+ });
107
+ return res.json();
108
+ }
109
+ /**
110
+ * 3. Fetch real-time delivery logs
111
+ * @param optionsOrLimit Limit number or options object { date: "YYYY-MM-DD", limit: 50 }
112
+ */
113
+ async logs(optionsOrLimit) {
114
+ let date = "";
115
+ let limit = 50;
116
+ if (typeof optionsOrLimit === "number") {
117
+ limit = optionsOrLimit;
118
+ }
119
+ else if (optionsOrLimit && typeof optionsOrLimit === "object") {
120
+ if (optionsOrLimit.date)
121
+ date = optionsOrLimit.date;
122
+ if (optionsOrLimit.limit)
123
+ limit = optionsOrLimit.limit;
124
+ }
125
+ const params = new URLSearchParams();
126
+ if (date)
127
+ params.set("date", date);
128
+ if (limit)
129
+ params.set("limit", limit.toString());
130
+ const headers = {};
131
+ if (this.apiKey) {
132
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
133
+ }
134
+ const qs = params.toString() ? `?${params.toString()}` : "";
135
+ const url = `${this.baseUrl.replace(/\/$/, "")}/logs${qs}`;
136
+ const res = await fetch(url, {
137
+ method: "GET",
138
+ headers,
139
+ });
140
+ return res.json();
141
+ }
142
+ }
143
+ exports.PaperplaneClient = PaperplaneClient;
144
+ // Default export: pre-configured singleton instance
145
+ exports.pp = new PaperplaneClient();
146
+ // Helper factory
147
+ function createPaperplane(apiKeyOrConfig) {
148
+ return new PaperplaneClient(apiKeyOrConfig);
149
+ }
150
+ exports.default = exports.pp;
package/dist/index.mjs ADDED
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Paperplane — Zero-dependency client library for the Paperplane passwordless OTP engine.
3
+ * Supports WhatsApp, SMS, and Amazon SES Email with $0.00 verification fees.
4
+ */
5
+ const DEFAULT_API_BASE = (typeof process !== "undefined" && (process.env.NEXT_PUBLIC_PAPERPLANE_URL || process.env.PAPERPLANE_URL)) ||
6
+ "https://api.arcopscloud.in";
7
+ export class PaperplaneClient {
8
+ constructor(apiKeyOrConfig) {
9
+ if (typeof apiKeyOrConfig === "string") {
10
+ this.apiKey = apiKeyOrConfig;
11
+ this.baseUrl = DEFAULT_API_BASE;
12
+ }
13
+ else if (apiKeyOrConfig && typeof apiKeyOrConfig === "object") {
14
+ this.apiKey = apiKeyOrConfig.apiKey || "";
15
+ this.baseUrl = apiKeyOrConfig.baseUrl || DEFAULT_API_BASE;
16
+ }
17
+ else {
18
+ this.apiKey =
19
+ typeof process !== "undefined"
20
+ ? process.env.NEXT_PUBLIC_PAPERPLANE_KEY ||
21
+ process.env.PAPERPLANE_API_KEY ||
22
+ process.env.ARCOPS_API_KEY ||
23
+ ""
24
+ : "";
25
+ this.baseUrl = DEFAULT_API_BASE;
26
+ }
27
+ }
28
+ /**
29
+ * 1. Send OTP via WhatsApp, Email, or SMS
30
+ * @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
+ */
34
+ async send(toOrOptions, channel = "whatsapp", appName = "Paperplane") {
35
+ let payload;
36
+ if (typeof toOrOptions === "string") {
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
+ }
56
+ const headers = {
57
+ "Content-Type": "application/json",
58
+ };
59
+ if (this.apiKey) {
60
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
61
+ }
62
+ const url = `${this.baseUrl.replace(/\/$/, "")}/send`;
63
+ const res = await fetch(url, {
64
+ method: "POST",
65
+ headers,
66
+ body: JSON.stringify(payload),
67
+ });
68
+ return res.json();
69
+ }
70
+ /**
71
+ * 2. Verify OTP code ($0.00 verification fee forever)
72
+ * @param to Recipient phone or email originally sent to
73
+ * @param otp 6-digit verification code entered by user
74
+ */
75
+ async verify(toOrOptions, otp) {
76
+ let payload;
77
+ if (typeof toOrOptions === "string") {
78
+ payload = {
79
+ to: toOrOptions,
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
+ }
91
+ const headers = {
92
+ "Content-Type": "application/json",
93
+ };
94
+ if (this.apiKey) {
95
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
96
+ }
97
+ const url = `${this.baseUrl.replace(/\/$/, "")}/verify`;
98
+ const res = await fetch(url, {
99
+ method: "POST",
100
+ headers,
101
+ body: JSON.stringify(payload),
102
+ });
103
+ return res.json();
104
+ }
105
+ /**
106
+ * 3. Fetch real-time delivery logs
107
+ * @param optionsOrLimit Limit number or options object { date: "YYYY-MM-DD", limit: 50 }
108
+ */
109
+ async logs(optionsOrLimit) {
110
+ let date = "";
111
+ let limit = 50;
112
+ if (typeof optionsOrLimit === "number") {
113
+ limit = optionsOrLimit;
114
+ }
115
+ else if (optionsOrLimit && typeof optionsOrLimit === "object") {
116
+ if (optionsOrLimit.date)
117
+ date = optionsOrLimit.date;
118
+ if (optionsOrLimit.limit)
119
+ limit = optionsOrLimit.limit;
120
+ }
121
+ const params = new URLSearchParams();
122
+ if (date)
123
+ params.set("date", date);
124
+ if (limit)
125
+ params.set("limit", limit.toString());
126
+ const headers = {};
127
+ if (this.apiKey) {
128
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
129
+ }
130
+ const qs = params.toString() ? `?${params.toString()}` : "";
131
+ const url = `${this.baseUrl.replace(/\/$/, "")}/logs${qs}`;
132
+ const res = await fetch(url, {
133
+ method: "GET",
134
+ headers,
135
+ });
136
+ return res.json();
137
+ }
138
+ }
139
+ // Default export: pre-configured singleton instance
140
+ export const pp = new PaperplaneClient();
141
+ // Helper factory
142
+ export function createPaperplane(apiKeyOrConfig) {
143
+ return new PaperplaneClient(apiKeyOrConfig);
144
+ }
145
+ export default pp;
package/package.json CHANGED
@@ -1,6 +1,39 @@
1
1
  {
2
2
  "name": "paperplane-sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "1.0.1",
4
+ "description": "Zero-dependency client SDK for Paperplane passwordless OTP and messaging engine",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.mjs",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.mjs",
12
+ "require": "./dist/index.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc"
22
+ },
23
+ "keywords": [
24
+ "paperplane",
25
+ "otp",
26
+ "whatsapp",
27
+ "sms",
28
+ "email",
29
+ "passwordless",
30
+ "auth",
31
+ "arcops",
32
+ "sdk"
33
+ ],
34
+ "author": "ArcOps",
35
+ "license": "MIT",
36
+ "devDependencies": {
37
+ "typescript": "^5.0.0"
38
+ }
6
39
  }