spaps-sdk 1.4.0 → 1.5.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/README.md CHANGED
@@ -116,7 +116,7 @@ const { SPAPSClient } = require('spaps-sdk');
116
116
 
117
117
  // Auto-detects local mode - no API key needed for localhost!
118
118
  const spaps = new SPAPSClient({
119
- apiUrl: 'http://localhost:3300' // Optional, auto-detected
119
+ apiUrl: 'http://localhost:3301' // Optional, auto-detected
120
120
  });
121
121
 
122
122
  // Login
@@ -133,7 +133,7 @@ if (spaps.isAuthenticated()) {
133
133
  ## Local Mode Explained
134
134
 
135
135
  - If `apiUrl` is omitted or points to `localhost`/`127.0.0.1`, the SDK runs in local mode.
136
- - Local mode integrates seamlessly with the `spaps` CLI (`npx spaps local`), defaulting to `http://localhost:3300`.
136
+ - Local mode integrates seamlessly with the `spaps` CLI (`npx spaps local`), defaulting to `http://localhost:3301`.
137
137
  - No API key is required in local mode; tokens and data are managed locally for development.
138
138
 
139
139
  You can check the mode at runtime:
@@ -280,7 +280,7 @@ const spaps = new SPAPSClient({
280
280
  ### Local Development Mode (Auto-detected)
281
281
  ```javascript
282
282
  const spaps = new SPAPSClient();
283
- // Automatically uses http://localhost:3300 with no API key
283
+ // Automatically uses http://localhost:3301 with no API key
284
284
  ```
285
285
 
286
286
  ### Environment Variables
package/dist/index.d.mts CHANGED
@@ -285,6 +285,17 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
285
285
  token: string;
286
286
  new_password: string;
287
287
  }) => Promise<void>;
288
+ /**
289
+ * Set or change password for authenticated users.
290
+ * For magic link / wallet users setting their first password, only new_password is required.
291
+ * For users changing an existing password, current_password is also required.
292
+ */
293
+ setPassword: (payload: {
294
+ current_password?: string;
295
+ new_password: string;
296
+ }) => Promise<{
297
+ message: string;
298
+ }>;
288
299
  register: (payload: {
289
300
  email: string;
290
301
  password: string;
package/dist/index.d.ts CHANGED
@@ -285,6 +285,17 @@ declare class SPAPSClient<SecureMessageMetadata extends Record<string, any> = Re
285
285
  token: string;
286
286
  new_password: string;
287
287
  }) => Promise<void>;
288
+ /**
289
+ * Set or change password for authenticated users.
290
+ * For magic link / wallet users setting their first password, only new_password is required.
291
+ * For users changing an existing password, current_password is also required.
292
+ */
293
+ setPassword: (payload: {
294
+ current_password?: string;
295
+ new_password: string;
296
+ }) => Promise<{
297
+ message: string;
298
+ }>;
288
299
  register: (payload: {
289
300
  email: string;
290
301
  password: string;
package/dist/index.js CHANGED
@@ -305,7 +305,7 @@ var SPAPSClient = class {
305
305
  if (!apiUrl || apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1")) {
306
306
  this._isLocalMode = true;
307
307
  this.client = import_axios.default.create({
308
- baseURL: apiUrl || "http://localhost:3300",
308
+ baseURL: apiUrl || "http://localhost:3301",
309
309
  timeout: config.timeout || 1e4,
310
310
  headers: {
311
311
  "Content-Type": "application/json"
@@ -466,6 +466,17 @@ var SPAPSClient = class {
466
466
  confirmPasswordReset: async (payload) => {
467
467
  await this.client.post("/api/auth/reset-password-confirm", payload);
468
468
  },
469
+ /**
470
+ * Set or change password for authenticated users.
471
+ * For magic link / wallet users setting their first password, only new_password is required.
472
+ * For users changing an existing password, current_password is also required.
473
+ */
474
+ setPassword: async (payload) => {
475
+ const res = await this.client.post("/api/auth/set-password", payload);
476
+ const body = res.data;
477
+ if (body?.success === false) throw new Error(body?.error?.message || "Set password failed");
478
+ return { message: body?.message || "Password updated successfully" };
479
+ },
469
480
  register: async (payload) => {
470
481
  const res = await this.client.post("/api/auth/register", payload);
471
482
  const body = res.data;
package/dist/index.mjs CHANGED
@@ -278,7 +278,7 @@ var SPAPSClient = class {
278
278
  if (!apiUrl || apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1")) {
279
279
  this._isLocalMode = true;
280
280
  this.client = axios.create({
281
- baseURL: apiUrl || "http://localhost:3300",
281
+ baseURL: apiUrl || "http://localhost:3301",
282
282
  timeout: config.timeout || 1e4,
283
283
  headers: {
284
284
  "Content-Type": "application/json"
@@ -439,6 +439,17 @@ var SPAPSClient = class {
439
439
  confirmPasswordReset: async (payload) => {
440
440
  await this.client.post("/api/auth/reset-password-confirm", payload);
441
441
  },
442
+ /**
443
+ * Set or change password for authenticated users.
444
+ * For magic link / wallet users setting their first password, only new_password is required.
445
+ * For users changing an existing password, current_password is also required.
446
+ */
447
+ setPassword: async (payload) => {
448
+ const res = await this.client.post("/api/auth/set-password", payload);
449
+ const body = res.data;
450
+ if (body?.success === false) throw new Error(body?.error?.message || "Set password failed");
451
+ return { message: body?.message || "Password updated successfully" };
452
+ },
442
453
  register: async (payload) => {
443
454
  const res = await this.client.post("/api/auth/register", payload);
444
455
  const body = res.data;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spaps-sdk",
3
- "version": "1.4.0",
3
+ "version": "1.5.1",
4
4
  "description": "Sweet Potato Authentication & Payment Service SDK - Zero-config client with built-in permission checking, role-based access control, and dayrate scheduling",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",