@bernierllc/dropbox-oauth 0.8.0 → 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/dropbox-oauth",
3
- "version": "0.8.0",
3
+ "version": "0.8.2",
4
4
  "description": "OAuth 2.0 authentication and token management for Dropbox",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -18,7 +18,7 @@
18
18
  "dependencies": {
19
19
  "dropbox": "^10.34.0",
20
20
  "uuid": "^11.1.1",
21
- "@bernierllc/logger": "1.7.0"
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 { DropboxOAuthConfig, DropboxOAuthTokens, TokenStorage } from "./types";
3
- /**
4
- * Extended configuration including logger
5
- */
6
- export interface DropboxOAuthConfigWithLogger extends DropboxOAuthConfig {
7
- logger?: Logger;
8
- }
9
- /**
10
- * DropboxOAuth - OAuth 2.0 authentication and token management for Dropbox
11
- *
12
- * Handles:
13
- * - Authorization URL generation with PKCE
14
- * - Authorization code exchange
15
- * - Token refresh
16
- * - Token validation
17
- * - Automatic token refresh with storage
18
- */
19
- export declare class DropboxOAuth {
20
- private config;
21
- private logger;
22
- private storage;
23
- private auth;
24
- /**
25
- * Create a new DropboxOAuth instance
26
- * @param config - OAuth configuration
27
- * @param storage - Optional token storage for automatic refresh
28
- */
29
- constructor(config: DropboxOAuthConfigWithLogger, storage?: TokenStorage);
30
- /**
31
- * Generate OAuth authorization URL with PKCE
32
- * @param state - Optional state parameter for CSRF protection (auto-generated if not provided)
33
- * @param scopes - Requested Dropbox scopes (default: ['files.content.write', 'files.content.read'])
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<DropboxOAuthTokens>;
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): DropboxOAuthTokens;
55
- /**
56
- * Validate access token by making a test request to Dropbox 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: DropboxOAuthTokens): 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=DropboxOAuth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropboxOAuth.d.ts","sourceRoot":"","sources":["../src/DropboxOAuth.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAgB,MAAM,oBAAoB,CAAC;AAG1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EAEb,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,kBAAkB;IACtE,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;GASG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,IAAI,CAAc;IAE1B;;;;OAIG;gBACS,MAAM,EAAE,4BAA4B,EAAE,OAAO,CAAC,EAAE,YAAY;IAwBxE;;;;;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;IA+BjC;;;;;;OAMG;IACG,qBAAqB,CACzB,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,kBAAkB,CAAC;IAyC9B;;;;;OAKG;IACH,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,kBAAkB;IAwC5D;;;;OAIG;IACG,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAc1D;;;;;;OAMG;IACG,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IA0BxD;;;;;OAKG;IACG,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC;IASzE;;;;OAIG;IACG,YAAY,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQtD"}
@@ -1,232 +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.DropboxOAuth = void 0;
11
- const logger_1 = require("@bernierllc/logger");
12
- const dropbox_1 = require("dropbox");
13
- const uuid_1 = require("uuid");
14
- /**
15
- * DropboxOAuth - OAuth 2.0 authentication and token management for Dropbox
16
- *
17
- * Handles:
18
- * - Authorization URL generation with PKCE
19
- * - Authorization code exchange
20
- * - Token refresh
21
- * - Token validation
22
- * - Automatic token refresh with storage
23
- */
24
- class DropboxOAuth {
25
- config;
26
- logger;
27
- storage;
28
- auth;
29
- /**
30
- * Create a new DropboxOAuth 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: "DropboxOAuth",
45
- version: "0.1.0",
46
- environment: process.env.NODE_ENV || "development",
47
- },
48
- });
49
- this.storage = storage;
50
- // Initialize DropboxAuth
51
- this.auth = new dropbox_1.DropboxAuth({
52
- clientId: this.config.clientId,
53
- clientSecret: this.config.clientSecret,
54
- });
55
- }
56
- /**
57
- * Generate OAuth authorization URL with PKCE
58
- * @param state - Optional state parameter for CSRF protection (auto-generated if not provided)
59
- * @param scopes - Requested Dropbox scopes (default: ['files.content.write', 'files.content.read'])
60
- * @returns Object with authorization URL and state
61
- */
62
- getAuthorizationUrl(state, scopes) {
63
- const authState = state || (0, uuid_1.v4)();
64
- const requestedScopes = scopes || [
65
- "files.content.write",
66
- "files.content.read",
67
- "account_info.read",
68
- ];
69
- // Dropbox uses PKCE, so we need to get the auth URL from the SDK
70
- // getAuthenticationUrl returns a string synchronously
71
- const authUrl = this.auth.getAuthenticationUrl(this.config.redirectUri, authState, "code", "offline", requestedScopes, "none", false);
72
- this.logger.info("Authorization URL generated", {
73
- state: authState,
74
- scopes: requestedScopes,
75
- });
76
- return {
77
- url: authUrl,
78
- state: authState,
79
- };
80
- }
81
- /**
82
- * Exchange authorization code for access and refresh tokens
83
- * @param code - Authorization code from OAuth callback
84
- * @param state - State token for CSRF validation
85
- * @returns OAuth tokens
86
- * @throws Error if exchange fails
87
- */
88
- async exchangeCodeForTokens(code, _state) {
89
- try {
90
- // Dropbox SDK handles the token exchange
91
- const tokenResult = await this.auth.getAccessTokenFromCode(this.config.redirectUri, code);
92
- if (!tokenResult.result) {
93
- throw new Error("No token result from Dropbox");
94
- }
95
- const result = tokenResult.result;
96
- const tokens = {
97
- accessToken: result.access_token,
98
- refreshToken: result.refresh_token ?? undefined,
99
- expiresAt: result.expires_in
100
- ? new Date(Date.now() + result.expires_in * 1000)
101
- : undefined,
102
- tokenType: result.token_type ?? "bearer",
103
- scope: result.scope ?? undefined,
104
- accountId: result.account_id ?? undefined,
105
- };
106
- this.logger.info("OAuth tokens obtained", {
107
- hasRefreshToken: !!tokens.refreshToken,
108
- expiresAt: tokens.expiresAt,
109
- accountId: tokens.accountId,
110
- });
111
- return tokens;
112
- }
113
- catch (error) {
114
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
115
- this.logger.error("Failed to exchange code for tokens", undefined, {
116
- errorMessage,
117
- });
118
- throw new Error(`OAuth token exchange failed: ${errorMessage}`);
119
- }
120
- }
121
- /**
122
- * Refresh access token using refresh token
123
- * @param refreshToken - Refresh token
124
- * @returns New OAuth tokens
125
- * @throws Error if refresh fails
126
- */
127
- refreshAccessToken(refreshToken) {
128
- try {
129
- // Set the refresh token in the auth instance
130
- this.auth.setRefreshToken(refreshToken);
131
- // Refresh access token - this updates the internal state
132
- // Note: refreshAccessToken() returns void but is synchronous
133
- this.auth.refreshAccessToken();
134
- // Get the access token from the auth instance
135
- const accessToken = this.auth.getAccessToken();
136
- if (!accessToken) {
137
- throw new Error("No access token after refresh");
138
- }
139
- // Dropbox refresh doesn't return expiry, so we'll set a default
140
- // Access tokens typically last 4 hours
141
- const tokens = {
142
- accessToken: accessToken,
143
- refreshToken: refreshToken || undefined, // Keep existing refresh token
144
- expiresAt: new Date(Date.now() + 4 * 60 * 60 * 1000), // 4 hours default
145
- tokenType: "bearer",
146
- scope: undefined,
147
- };
148
- this.logger.info("Access token refreshed", {
149
- expiresAt: tokens.expiresAt,
150
- });
151
- return tokens;
152
- }
153
- catch (error) {
154
- const errorMessage = error instanceof Error ? error.message : "Unknown error";
155
- this.logger.error("Failed to refresh access token", undefined, {
156
- errorMessage,
157
- });
158
- throw new Error(`Token refresh failed: ${errorMessage}`);
159
- }
160
- }
161
- /**
162
- * Validate access token by making a test request to Dropbox API
163
- * @param accessToken - Access token to validate
164
- * @returns True if token is valid, false otherwise
165
- */
166
- async validateToken(accessToken) {
167
- try {
168
- const dbx = new dropbox_1.Dropbox({ accessToken });
169
- const response = await dbx.usersGetCurrentAccount();
170
- return !!response.result;
171
- }
172
- catch (error) {
173
- this.logger.warn("Token validation failed", {
174
- error: error instanceof Error ? error.message : "Unknown error",
175
- });
176
- return false;
177
- }
178
- }
179
- /**
180
- * Get a valid access token, automatically refreshing if expired
181
- * Requires storage to be configured
182
- * @param storageKey - Key to retrieve tokens from storage
183
- * @returns Valid access token
184
- * @throws Error if storage not configured or tokens not found
185
- */
186
- async getValidToken(storageKey) {
187
- if (!this.storage) {
188
- throw new Error("Token storage not configured");
189
- }
190
- const tokens = await this.storage.retrieve(storageKey);
191
- if (!tokens) {
192
- throw new Error("No tokens found in storage");
193
- }
194
- // Check if token is expired (with 5 minute buffer)
195
- const isExpiring = tokens.expiresAt &&
196
- tokens.expiresAt.getTime() - Date.now() < 5 * 60 * 1000;
197
- if (isExpiring && tokens.refreshToken) {
198
- this.logger.info("Token expiring, refreshing...", { storageKey });
199
- const newTokens = this.refreshAccessToken(tokens.refreshToken);
200
- await this.storage.store(storageKey, newTokens);
201
- return newTokens.accessToken;
202
- }
203
- return tokens.accessToken;
204
- }
205
- /**
206
- * Store tokens using configured storage
207
- * @param key - Storage key
208
- * @param tokens - Tokens to store
209
- * @throws Error if storage not configured
210
- */
211
- async storeTokens(key, tokens) {
212
- if (!this.storage) {
213
- throw new Error("Token storage not configured");
214
- }
215
- await this.storage.store(key, tokens);
216
- this.logger.info("Tokens stored", { key });
217
- }
218
- /**
219
- * Revoke and delete tokens from storage
220
- * @param storageKey - Storage key
221
- * @throws Error if storage not configured
222
- */
223
- async revokeTokens(storageKey) {
224
- if (!this.storage) {
225
- throw new Error("Token storage not configured");
226
- }
227
- await this.storage.delete(storageKey);
228
- this.logger.info("Tokens revoked", { storageKey });
229
- }
230
- }
231
- exports.DropboxOAuth = DropboxOAuth;
232
- //# sourceMappingURL=DropboxOAuth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"DropboxOAuth.js","sourceRoot":"","sources":["../src/DropboxOAuth.ts"],"names":[],"mappings":";AAAA;;;;;;EAME;;;AAEF,+CAA0D;AAC1D,qCAA+C;AAC/C,+BAAoC;AAepC;;;;;;;;;GASG;AACH,MAAa,YAAY;IACf,MAAM,CAAqB;IAC3B,MAAM,CAAS;IACf,OAAO,CAA2B;IAClC,IAAI,CAAc;IAE1B;;;;OAIG;IACH,YAAY,MAAoC,EAAE,OAAsB;QACtE,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,cAAc;wBACvB,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,yBAAyB;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,qBAAW,CAAC;YAC1B,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ;YAC9B,YAAY,EAAE,IAAI,CAAC,MAAM,CAAC,YAAY;SACvC,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;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AAC,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;AA5PD,oCA4PC"}
package/dist/errors.d.ts DELETED
@@ -1,12 +0,0 @@
1
- export type DropboxOauthErrorCode = 'DROPBOX_OAUTH_ERROR' | 'INVALID_INPUT' | 'OPERATION_FAILED';
2
- export interface DropboxOauthErrorOptions {
3
- cause?: Error;
4
- code?: DropboxOauthErrorCode;
5
- context?: Record<string, unknown>;
6
- }
7
- export declare class DropboxOauthError extends Error {
8
- readonly code: DropboxOauthErrorCode;
9
- readonly context?: Record<string, unknown>;
10
- constructor(message: string, options?: DropboxOauthErrorOptions);
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,qBAAqB,GAC7B,qBAAqB,GACrB,eAAe,GACf,kBAAkB,CAAC;AAEvB,MAAM,WAAW,wBAAwB;IACvC,KAAK,CAAC,EAAE,KAAK,CAAC;IACd,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,IAAI,EAAE,qBAAqB,CAAC;IACrC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAE/B,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,wBAAwB;CAShE"}
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.DropboxOauthError = void 0;
11
- class DropboxOauthError extends Error {
12
- code;
13
- context;
14
- constructor(message, options) {
15
- super(message, options?.cause ? { cause: options.cause } : undefined);
16
- this.name = 'DropboxOauthError';
17
- this.code = options?.code ?? 'DROPBOX_OAUTH_ERROR';
18
- if (options?.context !== undefined) {
19
- this.context = options.context;
20
- }
21
- Error.captureStackTrace?.(this, this.constructor);
22
- }
23
- }
24
- exports.DropboxOauthError = DropboxOauthError;
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,iBAAkB,SAAQ,KAAK;IACjC,IAAI,CAAwB;IAC5B,OAAO,CAA2B;IAE3C,YAAY,OAAe,EAAE,OAAkC;QAC7D,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,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,EAAE,IAAI,IAAI,qBAAqB,CAAC;QACnD,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,8CAaC"}
package/dist/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export { DropboxOauthError, type DropboxOauthErrorCode, type DropboxOauthErrorOptions, } from "./errors";
2
- export { DropboxOAuth, type DropboxOAuthConfigWithLogger, } from "./DropboxOAuth";
3
- export type { DropboxOAuthTokens, DropboxOAuthConfig, TokenStorage, } from "./types";
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,iBAAiB,EACjB,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,GAC9B,MAAM,UAAU,CAAC;AAElB,OAAO,EACL,YAAY,EACZ,KAAK,4BAA4B,GAClC,MAAM,gBAAgB,CAAC;AACxB,YAAY,EACV,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,SAAS,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.DropboxOAuth = exports.DropboxOauthError = void 0;
11
- var errors_1 = require("./errors");
12
- Object.defineProperty(exports, "DropboxOauthError", { enumerable: true, get: function () { return errors_1.DropboxOauthError; } });
13
- var DropboxOAuth_1 = require("./DropboxOAuth");
14
- Object.defineProperty(exports, "DropboxOAuth", { enumerable: true, get: function () { return DropboxOAuth_1.DropboxOAuth; } });
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,mCAIkB;AAHhB,2GAAA,iBAAiB,OAAA;AAKnB,+CAGwB;AAFtB,4GAAA,YAAY,OAAA"}
package/dist/types.d.ts DELETED
@@ -1,55 +0,0 @@
1
- /**
2
- * OAuth 2.0 tokens returned by Dropbox
3
- */
4
- export interface DropboxOAuthTokens {
5
- accessToken: string;
6
- refreshToken?: string | undefined;
7
- expiresAt?: Date | undefined;
8
- tokenType: string;
9
- scope?: string | undefined;
10
- accountId?: string | undefined;
11
- }
12
- /**
13
- * OAuth 2.0 configuration for Dropbox
14
- */
15
- export interface DropboxOAuthConfig {
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: DropboxOAuthTokens): 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<DropboxOAuthTokens | null>;
37
- /**
38
- * Delete OAuth tokens
39
- * @param key - Storage key
40
- */
41
- delete(_key: string): Promise<void>;
42
- }
43
- /**
44
- * Dropbox API token result structure
45
- * This matches the structure returned by Dropbox SDK's getAccessTokenFromCode
46
- */
47
- export interface DropboxTokenResult {
48
- access_token: string;
49
- refresh_token?: string;
50
- expires_in?: number;
51
- token_type?: string;
52
- scope?: string;
53
- account_id?: string;
54
- }
55
- //# 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,kBAAkB;IACjC,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,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,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,kBAAkB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAEhE;;;;OAIG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IAE3D;;;OAGG;IACH,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
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"}