@seidor-cloud-produtos/orbit-backend-lib 2.0.87 → 2.0.89
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.
|
@@ -6,7 +6,7 @@ function handleAuthorizerHeaders(headers) {
|
|
|
6
6
|
userName: headers.username,
|
|
7
7
|
userEmail: headers.useremail,
|
|
8
8
|
appName: headers['app-name'],
|
|
9
|
-
entityId:
|
|
9
|
+
entityId: headers.userid || headers['app-id'] || headers.useremail,
|
|
10
10
|
tenantId: headers.tenantid,
|
|
11
11
|
};
|
|
12
12
|
}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @deprecated Use authorizerHeaders.
|
|
5
|
+
*/
|
|
2
6
|
export declare const headersDefault: z.ZodObject<{
|
|
3
7
|
tenantid: z.ZodString;
|
|
4
8
|
username: z.ZodString;
|
|
@@ -12,6 +16,10 @@ export declare const headersDefault: z.ZodObject<{
|
|
|
12
16
|
tenantid: string;
|
|
13
17
|
useremail: string;
|
|
14
18
|
}>;
|
|
19
|
+
/**
|
|
20
|
+
*
|
|
21
|
+
* @deprecated Use authorizerHeaders.
|
|
22
|
+
*/
|
|
15
23
|
export declare const headersDefaultWithUserId: z.ZodObject<{
|
|
16
24
|
tenantid: z.ZodString;
|
|
17
25
|
username: z.ZodString;
|
|
@@ -28,26 +36,84 @@ export declare const headersDefaultWithUserId: z.ZodObject<{
|
|
|
28
36
|
useremail: string;
|
|
29
37
|
userid: string;
|
|
30
38
|
}>;
|
|
31
|
-
export declare const
|
|
39
|
+
export declare const tenantIdSchema: z.ZodObject<{
|
|
40
|
+
tenantid: z.ZodString;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
tenantid: string;
|
|
43
|
+
}, {
|
|
44
|
+
tenantid: string;
|
|
45
|
+
}>;
|
|
46
|
+
export declare const userSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
32
47
|
username: z.ZodString;
|
|
33
48
|
useremail: z.ZodString;
|
|
34
|
-
userid: z.ZodString
|
|
49
|
+
userid: z.ZodOptional<z.ZodString>;
|
|
50
|
+
}, {
|
|
35
51
|
tenantid: z.ZodString;
|
|
36
|
-
}
|
|
52
|
+
}>, "strip", z.ZodTypeAny, {
|
|
37
53
|
username: string;
|
|
38
54
|
tenantid: string;
|
|
39
55
|
useremail: string;
|
|
40
|
-
userid
|
|
56
|
+
userid?: string | undefined;
|
|
41
57
|
}, {
|
|
42
58
|
username: string;
|
|
43
59
|
tenantid: string;
|
|
44
60
|
useremail: string;
|
|
45
|
-
userid
|
|
46
|
-
}
|
|
61
|
+
userid?: string | undefined;
|
|
62
|
+
}>;
|
|
63
|
+
export declare const appSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
47
64
|
"app-name": z.ZodString;
|
|
48
65
|
"app-id": z.ZodString;
|
|
66
|
+
}, {
|
|
49
67
|
tenantid: z.ZodString;
|
|
68
|
+
}>, "strip", z.ZodTypeAny, {
|
|
69
|
+
"app-id": string;
|
|
70
|
+
"app-name": string;
|
|
71
|
+
tenantid: string;
|
|
72
|
+
}, {
|
|
73
|
+
"app-id": string;
|
|
74
|
+
"app-name": string;
|
|
75
|
+
tenantid: string;
|
|
76
|
+
}>;
|
|
77
|
+
export declare const traceSchema: z.ZodObject<{
|
|
78
|
+
"x-trace-id": z.ZodDefault<z.ZodString>;
|
|
50
79
|
}, "strip", z.ZodTypeAny, {
|
|
80
|
+
"x-trace-id": string;
|
|
81
|
+
}, {
|
|
82
|
+
"x-trace-id"?: string | undefined;
|
|
83
|
+
}>;
|
|
84
|
+
export declare const integrationHeaders: z.ZodObject<z.objectUtil.extendShape<{
|
|
85
|
+
tenantid: z.ZodString;
|
|
86
|
+
}, {
|
|
87
|
+
"x-trace-id": z.ZodDefault<z.ZodString>;
|
|
88
|
+
}>, "strip", z.ZodTypeAny, {
|
|
89
|
+
tenantid: string;
|
|
90
|
+
"x-trace-id": string;
|
|
91
|
+
}, {
|
|
92
|
+
tenantid: string;
|
|
93
|
+
"x-trace-id"?: string | undefined;
|
|
94
|
+
}>;
|
|
95
|
+
export declare const authorizerHeaders: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
96
|
+
username: z.ZodString;
|
|
97
|
+
useremail: z.ZodString;
|
|
98
|
+
userid: z.ZodOptional<z.ZodString>;
|
|
99
|
+
}, {
|
|
100
|
+
tenantid: z.ZodString;
|
|
101
|
+
}>, "strip", z.ZodTypeAny, {
|
|
102
|
+
username: string;
|
|
103
|
+
tenantid: string;
|
|
104
|
+
useremail: string;
|
|
105
|
+
userid?: string | undefined;
|
|
106
|
+
}, {
|
|
107
|
+
username: string;
|
|
108
|
+
tenantid: string;
|
|
109
|
+
useremail: string;
|
|
110
|
+
userid?: string | undefined;
|
|
111
|
+
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
112
|
+
"app-name": z.ZodString;
|
|
113
|
+
"app-id": z.ZodString;
|
|
114
|
+
}, {
|
|
115
|
+
tenantid: z.ZodString;
|
|
116
|
+
}>, "strip", z.ZodTypeAny, {
|
|
51
117
|
"app-id": string;
|
|
52
118
|
"app-name": string;
|
|
53
119
|
tenantid: string;
|
|
@@ -56,30 +122,32 @@ export declare const authorizerHeaders: z.ZodUnion<[z.ZodObject<{
|
|
|
56
122
|
"app-name": string;
|
|
57
123
|
tenantid: string;
|
|
58
124
|
}>]>;
|
|
59
|
-
export declare const authorizerHeadersWithFiscalIds: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<{
|
|
125
|
+
export declare const authorizerHeadersWithFiscalIds: z.ZodUnion<[z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
60
126
|
username: z.ZodString;
|
|
61
127
|
useremail: z.ZodString;
|
|
62
|
-
userid: z.ZodString
|
|
63
|
-
tenantid: z.ZodString;
|
|
128
|
+
userid: z.ZodOptional<z.ZodString>;
|
|
64
129
|
}, {
|
|
130
|
+
tenantid: z.ZodString;
|
|
131
|
+
}>, {
|
|
65
132
|
fiscalidsfromtenant: z.ZodString;
|
|
66
133
|
}>, "strip", z.ZodTypeAny, {
|
|
67
134
|
fiscalidsfromtenant: string;
|
|
68
135
|
username: string;
|
|
69
136
|
tenantid: string;
|
|
70
137
|
useremail: string;
|
|
71
|
-
userid
|
|
138
|
+
userid?: string | undefined;
|
|
72
139
|
}, {
|
|
73
140
|
fiscalidsfromtenant: string;
|
|
74
141
|
username: string;
|
|
75
142
|
tenantid: string;
|
|
76
143
|
useremail: string;
|
|
77
|
-
userid
|
|
78
|
-
}>, z.ZodObject<z.objectUtil.extendShape<{
|
|
144
|
+
userid?: string | undefined;
|
|
145
|
+
}>, z.ZodObject<z.objectUtil.extendShape<z.objectUtil.extendShape<{
|
|
79
146
|
"app-name": z.ZodString;
|
|
80
147
|
"app-id": z.ZodString;
|
|
81
|
-
tenantid: z.ZodString;
|
|
82
148
|
}, {
|
|
149
|
+
tenantid: z.ZodString;
|
|
150
|
+
}>, {
|
|
83
151
|
fiscalidsfromtenant: z.ZodString;
|
|
84
152
|
}>, "strip", z.ZodTypeAny, {
|
|
85
153
|
fiscalidsfromtenant: string;
|
|
@@ -92,6 +160,10 @@ export declare const authorizerHeadersWithFiscalIds: z.ZodUnion<[z.ZodObject<z.o
|
|
|
92
160
|
"app-name": string;
|
|
93
161
|
tenantid: string;
|
|
94
162
|
}>]>;
|
|
163
|
+
/**
|
|
164
|
+
*
|
|
165
|
+
* @deprecated Use authorizerHeadersWithFiscalIds.
|
|
166
|
+
*/
|
|
95
167
|
export declare const headersDefaultWithFiscalIds: z.ZodObject<{
|
|
96
168
|
tenantid: z.ZodString;
|
|
97
169
|
username: z.ZodString;
|
|
@@ -1,28 +1,49 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.headersDefaultWithFiscalIds = exports.authorizerHeadersWithFiscalIds = exports.authorizerHeaders = exports.headersDefaultWithUserId = exports.headersDefault = void 0;
|
|
3
|
+
exports.headersDefaultWithFiscalIds = exports.authorizerHeadersWithFiscalIds = exports.authorizerHeaders = exports.integrationHeaders = exports.traceSchema = exports.appSchema = exports.userSchema = exports.tenantIdSchema = exports.headersDefaultWithUserId = exports.headersDefault = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
4
5
|
const zod_1 = require("zod");
|
|
6
|
+
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Use authorizerHeaders.
|
|
10
|
+
*/
|
|
5
11
|
exports.headersDefault = zod_1.z.object({
|
|
6
12
|
tenantid: zod_1.z.string().uuid(),
|
|
7
13
|
username: zod_1.z.string(),
|
|
8
14
|
useremail: zod_1.z.string(),
|
|
9
15
|
});
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @deprecated Use authorizerHeaders.
|
|
19
|
+
*/
|
|
10
20
|
exports.headersDefaultWithUserId = zod_1.z.object({
|
|
11
21
|
tenantid: zod_1.z.string().uuid(),
|
|
12
22
|
username: zod_1.z.string(),
|
|
13
23
|
useremail: zod_1.z.string(),
|
|
14
24
|
userid: zod_1.z.string().uuid(),
|
|
15
25
|
});
|
|
16
|
-
|
|
17
|
-
username: zod_1.z.string(),
|
|
18
|
-
useremail: zod_1.z.string().email(),
|
|
19
|
-
userid: zod_1.z.string().uuid(),
|
|
26
|
+
exports.tenantIdSchema = zod_1.z.object({
|
|
20
27
|
tenantid: zod_1.z.string().uuid(),
|
|
21
28
|
});
|
|
22
|
-
|
|
29
|
+
exports.userSchema = zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
username: zod_1.z.string(),
|
|
32
|
+
useremail: zod_1.z.string().email(),
|
|
33
|
+
userid: zod_1.z.string().uuid().optional(),
|
|
34
|
+
})
|
|
35
|
+
.merge(exports.tenantIdSchema);
|
|
36
|
+
exports.appSchema = zod_1.z
|
|
37
|
+
.object({
|
|
23
38
|
['app-name']: zod_1.z.string(),
|
|
24
39
|
['app-id']: zod_1.z.string().uuid(),
|
|
25
|
-
|
|
40
|
+
})
|
|
41
|
+
.merge(exports.tenantIdSchema);
|
|
42
|
+
exports.traceSchema = zod_1.z.object({
|
|
43
|
+
['x-trace-id']: zod_1.z
|
|
44
|
+
.string()
|
|
45
|
+
.uuid()
|
|
46
|
+
.default(() => crypto_1.default.randomUUID()),
|
|
26
47
|
});
|
|
27
48
|
const fiscalIdsSchema = zod_1.z.object({
|
|
28
49
|
fiscalidsfromtenant: zod_1.z.string(zod_1.z.array(zod_1.z.object({
|
|
@@ -31,11 +52,16 @@ const fiscalIdsSchema = zod_1.z.object({
|
|
|
31
52
|
countryCode: zod_1.z.string(),
|
|
32
53
|
}))),
|
|
33
54
|
});
|
|
34
|
-
exports.
|
|
55
|
+
exports.integrationHeaders = exports.tenantIdSchema.merge(exports.traceSchema);
|
|
56
|
+
exports.authorizerHeaders = zod_1.z.union([exports.userSchema, exports.appSchema]);
|
|
35
57
|
exports.authorizerHeadersWithFiscalIds = zod_1.z.union([
|
|
36
|
-
userSchema.merge(fiscalIdsSchema),
|
|
37
|
-
appSchema.merge(fiscalIdsSchema),
|
|
58
|
+
exports.userSchema.merge(fiscalIdsSchema),
|
|
59
|
+
exports.appSchema.merge(fiscalIdsSchema),
|
|
38
60
|
]);
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @deprecated Use authorizerHeadersWithFiscalIds.
|
|
64
|
+
*/
|
|
39
65
|
exports.headersDefaultWithFiscalIds = zod_1.z.object({
|
|
40
66
|
tenantid: zod_1.z.string().uuid(),
|
|
41
67
|
username: zod_1.z.string(),
|