@auth-gate/core 0.4.0 → 0.5.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/README.md CHANGED
@@ -15,7 +15,6 @@ import { createAuthGateClient } from "@auth-gate/core";
15
15
 
16
16
  const client = createAuthGateClient({
17
17
  apiKey: process.env.AUTHGATE_API_KEY!,
18
- projectId: process.env.AUTHGATE_PROJECT_ID!,
19
18
  baseUrl: "https://authgate.dev", // or your self-hosted instance
20
19
  });
21
20
  ```
@@ -27,8 +26,8 @@ const client = createAuthGateClient({
27
26
  Supports Google, GitHub, Discord, Azure (Microsoft), and Apple.
28
27
 
29
28
  ```ts
30
- // Generate the authorization URL
31
- const url = client.getOAuthUrl("google", "https://yourapp.com/auth/callback");
29
+ // Generate the authorization URL (async — resolves project ID from API key)
30
+ const url = await client.getOAuthUrl("google", "https://yourapp.com/auth/callback");
32
31
 
33
32
  // After callback, verify the JWT token from AuthGate
34
33
  const result = await client.verifyToken(token);
@@ -144,8 +143,7 @@ client.getNonceCookieOptions();
144
143
 
145
144
  | Option | Type | Required | Description |
146
145
  |--------|------|----------|-------------|
147
- | `apiKey` | `string` | Yes | Your AuthGate API key |
148
- | `projectId` | `string` | Yes | Your AuthGate project ID |
146
+ | `apiKey` | `string` | Yes | Your AuthGate API key (also used to resolve project ID) |
149
147
  | `baseUrl` | `string` | Yes | AuthGate instance URL |
150
148
  | `cookieName` | `string` | No | Session cookie name (default: `__authgate`) |
151
149
  | `sessionMaxAge` | `number` | No | Session TTL in seconds (default: `604800` / 7 days) |
