contiguity 0.0.6 → 0.0.7

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.
Files changed (2) hide show
  1. package/README.md +48 -156
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,186 +1,78 @@
1
- # Contiguity JavaScript/TypeScript SDK
1
+ <p align='center'><img src="https://contiguity.co/assets/icon-black.png" height="150px"/></p>
2
+ <h1 align='center'>Contiguity JavaScript SDK</h1>
2
3
 
3
- Official SDK for [Contiguity](https://contiguity.com). Send SMS, email, OTPs, iMessage, WhatsApp, manage domains and number leases, and verify webhooks.
4
+ <p align='center'>
5
+ <img display="inline-block" src="https://img.shields.io/npm/v/contiguity?style=for-the-badge" />
6
+ <img display="inline-block" src="https://img.shields.io/badge/Made%20with-TypeScript-3178C6?style=for-the-badge&logo=typescript&logoColor=white" />
7
+ </p>
4
8
 
5
- ## Install
9
+ <p align='center'>The official TypeScript/JavaScript SDK for Contiguity's APIs.</p>
6
10
 
7
- Works with Node 18+, Bun, and bundlers. ESM only.
11
+ ## Installation
8
12
 
9
13
  ```bash
10
- bun add contiguity
11
- # or
12
- pnpm add contiguity
13
- # or
14
+ # Using npm
14
15
  npm install contiguity
15
- # or
16
- yarn add contiguity
17
- ```
18
16
 
19
- ## Init
17
+ # Using pnpm
18
+ pnpm add contiguity
20
19
 
21
- ```ts
22
- import { Contiguity } from "contiguity";
20
+ # Using bun
21
+ bun add contiguity
22
+ ```
23
23
 
24
- const contiguity = new Contiguity("contiguity_sk_...your_token...");
24
+ ## Getting Started
25
25
 
26
- // Or omit the token and use env: CONTIGUITY_API_KEY or CONTIGUITY_TOKEN
27
- const contiguity = new Contiguity();
26
+ ```typescript
27
+ import { Contiguity } from 'contiguity';
28
28
 
29
- // With options
30
- const contiguity = new Contiguity("contiguity_sk_...", {
31
- debug: false, // set true for request logging
32
- });
29
+ const contiguity = new Contiguity('contiguity_sk_...your_token...');
33
30
  ```
34
31
 
35
- ## Quick start
32
+ Get your API token from the [Contiguity Console](https://console.contiguity.com/).
36
33
 
37
- ### Text (SMS)
34
+ ### Send a text message
38
35
 
39
- ```ts
40
- const res = await contiguity.text.send({
41
- to: "+1234567890",
42
- message: "Hello from Contiguity!",
43
- // from: "+15555555555", // optional, if you lease a number
36
+ ```typescript
37
+ const response = await contiguity.text.send({
38
+ to: "+1234567890",
39
+ message: "Hello from Contiguity!"
44
40
  });
45
- // res.message_id, res.metadata
46
-
47
- await contiguity.text.get("text_abc123");
48
- await contiguity.text.history({ to: "+1…", from: "+1…", limit: 20 });
49
- await contiguity.text.react("add", { message_id: "text_abc", reaction: "love" });
50
41
  ```
51
42
 
52
- ### Email
43
+ ### Send an email
53
44
 
54
- ```ts
55
- const res = await contiguity.email.send({
56
- to: "user@example.com",
57
- from: "Your App <no-reply@yourapp.com>",
58
- subject: "Welcome!",
59
- body: { text: "Welcome to our platform!" },
45
+ ```typescript
46
+ const response = await contiguity.email.send({
47
+ to: "user@example.com",
48
+ from: "Your App <no-reply@yourapp.com>",
49
+ subject: "Welcome!",
50
+ body: { text: "Welcome to our platform!" }
60
51
  });
61
- // res.email_id, res.metadata
62
52
  ```
63
53
 
64
- ### OTP
54
+ ### Send and verify OTP
65
55
 
66
- ```ts
67
- const res = await contiguity.otp.new({
68
- to: "+1234567890",
69
- language: "en",
70
- name: "MyApp",
56
+ ```typescript
57
+ const otpResponse = await contiguity.otp.send({
58
+ to: "+1234567890",
59
+ language: "en",
60
+ name: "MyApp"
71
61
  });
72
- // res.otp_id
73
-
74
- const verified = await contiguity.otp.verify({ otp_id: res.otp_id, otp: "123456" });
75
- // verified.verified === true | false
76
-
77
- await contiguity.otp.resend({ otp_id: res.otp_id });
78
- ```
79
-
80
- ### Domains
81
-
82
- ```ts
83
- const list = await contiguity.domains.list();
84
- const one = await contiguity.domains.get("example.com");
85
- await contiguity.domains.register("example.com", { region: "us-east-1", custom_return_path: "mail" });
86
- await contiguity.domains.delete("example.com");
87
- ```
88
-
89
- ### Lease (numbers)
90
-
91
- ```ts
92
- const available = await contiguity.lease.available();
93
- const details = await contiguity.lease.get("+1234567890");
94
- await contiguity.lease.create("+1234567890", { billing_method: "monthly" });
95
- const leased = await contiguity.lease.leased();
96
- const leaseDetails = await contiguity.lease.details("+1234567890");
97
- await contiguity.lease.terminate("+1234567890");
98
- ```
99
-
100
- ### iMessage / WhatsApp
101
-
102
- ```ts
103
- await contiguity.imessage.send({ to: "+1234567890", message: "Hello via iMessage!" });
104
- await contiguity.imessage.typing({ to: "+1234567890", action: "start" });
105
- await contiguity.imessage.get("imessage_abc123");
106
- await contiguity.imessage.history({ to: "+1…", from: "+1…", limit: 20 });
107
- await contiguity.imessage.react("add", { to: "+1…", from: "+1…", tapback: "love", message: "Hello!" });
108
- await contiguity.imessage.read({ to: "+1234567890", from: "+15555555555" });
109
-
110
- await contiguity.whatsapp.send({ to: "+1234567890", message: "Hello via WhatsApp!" });
111
- await contiguity.whatsapp.typing({ to: "+1234567890", action: "stop" });
112
- await contiguity.whatsapp.react("add", { to: "+1234567890", reaction: "👍", message: "wa_123" });
113
- ```
114
62
 
115
- ### Webhooks
116
-
117
- Verify signature (use raw body and `Contiguity-Signature` header):
118
-
119
- ```ts
120
- // With request-like object (e.g. Express req with raw body)
121
- const ok = contiguity.webhook.verify(req, process.env.WEBHOOK_SECRET, 300);
122
-
123
- // Or with raw values
124
- const ok = contiguity.webhook.verify(rawBody, signatureHeader, secret, 300);
125
- ```
126
-
127
- Parse webhook body (v2 format):
128
-
129
- ```ts
130
- const event = contiguity.webhook.parse(rawBody);
131
- // event.id, event.type, event.timestamp, event.data
132
- ```
133
-
134
- ### Pass-through options
135
-
136
- Request params accept extra JSON; unknown fields are sent to the API as-is. Types are defined for known fields; you can add more for new API options.
137
-
138
- ## Response format
139
-
140
- All responses return a clean shape: method-specific fields at the top level plus `metadata`:
141
-
142
- ```ts
143
- {
144
- message_id?: string;
145
- email_id?: string;
146
- otp_id?: string;
147
- // ... etc
148
- metadata: { id: string; timestamp: string; api_version: string; object: string; }
149
- }
150
- ```
151
-
152
- ## Errors
153
-
154
- On API errors the SDK throws `ContiguityError` with `message`, `status`, and optional `code`.
155
-
156
- ```ts
157
- import { ContiguityError } from "contiguity";
158
- try {
159
- await contiguity.text.send({ ... });
160
- } catch (e) {
161
- if (e instanceof ContiguityError) {
162
- console.error(e.status, e.message);
163
- }
164
- }
63
+ const verification = await contiguity.otp.verify({
64
+ otp_id: otpResponse.otp_id,
65
+ otp: "123456"
66
+ });
165
67
  ```
166
68
 
167
- ## Docs
168
-
169
- - [SDK overview](https://docs.contiguity.com/sdk/js/overview)
170
- - [API reference](https://docs.contiguity.com/llms.txt)
171
-
172
- ## Development
173
-
174
- Use Bun for local dev and publishing:
175
-
176
- - `bun install` / `bun run build` — install and compile
177
- - `bun run test` — build and run Vitest (Vitest loads `.env` from project root; unit tests always run; live API tests when `CONTIGUITY_TEST_API_KEY` is set; send tests need `CONTIGUITY_TEST_TO`, optional `CONTIGUITY_TEST_FROM`, `CONTIGUITY_TEST_EMAIL`, optional `CONTIGUITY_TEST_EMAIL_FROM_NAME`)
178
- - `bun run pack` — create the tarball (e.g. `contiguity-1.0.0.tgz`) without publishing
179
- - `bun run publish:dry` — build and simulate publish (no upload)
180
- - `bun publish` — build (via prepublishOnly) and publish to the registry
69
+ ## Documentation
181
70
 
182
- The published package is runtime-agnostic ESM and works for everyone.
71
+ For complete documentation, examples, and API reference, visit [docs.contiguity.com](https://docs.contiguity.com/sdk/js/overview).
183
72
 
184
- ## License
73
+ ## Resources
185
74
 
186
- MIT
75
+ - [API Reference](https://docs.contiguity.com/api-reference/) - Complete API documentation
76
+ - [Console](https://console.contiguity.com/) - Manage your account and API keys
77
+ - [Discord Community](https://discord.gg/Z9K5XAsS7H) - Get support and connect with other developers
78
+ - [GitHub Repository](https://github.com/contiguity/javascript) - Source code and issue tracking
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contiguity",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "description": "Contiguity JavaScript/TypeScript SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",