@unboundcx/sdk 4.13.112-security.0 → 4.13.112-security.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/index.js CHANGED
@@ -48,6 +48,7 @@ import { ChatService } from './services/chat.js';
48
48
  import { DeveloperApisService } from './services/developerApis.js';
49
49
  import { TextService } from './services/text.js';
50
50
  import { ReportingService } from './services/reporting.js';
51
+ import { OAuthService } from './services/oauth.js';
51
52
  import {
52
53
  DataImportService,
53
54
  DataExportService,
@@ -146,6 +147,7 @@ class UnboundSDK extends BaseSDK {
146
147
  this.recents = new RecentsService(this);
147
148
  this.search = new SearchService(this);
148
149
  this.directory = new DirectoryService(this);
150
+ this.oauth = new OAuthService(this);
149
151
  this.chat = new ChatService(this);
150
152
  this.developerApis = new DeveloperApisService(this);
151
153
  this.dataImport = new DataImportService(this);
@@ -352,6 +354,7 @@ export { ReportingService } from './services/reporting.js';
352
354
  export { RecentsService } from './services/recents.js';
353
355
  export { SearchService } from './services/search.js';
354
356
  export { DirectoryService } from './services/directory.js';
357
+ export { OAuthService } from './services/oauth.js';
355
358
  export { ChatService } from './services/chat.js';
356
359
  export { DeveloperApisService } from './services/developerApis.js';
357
360
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unboundcx/sdk",
3
- "version": "4.13.112-security.0",
3
+ "version": "4.13.112-security.1",
4
4
  "description": "Official JavaScript SDK for the Unbound API - A comprehensive toolkit for integrating with Unbound's communication, AI, and data management services",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -0,0 +1,159 @@
1
+ import { internalRequest } from '../base.js';
2
+
3
+ /**
4
+ * OAuth provider -- staff registry of OAuth clients (security-upgrades H1
5
+ * frozen contract). Every method hits `/oauth/clients*` under
6
+ * checkApiAuth; the server enforces `admin:oauthclient:manage`. Public
7
+ * authorize/token/introspect/revoke endpoints (H2/H3/H4) are not client
8
+ * methods -- they are third-party-facing, not called through this SDK.
9
+ *
10
+ * Exposed as `sdk.oauth.clients.*` (nested, since `oauth` is expected to
11
+ * grow other sub-surfaces alongside `clients` as H2-H4 land).
12
+ */
13
+ export class OAuthService {
14
+ constructor(sdk) {
15
+ this.sdk = sdk;
16
+ this.clients = new OAuthClientsService(sdk);
17
+ }
18
+ }
19
+
20
+ class OAuthClientsService {
21
+ constructor(sdk) {
22
+ this.sdk = sdk;
23
+ }
24
+
25
+ /**
26
+ * List this account's OAuth clients.
27
+ * @returns {Promise<Object>} `{ clients: [...] }`
28
+ * @example
29
+ * const { clients } = await sdk.oauth.clients.list();
30
+ */
31
+ async list() {
32
+ return internalRequest(this.sdk, '/oauth/clients', 'GET');
33
+ }
34
+
35
+ /**
36
+ * Register a new OAuth client.
37
+ * @param {Object} body
38
+ * @param {string} body.name
39
+ * @param {string} body.clientType - 'confidential' | 'public'
40
+ * @param {string[]} body.redirectUris
41
+ * @param {string[]} body.grantTypes - subset of 'authorization_code' | 'refresh_token' | 'client_credentials'
42
+ * @param {string[]} body.allowedScopes
43
+ * @param {string} [body.linkedUserId] - required when grantTypes includes 'client_credentials' (D11)
44
+ * @param {string} [body.logoUrl]
45
+ * @returns {Promise<Object>} `{ client, secret? }` -- secret is plaintext, shown once, confidential clients only
46
+ * @example
47
+ * const { client, secret } = await sdk.oauth.clients.create({
48
+ * name: 'Zapier',
49
+ * clientType: 'confidential',
50
+ * redirectUris: ['https://zapier.com/oauth/callback'],
51
+ * grantTypes: ['authorization_code', 'refresh_token'],
52
+ * allowedScopes: ['cdp:object:*:read'],
53
+ * });
54
+ */
55
+ async create(body) {
56
+ this.sdk.validateParams(body || {}, {
57
+ name: { type: 'string', required: true },
58
+ clientType: { type: 'string', required: true },
59
+ redirectUris: { type: 'array', required: true },
60
+ grantTypes: { type: 'array', required: true },
61
+ allowedScopes: { type: 'array', required: true },
62
+ linkedUserId: { type: 'string', required: false },
63
+ logoUrl: { type: 'string', required: false },
64
+ });
65
+ return internalRequest(this.sdk, '/oauth/clients', 'POST', { body });
66
+ }
67
+
68
+ /**
69
+ * Get one OAuth client.
70
+ * @param {string} id
71
+ * @returns {Promise<Object>} `{ client }`
72
+ */
73
+ async get(id) {
74
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
75
+ return internalRequest(this.sdk, `/oauth/clients/${id}`, 'GET');
76
+ }
77
+
78
+ /**
79
+ * Update an OAuth client. Any subset of the create fields, plus `status`
80
+ * ('active' | 'disabled').
81
+ * @param {string} id
82
+ * @param {Object} body
83
+ * @returns {Promise<Object>} `{ client }`
84
+ */
85
+ async update(id, body) {
86
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
87
+ return internalRequest(this.sdk, `/oauth/clients/${id}`, 'PUT', { body });
88
+ }
89
+
90
+ /**
91
+ * Soft-delete an OAuth client.
92
+ * @param {string} id
93
+ * @returns {Promise<Object>} `{ message }`
94
+ */
95
+ async remove(id) {
96
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
97
+ return internalRequest(this.sdk, `/oauth/clients/${id}`, 'DELETE');
98
+ }
99
+
100
+ /**
101
+ * List a client's secrets (id/createdAt/expiresAt/revokedAt/lastUsedAt
102
+ * only -- never the hash or plaintext). Use the returned `id` values
103
+ * with revokeSecret() to decommission an old/compromised secret.
104
+ * @param {string} id
105
+ * @returns {Promise<Object>} `{ secrets: [...] }`
106
+ */
107
+ async listSecrets(id) {
108
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
109
+ return internalRequest(this.sdk, `/oauth/clients/${id}/secrets`, 'GET');
110
+ }
111
+
112
+ /**
113
+ * Mint a new client secret. The old secret keeps working until revoked.
114
+ * @param {string} id
115
+ * @returns {Promise<Object>} `{ secret }` -- plaintext, shown once
116
+ */
117
+ async rotateSecret(id) {
118
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
119
+ return internalRequest(this.sdk, `/oauth/clients/${id}/secrets`, 'POST');
120
+ }
121
+
122
+ /**
123
+ * Revoke one of a client's secrets.
124
+ * @param {string} id
125
+ * @param {string} secretId
126
+ * @returns {Promise<Object>} `{ message }`
127
+ */
128
+ async revokeSecret(id, secretId) {
129
+ this.sdk.validateParams(
130
+ { id, secretId },
131
+ { id: { type: 'string', required: true }, secretId: { type: 'string', required: true } },
132
+ );
133
+ return internalRequest(this.sdk, `/oauth/clients/${id}/secrets/${secretId}`, 'DELETE');
134
+ }
135
+
136
+ /**
137
+ * List a client's user consent grants.
138
+ * @param {string} id
139
+ * @returns {Promise<Object>} `{ grants: [...] }`
140
+ */
141
+ async listGrants(id) {
142
+ this.sdk.validateParams({ id }, { id: { type: 'string', required: true } });
143
+ return internalRequest(this.sdk, `/oauth/clients/${id}/grants`, 'GET');
144
+ }
145
+
146
+ /**
147
+ * Revoke a client's consent grant for one user.
148
+ * @param {string} id
149
+ * @param {string} grantId
150
+ * @returns {Promise<Object>} `{ message }`
151
+ */
152
+ async revokeGrant(id, grantId) {
153
+ this.sdk.validateParams(
154
+ { id, grantId },
155
+ { id: { type: 'string', required: true }, grantId: { type: 'string', required: true } },
156
+ );
157
+ return internalRequest(this.sdk, `/oauth/clients/${id}/grants/${grantId}`, 'DELETE');
158
+ }
159
+ }