Skip to content

Commit

Permalink
Merge pull request #1320 from nestjs/10.0.0
Browse files Browse the repository at this point in the history
chore: laying the grounds for v10.0.0
  • Loading branch information
kamilmysliwiec committed Jun 15, 2023
2 parents 6d30ded + e0e5661 commit 7a947a1
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 17 deletions.
13 changes: 6 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ version: 2
aliases:
- &restore-cache
restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
key: dependency-cache-{{ checksum "package.json" }}
- &install-deps
run:
name: Install dependencies
command: npm ci
name: Install dependencies
command: npm ci --ignore-scripts
- &build-packages
run:
name: Build
command: npm run build
name: Build
command: npm run build

jobs:
build:
Expand All @@ -27,7 +27,7 @@ jobs:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: Install dependencies
command: npm ci
command: npm ci --ignore-scripts
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
Expand All @@ -44,4 +44,3 @@ workflows:
build-and-test:
jobs:
- build

6 changes: 4 additions & 2 deletions lib/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ export type IAuthGuard = CanActivate & {
getAuthenticateOptions(
context: ExecutionContext
): IAuthModuleOptions | undefined;
getRequest<T = any>(context: ExecutionContext): T;
};

export const AuthGuard: (type?: string | string[]) => Type<IAuthGuard> =
memoize(createAuthGuard);

const NO_STRATEGY_ERROR = `In order to use "defaultStrategy", please, ensure to import PassportModule in each place where AuthGuard() is being used. Otherwise, passport won't work correctly.`;
const authLogger = new Logger('AuthGuard');

function createAuthGuard(type?: string | string[]): Type<CanActivate> {
function createAuthGuard(type?: string | string[]): Type<IAuthGuard> {
class MixinAuthGuard<TUser = any> implements CanActivate {
@Optional()
@Inject(AuthModuleOptions)
Expand Down Expand Up @@ -103,7 +105,7 @@ function createAuthGuard(type?: string | string[]): Type<CanActivate> {
}
}
const guard = mixin(MixinAuthGuard);
return guard;
return guard as Type<IAuthGuard>;
}

const createPassportContext =
Expand Down
13 changes: 7 additions & 6 deletions lib/passport/passport.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import { Type } from '../interfaces';

export function PassportStrategy<T extends Type<any> = any>(
Strategy: T,
name?: string | undefined
name?: string | undefined,
callbackArity?: true | number
): {
new (...args): InstanceType<T>;
} {
Expand All @@ -24,17 +25,17 @@ export function PassportStrategy<T extends Type<any> = any>(
done(err, null);
}
};
/**
* Commented out due to the regression it introduced
* Read more here: https://github.com/nestjs/passport/issues/446

if (callbackArity !== undefined) {
const validate = new.target?.prototype?.validate;
const arity =
callbackArity === true ? validate.length + 1 : callbackArity;
if (validate) {
Object.defineProperty(callback, 'length', {
value: validate.length + 1
value: arity
});
}
*/
}
super(...args, callback);

const passportInstance = this.getPassportInstance();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"index.d.ts"
],
"peerDependencies": {
"@nestjs/common": "^8.0.0 || ^9.0.0",
"@nestjs/common": "^8.0.0 || ^9.0.0 || ^10.0.0",
"passport": "^0.4.0 || ^0.5.0 || ^0.6.0"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"noLib": false,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es6",
"target": "ES2021",
"sourceMap": false,
"outDir": "./dist",
"rootDir": "./lib",
Expand Down

0 comments on commit 7a947a1

Please sign in to comment.