@develit-io/backend-sdk 9.5.1 → 9.6.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.d.mts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/middlewares.mjs +19 -21
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/middlewares.mjs
CHANGED
|
@@ -120,7 +120,13 @@ const jwt = () => {
|
|
|
120
120
|
message: "User data integrity check failed."
|
|
121
121
|
});
|
|
122
122
|
}
|
|
123
|
-
context.set("identity",
|
|
123
|
+
context.set("identity", {
|
|
124
|
+
user: {
|
|
125
|
+
...data.payload.user,
|
|
126
|
+
organizationId: rawUserMetaData.organizationId,
|
|
127
|
+
exchangeOfficeId: rawUserMetaData.exchangeOfficeId
|
|
128
|
+
}
|
|
129
|
+
});
|
|
124
130
|
}
|
|
125
131
|
await next();
|
|
126
132
|
});
|
|
@@ -131,9 +137,7 @@ const ip = () => {
|
|
|
131
137
|
if (!context.env.MIDDLEWARE_IP_DISABLED) {
|
|
132
138
|
const requestIp = getRequestIpAddress(context.req);
|
|
133
139
|
const identityContext = context.get("identity");
|
|
134
|
-
const
|
|
135
|
-
const rawUserMetaData = rawUserMetaDataString ? JSON.parse(rawUserMetaDataString) : null;
|
|
136
|
-
const organizationId = rawUserMetaData.organizationId;
|
|
140
|
+
const organizationId = identityContext.user.organizationId;
|
|
137
141
|
if (!organizationId) {
|
|
138
142
|
throw new HTTPException(401, {
|
|
139
143
|
message: "Failed to retrieve request organization ID."
|
|
@@ -186,8 +190,8 @@ const logger = () => {
|
|
|
186
190
|
logRequest(requestLog);
|
|
187
191
|
if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
|
|
188
192
|
const identityContext = context.get("identity");
|
|
189
|
-
const
|
|
190
|
-
const
|
|
193
|
+
const organizationId = identityContext.user.organizationId;
|
|
194
|
+
const exchangeOfficeId = identityContext.user.exchangeOfficeId;
|
|
191
195
|
const requestId = uuidv4();
|
|
192
196
|
context.set("auditLog", {
|
|
193
197
|
requestId
|
|
@@ -198,11 +202,8 @@ const logger = () => {
|
|
|
198
202
|
path: requestLog.path,
|
|
199
203
|
actor: {
|
|
200
204
|
email: identityContext?.user?.email || "NOT_AUTHORIZED",
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
} : rawUserMetaData?.exchangeOfficeId ? {
|
|
204
|
-
exchangeOfficeId: rawUserMetaData?.exchangeOfficeId || "NOT_AUTHORIZED"
|
|
205
|
-
} : null
|
|
205
|
+
organizationId: organizationId || "NOT_AUTHORIZED",
|
|
206
|
+
exchangeOficeId: exchangeOfficeId || "NOT_AUTHORIZED"
|
|
206
207
|
},
|
|
207
208
|
metadata: {
|
|
208
209
|
ip: getRequestIpAddress(context.req),
|
|
@@ -224,8 +225,8 @@ const logger = () => {
|
|
|
224
225
|
logResponse(responseLog);
|
|
225
226
|
if (!context.env.MIDDLEWARE_LOGGER_AUDITLOG_DISABLED) {
|
|
226
227
|
const identityContext = context.get("identity");
|
|
227
|
-
const
|
|
228
|
-
const
|
|
228
|
+
const organizationId = identityContext.user.organizationId;
|
|
229
|
+
const exchangeOfficeId = identityContext.user.exchangeOfficeId;
|
|
229
230
|
const auditLogContext = context.get("auditLog");
|
|
230
231
|
await context.env.ACTIVITY_SERVICE.processAuditLog({
|
|
231
232
|
type: "RESPONSE",
|
|
@@ -233,11 +234,8 @@ const logger = () => {
|
|
|
233
234
|
path: responseLog.path,
|
|
234
235
|
actor: {
|
|
235
236
|
email: identityContext?.user?.email || "NOT_AUTHORIZED",
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
} : rawUserMetaData?.exchangeOfficeId ? {
|
|
239
|
-
exchangeOfficeId: rawUserMetaData?.exchangeOfficeId || "NOT_AUTHORIZED"
|
|
240
|
-
} : null
|
|
237
|
+
organizationId: organizationId || "NOT_AUTHORIZED",
|
|
238
|
+
exchangeOficeId: exchangeOfficeId || "NOT_AUTHORIZED"
|
|
241
239
|
},
|
|
242
240
|
metadata: {
|
|
243
241
|
ip: getRequestIpAddress(context.req),
|
|
@@ -268,9 +266,9 @@ const signature = () => {
|
|
|
268
266
|
}
|
|
269
267
|
const payload = JSON.stringify(await context.req.json().catch(() => null));
|
|
270
268
|
const identityContext = context.get("identity");
|
|
271
|
-
const
|
|
272
|
-
const
|
|
273
|
-
const identityId =
|
|
269
|
+
const organizationId = identityContext.user.organizationId;
|
|
270
|
+
const exchangeOfficeId = identityContext.user.exchangeOfficeId;
|
|
271
|
+
const identityId = organizationId ?? exchangeOfficeId;
|
|
274
272
|
if (!identityId) {
|
|
275
273
|
throw new HTTPException(401, {
|
|
276
274
|
message: "Failed to retrieve request identity ID."
|