teak-sdk 1.0.87 → 1.0.88
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 +3 -3
- package/{dist/sdk.js → index.js} +21 -4
- package/package.json +3 -18
- package/{dist/types/client → types}/authDiscovery.d.ts +3 -3
- package/types/convex/shared/oauthSurfaces.d.ts +2 -0
- package/{dist/types/client/sdk.d.ts → types/index.d.ts} +6 -5
- package/types/oauthCredentials.d.ts +10 -0
- /package/{dist/types → types/convex}/devUrls.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/boundedResponse.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/constants.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/fileFormats.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/filesOrigins.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/folders.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/markdown.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/oauthUrl.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/tags.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/utils/codePoints.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/utils/formatBytes.d.ts +0 -0
- /package/{dist/types → types/convex}/shared/workosResources.d.ts +0 -0
- /package/{dist/types/client → types}/workosConnect.d.ts +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# Teak SDK
|
|
2
2
|
|
|
3
|
-
Typed API client and OAuth discovery for Teak. The
|
|
4
|
-
|
|
5
|
-
dependencies
|
|
3
|
+
Typed API client and OAuth discovery for Teak. The source lives in `src/`, and
|
|
4
|
+
`bun run build` writes the npm package to `dist/`: one bundle with no runtime
|
|
5
|
+
dependencies, so it works without the Teak monorepo.
|
|
6
6
|
|
|
7
7
|
```ts
|
|
8
8
|
import { createTeakClient, discoverAuthServer } from "teak-sdk";
|
package/{dist/sdk.js → index.js}
RENAMED
|
@@ -46,6 +46,9 @@ var consumeResponseWithinLimit = async (response, maxBytes, consume) => {
|
|
|
46
46
|
};
|
|
47
47
|
var readResponseTextWithinLimit = (response, maxBytes) => consumeResponseWithinLimit(response, maxBytes, (boundedResponse) => boundedResponse.text());
|
|
48
48
|
|
|
49
|
+
// ../convex/shared/oauthSurfaces.ts
|
|
50
|
+
var OAUTH_SURFACES = ["cli", "raycast", "chrome", "firefox"];
|
|
51
|
+
|
|
49
52
|
// ../convex/devUrls.ts
|
|
50
53
|
var TEAK_DEV_DEPLOYMENT_NAME = "reminiscent-kangaroo-59";
|
|
51
54
|
var DEFAULT_TEAK_DEV_CONVEX_URL = `https://${TEAK_DEV_DEPLOYMENT_NAME}.convex.cloud`;
|
|
@@ -80,8 +83,7 @@ var workosResourcesFor = (url) => {
|
|
|
80
83
|
};
|
|
81
84
|
var PRODUCTION_WORKOS_RESOURCES = workosResourcesFor(PRODUCTION_WORKOS_RESOURCE_ORIGIN);
|
|
82
85
|
|
|
83
|
-
//
|
|
84
|
-
var OAUTH_SURFACES = ["cli", "raycast", "chrome", "firefox"];
|
|
86
|
+
// src/authDiscovery.ts
|
|
85
87
|
var caches = new WeakMap;
|
|
86
88
|
var object = (value) => {
|
|
87
89
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -195,7 +197,18 @@ function discoverAuthServer(siteUrl, options = {}) {
|
|
|
195
197
|
});
|
|
196
198
|
return pending;
|
|
197
199
|
}
|
|
198
|
-
//
|
|
200
|
+
// src/oauthCredentials.ts
|
|
201
|
+
var isWorkosCredential = (saved) => Boolean(saved?.origin && saved.issuer && saved.clientId?.startsWith("client_"));
|
|
202
|
+
var matchesBinding = (saved, current) => saved?.origin === current.origin && saved.issuer === current.issuer && saved.clientId === current.clientId;
|
|
203
|
+
var isRefreshTokenDead = (result) => !result.ok && result.reason === "refresh_token_rejected";
|
|
204
|
+
var refreshAndSave = async (refresh, save) => {
|
|
205
|
+
const renewed = await refresh();
|
|
206
|
+
if (renewed !== null && renewed !== undefined) {
|
|
207
|
+
await save(renewed);
|
|
208
|
+
}
|
|
209
|
+
return renewed;
|
|
210
|
+
};
|
|
211
|
+
// src/workosConnect.ts
|
|
199
212
|
var WORKOS_CONNECT_SCOPE = "openid profile email offline_access";
|
|
200
213
|
var MAX_RESPONSE_BYTES = 64 * 1024;
|
|
201
214
|
var MAX_TOKEN_LIFETIME_SECONDS = 365 * 24 * 3600;
|
|
@@ -903,7 +916,7 @@ var RESERVED_KEYWORDS = [
|
|
|
903
916
|
{ value: "trash", label: "Trash" }
|
|
904
917
|
];
|
|
905
918
|
|
|
906
|
-
//
|
|
919
|
+
// src/index.ts
|
|
907
920
|
var CARD_TYPES2 = cardTypes;
|
|
908
921
|
var CARD_SORTS = ["newest", "oldest", "relevance", "shuffle"];
|
|
909
922
|
var ERROR_CODES = [
|
|
@@ -1347,10 +1360,14 @@ export {
|
|
|
1347
1360
|
fetchConnectOwnerId,
|
|
1348
1361
|
formatBytes,
|
|
1349
1362
|
isCardType,
|
|
1363
|
+
isRefreshTokenDead,
|
|
1350
1364
|
isStringList,
|
|
1365
|
+
isWorkosCredential,
|
|
1366
|
+
matchesBinding,
|
|
1351
1367
|
normalizeLimit,
|
|
1352
1368
|
parseTags,
|
|
1353
1369
|
randomBase64Url,
|
|
1370
|
+
refreshAndSave,
|
|
1354
1371
|
requestConnectTokens,
|
|
1355
1372
|
staticTokenProvider,
|
|
1356
1373
|
validateOAuthUrl
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "teak-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.88",
|
|
4
4
|
"description": "Teak API client and OAuth discovery for browser and Node applications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -11,25 +11,10 @@
|
|
|
11
11
|
"type": "module",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
-
"types": "./
|
|
15
|
-
"import": "./
|
|
14
|
+
"types": "./types/index.d.ts",
|
|
15
|
+
"import": "./index.js"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
-
"files": [
|
|
19
|
-
"dist",
|
|
20
|
-
"README.md"
|
|
21
|
-
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "bun --no-env-file run build.ts",
|
|
24
|
-
"prepack": "bun run build",
|
|
25
|
-
"typecheck": "tsc build.ts ../convex/client/sdk.ts --strict --noEmit --moduleResolution bundler --module esnext --target es2022 --skipLibCheck --types bun,node"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@teak/convex": "workspace:*",
|
|
29
|
-
"@types/bun": "^1.4.0",
|
|
30
|
-
"@types/node": "^26.6.5",
|
|
31
|
-
"typescript": "^6.0.3"
|
|
32
|
-
},
|
|
33
18
|
"publishConfig": {
|
|
34
19
|
"access": "public",
|
|
35
20
|
"provenance": true
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
3
|
-
export
|
|
1
|
+
import { type OAuthSurface } from "./convex/shared/oauthSurfaces.js";
|
|
2
|
+
export { OAUTH_SURFACES, type OAuthSurface, } from "./convex/shared/oauthSurfaces.js";
|
|
3
|
+
export { validateOAuthUrl } from "./convex/shared/oauthUrl.js";
|
|
4
4
|
export interface AuthDiscovery {
|
|
5
5
|
readonly authorizationEndpoint: string;
|
|
6
6
|
readonly clients: Readonly<Record<OAuthSurface, string>>;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
export { formatBytes } from "
|
|
1
|
+
export { formatBytes } from "./convex/shared/utils/formatBytes.js";
|
|
2
2
|
export { type AuthDiscovery, discoverAuthServer, type OAuthSurface, validateOAuthUrl, } from "./authDiscovery.js";
|
|
3
|
+
export { type CredentialBinding, isRefreshTokenDead, isWorkosCredential, matchesBinding, refreshAndSave, } from "./oauthCredentials.js";
|
|
3
4
|
export { type ConnectTokenResult, type ConnectTokens, createConnectAuthorizeUrl, createPkceChallenge, disconnectConnectGrant, fetchConnectOwnerId, randomBase64Url, requestConnectTokens, WORKOS_CONNECT_SCOPE, } from "./workosConnect.js";
|
|
4
|
-
import { type CardType } from "
|
|
5
|
-
import type { FileKind, FilePreviewFacts } from "
|
|
6
|
-
import type { FOLDER_COLORS } from "
|
|
7
|
-
export type { CardType } from "
|
|
5
|
+
import { type CardType } from "./convex/shared/constants.js";
|
|
6
|
+
import type { FileKind, FilePreviewFacts } from "./convex/shared/fileFormats.js";
|
|
7
|
+
import type { FOLDER_COLORS } from "./convex/shared/folders.js";
|
|
8
|
+
export type { CardType } from "./convex/shared/constants.js";
|
|
8
9
|
export declare const CARD_TYPES: readonly ["text", "link", "image", "video", "audio", "document", "palette", "quote"];
|
|
9
10
|
export declare const CARD_SORTS: readonly ["newest", "oldest", "relevance", "shuffle"];
|
|
10
11
|
export declare const ERROR_CODES: readonly ["AUTH_REQUIRED", "BAD_REQUEST", "CARD_LIMIT_REACHED", "CONFIG_ERROR", "CONFLICT", "CONTENT_TOO_LARGE", "FILE_TOO_LARGE", "FOLDER_LIMIT", "FORBIDDEN", "IN_PROGRESS", "INTERNAL_ERROR", "INVALID_API_KEY", "INVALID_INPUT", "INVALID_STORAGE_KEY", "INVALID_UTF8", "LIMIT_REACHED", "METHOD_NOT_ALLOWED", "NETWORK_ERROR", "NOT_FOUND", "NO_CONTENT", "NOT_IN_TRASH", "PARSE_ERROR", "RATE_LIMITED", "REQUEST_FAILED", "SERVICE_UNAVAILABLE", "SMART_FOLDER", "TAG_EXISTS", "TAG_OPERATION_RUNNING", "TIMEOUT", "TYPE_MISMATCH", "UNAUTHORIZED", "UNSUPPORTED_TYPE"];
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ConnectTokenResult } from "./workosConnect.js";
|
|
2
|
+
export interface CredentialBinding {
|
|
3
|
+
clientId: string;
|
|
4
|
+
issuer: string;
|
|
5
|
+
origin: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const isWorkosCredential: (saved: Partial<CredentialBinding> | undefined) => saved is CredentialBinding;
|
|
8
|
+
export declare const matchesBinding: (saved: Partial<CredentialBinding> | undefined, current: CredentialBinding) => boolean;
|
|
9
|
+
export declare const isRefreshTokenDead: (result: ConnectTokenResult) => boolean;
|
|
10
|
+
export declare const refreshAndSave: <T>(refresh: () => Promise<T>, save: (renewed: NonNullable<T>) => unknown) => Promise<T>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|