ab-ecosystem-cpass 1.0.11 → 1.0.13

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 (39) hide show
  1. package/README.md +1 -0
  2. package/dist/client.d.ts +6 -0
  3. package/dist/client.js +7 -0
  4. package/dist/client.js.map +1 -1
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.js +8 -1
  7. package/dist/index.js.map +1 -1
  8. package/dist/internal/embedded-signup.d.ts +46 -0
  9. package/dist/internal/embedded-signup.js +318 -0
  10. package/dist/internal/embedded-signup.js.map +1 -0
  11. package/dist/resources/channels/onboarding.d.ts +89 -0
  12. package/dist/resources/channels/onboarding.js +96 -0
  13. package/dist/resources/channels/onboarding.js.map +1 -0
  14. package/dist/types/campaign.d.ts +8 -0
  15. package/dist/types/channels.d.ts +129 -0
  16. package/dist/types/channels.js.map +1 -1
  17. package/docs/audience/canned-replies.md +3 -0
  18. package/docs/audience/contact-tags.md +4 -0
  19. package/docs/audience/contacts.md +30 -1
  20. package/docs/audience/crm-triggers.md +3 -0
  21. package/docs/audience/custom-fields.md +23 -0
  22. package/docs/audience/exports.md +6 -0
  23. package/docs/audience/imports.md +7 -0
  24. package/docs/audience/notifications.md +11 -0
  25. package/docs/audience/scheduled-messages.md +5 -0
  26. package/docs/audience/segments.md +4 -0
  27. package/docs/audience/webhooks.md +7 -0
  28. package/docs/campaign/campaigns.md +27 -0
  29. package/docs/channels/activity.md +3 -0
  30. package/docs/channels/billing.md +2 -0
  31. package/docs/channels/channel-props.md +19 -0
  32. package/docs/channels/channels.md +35 -2
  33. package/docs/channels/onboarding.md +530 -0
  34. package/docs/channels/templates.md +22 -0
  35. package/docs/channels/wallet.md +2 -0
  36. package/docs/channels/webhooks.md +6 -0
  37. package/docs/data-store.md +18 -0
  38. package/docs/inbox/connection.md +88 -0
  39. package/package.json +1 -1
