Skip to content

Commit e23fea6

Browse files
committed
update dependecies and remove deprecated packages
1 parent b2ef39a commit e23fea6

29 files changed

+1263
-1388
lines changed
Lines changed: 292 additions & 291 deletions
Large diffs are not rendered by default.

.yarnrc.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ nodeLinker: node-modules
66

77
npmAuthToken: "${NODE_AUTH_TOKEN:-default}"
88

9-
yarnPath: .yarn/releases/yarn-4.6.0.cjs
9+
yarnPath: .yarn/releases/yarn-4.7.0.cjs

eslint.config.mjs

Lines changed: 50 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import simpleImportSort from "eslint-plugin-simple-import-sort";
2-
import typescriptSortKeys from "eslint-plugin-typescript-sort-keys";
1+
import perfectionist from "eslint-plugin-perfectionist";
32
import path from "node:path";
43
import { fileURLToPath } from "node:url";
4+
55
import { fixupConfigRules } from "@eslint/compat";
66
import { FlatCompat } from "@eslint/eslintrc";
77
import js from "@eslint/js";
@@ -10,9 +10,9 @@ import tsParser from "@typescript-eslint/parser";
1010
const __filename = fileURLToPath(import.meta.url);
1111
const __dirname = path.dirname(__filename);
1212
const compat = new FlatCompat({
13+
allConfig: js.configs.all,
1314
baseDirectory: __dirname,
1415
recommendedConfig: js.configs.recommended,
15-
allConfig: js.configs.all,
1616
});
1717

