Gathering detailed insights and metrics for @gapi/auth
Gathering detailed insights and metrics for @gapi/auth
Gathering detailed insights and metrics for @gapi/auth
Gathering detailed insights and metrics for @gapi/auth
gapi-script
package to load gapi script and some functions
@gapi/playground
##### For questions/issues you can write ticket [here](http://gitlab.youvolio.com/Stradivario/gapi-auth/issues) ##### This module is intended to be used with [rxdi](https://github.com/rxdi/core) or [gapi](https://github.com/Stradivario/gapi)
@types/gapi.auth2
TypeScript definitions for gapi.auth2
jnx-gapi-auth
npm install @gapi/auth
Typescript
Module System
Node Version
NPM Version
69.3
Supply Chain
97.8
Quality
74.5
Maintenance
50
Vulnerability
98.6
License
JavaScript (61.09%)
TypeScript (38.91%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
399 Commits
1 Watchers
3 Branches
1 Contributors
Updated on Jan 31, 2020
Latest Version
1.8.151
Package Id
@gapi/auth@1.8.151
Unpacked Size
13.78 kB
Size
4.16 kB
File Count
13
NPM Version
6.14.18
Node Version
14.21.3
Published on
Jun 18, 2024
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
2
3
1$ npm install @gapi/auth --save
1import { Module } from "@rxdi/core"; 2import { AuthModule } from "@gapi/auth"; 3 4@Module({ 5 imports: [ 6 AuthModule.forRoot({ 7 algorithm: 'HS256', 8 cert: 'dadada', 9 cyper: { 10 algorithm: 'dada', 11 iv: '', 12 privateKey: 'dadada' 13 } 14 }), 15 ] 16}) 17export class CoreModule {}
1 2import { Service } from '@rxdi/core'; 3import * as Boom from 'boom'; 4import { AuthInterface, AuthInternalService, TokenData } from '@gapi/auth'; 5 6export interface UserInfo { 7 scope: ['ADMIN', 'USER']; 8 type: 'ADMIN' | 'USER'; 9 iat: number; 10} 11 12@Service() 13export class AuthService implements AuthInterface { 14 15 constructor( 16 private authService: AuthInternalService 17 ) { } 18 19 onSubOperation(message, params, webSocket) { 20 return params; 21 } 22 23 onSubConnection(connectionParams): TokenData { 24 if (connectionParams.token) { 25 return this.validateToken(connectionParams.token, 'Subscription'); 26 } else { 27 throw Boom.unauthorized(); 28 } 29 } 30 31 validateToken(token: string, requestType: 'Query' | 'Subscription' = 'Query'): any { 32 const user = <any>this.authService.verifyToken(token); 33 user.type = user.scope[0]; 34 console.log(`${requestType} from: ${JSON.stringify(user)}`); 35 if (user) { 36 return user; 37 } else { 38 throw Boom.unauthorized(); 39 } 40 } 41 42 signJWTtoken(tokenData: TokenData): string { 43 return this.authService.sign(tokenData); 44 } 45 46 issueJWTToken(tokenData: TokenData) { 47 const jwtToken = this.authService.sign({ 48 email: '', 49 id: 1, 50 scope: ['ADMIN', 'USER'] 51 }); 52 return jwtToken; 53 } 54 55 verifyToken(token: string): TokenData { 56 return this.authService.verifyToken(token); 57 } 58 59 decryptPassword(password: string): string { 60 return this.authService.decrypt(password); 61 } 62 63 encryptPassword(password: string): string { 64 return this.authService.encrypt(password); 65 } 66 67} 68
authentication
parameter inside CoreModule.forRoot1 2import { CoreModule, Module } from '@gapi/core'; 3import { AuthService } from './app/core/services/auth/auth.service'; 4import { AuthModule } from '@gapi/auth'; 5import { readFileSync } from 'fs'; 6 7@Module({ 8 imports: [ 9 AuthModule.forRoot({ 10 algorithm: 'HS256', 11 cert: readFileSync('./cert.key'), 12 cyper: { 13 algorithm: 'aes256', 14 iv: 'Jkyt1H3FA8JK9L3B', 15 privateKey: '8zTVzr3p53VC12jHV54rIYu2545x47lA' 16 } 17 }), 18 CoreModule.forRoot({ 19 pubsub: { 20 authentication: AuthService 21 }, 22 graphql: { 23 authentication: AuthService 24 }, 25 }), 26 27 ] 28}) 29export class FrameworkImports {} 30
Then Subscriptions, Mutations and Queries will be secured via single authentication method validateToken
inside AuthService
!
TODO: Better documentation...
Enjoy ! :)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
7 existing vulnerabilities detected
Details
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
license file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Score
Last Scanned on 2025-07-14
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More