@auth-gate/core 0.9.2 → 0.10.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
@@ -1,6 +1,10 @@
1
+ <p align="center">
2
+ <img src="icon.png" alt="AuthGate" width="120" height="120" />
3
+ </p>
4
+
1
5
  # @auth-gate/core
2
6
 
3
- Core client library for [AuthGate](https://authgate.dev) — the OAuth proxy that handles provider configuration, token exchange, and user normalization so you don't have to.
7
+ Core client library for [AuthGate](https://www.authgate.dev) — the OAuth proxy that handles provider configuration, token exchange, and user normalization so you don't have to.
4
8
 
5
9
  ## Installation
6
10
 
@@ -15,7 +19,7 @@ import { createAuthGateClient } from "@auth-gate/core";
15
19
 
16
20
  const client = createAuthGateClient({
17
21
  apiKey: process.env.AUTHGATE_API_KEY!,
18
- baseUrl: "https://authgate.dev", // or your self-hosted instance
22
+ baseUrl: "https://www.authgate.dev", // or your self-hosted instance
19
23
  });
20
24
  ```
21
25
 
@@ -202,7 +206,14 @@ For framework-specific integrations with built-in route handlers, session helper
202
206
 
203
207
  - **Next.js** — [`@auth-gate/nextjs`](https://www.npmjs.com/package/@auth-gate/nextjs)
204
208
  - **React + Hono** — [`@auth-gate/react`](https://www.npmjs.com/package/@auth-gate/react)
205
- - **Testing (Playwright / Cypress)** — [`@auth-gate/testing`](https://www.npmjs.com/package/@auth-gate/testing)
209
+ - **React Native / Expo** — [`@auth-gate/react-native`](https://www.npmjs.com/package/@auth-gate/react-native)
210
+ - **Flutter** — [`auth_gate_flutter`](https://pub.dev/packages/auth_gate_flutter)
211
+
212
+ ## Add-on Packages
213
+
214
+ - **RBAC as Code** — [`@auth-gate/rbac`](https://www.npmjs.com/package/@auth-gate/rbac) — define roles and permissions in TypeScript
215
+ - **Billing as Code** — [`@auth-gate/billing`](https://www.npmjs.com/package/@auth-gate/billing) — define plans and prices in TypeScript
216
+ - **Testing** — [`@auth-gate/testing`](https://www.npmjs.com/package/@auth-gate/testing) — E2E helpers (Playwright/Cypress), billing test harness, RBAC test utilities
206
217
 
207
218
  ## License
208
219
 
package/dist/index.cjs CHANGED
@@ -328,14 +328,14 @@ var AuthGateClient = class {
328
328
  }
329
329
  if (!config.baseUrl || typeof config.baseUrl !== "string" || config.baseUrl.trim() === "") {
330
330
  throw new ConfigurationError(
331
- '[AuthGate] Missing or empty `baseUrl`. Set this to your AuthGate service URL (e.g. "https://authgate.dev").'
331
+ '[AuthGate] Missing or empty `baseUrl`. Set this to your AuthGate service URL (e.g. "https://www.authgate.dev").'
332
332
  );
333
333
  }
334
334
  try {
335
335
  new URL(config.baseUrl);
336
336
  } catch (e) {
337
337
  throw new ConfigurationError(
338
- `[AuthGate] Invalid \`baseUrl\`: "${config.baseUrl}". Must be a valid URL (e.g. "https://authgate.dev").`
338
+ `[AuthGate] Invalid \`baseUrl\`: "${config.baseUrl}". Must be a valid URL (e.g. "https://www.authgate.dev").`
339
339
  );
340
340
  }
341
341
  if (config.callbackPath !== void 0 && !config.callbackPath.startsWith("/")) {
@@ -494,21 +494,26 @@ var AuthGateClient = class {
494
494
  if (!SUPPORTED_PROVIDERS.includes(provider)) {
495
495
  throw new AuthGateError(`Unsupported provider: ${provider}`);
496
496
  }
497
- const response = await fetch(`${this.config.baseUrl}/api/proxy/${provider}`, {
498
- method: "POST",
499
- headers: {
500
- Authorization: `Bearer ${this.config.apiKey}`,
501
- "Content-Type": "application/json"
502
- },
503
- body: JSON.stringify({
504
- callback_url: callbackUrl,
505
- state: options == null ? void 0 : options.state,
506
- link_to: options == null ? void 0 : options.linkTo
507
- })
508
- });
497
+ const response = await fetch(
498
+ `${this.config.baseUrl}/api/proxy/${provider}`,
499
+ {
500
+ method: "POST",
501
+ headers: {
502
+ Authorization: `Bearer ${this.config.apiKey}`,
503
+ "Content-Type": "application/json"
504
+ },
505
+ body: JSON.stringify({
506
+ callback_url: callbackUrl,
507
+ state: options == null ? void 0 : options.state,
508
+ link_to: options == null ? void 0 : options.linkTo
509
+ })
510
+ }
511
+ );
509
512
  if (!response.ok) {
510
513
  const error = await response.json().catch(() => ({}));
511
- throw new AuthGateError(error.error || `OAuth initiation failed: ${response.status}`);
514
+ throw new AuthGateError(
515
+ error.error || `OAuth initiation failed: ${response.status}`
516
+ );
512
517
  }
513
518
  const data = await response.json();
514
519
  return data.redirect_url;
@@ -611,20 +616,17 @@ var AuthGateClient = class {
611
616
  * @returns The raw `Response` from the AuthGate proxy.
612
617
  */
613
618
  async magicLinkSend(data) {
614
- return fetch(
615
- `${this.config.baseUrl}/api/proxy/email/magic-link/send`,
616
- {
617
- method: "POST",
618
- headers: {
619
- Authorization: `Bearer ${this.config.apiKey}`,
620
- "Content-Type": "application/json"
621
- },
622
- body: JSON.stringify({
623
- email: data.email,
624
- callback_url: data.callbackUrl
625
- })
626
- }
627
- );
619
+ return fetch(`${this.config.baseUrl}/api/proxy/email/magic-link/send`, {
620
+ method: "POST",
621
+ headers: {
622
+ Authorization: `Bearer ${this.config.apiKey}`,
623
+ "Content-Type": "application/json"
624
+ },
625
+ body: JSON.stringify({
626
+ email: data.email,
627
+ callback_url: data.callbackUrl
628
+ })
629
+ });
628
630
  }
629
631
  // ---------------------------------------------------------------------------
630
632
  // Email verification
@@ -868,17 +870,14 @@ var AuthGateClient = class {
868
870
  * @returns The raw `Response` with an array of backup codes.
869
871
  */
870
872
  async mfaBackupCodesGenerate(token) {
871
- return fetch(
872
- `${this.config.baseUrl}/api/proxy/mfa/backup-codes/generate`,
873
- {
874
- method: "POST",
875
- headers: {
876
- Authorization: `Bearer ${token}`,
877
- "Content-Type": "application/json"
878
- },
879
- body: "{}"
880
- }
881
- );
873
+ return fetch(`${this.config.baseUrl}/api/proxy/mfa/backup-codes/generate`, {
874
+ method: "POST",
875
+ headers: {
876
+ Authorization: `Bearer ${token}`,
877
+ "Content-Type": "application/json"
878
+ },
879
+ body: "{}"
880
+ });
882
881
  }
883
882
  /**
884
883
  * Get the current MFA enrollment status for the authenticated user.
@@ -967,23 +966,20 @@ var AuthGateClient = class {
967
966
  * @returns The raw `Response` from the AuthGate proxy.
968
967
  */
969
968
  async updateOrg(orgIdOrSlug, data) {
970
- return fetch(
971
- `${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}`,
972
- {
973
- method: "PATCH",
974
- headers: {
975
- Authorization: `Bearer ${this.config.apiKey}`,
976
- "Content-Type": "application/json"
977
- },
978
- body: JSON.stringify({
979
- name: data.name,
980
- slug: data.slug,
981
- image_url: data.imageUrl,
982
- max_members: data.maxMembers,
983
- metadata: data.metadata
984
- })
985
- }
986
- );
969
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}`, {
970
+ method: "PATCH",
971
+ headers: {
972
+ Authorization: `Bearer ${this.config.apiKey}`,
973
+ "Content-Type": "application/json"
974
+ },
975
+ body: JSON.stringify({
976
+ name: data.name,
977
+ slug: data.slug,
978
+ image_url: data.imageUrl,
979
+ max_members: data.maxMembers,
980
+ metadata: data.metadata
981
+ })
982
+ });
987
983
  }
988
984
  /**
989
985
  * Delete an organization.
@@ -1122,19 +1118,16 @@ var AuthGateClient = class {
1122
1118
  * @returns The raw `Response` from the AuthGate proxy.
1123
1119
  */
1124
1120
  async acceptOrgInvitation(data) {
1125
- return fetch(
1126
- `${this.config.baseUrl}/api/proxy/orgs/invitations/accept`,
1127
- {
1128
- method: "POST",
1129
- headers: {
1130
- Authorization: `Bearer ${this.config.apiKey}`,
1131
- "Content-Type": "application/json"
1132
- },
1133
- body: JSON.stringify({
1134
- token: data.token
1135
- })
1136
- }
1137
- );
1121
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/invitations/accept`, {
1122
+ method: "POST",
1123
+ headers: {
1124
+ Authorization: `Bearer ${this.config.apiKey}`,
1125
+ "Content-Type": "application/json"
1126
+ },
1127
+ body: JSON.stringify({
1128
+ token: data.token
1129
+ })
1130
+ });
1138
1131
  }
1139
1132
  /**
1140
1133
  * Leave an organization as the current user.
@@ -1143,17 +1136,14 @@ var AuthGateClient = class {
1143
1136
  * @returns The raw `Response` from the AuthGate proxy.
1144
1137
  */
1145
1138
  async leaveOrg(orgIdOrSlug) {
1146
- return fetch(
1147
- `${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}/leave`,
1148
- {
1149
- method: "POST",
1150
- headers: {
1151
- Authorization: `Bearer ${this.config.apiKey}`,
1152
- "Content-Type": "application/json"
1153
- },
1154
- body: "{}"
1155
- }
1156
- );
1139
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}/leave`, {
1140
+ method: "POST",
1141
+ headers: {
1142
+ Authorization: `Bearer ${this.config.apiKey}`,
1143
+ "Content-Type": "application/json"
1144
+ },
1145
+ body: "{}"
1146
+ });
1157
1147
  }
1158
1148
  // ---------------------------------------------------------------------------
1159
1149
  // Cookie config accessors
package/dist/index.d.cts CHANGED
@@ -47,14 +47,14 @@ interface TokenVerifyResult {
47
47
  *
48
48
  * const client = createAuthGateClient({
49
49
  * apiKey: process.env.AUTHGATE_API_KEY!,
50
- * baseUrl: "https://authgate.dev",
50
+ * baseUrl: "https://www.authgate.dev",
51
51
  * });
52
52
  * ```
53
53
  */
54
54
  interface AuthGateConfig {
55
55
  /** Server-side API key for your AuthGate project. Found in the dashboard under API Key. */
56
56
  apiKey: string;
57
- /** Base URL of the AuthGate service (e.g. `"https://authgate.dev"`). */
57
+ /** Base URL of the AuthGate service (e.g. `"https://www.authgate.dev"`). */
58
58
  baseUrl: string;
59
59
  /**
60
60
  * Name of the session cookie.
@@ -169,7 +169,7 @@ interface BackupCodesResponse {
169
169
  * ```ts
170
170
  * const client = new AuthGateClient({
171
171
  * apiKey: process.env.AUTHGATE_API_KEY!,
172
- * baseUrl: "https://authgate.dev",
172
+ * baseUrl: "https://www.authgate.dev",
173
173
  * });
174
174
  * ```
175
175
  */
package/dist/index.d.ts CHANGED
@@ -47,14 +47,14 @@ interface TokenVerifyResult {
47
47
  *
48
48
  * const client = createAuthGateClient({
49
49
  * apiKey: process.env.AUTHGATE_API_KEY!,
50
- * baseUrl: "https://authgate.dev",
50
+ * baseUrl: "https://www.authgate.dev",
51
51
  * });
52
52
  * ```
53
53
  */
54
54
  interface AuthGateConfig {
55
55
  /** Server-side API key for your AuthGate project. Found in the dashboard under API Key. */
56
56
  apiKey: string;
57
- /** Base URL of the AuthGate service (e.g. `"https://authgate.dev"`). */
57
+ /** Base URL of the AuthGate service (e.g. `"https://www.authgate.dev"`). */
58
58
  baseUrl: string;
59
59
  /**
60
60
  * Name of the session cookie.
@@ -169,7 +169,7 @@ interface BackupCodesResponse {
169
169
  * ```ts
170
170
  * const client = new AuthGateClient({
171
171
  * apiKey: process.env.AUTHGATE_API_KEY!,
172
- * baseUrl: "https://authgate.dev",
172
+ * baseUrl: "https://www.authgate.dev",
173
173
  * });
174
174
  * ```
175
175
  */
package/dist/index.mjs CHANGED
@@ -285,14 +285,14 @@ var AuthGateClient = class {
285
285
  }
286
286
  if (!config.baseUrl || typeof config.baseUrl !== "string" || config.baseUrl.trim() === "") {
287
287
  throw new ConfigurationError(
288
- '[AuthGate] Missing or empty `baseUrl`. Set this to your AuthGate service URL (e.g. "https://authgate.dev").'
288
+ '[AuthGate] Missing or empty `baseUrl`. Set this to your AuthGate service URL (e.g. "https://www.authgate.dev").'
289
289
  );
290
290
  }
291
291
  try {
292
292
  new URL(config.baseUrl);
293
293
  } catch (e) {
294
294
  throw new ConfigurationError(
295
- `[AuthGate] Invalid \`baseUrl\`: "${config.baseUrl}". Must be a valid URL (e.g. "https://authgate.dev").`
295
+ `[AuthGate] Invalid \`baseUrl\`: "${config.baseUrl}". Must be a valid URL (e.g. "https://www.authgate.dev").`
296
296
  );
297
297
  }
298
298
  if (config.callbackPath !== void 0 && !config.callbackPath.startsWith("/")) {
@@ -451,21 +451,26 @@ var AuthGateClient = class {
451
451
  if (!SUPPORTED_PROVIDERS.includes(provider)) {
452
452
  throw new AuthGateError(`Unsupported provider: ${provider}`);
453
453
  }
454
- const response = await fetch(`${this.config.baseUrl}/api/proxy/${provider}`, {
455
- method: "POST",
456
- headers: {
457
- Authorization: `Bearer ${this.config.apiKey}`,
458
- "Content-Type": "application/json"
459
- },
460
- body: JSON.stringify({
461
- callback_url: callbackUrl,
462
- state: options == null ? void 0 : options.state,
463
- link_to: options == null ? void 0 : options.linkTo
464
- })
465
- });
454
+ const response = await fetch(
455
+ `${this.config.baseUrl}/api/proxy/${provider}`,
456
+ {
457
+ method: "POST",
458
+ headers: {
459
+ Authorization: `Bearer ${this.config.apiKey}`,
460
+ "Content-Type": "application/json"
461
+ },
462
+ body: JSON.stringify({
463
+ callback_url: callbackUrl,
464
+ state: options == null ? void 0 : options.state,
465
+ link_to: options == null ? void 0 : options.linkTo
466
+ })
467
+ }
468
+ );
466
469
  if (!response.ok) {
467
470
  const error = await response.json().catch(() => ({}));
468
- throw new AuthGateError(error.error || `OAuth initiation failed: ${response.status}`);
471
+ throw new AuthGateError(
472
+ error.error || `OAuth initiation failed: ${response.status}`
473
+ );
469
474
  }
470
475
  const data = await response.json();
471
476
  return data.redirect_url;
@@ -568,20 +573,17 @@ var AuthGateClient = class {
568
573
  * @returns The raw `Response` from the AuthGate proxy.
569
574
  */
570
575
  async magicLinkSend(data) {
571
- return fetch(
572
- `${this.config.baseUrl}/api/proxy/email/magic-link/send`,
573
- {
574
- method: "POST",
575
- headers: {
576
- Authorization: `Bearer ${this.config.apiKey}`,
577
- "Content-Type": "application/json"
578
- },
579
- body: JSON.stringify({
580
- email: data.email,
581
- callback_url: data.callbackUrl
582
- })
583
- }
584
- );
576
+ return fetch(`${this.config.baseUrl}/api/proxy/email/magic-link/send`, {
577
+ method: "POST",
578
+ headers: {
579
+ Authorization: `Bearer ${this.config.apiKey}`,
580
+ "Content-Type": "application/json"
581
+ },
582
+ body: JSON.stringify({
583
+ email: data.email,
584
+ callback_url: data.callbackUrl
585
+ })
586
+ });
585
587
  }
586
588
  // ---------------------------------------------------------------------------
587
589
  // Email verification
@@ -825,17 +827,14 @@ var AuthGateClient = class {
825
827
  * @returns The raw `Response` with an array of backup codes.
826
828
  */
827
829
  async mfaBackupCodesGenerate(token) {
828
- return fetch(
829
- `${this.config.baseUrl}/api/proxy/mfa/backup-codes/generate`,
830
- {
831
- method: "POST",
832
- headers: {
833
- Authorization: `Bearer ${token}`,
834
- "Content-Type": "application/json"
835
- },
836
- body: "{}"
837
- }
838
- );
830
+ return fetch(`${this.config.baseUrl}/api/proxy/mfa/backup-codes/generate`, {
831
+ method: "POST",
832
+ headers: {
833
+ Authorization: `Bearer ${token}`,
834
+ "Content-Type": "application/json"
835
+ },
836
+ body: "{}"
837
+ });
839
838
  }
840
839
  /**
841
840
  * Get the current MFA enrollment status for the authenticated user.
@@ -924,23 +923,20 @@ var AuthGateClient = class {
924
923
  * @returns The raw `Response` from the AuthGate proxy.
925
924
  */
926
925
  async updateOrg(orgIdOrSlug, data) {
927
- return fetch(
928
- `${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}`,
929
- {
930
- method: "PATCH",
931
- headers: {
932
- Authorization: `Bearer ${this.config.apiKey}`,
933
- "Content-Type": "application/json"
934
- },
935
- body: JSON.stringify({
936
- name: data.name,
937
- slug: data.slug,
938
- image_url: data.imageUrl,
939
- max_members: data.maxMembers,
940
- metadata: data.metadata
941
- })
942
- }
943
- );
926
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}`, {
927
+ method: "PATCH",
928
+ headers: {
929
+ Authorization: `Bearer ${this.config.apiKey}`,
930
+ "Content-Type": "application/json"
931
+ },
932
+ body: JSON.stringify({
933
+ name: data.name,
934
+ slug: data.slug,
935
+ image_url: data.imageUrl,
936
+ max_members: data.maxMembers,
937
+ metadata: data.metadata
938
+ })
939
+ });
944
940
  }
945
941
  /**
946
942
  * Delete an organization.
@@ -1079,19 +1075,16 @@ var AuthGateClient = class {
1079
1075
  * @returns The raw `Response` from the AuthGate proxy.
1080
1076
  */
1081
1077
  async acceptOrgInvitation(data) {
1082
- return fetch(
1083
- `${this.config.baseUrl}/api/proxy/orgs/invitations/accept`,
1084
- {
1085
- method: "POST",
1086
- headers: {
1087
- Authorization: `Bearer ${this.config.apiKey}`,
1088
- "Content-Type": "application/json"
1089
- },
1090
- body: JSON.stringify({
1091
- token: data.token
1092
- })
1093
- }
1094
- );
1078
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/invitations/accept`, {
1079
+ method: "POST",
1080
+ headers: {
1081
+ Authorization: `Bearer ${this.config.apiKey}`,
1082
+ "Content-Type": "application/json"
1083
+ },
1084
+ body: JSON.stringify({
1085
+ token: data.token
1086
+ })
1087
+ });
1095
1088
  }
1096
1089
  /**
1097
1090
  * Leave an organization as the current user.
@@ -1100,17 +1093,14 @@ var AuthGateClient = class {
1100
1093
  * @returns The raw `Response` from the AuthGate proxy.
1101
1094
  */
1102
1095
  async leaveOrg(orgIdOrSlug) {
1103
- return fetch(
1104
- `${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}/leave`,
1105
- {
1106
- method: "POST",
1107
- headers: {
1108
- Authorization: `Bearer ${this.config.apiKey}`,
1109
- "Content-Type": "application/json"
1110
- },
1111
- body: "{}"
1112
- }
1113
- );
1096
+ return fetch(`${this.config.baseUrl}/api/proxy/orgs/${orgIdOrSlug}/leave`, {
1097
+ method: "POST",
1098
+ headers: {
1099
+ Authorization: `Bearer ${this.config.apiKey}`,
1100
+ "Content-Type": "application/json"
1101
+ },
1102
+ body: "{}"
1103
+ });
1114
1104
  }
1115
1105
  // ---------------------------------------------------------------------------
1116
1106
  // Cookie config accessors
package/icon.png ADDED
Binary file
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth-gate/core",
3
- "version": "0.9.2",
3
+ "version": "0.10.0",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
@@ -13,7 +13,8 @@
13
13
  "module": "./dist/index.mjs",
14
14
  "types": "./dist/index.d.ts",
15
15
  "files": [
16
- "dist"
16
+ "dist",
17
+ "icon.png"
17
18
  ],
18
19
  "engines": {
19
20
  "node": ">=18"