@authyon/auth 0.2.0-beta.25 → 0.2.0-beta.27
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/{ability-DjEMCVjx.d.cts → ability-BE38_bgr.d.cts} +3 -1
- package/dist/{ability-DjEMCVjx.d.ts → ability-BE38_bgr.d.ts} +3 -1
- package/dist/{chunk-IX6U6A72.js → chunk-3MOFQ3S4.js} +19 -0
- package/dist/index.cjs +19 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/react/index.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- package/dist/react/index.js +1 -1
- package/package.json +1 -1
|
@@ -996,7 +996,9 @@ declare function createAuthyonAbility(source?: AuthyonPermissionSource, options?
|
|
|
996
996
|
* Whether a source holds an Authyon permission, by Authyon's own rules: the
|
|
997
997
|
* values are compared segment by segment, `*` stands for any one segment, and
|
|
998
998
|
* two values of different lengths never match — except an all-wildcard grant,
|
|
999
|
-
* which is everything
|
|
999
|
+
* which is everything, and a grant ending in `**`, which stands for one or
|
|
1000
|
+
* more segments (`manager:**` covers `manager:account:read` and
|
|
1001
|
+
* `manager:account:credentials:write`). OAuth scopes count as permissions.
|
|
1000
1002
|
*
|
|
1001
1003
|
* Not the same question as {@link AuthyonAbility.can}. An ability is CASL, so
|
|
1002
1004
|
* the action `manage` there means "every action on this subject", which is a
|
|
@@ -996,7 +996,9 @@ declare function createAuthyonAbility(source?: AuthyonPermissionSource, options?
|
|
|
996
996
|
* Whether a source holds an Authyon permission, by Authyon's own rules: the
|
|
997
997
|
* values are compared segment by segment, `*` stands for any one segment, and
|
|
998
998
|
* two values of different lengths never match — except an all-wildcard grant,
|
|
999
|
-
* which is everything
|
|
999
|
+
* which is everything, and a grant ending in `**`, which stands for one or
|
|
1000
|
+
* more segments (`manager:**` covers `manager:account:read` and
|
|
1001
|
+
* `manager:account:credentials:write`). OAuth scopes count as permissions.
|
|
1000
1002
|
*
|
|
1001
1003
|
* Not the same question as {@link AuthyonAbility.can}. An ability is CASL, so
|
|
1002
1004
|
* the action `manage` there means "every action on this subject", which is a
|
|
@@ -208,11 +208,30 @@ function grants(granted, required) {
|
|
|
208
208
|
if (isFullWildcard(granted)) return true;
|
|
209
209
|
const grantedSegments = granted.split(":");
|
|
210
210
|
const requiredSegments = required.split(":");
|
|
211
|
+
if (isRecursive(grantedSegments) || isRecursive(requiredSegments)) {
|
|
212
|
+
return grantsRecursive(grantedSegments, requiredSegments);
|
|
213
|
+
}
|
|
211
214
|
if (grantedSegments.length !== requiredSegments.length) return false;
|
|
212
215
|
return grantedSegments.every(
|
|
213
216
|
(segment, index) => segment === "*" || segment === requiredSegments[index]
|
|
214
217
|
);
|
|
215
218
|
}
|
|
219
|
+
var RECURSIVE_WILDCARD = "**";
|
|
220
|
+
function isRecursive(segments) {
|
|
221
|
+
return segments[segments.length - 1] === RECURSIVE_WILDCARD;
|
|
222
|
+
}
|
|
223
|
+
function grantsRecursive(granted, required) {
|
|
224
|
+
if (!isRecursive(granted)) return false;
|
|
225
|
+
if (granted.slice(0, -1).includes(RECURSIVE_WILDCARD)) return false;
|
|
226
|
+
if (required.slice(0, -1).includes(RECURSIVE_WILDCARD)) return false;
|
|
227
|
+
const prefix = granted.length - 1;
|
|
228
|
+
const requiredPinned = isRecursive(required) ? required.length - 1 : required.length;
|
|
229
|
+
if (isRecursive(required) ? requiredPinned < prefix : requiredPinned <= prefix) return false;
|
|
230
|
+
for (let index = 0; index < prefix; index++) {
|
|
231
|
+
if (granted[index] !== "*" && granted[index] !== required[index]) return false;
|
|
232
|
+
}
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
216
235
|
function isWellFormedPermission(permission) {
|
|
217
236
|
if (!permission) return false;
|
|
218
237
|
const segments = permission.split(":");
|
package/dist/index.cjs
CHANGED
|
@@ -1360,11 +1360,30 @@ function grants(granted, required) {
|
|
|
1360
1360
|
if (isFullWildcard(granted)) return true;
|
|
1361
1361
|
const grantedSegments = granted.split(":");
|
|
1362
1362
|
const requiredSegments = required.split(":");
|
|
1363
|
+
if (isRecursive(grantedSegments) || isRecursive(requiredSegments)) {
|
|
1364
|
+
return grantsRecursive(grantedSegments, requiredSegments);
|
|
1365
|
+
}
|
|
1363
1366
|
if (grantedSegments.length !== requiredSegments.length) return false;
|
|
1364
1367
|
return grantedSegments.every(
|
|
1365
1368
|
(segment, index) => segment === "*" || segment === requiredSegments[index]
|
|
1366
1369
|
);
|
|
1367
1370
|
}
|
|
1371
|
+
var RECURSIVE_WILDCARD = "**";
|
|
1372
|
+
function isRecursive(segments) {
|
|
1373
|
+
return segments[segments.length - 1] === RECURSIVE_WILDCARD;
|
|
1374
|
+
}
|
|
1375
|
+
function grantsRecursive(granted, required) {
|
|
1376
|
+
if (!isRecursive(granted)) return false;
|
|
1377
|
+
if (granted.slice(0, -1).includes(RECURSIVE_WILDCARD)) return false;
|
|
1378
|
+
if (required.slice(0, -1).includes(RECURSIVE_WILDCARD)) return false;
|
|
1379
|
+
const prefix = granted.length - 1;
|
|
1380
|
+
const requiredPinned = isRecursive(required) ? required.length - 1 : required.length;
|
|
1381
|
+
if (isRecursive(required) ? requiredPinned < prefix : requiredPinned <= prefix) return false;
|
|
1382
|
+
for (let index = 0; index < prefix; index++) {
|
|
1383
|
+
if (granted[index] !== "*" && granted[index] !== required[index]) return false;
|
|
1384
|
+
}
|
|
1385
|
+
return true;
|
|
1386
|
+
}
|
|
1368
1387
|
function isWellFormedPermission(permission) {
|
|
1369
1388
|
if (!permission) return false;
|
|
1370
1389
|
const segments = permission.split(":");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, M as OrganizationInviteInput, N as OrganizationInviteIssued, P as OrganizationInvitePreview, Q as OrganizationInviteStatus, R as OrganizationMember, S as Paged, U as PaginationOptions, V as PasswordResetCompleted, W as PasswordResetPreview, X as PasswordResetRequestOptions, Y as PermissionGroup, Z as RegisterInput, _ as Role, $ as SecurityMethods, a0 as Session, a1 as SessionControllerOptions, a2 as SessionInfo, a3 as SessionSnapshot, a4 as SessionSnapshotListener, a5 as SessionStatus, a6 as SsoProvider, a7 as SubjectApprovals, a8 as SubjectSecurity, a9 as TwoFactorChallenge, aa as TwoFactorMethod, ab as TwoFactorStatus, ac as User, ad as ValidateResult, ae as VerifyTwoFactorInput, af as WebAuthnAssertion, ag as WebAuthnCeremonyStart, ah as WebAuthnCredential, ai as createAuthyonAbility, aj as createAuthyonRules, ak as createClient, al as hasPermission, am as hasPermissionGroup } from './ability-
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-BE38_bgr.cjs';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, M as OrganizationInviteInput, N as OrganizationInviteIssued, P as OrganizationInvitePreview, Q as OrganizationInviteStatus, R as OrganizationMember, S as Paged, U as PaginationOptions, V as PasswordResetCompleted, W as PasswordResetPreview, X as PasswordResetRequestOptions, Y as PermissionGroup, Z as RegisterInput, _ as Role, $ as SecurityMethods, a0 as Session, a1 as SessionControllerOptions, a2 as SessionInfo, a3 as SessionSnapshot, a4 as SessionSnapshotListener, a5 as SessionStatus, a6 as SsoProvider, a7 as SubjectApprovals, a8 as SubjectSecurity, a9 as TwoFactorChallenge, aa as TwoFactorMethod, ab as TwoFactorStatus, ac as User, ad as ValidateResult, ae as VerifyTwoFactorInput, af as WebAuthnAssertion, ag as WebAuthnCeremonyStart, ah as WebAuthnCredential, ai as createAuthyonAbility, aj as createAuthyonRules, ak as createClient, al as hasPermission, am as hasPermissionGroup } from './ability-BE38_bgr.cjs';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-
|
|
2
|
-
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, M as OrganizationInviteInput, N as OrganizationInviteIssued, P as OrganizationInvitePreview, Q as OrganizationInviteStatus, R as OrganizationMember, S as Paged, U as PaginationOptions, V as PasswordResetCompleted, W as PasswordResetPreview, X as PasswordResetRequestOptions, Y as PermissionGroup, Z as RegisterInput, _ as Role, $ as SecurityMethods, a0 as Session, a1 as SessionControllerOptions, a2 as SessionInfo, a3 as SessionSnapshot, a4 as SessionSnapshotListener, a5 as SessionStatus, a6 as SsoProvider, a7 as SubjectApprovals, a8 as SubjectSecurity, a9 as TwoFactorChallenge, aa as TwoFactorMethod, ab as TwoFactorStatus, ac as User, ad as ValidateResult, ae as VerifyTwoFactorInput, af as WebAuthnAssertion, ag as WebAuthnCeremonyStart, ah as WebAuthnCredential, ai as createAuthyonAbility, aj as createAuthyonRules, ak as createClient, al as hasPermission, am as hasPermissionGroup } from './ability-
|
|
1
|
+
import { T as TokenStorage, H as HttpAdapter, a as HttpLoggerOptions, A as AuthyonClient } from './ability-BE38_bgr.js';
|
|
2
|
+
export { b as AbilityConditions, c as AbilityEvent, d as AbilityListener, e as AbilityRule, f as AbilitySubject, g as AcceptOrganizationInviteInput, h as Activity, i as Approval, j as ApprovalAssurance, k as ApprovalPayload, l as ApprovalStatus, m as ApprovalWebAuthnOptions, n as AuthEvent, o as AuthState, p as AuthStateListener, q as AuthenticatorSetup, r as AuthyonAbility, s as AuthyonAbilityBuilder, t as AuthyonAbilityOptions, u as AuthyonClientOptions, v as AuthyonPermissionSource, w as AuthyonSessionController, C as ConfirmApprovalInput, x as CreateOrganizationInput, F as FetchHttpAdapter, y as HttpAdapterRequest, z as HttpLogEvent, B as HttpLogger, I as IntrospectResult, D as InviteMemberInput, L as LoggingHttpAdapter, E as LoginInput, G as LoginResult, O as Organization, J as OrganizationInvite, K as OrganizationInviteAccepted, M as OrganizationInviteInput, N as OrganizationInviteIssued, P as OrganizationInvitePreview, Q as OrganizationInviteStatus, R as OrganizationMember, S as Paged, U as PaginationOptions, V as PasswordResetCompleted, W as PasswordResetPreview, X as PasswordResetRequestOptions, Y as PermissionGroup, Z as RegisterInput, _ as Role, $ as SecurityMethods, a0 as Session, a1 as SessionControllerOptions, a2 as SessionInfo, a3 as SessionSnapshot, a4 as SessionSnapshotListener, a5 as SessionStatus, a6 as SsoProvider, a7 as SubjectApprovals, a8 as SubjectSecurity, a9 as TwoFactorChallenge, aa as TwoFactorMethod, ab as TwoFactorStatus, ac as User, ad as ValidateResult, ae as VerifyTwoFactorInput, af as WebAuthnAssertion, ag as WebAuthnCeremonyStart, ah as WebAuthnCredential, ai as createAuthyonAbility, aj as createAuthyonRules, ak as createClient, al as hasPermission, am as hasPermissionGroup } from './ability-BE38_bgr.js';
|
|
3
3
|
|
|
4
4
|
declare const ErrorCodes: {
|
|
5
5
|
readonly Unknown: "unknown";
|
package/dist/index.js
CHANGED
package/dist/react/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { ac as User, a1 as SessionControllerOptions, A as AuthyonClient, a3 as SessionSnapshot, a0 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-
|
|
4
|
-
export { w as AuthyonSessionController, a4 as SessionSnapshotListener, a5 as SessionStatus } from '../ability-
|
|
3
|
+
import { ac as User, a1 as SessionControllerOptions, A as AuthyonClient, a3 as SessionSnapshot, a0 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-BE38_bgr.cjs';
|
|
4
|
+
export { w as AuthyonSessionController, a4 as SessionSnapshotListener, a5 as SessionStatus } from '../ability-BE38_bgr.cjs';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|
package/dist/react/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { ac as User, a1 as SessionControllerOptions, A as AuthyonClient, a3 as SessionSnapshot, a0 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-
|
|
4
|
-
export { w as AuthyonSessionController, a4 as SessionSnapshotListener, a5 as SessionStatus } from '../ability-
|
|
3
|
+
import { ac as User, a1 as SessionControllerOptions, A as AuthyonClient, a3 as SessionSnapshot, a0 as Session, f as AbilitySubject, t as AuthyonAbilityOptions, r as AuthyonAbility } from '../ability-BE38_bgr.js';
|
|
4
|
+
export { w as AuthyonSessionController, a4 as SessionSnapshotListener, a5 as SessionStatus } from '../ability-BE38_bgr.js';
|
|
5
5
|
|
|
6
6
|
interface AuthyonProviderProps<TUser extends User = User> extends SessionControllerOptions {
|
|
7
7
|
client: AuthyonClient;
|
package/dist/react/index.js
CHANGED