@oatfi/oatfi-sdk-ts 0.11.1 → 0.11.3
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/README.md +0 -2
- package/dist/commonjs/lib/config.d.ts +2 -2
- package/dist/commonjs/lib/config.js +2 -2
- package/dist/commonjs/sdk/sdk.d.ts +139 -0
- package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
- package/dist/commonjs/sdk/sdk.js +239 -0
- package/dist/commonjs/sdk/sdk.js.map +1 -1
- package/dist/esm/lib/config.d.ts +2 -2
- package/dist/esm/lib/config.js +2 -2
- package/dist/esm/sdk/sdk.d.ts +139 -0
- package/dist/esm/sdk/sdk.d.ts.map +1 -1
- package/dist/esm/sdk/sdk.js +239 -0
- package/dist/esm/sdk/sdk.js.map +1 -1
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/lib/config.ts +2 -2
- package/src/sdk/sdk.ts +310 -0
package/README.md
CHANGED
|
@@ -11,8 +11,6 @@ Developer-friendly & type-safe Typescript SDK specifically catered to leverage *
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
<br /><br />
|
|
14
|
-
> [!IMPORTANT]
|
|
15
|
-
> This SDK is not yet ready for production use. To complete setup please follow the steps outlined in your [workspace](https://app.speakeasy.com/org/oatfi/v3-api). Delete this section before > publishing to a package manager.
|
|
16
14
|
|
|
17
15
|
<!-- Start Summary [summary] -->
|
|
18
16
|
## Summary
|
|
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "3.0.0";
|
|
34
|
-
readonly sdkVersion: "0.11.
|
|
34
|
+
readonly sdkVersion: "0.11.3";
|
|
35
35
|
readonly genVersion: "2.731.6";
|
|
36
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.11.
|
|
36
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.11.3 2.731.6 3.0.0 @oatfi/oatfi-sdk-ts";
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -39,8 +39,8 @@ function serverURLFromOptions(options) {
|
|
|
39
39
|
exports.SDK_METADATA = {
|
|
40
40
|
language: "typescript",
|
|
41
41
|
openapiDocVersion: "3.0.0",
|
|
42
|
-
sdkVersion: "0.11.
|
|
42
|
+
sdkVersion: "0.11.3",
|
|
43
43
|
genVersion: "2.731.6",
|
|
44
|
-
userAgent: "speakeasy-sdk/typescript 0.11.
|
|
44
|
+
userAgent: "speakeasy-sdk/typescript 0.11.3 2.731.6 3.0.0 @oatfi/oatfi-sdk-ts",
|
|
45
45
|
};
|
|
46
46
|
//# sourceMappingURL=config.js.map
|
|
@@ -87,5 +87,144 @@ export declare class OatFiSDK extends ClientSDK {
|
|
|
87
87
|
get programSettings(): ProgramSettings;
|
|
88
88
|
private _users?;
|
|
89
89
|
get users(): Users;
|
|
90
|
+
/**
|
|
91
|
+
* Token cache for managing access tokens per API key/server combination.
|
|
92
|
+
* Map key format: "{serverURL || serverIdx}-{apiKeyLast10Chars}"
|
|
93
|
+
*/
|
|
94
|
+
private static tokenCache;
|
|
95
|
+
/**
|
|
96
|
+
* Stored API key configuration for instance methods.
|
|
97
|
+
* Only set when SDK is created via initialize() or createFromApiKey().
|
|
98
|
+
*/
|
|
99
|
+
private _apiKeyConfig?;
|
|
100
|
+
/**
|
|
101
|
+
* Initialize an authenticated SDK instance with automatic token management.
|
|
102
|
+
*
|
|
103
|
+
* This method handles the two-step authentication process:
|
|
104
|
+
* 1. Checks for cached token (uses cache if valid)
|
|
105
|
+
* 2. If needed, creates temporary SDK to exchange API key for bearer token
|
|
106
|
+
* 3. Caches the token with expiration
|
|
107
|
+
* 4. Returns SDK instance with bearer token
|
|
108
|
+
*
|
|
109
|
+
* Tokens are automatically cached per API key/server combination.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const sdk = await OatFiSDK.initialize({
|
|
114
|
+
* apiKey: 'your-api-key',
|
|
115
|
+
* serverIdx: 0
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static initialize(config: {
|
|
120
|
+
apiKey: string;
|
|
121
|
+
serverIdx?: number;
|
|
122
|
+
serverURL?: string;
|
|
123
|
+
debug?: boolean;
|
|
124
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
125
|
+
timeoutMs?: number;
|
|
126
|
+
}): Promise<OatFiSDK>;
|
|
127
|
+
/**
|
|
128
|
+
* Create SDK from API key with automatic token exchange (simple factory method).
|
|
129
|
+
*
|
|
130
|
+
* This is a convenience method that calls initialize() internally.
|
|
131
|
+
* For advanced token management, use initialize() instead.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const sdk = await OatFiSDK.createFromApiKey({
|
|
136
|
+
* apiKey: 'your-api-key',
|
|
137
|
+
* serverIdx: 0
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
static createFromApiKey(config: {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
serverIdx?: number;
|
|
144
|
+
serverURL?: string;
|
|
145
|
+
debug?: boolean;
|
|
146
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
147
|
+
timeoutMs?: number;
|
|
148
|
+
}): Promise<OatFiSDK>;
|
|
149
|
+
/**
|
|
150
|
+
* Manually refresh the access token for a given configuration.
|
|
151
|
+
* This clears the cache and forces a new token exchange.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const sdk = await OatFiSDK.refreshToken({
|
|
156
|
+
* apiKey: 'your-api-key',
|
|
157
|
+
* serverIdx: 0
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static refreshToken(config: {
|
|
162
|
+
apiKey: string;
|
|
163
|
+
serverIdx?: number;
|
|
164
|
+
serverURL?: string;
|
|
165
|
+
debug?: boolean;
|
|
166
|
+
}): Promise<OatFiSDK>;
|
|
167
|
+
/**
|
|
168
|
+
* Get the current cached access token for a configuration.
|
|
169
|
+
* Returns null if no token is cached or token is expired.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* const token = OatFiSDK.getCachedToken({
|
|
174
|
+
* apiKey: 'your-api-key',
|
|
175
|
+
* serverIdx: 0
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
static getCachedToken(config: {
|
|
180
|
+
apiKey: string;
|
|
181
|
+
serverIdx?: number;
|
|
182
|
+
serverURL?: string;
|
|
183
|
+
}): string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Clear the entire token cache.
|
|
186
|
+
* Useful when switching users or debugging.
|
|
187
|
+
*/
|
|
188
|
+
static clearTokenCache(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Refresh the access token for this SDK instance in place.
|
|
191
|
+
* Updates the bearer token on the current instance without creating a new one.
|
|
192
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
197
|
+
* // Later, when token expires:
|
|
198
|
+
* await sdk.refreshToken();
|
|
199
|
+
* // Continue using the same instance - no need to reassign
|
|
200
|
+
* const businesses = await sdk.businesses.list();
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
refreshToken(): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Get the cached access token for this SDK instance.
|
|
206
|
+
* Returns null if no token is cached or token is expired.
|
|
207
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
212
|
+
* const token = sdk.getCachedToken();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
getCachedToken(): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* Check if the current SDK instance has a valid cached token.
|
|
218
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
223
|
+
* if (await sdk.hasValidToken()) {
|
|
224
|
+
* // Token is valid
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
hasValidToken(): boolean;
|
|
90
229
|
}
|
|
91
230
|
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,eAAe,E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c/B;;;;;;;;;;;OAWG;IACH,aAAa,IAAI,OAAO;CAKzB"}
|
package/dist/commonjs/sdk/sdk.js
CHANGED
|
@@ -34,6 +34,7 @@ const platformsettings_js_1 = require("./platformsettings.js");
|
|
|
34
34
|
const programs_js_1 = require("./programs.js");
|
|
35
35
|
const programsettings_js_1 = require("./programsettings.js");
|
|
36
36
|
const users_js_1 = require("./users.js");
|
|
37
|
+
// #endregion imports
|
|
37
38
|
class OatFiSDK extends sdks_js_1.ClientSDK {
|
|
38
39
|
get applications() {
|
|
39
40
|
return (this._applications ?? (this._applications = new applications_js_1.Applications(this._options)));
|
|
@@ -122,6 +123,244 @@ class OatFiSDK extends sdks_js_1.ClientSDK {
|
|
|
122
123
|
get users() {
|
|
123
124
|
return (this._users ?? (this._users = new users_js_1.Users(this._options)));
|
|
124
125
|
}
|
|
126
|
+
/**
|
|
127
|
+
* Initialize an authenticated SDK instance with automatic token management.
|
|
128
|
+
*
|
|
129
|
+
* This method handles the two-step authentication process:
|
|
130
|
+
* 1. Checks for cached token (uses cache if valid)
|
|
131
|
+
* 2. If needed, creates temporary SDK to exchange API key for bearer token
|
|
132
|
+
* 3. Caches the token with expiration
|
|
133
|
+
* 4. Returns SDK instance with bearer token
|
|
134
|
+
*
|
|
135
|
+
* Tokens are automatically cached per API key/server combination.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```typescript
|
|
139
|
+
* const sdk = await OatFiSDK.initialize({
|
|
140
|
+
* apiKey: 'your-api-key',
|
|
141
|
+
* serverIdx: 0
|
|
142
|
+
* });
|
|
143
|
+
* ```
|
|
144
|
+
*/
|
|
145
|
+
static async initialize(config) {
|
|
146
|
+
const { apiKey, serverIdx = 0, serverURL, debug = false } = config;
|
|
147
|
+
// Create cache key based on config
|
|
148
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
149
|
+
// Check if we have a valid cached token
|
|
150
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
151
|
+
const now = Date.now();
|
|
152
|
+
let accessToken;
|
|
153
|
+
if (cached && cached.expiresAt > now + 60000) { // Refresh if expiring in <1min
|
|
154
|
+
accessToken = cached.token;
|
|
155
|
+
if (debug)
|
|
156
|
+
console.log("Using cached access token");
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
// Step 1: Create temporary SDK for token exchange
|
|
160
|
+
const authSDK = new OatFiSDK({
|
|
161
|
+
serverIdx,
|
|
162
|
+
serverURL,
|
|
163
|
+
...(debug && { debug: true }),
|
|
164
|
+
});
|
|
165
|
+
// Step 2: Exchange API key for bearer token
|
|
166
|
+
if (debug)
|
|
167
|
+
console.log("Exchanging API key for bearer token...");
|
|
168
|
+
const tokenResult = await authSDK.authentications.token({
|
|
169
|
+
apiKey: apiKey,
|
|
170
|
+
});
|
|
171
|
+
accessToken = tokenResult.accessToken;
|
|
172
|
+
// Cache the token (assume 1 hour expiry unless we get expiresIn)
|
|
173
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
174
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
175
|
+
token: accessToken,
|
|
176
|
+
expiresAt: now + expiresIn * 1000,
|
|
177
|
+
});
|
|
178
|
+
if (debug)
|
|
179
|
+
console.log("Access token obtained and cached");
|
|
180
|
+
}
|
|
181
|
+
// Step 3: Create the main SDK with bearer token
|
|
182
|
+
const sdk = new OatFiSDK({
|
|
183
|
+
bearer: accessToken,
|
|
184
|
+
serverIdx,
|
|
185
|
+
serverURL,
|
|
186
|
+
...(debug && { debug: true }),
|
|
187
|
+
});
|
|
188
|
+
// Store API key config for instance methods
|
|
189
|
+
sdk._apiKeyConfig = {
|
|
190
|
+
apiKey,
|
|
191
|
+
...(serverIdx !== undefined && { serverIdx }),
|
|
192
|
+
...(serverURL !== undefined && { serverURL }),
|
|
193
|
+
};
|
|
194
|
+
return sdk;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Create SDK from API key with automatic token exchange (simple factory method).
|
|
198
|
+
*
|
|
199
|
+
* This is a convenience method that calls initialize() internally.
|
|
200
|
+
* For advanced token management, use initialize() instead.
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const sdk = await OatFiSDK.createFromApiKey({
|
|
205
|
+
* apiKey: 'your-api-key',
|
|
206
|
+
* serverIdx: 0
|
|
207
|
+
* });
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
static async createFromApiKey(config) {
|
|
211
|
+
return OatFiSDK.initialize(config);
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Manually refresh the access token for a given configuration.
|
|
215
|
+
* This clears the cache and forces a new token exchange.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* ```typescript
|
|
219
|
+
* const sdk = await OatFiSDK.refreshToken({
|
|
220
|
+
* apiKey: 'your-api-key',
|
|
221
|
+
* serverIdx: 0
|
|
222
|
+
* });
|
|
223
|
+
* ```
|
|
224
|
+
*/
|
|
225
|
+
static async refreshToken(config) {
|
|
226
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
227
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
228
|
+
// Clear cache for this key
|
|
229
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
230
|
+
// Re-initialize to get fresh token
|
|
231
|
+
return OatFiSDK.initialize(config);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get the current cached access token for a configuration.
|
|
235
|
+
* Returns null if no token is cached or token is expired.
|
|
236
|
+
*
|
|
237
|
+
* @example
|
|
238
|
+
* ```typescript
|
|
239
|
+
* const token = OatFiSDK.getCachedToken({
|
|
240
|
+
* apiKey: 'your-api-key',
|
|
241
|
+
* serverIdx: 0
|
|
242
|
+
* });
|
|
243
|
+
* ```
|
|
244
|
+
*/
|
|
245
|
+
static getCachedToken(config) {
|
|
246
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
247
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
248
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
249
|
+
if (!cached)
|
|
250
|
+
return null;
|
|
251
|
+
const now = Date.now();
|
|
252
|
+
if (cached.expiresAt <= now) {
|
|
253
|
+
// Expired, remove from cache
|
|
254
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
255
|
+
return null;
|
|
256
|
+
}
|
|
257
|
+
return cached.token;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Clear the entire token cache.
|
|
261
|
+
* Useful when switching users or debugging.
|
|
262
|
+
*/
|
|
263
|
+
static clearTokenCache() {
|
|
264
|
+
OatFiSDK.tokenCache.clear();
|
|
265
|
+
}
|
|
266
|
+
// ==========================================
|
|
267
|
+
// Instance Methods (available on SDK instances)
|
|
268
|
+
// ==========================================
|
|
269
|
+
/**
|
|
270
|
+
* Refresh the access token for this SDK instance in place.
|
|
271
|
+
* Updates the bearer token on the current instance without creating a new one.
|
|
272
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
277
|
+
* // Later, when token expires:
|
|
278
|
+
* await sdk.refreshToken();
|
|
279
|
+
* // Continue using the same instance - no need to reassign
|
|
280
|
+
* const businesses = await sdk.businesses.list();
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
async refreshToken() {
|
|
284
|
+
if (!this._apiKeyConfig) {
|
|
285
|
+
throw new Error("Cannot refresh token: SDK was not initialized with an API key. "
|
|
286
|
+
+ "Use OatFiSDK.initialize() or OatFiSDK.createFromApiKey() instead.");
|
|
287
|
+
}
|
|
288
|
+
const { apiKey, serverIdx, serverURL } = this._apiKeyConfig;
|
|
289
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
290
|
+
// Clear cache for this key to force a fresh token
|
|
291
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
292
|
+
// Create temporary SDK for token exchange (without bearer token)
|
|
293
|
+
const authSDK = new OatFiSDK({
|
|
294
|
+
serverIdx,
|
|
295
|
+
serverURL,
|
|
296
|
+
...(this._options.debugLogger && { debug: true }),
|
|
297
|
+
});
|
|
298
|
+
// Exchange API key for bearer token
|
|
299
|
+
if (this._options.debugLogger) {
|
|
300
|
+
this._options.debugLogger.log("Exchanging API key for bearer token...");
|
|
301
|
+
}
|
|
302
|
+
const tokenResult = await authSDK.authentications.token({
|
|
303
|
+
apiKey: apiKey,
|
|
304
|
+
});
|
|
305
|
+
const accessToken = tokenResult.accessToken;
|
|
306
|
+
const now = Date.now();
|
|
307
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
308
|
+
// Update cache
|
|
309
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
310
|
+
token: accessToken,
|
|
311
|
+
expiresAt: now + expiresIn * 1000,
|
|
312
|
+
});
|
|
313
|
+
// Update bearer token in current instance
|
|
314
|
+
// Using type assertion since _options is readonly but we need to mutate bearer
|
|
315
|
+
this._options.bearer = accessToken;
|
|
316
|
+
if (this._options.debugLogger) {
|
|
317
|
+
this._options.debugLogger.log("Access token refreshed in place");
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Get the cached access token for this SDK instance.
|
|
322
|
+
* Returns null if no token is cached or token is expired.
|
|
323
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
324
|
+
*
|
|
325
|
+
* @example
|
|
326
|
+
* ```typescript
|
|
327
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
328
|
+
* const token = sdk.getCachedToken();
|
|
329
|
+
* ```
|
|
330
|
+
*/
|
|
331
|
+
getCachedToken() {
|
|
332
|
+
if (!this._apiKeyConfig) {
|
|
333
|
+
return null;
|
|
334
|
+
}
|
|
335
|
+
return OatFiSDK.getCachedToken({
|
|
336
|
+
apiKey: this._apiKeyConfig.apiKey,
|
|
337
|
+
...(this._apiKeyConfig.serverIdx !== undefined
|
|
338
|
+
&& { serverIdx: this._apiKeyConfig.serverIdx }),
|
|
339
|
+
...(this._apiKeyConfig.serverURL !== undefined
|
|
340
|
+
&& { serverURL: this._apiKeyConfig.serverURL }),
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Check if the current SDK instance has a valid cached token.
|
|
345
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
346
|
+
*
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
350
|
+
* if (await sdk.hasValidToken()) {
|
|
351
|
+
* // Token is valid
|
|
352
|
+
* }
|
|
353
|
+
* ```
|
|
354
|
+
*/
|
|
355
|
+
hasValidToken() {
|
|
356
|
+
return this.getCachedToken() !== null;
|
|
357
|
+
}
|
|
125
358
|
}
|
|
126
359
|
exports.OatFiSDK = OatFiSDK;
|
|
360
|
+
// #region sdk-class-body
|
|
361
|
+
/**
|
|
362
|
+
* Token cache for managing access tokens per API key/server combination.
|
|
363
|
+
* Map key format: "{serverURL || serverIdx}-{apiKeyLast10Chars}"
|
|
364
|
+
*/
|
|
365
|
+
OatFiSDK.tokenCache = new Map();
|
|
127
366
|
//# sourceMappingURL=sdk.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/sdk/sdk.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,4CAA2C;AAC3C,+DAAyD;AACzD,uDAAiD;AACjD,mEAA6D;AAC7D,uCAAiC;AACjC,2DAAqD;AACrD,6DAAuD;AACvD,mDAA6C;AAC7C,yDAAmD;AACnD,iFAA2E;AAC3E,yDAAmD;AACnD,6DAAuD;AACvD,qEAA+D;A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AI,CAAC,QAA6C,CAAC,MAAM,GAAG,WAAW,CAAC;QAEzE,IAAI,IAAI,CAAC,QAAQ,CAAC,WAAW,EAAE,CAAC;YAC9B,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,iCAAiC,CAAC,CAAC;QACnE,CAAC;IACH,CAAC;IAED;;;;;;;;;;OAUG;IACH,cAAc;QACZ,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,OAAO,IAAI,CAAC;QACd,CAAC;QAED,OAAO,QAAQ,CAAC,cAAc,CAAC;YAC7B,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;YACjC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,KAAK,SAAS;mBACzC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YACjD,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,KAAK,SAAS;mBACzC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC;IACxC,CAAC;;AAvcH,4BA0cC;AAlTC,yBAAyB;AAEzB;;;GAGG;AACY,mBAAU,GACvB,IAAI,GAAG,EAAE,CAAC"}
|
package/dist/esm/lib/config.d.ts
CHANGED
|
@@ -31,8 +31,8 @@ export declare function serverURLFromOptions(options: SDKOptions): URL | null;
|
|
|
31
31
|
export declare const SDK_METADATA: {
|
|
32
32
|
readonly language: "typescript";
|
|
33
33
|
readonly openapiDocVersion: "3.0.0";
|
|
34
|
-
readonly sdkVersion: "0.11.
|
|
34
|
+
readonly sdkVersion: "0.11.3";
|
|
35
35
|
readonly genVersion: "2.731.6";
|
|
36
|
-
readonly userAgent: "speakeasy-sdk/typescript 0.11.
|
|
36
|
+
readonly userAgent: "speakeasy-sdk/typescript 0.11.3 2.731.6 3.0.0 @oatfi/oatfi-sdk-ts";
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/esm/lib/config.js
CHANGED
|
@@ -35,8 +35,8 @@ export function serverURLFromOptions(options) {
|
|
|
35
35
|
export const SDK_METADATA = {
|
|
36
36
|
language: "typescript",
|
|
37
37
|
openapiDocVersion: "3.0.0",
|
|
38
|
-
sdkVersion: "0.11.
|
|
38
|
+
sdkVersion: "0.11.3",
|
|
39
39
|
genVersion: "2.731.6",
|
|
40
|
-
userAgent: "speakeasy-sdk/typescript 0.11.
|
|
40
|
+
userAgent: "speakeasy-sdk/typescript 0.11.3 2.731.6 3.0.0 @oatfi/oatfi-sdk-ts",
|
|
41
41
|
};
|
|
42
42
|
//# sourceMappingURL=config.js.map
|
package/dist/esm/sdk/sdk.d.ts
CHANGED
|
@@ -87,5 +87,144 @@ export declare class OatFiSDK extends ClientSDK {
|
|
|
87
87
|
get programSettings(): ProgramSettings;
|
|
88
88
|
private _users?;
|
|
89
89
|
get users(): Users;
|
|
90
|
+
/**
|
|
91
|
+
* Token cache for managing access tokens per API key/server combination.
|
|
92
|
+
* Map key format: "{serverURL || serverIdx}-{apiKeyLast10Chars}"
|
|
93
|
+
*/
|
|
94
|
+
private static tokenCache;
|
|
95
|
+
/**
|
|
96
|
+
* Stored API key configuration for instance methods.
|
|
97
|
+
* Only set when SDK is created via initialize() or createFromApiKey().
|
|
98
|
+
*/
|
|
99
|
+
private _apiKeyConfig?;
|
|
100
|
+
/**
|
|
101
|
+
* Initialize an authenticated SDK instance with automatic token management.
|
|
102
|
+
*
|
|
103
|
+
* This method handles the two-step authentication process:
|
|
104
|
+
* 1. Checks for cached token (uses cache if valid)
|
|
105
|
+
* 2. If needed, creates temporary SDK to exchange API key for bearer token
|
|
106
|
+
* 3. Caches the token with expiration
|
|
107
|
+
* 4. Returns SDK instance with bearer token
|
|
108
|
+
*
|
|
109
|
+
* Tokens are automatically cached per API key/server combination.
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* ```typescript
|
|
113
|
+
* const sdk = await OatFiSDK.initialize({
|
|
114
|
+
* apiKey: 'your-api-key',
|
|
115
|
+
* serverIdx: 0
|
|
116
|
+
* });
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
static initialize(config: {
|
|
120
|
+
apiKey: string;
|
|
121
|
+
serverIdx?: number;
|
|
122
|
+
serverURL?: string;
|
|
123
|
+
debug?: boolean;
|
|
124
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
125
|
+
timeoutMs?: number;
|
|
126
|
+
}): Promise<OatFiSDK>;
|
|
127
|
+
/**
|
|
128
|
+
* Create SDK from API key with automatic token exchange (simple factory method).
|
|
129
|
+
*
|
|
130
|
+
* This is a convenience method that calls initialize() internally.
|
|
131
|
+
* For advanced token management, use initialize() instead.
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* ```typescript
|
|
135
|
+
* const sdk = await OatFiSDK.createFromApiKey({
|
|
136
|
+
* apiKey: 'your-api-key',
|
|
137
|
+
* serverIdx: 0
|
|
138
|
+
* });
|
|
139
|
+
* ```
|
|
140
|
+
*/
|
|
141
|
+
static createFromApiKey(config: {
|
|
142
|
+
apiKey: string;
|
|
143
|
+
serverIdx?: number;
|
|
144
|
+
serverURL?: string;
|
|
145
|
+
debug?: boolean;
|
|
146
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
147
|
+
timeoutMs?: number;
|
|
148
|
+
}): Promise<OatFiSDK>;
|
|
149
|
+
/**
|
|
150
|
+
* Manually refresh the access token for a given configuration.
|
|
151
|
+
* This clears the cache and forces a new token exchange.
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* const sdk = await OatFiSDK.refreshToken({
|
|
156
|
+
* apiKey: 'your-api-key',
|
|
157
|
+
* serverIdx: 0
|
|
158
|
+
* });
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
static refreshToken(config: {
|
|
162
|
+
apiKey: string;
|
|
163
|
+
serverIdx?: number;
|
|
164
|
+
serverURL?: string;
|
|
165
|
+
debug?: boolean;
|
|
166
|
+
}): Promise<OatFiSDK>;
|
|
167
|
+
/**
|
|
168
|
+
* Get the current cached access token for a configuration.
|
|
169
|
+
* Returns null if no token is cached or token is expired.
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* ```typescript
|
|
173
|
+
* const token = OatFiSDK.getCachedToken({
|
|
174
|
+
* apiKey: 'your-api-key',
|
|
175
|
+
* serverIdx: 0
|
|
176
|
+
* });
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
static getCachedToken(config: {
|
|
180
|
+
apiKey: string;
|
|
181
|
+
serverIdx?: number;
|
|
182
|
+
serverURL?: string;
|
|
183
|
+
}): string | null;
|
|
184
|
+
/**
|
|
185
|
+
* Clear the entire token cache.
|
|
186
|
+
* Useful when switching users or debugging.
|
|
187
|
+
*/
|
|
188
|
+
static clearTokenCache(): void;
|
|
189
|
+
/**
|
|
190
|
+
* Refresh the access token for this SDK instance in place.
|
|
191
|
+
* Updates the bearer token on the current instance without creating a new one.
|
|
192
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```typescript
|
|
196
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
197
|
+
* // Later, when token expires:
|
|
198
|
+
* await sdk.refreshToken();
|
|
199
|
+
* // Continue using the same instance - no need to reassign
|
|
200
|
+
* const businesses = await sdk.businesses.list();
|
|
201
|
+
* ```
|
|
202
|
+
*/
|
|
203
|
+
refreshToken(): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Get the cached access token for this SDK instance.
|
|
206
|
+
* Returns null if no token is cached or token is expired.
|
|
207
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```typescript
|
|
211
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
212
|
+
* const token = sdk.getCachedToken();
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
getCachedToken(): string | null;
|
|
216
|
+
/**
|
|
217
|
+
* Check if the current SDK instance has a valid cached token.
|
|
218
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
223
|
+
* if (await sdk.hasValidToken()) {
|
|
224
|
+
* // Token is valid
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
hasValidToken(): boolean;
|
|
90
229
|
}
|
|
91
230
|
//# sourceMappingURL=sdk.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk/sdk.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,aAAa,EAAE,MAAM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UG;IACH,cAAc,IAAI,MAAM,GAAG,IAAI;IAc/B;;;;;;;;;;;OAWG;IACH,aAAa,IAAI,OAAO;CAKzB"}
|
package/dist/esm/sdk/sdk.js
CHANGED
|
@@ -31,6 +31,7 @@ import { PlatformSettings } from "./platformsettings.js";
|
|
|
31
31
|
import { Programs } from "./programs.js";
|
|
32
32
|
import { ProgramSettings } from "./programsettings.js";
|
|
33
33
|
import { Users } from "./users.js";
|
|
34
|
+
// #endregion imports
|
|
34
35
|
export class OatFiSDK extends ClientSDK {
|
|
35
36
|
get applications() {
|
|
36
37
|
return (this._applications ?? (this._applications = new Applications(this._options)));
|
|
@@ -119,5 +120,243 @@ export class OatFiSDK extends ClientSDK {
|
|
|
119
120
|
get users() {
|
|
120
121
|
return (this._users ?? (this._users = new Users(this._options)));
|
|
121
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Initialize an authenticated SDK instance with automatic token management.
|
|
125
|
+
*
|
|
126
|
+
* This method handles the two-step authentication process:
|
|
127
|
+
* 1. Checks for cached token (uses cache if valid)
|
|
128
|
+
* 2. If needed, creates temporary SDK to exchange API key for bearer token
|
|
129
|
+
* 3. Caches the token with expiration
|
|
130
|
+
* 4. Returns SDK instance with bearer token
|
|
131
|
+
*
|
|
132
|
+
* Tokens are automatically cached per API key/server combination.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* const sdk = await OatFiSDK.initialize({
|
|
137
|
+
* apiKey: 'your-api-key',
|
|
138
|
+
* serverIdx: 0
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
static async initialize(config) {
|
|
143
|
+
const { apiKey, serverIdx = 0, serverURL, debug = false } = config;
|
|
144
|
+
// Create cache key based on config
|
|
145
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
146
|
+
// Check if we have a valid cached token
|
|
147
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
148
|
+
const now = Date.now();
|
|
149
|
+
let accessToken;
|
|
150
|
+
if (cached && cached.expiresAt > now + 60000) { // Refresh if expiring in <1min
|
|
151
|
+
accessToken = cached.token;
|
|
152
|
+
if (debug)
|
|
153
|
+
console.log("Using cached access token");
|
|
154
|
+
}
|
|
155
|
+
else {
|
|
156
|
+
// Step 1: Create temporary SDK for token exchange
|
|
157
|
+
const authSDK = new OatFiSDK({
|
|
158
|
+
serverIdx,
|
|
159
|
+
serverURL,
|
|
160
|
+
...(debug && { debug: true }),
|
|
161
|
+
});
|
|
162
|
+
// Step 2: Exchange API key for bearer token
|
|
163
|
+
if (debug)
|
|
164
|
+
console.log("Exchanging API key for bearer token...");
|
|
165
|
+
const tokenResult = await authSDK.authentications.token({
|
|
166
|
+
apiKey: apiKey,
|
|
167
|
+
});
|
|
168
|
+
accessToken = tokenResult.accessToken;
|
|
169
|
+
// Cache the token (assume 1 hour expiry unless we get expiresIn)
|
|
170
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
171
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
172
|
+
token: accessToken,
|
|
173
|
+
expiresAt: now + expiresIn * 1000,
|
|
174
|
+
});
|
|
175
|
+
if (debug)
|
|
176
|
+
console.log("Access token obtained and cached");
|
|
177
|
+
}
|
|
178
|
+
// Step 3: Create the main SDK with bearer token
|
|
179
|
+
const sdk = new OatFiSDK({
|
|
180
|
+
bearer: accessToken,
|
|
181
|
+
serverIdx,
|
|
182
|
+
serverURL,
|
|
183
|
+
...(debug && { debug: true }),
|
|
184
|
+
});
|
|
185
|
+
// Store API key config for instance methods
|
|
186
|
+
sdk._apiKeyConfig = {
|
|
187
|
+
apiKey,
|
|
188
|
+
...(serverIdx !== undefined && { serverIdx }),
|
|
189
|
+
...(serverURL !== undefined && { serverURL }),
|
|
190
|
+
};
|
|
191
|
+
return sdk;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Create SDK from API key with automatic token exchange (simple factory method).
|
|
195
|
+
*
|
|
196
|
+
* This is a convenience method that calls initialize() internally.
|
|
197
|
+
* For advanced token management, use initialize() instead.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* ```typescript
|
|
201
|
+
* const sdk = await OatFiSDK.createFromApiKey({
|
|
202
|
+
* apiKey: 'your-api-key',
|
|
203
|
+
* serverIdx: 0
|
|
204
|
+
* });
|
|
205
|
+
* ```
|
|
206
|
+
*/
|
|
207
|
+
static async createFromApiKey(config) {
|
|
208
|
+
return OatFiSDK.initialize(config);
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Manually refresh the access token for a given configuration.
|
|
212
|
+
* This clears the cache and forces a new token exchange.
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const sdk = await OatFiSDK.refreshToken({
|
|
217
|
+
* apiKey: 'your-api-key',
|
|
218
|
+
* serverIdx: 0
|
|
219
|
+
* });
|
|
220
|
+
* ```
|
|
221
|
+
*/
|
|
222
|
+
static async refreshToken(config) {
|
|
223
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
224
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
225
|
+
// Clear cache for this key
|
|
226
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
227
|
+
// Re-initialize to get fresh token
|
|
228
|
+
return OatFiSDK.initialize(config);
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Get the current cached access token for a configuration.
|
|
232
|
+
* Returns null if no token is cached or token is expired.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```typescript
|
|
236
|
+
* const token = OatFiSDK.getCachedToken({
|
|
237
|
+
* apiKey: 'your-api-key',
|
|
238
|
+
* serverIdx: 0
|
|
239
|
+
* });
|
|
240
|
+
* ```
|
|
241
|
+
*/
|
|
242
|
+
static getCachedToken(config) {
|
|
243
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
244
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
245
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
246
|
+
if (!cached)
|
|
247
|
+
return null;
|
|
248
|
+
const now = Date.now();
|
|
249
|
+
if (cached.expiresAt <= now) {
|
|
250
|
+
// Expired, remove from cache
|
|
251
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
252
|
+
return null;
|
|
253
|
+
}
|
|
254
|
+
return cached.token;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Clear the entire token cache.
|
|
258
|
+
* Useful when switching users or debugging.
|
|
259
|
+
*/
|
|
260
|
+
static clearTokenCache() {
|
|
261
|
+
OatFiSDK.tokenCache.clear();
|
|
262
|
+
}
|
|
263
|
+
// ==========================================
|
|
264
|
+
// Instance Methods (available on SDK instances)
|
|
265
|
+
// ==========================================
|
|
266
|
+
/**
|
|
267
|
+
* Refresh the access token for this SDK instance in place.
|
|
268
|
+
* Updates the bearer token on the current instance without creating a new one.
|
|
269
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
270
|
+
*
|
|
271
|
+
* @example
|
|
272
|
+
* ```typescript
|
|
273
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
274
|
+
* // Later, when token expires:
|
|
275
|
+
* await sdk.refreshToken();
|
|
276
|
+
* // Continue using the same instance - no need to reassign
|
|
277
|
+
* const businesses = await sdk.businesses.list();
|
|
278
|
+
* ```
|
|
279
|
+
*/
|
|
280
|
+
async refreshToken() {
|
|
281
|
+
if (!this._apiKeyConfig) {
|
|
282
|
+
throw new Error("Cannot refresh token: SDK was not initialized with an API key. "
|
|
283
|
+
+ "Use OatFiSDK.initialize() or OatFiSDK.createFromApiKey() instead.");
|
|
284
|
+
}
|
|
285
|
+
const { apiKey, serverIdx, serverURL } = this._apiKeyConfig;
|
|
286
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
287
|
+
// Clear cache for this key to force a fresh token
|
|
288
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
289
|
+
// Create temporary SDK for token exchange (without bearer token)
|
|
290
|
+
const authSDK = new OatFiSDK({
|
|
291
|
+
serverIdx,
|
|
292
|
+
serverURL,
|
|
293
|
+
...(this._options.debugLogger && { debug: true }),
|
|
294
|
+
});
|
|
295
|
+
// Exchange API key for bearer token
|
|
296
|
+
if (this._options.debugLogger) {
|
|
297
|
+
this._options.debugLogger.log("Exchanging API key for bearer token...");
|
|
298
|
+
}
|
|
299
|
+
const tokenResult = await authSDK.authentications.token({
|
|
300
|
+
apiKey: apiKey,
|
|
301
|
+
});
|
|
302
|
+
const accessToken = tokenResult.accessToken;
|
|
303
|
+
const now = Date.now();
|
|
304
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
305
|
+
// Update cache
|
|
306
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
307
|
+
token: accessToken,
|
|
308
|
+
expiresAt: now + expiresIn * 1000,
|
|
309
|
+
});
|
|
310
|
+
// Update bearer token in current instance
|
|
311
|
+
// Using type assertion since _options is readonly but we need to mutate bearer
|
|
312
|
+
this._options.bearer = accessToken;
|
|
313
|
+
if (this._options.debugLogger) {
|
|
314
|
+
this._options.debugLogger.log("Access token refreshed in place");
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Get the cached access token for this SDK instance.
|
|
319
|
+
* Returns null if no token is cached or token is expired.
|
|
320
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
321
|
+
*
|
|
322
|
+
* @example
|
|
323
|
+
* ```typescript
|
|
324
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
325
|
+
* const token = sdk.getCachedToken();
|
|
326
|
+
* ```
|
|
327
|
+
*/
|
|
328
|
+
getCachedToken() {
|
|
329
|
+
if (!this._apiKeyConfig) {
|
|
330
|
+
return null;
|
|
331
|
+
}
|
|
332
|
+
return OatFiSDK.getCachedToken({
|
|
333
|
+
apiKey: this._apiKeyConfig.apiKey,
|
|
334
|
+
...(this._apiKeyConfig.serverIdx !== undefined
|
|
335
|
+
&& { serverIdx: this._apiKeyConfig.serverIdx }),
|
|
336
|
+
...(this._apiKeyConfig.serverURL !== undefined
|
|
337
|
+
&& { serverURL: this._apiKeyConfig.serverURL }),
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
/**
|
|
341
|
+
* Check if the current SDK instance has a valid cached token.
|
|
342
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
343
|
+
*
|
|
344
|
+
* @example
|
|
345
|
+
* ```typescript
|
|
346
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
347
|
+
* if (await sdk.hasValidToken()) {
|
|
348
|
+
* // Token is valid
|
|
349
|
+
* }
|
|
350
|
+
* ```
|
|
351
|
+
*/
|
|
352
|
+
hasValidToken() {
|
|
353
|
+
return this.getCachedToken() !== null;
|
|
354
|
+
}
|
|
122
355
|
}
|
|
356
|
+
// #region sdk-class-body
|
|
357
|
+
/**
|
|
358
|
+
* Token cache for managing access tokens per API key/server combination.
|
|
359
|
+
* Map key format: "{serverURL || serverIdx}-{apiKeyLast10Chars}"
|
|
360
|
+
*/
|
|
361
|
+
OatFiSDK.tokenCache = new Map();
|
|
123
362
|
//# sourceMappingURL=sdk.js.map
|
package/dist/esm/sdk/sdk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.js","sourceRoot":"","sources":["../../../src/sdk/sdk.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAA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O,QAAQ,CAAC,cAAc,CAAC;YAC7B,MAAM,EAAE,IAAI,CAAC,aAAa,CAAC,MAAM;YACjC,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,KAAK,SAAS;mBACzC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;YACjD,GAAG,CAAC,IAAI,CAAC,aAAa,CAAC,SAAS,KAAK,SAAS;mBACzC,EAAE,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,SAAS,EAAE,CAAC;SAClD,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,cAAc,EAAE,KAAK,IAAI,CAAC;IACxC,CAAC;;AA/SD,yBAAyB;AAEzB;;;GAGG;AACY,mBAAU,GACvB,IAAI,GAAG,EAAE,CAAC"}
|
package/jsr.json
CHANGED
package/package.json
CHANGED
package/src/lib/config.ts
CHANGED
|
@@ -69,8 +69,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
69
69
|
export const SDK_METADATA = {
|
|
70
70
|
language: "typescript",
|
|
71
71
|
openapiDocVersion: "3.0.0",
|
|
72
|
-
sdkVersion: "0.11.
|
|
72
|
+
sdkVersion: "0.11.3",
|
|
73
73
|
genVersion: "2.731.6",
|
|
74
74
|
userAgent:
|
|
75
|
-
"speakeasy-sdk/typescript 0.11.
|
|
75
|
+
"speakeasy-sdk/typescript 0.11.3 2.731.6 3.0.0 @oatfi/oatfi-sdk-ts",
|
|
76
76
|
} as const;
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -32,6 +32,9 @@ import { PlatformSettings } from "./platformsettings.js";
|
|
|
32
32
|
import { Programs } from "./programs.js";
|
|
33
33
|
import { ProgramSettings } from "./programsettings.js";
|
|
34
34
|
import { Users } from "./users.js";
|
|
35
|
+
// #region imports
|
|
36
|
+
import type { SDKOptions } from "../lib/config.js";
|
|
37
|
+
// #endregion imports
|
|
35
38
|
|
|
36
39
|
export class OatFiSDK extends ClientSDK {
|
|
37
40
|
private _applications?: Applications;
|
|
@@ -184,4 +187,311 @@ export class OatFiSDK extends ClientSDK {
|
|
|
184
187
|
get users(): Users {
|
|
185
188
|
return (this._users ??= new Users(this._options));
|
|
186
189
|
}
|
|
190
|
+
|
|
191
|
+
// #region sdk-class-body
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Token cache for managing access tokens per API key/server combination.
|
|
195
|
+
* Map key format: "{serverURL || serverIdx}-{apiKeyLast10Chars}"
|
|
196
|
+
*/
|
|
197
|
+
private static tokenCache: Map<string, { token: string; expiresAt: number }> =
|
|
198
|
+
new Map();
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Stored API key configuration for instance methods.
|
|
202
|
+
* Only set when SDK is created via initialize() or createFromApiKey().
|
|
203
|
+
*/
|
|
204
|
+
private _apiKeyConfig?: {
|
|
205
|
+
apiKey: string;
|
|
206
|
+
serverIdx?: number;
|
|
207
|
+
serverURL?: string;
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Initialize an authenticated SDK instance with automatic token management.
|
|
212
|
+
*
|
|
213
|
+
* This method handles the two-step authentication process:
|
|
214
|
+
* 1. Checks for cached token (uses cache if valid)
|
|
215
|
+
* 2. If needed, creates temporary SDK to exchange API key for bearer token
|
|
216
|
+
* 3. Caches the token with expiration
|
|
217
|
+
* 4. Returns SDK instance with bearer token
|
|
218
|
+
*
|
|
219
|
+
* Tokens are automatically cached per API key/server combination.
|
|
220
|
+
*
|
|
221
|
+
* @example
|
|
222
|
+
* ```typescript
|
|
223
|
+
* const sdk = await OatFiSDK.initialize({
|
|
224
|
+
* apiKey: 'your-api-key',
|
|
225
|
+
* serverIdx: 0
|
|
226
|
+
* });
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
static async initialize(config: {
|
|
230
|
+
apiKey: string;
|
|
231
|
+
serverIdx?: number;
|
|
232
|
+
serverURL?: string;
|
|
233
|
+
debug?: boolean;
|
|
234
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
235
|
+
timeoutMs?: number;
|
|
236
|
+
}): Promise<OatFiSDK> {
|
|
237
|
+
const { apiKey, serverIdx = 0, serverURL, debug = false } = config;
|
|
238
|
+
|
|
239
|
+
// Create cache key based on config
|
|
240
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
241
|
+
|
|
242
|
+
// Check if we have a valid cached token
|
|
243
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
244
|
+
const now = Date.now();
|
|
245
|
+
|
|
246
|
+
let accessToken: string;
|
|
247
|
+
|
|
248
|
+
if (cached && cached.expiresAt > now + 60000) { // Refresh if expiring in <1min
|
|
249
|
+
accessToken = cached.token;
|
|
250
|
+
if (debug) console.log("Using cached access token");
|
|
251
|
+
} else {
|
|
252
|
+
// Step 1: Create temporary SDK for token exchange
|
|
253
|
+
const authSDK = new OatFiSDK({
|
|
254
|
+
serverIdx,
|
|
255
|
+
serverURL,
|
|
256
|
+
...(debug && { debug: true }),
|
|
257
|
+
});
|
|
258
|
+
|
|
259
|
+
// Step 2: Exchange API key for bearer token
|
|
260
|
+
if (debug) console.log("Exchanging API key for bearer token...");
|
|
261
|
+
const tokenResult = await authSDK.authentications.token({
|
|
262
|
+
apiKey: apiKey,
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
accessToken = tokenResult.accessToken;
|
|
266
|
+
|
|
267
|
+
// Cache the token (assume 1 hour expiry unless we get expiresIn)
|
|
268
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
269
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
270
|
+
token: accessToken,
|
|
271
|
+
expiresAt: now + expiresIn * 1000,
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
if (debug) console.log("Access token obtained and cached");
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// Step 3: Create the main SDK with bearer token
|
|
278
|
+
const sdk = new OatFiSDK({
|
|
279
|
+
bearer: accessToken,
|
|
280
|
+
serverIdx,
|
|
281
|
+
serverURL,
|
|
282
|
+
...(debug && { debug: true }),
|
|
283
|
+
});
|
|
284
|
+
|
|
285
|
+
// Store API key config for instance methods
|
|
286
|
+
sdk._apiKeyConfig = {
|
|
287
|
+
apiKey,
|
|
288
|
+
...(serverIdx !== undefined && { serverIdx }),
|
|
289
|
+
...(serverURL !== undefined && { serverURL }),
|
|
290
|
+
};
|
|
291
|
+
|
|
292
|
+
return sdk;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Create SDK from API key with automatic token exchange (simple factory method).
|
|
297
|
+
*
|
|
298
|
+
* This is a convenience method that calls initialize() internally.
|
|
299
|
+
* For advanced token management, use initialize() instead.
|
|
300
|
+
*
|
|
301
|
+
* @example
|
|
302
|
+
* ```typescript
|
|
303
|
+
* const sdk = await OatFiSDK.createFromApiKey({
|
|
304
|
+
* apiKey: 'your-api-key',
|
|
305
|
+
* serverIdx: 0
|
|
306
|
+
* });
|
|
307
|
+
* ```
|
|
308
|
+
*/
|
|
309
|
+
static async createFromApiKey(config: {
|
|
310
|
+
apiKey: string;
|
|
311
|
+
serverIdx?: number;
|
|
312
|
+
serverURL?: string;
|
|
313
|
+
debug?: boolean;
|
|
314
|
+
retryConfig?: import("../lib/retries.js").RetryConfig;
|
|
315
|
+
timeoutMs?: number;
|
|
316
|
+
}): Promise<OatFiSDK> {
|
|
317
|
+
return OatFiSDK.initialize(config);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/**
|
|
321
|
+
* Manually refresh the access token for a given configuration.
|
|
322
|
+
* This clears the cache and forces a new token exchange.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```typescript
|
|
326
|
+
* const sdk = await OatFiSDK.refreshToken({
|
|
327
|
+
* apiKey: 'your-api-key',
|
|
328
|
+
* serverIdx: 0
|
|
329
|
+
* });
|
|
330
|
+
* ```
|
|
331
|
+
*/
|
|
332
|
+
static async refreshToken(config: {
|
|
333
|
+
apiKey: string;
|
|
334
|
+
serverIdx?: number;
|
|
335
|
+
serverURL?: string;
|
|
336
|
+
debug?: boolean;
|
|
337
|
+
}): Promise<OatFiSDK> {
|
|
338
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
339
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
340
|
+
|
|
341
|
+
// Clear cache for this key
|
|
342
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
343
|
+
|
|
344
|
+
// Re-initialize to get fresh token
|
|
345
|
+
return OatFiSDK.initialize(config);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* Get the current cached access token for a configuration.
|
|
350
|
+
* Returns null if no token is cached or token is expired.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* ```typescript
|
|
354
|
+
* const token = OatFiSDK.getCachedToken({
|
|
355
|
+
* apiKey: 'your-api-key',
|
|
356
|
+
* serverIdx: 0
|
|
357
|
+
* });
|
|
358
|
+
* ```
|
|
359
|
+
*/
|
|
360
|
+
static getCachedToken(config: {
|
|
361
|
+
apiKey: string;
|
|
362
|
+
serverIdx?: number;
|
|
363
|
+
serverURL?: string;
|
|
364
|
+
}): string | null {
|
|
365
|
+
const { apiKey, serverIdx = 0, serverURL } = config;
|
|
366
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
367
|
+
const cached = OatFiSDK.tokenCache.get(cacheKey);
|
|
368
|
+
|
|
369
|
+
if (!cached) return null;
|
|
370
|
+
|
|
371
|
+
const now = Date.now();
|
|
372
|
+
if (cached.expiresAt <= now) {
|
|
373
|
+
// Expired, remove from cache
|
|
374
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
375
|
+
return null;
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
return cached.token;
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
/**
|
|
382
|
+
* Clear the entire token cache.
|
|
383
|
+
* Useful when switching users or debugging.
|
|
384
|
+
*/
|
|
385
|
+
static clearTokenCache(): void {
|
|
386
|
+
OatFiSDK.tokenCache.clear();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
// ==========================================
|
|
390
|
+
// Instance Methods (available on SDK instances)
|
|
391
|
+
// ==========================================
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Refresh the access token for this SDK instance in place.
|
|
395
|
+
* Updates the bearer token on the current instance without creating a new one.
|
|
396
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
397
|
+
*
|
|
398
|
+
* @example
|
|
399
|
+
* ```typescript
|
|
400
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
401
|
+
* // Later, when token expires:
|
|
402
|
+
* await sdk.refreshToken();
|
|
403
|
+
* // Continue using the same instance - no need to reassign
|
|
404
|
+
* const businesses = await sdk.businesses.list();
|
|
405
|
+
* ```
|
|
406
|
+
*/
|
|
407
|
+
async refreshToken(): Promise<void> {
|
|
408
|
+
if (!this._apiKeyConfig) {
|
|
409
|
+
throw new Error(
|
|
410
|
+
"Cannot refresh token: SDK was not initialized with an API key. "
|
|
411
|
+
+ "Use OatFiSDK.initialize() or OatFiSDK.createFromApiKey() instead.",
|
|
412
|
+
);
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
const { apiKey, serverIdx, serverURL } = this._apiKeyConfig;
|
|
416
|
+
const cacheKey = `${serverURL || serverIdx}-${apiKey.slice(-10)}`;
|
|
417
|
+
|
|
418
|
+
// Clear cache for this key to force a fresh token
|
|
419
|
+
OatFiSDK.tokenCache.delete(cacheKey);
|
|
420
|
+
|
|
421
|
+
// Create temporary SDK for token exchange (without bearer token)
|
|
422
|
+
const authSDK = new OatFiSDK({
|
|
423
|
+
serverIdx,
|
|
424
|
+
serverURL,
|
|
425
|
+
...(this._options.debugLogger && { debug: true }),
|
|
426
|
+
});
|
|
427
|
+
|
|
428
|
+
// Exchange API key for bearer token
|
|
429
|
+
if (this._options.debugLogger) {
|
|
430
|
+
this._options.debugLogger.log("Exchanging API key for bearer token...");
|
|
431
|
+
}
|
|
432
|
+
const tokenResult = await authSDK.authentications.token({
|
|
433
|
+
apiKey: apiKey,
|
|
434
|
+
});
|
|
435
|
+
|
|
436
|
+
const accessToken = tokenResult.accessToken;
|
|
437
|
+
const now = Date.now();
|
|
438
|
+
const expiresIn = tokenResult.expiresIn || 3600;
|
|
439
|
+
|
|
440
|
+
// Update cache
|
|
441
|
+
OatFiSDK.tokenCache.set(cacheKey, {
|
|
442
|
+
token: accessToken,
|
|
443
|
+
expiresAt: now + expiresIn * 1000,
|
|
444
|
+
});
|
|
445
|
+
|
|
446
|
+
// Update bearer token in current instance
|
|
447
|
+
// Using type assertion since _options is readonly but we need to mutate bearer
|
|
448
|
+
(this._options as SDKOptions & { hooks?: unknown }).bearer = accessToken;
|
|
449
|
+
|
|
450
|
+
if (this._options.debugLogger) {
|
|
451
|
+
this._options.debugLogger.log("Access token refreshed in place");
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
/**
|
|
456
|
+
* Get the cached access token for this SDK instance.
|
|
457
|
+
* Returns null if no token is cached or token is expired.
|
|
458
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
459
|
+
*
|
|
460
|
+
* @example
|
|
461
|
+
* ```typescript
|
|
462
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
463
|
+
* const token = sdk.getCachedToken();
|
|
464
|
+
* ```
|
|
465
|
+
*/
|
|
466
|
+
getCachedToken(): string | null {
|
|
467
|
+
if (!this._apiKeyConfig) {
|
|
468
|
+
return null;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
return OatFiSDK.getCachedToken({
|
|
472
|
+
apiKey: this._apiKeyConfig.apiKey,
|
|
473
|
+
...(this._apiKeyConfig.serverIdx !== undefined
|
|
474
|
+
&& { serverIdx: this._apiKeyConfig.serverIdx }),
|
|
475
|
+
...(this._apiKeyConfig.serverURL !== undefined
|
|
476
|
+
&& { serverURL: this._apiKeyConfig.serverURL }),
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
/**
|
|
481
|
+
* Check if the current SDK instance has a valid cached token.
|
|
482
|
+
* Requires that the SDK was created via initialize() or createFromApiKey().
|
|
483
|
+
*
|
|
484
|
+
* @example
|
|
485
|
+
* ```typescript
|
|
486
|
+
* const sdk = await OatFiSDK.initialize({ apiKey: 'key', serverIdx: 0 });
|
|
487
|
+
* if (await sdk.hasValidToken()) {
|
|
488
|
+
* // Token is valid
|
|
489
|
+
* }
|
|
490
|
+
* ```
|
|
491
|
+
*/
|
|
492
|
+
hasValidToken(): boolean {
|
|
493
|
+
return this.getCachedToken() !== null;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
// #endregion sdk-class-body
|
|
187
497
|
}
|