@bernierllc/google-drive-oauth 0.8.1 → 0.8.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bernierllc/google-drive-oauth",
3
- "version": "0.8.1",
3
+ "version": "0.8.2",
4
4
  "description": "OAuth 2.0 authentication and token management for Google Drive",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "googleapis": "^130.0.0",
20
20
  "uuid": "^11.1.1",
21
- "@bernierllc/logger": "1.7.1"
21
+ "@bernierllc/logger": "2.0.0"
22
22
  },
23
23
  "devDependencies": {
24
24
  "@types/jest": "^29.5.12",
@@ -1,83 +0,0 @@
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
@@ -1 +0,0 @@
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"}
@@ -1,229 +0,0 @@
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
- config;
26
- logger;
27
- storage;
28
- oauth2Client;
29
- /**
30
- * Create a new GoogleDriveOAuth instance
31
- * @param config - OAuth configuration
32
- * @param storage - Optional token storage for automatic refresh
33
- */
34
- constructor(config, storage) {
35
- this.config = {
36
- clientId: config.clientId,
37
- clientSecret: config.clientSecret,
38
- redirectUri: config.redirectUri,
39
- };
40
- this.logger =
41
- config.logger ||
42
- (0, logger_1.createLogger)({
43
- context: {
44
- service: "GoogleDriveOAuth",
45
- version: "0.1.0",
46
- environment: process.env.NODE_ENV || "development",
47
- },
48
- });
49
- this.storage = storage;
50
- // Initialize OAuth2 client
51
- this.oauth2Client = new googleapis_1.google.auth.OAuth2(this.config.clientId, this.config.clientSecret, this.config.redirectUri);
52
- }
53
- /**
54
- * Generate OAuth authorization URL
55
- * @param state - Optional state parameter for CSRF protection (auto-generated if not provided)
56
- * @param scopes - Requested Google Drive scopes (default: ['https://www.googleapis.com/auth/drive.file'])
57
- * @returns Object with authorization URL and state
58
- */
59
- getAuthorizationUrl(state, scopes) {
60
- const authState = state || (0, uuid_1.v4)();
61
- const requestedScopes = scopes || [
62
- "https://www.googleapis.com/auth/drive.file",
63
- "https://www.googleapis.com/auth/drive.metadata.readonly",
64
- ];
65
- const authUrl = this.oauth2Client.generateAuthUrl({
66
- access_type: "offline", // Request refresh token
67
- scope: requestedScopes,
68
- state: authState,
69
- prompt: "consent", // Force consent screen to get refresh token
70
- });
71
- this.logger.info("Authorization URL generated", {
72
- state: authState,
73
- scopes: requestedScopes,
74
- });
75
- return {
76
- url: authUrl,
77
- state: authState,
78
- };
79
- }
80
- /**
81
- * Exchange authorization code for access and refresh tokens
82
- * @param code - Authorization code from OAuth callback
83
- * @param state - State token for CSRF validation
84
- * @returns OAuth tokens
85
- * @throws Error if exchange fails
86
- */
87
- async exchangeCodeForTokens(code, _state) {
88
- try {
89
- const { tokens } = await this.oauth2Client.getToken(code);
90
- if (!tokens.access_token) {
91
- throw new Error("No access token received from Google");
92
- }
93
- const oauthTokens = {
94
- accessToken: tokens.access_token,
95
- refreshToken: tokens.refresh_token ?? undefined,
96
- expiresAt: tokens.expiry_date
97
- ? new Date(tokens.expiry_date)
98
- : undefined,
99
- tokenType: tokens.token_type ?? "Bearer",
100
- scope: tokens.scope ?? undefined,
101
- idToken: tokens.id_token ?? undefined,
102
- };
103
- this.logger.info("OAuth tokens obtained", {
104
- hasRefreshToken: !!oauthTokens.refreshToken,
105
- expiresAt: oauthTokens.expiresAt,
106
- });
107
- return oauthTokens;
108
- }
109
- catch (error) {
110
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
111
- this.logger.error("Failed to exchange code for tokens", undefined, {
112
- errorMessage,
113
- });
114
- throw new Error(`OAuth token exchange failed: ${errorMessage}`);
115
- }
116
- }
117
- /**
118
- * Refresh access token using refresh token
119
- * @param refreshToken - Refresh token
120
- * @returns New OAuth tokens
121
- * @throws Error if refresh fails
122
- */
123
- async refreshAccessToken(refreshToken) {
124
- try {
125
- this.oauth2Client.setCredentials({
126
- refresh_token: refreshToken,
127
- });
128
- const { credentials } = await this.oauth2Client.refreshAccessToken();
129
- if (!credentials.access_token) {
130
- throw new Error("No access token received from Google refresh");
131
- }
132
- const tokens = {
133
- accessToken: credentials.access_token,
134
- refreshToken: credentials.refresh_token ?? refreshToken,
135
- expiresAt: credentials.expiry_date
136
- ? new Date(credentials.expiry_date)
137
- : undefined,
138
- tokenType: credentials.token_type ?? "Bearer",
139
- scope: credentials.scope ?? undefined,
140
- idToken: credentials.id_token ?? undefined,
141
- };
142
- this.logger.info("Access token refreshed", {
143
- expiresAt: tokens.expiresAt,
144
- });
145
- return tokens;
146
- }
147
- catch (error) {
148
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
149
- this.logger.error("Failed to refresh access token", undefined, {
150
- errorMessage,
151
- });
152
- throw new Error(`Token refresh failed: ${errorMessage}`);
153
- }
154
- }
155
- /**
156
- * Validate access token by making a test request to Google Drive API
157
- * @param accessToken - Access token to validate
158
- * @returns True if token is valid, false otherwise
159
- */
160
- async validateToken(accessToken) {
161
- try {
162
- this.oauth2Client.setCredentials({
163
- access_token: accessToken,
164
- });
165
- const drive = googleapis_1.google.drive({ version: "v3", auth: this.oauth2Client });
166
- const response = await drive.about.get({ fields: "user" });
167
- return !!response.data.user;
168
- }
169
- catch (error) {
170
- this.logger.warn("Token validation failed", {
171
- error: error instanceof Error ? error.message : "Unknown error",
172
- });
173
- return false;
174
- }
175
- }
176
- /**
177
- * Get a valid access token, automatically refreshing if expired
178
- * Requires storage to be configured
179
- * @param storageKey - Key to retrieve tokens from storage
180
- * @returns Valid access token
181
- * @throws Error if storage not configured or tokens not found
182
- */
183
- async getValidToken(storageKey) {
184
- if (!this.storage) {
185
- throw new Error("Token storage not configured");
186
- }
187
- const tokens = await this.storage.retrieve(storageKey);
188
- if (!tokens) {
189
- throw new Error("No tokens found in storage");
190
- }
191
- // Check if token is expired (with 5 minute buffer)
192
- const isExpiring = tokens.expiresAt &&
193
- tokens.expiresAt.getTime() - Date.now() < 5 * 60 * 1000;
194
- if (isExpiring && tokens.refreshToken) {
195
- this.logger.info("Token expiring, refreshing...", { storageKey });
196
- const newTokens = await this.refreshAccessToken(tokens.refreshToken);
197
- await this.storage.store(storageKey, newTokens);
198
- return newTokens.accessToken;
199
- }
200
- return tokens.accessToken;
201
- }
202
- /**
203
- * Store tokens using configured storage
204
- * @param key - Storage key
205
- * @param tokens - Tokens to store
206
- * @throws Error if storage not configured
207
- */
208
- async storeTokens(key, tokens) {
209
- if (!this.storage) {
210
- throw new Error("Token storage not configured");
211
- }
212
- await this.storage.store(key, tokens);
213
- this.logger.info("Tokens stored", { key });
214
- }
215
- /**
216
- * Revoke and delete tokens from storage
217
- * @param storageKey - Storage key
218
- * @throws Error if storage not configured
219
- */
220
- async revokeTokens(storageKey) {
221
- if (!this.storage) {
222
- throw new Error("Token storage not configured");
223
- }
224
- await this.storage.delete(storageKey);
225
- this.logger.info("Tokens revoked", { storageKey });
226
- }
227
- }
228
- exports.GoogleDriveOAuth = GoogleDriveOAuth;
229
- //# sourceMappingURL=GoogleDriveOAuth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GoogleDriveOAuth.js","sourceRoot":"","sources":["../src/GoogleDriveOAuth.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,+CAA0D;AAC1D,2CAA0C;AAC1C,+BAAoC;AAepC;;;;;;;;;GASG;AACH,MAAa,gBAAgB;IACnB,MAAM,CAAyB;IAC/B,MAAM,CAAS;IACf,OAAO,CAA2B;IAClC,YAAY,CAAoB;IAExC;;;;OAIG;IACH,YACE,MAAwC,EACxC,OAAsB;QAEtB,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ;YACzB,YAAY,EAAE,MAAM,CAAC,YAAY;YACjC,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC,CAAC;QACF,IAAI,CAAC,MAAM;YACT,MAAM,CAAC,MAAM;gBACb,IAAA,qBAAY,EAAC;oBACX,OAAO,EAAE;wBACP,OAAO,EAAE,kBAAkB;wBAC3B,OAAO,EAAE,OAAO;wBAChB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,QAAQ,IAAI,aAAa;qBACnD;iBACF,CAAC,CAAC;QACL,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,2BAA2B;QAC3B,IAAI,CAAC,YAAY,GAAG,IAAI,mBAAM,CAAC,IAAI,CAAC,MAAM,CACxC,IAAI,CAAC,MAAM,CAAC,QAAQ,EACpB,IAAI,CAAC,MAAM,CAAC,YAAY,EACxB,IAAI,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,OAAO,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC7C,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,YAAY,CAAC,UAAkB;QACnC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;QAED,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,gBAAgB,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IACrD,CAAC;CACF;AA3PD,4CA2PC"}
package/dist/errors.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export type GoogleDriveOauthErrorCode = 'GOOGLE_DRIVE_OAUTH_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
- export interface GoogleDriveOauthErrorOptions {
3
- cause?: Error;
4
- code?: GoogleDriveOauthErrorCode;
5
- context?: Record<string, unknown>;
6
- }
7
- export declare class GoogleDriveOauthError extends Error {
8
- readonly code: GoogleDriveOauthErrorCode;
9
- readonly context?: Record<string, unknown>;
10
- constructor(message: string, options?: GoogleDriveOauthErrorOptions);
11
- }
12
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,yBAAyB,GACjC,0BAA0B,GAC1B,eAAe,GACf,kBAAkB,CAAC;AAEvB,MAAM,WAAW,4BAA4B;IAC3C,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,yBAAyB,CAAC;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,qBAAsB,SAAQ,KAAK;IAC9C,QAAQ,CAAC,IAAI,EAAE,yBAAyB,CAAC;IACzC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,4BAA4B;CASpE"}
package/dist/errors.js DELETED
@@ -1,25 +0,0 @@
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.GoogleDriveOauthError = void 0;
11
- class GoogleDriveOauthError extends Error {
12
- code;
13
- context;
14
- constructor(message, options) {
15
- super(message, options?.cause ? { cause: options.cause } : undefined);
16
- this.name = 'GoogleDriveOauthError';
17
- this.code = options?.code ?? 'GOOGLE_DRIVE_OAUTH_ERROR';
18
- if (options?.context !== undefined) {
19
- this.context = options.context;
20
- }
21
- Error.captureStackTrace?.(this, this.constructor);
22
- }
23
- }
24
- exports.GoogleDriveOauthError = GoogleDriveOauthError;
25
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAaF,MAAa,qBAAsB,SAAQ,KAAK;IACrC,IAAI,CAA4B;IAChC,OAAO,CAA2B;IAE3C,YAAY,OAAe,EAAE,OAAsC;QACjE,KAAK,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtE,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,0BAA0B,CAAC;QACxD,IAAI,OAAO,EAAE,OAAO,KAAK,SAAS,EAAE,CAAC;YACnC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QACjC,CAAC;QACD,KAAK,CAAC,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IACpD,CAAC;CACF;AAbD,sDAaC"}
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { GoogleDriveOAuth, type GoogleDriveOAuthConfigWithLogger, } from "./GoogleDriveOAuth";
2
- export type { GoogleDriveOAuthTokens, GoogleDriveOAuthConfig, TokenStorage, } from "./types";
3
- export { GoogleDriveOauthError, type GoogleDriveOauthErrorCode, type GoogleDriveOauthErrorOptions } from './errors';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.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;AACjB,OAAO,EAAE,qBAAqB,EAAE,KAAK,yBAAyB,EAAE,KAAK,4BAA4B,EAAE,MAAM,UAAU,CAAC"}
package/dist/index.js DELETED
@@ -1,15 +0,0 @@
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.GoogleDriveOauthError = exports.GoogleDriveOAuth = void 0;
11
- var GoogleDriveOAuth_1 = require("./GoogleDriveOAuth");
12
- Object.defineProperty(exports, "GoogleDriveOAuth", { enumerable: true, get: function () { return GoogleDriveOAuth_1.GoogleDriveOAuth; } });
13
- var errors_1 = require("./errors");
14
- Object.defineProperty(exports, "GoogleDriveOauthError", { enumerable: true, get: function () { return errors_1.GoogleDriveOauthError; } });
15
- //# sourceMappingURL=index.js.map
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,uDAG4B;AAF1B,oHAAA,gBAAgB,OAAA;AAQlB,mCAAoH;AAA3G,+GAAA,qBAAqB,OAAA"}
package/dist/types.d.ts DELETED
@@ -1,43 +0,0 @@
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
@@ -1 +0,0 @@
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 DELETED
@@ -1,10 +0,0 @@
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
package/dist/types.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;;;;;EAME"}