@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.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[] | undefined;
65
+ getScopes(ctx: ExecutionContext): string[];
66
+ withExtendedScopes(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[] | undefined;
74
+ getScopes(ctx: ExecutionContext): string[];
75
+ withExtendedScopes(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[] | undefined;
65
+ getScopes(ctx: ExecutionContext): string[];
66
+ withExtendedScopes(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[] | undefined;
74
+ getScopes(ctx: ExecutionContext): string[];
75
+ withExtendedScopes(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
@@ -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 _lodash.intersection.call(void 0, 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 _lodash.uniq.call(void 0, [
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 _lodash.intersection.call(void 0, request.query.scopes, config.allowedScopes);
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 config.scopes;
9274
+ return scopes;
9258
9275
  }
9259
9276
  };
9260
9277
  SerializerInterceptor2 = _ts_decorate2([