passport-google-oauth-token
Advanced tools
Comparing version 1.0.5 to 1.0.6
{ | ||
"name": "passport-google-oauth-token", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Google access token authentication strategy for Passport", | ||
@@ -22,4 +22,12 @@ "author": "Alpha", | ||
}, | ||
"main": "lib/index.js", | ||
"types": "lib/index.d.ts", | ||
"main": "./lib/index.cjs", | ||
"module": "./lib/index.mjs", | ||
"types": "./lib/index.d.ts", | ||
"exports": { | ||
".": { | ||
"import": "./lib/index.mjs", | ||
"require": "./lib/index.cjs", | ||
"types": "./lib/index.d.ts" | ||
} | ||
}, | ||
"dependencies": { | ||
@@ -30,14 +38,12 @@ "passport-oauth2": "^1.7.0" | ||
"@types/express": "^4.17.17", | ||
"@types/jest": "^29.4.0", | ||
"@types/oauth": "^0.9.1", | ||
"@types/passport-oauth2": "^1.4.12", | ||
"jest": "^29.5.0", | ||
"oauth": "^0.10.0", | ||
"ts-jest": "^29.0.5" | ||
"vitest": "^0.29.8" | ||
}, | ||
"scripts": { | ||
"prepublish": "rm -rf lib && tsc", | ||
"test": "jest --config jest.config.json", | ||
"update-packages": "pnpm update -i -r --latest" | ||
"prepublish": "pnpm build", | ||
"build": "rollup --config rollup.config.ts --configPlugin typescript", | ||
"test": "vitest run --passWithNoTests" | ||
} | ||
} |
@@ -0,1 +1,3 @@ | ||
import { describe, it, expect, vi } from 'vitest'; | ||
import userinfo from './fixtures/userinfo.json'; | ||
@@ -138,14 +140,14 @@ import GoogleOauthTokenStrategy from '../Strategy'; | ||
describe('GoogleOauthTokenStrategy#userProfile', () => { | ||
it('should properly fetch profile', (done) => { | ||
it('should properly fetch profile', ({ onTestFailed }) => { | ||
const strategy = initStrategy(); | ||
jest | ||
.spyOn(strategy.oauth2Instance, 'get') | ||
.mockImplementation((_url, _accessToken, next) => { | ||
vi.spyOn(strategy.oauth2Instance, 'get').mockImplementation( | ||
(_url, _accessToken, next) => { | ||
next(null as any, userinfo as any, null as any); | ||
}); | ||
}, | ||
); | ||
strategy.userProfile(defaultAccessToken, (error, profile) => { | ||
if (error) { | ||
return done(error); | ||
return onTestFailed(error); | ||
} | ||
@@ -163,16 +165,14 @@ | ||
jest.clearAllMocks(); | ||
done(); | ||
vi.clearAllMocks(); | ||
}); | ||
}); | ||
it('should properly handle exception on fetching profile', (done) => { | ||
it('should properly handle exception on fetching profile', () => { | ||
const strategy = initStrategy(); | ||
jest | ||
.spyOn(strategy.oauth2Instance, 'get') | ||
.mockImplementation((_url, _accessToken, next) => { | ||
vi.spyOn(strategy.oauth2Instance, 'get').mockImplementation( | ||
(_url, _accessToken, next) => { | ||
next(null as any, 'not a JSON'); | ||
}); | ||
}, | ||
); | ||
@@ -183,14 +183,11 @@ strategy.userProfile(defaultAccessToken, (error, profile) => { | ||
jest.clearAllMocks(); | ||
done(); | ||
vi.clearAllMocks(); | ||
}); | ||
}); | ||
it('should properly throw error on _oauth2.get error', (done) => { | ||
it('should properly throw error on _oauth2.get error', () => { | ||
const strategy = initStrategy(); | ||
jest | ||
.spyOn(strategy.oauth2Instance, 'get') | ||
.mockImplementation((_url, _accessToken, next) => { | ||
vi.spyOn(strategy.oauth2Instance, 'get').mockImplementation( | ||
(_url, _accessToken, next) => { | ||
next({ | ||
@@ -200,3 +197,4 @@ statusCode: 401, | ||
}); | ||
}); | ||
}, | ||
); | ||
@@ -206,7 +204,5 @@ strategy.userProfile(defaultAccessToken, (error, _profile) => { | ||
jest.clearAllMocks(); | ||
done(); | ||
vi.clearAllMocks(); | ||
}); | ||
}); | ||
}); |
/* eslint-disable @typescript-eslint/naming-convention */ | ||
import OAuth2Strategy from 'passport-oauth2'; | ||
import { InternalOAuthError } from 'passport-oauth2'; | ||
import { | ||
InternalOAuthError, | ||
type VerifyFunctionWithRequest as POVerifyFunctionWithRequest, | ||
} from 'passport-oauth2'; | ||
import type { OAuth2 } from 'oauth'; | ||
import type { Request } from 'express'; | ||
import type { VerifyFunctionWithRequest as POVerifyFunctionWithRequest } from 'passport-oauth2'; | ||
@@ -10,0 +12,0 @@ import type { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
35575
5
884
0