package/dist/index.cjs CHANGED
@@ -453,17 +453,28 @@ var AuthGateClient = class {
453
453
  * @returns The full authorization URL to redirect the user to.
454
454
  * @throws {@link AuthGateError} if the provider is not in {@link SUPPORTED_PROVIDERS}.
455
455
  */
456
- getOAuthUrl(provider, callbackUrl, options) {
456
+ async getOAuthUrl(provider, callbackUrl, options) {
457
457
  if (!SUPPORTED_PROVIDERS.includes(provider)) {
458
458
  throw new AuthGateError(`Unsupported provider: ${provider}`);
459
459
  }
460
- const url = new URL(`/api/proxy/${provider}`, this.config.baseUrl);
461
- url.searchParams.set("project_id", this.config.projectId);
462
- url.searchParams.set("callback_url", callbackUrl);
463
- if (options == null ? void 0 : options.linkTo) {
464
- url.searchParams.set("link_to", options.linkTo);
460
+ const response = await fetch(`${this.config.baseUrl}/api/proxy/${provider}`, {
461
+ method: "POST",
462
+ headers: {
463
+ Authorization: `Bearer ${this.config.apiKey}`,
464
+ "Content-Type": "application/json"
465
+ },
466
+ body: JSON.stringify({
467
+ callback_url: callbackUrl,
468
+ state: options == null ? void 0 : options.state,
469
+ link_to: options == null ? void 0 : options.linkTo
470
+ })
471
+ });
472
+ if (!response.ok) {
473
+ const error = await response.json().catch(() => ({}));
474
+ throw new AuthGateError(error.error || `OAuth initiation failed: ${response.status}`);
465
475
  }
466
- return url.toString();
476
+ const data = await response.json();
477
+ return data.redirect_url;
467
478
  }
468
479
  // ---------------------------------------------------------------------------
469
480
  // Email auth
@@ -477,12 +488,14 @@ var AuthGateClient = class {
477
488
  async emailSignup(data) {
478
489
  return fetch(`${this.config.baseUrl}/api/proxy/email/signup`, {
479
490
  method: "POST",
480
- headers: { "Content-Type": "application/json" },
491
+ headers: {
492
+ Authorization: `Bearer ${this.config.apiKey}`,
493
+ "Content-Type": "application/json"
494
+ },
481
495
  body: JSON.stringify({
482
496
  email: data.email,
483
497
  password: data.password,
484
498
  name: data.name,
485
- project_id: this.config.projectId,
486
499
  callback_url: data.callbackUrl
487
500
  })
488
501
  });
@@ -499,11 +512,13 @@ var AuthGateClient = class {
499
512
  async emailSignin(data) {
500
513
  return fetch(`${this.config.baseUrl}/api/proxy/email/signin`, {
501
514
  method: "POST",
502
- headers: { "Content-Type": "application/json" },
515
+ headers: {
516
+ Authorization: `Bearer ${this.config.apiKey}`,
517
+ "Content-Type": "application/json"
518
+ },
503
519
  body: JSON.stringify({
504
520
  email: data.email,
505
521
  password: data.password,
506
- project_id: this.config.projectId,
507
522
  callback_url: data.callbackUrl
508
523
  })
509
524
  });
@@ -517,10 +532,12 @@ var AuthGateClient = class {
517
532
  async emailForgotPassword(data) {
518
533
  return fetch(`${this.config.baseUrl}/api/proxy/email/reset-password`, {
519
534
  method: "POST",
520
- headers: { "Content-Type": "application/json" },
535
+ headers: {
536
+ Authorization: `Bearer ${this.config.apiKey}`,
537
+ "Content-Type": "application/json"
538
+ },
521
539
  body: JSON.stringify({
522
540
  email: data.email,
523
- project_id: this.config.projectId,
524
541
  callback_url: data.callbackUrl
525
542
  })
526
543
  });
@@ -536,11 +553,13 @@ var AuthGateClient = class {
536
553
  `${this.config.baseUrl}/api/proxy/email/reset-password/confirm`,
537
554
  {
538
555
  method: "POST",
539
- headers: { "Content-Type": "application/json" },
556
+ headers: {
557
+ Authorization: `Bearer ${this.config.apiKey}`,
558
+ "Content-Type": "application/json"
559
+ },
540
560
  body: JSON.stringify({
541
561
  token: data.token,
542
- password: data.password,
543
- project_id: this.config.projectId
562
+ password: data.password
544
563
  })
545
564
  }
546
565
  );
@@ -559,10 +578,12 @@ var AuthGateClient = class {
559
578
  `${this.config.baseUrl}/api/proxy/email/magic-link/send`,
560
579
  {
561
580
  method: "POST",
562
- headers: { "Content-Type": "application/json" },
581
+ headers: {
582
+ Authorization: `Bearer ${this.config.apiKey}`,
583
+ "Content-Type": "application/json"
584
+ },
563
585
  body: JSON.stringify({
564
586
  email: data.email,
565
- project_id: this.config.projectId,
566
587
  callback_url: data.callbackUrl
567
588
  })
568
589
  }
@@ -580,11 +601,13 @@ var AuthGateClient = class {
580
601
  async emailVerifyCode(data) {
581
602
  return fetch(`${this.config.baseUrl}/api/proxy/email/verify`, {
582
603
  method: "POST",
583
- headers: { "Content-Type": "application/json" },
604
+ headers: {
605
+ Authorization: `Bearer ${this.config.apiKey}`,
606
+ "Content-Type": "application/json"
607
+ },
584
608
  body: JSON.stringify({
585
609
  email: data.email,
586
- code: data.code,
587
- project_id: this.config.projectId
610
+ code: data.code
588
611
  })
589
612
  });
590
613
  }
@@ -600,10 +623,12 @@ var AuthGateClient = class {
600
623
  async smsSendCode(data) {
601
624
  return fetch(`${this.config.baseUrl}/api/proxy/sms/send-code`, {
602
625
  method: "POST",
603
- headers: { "Content-Type": "application/json" },
626
+ headers: {
627
+ Authorization: `Bearer ${this.config.apiKey}`,
628
+ "Content-Type": "application/json"
629
+ },
604
630
  body: JSON.stringify({
605
631
  phone: data.phone,
606
- project_id: this.config.projectId,
607
632
  callback_url: data.callbackUrl
608
633
  })
609
634
  });
@@ -617,11 +642,13 @@ var AuthGateClient = class {
617
642
  async smsVerifyCode(data) {
618
643
  return fetch(`${this.config.baseUrl}/api/proxy/sms/verify-code`, {
619
644
  method: "POST",
620
- headers: { "Content-Type": "application/json" },
645
+ headers: {
646
+ Authorization: `Bearer ${this.config.apiKey}`,
647
+ "Content-Type": "application/json"
648
+ },
621
649
  body: JSON.stringify({
622
650
  phone: data.phone,
623
651
  code: data.code,
624
- project_id: this.config.projectId,
625
652
  callback_url: data.callbackUrl
626
653
  })
627
654
  });
@@ -644,10 +671,12 @@ var AuthGateClient = class {
644
671
  `${this.config.baseUrl}/api/proxy/token/refresh`,
645
672
  {
646
673
  method: "POST",
647
- headers: { "Content-Type": "application/json" },
674
+ headers: {
675
+ Authorization: `Bearer ${this.config.apiKey}`,
676
+ "Content-Type": "application/json"
677
+ },
648
678
  body: JSON.stringify({
649
- refresh_token: refreshToken,
650
- project_id: this.config.projectId
679
+ refresh_token: refreshToken
651
680
  })
652
681
  }
653
682
  );
@@ -672,10 +701,12 @@ var AuthGateClient = class {
672
701
  `${this.config.baseUrl}/api/proxy/sessions/revoke`,
673
702
  {
674
703
  method: "POST",
675
- headers: { "Content-Type": "application/json" },
704
+ headers: {
705
+ Authorization: `Bearer ${this.config.apiKey}`,
706
+ "Content-Type": "application/json"
707
+ },
676
708
  body: JSON.stringify({
677
- refresh_token: refreshToken,
678
- project_id: this.config.projectId
709
+ refresh_token: refreshToken
679
710
  })
680
711
  }
681
712
  );
@@ -698,10 +729,11 @@ var AuthGateClient = class {
698
729
  async mfaVerify(data) {
699
730
  return fetch(`${this.config.baseUrl}/api/proxy/mfa/verify`, {
700
731
  method: "POST",
701
- headers: { "Content-Type": "application/json" },
702
- body: JSON.stringify(__spreadProps(__spreadValues({}, data), {
703
- project_id: this.config.projectId
704
- }))
732
+ headers: {
733
+ Authorization: `Bearer ${this.config.apiKey}`,
734
+ "Content-Type": "application/json"
735
+ },
736
+ body: JSON.stringify(data)
705
737
  });
706
738
  }
707
739
  /**
@@ -832,11 +864,11 @@ var AuthGateClient = class {
832
864
  async mfaSmsSendCode(challenge) {
833
865
  return fetch(`${this.config.baseUrl}/api/proxy/mfa/sms/send-code`, {
834
866
  method: "POST",
835
- headers: { "Content-Type": "application/json" },
836
- body: JSON.stringify({
837
- challenge,
838
- project_id: this.config.projectId
839
- })
867
+ headers: {
868
+ Authorization: `Bearer ${this.config.apiKey}`,
869
+ "Content-Type": "application/json"
870
+ },
871
+ body: JSON.stringify({ challenge })
840
872
  });
841
873
  }
842
874
  // ---------------------------------------------------------------------------
@@ -858,10 +890,6 @@ var AuthGateClient = class {
858
890
  get callbackPath() {
859
891
  return this.config.callbackPath;
860
892
  }
861
- /** The AuthGate project ID. */
862
- get projectId() {
863
- return this.config.projectId;
864
- }
865
893
  /** The AuthGate service base URL. */
866
894
  get baseUrl() {
867
895
  return this.config.baseUrl;
package/dist/index.d.cts CHANGED
@@ -47,16 +47,13 @@ interface TokenVerifyResult {
47
47
  *
48
48
  * const client = createAuthGateClient({
49
49
  * apiKey: process.env.AUTHGATE_API_KEY!,
50
- * projectId: process.env.AUTHGATE_PROJECT_ID!,
51
50
  * baseUrl: "https://authgate.dev",
52
51
  * });
53
52
  * ```
54
53
  */
55
54
  interface AuthGateConfig {
56
- /** Server-side API key for your AuthGate project. Found in the dashboard under API Keys. */
55
+ /** Server-side API key for your AuthGate project. Found in the dashboard under API Key. */
57
56
  apiKey: string;
58
- /** The project ID from your AuthGate dashboard. */
59
- projectId: string;
60
57
  /** Base URL of the AuthGate service (e.g. `"https://authgate.dev"`). */
61
58
  baseUrl: string;
62
59
  /**
@@ -172,7 +169,6 @@ interface BackupCodesResponse {
172
169
  * ```ts
173
170
  * const client = new AuthGateClient({
174
171
  * apiKey: process.env.AUTHGATE_API_KEY!,
175
- * projectId: process.env.AUTHGATE_PROJECT_ID!,
176
172
  * baseUrl: "https://authgate.dev",
177
173
  * });
178
174
  * ```
@@ -262,8 +258,9 @@ declare class AuthGateClient {
262
258
  * @throws {@link AuthGateError} if the provider is not in {@link SUPPORTED_PROVIDERS}.
263
259
  */
264
260
  getOAuthUrl(provider: OAuthProvider, callbackUrl: string, options?: {
261
+ state?: string;
265
262
  linkTo?: string;
266
- }): string;
263
+ }): Promise<string>;
267
264
  /**
268
265
  * Register a new user with email and password.
269
266
  *
@@ -459,8 +456,6 @@ declare class AuthGateClient {
459
456
  get refreshTokenCookieName(): string;
460
457
  /** The callback path where OAuth redirects are handled (default: `"/api/auth/callback"`). */
461
458
  get callbackPath(): string;
462
- /** The AuthGate project ID. */
463
- get projectId(): string;
464
459
  /** The AuthGate service base URL. */
465
460
  get baseUrl(): string;
466
461
  /** Session lifetime in seconds. */
package/dist/index.d.ts CHANGED
@@ -47,16 +47,13 @@ interface TokenVerifyResult {
47
47
  *
48
48
  * const client = createAuthGateClient({
49
49
  * apiKey: process.env.AUTHGATE_API_KEY!,
50
- * projectId: process.env.AUTHGATE_PROJECT_ID!,
51
50
  * baseUrl: "https://authgate.dev",
52
51
  * });
53
52
  * ```
54
53
  */
55
54
  interface AuthGateConfig {
56
- /** Server-side API key for your AuthGate project. Found in the dashboard under API Keys. */
55
+ /** Server-side API key for your AuthGate project. Found in the dashboard under API Key. */
57
56
  apiKey: string;
58
- /** The project ID from your AuthGate dashboard. */
59
- projectId: string;
60
57
  /** Base URL of the AuthGate service (e.g. `"https://authgate.dev"`). */
61
58
  baseUrl: string;
62
59
  /**
@@ -172,7 +169,6 @@ interface BackupCodesResponse {
172
169
  * ```ts
173
170
  * const client = new AuthGateClient({
174
171
  * apiKey: process.env.AUTHGATE_API_KEY!,
175
- * projectId: process.env.AUTHGATE_PROJECT_ID!,
176
172
  * baseUrl: "https://authgate.dev",
177
173
  * });
178
174
  * ```
@@ -262,8 +258,9 @@ declare class AuthGateClient {
262
258
  * @throws {@link AuthGateError} if the provider is not in {@link SUPPORTED_PROVIDERS}.
263
259
  */
264
260
  getOAuthUrl(provider: OAuthProvider, callbackUrl: string, options?: {
261
+ state?: string;
265
262
  linkTo?: string;
266
- }): string;
263
+ }): Promise<string>;
267
264
  /**
268
265
  * Register a new user with email and password.
269
266
  *
@@ -459,8 +456,6 @@ declare class AuthGateClient {
459
456
  get refreshTokenCookieName(): string;
460
457
  /** The callback path where OAuth redirects are handled (default: `"/api/auth/callback"`). */
461
458
  get callbackPath(): string;
462
- /** The AuthGate project ID. */
463
- get projectId(): string;
464
459
  /** The AuthGate service base URL. */
465
460
  get baseUrl(): string;
466
461
  /** Session lifetime in seconds. */
package/dist/index.mjs CHANGED
@@ -419,17 +419,28 @@ var AuthGateClient = class {
419
419
  * @returns The full authorization URL to redirect the user to.
420
420
  * @throws {@link AuthGateError} if the provider is not in {@link SUPPORTED_PROVIDERS}.
421
421
  */
422
- getOAuthUrl(provider, callbackUrl, options) {
422
+ async getOAuthUrl(provider, callbackUrl, options) {
423
423
  if (!SUPPORTED_PROVIDERS.includes(provider)) {
424
424
  throw new AuthGateError(`Unsupported provider: ${provider}`);
425
425
  }
426
- const url = new URL(`/api/proxy/${provider}`, this.config.baseUrl);
427
- url.searchParams.set("project_id", this.config.projectId);
428
- url.searchParams.set("callback_url", callbackUrl);
429
- if (options == null ? void 0 : options.linkTo) {
430
- url.searchParams.set("link_to", options.linkTo);
426
+ const response = await fetch(`${this.config.baseUrl}/api/proxy/${provider}`, {
427
+ method: "POST",
428
+ headers: {
429
+ Authorization: `Bearer ${this.config.apiKey}`,
430
+ "Content-Type": "application/json"
431
+ },
432
+ body: JSON.stringify({
433
+ callback_url: callbackUrl,
434
+ state: options == null ? void 0 : options.state,
435
+ link_to: options == null ? void 0 : options.linkTo
436
+ })
437
+ });
438
+ if (!response.ok) {
439
+ const error = await response.json().catch(() => ({}));
440
+ throw new AuthGateError(error.error || `OAuth initiation failed: ${response.status}`);
431
441
  }
432
- return url.toString();
442
+ const data = await response.json();
443
+ return data.redirect_url;
433
444
  }
434
445
  // ---------------------------------------------------------------------------
435
446
  // Email auth
@@ -443,12 +454,14 @@ var AuthGateClient = class {
443
454
  async emailSignup(data) {
444
455
  return fetch(`${this.config.baseUrl}/api/proxy/email/signup`, {
445
456
  method: "POST",
446
- headers: { "Content-Type": "application/json" },
457
+ headers: {
458
+ Authorization: `Bearer ${this.config.apiKey}`,
459
+ "Content-Type": "application/json"
460
+ },
447
461
  body: JSON.stringify({
448
462
  email: data.email,
449
463
  password: data.password,
450
464
  name: data.name,
451
- project_id: this.config.projectId,
452
465
  callback_url: data.callbackUrl
453
466
  })
454
467
  });
@@ -465,11 +478,13 @@ var AuthGateClient = class {
465
478
  async emailSignin(data) {
466
479
  return fetch(`${this.config.baseUrl}/api/proxy/email/signin`, {
467
480
  method: "POST",
468
- headers: { "Content-Type": "application/json" },
481
+ headers: {
482
+ Authorization: `Bearer ${this.config.apiKey}`,
483
+ "Content-Type": "application/json"
484
+ },
469
485
  body: JSON.stringify({
470
486
  email: data.email,
471
487
  password: data.password,
472
- project_id: this.config.projectId,
473
488
  callback_url: data.callbackUrl
474
489
  })
475
490
  });
@@ -483,10 +498,12 @@ var AuthGateClient = class {
483
498
  async emailForgotPassword(data) {
484
499
  return fetch(`${this.config.baseUrl}/api/proxy/email/reset-password`, {
485
500
  method: "POST",
486
- headers: { "Content-Type": "application/json" },
501
+ headers: {
502
+ Authorization: `Bearer ${this.config.apiKey}`,
503
+ "Content-Type": "application/json"
504
+ },
487
505
  body: JSON.stringify({
488
506
  email: data.email,
489
- project_id: this.config.projectId,
490
507
  callback_url: data.callbackUrl
491
508
  })
492
509
  });
@@ -502,11 +519,13 @@ var AuthGateClient = class {
502
519
  `${this.config.baseUrl}/api/proxy/email/reset-password/confirm`,
503
520
  {
504
521
  method: "POST",
505
- headers: { "Content-Type": "application/json" },
522
+ headers: {
523
+ Authorization: `Bearer ${this.config.apiKey}`,
524
+ "Content-Type": "application/json"
525
+ },
506
526
  body: JSON.stringify({
507
527
  token: data.token,
508
- password: data.password,
509
- project_id: this.config.projectId
528
+ password: data.password
510
529
  })
511
530
  }
512
531
  );
@@ -525,10 +544,12 @@ var AuthGateClient = class {
525
544
  `${this.config.baseUrl}/api/proxy/email/magic-link/send`,
526
545
  {
527
546
  method: "POST",
528
- headers: { "Content-Type": "application/json" },
547
+ headers: {
548
+ Authorization: `Bearer ${this.config.apiKey}`,
549
+ "Content-Type": "application/json"
550
+ },
529
551
  body: JSON.stringify({
530
552
  email: data.email,
531
- project_id: this.config.projectId,
532
553
  callback_url: data.callbackUrl
533
554
  })
534
555
  }
@@ -546,11 +567,13 @@ var AuthGateClient = class {
546
567
  async emailVerifyCode(data) {
547
568
  return fetch(`${this.config.baseUrl}/api/proxy/email/verify`, {
548
569
  method: "POST",
549
- headers: { "Content-Type": "application/json" },
570
+ headers: {
571
+ Authorization: `Bearer ${this.config.apiKey}`,
572
+ "Content-Type": "application/json"
573
+ },
550
574
  body: JSON.stringify({
551
575
  email: data.email,
552
- code: data.code,
553
- project_id: this.config.projectId
576
+ code: data.code
554
577
  })
555
578
  });
556
579
  }
@@ -566,10 +589,12 @@ var AuthGateClient = class {
566
589
  async smsSendCode(data) {
567
590
  return fetch(`${this.config.baseUrl}/api/proxy/sms/send-code`, {
568
591
  method: "POST",
569
- headers: { "Content-Type": "application/json" },
592
+ headers: {
593
+ Authorization: `Bearer ${this.config.apiKey}`,
594
+ "Content-Type": "application/json"
595
+ },
570
596
  body: JSON.stringify({
571
597
  phone: data.phone,
572
- project_id: this.config.projectId,
573
598
  callback_url: data.callbackUrl
574
599
  })
575
600
  });
@@ -583,11 +608,13 @@ var AuthGateClient = class {
583
608
  async smsVerifyCode(data) {
584
609
  return fetch(`${this.config.baseUrl}/api/proxy/sms/verify-code`, {
585
610
  method: "POST",
586
- headers: { "Content-Type": "application/json" },
611
+ headers: {
612
+ Authorization: `Bearer ${this.config.apiKey}`,
613
+ "Content-Type": "application/json"
614
+ },
587
615
  body: JSON.stringify({
588
616
  phone: data.phone,
589
617
  code: data.code,
590
- project_id: this.config.projectId,
591
618
  callback_url: data.callbackUrl
592
619
  })
593
620
  });
@@ -610,10 +637,12 @@ var AuthGateClient = class {
610
637
  `${this.config.baseUrl}/api/proxy/token/refresh`,
611
638
  {
612
639
  method: "POST",
613
- headers: { "Content-Type": "application/json" },
640
+ headers: {
641
+ Authorization: `Bearer ${this.config.apiKey}`,
642
+ "Content-Type": "application/json"
643
+ },
614
644
  body: JSON.stringify({
615
- refresh_token: refreshToken,
616
- project_id: this.config.projectId
645
+ refresh_token: refreshToken
617
646
  })
618
647
  }
619
648
  );
@@ -638,10 +667,12 @@ var AuthGateClient = class {
638
667
  `${this.config.baseUrl}/api/proxy/sessions/revoke`,
639
668
  {
640
669
  method: "POST",
641
- headers: { "Content-Type": "application/json" },
670
+ headers: {
671
+ Authorization: `Bearer ${this.config.apiKey}`,
672
+ "Content-Type": "application/json"
673
+ },
642
674
  body: JSON.stringify({
643
- refresh_token: refreshToken,
644
- project_id: this.config.projectId
675
+ refresh_token: refreshToken
645
676
  })
646
677
  }
647
678
  );
@@ -664,10 +695,11 @@ var AuthGateClient = class {
664
695
  async mfaVerify(data) {
665
696
  return fetch(`${this.config.baseUrl}/api/proxy/mfa/verify`, {
666
697
  method: "POST",
667
- headers: { "Content-Type": "application/json" },
668
- body: JSON.stringify(__spreadProps(__spreadValues({}, data), {
669
- project_id: this.config.projectId
670
- }))
698
+ headers: {
699
+ Authorization: `Bearer ${this.config.apiKey}`,
700
+ "Content-Type": "application/json"
701
+ },
702
+ body: JSON.stringify(data)
671
703
  });
672
704
  }
673
705
  /**
@@ -798,11 +830,11 @@ var AuthGateClient = class {
798
830
  async mfaSmsSendCode(challenge) {
799
831
  return fetch(`${this.config.baseUrl}/api/proxy/mfa/sms/send-code`, {
800
832
  method: "POST",
801
- headers: { "Content-Type": "application/json" },
802
- body: JSON.stringify({
803
- challenge,
804
- project_id: this.config.projectId
805
- })
833
+ headers: {
834
+ Authorization: `Bearer ${this.config.apiKey}`,
835
+ "Content-Type": "application/json"
836
+ },
837
+ body: JSON.stringify({ challenge })
806
838
  });
807
839
  }
808
840
  // ---------------------------------------------------------------------------
@@ -824,10 +856,6 @@ var AuthGateClient = class {
824
856
  get callbackPath() {
825
857
  return this.config.callbackPath;
826
858
  }
827
- /** The AuthGate project ID. */
828
- get projectId() {
829
- return this.config.projectId;
830
- }
831
859
  /** The AuthGate service base URL. */
832
860
  get baseUrl() {
833
861
  return this.config.baseUrl;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth-gate/core",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {