@auth-gate/core 0.9.0 → 0.9.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
@@ -51,6 +51,7 @@ __export(index_exports, {
51
51
  TokenVerificationError: () => TokenVerificationError,
52
52
  checkFeature: () => checkFeature,
53
53
  createAuthGateClient: () => createAuthGateClient,
54
+ defineConfig: () => defineConfig,
54
55
  hasAllPermissions: () => hasAllPermissions,
55
56
  hasAnyPermission: () => hasAnyPermission,
56
57
  hasFeature: () => hasFeature,
@@ -1268,6 +1269,11 @@ function createAuthGateClient(config) {
1268
1269
  return new AuthGateClient(config);
1269
1270
  }
1270
1271
 
1272
+ // src/project-config.ts
1273
+ function defineConfig(config) {
1274
+ return config;
1275
+ }
1276
+
1271
1277
  // src/billing.ts
1272
1278
  function hasPlan(entitlements, plan) {
1273
1279
  if (!(entitlements == null ? void 0 : entitlements.plan)) return false;
package/dist/index.d.cts CHANGED
@@ -688,6 +688,48 @@ declare class ConfigurationError extends AuthGateError {
688
688
  constructor(message: string);
689
689
  }
690
690
 
691
+ /**
692
+ * Connection details for the AuthGate API.
693
+ */
694
+ type AuthGateConnection = {
695
+ baseUrl?: string;
696
+ apiKey?: string;
697
+ };
698
+ /**
699
+ * Project-level config shape for `authgate.config.ts`.
700
+ * Used by both `@auth-gate/rbac` and `@auth-gate/billing` CLIs.
701
+ *
702
+ * The CLI auto-loads `.env` and `.env.local` before importing this file,
703
+ * so you can reference `process.env` or use a typed env module directly.
704
+ *
705
+ * @example
706
+ * ```ts
707
+ * import { defineConfig } from "@auth-gate/core";
708
+ *
709
+ * export default defineConfig({
710
+ * connection: {
711
+ * baseUrl: process.env.AUTHGATE_URL,
712
+ * apiKey: process.env.AUTHGATE_API_KEY,
713
+ * },
714
+ * });
715
+ * ```
716
+ */
717
+ interface AuthGateProjectConfig {
718
+ /** Connection details for the AuthGate API. */
719
+ connection?: AuthGateConnection;
720
+ /** Path to the RBAC config file (overrides auto-discovery). */
721
+ rbacConfig?: string;
722
+ /** Path to the Billing config file (overrides auto-discovery). */
723
+ billingConfig?: string;
724
+ }
725
+ /**
726
+ * Define your project-level AuthGate config. Use this in `authgate.config.ts`.
727
+ *
728
+ * Provides type safety and IDE autocomplete for the config file.
729
+ * This is an identity function — it returns the config as-is.
730
+ */
731
+ declare function defineConfig(config: AuthGateProjectConfig): AuthGateProjectConfig;
732
+
691
733
  /** A product/plan in the billing catalog. */
692
734
  interface BillingPlan {
693
735
  id: string;
@@ -880,4 +922,4 @@ declare function hasAnyPermission(membership: OrgMembership | null | undefined,
880
922
  */
881
923
  declare function hasAllPermissions(membership: OrgMembership | null | undefined, permissions: string[]): boolean;
882
924
 
883
- export { AuthGateClient, type AuthGateConfig, AuthGateError, type AuthGateUser, type BackupCodesResponse, type BillingEntitlement, type BillingEntitlementV2, type BillingPlan, type BillingPrice, type BillingSubscription, type BillingSubscriptionItem, type BooleanEntitlementDetail, ConfigurationError, type CookieOptions, DEFAULT_COOKIE_NAME, type EntitlementDetail, InvalidStateError, type MeteredEntitlementDetail, type MfaChallengeResponse, type MfaStatus, NONCE_COOKIE_NAME, type OAuthProvider, type OrgInvitation, type OrgMember, type OrgMembership, type OrgRole, type OrgWithMembership, type Organization, REFRESH_TOKEN_COOKIE_NAME, SESSION_MAX_AGE, STATE_TTL_MS, SUPPORTED_PROVIDERS, SessionDecryptionError, type SessionPayload, TokenVerificationError, type TokenVerifyResult, type TotpSetupResponse, type UsageEvent, checkFeature, createAuthGateClient, hasAllPermissions, hasAnyPermission, hasFeature, hasPermission, hasPlan, hasRole };
925
+ export { AuthGateClient, type AuthGateConfig, type AuthGateConnection, AuthGateError, type AuthGateProjectConfig, type AuthGateUser, type BackupCodesResponse, type BillingEntitlement, type BillingEntitlementV2, type BillingPlan, type BillingPrice, type BillingSubscription, type BillingSubscriptionItem, type BooleanEntitlementDetail, ConfigurationError, type CookieOptions, DEFAULT_COOKIE_NAME, type EntitlementDetail, InvalidStateError, type MeteredEntitlementDetail, type MfaChallengeResponse, type MfaStatus, NONCE_COOKIE_NAME, type OAuthProvider, type OrgInvitation, type OrgMember, type OrgMembership, type OrgRole, type OrgWithMembership, type Organization, REFRESH_TOKEN_COOKIE_NAME, SESSION_MAX_AGE, STATE_TTL_MS, SUPPORTED_PROVIDERS, SessionDecryptionError, type SessionPayload, TokenVerificationError, type TokenVerifyResult, type TotpSetupResponse, type UsageEvent, checkFeature, createAuthGateClient, defineConfig, hasAllPermissions, hasAnyPermission, hasFeature, hasPermission, hasPlan, hasRole };
package/dist/index.d.ts CHANGED
@@ -688,6 +688,48 @@ declare class ConfigurationError extends AuthGateError {
688
688
  constructor(message: string);
689
689
  }
690
690
 
691
+ /**
692
+ * Connection details for the AuthGate API.
693
+ */
694
+ type AuthGateConnection = {
695
+ baseUrl?: string;
696
+ apiKey?: string;
697
+ };
698
+ /**
699
+ * Project-level config shape for `authgate.config.ts`.
700
+ * Used by both `@auth-gate/rbac` and `@auth-gate/billing` CLIs.
701
+ *
702
+ * The CLI auto-loads `.env` and `.env.local` before importing this file,
703
+ * so you can reference `process.env` or use a typed env module directly.
704
+ *
705
+ * @example
706
+ * ```ts
707
+ * import { defineConfig } from "@auth-gate/core";
708
+ *
709
+ * export default defineConfig({
710
+ * connection: {
711
+ * baseUrl: process.env.AUTHGATE_URL,
712
+ * apiKey: process.env.AUTHGATE_API_KEY,
713
+ * },
714
+ * });
715
+ * ```
716
+ */
717
+ interface AuthGateProjectConfig {
718
+ /** Connection details for the AuthGate API. */
719
+ connection?: AuthGateConnection;
720
+ /** Path to the RBAC config file (overrides auto-discovery). */
721
+ rbacConfig?: string;
722
+ /** Path to the Billing config file (overrides auto-discovery). */
723
+ billingConfig?: string;
724
+ }
725
+ /**
726
+ * Define your project-level AuthGate config. Use this in `authgate.config.ts`.
727
+ *
728
+ * Provides type safety and IDE autocomplete for the config file.
729
+ * This is an identity function — it returns the config as-is.
730
+ */
731
+ declare function defineConfig(config: AuthGateProjectConfig): AuthGateProjectConfig;
732
+
691
733
  /** A product/plan in the billing catalog. */
692
734
  interface BillingPlan {
693
735
  id: string;
@@ -880,4 +922,4 @@ declare function hasAnyPermission(membership: OrgMembership | null | undefined,
880
922
  */
881
923
  declare function hasAllPermissions(membership: OrgMembership | null | undefined, permissions: string[]): boolean;
882
924
 
883
- export { AuthGateClient, type AuthGateConfig, AuthGateError, type AuthGateUser, type BackupCodesResponse, type BillingEntitlement, type BillingEntitlementV2, type BillingPlan, type BillingPrice, type BillingSubscription, type BillingSubscriptionItem, type BooleanEntitlementDetail, ConfigurationError, type CookieOptions, DEFAULT_COOKIE_NAME, type EntitlementDetail, InvalidStateError, type MeteredEntitlementDetail, type MfaChallengeResponse, type MfaStatus, NONCE_COOKIE_NAME, type OAuthProvider, type OrgInvitation, type OrgMember, type OrgMembership, type OrgRole, type OrgWithMembership, type Organization, REFRESH_TOKEN_COOKIE_NAME, SESSION_MAX_AGE, STATE_TTL_MS, SUPPORTED_PROVIDERS, SessionDecryptionError, type SessionPayload, TokenVerificationError, type TokenVerifyResult, type TotpSetupResponse, type UsageEvent, checkFeature, createAuthGateClient, hasAllPermissions, hasAnyPermission, hasFeature, hasPermission, hasPlan, hasRole };
925
+ export { AuthGateClient, type AuthGateConfig, type AuthGateConnection, AuthGateError, type AuthGateProjectConfig, type AuthGateUser, type BackupCodesResponse, type BillingEntitlement, type BillingEntitlementV2, type BillingPlan, type BillingPrice, type BillingSubscription, type BillingSubscriptionItem, type BooleanEntitlementDetail, ConfigurationError, type CookieOptions, DEFAULT_COOKIE_NAME, type EntitlementDetail, InvalidStateError, type MeteredEntitlementDetail, type MfaChallengeResponse, type MfaStatus, NONCE_COOKIE_NAME, type OAuthProvider, type OrgInvitation, type OrgMember, type OrgMembership, type OrgRole, type OrgWithMembership, type Organization, REFRESH_TOKEN_COOKIE_NAME, SESSION_MAX_AGE, STATE_TTL_MS, SUPPORTED_PROVIDERS, SessionDecryptionError, type SessionPayload, TokenVerificationError, type TokenVerifyResult, type TotpSetupResponse, type UsageEvent, checkFeature, createAuthGateClient, defineConfig, hasAllPermissions, hasAnyPermission, hasFeature, hasPermission, hasPlan, hasRole };
package/dist/index.mjs CHANGED
@@ -1226,6 +1226,11 @@ function createAuthGateClient(config) {
1226
1226
  return new AuthGateClient(config);
1227
1227
  }
1228
1228
 
1229
+ // src/project-config.ts
1230
+ function defineConfig(config) {
1231
+ return config;
1232
+ }
1233
+
1229
1234
  // src/billing.ts
1230
1235
  function hasPlan(entitlements, plan) {
1231
1236
  if (!(entitlements == null ? void 0 : entitlements.plan)) return false;
@@ -1300,6 +1305,7 @@ export {
1300
1305
  TokenVerificationError,
1301
1306
  checkFeature,
1302
1307
  createAuthGateClient,
1308
+ defineConfig,
1303
1309
  hasAllPermissions,
1304
1310
  hasAnyPermission,
1305
1311
  hasFeature,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@auth-gate/core",
3
- "version": "0.9.0",
3
+ "version": "0.9.1",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {