@iamnnort/nestjs-serializer 2.2.6 → 2.2.9

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.mjs CHANGED
@@ -9205,7 +9205,7 @@ SerializerService = _ts_decorate([
9205
9205
  ], SerializerService);
9206
9206
 
9207
9207
  // src/interceptor.ts
9208
- import { intersection } from "lodash";
9208
+ import { intersection, uniq as uniq2 } from "lodash";
9209
9209
  function _ts_decorate2(decorators, target, key, desc) {
9210
9210
  var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
9211
9211
  if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
@@ -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 || config.scopes;
9247
+ return config.limitedScopes || this.serializerService.config.globalLimitedScopes || scopes;
9247
9248
  }
9249
+ if (request.query.scopes && config.allowedScopes) {
9250
+ return intersection(request.query.scopes, config.allowedScopes);
9251
+ }
9252
+ return this.withSecretScopes(ctx, this.withExtendedScopes(ctx, scopes));
9253
+ }
9254
+ withExtendedScopes(ctx, scopes) {
9255
+ const request = ctx.switchToHttp().getRequest();
9248
9256
  if (request.query.extended === "true") {
9249
- return config.extendedScopes || config.scopes;
9257
+ const extendedScopes = config.extendedScopes || [];
9258
+ return uniq2([
9259
+ ...scopes,
9260
+ ...extendedScopes
9261
+ ]);
9250
9262
  }
9263
+ return scopes;
9264
+ }
9265
+ withSecretScopes(ctx, scopes) {
9266
+ const request = ctx.switchToHttp().getRequest();
9251
9267
  if (request.query.secret === "true") {
9252
- return config.secretScopes || this.serializerService.config.globalSecretScopes || config.scopes;
9253
- }
9254
- if (request.query.scopes && config.allowedScopes) {
9255
- return intersection(request.query.scopes, config.allowedScopes);
9268
+ const secretScopes = config.secretScopes || this.serializerService.config.globalSecretScopes || [];
9269
+ return uniq2([
9270
+ ...scopes,
9271
+ ...secretScopes
9272
+ ]);
9256
9273
  }
9257
- return config.scopes;
9274
+ return scopes;
9258
9275
  }
9259
9276
  };
9260
9277
  SerializerInterceptor2 = _ts_decorate2([