@unboundcx/sdk 1.0.8 → 1.2.0
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/base.js +27 -3
- package/package.json +1 -1
- package/services/login.js +32 -4
package/base.js
CHANGED
|
@@ -32,6 +32,7 @@ export class BaseSDK {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
this.transports = new Map();
|
|
35
|
+
this.debugMode = false;
|
|
35
36
|
this._initializeEnvironment();
|
|
36
37
|
}
|
|
37
38
|
|
|
@@ -73,6 +74,11 @@ export class BaseSDK {
|
|
|
73
74
|
}
|
|
74
75
|
}
|
|
75
76
|
|
|
77
|
+
debug(enabled = true) {
|
|
78
|
+
this.debugMode = enabled;
|
|
79
|
+
return this;
|
|
80
|
+
}
|
|
81
|
+
|
|
76
82
|
addTransport(transport) {
|
|
77
83
|
if (!transport || typeof transport.request !== 'function') {
|
|
78
84
|
throw new Error('Transport must have a request method');
|
|
@@ -172,8 +178,19 @@ export class BaseSDK {
|
|
|
172
178
|
fwRequestId: this.fwRequestId,
|
|
173
179
|
baseURL: this.baseURL || this.fullUrl,
|
|
174
180
|
});
|
|
181
|
+
|
|
182
|
+
// Debug logging for transport plugins
|
|
183
|
+
if (this.debugMode) {
|
|
184
|
+
const status = result?.status || 200;
|
|
185
|
+
console.log(`API :: ${transport.name} :: ${method.toUpperCase()} :: ${endpoint} :: ${status}`);
|
|
186
|
+
}
|
|
187
|
+
|
|
175
188
|
return result;
|
|
176
189
|
} catch (err) {
|
|
190
|
+
// Debug logging for transport plugin failures
|
|
191
|
+
if (this.debugMode) {
|
|
192
|
+
console.log(`API :: ${transport.name} :: ${method.toUpperCase()} :: ${endpoint} :: ERROR :: ${err.message}`);
|
|
193
|
+
}
|
|
177
194
|
console.warn(
|
|
178
195
|
`Transport ${transport.name} failed, falling back to HTTP:`,
|
|
179
196
|
err.message,
|
|
@@ -256,6 +273,11 @@ export class BaseSDK {
|
|
|
256
273
|
responseHeaders?.['x-request-id'];
|
|
257
274
|
|
|
258
275
|
if (!response.ok) {
|
|
276
|
+
// Debug logging for HTTP errors
|
|
277
|
+
if (this.debugMode) {
|
|
278
|
+
console.log(`API :: https :: ${method.toUpperCase()} :: ${endpoint} :: ${response?.status}`);
|
|
279
|
+
}
|
|
280
|
+
|
|
259
281
|
throw {
|
|
260
282
|
name: `API :: Error :: https :: ${method} :: ${endpoint} :: ${responseRequestId} :: ${response?.status} :: ${response?.statusText}`,
|
|
261
283
|
message: bodyResponse?.message || `API Error occured.`,
|
|
@@ -266,9 +288,11 @@ export class BaseSDK {
|
|
|
266
288
|
};
|
|
267
289
|
}
|
|
268
290
|
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
291
|
+
// Debug logging for successful HTTP requests
|
|
292
|
+
if (this.debugMode) {
|
|
293
|
+
console.log(`API :: https :: ${method.toUpperCase()} :: ${endpoint} :: ${response?.status}`);
|
|
294
|
+
}
|
|
295
|
+
|
|
272
296
|
return bodyResponse;
|
|
273
297
|
}
|
|
274
298
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unboundcx/sdk",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.2.0",
|
|
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",
|
package/services/login.js
CHANGED
|
@@ -62,21 +62,49 @@ export class LoginService {
|
|
|
62
62
|
return validation;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
async changePassword(
|
|
65
|
+
async changePassword(newPassword) {
|
|
66
66
|
this.sdk.validateParams(
|
|
67
|
-
{
|
|
67
|
+
{ newPassword },
|
|
68
68
|
{
|
|
69
|
-
currentPassword: { type: 'string', required: true },
|
|
70
69
|
newPassword: { type: 'string', required: true },
|
|
71
70
|
},
|
|
72
71
|
);
|
|
73
72
|
|
|
74
73
|
const options = {
|
|
75
|
-
body: {
|
|
74
|
+
body: { password: newPassword },
|
|
76
75
|
};
|
|
77
76
|
|
|
78
77
|
const result = await this.sdk._fetch(
|
|
79
78
|
'/login/changePassword',
|
|
79
|
+
'PUT',
|
|
80
|
+
options,
|
|
81
|
+
);
|
|
82
|
+
return result;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async getPasswordRequirements() {
|
|
86
|
+
const result = await this.sdk._fetch(
|
|
87
|
+
'/login/passwordRequirements',
|
|
88
|
+
'GET',
|
|
89
|
+
{},
|
|
90
|
+
);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async validatePasswordStrength(password) {
|
|
95
|
+
this.sdk.validateParams(
|
|
96
|
+
{ password },
|
|
97
|
+
{
|
|
98
|
+
password: { type: 'string', required: true },
|
|
99
|
+
},
|
|
100
|
+
);
|
|
101
|
+
|
|
102
|
+
const options = {
|
|
103
|
+
body: { password },
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
const result = await this.sdk._fetch(
|
|
107
|
+
'/login/validatePasswordStrength',
|
|
80
108
|
'POST',
|
|
81
109
|
options,
|
|
82
110
|
);
|