@internetdata/internetdata 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -0
- package/dist/client.d.ts +10 -3
- package/dist/client.js +16 -72
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +28 -0
- package/dist/errors.js +50 -0
- package/dist/errors.js.map +1 -1
- package/dist/generated/index.d.ts +2 -2
- package/dist/generated/index.js +1 -1
- package/dist/generated/index.js.map +1 -1
- package/dist/generated/sdk.gen.d.ts +165 -3
- package/dist/generated/sdk.gen.js +224 -1
- package/dist/generated/sdk.gen.js.map +1 -1
- package/dist/generated/types.gen.d.ts +593 -11
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/oauth.d.ts +118 -0
- package/dist/oauth.js +240 -0
- package/dist/oauth.js.map +1 -0
- package/dist/transport.d.ts +18 -0
- package/dist/transport.js +82 -0
- package/dist/transport.js.map +1 -0
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -119,6 +119,27 @@ Note that `rate_limited` and `quota_exceeded` both arrive as HTTP 429 and are no
|
|
|
119
119
|
|
|
120
120
|
A failure part way through a transfer is rethrown as it arrived rather than wrapped: a reset socket and a full disk are different problems, and only one of them is ours.
|
|
121
121
|
|
|
122
|
+
### Sign in with OAuth (device flow)
|
|
123
|
+
|
|
124
|
+
A program running on the person's own machine can let them sign in with a browser and pick one of their API keys, instead of asking them to paste it:
|
|
125
|
+
|
|
126
|
+
```js
|
|
127
|
+
const client = new InternetData();
|
|
128
|
+
|
|
129
|
+
const device = await client.oauth.deviceAuthorization('your-client-id', {
|
|
130
|
+
scope: 'account.read apikeys.read apikeys.reveal',
|
|
131
|
+
});
|
|
132
|
+
console.log(`Open ${device.verification_uri} and enter ${device.user_code}`);
|
|
133
|
+
|
|
134
|
+
const token = await client.oauth.pollDeviceToken('your-client-id', device);
|
|
135
|
+
if (token.apikey === undefined) {
|
|
136
|
+
throw new Error("no API key came back: none was picked, or it can't be shown again");
|
|
137
|
+
}
|
|
138
|
+
const keyed = new InternetData({ apiKey: token.apikey });
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
A denied sign-in rejects with `OauthAccessDeniedError` and a code that ran out with `OauthExpiredTokenError`. Client IDs are issued on request from support@internetdata.io, and `client.oauth.revoke('your-client-id', token.refresh_token)` signs the machine out again.
|
|
142
|
+
|
|
122
143
|
## Other Libraries
|
|
123
144
|
|
|
124
145
|
There are official InternetData client libraries available for many languages including PHP, Python, Go, Java, Ruby, and many popular frameworks such as Django, Rails, and Laravel. See our GitHub at https://github.com/internetdata for more.
|
package/dist/client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { Writable } from 'node:stream';
|
|
2
2
|
import type { Client } from './generated/client/index.js';
|
|
3
|
+
import { OauthApi } from './oauth.js';
|
|
3
4
|
import type { Database, DatabaseFormat, DatabaseMetadata, DbChecksums, Download } from './types.js';
|
|
4
5
|
/**
|
|
5
6
|
* Where `download` puts the bytes: a path to write, or a stream you opened
|
|
@@ -45,13 +46,19 @@ export interface Options {
|
|
|
45
46
|
* one organization and nothing it learns may be reused for another key.
|
|
46
47
|
*
|
|
47
48
|
* The key is optional, and an absent one sends no `Authorization` header rather
|
|
48
|
-
* than an empty one. Every
|
|
49
|
-
*
|
|
50
|
-
* without a license is a product decision, not the
|
|
49
|
+
* than an empty one. `oauth` needs none. Every database published today is
|
|
50
|
+
* licensed, so a keyless `database` call is answered `401` for now; it exists
|
|
51
|
+
* because what the API serves without a license is a product decision, not the
|
|
52
|
+
* client's to refuse.
|
|
51
53
|
*/
|
|
52
54
|
export declare class InternetData {
|
|
53
55
|
/** The database catalog, downloads and their history. */
|
|
54
56
|
readonly database: DatabaseApi;
|
|
57
|
+
/**
|
|
58
|
+
* Sign a person in with the OAuth device flow, so a program on their own
|
|
59
|
+
* machine can be handed one of their API keys. Needs no API key.
|
|
60
|
+
*/
|
|
61
|
+
readonly oauth: OauthApi;
|
|
55
62
|
constructor(options?: Options);
|
|
56
63
|
}
|
|
57
64
|
/** The licensed database downloads. Access is granted by contract, not self-serve. */
|
package/dist/client.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import pRetry from 'p-retry';
|
|
2
1
|
import { createClient, createConfig } from './generated/client/index.js';
|
|
3
2
|
import { databaseChecksumV2, databaseMetadataV2, downloadDatabaseV2 as downloadRedirect, listDatabases, listDownloads, } from './generated/sdk.gen.js';
|
|
4
|
-
import { errorFromResponse, InternetDataError
|
|
3
|
+
import { errorFromResponse, InternetDataError } from './errors.js';
|
|
4
|
+
import { OauthApi } from './oauth.js';
|
|
5
|
+
import { deadline, unwrap, withRetry } from './transport.js';
|
|
5
6
|
import { DATABASE_FORMATS } from './types.js';
|
|
6
7
|
export const DEFAULT_BASE_URL = 'https://internetdata.io';
|
|
7
8
|
// Matches the other SDKs, whose HTTP clients default to 30s. Node's global
|
|
@@ -16,13 +17,19 @@ const DEFAULT_TIMEOUT_MS = 30_000;
|
|
|
16
17
|
* one organization and nothing it learns may be reused for another key.
|
|
17
18
|
*
|
|
18
19
|
* The key is optional, and an absent one sends no `Authorization` header rather
|
|
19
|
-
* than an empty one. Every
|
|
20
|
-
*
|
|
21
|
-
* without a license is a product decision, not the
|
|
20
|
+
* than an empty one. `oauth` needs none. Every database published today is
|
|
21
|
+
* licensed, so a keyless `database` call is answered `401` for now; it exists
|
|
22
|
+
* because what the API serves without a license is a product decision, not the
|
|
23
|
+
* client's to refuse.
|
|
22
24
|
*/
|
|
23
25
|
export class InternetData {
|
|
24
26
|
/** The database catalog, downloads and their history. */
|
|
25
27
|
database;
|
|
28
|
+
/**
|
|
29
|
+
* Sign a person in with the OAuth device flow, so a program on their own
|
|
30
|
+
* machine can be handed one of their API keys. Needs no API key.
|
|
31
|
+
*/
|
|
32
|
+
oauth;
|
|
26
33
|
constructor(options = {}) {
|
|
27
34
|
// Resolved once, because the download path calls object storage
|
|
28
35
|
// directly rather than through the generated client and has to reach
|
|
@@ -33,7 +40,10 @@ export class InternetData {
|
|
|
33
40
|
...(options.apiKey === undefined ? {} : { auth: bearerOnly(options.apiKey) }),
|
|
34
41
|
fetch: fetchImpl,
|
|
35
42
|
}));
|
|
36
|
-
|
|
43
|
+
const retries = options.retries ?? 2;
|
|
44
|
+
const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
|
|
45
|
+
this.database = new DatabaseApi(client, retries, timeoutMs, fetchImpl);
|
|
46
|
+
this.oauth = new OauthApi(client, retries, timeoutMs);
|
|
37
47
|
}
|
|
38
48
|
}
|
|
39
49
|
/** The licensed database downloads. Access is granted by contract, not self-serve. */
|
|
@@ -255,70 +265,4 @@ function assertFormat(format) {
|
|
|
255
265
|
}
|
|
256
266
|
throw new InternetDataError('bad_request', `invalid format ${JSON.stringify(format)}; must be one of ${DATABASE_FORMATS.join(', ')}`);
|
|
257
267
|
}
|
|
258
|
-
function unwrap(res) {
|
|
259
|
-
if (res.response === undefined) {
|
|
260
|
-
throw new InternetDataError('network', 'no response from the API');
|
|
261
|
-
}
|
|
262
|
-
if (!res.response.ok) {
|
|
263
|
-
throw errorFromResponse(res.response.status, res.response.headers, messageFromBody(res.error ?? res.data));
|
|
264
|
-
}
|
|
265
|
-
return res.data;
|
|
266
|
-
}
|
|
267
|
-
// p-retry owns the backoff schedule; the extra sleep here is what honors a
|
|
268
|
-
// server-supplied Retry-After, which p-retry has no way to know about. A 429
|
|
269
|
-
// carrying that header is the only 429 worth retrying, which is why the wait
|
|
270
|
-
// and the retry decision both key off the same field.
|
|
271
|
-
/**
|
|
272
|
-
* Bound one attempt, and report an expiry as our own error rather than the
|
|
273
|
-
* runtime's `TimeoutError`, whose message says nothing about which call gave up.
|
|
274
|
-
*
|
|
275
|
-
* Raced, not left to the signal alone: aborting releases the socket, but only
|
|
276
|
-
* a transport that HONORS the signal then settles, and a substituted `fetch`
|
|
277
|
-
* need not. Clearing the timer stops the losing side rejecting into nothing.
|
|
278
|
-
*/
|
|
279
|
-
async function deadline(timeoutMs, fn) {
|
|
280
|
-
const controller = new AbortController();
|
|
281
|
-
let timer;
|
|
282
|
-
const expiry = new Promise((_, reject) => {
|
|
283
|
-
timer = setTimeout(() => {
|
|
284
|
-
controller.abort();
|
|
285
|
-
reject(new InternetDataError('network', `request timed out after ${timeoutMs}ms`));
|
|
286
|
-
}, timeoutMs);
|
|
287
|
-
});
|
|
288
|
-
try {
|
|
289
|
-
return await Promise.race([fn(controller.signal), expiry]);
|
|
290
|
-
}
|
|
291
|
-
finally {
|
|
292
|
-
clearTimeout(timer);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
async function withRetry(retries, fn) {
|
|
296
|
-
try {
|
|
297
|
-
return await pRetry(fn, {
|
|
298
|
-
retries: retries,
|
|
299
|
-
shouldRetry: ({ error }) => !(error instanceof InternetDataError) || error.retryable,
|
|
300
|
-
onFailedAttempt: async ({ error }) => {
|
|
301
|
-
const seconds = error instanceof InternetDataError
|
|
302
|
-
? error.retryAfterSeconds
|
|
303
|
-
: undefined;
|
|
304
|
-
if (seconds !== undefined && seconds > 0) {
|
|
305
|
-
await new Promise((r) => setTimeout(r, seconds * 1000));
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
});
|
|
309
|
-
}
|
|
310
|
-
catch (err) {
|
|
311
|
-
throw asError(err);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
function asError(err) {
|
|
315
|
-
if (err instanceof InternetDataError) {
|
|
316
|
-
return err;
|
|
317
|
-
}
|
|
318
|
-
const cause = err?.cause;
|
|
319
|
-
if (cause instanceof InternetDataError) {
|
|
320
|
-
return cause;
|
|
321
|
-
}
|
|
322
|
-
return new InternetDataError('network', err instanceof Error ? err.message : String(err));
|
|
323
|
-
}
|
|
324
268
|
//# sourceMappingURL=client.js.map
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot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AK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;AACrE,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,YAAY,CAAC,MAAsB;IACxC,IAAI,gBAAgB,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,OAAO;IACX,CAAC;IACD,MAAM,IAAI,iBAAiB,CACvB,aAAa,EACb,kBAAkB,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,oBAAoB,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAC5F,CAAC;AACN,CAAC"}
|
package/dist/errors.d.ts
CHANGED
|
@@ -16,6 +16,34 @@ export declare class InternetDataError extends Error {
|
|
|
16
16
|
/** Whether retrying this exact request could succeed. */
|
|
17
17
|
get retryable(): boolean;
|
|
18
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* The authorization server refusing an OAuth request: a 4xx whose body names an
|
|
21
|
+
* OAuth error code. Never retryable as it stands.
|
|
22
|
+
*
|
|
23
|
+
* `kind` follows the status like any other failure's. A 401 here means the
|
|
24
|
+
* client ID is not registered, never the API key, which OAuth requests do not
|
|
25
|
+
* carry. The two codes a sign-in ends on have their own subclasses.
|
|
26
|
+
*/
|
|
27
|
+
export declare class OauthError extends InternetDataError {
|
|
28
|
+
/** The server's code, such as `authorization_pending` or `invalid_grant`, kept as sent. */
|
|
29
|
+
readonly errorCode: string;
|
|
30
|
+
/** The server's explanation, when it sent one. */
|
|
31
|
+
readonly errorDescription?: string;
|
|
32
|
+
constructor(errorCode: string, errorDescription?: string, status?: number);
|
|
33
|
+
get retryable(): boolean;
|
|
34
|
+
}
|
|
35
|
+
/** The person refused the sign-in. Its device code is spent, so a new attempt starts over. */
|
|
36
|
+
export declare class OauthAccessDeniedError extends OauthError {
|
|
37
|
+
constructor(errorDescription?: string, status?: number);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The device code is no longer valid: it expired, or was already used or
|
|
41
|
+
* refused. A poll that outlives the code raises this itself, with no `status`.
|
|
42
|
+
*/
|
|
43
|
+
export declare class OauthExpiredTokenError extends OauthError {
|
|
44
|
+
constructor(errorDescription?: string, status?: number);
|
|
45
|
+
}
|
|
46
|
+
export declare function oauthErrorFrom(errorCode: string, errorDescription: string | undefined, status: number): OauthError;
|
|
19
47
|
export declare function errorFromResponse(status: number, headers: {
|
|
20
48
|
get(name: string): string | null;
|
|
21
49
|
}, message?: string): InternetDataError;
|
package/dist/errors.js
CHANGED
|
@@ -14,6 +14,56 @@ export class InternetDataError extends Error {
|
|
|
14
14
|
return this.kind === 'rate_limited' || this.kind === 'server_error' || this.kind === 'network';
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* The authorization server refusing an OAuth request: a 4xx whose body names an
|
|
19
|
+
* OAuth error code. Never retryable as it stands.
|
|
20
|
+
*
|
|
21
|
+
* `kind` follows the status like any other failure's. A 401 here means the
|
|
22
|
+
* client ID is not registered, never the API key, which OAuth requests do not
|
|
23
|
+
* carry. The two codes a sign-in ends on have their own subclasses.
|
|
24
|
+
*/
|
|
25
|
+
export class OauthError extends InternetDataError {
|
|
26
|
+
/** The server's code, such as `authorization_pending` or `invalid_grant`, kept as sent. */
|
|
27
|
+
errorCode;
|
|
28
|
+
/** The server's explanation, when it sent one. */
|
|
29
|
+
errorDescription;
|
|
30
|
+
constructor(errorCode, errorDescription, status) {
|
|
31
|
+
super(status === undefined ? 'bad_request' : errorFromResponse(status, NO_HEADERS).kind, errorDescription === undefined ? errorCode : `${errorCode}: ${errorDescription}`, status);
|
|
32
|
+
this.name = 'OauthError';
|
|
33
|
+
this.errorCode = errorCode;
|
|
34
|
+
this.errorDescription = errorDescription;
|
|
35
|
+
}
|
|
36
|
+
get retryable() {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/** The person refused the sign-in. Its device code is spent, so a new attempt starts over. */
|
|
41
|
+
export class OauthAccessDeniedError extends OauthError {
|
|
42
|
+
constructor(errorDescription, status) {
|
|
43
|
+
super('access_denied', errorDescription, status);
|
|
44
|
+
this.name = 'OauthAccessDeniedError';
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The device code is no longer valid: it expired, or was already used or
|
|
49
|
+
* refused. A poll that outlives the code raises this itself, with no `status`.
|
|
50
|
+
*/
|
|
51
|
+
export class OauthExpiredTokenError extends OauthError {
|
|
52
|
+
constructor(errorDescription, status) {
|
|
53
|
+
super('expired_token', errorDescription, status);
|
|
54
|
+
this.name = 'OauthExpiredTokenError';
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
export function oauthErrorFrom(errorCode, errorDescription, status) {
|
|
58
|
+
if (errorCode === 'access_denied') {
|
|
59
|
+
return new OauthAccessDeniedError(errorDescription, status);
|
|
60
|
+
}
|
|
61
|
+
if (errorCode === 'expired_token') {
|
|
62
|
+
return new OauthExpiredTokenError(errorDescription, status);
|
|
63
|
+
}
|
|
64
|
+
return new OauthError(errorCode, errorDescription, status);
|
|
65
|
+
}
|
|
66
|
+
const NO_HEADERS = { get: () => null };
|
|
17
67
|
export function errorFromResponse(status, headers, message) {
|
|
18
68
|
const text = message ?? `request failed with status ${status}`;
|
|
19
69
|
const retryAfter = parseRetryAfter(headers.get('retry-after'));
|
package/dist/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAkBA,MAAM,OAAO,iBAAkB,SAAQ,KAAK;IAC/B,IAAI,CAAY;IAChB,MAAM,CAAU;IAChB,iBAAiB,CAAU;IAEpC,YAAY,IAAe,EAAE,OAAe,EAAE,MAAe,EAAE,iBAA0B;QACrF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;QAChC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,C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;IACrB,CAAC;IACD,MAAM,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,IAAI,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,OAAO,IAAI,CAAC,EAAE,CAAC;QAC3C,OAAO,OAAO,CAAC;IACnB,CAAC;IACD,wCAAwC;IACxC,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACrB,OAAO,SAAS,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { databaseChecksum, databaseChecksumV2, databaseDownload, databaseMetadata, databaseMetadataV2, downloadDatabaseV2, listDatabases, listDownloads, type Options } from './sdk.gen.js';
|
|
2
|
-
export type { ClientOptions, Database, DatabaseChecksumData, DatabaseChecksumError, DatabaseChecksumErrors, DatabaseChecksumResponse, DatabaseChecksumResponses, DatabaseChecksumV2Data, DatabaseChecksumV2Error, DatabaseChecksumV2Errors, DatabaseChecksumV2Response, DatabaseChecksumV2Responses, DatabaseDownloadData, DatabaseDownloadError, DatabaseDownloadErrors, DatabaseDownloadResponse, DatabaseDownloadResponses, DatabaseFormat, DatabaseMetadata, DatabaseMetadataColumn, DatabaseMetadataData, DatabaseMetadataError, DatabaseMetadataErrors, DatabaseMetadataResponse, DatabaseMetadataResponses, DatabaseMetadataV2Data, DatabaseMetadataV2Error, DatabaseMetadataV2Errors, DatabaseMetadataV2Response, DatabaseMetadataV2Responses, DatabaseVersion, DbChecksums, DbChecksumSuccessResponse, DbFormat, DbId, DbInvalidApiKeyError, DbInvalidFormatError, DbInvalidIdError, DbMetadata, DbMetadataSuccessResponse, DbNotFoundError, DbUnauthorizedIdError, Download, DownloadDatabaseV2Data, DownloadDatabaseV2Error, DownloadDatabaseV2Errors, Error, ListDatabasesData, ListDatabasesError, ListDatabasesErrors, ListDatabasesResponse, ListDatabasesResponses, ListDownloadsData, ListDownloadsError, ListDownloadsErrors, ListDownloadsResponse, ListDownloadsResponses, Standing } from './types.gen.js';
|
|
1
|
+
export { accountCreateApikey, accountIdentity, accountListApikeys, accountOrg, accountOrgMembers, accountRevealApikey, accountRevokeApikey, accountRotateApikey, databaseChecksum, databaseChecksumV2, databaseDownload, databaseMetadata, databaseMetadataV2, downloadDatabaseV2, listDatabases, listDownloads, oauthAuthorize, oauthDeviceAuthorization, oauthMetadata, oauthRevoke, oauthToken, type Options } from './sdk.gen.js';
|
|
2
|
+
export type { AccountCreateApikeyData, AccountCreateApikeyError, AccountCreateApikeyErrors, AccountCreateApikeyRequest, AccountCreateApikeyResponse, AccountCreateApikeyResponses, AccountCreatedApikey, AccountIdentityData, AccountIdentityError, AccountIdentityErrors, AccountIdentityResponse, AccountIdentityResponses, AccountListApikeysData, AccountListApikeysError, AccountListApikeysErrors, AccountListApikeysResponse, AccountListApikeysResponses, AccountOrg, AccountOrgData, AccountOrgError, AccountOrgErrors, AccountOrgMembersData, AccountOrgMembersError, AccountOrgMembersErrors, AccountOrgMembersResponse, AccountOrgMembersResponses, AccountOrgRef, AccountOrgResponse, AccountOrgResponses, AccountOrgWrap, AccountRc, AccountRevealApikeyData, AccountRevealApikeyError, AccountRevealApikeyErrors, AccountRevealApikeyResponse, AccountRevealApikeyResponses, AccountRevealedApikey, AccountRevokeApikeyData, AccountRevokeApikeyError, AccountRevokeApikeyErrors, AccountRevokeApikeyResponse, AccountRevokeApikeyResponses, AccountRotateApikeyData, AccountRotateApikeyError, AccountRotateApikeyErrors, AccountRotateApikeyResponse, AccountRotateApikeyResponses, AccountUser, ApikeyDetail, ApikeyIdParam, ApikeyList, ClientOptions, Database, DatabaseChecksumData, DatabaseChecksumError, DatabaseChecksumErrors, DatabaseChecksumResponse, DatabaseChecksumResponses, DatabaseChecksumV2Data, DatabaseChecksumV2Error, DatabaseChecksumV2Errors, DatabaseChecksumV2Response, DatabaseChecksumV2Responses, DatabaseDownloadData, DatabaseDownloadError, DatabaseDownloadErrors, DatabaseDownloadResponse, DatabaseDownloadResponses, DatabaseFormat, DatabaseMetadata, DatabaseMetadataColumn, DatabaseMetadataData, DatabaseMetadataError, DatabaseMetadataErrors, DatabaseMetadataResponse, DatabaseMetadataResponses, DatabaseMetadataV2Data, DatabaseMetadataV2Error, DatabaseMetadataV2Errors, DatabaseMetadataV2Response, DatabaseMetadataV2Responses, DatabaseVersion, DbChecksums, DbChecksumSuccessResponse, DbFormat, DbId, DbInvalidApiKeyError, DbInvalidFormatError, DbInvalidIdError, DbMetadata, DbMetadataSuccessResponse, DbNotFoundError, DbUnauthorizedIdError, DeviceAuthorization, DeviceAuthorizationRequest, Download, DownloadDatabaseV2Data, DownloadDatabaseV2Error, DownloadDatabaseV2Errors, Error, Identity, ListDatabasesData, ListDatabasesError, ListDatabasesErrors, ListDatabasesResponse, ListDatabasesResponses, ListDownloadsData, ListDownloadsError, ListDownloadsErrors, ListDownloadsResponse, ListDownloadsResponses, OauthAuthorizeData, OauthAuthorizeErrors, OauthDeviceAuthorizationData, OauthDeviceAuthorizationError, OauthDeviceAuthorizationErrors, OauthDeviceAuthorizationResponse, OauthDeviceAuthorizationResponses, OauthError, OauthMetadata, OauthMetadataData, OauthMetadataResponse, OauthMetadataResponses, OauthRevokeData, OauthRevokeResponse, OauthRevokeResponses, OauthTokenData, OauthTokenError, OauthTokenErrors, OauthTokenResponse, OauthTokenResponses, RevokeRequest, Standing, TokenRequest, TokenResponse } from './types.gen.js';
|
package/dist/generated/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This file is auto-generated by @hey-api/openapi-ts
|
|
2
|
-
export { databaseChecksum, databaseChecksumV2, databaseDownload, databaseMetadata, databaseMetadataV2, downloadDatabaseV2, listDatabases, listDownloads } from './sdk.gen.js';
|
|
2
|
+
export { accountCreateApikey, accountIdentity, accountListApikeys, accountOrg, accountOrgMembers, accountRevealApikey, accountRevokeApikey, accountRotateApikey, databaseChecksum, databaseChecksumV2, databaseDownload, databaseMetadata, databaseMetadataV2, downloadDatabaseV2, listDatabases, listDownloads, oauthAuthorize, oauthDeviceAuthorization, oauthMetadata, oauthRevoke, oauthToken } from './sdk.gen.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAgB,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/generated/index.ts"],"names":[],"mappings":"AAAA,qDAAqD;AAErD,OAAO,EAAE,mBAAmB,EAAE,eAAe,EAAE,kBAAkB,EAAE,UAAU,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,wBAAwB,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,cAAc,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type
|
|
2
|
-
import type { DatabaseChecksumData, DatabaseChecksumErrors, DatabaseChecksumResponses, DatabaseChecksumV2Data, DatabaseChecksumV2Errors, DatabaseChecksumV2Responses, DatabaseDownloadData, DatabaseDownloadErrors, DatabaseDownloadResponses, DatabaseMetadataData, DatabaseMetadataErrors, DatabaseMetadataResponses, DatabaseMetadataV2Data, DatabaseMetadataV2Errors, DatabaseMetadataV2Responses, DownloadDatabaseV2Data, DownloadDatabaseV2Errors, ListDatabasesData, ListDatabasesErrors, ListDatabasesResponses, ListDownloadsData, ListDownloadsErrors, ListDownloadsResponses } from './types.gen.js';
|
|
1
|
+
import { type Client, type ClientMeta, type Options as Options2, type RequestResult, type TDataShape } from './client/index.js';
|
|
2
|
+
import type { AccountCreateApikeyData, AccountCreateApikeyErrors, AccountCreateApikeyResponses, AccountIdentityData, AccountIdentityErrors, AccountIdentityResponses, AccountListApikeysData, AccountListApikeysErrors, AccountListApikeysResponses, AccountOrgData, AccountOrgErrors, AccountOrgMembersData, AccountOrgMembersErrors, AccountOrgMembersResponses, AccountOrgResponses, AccountRevealApikeyData, AccountRevealApikeyErrors, AccountRevealApikeyResponses, AccountRevokeApikeyData, AccountRevokeApikeyErrors, AccountRevokeApikeyResponses, AccountRotateApikeyData, AccountRotateApikeyErrors, AccountRotateApikeyResponses, DatabaseChecksumData, DatabaseChecksumErrors, DatabaseChecksumResponses, DatabaseChecksumV2Data, DatabaseChecksumV2Errors, DatabaseChecksumV2Responses, DatabaseDownloadData, DatabaseDownloadErrors, DatabaseDownloadResponses, DatabaseMetadataData, DatabaseMetadataErrors, DatabaseMetadataResponses, DatabaseMetadataV2Data, DatabaseMetadataV2Errors, DatabaseMetadataV2Responses, DownloadDatabaseV2Data, DownloadDatabaseV2Errors, ListDatabasesData, ListDatabasesErrors, ListDatabasesResponses, ListDownloadsData, ListDownloadsErrors, ListDownloadsResponses, OauthAuthorizeData, OauthAuthorizeErrors, OauthDeviceAuthorizationData, OauthDeviceAuthorizationErrors, OauthDeviceAuthorizationResponses, OauthMetadataData, OauthMetadataResponses, OauthRevokeData, OauthRevokeResponses, OauthTokenData, OauthTokenErrors, OauthTokenResponses } from './types.gen.js';
|
|
3
3
|
export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends boolean = boolean, TResponse = unknown> = Options2<TData, ThrowOnError, TResponse> & {
|
|
4
4
|
/**
|
|
5
5
|
* You can provide a client instance returned by `createClient()` instead of
|
|
@@ -16,7 +16,7 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
|
|
|
16
16
|
/**
|
|
17
17
|
* List
|
|
18
18
|
*
|
|
19
|
-
* The whole published catalog, with your organization's
|
|
19
|
+
* The whole published catalog, with your organization's license beside
|
|
20
20
|
* each entry, so `standing` says whether a database is yours today
|
|
21
21
|
* (`licensed`), was (`expired`), or has never been bought (`unlicensed`).
|
|
22
22
|
*
|
|
@@ -82,3 +82,165 @@ export declare const databaseChecksum: <ThrowOnError extends boolean = false>(op
|
|
|
82
82
|
*
|
|
83
83
|
*/
|
|
84
84
|
export declare const databaseMetadata: <ThrowOnError extends boolean = false>(options: Options<DatabaseMetadataData, ThrowOnError>) => RequestResult<DatabaseMetadataResponses, DatabaseMetadataErrors, ThrowOnError>;
|
|
85
|
+
/**
|
|
86
|
+
* Identity
|
|
87
|
+
*
|
|
88
|
+
* The identity behind this credential: what it is, the organization it is
|
|
89
|
+
* scoped to, and the scopes it currently holds.
|
|
90
|
+
*
|
|
91
|
+
* `user` is present for an OAuth token and ABSENT for an API key, which
|
|
92
|
+
* has an organization but no person behind it. `credential.kind` says
|
|
93
|
+
* which you are holding, so a client can branch without guessing from a
|
|
94
|
+
* missing field.
|
|
95
|
+
*
|
|
96
|
+
* Narrower than what the console shows its own user on purpose: an
|
|
97
|
+
* integration needs a name to display and an organization to address, not
|
|
98
|
+
* a profile. The `scopes` array is what the credential may do RIGHT NOW,
|
|
99
|
+
* so a client can render its own capabilities rather than discovering
|
|
100
|
+
* them from a 403.
|
|
101
|
+
*
|
|
102
|
+
*/
|
|
103
|
+
export declare const accountIdentity: <ThrowOnError extends boolean = false>(options?: Options<AccountIdentityData, ThrowOnError>) => RequestResult<AccountIdentityResponses, AccountIdentityErrors, ThrowOnError>;
|
|
104
|
+
/**
|
|
105
|
+
* Organization
|
|
106
|
+
*
|
|
107
|
+
* The organization this credential is scoped to.
|
|
108
|
+
*
|
|
109
|
+
* There is no way to name a different one. A credential describes exactly
|
|
110
|
+
* one organization, so an identifier in the path could only ever be your
|
|
111
|
+
* own or a refusal.
|
|
112
|
+
*
|
|
113
|
+
*/
|
|
114
|
+
export declare const accountOrg: <ThrowOnError extends boolean = false>(options?: Options<AccountOrgData, ThrowOnError>) => RequestResult<AccountOrgResponses, AccountOrgErrors, ThrowOnError>;
|
|
115
|
+
/**
|
|
116
|
+
* Members
|
|
117
|
+
*
|
|
118
|
+
* Read-only. Adding or removing a member is an invitation flow with email
|
|
119
|
+
* in the middle rather than a POST, and modelling it as one here would
|
|
120
|
+
* promise something this API does not do.
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
export declare const accountOrgMembers: <ThrowOnError extends boolean = false>(options?: Options<AccountOrgMembersData, ThrowOnError>) => RequestResult<AccountOrgMembersResponses, AccountOrgMembersErrors, ThrowOnError>;
|
|
124
|
+
/**
|
|
125
|
+
* List
|
|
126
|
+
*
|
|
127
|
+
* Metadata only. A key's secret is never in a list - not here and not in
|
|
128
|
+
* the console - because a list is the response that ends up in logs,
|
|
129
|
+
* caches and support tickets.
|
|
130
|
+
*
|
|
131
|
+
* `retrievable` says whether the secret could still be read back at all.
|
|
132
|
+
* A key issued before this product stored secrets recoverably was never
|
|
133
|
+
* kept, so `reveal` will refuse it permanently; rotating produces one
|
|
134
|
+
* that can be read.
|
|
135
|
+
*
|
|
136
|
+
*/
|
|
137
|
+
export declare const accountListApikeys: <ThrowOnError extends boolean = false>(options?: Options<AccountListApikeysData, ThrowOnError>) => RequestResult<AccountListApikeysResponses, AccountListApikeysErrors, ThrowOnError>;
|
|
138
|
+
/**
|
|
139
|
+
* Create
|
|
140
|
+
*
|
|
141
|
+
* Creates a key and returns its secret.
|
|
142
|
+
*
|
|
143
|
+
* This is the ONLY response that ever carries the secret, and only
|
|
144
|
+
* because this is the moment it comes into existence. Store it now.
|
|
145
|
+
*
|
|
146
|
+
*/
|
|
147
|
+
export declare const accountCreateApikey: <ThrowOnError extends boolean = false>(options: Options<AccountCreateApikeyData, ThrowOnError>) => RequestResult<AccountCreateApikeyResponses, AccountCreateApikeyErrors, ThrowOnError>;
|
|
148
|
+
/**
|
|
149
|
+
* Rotate
|
|
150
|
+
*
|
|
151
|
+
* Replaces the secret behind a key, keeping its id, name and settings.
|
|
152
|
+
* The previous secret stops working immediately.
|
|
153
|
+
*
|
|
154
|
+
*/
|
|
155
|
+
export declare const accountRotateApikey: <ThrowOnError extends boolean = false>(options: Options<AccountRotateApikeyData, ThrowOnError>) => RequestResult<AccountRotateApikeyResponses, AccountRotateApikeyErrors, ThrowOnError>;
|
|
156
|
+
/**
|
|
157
|
+
* Revoke
|
|
158
|
+
*
|
|
159
|
+
* Stops the key working. Revocation is soft: the key stays listed with a
|
|
160
|
+
* `revoked_at`, because the organization still owns whatever it did while
|
|
161
|
+
* it was alive.
|
|
162
|
+
*
|
|
163
|
+
*/
|
|
164
|
+
export declare const accountRevokeApikey: <ThrowOnError extends boolean = false>(options: Options<AccountRevokeApikeyData, ThrowOnError>) => RequestResult<AccountRevokeApikeyResponses, AccountRevokeApikeyErrors, ThrowOnError>;
|
|
165
|
+
/**
|
|
166
|
+
* Reveal
|
|
167
|
+
*
|
|
168
|
+
* Returns an existing key's secret.
|
|
169
|
+
*
|
|
170
|
+
* Its own scope rather than part of `apikeys.manage`, because the two are
|
|
171
|
+
* different acts: rotating replaces a secret you never see, while this
|
|
172
|
+
* hands one over.
|
|
173
|
+
*
|
|
174
|
+
* Refused with `NOT_RETRIEVABLE` for a key issued before this product
|
|
175
|
+
* stored secrets recoverably - that secret was never kept, so no retry
|
|
176
|
+
* will ever produce it. Rotate the key instead.
|
|
177
|
+
*
|
|
178
|
+
*/
|
|
179
|
+
export declare const accountRevealApikey: <ThrowOnError extends boolean = false>(options: Options<AccountRevealApikeyData, ThrowOnError>) => RequestResult<AccountRevealApikeyResponses, AccountRevealApikeyErrors, ThrowOnError>;
|
|
180
|
+
/**
|
|
181
|
+
* Discovery
|
|
182
|
+
*
|
|
183
|
+
* RFC 8414 authorization server metadata: the endpoints, the grant types
|
|
184
|
+
* and the scopes this server supports.
|
|
185
|
+
*
|
|
186
|
+
* Read this rather than hardcoding endpoints. It is also served at
|
|
187
|
+
* `/.well-known/openid-configuration`, identically, because several
|
|
188
|
+
* clients probe that path first.
|
|
189
|
+
*
|
|
190
|
+
*/
|
|
191
|
+
export declare const oauthMetadata: <ThrowOnError extends boolean = false>(options?: Options<OauthMetadataData, ThrowOnError>) => RequestResult<OauthMetadataResponses, unknown, ThrowOnError>;
|
|
192
|
+
/**
|
|
193
|
+
* Device authorization
|
|
194
|
+
*
|
|
195
|
+
* Starts the device flow. Show the `user_code` to the person and send them
|
|
196
|
+
* to `verification_uri`; `verification_uri_complete` has the code already
|
|
197
|
+
* embedded, which is what to open if you can open a browser at all.
|
|
198
|
+
*
|
|
199
|
+
* Then poll `/oauth/token`, no faster than `interval` seconds.
|
|
200
|
+
*
|
|
201
|
+
*/
|
|
202
|
+
export declare const oauthDeviceAuthorization: <ThrowOnError extends boolean = false>(options: Options<OauthDeviceAuthorizationData, ThrowOnError>) => RequestResult<OauthDeviceAuthorizationResponses, OauthDeviceAuthorizationErrors, ThrowOnError>;
|
|
203
|
+
/**
|
|
204
|
+
* Authorize
|
|
205
|
+
*
|
|
206
|
+
* The browser entry point for the authorization-code flow. This is a
|
|
207
|
+
* redirect target, not something to call from code.
|
|
208
|
+
*
|
|
209
|
+
* An unknown `client_id` or an unregistered `redirect_uri` is shown to the
|
|
210
|
+
* USER and never redirected, because sending an error to an address we
|
|
211
|
+
* have not verified belongs to you is how an open redirector works.
|
|
212
|
+
* Everything else comes back to your `redirect_uri` with `error`, your
|
|
213
|
+
* `state`, and `iss`.
|
|
214
|
+
*
|
|
215
|
+
*/
|
|
216
|
+
export declare const oauthAuthorize: <ThrowOnError extends boolean = false>(options: Options<OauthAuthorizeData, ThrowOnError>) => RequestResult<unknown, OauthAuthorizeErrors, ThrowOnError>;
|
|
217
|
+
/**
|
|
218
|
+
* Token
|
|
219
|
+
*
|
|
220
|
+
* Three grant types.
|
|
221
|
+
*
|
|
222
|
+
* `urn:ietf:params:oauth:grant-type:device_code` polls a device
|
|
223
|
+
* authorization. Until the person approves it answers
|
|
224
|
+
* `authorization_pending`; poll faster than `interval` and it answers
|
|
225
|
+
* `slow_down`, which means widen your interval and keep it widened.
|
|
226
|
+
*
|
|
227
|
+
* `authorization_code` exchanges a code from `/oauth/authorize`, with the
|
|
228
|
+
* `code_verifier` matching the challenge you sent.
|
|
229
|
+
*
|
|
230
|
+
* `refresh_token` exchanges a refresh token. The presented token is
|
|
231
|
+
* consumed whatever happens next, so store the new one before using it.
|
|
232
|
+
*
|
|
233
|
+
*/
|
|
234
|
+
export declare const oauthToken: <ThrowOnError extends boolean = false>(options: Options<OauthTokenData, ThrowOnError>) => RequestResult<OauthTokenResponses, OauthTokenErrors, ThrowOnError>;
|
|
235
|
+
/**
|
|
236
|
+
* Revoke
|
|
237
|
+
*
|
|
238
|
+
* RFC 7009. Always answers 200, including for a token that was never
|
|
239
|
+
* valid - an endpoint that distinguished the two would be a way to test
|
|
240
|
+
* whether a stolen string is a live credential.
|
|
241
|
+
*
|
|
242
|
+
* Revoking a REFRESH token ends the whole authorization and takes its
|
|
243
|
+
* access tokens with it. Revoking an access token affects only that token.
|
|
244
|
+
*
|
|
245
|
+
*/
|
|
246
|
+
export declare const oauthRevoke: <ThrowOnError extends boolean = false>(options: Options<OauthRevokeData, ThrowOnError>) => RequestResult<OauthRevokeResponses, unknown, ThrowOnError>;
|