@supportwire/messenger-js-sdk 1.0.26
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/README.md +80 -0
- package/dist/index-bfV4xNqW-CRQbrL80.js +1092 -0
- package/dist/index-bfV4xNqW-CRQbrL80.js.map +1 -0
- package/dist/index-bfV4xNqW-ChZOGalc.cjs +162 -0
- package/dist/index-bfV4xNqW-ChZOGalc.cjs.map +1 -0
- package/dist/index.cjs +921 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +149 -0
- package/dist/index.js +2646 -0
- package/dist/index.js.map +1 -0
- package/dist/snapdom-6yvsn_Iv-6uiY9rZc.js +3373 -0
- package/dist/snapdom-6yvsn_Iv-6uiY9rZc.js.map +1 -0
- package/dist/snapdom-6yvsn_Iv-OVmChxqF.cjs +9 -0
- package/dist/snapdom-6yvsn_Iv-OVmChxqF.cjs.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# @supportwire/messenger-js-sdk
|
|
2
|
+
|
|
3
|
+
Drop-in replacement for [`@intercom/messenger-js-sdk`](https://www.npmjs.com/package/@intercom/messenger-js-sdk) that mounts a SupportWire widget.
|
|
4
|
+
|
|
5
|
+
Native usage:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
import SupportWire from '@supportwire/messenger-js-sdk';
|
|
9
|
+
|
|
10
|
+
SupportWire({
|
|
11
|
+
app_id: 'your-supportwire-widget-slug',
|
|
12
|
+
user_id: currentUser.id,
|
|
13
|
+
email: currentUser.email,
|
|
14
|
+
user_hash: currentUser.supportwireHash,
|
|
15
|
+
name: currentUser.name,
|
|
16
|
+
});
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
If you're migrating an existing Intercom integration, default imports can be
|
|
20
|
+
renamed at the import site — no other code change required:
|
|
21
|
+
|
|
22
|
+
```diff
|
|
23
|
+
- import Intercom from '@intercom/messenger-js-sdk';
|
|
24
|
+
+ import Intercom from '@supportwire/messenger-js-sdk';
|
|
25
|
+
|
|
26
|
+
Intercom({
|
|
27
|
+
- app_id: 'your-intercom-app-id',
|
|
28
|
+
+ app_id: 'your-supportwire-widget-slug',
|
|
29
|
+
user_id: currentUser.id,
|
|
30
|
+
email: currentUser.email,
|
|
31
|
+
- user_hash: currentUser.intercomHash,
|
|
32
|
+
+ user_hash: currentUser.supportwireHash,
|
|
33
|
+
name: currentUser.name,
|
|
34
|
+
});
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## What's the `app_id`?
|
|
38
|
+
|
|
39
|
+
For SupportWire, `app_id` is your **widget slug** — the opaque, lowercase
|
|
40
|
+
alphanumeric identifier shown next to each widget in the admin panel at
|
|
41
|
+
`/settings/widgets`. Each widget is owned by one organization. Your
|
|
42
|
+
backend resolves the org from the widget slug; you do not need to send a
|
|
43
|
+
separate org identifier.
|
|
44
|
+
|
|
45
|
+
## Identity & HMAC
|
|
46
|
+
|
|
47
|
+
When identity verification is enabled on your organization, send a
|
|
48
|
+
`user_hash` computed server-side. The HMAC subject is
|
|
49
|
+
`user_id ?? email` — i.e. when `user_id` is present it wins, otherwise
|
|
50
|
+
the (lowercased, trimmed) email is signed.
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
import crypto from 'node:crypto';
|
|
54
|
+
const subject = currentUser.id ?? currentUser.email.trim().toLowerCase();
|
|
55
|
+
const userHash = crypto
|
|
56
|
+
.createHmac('sha256', SUPPORTWIRE_HMAC_SECRET)
|
|
57
|
+
.update(subject)
|
|
58
|
+
.digest('hex');
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Supported methods
|
|
62
|
+
|
|
63
|
+
| Method | Status |
|
|
64
|
+
|---|---|
|
|
65
|
+
| `Intercom(settings)` / `boot(settings)` | ✅ |
|
|
66
|
+
| `update(settings)` | ✅ |
|
|
67
|
+
| `shutdown()` | ✅ |
|
|
68
|
+
| `show()` / `hide()` | ✅ |
|
|
69
|
+
| `showNewMessage(content?)` | ✅ (opens widget + sends content if supplied) |
|
|
70
|
+
| `onShow(cb)` / `onHide(cb)` / `onUnreadCountChange(cb)` / `onUserEmailSupplied(cb)` | ✅ |
|
|
71
|
+
| `getVisitorId()` / `whoami()` | ⚠️ returns `null` for now |
|
|
72
|
+
| `trackEvent(name, metadata?)` | ⚠️ no-op + warn until backend endpoint ships |
|
|
73
|
+
| `hideNotifications(hidden)` | ⚠️ no-op + warn |
|
|
74
|
+
| `startTour` / `showArticle` / `showNews` / `startSurvey` / `startChecklist` / `showTicket` / `showConversation` / `showSpace` / `showMessages` | ⚠️ no-op + warn (no SupportWire equivalent) |
|
|
75
|
+
|
|
76
|
+
## Differences from Intercom
|
|
77
|
+
|
|
78
|
+
- The product surface is smaller (no tours/articles/news/surveys). Those methods are silent no-ops so existing call sites don't throw.
|
|
79
|
+
- `getVisitorId()` is synchronous in Intercom; ours returns `null` until an async fallback is added.
|
|
80
|
+
- We do not masquerade as `window.Intercom` globally — the queue stub lives on `window.SupportWireMessenger` so both packages can coexist during migration.
|