@travetto/auth 3.4.2 → 4.0.0-rc.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/README.md +2 -8
- package/package.json +2 -2
- package/src/types/authenticator.ts +1 -1
- package/src/types/authorizer.ts +1 -1
- package/src/types/principal.ts +1 -1
- package/src/util.ts +2 -23
package/README.md
CHANGED
|
@@ -118,20 +118,14 @@ The [AuthUtil](https://github.com/travetto/travetto/tree/main/module/auth/src/ut
|
|
|
118
118
|
|
|
119
119
|
**Code: Auth util structure**
|
|
120
120
|
```typescript
|
|
121
|
-
import crypto from 'crypto';
|
|
122
|
-
import util from 'util';
|
|
121
|
+
import crypto from 'node:crypto';
|
|
122
|
+
import util from 'node:util';
|
|
123
123
|
import { AppError, Util } from '@travetto/base';
|
|
124
124
|
const pbkdf2 = util.promisify(crypto.pbkdf2);
|
|
125
125
|
/**
|
|
126
126
|
* Standard auth utilities
|
|
127
127
|
*/
|
|
128
128
|
export class AuthUtil {
|
|
129
|
-
/**
|
|
130
|
-
* Build matcher for permissions in allow/deny fashion
|
|
131
|
-
*
|
|
132
|
-
* @param permissions Permissions to build matcher for
|
|
133
|
-
*/
|
|
134
|
-
static permissionMatcher(permissions: string[]): (perms: Set<string>) => boolean;
|
|
135
129
|
/**
|
|
136
130
|
* Generate a hash for a given value
|
|
137
131
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/auth",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-rc.1",
|
|
4
4
|
"description": "Authentication scaffolding for the Travetto framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"directory": "module/auth"
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@travetto/base": "^
|
|
26
|
+
"@travetto/base": "^4.0.0-rc.1"
|
|
27
27
|
},
|
|
28
28
|
"travetto": {
|
|
29
29
|
"displayName": "Authentication"
|
|
@@ -3,7 +3,7 @@ import { Principal } from './principal';
|
|
|
3
3
|
/**
|
|
4
4
|
* Supports validation payload of type T into an authenticated principal
|
|
5
5
|
*
|
|
6
|
-
* @concrete ../internal/types
|
|
6
|
+
* @concrete ../internal/types#AuthenticatorTarget
|
|
7
7
|
*/
|
|
8
8
|
export interface Authenticator<T = unknown, P extends Principal = Principal, C = unknown> {
|
|
9
9
|
/**
|
package/src/types/authorizer.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { Principal } from './principal';
|
|
|
3
3
|
/**
|
|
4
4
|
* Definition of an authorization source, which validates a principal into an authorized principal
|
|
5
5
|
*
|
|
6
|
-
* @concrete ../internal/types
|
|
6
|
+
* @concrete ../internal/types#AuthorizerTarget
|
|
7
7
|
*/
|
|
8
8
|
export interface Authorizer<P extends Principal = Principal> {
|
|
9
9
|
/**
|
package/src/types/principal.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A user principal, including permissions and details
|
|
3
3
|
*
|
|
4
|
-
* @concrete ../internal/types
|
|
4
|
+
* @concrete ../internal/types#PrincipalTarget
|
|
5
5
|
* @augments `@travetto/rest:Context`
|
|
6
6
|
*/
|
|
7
7
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
package/src/util.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import crypto from 'crypto';
|
|
2
|
-
import util from 'util';
|
|
1
|
+
import crypto from 'node:crypto';
|
|
2
|
+
import util from 'node:util';
|
|
3
3
|
|
|
4
4
|
import { AppError, Util } from '@travetto/base';
|
|
5
5
|
|
|
@@ -10,27 +10,6 @@ const pbkdf2 = util.promisify(crypto.pbkdf2);
|
|
|
10
10
|
*/
|
|
11
11
|
export class AuthUtil {
|
|
12
12
|
|
|
13
|
-
static #matchPermissionSet(rule: string[], perms: Set<string>): boolean {
|
|
14
|
-
for (const el of rule) {
|
|
15
|
-
if (!perms.has(el)) {
|
|
16
|
-
return false;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
return true;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Build matcher for permissions in allow/deny fashion
|
|
24
|
-
*
|
|
25
|
-
* @param permissions Permissions to build matcher for
|
|
26
|
-
*/
|
|
27
|
-
static permissionMatcher(permissions: string[]): (perms: Set<string>) => boolean {
|
|
28
|
-
return Util.allowDenyMatcher<string[], [Set<string>]>(permissions,
|
|
29
|
-
x => x.split('|'),
|
|
30
|
-
this.#matchPermissionSet.bind(this),
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
13
|
/**
|
|
35
14
|
* Generate a hash for a given value
|
|
36
15
|
*
|