@55387.ai/uniauth-client 1.0.0 → 1.1.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/dist/index.cjs CHANGED
@@ -269,11 +269,19 @@ var UniAuthClient = class {
269
269
  /**
270
270
  * Send verification code to phone number
271
271
  * 发送验证码到手机号
272
+ *
273
+ * @param phone - Phone number
274
+ * @param type - Purpose of the verification code
275
+ * @param captchaToken - Captcha verification token from slider captcha
272
276
  */
273
- async sendCode(phone, type = "login") {
274
- const response = await this.request("/api/v1/auth/send-code", {
277
+ async sendCode(phone, type = "login", captchaToken) {
278
+ const response = await this.request("/api/v1/auth/phone/send-code", {
275
279
  method: "POST",
276
- body: JSON.stringify({ phone, type })
280
+ body: JSON.stringify({
281
+ phone,
282
+ type,
283
+ captcha_token: captchaToken
284
+ })
277
285
  });
278
286
  if (!response.success || !response.data) {
279
287
  throw this.createError(response.error?.code || "SEND_CODE_FAILED", response.error?.message || "Failed to send code");
@@ -283,11 +291,15 @@ var UniAuthClient = class {
283
291
  /**
284
292
  * Send verification code to email
285
293
  * 发送验证码到邮箱
294
+ *
295
+ * @param email - Email address
296
+ * @param type - Purpose of the verification code
297
+ * @param captchaToken - Captcha verification token from slider captcha
286
298
  */
287
- async sendEmailCode(email, type = "login") {
288
- const response = await this.request("/api/v1/auth/send-code", {
299
+ async sendEmailCode(email, type = "login", captchaToken) {
300
+ const response = await this.request("/api/v1/auth/email/send-code", {
289
301
  method: "POST",
290
- body: JSON.stringify({ email, type })
302
+ body: JSON.stringify({ email, type, captcha_token: captchaToken })
291
303
  });
292
304
  if (!response.success || !response.data) {
293
305
  throw this.createError(response.error?.code || "SEND_CODE_FAILED", response.error?.message || "Failed to send code");
package/dist/index.d.cts CHANGED
@@ -61,7 +61,7 @@ declare function getAndClearCodeVerifier(storageKey?: string): string | null;
61
61
  *
62
62
  * Usage:
63
63
  * ```typescript
64
- * import { UniAuthClient } from '@uniauth/client';
64
+ * import { UniAuthClient } from '@55387.ai/uniauth-client';
65
65
  *
66
66
  * const auth = new UniAuthClient({
67
67
  * baseUrl: 'https://auth.example.com',
@@ -237,13 +237,21 @@ declare class UniAuthClient {
237
237
  /**
238
238
  * Send verification code to phone number
239
239
  * 发送验证码到手机号
240
+ *
241
+ * @param phone - Phone number
242
+ * @param type - Purpose of the verification code
243
+ * @param captchaToken - Captcha verification token from slider captcha
240
244
  */
241
- sendCode(phone: string, type?: 'login' | 'register' | 'reset'): Promise<SendCodeResult>;
245
+ sendCode(phone: string, type?: 'login' | 'register' | 'reset', captchaToken?: string): Promise<SendCodeResult>;
242
246
  /**
243
247
  * Send verification code to email
244
248
  * 发送验证码到邮箱
249
+ *
250
+ * @param email - Email address
251
+ * @param type - Purpose of the verification code
252
+ * @param captchaToken - Captcha verification token from slider captcha
245
253
  */
246
- sendEmailCode(email: string, type?: 'login' | 'register' | 'reset' | 'email_verify'): Promise<SendCodeResult>;
254
+ sendEmailCode(email: string, type?: 'login' | 'register' | 'reset' | 'email_verify', captchaToken?: string): Promise<SendCodeResult>;
247
255
  /**
248
256
  * Login with phone verification code
249
257
  * 使用手机验证码登录
package/dist/index.d.ts CHANGED
@@ -61,7 +61,7 @@ declare function getAndClearCodeVerifier(storageKey?: string): string | null;
61
61
  *
62
62
  * Usage:
63
63
  * ```typescript
64
- * import { UniAuthClient } from '@uniauth/client';
64
+ * import { UniAuthClient } from '@55387.ai/uniauth-client';
65
65
  *
66
66
  * const auth = new UniAuthClient({
67
67
  * baseUrl: 'https://auth.example.com',
@@ -237,13 +237,21 @@ declare class UniAuthClient {
237
237
  /**
238
238
  * Send verification code to phone number
239
239
  * 发送验证码到手机号
240
+ *
241
+ * @param phone - Phone number
242
+ * @param type - Purpose of the verification code
243
+ * @param captchaToken - Captcha verification token from slider captcha
240
244
  */
241
- sendCode(phone: string, type?: 'login' | 'register' | 'reset'): Promise<SendCodeResult>;
245
+ sendCode(phone: string, type?: 'login' | 'register' | 'reset', captchaToken?: string): Promise<SendCodeResult>;
242
246
  /**
243
247
  * Send verification code to email
244
248
  * 发送验证码到邮箱
249
+ *
250
+ * @param email - Email address
251
+ * @param type - Purpose of the verification code
252
+ * @param captchaToken - Captcha verification token from slider captcha
245
253
  */
246
- sendEmailCode(email: string, type?: 'login' | 'register' | 'reset' | 'email_verify'): Promise<SendCodeResult>;
254
+ sendEmailCode(email: string, type?: 'login' | 'register' | 'reset' | 'email_verify', captchaToken?: string): Promise<SendCodeResult>;
247
255
  /**
248
256
  * Login with phone verification code
249
257
  * 使用手机验证码登录
package/dist/index.js CHANGED
@@ -235,11 +235,19 @@ var UniAuthClient = class {
235
235
  /**
236
236
  * Send verification code to phone number
237
237
  * 发送验证码到手机号
238
+ *
239
+ * @param phone - Phone number
240
+ * @param type - Purpose of the verification code
241
+ * @param captchaToken - Captcha verification token from slider captcha
238
242
  */
239
- async sendCode(phone, type = "login") {
240
- const response = await this.request("/api/v1/auth/send-code", {
243
+ async sendCode(phone, type = "login", captchaToken) {
244
+ const response = await this.request("/api/v1/auth/phone/send-code", {
241
245
  method: "POST",
242
- body: JSON.stringify({ phone, type })
246
+ body: JSON.stringify({
247
+ phone,
248
+ type,
249
+ captcha_token: captchaToken
250
+ })
243
251
  });
244
252
  if (!response.success || !response.data) {
245
253
  throw this.createError(response.error?.code || "SEND_CODE_FAILED", response.error?.message || "Failed to send code");
@@ -249,11 +257,15 @@ var UniAuthClient = class {
249
257
  /**
250
258
  * Send verification code to email
251
259
  * 发送验证码到邮箱
260
+ *
261
+ * @param email - Email address
262
+ * @param type - Purpose of the verification code
263
+ * @param captchaToken - Captcha verification token from slider captcha
252
264
  */
253
- async sendEmailCode(email, type = "login") {
254
- const response = await this.request("/api/v1/auth/send-code", {
265
+ async sendEmailCode(email, type = "login", captchaToken) {
266
+ const response = await this.request("/api/v1/auth/email/send-code", {
255
267
  method: "POST",
256
- body: JSON.stringify({ email, type })
268
+ body: JSON.stringify({ email, type, captcha_token: captchaToken })
257
269
  });
258
270
  if (!response.success || !response.data) {
259
271
  throw this.createError(response.error?.code || "SEND_CODE_FAILED", response.error?.message || "Failed to send code");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@55387.ai/uniauth-client",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "UniAuth Frontend SDK - Phone, Email, SSO login for browser",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -8,9 +8,9 @@
8
8
  "types": "./dist/index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js",
13
- "types": "./dist/index.d.ts"
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "publishConfig": {
package/src/index.ts CHANGED
@@ -4,7 +4,7 @@
4
4
  *
5
5
  * Usage:
6
6
  * ```typescript
7
- * import { UniAuthClient } from '@uniauth/client';
7
+ * import { UniAuthClient } from '@55387.ai/uniauth-client';
8
8
  *
9
9
  * const auth = new UniAuthClient({
10
10
  * baseUrl: 'https://auth.example.com',
@@ -344,14 +344,23 @@ export class UniAuthClient {
344
344
  /**
345
345
  * Send verification code to phone number
346
346
  * 发送验证码到手机号
347
+ *
348
+ * @param phone - Phone number
349
+ * @param type - Purpose of the verification code
350
+ * @param captchaToken - Captcha verification token from slider captcha
347
351
  */
348
352
  async sendCode(
349
353
  phone: string,
350
- type: 'login' | 'register' | 'reset' = 'login'
354
+ type: 'login' | 'register' | 'reset' = 'login',
355
+ captchaToken?: string
351
356
  ): Promise<SendCodeResult> {
352
- const response = await this.request<SendCodeResult>('/api/v1/auth/send-code', {
357
+ const response = await this.request<SendCodeResult>('/api/v1/auth/phone/send-code', {
353
358
  method: 'POST',
354
- body: JSON.stringify({ phone, type }),
359
+ body: JSON.stringify({
360
+ phone,
361
+ type,
362
+ captcha_token: captchaToken
363
+ }),
355
364
  });
356
365
 
357
366
  if (!response.success || !response.data) {
@@ -364,14 +373,19 @@ export class UniAuthClient {
364
373
  /**
365
374
  * Send verification code to email
366
375
  * 发送验证码到邮箱
376
+ *
377
+ * @param email - Email address
378
+ * @param type - Purpose of the verification code
379
+ * @param captchaToken - Captcha verification token from slider captcha
367
380
  */
368
381
  async sendEmailCode(
369
382
  email: string,
370
- type: 'login' | 'register' | 'reset' | 'email_verify' = 'login'
383
+ type: 'login' | 'register' | 'reset' | 'email_verify' = 'login',
384
+ captchaToken?: string
371
385
  ): Promise<SendCodeResult> {
372
- const response = await this.request<SendCodeResult>('/api/v1/auth/send-code', {
386
+ const response = await this.request<SendCodeResult>('/api/v1/auth/email/send-code', {
373
387
  method: 'POST',
374
- body: JSON.stringify({ email, type }),
388
+ body: JSON.stringify({ email, type, captcha_token: captchaToken }),
375
389
  });
376
390
 
377
391
  if (!response.success || !response.data) {