@lanonasis/oauth-client 1.0.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 +21 -0
- package/README.md +95 -0
- package/dist/index.cjs +1338 -0
- package/dist/index.d.cts +204 -0
- package/dist/index.d.ts +204 -0
- package/dist/index.js +1303 -0
- package/package.json +67 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lan Onasis
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# @lanonasis/oauth-client
|
|
2
|
+
|
|
3
|
+
Drop-in OAuth + MCP connectivity client for the Lanonasis ecosystem. Handles browser/desktop/terminal flows, token lifecycle, secure (hashed) API key storage, and MCP WebSocket/SSE connections so other projects can integrate without re-implementing auth.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
- OAuth flows for terminal and desktop (Electron-friendly) environments
|
|
7
|
+
- Token storage with secure backends (Keytar, encrypted files, Electron secure store, mobile secure storage, WebCrypto in browsers)
|
|
8
|
+
- API key storage that normalizes to SHA-256 digests before persisting
|
|
9
|
+
- MCP client that connects over WebSocket (`/ws`) or SSE (`/sse`) with auto-refreshing tokens
|
|
10
|
+
- ESM + CJS bundles with TypeScript types
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
```bash
|
|
14
|
+
npm install @lanonasis/oauth-client
|
|
15
|
+
# or
|
|
16
|
+
bun add @lanonasis/oauth-client
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Quick Start
|
|
20
|
+
```ts
|
|
21
|
+
import { MCPClient } from '@lanonasis/oauth-client';
|
|
22
|
+
|
|
23
|
+
const client = new MCPClient({
|
|
24
|
+
clientId: 'your_oauth_client_id',
|
|
25
|
+
authBaseUrl: 'https://auth.lanonasis.com',
|
|
26
|
+
mcpEndpoint: 'wss://mcp.lanonasis.com',
|
|
27
|
+
scope: 'mcp:read mcp:write api_keys:manage'
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
await client.connect(); // handles auth, refresh, and MCP connect
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Terminal OAuth flow
|
|
34
|
+
```ts
|
|
35
|
+
import { TerminalOAuthFlow } from '@lanonasis/oauth-client';
|
|
36
|
+
|
|
37
|
+
const flow = new TerminalOAuthFlow({
|
|
38
|
+
clientId: 'your_client_id',
|
|
39
|
+
authBaseUrl: 'https://auth.lanonasis.com',
|
|
40
|
+
scope: 'mcp:read'
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const tokens = await flow.authenticate();
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### Desktop (Electron) OAuth flow
|
|
47
|
+
```ts
|
|
48
|
+
import { DesktopOAuthFlow } from '@lanonasis/oauth-client';
|
|
49
|
+
|
|
50
|
+
const flow = new DesktopOAuthFlow({
|
|
51
|
+
clientId: 'your_client_id',
|
|
52
|
+
authBaseUrl: 'https://auth.lanonasis.com'
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const tokens = await flow.authenticate();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Token storage
|
|
59
|
+
```ts
|
|
60
|
+
import { TokenStorage } from '@lanonasis/oauth-client';
|
|
61
|
+
|
|
62
|
+
const storage = new TokenStorage();
|
|
63
|
+
await storage.store(tokens);
|
|
64
|
+
const restored = await storage.retrieve();
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### API key storage (hashes to SHA-256)
|
|
68
|
+
```ts
|
|
69
|
+
import { ApiKeyStorage } from '@lanonasis/oauth-client';
|
|
70
|
+
|
|
71
|
+
const apiKeys = new ApiKeyStorage();
|
|
72
|
+
await apiKeys.store({ apiKey: 'lns_abc123', environment: 'production' });
|
|
73
|
+
const hashed = await apiKeys.getApiKey(); // returns sha256 hex digest
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Configuration
|
|
77
|
+
- `clientId` (required): OAuth client id issued by Lanonasis Auth.
|
|
78
|
+
- `authBaseUrl` (optional): defaults to `https://auth.lanonasis.com`.
|
|
79
|
+
- `mcpEndpoint` (optional): defaults to `wss://mcp.lanonasis.com` and can also be `https://...` for SSE.
|
|
80
|
+
- `scope` (optional): defaults to `mcp:read mcp:write api_keys:manage`.
|
|
81
|
+
- `autoRefresh` (MCPClient): refresh tokens 5 minutes before expiry (default `true`).
|
|
82
|
+
|
|
83
|
+
## Publishing (maintainers)
|
|
84
|
+
1) Build artifacts: `npm install && npm run build`
|
|
85
|
+
2) Verify contents: ensure `dist`, `README.md`, `LICENSE` are present.
|
|
86
|
+
3) Publish: `npm publish --access public` (registry must have 2FA as configured).
|
|
87
|
+
4) Tag in git (optional): `git tag oauth-client-v1.0.0 && git push --tags`
|
|
88
|
+
|
|
89
|
+
## Files shipped
|
|
90
|
+
- `dist/*` compiled CJS/ESM bundles + types
|
|
91
|
+
- `README.md`
|
|
92
|
+
- `LICENSE`
|
|
93
|
+
|
|
94
|
+
## License
|
|
95
|
+
MIT © Lan Onasis
|