latchkey 0.1.3 → 0.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/LICENSE +1 -1
- package/README.md +21 -5
- package/dist/integrations/SKILL.md +71 -0
- package/dist/package.json +67 -0
- package/dist/scripts/recordBrowserSession.js +1 -1
- package/dist/scripts/recordBrowserSession.js.map +1 -1
- package/dist/src/apiCredentials.d.ts +83 -1
- package/dist/src/apiCredentials.d.ts.map +1 -1
- package/dist/src/apiCredentials.js +83 -1
- package/dist/src/apiCredentials.js.map +1 -1
- package/dist/src/browserConfig.d.ts +30 -27
- package/dist/src/browserConfig.d.ts.map +1 -1
- package/dist/src/browserConfig.js +125 -94
- package/dist/src/browserConfig.js.map +1 -1
- package/dist/src/cli.js +2 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/cliCommands.d.ts.map +1 -1
- package/dist/src/cliCommands.js +171 -18
- package/dist/src/cliCommands.js.map +1 -1
- package/dist/src/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -1
- package/dist/src/config.js +5 -0
- package/dist/src/config.js.map +1 -1
- package/dist/src/oauthUtils.d.ts +49 -0
- package/dist/src/oauthUtils.d.ts.map +1 -0
- package/dist/src/oauthUtils.js +183 -0
- package/dist/src/oauthUtils.js.map +1 -0
- package/dist/src/playwrightDownload.d.ts +44 -0
- package/dist/src/playwrightDownload.d.ts.map +1 -0
- package/dist/src/playwrightDownload.js +222 -0
- package/dist/src/playwrightDownload.js.map +1 -0
- package/dist/src/playwrightUtils.d.ts +15 -2
- package/dist/src/playwrightUtils.d.ts.map +1 -1
- package/dist/src/playwrightUtils.js +39 -16
- package/dist/src/playwrightUtils.js.map +1 -1
- package/dist/src/registry.d.ts.map +1 -1
- package/dist/src/registry.js +2 -2
- package/dist/src/registry.js.map +1 -1
- package/dist/src/services/base.d.ts +32 -5
- package/dist/src/services/base.d.ts.map +1 -1
- package/dist/src/services/base.js +14 -10
- package/dist/src/services/base.js.map +1 -1
- package/dist/src/services/discord.d.ts +2 -0
- package/dist/src/services/discord.d.ts.map +1 -1
- package/dist/src/services/discord.js +3 -0
- package/dist/src/services/discord.js.map +1 -1
- package/dist/src/services/dropbox.d.ts +3 -1
- package/dist/src/services/dropbox.d.ts.map +1 -1
- package/dist/src/services/dropbox.js +7 -5
- package/dist/src/services/dropbox.js.map +1 -1
- package/dist/src/services/github.d.ts +3 -1
- package/dist/src/services/github.d.ts.map +1 -1
- package/dist/src/services/github.js +18 -8
- package/dist/src/services/github.js.map +1 -1
- package/dist/src/services/google.d.ts +35 -0
- package/dist/src/services/google.d.ts.map +1 -0
- package/dist/src/services/google.js +358 -0
- package/dist/src/services/google.js.map +1 -0
- package/dist/src/services/index.d.ts +2 -0
- package/dist/src/services/index.d.ts.map +1 -1
- package/dist/src/services/index.js +2 -0
- package/dist/src/services/index.js.map +1 -1
- package/dist/src/services/linear.d.ts +3 -1
- package/dist/src/services/linear.d.ts.map +1 -1
- package/dist/src/services/linear.js +7 -6
- package/dist/src/services/linear.js.map +1 -1
- package/dist/src/services/notion.d.ts +30 -0
- package/dist/src/services/notion.d.ts.map +1 -0
- package/dist/src/services/notion.js +121 -0
- package/dist/src/services/notion.js.map +1 -0
- package/dist/src/services/slack.d.ts +2 -0
- package/dist/src/services/slack.d.ts.map +1 -1
- package/dist/src/services/slack.js +3 -0
- package/dist/src/services/slack.js.map +1 -1
- package/dist/src/skillMd.d.ts +2 -0
- package/dist/src/skillMd.d.ts.map +1 -0
- package/dist/src/skillMd.js +19 -0
- package/dist/src/skillMd.js.map +1 -0
- package/dist/tests/cli.test.js +53 -3
- package/dist/tests/cli.test.js.map +1 -1
- package/dist/tests/playwrightDownload.test.d.ts +2 -0
- package/dist/tests/playwrightDownload.test.d.ts.map +1 -0
- package/dist/tests/playwrightDownload.test.js +131 -0
- package/dist/tests/playwrightDownload.test.js.map +1 -0
- package/dist/tests/registry.test.js +16 -3
- package/dist/tests/registry.test.js.map +1 -1
- package/package.json +5 -6
package/LICENSE
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Copyright 2026 Imbue
|
|
1
|
+
Copyright 2026 Imbue, Inc.
|
|
2
2
|
|
|
3
3
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
4
|
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ latchkey curl -X POST 'https://slack.com/api/conversations.create' \
|
|
|
15
15
|
Latchkey is a command-line tool that injects credentials to curl requests to known public APIs.
|
|
16
16
|
|
|
17
17
|
- `latchkey services`
|
|
18
|
-
- Get a list of known and supported third-party services (Slack,
|
|
18
|
+
- Get a list of known and supported third-party services (Slack, Google Workspace, Linear, GitHub, etc.).
|
|
19
19
|
- `latchkey curl <arguments>`
|
|
20
20
|
- Automatically inject credentials to your otherwise standard curl calls to public APIs.
|
|
21
21
|
- (The first time you access a service, a browser pop-up with a login screen appears.)
|
|
@@ -46,8 +46,11 @@ for details.
|
|
|
46
46
|
|
|
47
47
|
```
|
|
48
48
|
npm install -g latchkey
|
|
49
|
+
latchkey ensure-browser
|
|
49
50
|
```
|
|
50
51
|
|
|
52
|
+
The `ensure-browser` command discovers and configures a browser for Latchkey to use. It searches for Chrome, Chromium, or Edge on your system. If none is found, it downloads Chromium via Playwright.
|
|
53
|
+
|
|
51
54
|
**nvm users**: Global packages are per node version. If you switch versions, reinstall with `npm install -g latchkey`
|
|
52
55
|
|
|
53
56
|
## Integrations
|
|
@@ -60,21 +63,30 @@ you're willing to accept the risks.
|
|
|
60
63
|
### OpenCode
|
|
61
64
|
```
|
|
62
65
|
mkdir -p ~/.opencode/skills/latchkey
|
|
63
|
-
|
|
66
|
+
latchkey skill-md > ~/.opencode/skills/latchkey/SKILL.md
|
|
64
67
|
```
|
|
65
68
|
|
|
66
69
|
### Claude Code
|
|
67
70
|
```
|
|
68
71
|
mkdir -p ~/.claude/skills/latchkey
|
|
69
|
-
|
|
72
|
+
latchkey skill-md > ~/.claude/skills/latchkey/SKILL.md
|
|
70
73
|
```
|
|
71
74
|
|
|
72
75
|
### Codex
|
|
73
76
|
```
|
|
74
77
|
mkdir -p ~/.codex/skills/latchkey
|
|
75
|
-
|
|
78
|
+
latchkey skill-md > ~/.codex/skills/latchkey/SKILL.md
|
|
76
79
|
```
|
|
77
80
|
|
|
81
|
+
### Passepartout
|
|
82
|
+
|
|
83
|
+
Check out our [Passepartout demo app](https://github.com/imbue-ai/passepartout) for an idea of how to build AI assistants for non-technical users on top of Latchkey.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
## Demo
|
|
87
|
+
|
|
88
|
+

|
|
89
|
+
|
|
78
90
|
|
|
79
91
|
## Direct usage
|
|
80
92
|
|
|
@@ -155,13 +167,17 @@ containing stored API credentials
|
|
|
155
167
|
containing the state (cookies, local storage, etc.) of
|
|
156
168
|
the browser used for the login popup
|
|
157
169
|
- `LATCHKEY_CURL_PATH`: path to the curl binary
|
|
170
|
+
- `LATCHKEY_CONFIG`: path to the configuration file
|
|
171
|
+
(defaults to `~/.latchkey/config.json`)
|
|
158
172
|
- `LATCHKEY_KEYRING_SERVICE_NAME`, `LATCHKEY_KEYRING_ACCOUNT_NAME`: identifiers that are used to store the encryption password in your keyring
|
|
159
173
|
|
|
160
174
|
|
|
161
175
|
## Disclaimers
|
|
162
176
|
|
|
177
|
+
- This is still a work in progress.
|
|
178
|
+
- Latchkey has been created with the help of AI-assisted coding tools with careful human curation.
|
|
163
179
|
- Invoking `latchkey curl ...` can sometimes have side effects in the form of
|
|
164
|
-
new API keys being created
|
|
180
|
+
new API keys being created in your accounts (through browser automation).
|
|
165
181
|
- Using agents for automated access may be prohibited by some services' ToS.
|
|
166
182
|
- We reserve the right to change the license of future releases of Latchkey.
|
|
167
183
|
- Latchkey was not tested on Windows.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: latchkey
|
|
3
|
+
description: Interact with third-party services (Slack, Google Workspace, Dropbox, GitHub, Linear...) on user's behalf using their public APIs.
|
|
4
|
+
compatibility: Requires node.js, curl, latchkey (npm install -g latchkey) and a desktop/GUI environment.
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Latchkey
|
|
8
|
+
|
|
9
|
+
## Instructions
|
|
10
|
+
|
|
11
|
+
Latchkey is a CLI tool that automatically injects credentials into curl commands for supported public APIs. Instead of manually managing API tokens, latchkey opens a browser for login, extracts credentials from the session, and injects them into your curl requests.
|
|
12
|
+
|
|
13
|
+
Use this skill when the user asks you to work with third-party services like Slack, Discord, Dropbox, Github, Linear and others on their behalf.
|
|
14
|
+
|
|
15
|
+
Usage:
|
|
16
|
+
|
|
17
|
+
1. **Use `latchkey curl`** instead of regular `curl` for supported services.
|
|
18
|
+
2. **Use `latchkey info <service_name>`** to get developer notes about a specific service (API docs links, special requirements, etc.).
|
|
19
|
+
3. **Look for the newest documentation of the desired public API online.** Avoid bot-only endpoints if such a distinction exists.
|
|
20
|
+
4. **Pass through all regular curl arguments** - latchkey is a transparent wrapper.
|
|
21
|
+
5. **Use `latchkey status <service_name>`** when you notice potentially expired credentials.
|
|
22
|
+
6. When the status is `invalid`, **force a new login by calling `latchkey clear <service_name>`**, then retry the curl command.
|
|
23
|
+
7. **Do not force a new login if the status is `valid`** - the user might just not have the necessary permissions.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Examples
|
|
27
|
+
|
|
28
|
+
### Make an authenticated curl request
|
|
29
|
+
```bash
|
|
30
|
+
latchkey curl [curl arguments]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Creating a Slack channel
|
|
34
|
+
```bash
|
|
35
|
+
latchkey curl -X POST 'https://slack.com/api/conversations.create' \
|
|
36
|
+
-H 'Content-Type: application/json' \
|
|
37
|
+
-d '{"name":"my-channel"}'
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
(Notice that `-H 'Authorization: Bearer` is not present in the invocation.)
|
|
41
|
+
|
|
42
|
+
### Getting Discord user info
|
|
43
|
+
```bash
|
|
44
|
+
latchkey curl 'https://discord.com/api/v10/users/@me'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Clear expired credentials and force a new login to Discord
|
|
48
|
+
```bash
|
|
49
|
+
latchkey status discord # Returns "invalid"
|
|
50
|
+
latchkey clear discord
|
|
51
|
+
latchkey curl 'https://discord.com/api/v10/users/@me'
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Only do this when you notice that your previous call ended up not being authenticated (HTTP 401 or 403). The next `latchkey curl` call will trigger a new login flow.
|
|
55
|
+
|
|
56
|
+
### List supported services
|
|
57
|
+
```bash
|
|
58
|
+
latchkey services
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Get service-specific info
|
|
62
|
+
```bash
|
|
63
|
+
latchkey info slack
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
Returns developer notes about the service, including API documentation links and any special requirements.
|
|
67
|
+
|
|
68
|
+
## Notes
|
|
69
|
+
|
|
70
|
+
- All curl arguments are passed through unchanged
|
|
71
|
+
- Return codes, stdin, and stdout are passed back from curl
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "latchkey",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "A CLI tool that injects API credentials into curl requests for known third-party services",
|
|
5
|
+
"author": "Imbue <hynek@imbue.com>",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/imbue-ai/latchkey.git"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/imbue-ai/latchkey#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/imbue-ai/latchkey/issues"
|
|
13
|
+
},
|
|
14
|
+
"type": "module",
|
|
15
|
+
"main": "dist/src/index.js",
|
|
16
|
+
"types": "dist/src/index.d.ts",
|
|
17
|
+
"bin": {
|
|
18
|
+
"latchkey": "./dist/src/cli.js"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md",
|
|
23
|
+
"LICENSE"
|
|
24
|
+
],
|
|
25
|
+
"scripts": {
|
|
26
|
+
"prepublishOnly": "npm run build",
|
|
27
|
+
"build": "tsc && node -e \"require('fs').cpSync('integrations', 'dist/integrations', {recursive:true})\" ",
|
|
28
|
+
"dev": "tsc --watch",
|
|
29
|
+
"lint": "eslint src tests scripts",
|
|
30
|
+
"lint:fix": "eslint src tests scripts --fix",
|
|
31
|
+
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\" \"scripts/**/*.ts\"",
|
|
32
|
+
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\" \"scripts/**/*.ts\"",
|
|
33
|
+
"typecheck": "tsc --noEmit",
|
|
34
|
+
"test": "vitest run",
|
|
35
|
+
"test:watch": "vitest",
|
|
36
|
+
"start": "node dist/cli.js",
|
|
37
|
+
"bun-compile": "bun build ./src/cli.ts --compile --external chromium-bidi --external electron --outfile latchkey"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"cli",
|
|
41
|
+
"curl",
|
|
42
|
+
"api",
|
|
43
|
+
"credentials",
|
|
44
|
+
"authentication",
|
|
45
|
+
"agents",
|
|
46
|
+
"imbue"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=20"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@napi-rs/keyring": "^1.2.0",
|
|
54
|
+
"commander": "^12.0.0",
|
|
55
|
+
"playwright": "^1.49.1",
|
|
56
|
+
"zod": "^3.22.0"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@eslint/js": "^9.39.2",
|
|
60
|
+
"@types/node": "^20.0.0",
|
|
61
|
+
"eslint": "^9.39.2",
|
|
62
|
+
"prettier": "^3.8.1",
|
|
63
|
+
"typescript": "^5.3.0",
|
|
64
|
+
"typescript-eslint": "^8.53.1",
|
|
65
|
+
"vitest": "^2.0.0"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -159,7 +159,7 @@ async function record(serviceName, recordingName = DEFAULT_RECORDING_NAME) {
|
|
|
159
159
|
serviceName: CONFIG.serviceName,
|
|
160
160
|
accountName: CONFIG.accountName,
|
|
161
161
|
});
|
|
162
|
-
await withTempBrowserContext(encryptedStorage, browserStatePath, async ({ context }) => {
|
|
162
|
+
await withTempBrowserContext(encryptedStorage, { browserStatePath }, async ({ context }) => {
|
|
163
163
|
const page = await context.newPage();
|
|
164
164
|
// Register response handler to capture all requests and responses
|
|
165
165
|
page.on('response', (response) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"recordBrowserSession.js","sourceRoot":"","sources":["../../scripts/recordBrowserSession.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAC;AACnE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,iCAAiC;AACjC,MAAM,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAClD,MAAM,SAAS,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAEtC,+CAA+C;AAC/C,MAAM,oBAAoB,GAAG,OAAO,CAAC,SAA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|
|
3
|
+
*
|
|
3
4
|
*/
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
export declare enum ApiCredentialStatus {
|
|
@@ -14,6 +15,11 @@ export declare enum ApiCredentialStatus {
|
|
|
14
15
|
export interface ApiCredentials {
|
|
15
16
|
readonly objectType: string;
|
|
16
17
|
asCurlArguments(): readonly string[];
|
|
18
|
+
/**
|
|
19
|
+
* Check if the credentials are expired.
|
|
20
|
+
* Returns true if expired, false if valid, or undefined if expiration is unknown.
|
|
21
|
+
*/
|
|
22
|
+
isExpired(): boolean | undefined;
|
|
17
23
|
}
|
|
18
24
|
/**
|
|
19
25
|
* Bearer token authentication (Authorization: Bearer <token>).
|
|
@@ -34,6 +40,7 @@ export declare class AuthorizationBearer implements ApiCredentials {
|
|
|
34
40
|
readonly token: string;
|
|
35
41
|
constructor(token: string);
|
|
36
42
|
asCurlArguments(): readonly string[];
|
|
43
|
+
isExpired(): boolean | undefined;
|
|
37
44
|
toJSON(): AuthorizationBearerData;
|
|
38
45
|
static fromJSON(data: AuthorizationBearerData): AuthorizationBearer;
|
|
39
46
|
}
|
|
@@ -56,6 +63,7 @@ export declare class AuthorizationBare implements ApiCredentials {
|
|
|
56
63
|
readonly token: string;
|
|
57
64
|
constructor(token: string);
|
|
58
65
|
asCurlArguments(): readonly string[];
|
|
66
|
+
isExpired(): boolean | undefined;
|
|
59
67
|
toJSON(): AuthorizationBareData;
|
|
60
68
|
static fromJSON(data: AuthorizationBareData): AuthorizationBare;
|
|
61
69
|
}
|
|
@@ -82,9 +90,59 @@ export declare class SlackApiCredentials implements ApiCredentials {
|
|
|
82
90
|
readonly dCookie: string;
|
|
83
91
|
constructor(token: string, dCookie: string);
|
|
84
92
|
asCurlArguments(): readonly string[];
|
|
93
|
+
isExpired(): boolean | undefined;
|
|
85
94
|
toJSON(): SlackApiCredentialsData;
|
|
86
95
|
static fromJSON(data: SlackApiCredentialsData): SlackApiCredentials;
|
|
87
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* OAuth 2.0 credentials (access token, refresh token, client ID, and client secret).
|
|
99
|
+
* Used by services that implement OAuth 2.0 authorization flows.
|
|
100
|
+
* Token attributes are optional - when only clientId and clientSecret are present,
|
|
101
|
+
* this represents credentials from the prepare() step before obtaining user tokens.
|
|
102
|
+
*/
|
|
103
|
+
export declare const OAuthCredentialsSchema: z.ZodObject<{
|
|
104
|
+
objectType: z.ZodLiteral<"oauth">;
|
|
105
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
106
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
107
|
+
clientId: z.ZodString;
|
|
108
|
+
clientSecret: z.ZodString;
|
|
109
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodString>;
|
|
110
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, "strip", z.ZodTypeAny, {
|
|
112
|
+
objectType: "oauth";
|
|
113
|
+
clientId: string;
|
|
114
|
+
clientSecret: string;
|
|
115
|
+
accessToken?: string | undefined;
|
|
116
|
+
refreshToken?: string | undefined;
|
|
117
|
+
accessTokenExpiresAt?: string | undefined;
|
|
118
|
+
refreshTokenExpiresAt?: string | undefined;
|
|
119
|
+
}, {
|
|
120
|
+
objectType: "oauth";
|
|
121
|
+
clientId: string;
|
|
122
|
+
clientSecret: string;
|
|
123
|
+
accessToken?: string | undefined;
|
|
124
|
+
refreshToken?: string | undefined;
|
|
125
|
+
accessTokenExpiresAt?: string | undefined;
|
|
126
|
+
refreshTokenExpiresAt?: string | undefined;
|
|
127
|
+
}>;
|
|
128
|
+
export type OAuthCredentialsData = z.infer<typeof OAuthCredentialsSchema>;
|
|
129
|
+
export declare class OAuthCredentials implements ApiCredentials {
|
|
130
|
+
readonly objectType: "oauth";
|
|
131
|
+
readonly accessToken?: string;
|
|
132
|
+
readonly refreshToken?: string;
|
|
133
|
+
readonly clientId: string;
|
|
134
|
+
readonly clientSecret: string;
|
|
135
|
+
readonly accessTokenExpiresAt?: string;
|
|
136
|
+
readonly refreshTokenExpiresAt?: string;
|
|
137
|
+
constructor(clientId: string, clientSecret: string, accessToken?: string, refreshToken?: string, accessTokenExpiresAt?: string, refreshTokenExpiresAt?: string);
|
|
138
|
+
asCurlArguments(): readonly string[];
|
|
139
|
+
isExpired(): boolean | undefined;
|
|
140
|
+
toJSON(): OAuthCredentialsData;
|
|
141
|
+
static fromJSON(data: OAuthCredentialsData): OAuthCredentials;
|
|
142
|
+
}
|
|
143
|
+
export declare class ApiCredentialsUsageError extends Error {
|
|
144
|
+
constructor(message: string);
|
|
145
|
+
}
|
|
88
146
|
/**
|
|
89
147
|
* Union schema for all credential types.
|
|
90
148
|
*/
|
|
@@ -118,6 +176,30 @@ export declare const ApiCredentialsSchema: z.ZodDiscriminatedUnion<"objectType",
|
|
|
118
176
|
objectType: "slack";
|
|
119
177
|
token: string;
|
|
120
178
|
dCookie: string;
|
|
179
|
+
}>, z.ZodObject<{
|
|
180
|
+
objectType: z.ZodLiteral<"oauth">;
|
|
181
|
+
accessToken: z.ZodOptional<z.ZodString>;
|
|
182
|
+
refreshToken: z.ZodOptional<z.ZodString>;
|
|
183
|
+
clientId: z.ZodString;
|
|
184
|
+
clientSecret: z.ZodString;
|
|
185
|
+
accessTokenExpiresAt: z.ZodOptional<z.ZodString>;
|
|
186
|
+
refreshTokenExpiresAt: z.ZodOptional<z.ZodString>;
|
|
187
|
+
}, "strip", z.ZodTypeAny, {
|
|
188
|
+
objectType: "oauth";
|
|
189
|
+
clientId: string;
|
|
190
|
+
clientSecret: string;
|
|
191
|
+
accessToken?: string | undefined;
|
|
192
|
+
refreshToken?: string | undefined;
|
|
193
|
+
accessTokenExpiresAt?: string | undefined;
|
|
194
|
+
refreshTokenExpiresAt?: string | undefined;
|
|
195
|
+
}, {
|
|
196
|
+
objectType: "oauth";
|
|
197
|
+
clientId: string;
|
|
198
|
+
clientSecret: string;
|
|
199
|
+
accessToken?: string | undefined;
|
|
200
|
+
refreshToken?: string | undefined;
|
|
201
|
+
accessTokenExpiresAt?: string | undefined;
|
|
202
|
+
refreshTokenExpiresAt?: string | undefined;
|
|
121
203
|
}>]>;
|
|
122
204
|
export type ApiCredentialsData = z.infer<typeof ApiCredentialsSchema>;
|
|
123
205
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiCredentials.d.ts","sourceRoot":"","sources":["../../src/apiCredentials.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"apiCredentials.d.ts","sourceRoot":"","sources":["../../src/apiCredentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,oBAAY,mBAAmB;IAC7B,OAAO,YAAY;IACnB,KAAK,UAAU;IACf,OAAO,YAAY;CACpB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,eAAe,IAAI,SAAS,MAAM,EAAE,CAAC;IACrC;;;OAGG;IACH,SAAS,IAAI,OAAO,GAAG,SAAS,CAAC;CAClC;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;EAGpC,CAAC;AAEH,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAEhF,qBAAa,mBAAoB,YAAW,cAAc;IACxD,QAAQ,CAAC,UAAU,EAAG,qBAAqB,CAAU;IACrD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,KAAK,EAAE,MAAM;IAIzB,eAAe,IAAI,SAAS,MAAM,EAAE;IAIpC,SAAS,IAAI,OAAO,GAAG,SAAS;IAIhC,MAAM,IAAI,uBAAuB;IAOjC,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,uBAAuB,GAAG,mBAAmB;CAGpE;AAED;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;EAGlC,CAAC;AAEH,MAAM,MAAM,qBAAqB,G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
5
6
|
export var ApiCredentialStatus;
|
|
@@ -24,6 +25,9 @@ export class AuthorizationBearer {
|
|
|
24
25
|
asCurlArguments() {
|
|
25
26
|
return ['-H', `Authorization: Bearer ${this.token}`];
|
|
26
27
|
}
|
|
28
|
+
isExpired() {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
27
31
|
toJSON() {
|
|
28
32
|
return {
|
|
29
33
|
objectType: this.objectType,
|
|
@@ -50,6 +54,9 @@ export class AuthorizationBare {
|
|
|
50
54
|
asCurlArguments() {
|
|
51
55
|
return ['-H', `Authorization: ${this.token}`];
|
|
52
56
|
}
|
|
57
|
+
isExpired() {
|
|
58
|
+
return undefined;
|
|
59
|
+
}
|
|
53
60
|
toJSON() {
|
|
54
61
|
return {
|
|
55
62
|
objectType: this.objectType,
|
|
@@ -79,6 +86,9 @@ export class SlackApiCredentials {
|
|
|
79
86
|
asCurlArguments() {
|
|
80
87
|
return ['-H', `Authorization: Bearer ${this.token}`, '-H', `Cookie: d=${this.dCookie}`];
|
|
81
88
|
}
|
|
89
|
+
isExpired() {
|
|
90
|
+
return undefined;
|
|
91
|
+
}
|
|
82
92
|
toJSON() {
|
|
83
93
|
return {
|
|
84
94
|
objectType: this.objectType,
|
|
@@ -90,6 +100,72 @@ export class SlackApiCredentials {
|
|
|
90
100
|
return new SlackApiCredentials(data.token, data.dCookie);
|
|
91
101
|
}
|
|
92
102
|
}
|
|
103
|
+
/**
|
|
104
|
+
* OAuth 2.0 credentials (access token, refresh token, client ID, and client secret).
|
|
105
|
+
* Used by services that implement OAuth 2.0 authorization flows.
|
|
106
|
+
* Token attributes are optional - when only clientId and clientSecret are present,
|
|
107
|
+
* this represents credentials from the prepare() step before obtaining user tokens.
|
|
108
|
+
*/
|
|
109
|
+
export const OAuthCredentialsSchema = z.object({
|
|
110
|
+
objectType: z.literal('oauth'),
|
|
111
|
+
accessToken: z.string().optional(),
|
|
112
|
+
refreshToken: z.string().optional(),
|
|
113
|
+
clientId: z.string(),
|
|
114
|
+
clientSecret: z.string(),
|
|
115
|
+
accessTokenExpiresAt: z.string().optional(),
|
|
116
|
+
refreshTokenExpiresAt: z.string().optional(),
|
|
117
|
+
});
|
|
118
|
+
export class OAuthCredentials {
|
|
119
|
+
objectType = 'oauth';
|
|
120
|
+
accessToken;
|
|
121
|
+
refreshToken;
|
|
122
|
+
clientId;
|
|
123
|
+
clientSecret;
|
|
124
|
+
accessTokenExpiresAt;
|
|
125
|
+
refreshTokenExpiresAt;
|
|
126
|
+
constructor(clientId, clientSecret, accessToken, refreshToken, accessTokenExpiresAt, refreshTokenExpiresAt) {
|
|
127
|
+
this.clientId = clientId;
|
|
128
|
+
this.clientSecret = clientSecret;
|
|
129
|
+
this.accessToken = accessToken;
|
|
130
|
+
this.refreshToken = refreshToken;
|
|
131
|
+
this.accessTokenExpiresAt = accessTokenExpiresAt;
|
|
132
|
+
this.refreshTokenExpiresAt = refreshTokenExpiresAt;
|
|
133
|
+
}
|
|
134
|
+
asCurlArguments() {
|
|
135
|
+
if (this.accessToken === undefined) {
|
|
136
|
+
throw new ApiCredentialsUsageError('OAuth credentials missing access token. Run login to obtain access tokens.');
|
|
137
|
+
}
|
|
138
|
+
return ['-H', `Authorization: Bearer ${this.accessToken}`];
|
|
139
|
+
}
|
|
140
|
+
isExpired() {
|
|
141
|
+
if (this.accessTokenExpiresAt === undefined) {
|
|
142
|
+
return undefined;
|
|
143
|
+
}
|
|
144
|
+
const expirationDate = new Date(this.accessTokenExpiresAt);
|
|
145
|
+
return Date.now() >= expirationDate.getTime();
|
|
146
|
+
}
|
|
147
|
+
toJSON() {
|
|
148
|
+
const result = {
|
|
149
|
+
objectType: this.objectType,
|
|
150
|
+
clientId: this.clientId,
|
|
151
|
+
clientSecret: this.clientSecret,
|
|
152
|
+
accessToken: this.accessToken,
|
|
153
|
+
refreshToken: this.refreshToken,
|
|
154
|
+
accessTokenExpiresAt: this.accessTokenExpiresAt,
|
|
155
|
+
refreshTokenExpiresAt: this.refreshTokenExpiresAt,
|
|
156
|
+
};
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
static fromJSON(data) {
|
|
160
|
+
return new OAuthCredentials(data.clientId, data.clientSecret, data.accessToken, data.refreshToken, data.accessTokenExpiresAt, data.refreshTokenExpiresAt);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
export class ApiCredentialsUsageError extends Error {
|
|
164
|
+
constructor(message) {
|
|
165
|
+
super(message);
|
|
166
|
+
this.name = 'ApiCredentialsUsageError';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
93
169
|
/**
|
|
94
170
|
* Union schema for all credential types.
|
|
95
171
|
*/
|
|
@@ -97,6 +173,7 @@ export const ApiCredentialsSchema = z.discriminatedUnion('objectType', [
|
|
|
97
173
|
AuthorizationBearerSchema,
|
|
98
174
|
AuthorizationBareSchema,
|
|
99
175
|
SlackApiCredentialsSchema,
|
|
176
|
+
OAuthCredentialsSchema,
|
|
100
177
|
]);
|
|
101
178
|
/**
|
|
102
179
|
* Deserialize credentials from JSON data.
|
|
@@ -109,6 +186,8 @@ export function deserializeCredentials(data) {
|
|
|
109
186
|
return AuthorizationBare.fromJSON(data);
|
|
110
187
|
case 'slack':
|
|
111
188
|
return SlackApiCredentials.fromJSON(data);
|
|
189
|
+
case 'oauth':
|
|
190
|
+
return OAuthCredentials.fromJSON(data);
|
|
112
191
|
default: {
|
|
113
192
|
const exhaustiveCheck = data;
|
|
114
193
|
throw new ApiCredentialsSerializationError(`Unknown credential type: ${exhaustiveCheck.objectType}`);
|
|
@@ -128,6 +207,9 @@ export function serializeCredentials(credentials) {
|
|
|
128
207
|
if (credentials instanceof SlackApiCredentials) {
|
|
129
208
|
return credentials.toJSON();
|
|
130
209
|
}
|
|
210
|
+
if (credentials instanceof OAuthCredentials) {
|
|
211
|
+
return credentials.toJSON();
|
|
212
|
+
}
|
|
131
213
|
throw new ApiCredentialsSerializationError(`Unknown credential type: ${credentials.objectType}`);
|
|
132
214
|
}
|
|
133
215
|
export class ApiCredentialsSerializationError extends Error {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apiCredentials.js","sourceRoot":"","sources":["../../src/apiCredentials.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"apiCredentials.js","sourceRoot":"","sources":["../../src/apiCredentials.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAN,IAAY,mBAIX;AAJD,WAAY,mBAAmB;IAC7B,0CAAmB,CAAA;IACnB,sCAAe,CAAA;IACf,0CAAmB,CAAA;AACrB,CAAC,EAJW,mBAAmB,KAAnB,mBAAmB,QAI9B;AAgBD;;GAEG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,UAAU,EAAE,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC;IAC5C,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE;CAClB,CAAC,CAAC;AAIH,MAAM,OAAO,mBAAmB;IACrB,UAAU,GAAG,qBAA8B,CAAC;IAC5C,KAAK,CAAS;IAEvB,YAAY,KAAa;QACvB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,eAAe;QACb,OAAO,CAAC,IAAI,EAAE,yBAAyB,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;IACvD,CAAC;IAED,SAAS;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM;QACJ,OAAO;YACL,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAA6B;QAC3C,OAAO,IAAI,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACF;AAED;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,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M,EAAE,CAAC;IAC9B,CAAC;IACD,IAAI,WAAW,YAAY,gBAAgB,EAAE,CAAC;QAC5C,OAAO,WAAW,CAAC,MAAM,EAAE,CAAC;IAC9B,CAAC;IACD,MAAM,IAAI,gCAAgC,CAAC,4BAA4B,WAAW,CAAC,UAAU,EAAE,CAAC,CAAC;AACnG,CAAC;AAED,MAAM,OAAO,gCAAiC,SAAQ,KAAK;IACzD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kCAAkC,CAAC;IACjD,CAAC;CACF"}
|
|
@@ -9,7 +9,16 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import { z } from 'zod';
|
|
11
11
|
/**
|
|
12
|
-
*
|
|
12
|
+
* Browser sources that can be used for discovery.
|
|
13
|
+
*/
|
|
14
|
+
export declare const BROWSER_SOURCES: readonly ["existing-config", "system-browser", "existing-playwright-browser", "download-playwright-browser"];
|
|
15
|
+
export type BrowserSource = (typeof BROWSER_SOURCES)[number];
|
|
16
|
+
/**
|
|
17
|
+
* Default order for browser source discovery.
|
|
18
|
+
*/
|
|
19
|
+
export declare const DEFAULT_BROWSER_SOURCES: readonly BrowserSource[];
|
|
20
|
+
/**
|
|
21
|
+
* Schema for the browser configuration.
|
|
13
22
|
*/
|
|
14
23
|
declare const BrowserConfigSchema: z.ZodObject<{
|
|
15
24
|
executablePath: z.ZodString;
|
|
@@ -32,9 +41,9 @@ export declare class BrowserConfigError extends Error {
|
|
|
32
41
|
constructor(message: string);
|
|
33
42
|
}
|
|
34
43
|
/**
|
|
35
|
-
* Get the default path for the
|
|
44
|
+
* Get the default path for the configuration file.
|
|
36
45
|
*/
|
|
37
|
-
export declare function
|
|
46
|
+
export declare function getDefaultConfigPath(): string;
|
|
38
47
|
/**
|
|
39
48
|
* Find a system-installed Chrome/Chromium browser.
|
|
40
49
|
* Returns the path to the executable if found, null otherwise.
|
|
@@ -44,28 +53,25 @@ export declare function findSystemBrowser(): string | null;
|
|
|
44
53
|
* Find Chrome/Chromium installed by Playwright.
|
|
45
54
|
* Returns the path to the executable if found, null otherwise.
|
|
46
55
|
*/
|
|
47
|
-
export declare function findPlaywrightBrowser():
|
|
56
|
+
export declare function findPlaywrightBrowser(): string | null;
|
|
48
57
|
/**
|
|
49
|
-
* Download Chromium using
|
|
58
|
+
* Download Chromium using a direct download mechanism.
|
|
59
|
+
*
|
|
60
|
+
* This implementation downloads Chromium without using Playwright's
|
|
61
|
+
* installBrowsersForNpmInstall, which uses childProcess.fork() - a mechanism
|
|
62
|
+
* not supported when Latchkey is compiled with Bun.
|
|
63
|
+
*
|
|
50
64
|
* Returns the path to the downloaded executable.
|
|
51
65
|
*/
|
|
52
66
|
export declare function downloadPlaywrightBrowser(): Promise<string>;
|
|
53
67
|
/**
|
|
54
|
-
*
|
|
55
|
-
|
|
56
|
-
export interface DiscoverBrowserOptions {
|
|
57
|
-
/** Skip discovery of system-installed browsers. Default: false */
|
|
58
|
-
skipSystemBrowser?: boolean;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Discover a Chrome/Chromium browser using the following priority:
|
|
62
|
-
* 1. System-installed browser (unless skipSystemBrowser is true)
|
|
63
|
-
* 2. Playwright's bundled browser
|
|
64
|
-
* 3. Download via Playwright
|
|
65
|
-
*
|
|
66
|
-
* Returns the browser configuration with the discovered path.
|
|
68
|
+
* Discover a browser by trying sources in the specified order.
|
|
69
|
+
* Returns the first successful result, or throws if none succeed.
|
|
67
70
|
*/
|
|
68
|
-
export declare function
|
|
71
|
+
export declare function discoverBrowserFromSources(sources: readonly BrowserSource[], configPath: string): Promise<{
|
|
72
|
+
config: BrowserConfig;
|
|
73
|
+
source: BrowserSource;
|
|
74
|
+
}>;
|
|
69
75
|
/**
|
|
70
76
|
* Save browser configuration to disk.
|
|
71
77
|
*/
|
|
@@ -77,14 +83,11 @@ export declare function saveBrowserConfig(configPath: string, config: BrowserCon
|
|
|
77
83
|
export declare function loadBrowserConfig(configPath: string): BrowserConfig | null;
|
|
78
84
|
/**
|
|
79
85
|
* Ensure a browser is available and return its configuration.
|
|
80
|
-
*
|
|
81
|
-
* Otherwise, a new browser is discovered and the configuration is saved.
|
|
86
|
+
* Tries sources in the specified order, saves the result to the config file.
|
|
82
87
|
*/
|
|
83
|
-
export declare function ensureBrowser(configPath?: string,
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
*/
|
|
88
|
-
export declare function getBrowserExecutablePath(configPath?: string): string | null;
|
|
88
|
+
export declare function ensureBrowser(configPath?: string, sources?: readonly BrowserSource[]): Promise<{
|
|
89
|
+
config: BrowserConfig;
|
|
90
|
+
source: BrowserSource;
|
|
91
|
+
}>;
|
|
89
92
|
export {};
|
|
90
93
|
//# sourceMappingURL=browserConfig.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browserConfig.d.ts","sourceRoot":"","sources":["../../src/browserConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"browserConfig.d.ts","sourceRoot":"","sources":["../../src/browserConfig.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;GAEG;AACH,eAAO,MAAM,eAAe,8GAKlB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAC;AAE7D;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,SAAS,aAAa,EAK3D,CAAC;AAEF;;GAEG;AACH,QAAA,MAAM,mBAAmB;;;;;;;;;;;;EAIvB,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAShE,qBAAa,oBAAqB,SAAQ,KAAK;gBACjC,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,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