1818
export default [
@@ -27,93 +27,97 @@ export default [
2727
"plugin:prettier/recommended",
2828
),
2929
),
30+
perfectionist.configs["recommended-natural"],
3031
{
31-
plugins: {
32-
"simple-import-sort": simpleImportSort,
33-
"typescript-sort-keys": typescriptSortKeys,
34-
},
35-
3632
languageOptions: {
37-
parser: tsParser,
3833
ecmaVersion: 2018,
34+
parser: tsParser,
3935
sourceType: "module",
4036
},
4137

42-
rules: {
43-
curly: "error",
44-
eqeqeq: ["error", "always"],
45-
"no-console": "warn",
46-
"no-debugger": "warn",
47-
"no-duplicate-case": "error",
48-
"no-use-before-define": "off",
38+
plugins: {},
4939

40+
rules: {
5041
"@typescript-eslint/consistent-type-assertions": [
5142
"error",
5243
{
5344
assertionStyle: "as",
5445
objectLiteralTypeAssertions: "allow-as-parameter",
5546
},
5647
],
57-
5848
"@typescript-eslint/explicit-module-boundary-types": "off",
59-
6049
"@typescript-eslint/naming-convention": [
6150
1,
6251
{
63-
selector: "interface",
6452
format: ["PascalCase"],
53+
selector: "interface",
6554
},
6655
],
67-
6856
"@typescript-eslint/no-empty-function": "off",
69-
"@typescript-eslint/no-inferrable-types": "off",
70-
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
71-
"@typescript-eslint/no-non-null-assertion": "off",
72-
"@typescript-eslint/no-var-requires": "off",
73-
"prettier/prettier": ["error"],
74-
75-
"simple-import-sort/imports": [
76-
"warn",
77-
{
78-
groups: [["^\\u0000"], ["^\\w", "^@"], ["^"], ["^\\."]],
79-
},
80-
],
81-
82-
"typescript-sort-keys/string-enum": [
57+
"@typescript-eslint/no-empty-interface": "off",
58+
"@typescript-eslint/no-explicit-any": [
8359
"error",
84-
"asc",
8560
{
86-
caseSensitive: false,
87-
natural: true,
61+
fixToUnknown: true,
8862
},
8963
],
9064

65+
"@typescript-eslint/no-inferrable-types": "off",
66+
67+
"@typescript-eslint/no-non-null-asserted-nullish-coalescing": "error",
68+
69+
"@typescript-eslint/no-non-null-assertion": "off",
70+
9171
"@typescript-eslint/no-unused-expressions": [
9272
"error",
9373
{
9474
allowShortCircuit: true,
9575
allowTernary: true,
9676
},
9777
],
98-
99-
"@typescript-eslint/no-empty-interface": "off",
100-
101-
"@typescript-eslint/no-explicit-any": [
102-
"error",
78+
"@typescript-eslint/no-unused-vars": [
79+
"warn",
10380
{
104-
fixToUnknown: true,
81+
argsIgnorePattern: "^_",
82+
varsIgnorePattern: "^_",
10583
},
10684
],
85+
"@typescript-eslint/no-var-requires": "off",
86+
curly: "error",
87+
eqeqeq: ["error", "always"],
88+
"no-console": "warn",
89+
90+
"no-debugger": "warn",
91+
92+
"no-duplicate-case": "error",
10793

10894
"no-unused-vars": "off",
10995

110-
"@typescript-eslint/no-unused-vars": [
96+
"no-use-before-define": "off",
97+
"perfectionist/sort-enums": [
11198
"warn",
11299
{
113-
argsIgnorePattern: "^_",
114-
varsIgnorePattern: "^_",
100+
partitionByComment: true,
101+
partitionByNewLine: true,
115102
},
116103
],
104+
"perfectionist/sort-imports": [
105+
"warn",
106+
{
107+
internalPattern: ["^@"],
108+
specialCharacters: "keep",
109+
},
110+
],
111+
"perfectionist/sort-maps": [
112+
"warn",
113+
{
114+
partitionByComment: true,
115+
partitionByNewLine: true,
116+
},
117+
],
118+
"perfectionist/sort-objects": "off",
119+
"perfectionist/sort-interfaces": "off",
120+
"prettier/prettier": ["error"],
117121
},
118122
},
119123
];

lib/authorizer/index.ts

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { readFileSync } from "fs";
2+
23
import {
34
Authorizer as AuthorizerClient,
45
DecisionTreeRequestSchema,
@@ -30,14 +31,14 @@ import {
3031
} from "./types";
3132

3233
type AuthorizerConfig = {
33-
authorizerServiceUrl?: string;
34-
tenantId?: string;
3534
authorizerApiKey?: string;
36-
token?: string;
3735
authorizerCertFile?: string;
36+
authorizerServiceUrl?: string;
3837
caFile?: string;
39-
insecure?: boolean;
4038
customHeaders?: { [key: string]: unknown };
39+
insecure?: boolean;
40+
tenantId?: string;
41+
token?: string;
4142
};
4243

4344
type Path = {
@@ -68,9 +69,9 @@ export class Authorizer {
6869

6970
const insecure = config?.insecure || false;
7071
const baseNodeOptions = {
71-
rejectUnauthorized: !insecure,
7272
ca: baseCaFile,
7373
headers: config.customHeaders,
74+
rejectUnauthorized: !insecure,
7475
};
7576

7677
const baseGrpcTransport = createGrpcTransport({
@@ -82,44 +83,6 @@ export class Authorizer {
8283
this.AuthClient = createClient(AuthorizerClient, baseGrpcTransport);
8384
}
8485

85-
async Is(params: IsRequest, options?: CallOptions): Promise<boolean> {
86-
try {
87-
const request: IsRequest$ = create(IsRequestSchema, {
88-
...params,
89-
policyInstance:
90-
params.policyInstance &&
91-
policyInstance(params.policyInstance.name || ""),
92-
});
93-
const response = await this.AuthClient.is(request, options);
94-
95-
const allowed = response.decisions[0]?.is;
96-
return !!allowed;
97-
} catch (error) {
98-
throw handleError(error, "Is");
99-
}
100-
}
101-
102-
async Query(
103-
params: QueryRequest,
104-
options?: CallOptions,
105-
): Promise<JsonObject> {
106-
try {
107-
const request: QueryRequest$ = create(QueryRequestSchema, {
108-
...params,
109-
policyInstance:
110-
params.policyInstance &&
111-
policyInstance(params.policyInstance.name || ""),
112-
});
113-
114-
const response = await this.AuthClient.query(request, options);
115-
const query: JsonObject = response.response || {};
116-
117-
return query;
118-
} catch (error) {
119-
throw handleError(error, "Query");
120-
}
121-
}
122-
12386
async DecisionTree(
12487
params: DecisionTreeRequest,
12588
options?: CallOptions,
@@ -144,6 +107,24 @@ export class Authorizer {
144107
throw handleError(error, "DecissionTree");
145108
}
146109
}
110+
111+
async Is(params: IsRequest, options?: CallOptions): Promise<boolean> {
112+
try {
113+
const request: IsRequest$ = create(IsRequestSchema, {
114+
...params,
115+
policyInstance:
116+
params.policyInstance &&
117+
policyInstance(params.policyInstance.name || ""),
118+
});
119+
const response = await this.AuthClient.is(request, options);
120+
121+
const allowed = response.decisions[0]?.is;
122+
return !!allowed;
123+
} catch (error) {
124+
throw handleError(error, "Is");
125+
}
126+
}
127+
147128
async ListPolicies(
148129
params: ListPoliciesRequest,
149130
options?: CallOptions,
@@ -159,6 +140,26 @@ export class Authorizer {
159140
throw handleError(error, "ListPolicies");
160141
}
161142
}
143+
async Query(
144+
params: QueryRequest,
145+
options?: CallOptions,
146+
): Promise<JsonObject> {
147+
try {
148+
const request: QueryRequest$ = create(QueryRequestSchema, {
149+
...params,
150+
policyInstance:
151+
params.policyInstance &&
152+
policyInstance(params.policyInstance.name || ""),
153+
});
154+
155+
const response = await this.AuthClient.query(request, options);
156+
const query: JsonObject = response.response || {};
157+
158+
return query;
159+
} catch (error) {
160+
throw handleError(error, "Query");
161+
}
162+
}
162163
}
163164

164165
/**

lib/authorizer/mapper/identity/jwt.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Request } from "express";
22
import { jwtDecode } from "jwt-decode";
3+
34
import { IdentityContext } from "@aserto/node-authorizer/src/gen/cjs/aserto/authorizer/v2/api/identity_context_pb";
45

56
import { IdentityMapper } from "../../middleware";

lib/authorizer/mapper/identity/sub.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Request } from "express";
22
import { jwtDecode, JwtPayload } from "jwt-decode";
3+
34
import { IdentityContext } from "@aserto/node-authorizer/src/gen/cjs/aserto/authorizer/v2/api/identity_context_pb";
45

56
import { IdentityMapper } from "../../middleware";

0 commit comments

Comments
 (0)