@iamnnort/nestjs-serializer 2.2.6 → 2.2.8
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 +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +25 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +26 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -62,14 +62,18 @@ declare const SerializerInterceptor: (config: {
|
|
|
62
62
|
new (serializerService: SerializerService): {
|
|
63
63
|
serializerService: SerializerService;
|
|
64
64
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
65
|
-
getScopes(ctx: ExecutionContext): string[]
|
|
65
|
+
getScopes(ctx: ExecutionContext): string[];
|
|
66
|
+
withQueryScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
67
|
+
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
66
68
|
};
|
|
67
69
|
};
|
|
68
70
|
declare const SerializerIdInterceptor_base: {
|
|
69
71
|
new (serializerService: SerializerService): {
|
|
70
72
|
serializerService: SerializerService;
|
|
71
73
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
72
|
-
getScopes(ctx: ExecutionContext): string[]
|
|
74
|
+
getScopes(ctx: ExecutionContext): string[];
|
|
75
|
+
withQueryScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
76
|
+
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
73
77
|
};
|
|
74
78
|
};
|
|
75
79
|
declare class SerializerIdInterceptor extends SerializerIdInterceptor_base {
|
package/dist/index.d.ts
CHANGED
|
@@ -62,14 +62,18 @@ declare const SerializerInterceptor: (config: {
|
|
|
62
62
|
new (serializerService: SerializerService): {
|
|
63
63
|
serializerService: SerializerService;
|
|
64
64
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
65
|
-
getScopes(ctx: ExecutionContext): string[]
|
|
65
|
+
getScopes(ctx: ExecutionContext): string[];
|
|
66
|
+
withQueryScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
67
|
+
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
66
68
|
};
|
|
67
69
|
};
|
|
68
70
|
declare const SerializerIdInterceptor_base: {
|
|
69
71
|
new (serializerService: SerializerService): {
|
|
70
72
|
serializerService: SerializerService;
|
|
71
73
|
intercept(ctx: ExecutionContext, next: CallHandler<Promise<any>>): rxjs.Observable<Promise<any>>;
|
|
72
|
-
getScopes(ctx: ExecutionContext): string[]
|
|
74
|
+
getScopes(ctx: ExecutionContext): string[];
|
|
75
|
+
withQueryScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
76
|
+
withSecretScopes(ctx: ExecutionContext, scopes: string[]): string[];
|
|
73
77
|
};
|
|
74
78
|
};
|
|
75
79
|
declare class SerializerIdInterceptor extends SerializerIdInterceptor_base {
|
package/dist/index.js
CHANGED
|
@@ -9228,7 +9228,7 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
|
|
|
9228
9228
|
}
|
|
9229
9229
|
intercept(ctx, next) {
|
|
9230
9230
|
const request = ctx.switchToHttp().getRequest();
|
|
9231
|
-
request.scopes = this.getScopes(ctx);
|
|
9231
|
+
request.scopes = this.withQueryScopes(ctx, this.withSecretScopes(ctx, this.getScopes(ctx)));
|
|
9232
9232
|
return next.handle().pipe((0, import_operators.map)(async (responsePromise) => {
|
|
9233
9233
|
const response = await responsePromise;
|
|
9234
9234
|
if (!request.scopes && !config.fields) {
|
|
@@ -9242,19 +9242,36 @@ var SerializerInterceptor = /* @__PURE__ */ __name((config) => {
|
|
|
9242
9242
|
}
|
|
9243
9243
|
getScopes(ctx) {
|
|
9244
9244
|
const request = ctx.switchToHttp().getRequest();
|
|
9245
|
+
const scopes = config.scopes || [];
|
|
9245
9246
|
if (request.query.limited === "true") {
|
|
9246
|
-
return config.limitedScopes || this.serializerService.config.globalLimitedScopes ||
|
|
9247
|
+
return config.limitedScopes || this.serializerService.config.globalLimitedScopes || scopes;
|
|
9247
9248
|
}
|
|
9248
9249
|
if (request.query.extended === "true") {
|
|
9249
|
-
return config.extendedScopes ||
|
|
9250
|
-
}
|
|
9251
|
-
if (request.query.secret === "true") {
|
|
9252
|
-
return config.secretScopes || this.serializerService.config.globalSecretScopes || config.scopes;
|
|
9250
|
+
return config.extendedScopes || scopes;
|
|
9253
9251
|
}
|
|
9252
|
+
return scopes;
|
|
9253
|
+
}
|
|
9254
|
+
withQueryScopes(ctx, scopes) {
|
|
9255
|
+
const request = ctx.switchToHttp().getRequest();
|
|
9254
9256
|
if (request.query.scopes && config.allowedScopes) {
|
|
9255
|
-
|
|
9257
|
+
const queryScopes = _lodash.intersection.call(void 0, request.query.scopes, config.allowedScopes);
|
|
9258
|
+
return _lodash.uniq.call(void 0, [
|
|
9259
|
+
...scopes,
|
|
9260
|
+
...queryScopes
|
|
9261
|
+
]);
|
|
9262
|
+
}
|
|
9263
|
+
return scopes;
|
|
9264
|
+
}
|
|
9265
|
+
withSecretScopes(ctx, scopes) {
|
|
9266
|
+
const request = ctx.switchToHttp().getRequest();
|
|
9267
|
+
if (request.query.secret === "true") {
|
|
9268
|
+
const secretScopes = config.secretScopes || this.serializerService.config.globalSecretScopes || [];
|
|
9269
|
+
return _lodash.uniq.call(void 0, [
|
|
9270
|
+
...scopes,
|
|
9271
|
+
...secretScopes
|
|
9272
|
+
]);
|
|
9256
9273
|
}
|
|
9257
|
-
return
|
|
9274
|
+
return scopes;
|
|
9258
9275
|
}
|
|
9259
9276
|
};
|
|
9260
9277
|
SerializerInterceptor2 = _ts_decorate2([
|