@@ -132,6 +132,8 @@ try {
132
132
  |---|---|---|
133
133
  | 401 | `unauthorized` | The handshake's token did not verify. |
134
134
  | 403 | `forbidden` | The action is beyond this member's permissions. |
135
+ | 403 | `A403` | The role does not hold the permission the action needs. |
136
+ | 403 | `E403` | The account's plan does not include the feature. `details.feature` names it. |
135
137
  | 404 | `not_found` | No such chat or message **for this account**. |
136
138
  | 422 | `validation_failed` | Payload rejected. `details` names the fields. |
137
139
  | 500 | `internal_error` | Server fault. Nothing further is disclosed. |
@@ -146,6 +148,29 @@ Every read and write is scoped to the account the token identifies, the same way
146
148
  the REST contact endpoints are. Quoting another account's chat or message id
147
149
  produces `404`, not that account's data.
148
150
 
151
+ Which account that is depends on who signed in. The token's `act` claim says:
152
+
153
+ | `act` | The account | Who you are |
154
+ |---|---|---|
155
+ | `owner` (or absent) | your own `psuid` | the account holder |
156
+ | `member` | the `accountId` claim | someone the holder granted access to |
157
+
158
+ A member works inside the owner's account — the owner's chats, contacts and
159
+ channels, counted against the owner's plan. How much of it they see is the
160
+ role's `data_scope`:
161
+
162
+ | `data_scope` | Sees |
163
+ |---|---|
164
+ | `own` (or absent) | the chats and contacts assigned to them |
165
+ | `all` | everything in the account |
166
+
167
+ Absent means `own`: a role the server could not read narrows rather than opens.
168
+ Nothing distinguishes an owner from a member in a request — the same events, the
169
+ same payloads — and a chat nobody assigned you simply is not there. A chat
170
+ assigned to nobody at all is the account's, not everybody's, so an `own`-scoped
171
+ member does not see it either; `live_chat.unassigned.*` below is how that is
172
+ granted.
173
+
149
174
  ## Permissions
150
175
 
151
176
  Visibility inside an account is gated on inbox permissions, not API scopes. An
@@ -160,6 +185,69 @@ owner or a manager is never gated; a team member needs the permission named.
160
185
  A team member without these is narrowed to their own chats rather than refused —
161
186
  and the reply says so. See [chats.md](https://github.com/udghatan-dev/crm-sdk/blob/main/packages/sdk-js/docs/inbox/chats.md#the-applied-filter).
162
187
 
188
+ The token carries a `roleId` rather than a list of permissions. The server
189
+ resolves it against the SSO at connect — once per role version, cached — and the
190
+ grants it returns are what the table above is checked against. A role that
191
+ grants none of these names leaves the member in the narrow case: their assigned
192
+ chats, no unassigned queue, no sending as somebody else. So does a role the SSO
193
+ cannot be asked about, which is deliberate — an SSO outage narrows a member, it
194
+ never opens an account.
195
+
196
+ Permissions are read once, at connect. A role edited mid-session takes effect on
197
+ the next reconnect, the same way an upgraded plan does. A member's `role` is
198
+ `team_member` unless the token says `manager`.
199
+
200
+ ### Permission keys, per event
201
+
202
+ `CRM.CHAT` governs the inbox, and every event names a verb of it. There is no
203
+ router here, so the check runs in the dispatcher in the position route
204
+ middleware would occupy — before the handler, after the payload is validated.
205
+
206
+ | Event | Key |
207
+ | --- | --- |
208
+ | `contact.list`, `ctwa.list` | `CRM.CHAT.LIST` |
209
+ | `contact.fetch`, `chat_session.list`, `message.list`, `message.fetch`, `message.retry_download` | `CRM.CHAT.READ` |
210
+ | `message.send` | `CRM.CHAT.SEND` |
211
+ | `message.delete` | `CRM.CHAT.DELETE` |
212
+ | `contact.update`, `contact.done`, `contact.bot_assign` | `CRM.CHAT.UPDATE` |
213
+ | `chat.action` | **depends on the action** |
214
+ | `ping` | none — it is a liveness probe |
215
+
216
+ `chat.action` carries thirteen actions under one event name, and they are not one
217
+ capability: `transfer` and `bulk_transfer` need `CRM.CHAT.TRANSFER`, `delete`
218
+ needs `CRM.CHAT.DELETE`, and the state changes — archive, unarchive, close, done,
219
+ block, mark read/unread, pause/resume automation, pause timer — need
220
+ `CRM.CHAT.UPDATE`. The key is resolved from the validated payload, so a client
221
+ that may archive but not delete gets `A403` on the second and nothing changes.
222
+
223
+ `contact.bot_assign` is `UPDATE`, not `ASSIGN`: it hands a conversation to
224
+ automation rather than to a colleague, and the catalogue's `ASSIGN` implies
225
+ `TEAM.LIST` because choosing a person means seeing the team.
226
+
227
+ A refusal arrives as the same `A403` / `E403` the REST API returns, in the
228
+ acknowledgement callback and as an `error` emit.
229
+
230
+ ### `live_chat.*` is a separate, older vocabulary
231
+
232
+ The three permissions in the table above this section are **not in the SSO's
233
+ catalogue**. A role can only grant what the catalogue publishes, so nothing can
234
+ currently grant `live_chat.unassigned.ALL` — the way to give a member the whole
235
+ account's inbox is `data_scope: all` on their role, which `CRM.CHAT` is marked
236
+ **scopable** for. The three names are kept because the inbox still checks them.
237
+
238
+ ### Two different refusals
239
+
240
+ Beyond the inbox's own visibility rules, an action can be refused for either of
241
+ two reasons, and the codes are distinct because the answers are:
242
+
243
+ - **`A403`** — the role does not hold the permission. Ask the account owner.
244
+ - **`E403`** — the account's plan does not cover the feature. Upgrade.
245
+ `details.feature` names the feature, so the client can say which.
246
+
247
+ An owner is never refused for `A403` — there is no role to check them against —
248
+ but an owner *is* refused for `E403`: a feature outside the plan is outside it
249
+ for everybody on the account.
250
+
163
251
  ## Modules
164
252
 
165
253
  | Page | Actions |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ab-ecosystem-cpass",
3
- "version": "1.0.11",
3
+ "version": "1.0.13",
4
4
  "description": "JavaScript/TypeScript SDK for the CPaaS CRM gateway: audience and channels",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",