@auth-gate/core 0.12.1 → 0.13.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/dist/index.cjs +18 -1
- package/dist/index.d.cts +18 -1
- package/dist/index.d.ts +18 -1
- package/dist/index.mjs +18 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -55,9 +55,11 @@ __export(index_exports, {
|
|
|
55
55
|
hasAllPermissions: () => hasAllPermissions,
|
|
56
56
|
hasAnyPermission: () => hasAnyPermission,
|
|
57
57
|
hasFeature: () => hasFeature,
|
|
58
|
+
hasMergedPermission: () => hasMergedPermission,
|
|
58
59
|
hasPermission: () => hasPermission,
|
|
59
60
|
hasPlan: () => hasPlan,
|
|
60
|
-
hasRole: () => hasRole
|
|
61
|
+
hasRole: () => hasRole,
|
|
62
|
+
mergePermissions: () => mergePermissions
|
|
61
63
|
});
|
|
62
64
|
module.exports = __toCommonJS(index_exports);
|
|
63
65
|
|
|
@@ -1323,3 +1325,18 @@ function matchesPermission(granted, required) {
|
|
|
1323
1325
|
}
|
|
1324
1326
|
return false;
|
|
1325
1327
|
}
|
|
1328
|
+
function mergePermissions(projectRole, orgMembership) {
|
|
1329
|
+
var _a;
|
|
1330
|
+
const set = /* @__PURE__ */ new Set();
|
|
1331
|
+
if (projectRole == null ? void 0 : projectRole.permissions) {
|
|
1332
|
+
for (const p of projectRole.permissions) set.add(p);
|
|
1333
|
+
}
|
|
1334
|
+
if ((_a = orgMembership == null ? void 0 : orgMembership.role) == null ? void 0 : _a.permissions) {
|
|
1335
|
+
for (const p of orgMembership.role.permissions) set.add(p);
|
|
1336
|
+
}
|
|
1337
|
+
return [...set];
|
|
1338
|
+
}
|
|
1339
|
+
function hasMergedPermission(projectRole, orgMembership, permission) {
|
|
1340
|
+
const merged = mergePermissions(projectRole, orgMembership);
|
|
1341
|
+
return matchesPermission(merged, permission);
|
|
1342
|
+
}
|
package/dist/index.d.cts
CHANGED
|
@@ -989,5 +989,22 @@ declare function hasAnyPermission(membership: OrgMembership | null | undefined,
|
|
|
989
989
|
* @returns `true` if every permission is granted.
|
|
990
990
|
*/
|
|
991
991
|
declare function hasAllPermissions(membership: OrgMembership | null | undefined, permissions: string[]): boolean;
|
|
992
|
+
/** A user's project-level role assignment (no org required). */
|
|
993
|
+
interface UserRoleAssignment {
|
|
994
|
+
roleKey: string;
|
|
995
|
+
roleName: string;
|
|
996
|
+
permissions: string[];
|
|
997
|
+
assignedAt: string;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Merge permissions from a project-level role and an org-level role (union).
|
|
1001
|
+
* Either may be null/undefined.
|
|
1002
|
+
*/
|
|
1003
|
+
declare function mergePermissions(projectRole: UserRoleAssignment | null | undefined, orgMembership: OrgMembership | null | undefined): string[];
|
|
1004
|
+
/**
|
|
1005
|
+
* Check a permission against a merged permission set (project + org).
|
|
1006
|
+
* Supports wildcard matching.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function hasMergedPermission(projectRole: UserRoleAssignment | null | undefined, orgMembership: OrgMembership | null | undefined, permission: string): boolean;
|
|
992
1009
|
|
|
993
|
-
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 };
|
|
1010
|
+
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, type UserRoleAssignment, checkFeature, createAuthGateClient, defineConfig, hasAllPermissions, hasAnyPermission, hasFeature, hasMergedPermission, hasPermission, hasPlan, hasRole, mergePermissions };
|
package/dist/index.d.ts
CHANGED
|
@@ -989,5 +989,22 @@ declare function hasAnyPermission(membership: OrgMembership | null | undefined,
|
|
|
989
989
|
* @returns `true` if every permission is granted.
|
|
990
990
|
*/
|
|
991
991
|
declare function hasAllPermissions(membership: OrgMembership | null | undefined, permissions: string[]): boolean;
|
|
992
|
+
/** A user's project-level role assignment (no org required). */
|
|
993
|
+
interface UserRoleAssignment {
|
|
994
|
+
roleKey: string;
|
|
995
|
+
roleName: string;
|
|
996
|
+
permissions: string[];
|
|
997
|
+
assignedAt: string;
|
|
998
|
+
}
|
|
999
|
+
/**
|
|
1000
|
+
* Merge permissions from a project-level role and an org-level role (union).
|
|
1001
|
+
* Either may be null/undefined.
|
|
1002
|
+
*/
|
|
1003
|
+
declare function mergePermissions(projectRole: UserRoleAssignment | null | undefined, orgMembership: OrgMembership | null | undefined): string[];
|
|
1004
|
+
/**
|
|
1005
|
+
* Check a permission against a merged permission set (project + org).
|
|
1006
|
+
* Supports wildcard matching.
|
|
1007
|
+
*/
|
|
1008
|
+
declare function hasMergedPermission(projectRole: UserRoleAssignment | null | undefined, orgMembership: OrgMembership | null | undefined, permission: string): boolean;
|
|
992
1009
|
|
|
993
|
-
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 };
|
|
1010
|
+
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, type UserRoleAssignment, checkFeature, createAuthGateClient, defineConfig, hasAllPermissions, hasAnyPermission, hasFeature, hasMergedPermission, hasPermission, hasPlan, hasRole, mergePermissions };
|
package/dist/index.mjs
CHANGED
|
@@ -1280,6 +1280,21 @@ function matchesPermission(granted, required) {
|
|
|
1280
1280
|
}
|
|
1281
1281
|
return false;
|
|
1282
1282
|
}
|
|
1283
|
+
function mergePermissions(projectRole, orgMembership) {
|
|
1284
|
+
var _a;
|
|
1285
|
+
const set = /* @__PURE__ */ new Set();
|
|
1286
|
+
if (projectRole == null ? void 0 : projectRole.permissions) {
|
|
1287
|
+
for (const p of projectRole.permissions) set.add(p);
|
|
1288
|
+
}
|
|
1289
|
+
if ((_a = orgMembership == null ? void 0 : orgMembership.role) == null ? void 0 : _a.permissions) {
|
|
1290
|
+
for (const p of orgMembership.role.permissions) set.add(p);
|
|
1291
|
+
}
|
|
1292
|
+
return [...set];
|
|
1293
|
+
}
|
|
1294
|
+
function hasMergedPermission(projectRole, orgMembership, permission) {
|
|
1295
|
+
const merged = mergePermissions(projectRole, orgMembership);
|
|
1296
|
+
return matchesPermission(merged, permission);
|
|
1297
|
+
}
|
|
1283
1298
|
export {
|
|
1284
1299
|
AuthGateClient,
|
|
1285
1300
|
AuthGateError,
|
|
@@ -1299,7 +1314,9 @@ export {
|
|
|
1299
1314
|
hasAllPermissions,
|
|
1300
1315
|
hasAnyPermission,
|
|
1301
1316
|
hasFeature,
|
|
1317
|
+
hasMergedPermission,
|
|
1302
1318
|
hasPermission,
|
|
1303
1319
|
hasPlan,
|
|
1304
|
-
hasRole
|
|
1320
|
+
hasRole,
|
|
1321
|
+
mergePermissions
|
|
1305
1322
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@auth-gate/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "Core client library for AuthGate — the OAuth proxy that handles provider configuration, token exchange, and user normalization so you don't have to.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|