@bernierllc/google-drive-oauth 0.2.0
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/LICENSE +7 -0
- package/README.md +168 -0
- package/dist/GoogleDriveOAuth.d.ts +83 -0
- package/dist/GoogleDriveOAuth.d.ts.map +1 -0
- package/dist/GoogleDriveOAuth.js +225 -0
- package/dist/GoogleDriveOAuth.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright (c) 2025 Bernier LLC
|
|
2
|
+
|
|
3
|
+
This file is licensed to the client under a limited-use license.
|
|
4
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
5
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
6
|
+
|
|
7
|
+
|
package/README.md
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# @bernierllc/google-drive-oauth
|
|
2
|
+
|
|
3
|
+
OAuth 2.0 authentication and token management for Google Drive.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- OAuth 2.0 authorization URL generation
|
|
8
|
+
- Authorization code exchange for access tokens
|
|
9
|
+
- Automatic token refresh with refresh tokens
|
|
10
|
+
- Token validation and expiration checking
|
|
11
|
+
- Secure credential storage interfaces
|
|
12
|
+
- Multi-user token management
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @bernierllc/google-drive-oauth
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### Basic Authentication Flow
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { GoogleDriveOAuth } from '@bernierllc/google-drive-oauth';
|
|
26
|
+
|
|
27
|
+
// Create auth instance
|
|
28
|
+
const driveAuth = new GoogleDriveOAuth({
|
|
29
|
+
clientId: 'your-client-id',
|
|
30
|
+
clientSecret: 'your-client-secret',
|
|
31
|
+
redirectUri: 'https://your-app.com/oauth/google-drive/callback'
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
// Step 1: Generate authorization URL
|
|
35
|
+
const { url, state } = driveAuth.getAuthorizationUrl();
|
|
36
|
+
// Store state in session for CSRF protection
|
|
37
|
+
// Redirect user to url
|
|
38
|
+
|
|
39
|
+
// Step 2: Exchange authorization code for tokens
|
|
40
|
+
const tokens = await driveAuth.exchangeCodeForTokens(code, state);
|
|
41
|
+
console.log('Access token:', tokens.accessToken);
|
|
42
|
+
console.log('Refresh token:', tokens.refreshToken);
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Token Refresh
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
// Manually refresh token
|
|
49
|
+
const newTokens = await driveAuth.refreshAccessToken(refreshToken);
|
|
50
|
+
|
|
51
|
+
// Or use automatic refresh with storage
|
|
52
|
+
const storage: TokenStorage = {
|
|
53
|
+
async store(key, tokens) {
|
|
54
|
+
// Store tokens in your database
|
|
55
|
+
await db.saveTokens(key, tokens);
|
|
56
|
+
},
|
|
57
|
+
async retrieve(key) {
|
|
58
|
+
// Retrieve tokens from your database
|
|
59
|
+
return await db.getTokens(key);
|
|
60
|
+
},
|
|
61
|
+
async delete(key) {
|
|
62
|
+
// Delete tokens from your database
|
|
63
|
+
await db.deleteTokens(key);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const authWithStorage = new GoogleDriveOAuth(config, storage);
|
|
68
|
+
|
|
69
|
+
// Automatically refreshes if token is expired
|
|
70
|
+
const validToken = await authWithStorage.getValidToken('user-123');
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Token Validation
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
const isValid = await driveAuth.validateToken(accessToken);
|
|
77
|
+
if (!isValid) {
|
|
78
|
+
console.log('Token is invalid or expired');
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## API
|
|
83
|
+
|
|
84
|
+
### `GoogleDriveOAuth`
|
|
85
|
+
|
|
86
|
+
#### Constructor
|
|
87
|
+
|
|
88
|
+
```typescript
|
|
89
|
+
constructor(config: GoogleDriveOAuthConfig, storage?: TokenStorage)
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
- `config.clientId` - Google OAuth client ID
|
|
93
|
+
- `config.clientSecret` - Google OAuth client secret
|
|
94
|
+
- `config.redirectUri` - OAuth redirect URI
|
|
95
|
+
- `config.logger` - (Optional) Custom logger instance
|
|
96
|
+
- `storage` - (Optional) Token storage implementation
|
|
97
|
+
|
|
98
|
+
#### Methods
|
|
99
|
+
|
|
100
|
+
##### `getAuthorizationUrl(state?: string, scopes?: string[]): { url: string; state: string }`
|
|
101
|
+
|
|
102
|
+
Generate OAuth authorization URL.
|
|
103
|
+
|
|
104
|
+
##### `exchangeCodeForTokens(code: string, state: string): Promise<GoogleDriveOAuthTokens>`
|
|
105
|
+
|
|
106
|
+
Exchange authorization code for access and refresh tokens.
|
|
107
|
+
|
|
108
|
+
##### `refreshAccessToken(refreshToken: string): Promise<GoogleDriveOAuthTokens>`
|
|
109
|
+
|
|
110
|
+
Refresh access token using refresh token.
|
|
111
|
+
|
|
112
|
+
##### `validateToken(accessToken: string): Promise<boolean>`
|
|
113
|
+
|
|
114
|
+
Validate access token against Google Drive API.
|
|
115
|
+
|
|
116
|
+
##### `getValidToken(storageKey: string): Promise<string>`
|
|
117
|
+
|
|
118
|
+
Get a valid access token, automatically refreshing if expired (requires storage).
|
|
119
|
+
|
|
120
|
+
##### `storeTokens(key: string, tokens: GoogleDriveOAuthTokens): Promise<void>`
|
|
121
|
+
|
|
122
|
+
Store tokens (requires storage).
|
|
123
|
+
|
|
124
|
+
##### `revokeTokens(storageKey: string): Promise<void>`
|
|
125
|
+
|
|
126
|
+
Revoke and delete tokens (requires storage).
|
|
127
|
+
|
|
128
|
+
### `TokenStorage` Interface
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
interface TokenStorage {
|
|
132
|
+
store(key: string, tokens: GoogleDriveOAuthTokens): Promise<void>;
|
|
133
|
+
retrieve(key: string): Promise<GoogleDriveOAuthTokens | null>;
|
|
134
|
+
delete(key: string): Promise<void>;
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
Implement this interface to provide persistent token storage.
|
|
139
|
+
|
|
140
|
+
## Token Expiration
|
|
141
|
+
|
|
142
|
+
Tokens are automatically refreshed when:
|
|
143
|
+
- Less than 5 minutes remaining before expiration
|
|
144
|
+
- `getValidToken()` is called with valid refresh token
|
|
145
|
+
|
|
146
|
+
## Error Handling
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
try {
|
|
150
|
+
const tokens = await driveAuth.exchangeCodeForTokens(code, state);
|
|
151
|
+
} catch (error) {
|
|
152
|
+
console.error('OAuth failed:', error.message);
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
All methods throw descriptive errors on failure.
|
|
157
|
+
|
|
158
|
+
## Integration
|
|
159
|
+
|
|
160
|
+
### Logger Integration
|
|
161
|
+
|
|
162
|
+
This package uses `@bernierllc/logger` for structured logging. The logger is optional and will use a no-op logger if not provided.
|
|
163
|
+
|
|
164
|
+
## License
|
|
165
|
+
|
|
166
|
+
Copyright (c) 2025 Bernier LLC. See LICENSE file for details.
|
|
167
|
+
|
|
168
|
+
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Logger } from "@bernierllc/logger";
|
|
2
|
+
import { GoogleDriveOAuthConfig, GoogleDriveOAuthTokens, TokenStorage } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Extended configuration including logger
|
|
5
|
+
*/
|
|
6
|
+
export interface GoogleDriveOAuthConfigWithLogger extends GoogleDriveOAuthConfig {
|
|
7
|
+
logger?: Logger;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* GoogleDriveOAuth - OAuth 2.0 authentication and token management for Google Drive
|
|
11
|
+
*
|
|
12
|
+
* Handles:
|
|
13
|
+
* - Authorization URL generation
|
|
14
|
+
* - Authorization code exchange
|
|
15
|
+
* - Token refresh
|
|
16
|
+
* - Token validation
|
|
17
|
+
* - Automatic token refresh with storage
|
|
18
|
+
*/
|
|
19
|
+
export declare class GoogleDriveOAuth {
|
|
20
|
+
private config;
|
|
21
|
+
private logger;
|
|
22
|
+
private storage;
|
|
23
|
+
private oauth2Client;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new GoogleDriveOAuth instance
|
|
26
|
+
* @param config - OAuth configuration
|
|
27
|
+
* @param storage - Optional token storage for automatic refresh
|
|
28
|
+
*/
|
|
29
|
+
constructor(config: GoogleDriveOAuthConfigWithLogger, storage?: TokenStorage);
|
|
30
|
+
/**
|
|
31
|
+
* Generate OAuth authorization URL
|
|
32
|
+
* @param state - Optional state parameter for CSRF protection (auto-generated if not provided)
|
|
33
|
+
* @param scopes - Requested Google Drive scopes (default: ['https://www.googleapis.com/auth/drive.file'])
|
|
34
|
+
* @returns Object with authorization URL and state
|
|
35
|
+
*/
|
|
36
|
+
getAuthorizationUrl(state?: string, scopes?: string[]): {
|
|
37
|
+
url: string;
|
|
38
|
+
state: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Exchange authorization code for access and refresh tokens
|
|
42
|
+
* @param code - Authorization code from OAuth callback
|
|
43
|
+
* @param state - State token for CSRF validation
|
|
44
|
+
* @returns OAuth tokens
|
|
45
|
+
* @throws Error if exchange fails
|
|
46
|
+
*/
|
|
47
|
+
exchangeCodeForTokens(code: string, _state: string): Promise<GoogleDriveOAuthTokens>;
|
|
48
|
+
/**
|
|
49
|
+
* Refresh access token using refresh token
|
|
50
|
+
* @param refreshToken - Refresh token
|
|
51
|
+
* @returns New OAuth tokens
|
|
52
|
+
* @throws Error if refresh fails
|
|
53
|
+
*/
|
|
54
|
+
refreshAccessToken(refreshToken: string): Promise<GoogleDriveOAuthTokens>;
|
|
55
|
+
/**
|
|
56
|
+
* Validate access token by making a test request to Google Drive API
|
|
57
|
+
* @param accessToken - Access token to validate
|
|
58
|
+
* @returns True if token is valid, false otherwise
|
|
59
|
+
*/
|
|
60
|
+
validateToken(accessToken: string): Promise<boolean>;
|
|
61
|
+
/**
|
|
62
|
+
* Get a valid access token, automatically refreshing if expired
|
|
63
|
+
* Requires storage to be configured
|
|
64
|
+
* @param storageKey - Key to retrieve tokens from storage
|
|
65
|
+
* @returns Valid access token
|
|
66
|
+
* @throws Error if storage not configured or tokens not found
|
|
67
|
+
*/
|
|
68
|
+
getValidToken(storageKey: string): Promise<string>;
|
|
69
|
+
/**
|
|
70
|
+
* Store tokens using configured storage
|
|
71
|
+
* @param key - Storage key
|
|
72
|
+
* @param tokens - Tokens to store
|
|
73
|
+
* @throws Error if storage not configured
|
|
74
|
+
*/
|
|
75
|
+
storeTokens(key: string, tokens: GoogleDriveOAuthTokens): Promise<void>;
|
|
76
|
+
/**
|
|
77
|
+
* Revoke and delete tokens from storage
|
|
78
|
+
* @param storageKey - Storage key
|
|
79
|
+
* @throws Error if storage not configured
|
|
80
|
+
*/
|
|
81
|
+
revokeTokens(storageKey: string): Promise<void>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=GoogleDriveOAuth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleDriveOAuth.d.ts","sourceRoot":"","sources":["../src/GoogleDriveOAuth.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAgB,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EACL,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,EACb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,gCACf,SAAQ,sBAAsB;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,MAAM,CAAyB;IACvC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,YAAY,CAAoB;IAExC;;;;OAIG;gBAED,MAAM,EAAE,gCAAgC,EACxC,OAAO,CAAC,EAAE,YAAY;IA0BxB;;;;;OAKG;IACH,mBAAmB,CACjB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,EAAE,GAChB;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE;IAyBjC;;;;;;OAMG;IACG,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,sBAAsB,CAAC;IAmClC;;;;;OAKG;IACG,kBAAkB,CACtB,YAAY,EAAE,MAAM,GACnB,OAAO,CAAC,sBAAsB,CAAC;IAsClC;;;;OAIG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB1D;;;;;;OAMG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0BxD;;;;;OAKG;IACG,WAAW,CACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,sBAAsB,GAC7B,OAAO,CAAC,IAAI,CAAC;IAShB;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQtD"}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GoogleDriveOAuth = void 0;
|
|
11
|
+
const logger_1 = require("@bernierllc/logger");
|
|
12
|
+
const googleapis_1 = require("googleapis");
|
|
13
|
+
const uuid_1 = require("uuid");
|
|
14
|
+
/**
|
|
15
|
+
* GoogleDriveOAuth - OAuth 2.0 authentication and token management for Google Drive
|
|
16
|
+
*
|
|
17
|
+
* Handles:
|
|
18
|
+
* - Authorization URL generation
|
|
19
|
+
* - Authorization code exchange
|
|
20
|
+
* - Token refresh
|
|
21
|
+
* - Token validation
|
|
22
|
+
* - Automatic token refresh with storage
|
|
23
|
+
*/
|
|
24
|
+
class GoogleDriveOAuth {
|
|
25
|
+
/**
|
|
26
|
+
* Create a new GoogleDriveOAuth instance
|
|
27
|
+
* @param config - OAuth configuration
|
|
28
|
+
* @param storage - Optional token storage for automatic refresh
|
|
29
|
+
*/
|
|
30
|
+
constructor(config, storage) {
|
|
31
|
+
this.config = {
|
|
32
|
+
clientId: config.clientId,
|
|
33
|
+
clientSecret: config.clientSecret,
|
|
34
|
+
redirectUri: config.redirectUri,
|
|
35
|
+
};
|
|
36
|
+
this.logger =
|
|
37
|
+
config.logger ||
|
|
38
|
+
(0, logger_1.createLogger)({
|
|
39
|
+
context: {
|
|
40
|
+
service: "GoogleDriveOAuth",
|
|
41
|
+
version: "0.1.0",
|
|
42
|
+
environment: process.env.NODE_ENV || "development",
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
this.storage = storage;
|
|
46
|
+
// Initialize OAuth2 client
|
|
47
|
+
this.oauth2Client = new googleapis_1.google.auth.OAuth2(this.config.clientId, this.config.clientSecret, this.config.redirectUri);
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Generate OAuth authorization URL
|
|
51
|
+
* @param state - Optional state parameter for CSRF protection (auto-generated if not provided)
|
|
52
|
+
* @param scopes - Requested Google Drive scopes (default: ['https://www.googleapis.com/auth/drive.file'])
|
|
53
|
+
* @returns Object with authorization URL and state
|
|
54
|
+
*/
|
|
55
|
+
getAuthorizationUrl(state, scopes) {
|
|
56
|
+
const authState = state || (0, uuid_1.v4)();
|
|
57
|
+
const requestedScopes = scopes || [
|
|
58
|
+
"https://www.googleapis.com/auth/drive.file",
|
|
59
|
+
"https://www.googleapis.com/auth/drive.metadata.readonly",
|
|
60
|
+
];
|
|
61
|
+
const authUrl = this.oauth2Client.generateAuthUrl({
|
|
62
|
+
access_type: "offline", // Request refresh token
|
|
63
|
+
scope: requestedScopes,
|
|
64
|
+
state: authState,
|
|
65
|
+
prompt: "consent", // Force consent screen to get refresh token
|
|
66
|
+
});
|
|
67
|
+
this.logger.info("Authorization URL generated", {
|
|
68
|
+
state: authState,
|
|
69
|
+
scopes: requestedScopes,
|
|
70
|
+
});
|
|
71
|
+
return {
|
|
72
|
+
url: authUrl,
|
|
73
|
+
state: authState,
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Exchange authorization code for access and refresh tokens
|
|
78
|
+
* @param code - Authorization code from OAuth callback
|
|
79
|
+
* @param state - State token for CSRF validation
|
|
80
|
+
* @returns OAuth tokens
|
|
81
|
+
* @throws Error if exchange fails
|
|
82
|
+
*/
|
|
83
|
+
async exchangeCodeForTokens(code, _state) {
|
|
84
|
+
try {
|
|
85
|
+
const { tokens } = await this.oauth2Client.getToken(code);
|
|
86
|
+
if (!tokens.access_token) {
|
|
87
|
+
throw new Error("No access token received from Google");
|
|
88
|
+
}
|
|
89
|
+
const oauthTokens = {
|
|
90
|
+
accessToken: tokens.access_token,
|
|
91
|
+
refreshToken: tokens.refresh_token ?? undefined,
|
|
92
|
+
expiresAt: tokens.expiry_date
|
|
93
|
+
? new Date(tokens.expiry_date)
|
|
94
|
+
: undefined,
|
|
95
|
+
tokenType: tokens.token_type ?? "Bearer",
|
|
96
|
+
scope: tokens.scope ?? undefined,
|
|
97
|
+
idToken: tokens.id_token ?? undefined,
|
|
98
|
+
};
|
|
99
|
+
this.logger.info("OAuth tokens obtained", {
|
|
100
|
+
hasRefreshToken: !!oauthTokens.refreshToken,
|
|
101
|
+
expiresAt: oauthTokens.expiresAt,
|
|
102
|
+
});
|
|
103
|
+
return oauthTokens;
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
107
|
+
this.logger.error("Failed to exchange code for tokens", undefined, {
|
|
108
|
+
errorMessage,
|
|
109
|
+
});
|
|
110
|
+
throw new Error(`OAuth token exchange failed: ${errorMessage}`);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Refresh access token using refresh token
|
|
115
|
+
* @param refreshToken - Refresh token
|
|
116
|
+
* @returns New OAuth tokens
|
|
117
|
+
* @throws Error if refresh fails
|
|
118
|
+
*/
|
|
119
|
+
async refreshAccessToken(refreshToken) {
|
|
120
|
+
try {
|
|
121
|
+
this.oauth2Client.setCredentials({
|
|
122
|
+
refresh_token: refreshToken,
|
|
123
|
+
});
|
|
124
|
+
const { credentials } = await this.oauth2Client.refreshAccessToken();
|
|
125
|
+
if (!credentials.access_token) {
|
|
126
|
+
throw new Error("No access token received from Google refresh");
|
|
127
|
+
}
|
|
128
|
+
const tokens = {
|
|
129
|
+
accessToken: credentials.access_token,
|
|
130
|
+
refreshToken: credentials.refresh_token ?? refreshToken,
|
|
131
|
+
expiresAt: credentials.expiry_date
|
|
132
|
+
? new Date(credentials.expiry_date)
|
|
133
|
+
: undefined,
|
|
134
|
+
tokenType: credentials.token_type ?? "Bearer",
|
|
135
|
+
scope: credentials.scope ?? undefined,
|
|
136
|
+
idToken: credentials.id_token ?? undefined,
|
|
137
|
+
};
|
|
138
|
+
this.logger.info("Access token refreshed", {
|
|
139
|
+
expiresAt: tokens.expiresAt,
|
|
140
|
+
});
|
|
141
|
+
return tokens;
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error";
|
|
145
|
+
this.logger.error("Failed to refresh access token", undefined, {
|
|
146
|
+
errorMessage,
|
|
147
|
+
});
|
|
148
|
+
throw new Error(`Token refresh failed: ${errorMessage}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Validate access token by making a test request to Google Drive API
|
|
153
|
+
* @param accessToken - Access token to validate
|
|
154
|
+
* @returns True if token is valid, false otherwise
|
|
155
|
+
*/
|
|
156
|
+
async validateToken(accessToken) {
|
|
157
|
+
try {
|
|
158
|
+
this.oauth2Client.setCredentials({
|
|
159
|
+
access_token: accessToken,
|
|
160
|
+
});
|
|
161
|
+
const drive = googleapis_1.google.drive({ version: "v3", auth: this.oauth2Client });
|
|
162
|
+
const response = await drive.about.get({ fields: "user" });
|
|
163
|
+
return !!response.data.user;
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
this.logger.warn("Token validation failed", {
|
|
167
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
|
168
|
+
});
|
|
169
|
+
return false;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Get a valid access token, automatically refreshing if expired
|
|
174
|
+
* Requires storage to be configured
|
|
175
|
+
* @param storageKey - Key to retrieve tokens from storage
|
|
176
|
+
* @returns Valid access token
|
|
177
|
+
* @throws Error if storage not configured or tokens not found
|
|
178
|
+
*/
|
|
179
|
+
async getValidToken(storageKey) {
|
|
180
|
+
if (!this.storage) {
|
|
181
|
+
throw new Error("Token storage not configured");
|
|
182
|
+
}
|
|
183
|
+
const tokens = await this.storage.retrieve(storageKey);
|
|
184
|
+
if (!tokens) {
|
|
185
|
+
throw new Error("No tokens found in storage");
|
|
186
|
+
}
|
|
187
|
+
// Check if token is expired (with 5 minute buffer)
|
|
188
|
+
const isExpiring = tokens.expiresAt &&
|
|
189
|
+
tokens.expiresAt.getTime() - Date.now() < 5 * 60 * 1000;
|
|
190
|
+
if (isExpiring && tokens.refreshToken) {
|
|
191
|
+
this.logger.info("Token expiring, refreshing...", { storageKey });
|
|
192
|
+
const newTokens = await this.refreshAccessToken(tokens.refreshToken);
|
|
193
|
+
await this.storage.store(storageKey, newTokens);
|
|
194
|
+
return newTokens.accessToken;
|
|
195
|
+
}
|
|
196
|
+
return tokens.accessToken;
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Store tokens using configured storage
|
|
200
|
+
* @param key - Storage key
|
|
201
|
+
* @param tokens - Tokens to store
|
|
202
|
+
* @throws Error if storage not configured
|
|
203
|
+
*/
|
|
204
|
+
async storeTokens(key, tokens) {
|
|
205
|
+
if (!this.storage) {
|
|
206
|
+
throw new Error("Token storage not configured");
|
|
207
|
+
}
|
|
208
|
+
await this.storage.store(key, tokens);
|
|
209
|
+
this.logger.info("Tokens stored", { key });
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Revoke and delete tokens from storage
|
|
213
|
+
* @param storageKey - Storage key
|
|
214
|
+
* @throws Error if storage not configured
|
|
215
|
+
*/
|
|
216
|
+
async revokeTokens(storageKey) {
|
|
217
|
+
if (!this.storage) {
|
|
218
|
+
throw new Error("Token storage not configured");
|
|
219
|
+
}
|
|
220
|
+
await this.storage.delete(storageKey);
|
|
221
|
+
this.logger.info("Tokens revoked", { storageKey });
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
exports.GoogleDriveOAuth = GoogleDriveOAuth;
|
|
225
|
+
//# sourceMappingURL=GoogleDriveOAuth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"GoogleDriveOAuth.js","sourceRoot":"","sources":["../src/GoogleDriveOAuth.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,+CAA0D;AAC1D,2CAA0C;AAC1C,+BAAoC;AAepC;;;;;;;;;GASG;AAC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ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,gBAAgB,EAChB,KAAK,gCAAgC,GACtC,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,sBAAsB,EACtB,sBAAsB,EACtB,YAAY,GACb,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.GoogleDriveOAuth = void 0;
|
|
11
|
+
var GoogleDriveOAuth_1 = require("./GoogleDriveOAuth");
|
|
12
|
+
Object.defineProperty(exports, "GoogleDriveOAuth", { enumerable: true, get: function () { return GoogleDriveOAuth_1.GoogleDriveOAuth; } });
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,uDAG4B;AAF1B,oHAAA,gBAAgB,OAAA"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OAuth 2.0 tokens returned by Google
|
|
3
|
+
*/
|
|
4
|
+
export interface GoogleDriveOAuthTokens {
|
|
5
|
+
accessToken: string;
|
|
6
|
+
refreshToken?: string | undefined;
|
|
7
|
+
expiresAt?: Date | undefined;
|
|
8
|
+
tokenType: string;
|
|
9
|
+
scope?: string | undefined;
|
|
10
|
+
idToken?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* OAuth 2.0 configuration for Google Drive
|
|
14
|
+
*/
|
|
15
|
+
export interface GoogleDriveOAuthConfig {
|
|
16
|
+
clientId: string;
|
|
17
|
+
clientSecret: string;
|
|
18
|
+
redirectUri: string;
|
|
19
|
+
logger?: import("@bernierllc/logger").Logger;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Token storage interface for persistent credential management
|
|
23
|
+
*/
|
|
24
|
+
export interface TokenStorage {
|
|
25
|
+
/**
|
|
26
|
+
* Store OAuth tokens
|
|
27
|
+
* @param key - Storage key (e.g., user ID)
|
|
28
|
+
* @param tokens - OAuth tokens to store
|
|
29
|
+
*/
|
|
30
|
+
store(_key: string, _tokens: GoogleDriveOAuthTokens): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Retrieve OAuth tokens
|
|
33
|
+
* @param key - Storage key
|
|
34
|
+
* @returns Tokens if found, null otherwise
|
|
35
|
+
*/
|
|
36
|
+
retrieve(_key: string): Promise<GoogleDriveOAuthTokens | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Delete OAuth tokens
|
|
39
|
+
* @param key - Storage key
|
|
40
|
+
*/
|
|
41
|
+
delete(_key: string): Promise<void>;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,SAAS,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3B,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,oBAAoB,EAAE,MAAM,CAAC;CAC9C;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B;;;;OAIG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEpE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,GAAG,IAAI,CAAC,CAAC;IAE/D;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (c) 2025 Bernier LLC
|
|
4
|
+
|
|
5
|
+
This file is licensed to the client under a limited-use license.
|
|
6
|
+
The client may use and modify this code *only within the scope of the project it was delivered for*.
|
|
7
|
+
Redistribution or use in other products or commercial offerings is not permitted without written consent from Bernier LLC.
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;EAME"}
|
package/package.json
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@bernierllc/google-drive-oauth",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "OAuth 2.0 authentication and token management for Google Drive",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"author": "Bernier LLC",
|
|
8
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
9
|
+
"files": [
|
|
10
|
+
"dist",
|
|
11
|
+
"LICENSE"
|
|
12
|
+
],
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public",
|
|
15
|
+
"registry": "https://registry.npmjs.org/"
|
|
16
|
+
},
|
|
17
|
+
"dependencies": {
|
|
18
|
+
"googleapis": "^130.0.0",
|
|
19
|
+
"uuid": "^11.1.0",
|
|
20
|
+
"@bernierllc/logger": "1.0.3"
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/jest": "^29.5.12",
|
|
24
|
+
"@types/node": "^20.12.12",
|
|
25
|
+
"@types/uuid": "^9.0.4",
|
|
26
|
+
"@typescript-eslint/eslint-plugin": "^7.9.0",
|
|
27
|
+
"@typescript-eslint/parser": "^7.9.0",
|
|
28
|
+
"eslint": "^8.57.0",
|
|
29
|
+
"eslint-config-prettier": "^9.1.0",
|
|
30
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
31
|
+
"jest": "^29.7.0",
|
|
32
|
+
"prettier": "^3.2.5",
|
|
33
|
+
"ts-jest": "^29.1.2",
|
|
34
|
+
"typescript": "^5.4.5"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"googleapis": "^130.0.0"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsc",
|
|
41
|
+
"test": "jest --runInBand",
|
|
42
|
+
"test:run": "jest --runInBand --collectCoverage",
|
|
43
|
+
"test:coverage": "jest --runInBand --collectCoverage",
|
|
44
|
+
"lint": "eslint \"src/**/*.ts\" \"__tests__/**/*.ts\" --max-warnings 0"
|
|
45
|
+
}
|
|
46
|
+
}
|