@clonecommand/cloud 0.0.2 → 0.0.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/docs/README.md +23 -0
- package/docs/email.md +65 -0
- package/docs/login.md +54 -0
- package/docs/storage.md +40 -0
- package/package.json +3 -2
package/docs/README.md
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# CloneCommand Cloud SDK Documentation
|
|
2
|
+
|
|
3
|
+
Welcome to the `@clonecommand/cloud` SDK documentation.
|
|
4
|
+
|
|
5
|
+
## Modules
|
|
6
|
+
|
|
7
|
+
- [**🔐 Login**](./login.md): OAuth Proxy service for preview environments.
|
|
8
|
+
- [**📦 Storage**](./storage.md): Managed file hosting with CDN and custom domains.
|
|
9
|
+
- [**📧 Email**](./email.md): Managed email sending and receiving with inbound processing.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { ccc } from '@clonecommand/cloud';
|
|
15
|
+
|
|
16
|
+
// 1. Initialize (Optional in managed environments)
|
|
17
|
+
ccc.init({ projectId: 'your-project-id' });
|
|
18
|
+
|
|
19
|
+
// 2. Use services
|
|
20
|
+
const loginUrl = ccc.login.proxy('https://google.com/oauth...');
|
|
21
|
+
const file = await ccc.storage.importFileFromUrl('...');
|
|
22
|
+
const config = await ccc.email.getConfig();
|
|
23
|
+
```
|
package/docs/email.md
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 📧 CloneCommand Email Service
|
|
2
|
+
|
|
3
|
+
Managed email sending and receiving with inbound processing and domain verification.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Send Emails**: Send transactional emails via Amazon SES (managed backend).
|
|
8
|
+
- **Inbound Processing**: Receive emails, store them in GCS, and access them via API.
|
|
9
|
+
- **Domain Verification**: Automates DNS verification for custom domains.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Getting Configuration
|
|
14
|
+
|
|
15
|
+
Check if email is enabled for the current project.
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { ccc } from '@clonecommand/cloud';
|
|
19
|
+
|
|
20
|
+
const config = await ccc.email.getConfig();
|
|
21
|
+
|
|
22
|
+
if (config?.isEnabled) {
|
|
23
|
+
console.log('Email is active!');
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### Sending Emails
|
|
28
|
+
|
|
29
|
+
Send simple text or HTML emails.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
const messageId = await ccc.email.send({
|
|
33
|
+
to: 'user@example.com',
|
|
34
|
+
subject: 'Welcome!',
|
|
35
|
+
html: '<h1>Welcome to our platform</h1>',
|
|
36
|
+
text: 'Welcome to our platform'
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Retrieving Inbound Emails
|
|
41
|
+
|
|
42
|
+
Fetch the latest emails received by the project's inbound address.
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
const emails = await ccc.email.getInbound({ limit: 5 });
|
|
46
|
+
|
|
47
|
+
for (const email of emails) {
|
|
48
|
+
console.log(`Received from: ${email.sender}`);
|
|
49
|
+
console.log(`Subject: ${email.subject}`);
|
|
50
|
+
|
|
51
|
+
// Fetch full details including body
|
|
52
|
+
const fullEmail = await ccc.email.get(email.id);
|
|
53
|
+
console.log(fullEmail.body);
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Agent Capabilities
|
|
58
|
+
|
|
59
|
+
The email service is designed to be easily used by AI agents to build automated workflows:
|
|
60
|
+
- **Auto-Reply Bots**: Poll `getInbound()` and `send()` replies.
|
|
61
|
+
- **Verification flows**: Trigger emails and read the verification codes from the inbox.
|
|
62
|
+
|
|
63
|
+
## Authentication
|
|
64
|
+
|
|
65
|
+
Requires the `CC_PROJECT_TOKEN` environment variable, automatically injected in CloneCommand deployments.
|
package/docs/login.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# 🔐 CloneCommand Login Service (OAuth Proxy)
|
|
2
|
+
|
|
3
|
+
The **CloneCommand Login Service** acts as a trusted intermediary for OAuth flows, solving the "Redirect URI Paradox" in preview environments.
|
|
4
|
+
|
|
5
|
+
## Why is this needed?
|
|
6
|
+
|
|
7
|
+
OAuth providers (Google, GitHub, LinkedIn, etc.) require whitelisting specific Redirect URIs. This is problematic for:
|
|
8
|
+
1. **Preview Environments**: Each pull request creates a unique URL (e.g., `pr-123.clonecommand.app`). You can't whitelist infinite dynamic URLs.
|
|
9
|
+
2. **Local Development**: Managing `localhost` vs production URLs often leads to config drift.
|
|
10
|
+
|
|
11
|
+
## How it works
|
|
12
|
+
|
|
13
|
+
Instead of redirecting users directly to the OAuth provider, you redirect them to the **CloneCommand Proxy**. The proxy handles the redirection to the provider using a single, stable callback URL (`https://graph.clonecommand.com/login/proxy/callback`), and then redirects the user back to your specific environment.
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### 1. Wrap your Authorization URL
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { ccc } from '@clonecommand/cloud';
|
|
21
|
+
|
|
22
|
+
const originalUrl = 'https://github.com/login/oauth/authorize?client_id=...';
|
|
23
|
+
const proxyUrl = ccc.login.proxy(originalUrl);
|
|
24
|
+
|
|
25
|
+
window.location.href = proxyUrl;
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### 2. Configure your OAuth Provider
|
|
29
|
+
|
|
30
|
+
Whitelist **only** this URL in your provider's developer console:
|
|
31
|
+
|
|
32
|
+
`https://graph.clonecommand.com/login/proxy/callback`
|
|
33
|
+
|
|
34
|
+
### 3. Handle the Callback
|
|
35
|
+
|
|
36
|
+
When exchanging the `code` for an access token on your backend, you **must** use the proxy callback URL as the `redirect_uri`, regardless of where your app is actually running.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// Backend code to exchange code for token
|
|
40
|
+
const response = await fetch('https://github.com/login/oauth/access_token', {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: JSON.stringify({
|
|
43
|
+
client_id: '...',
|
|
44
|
+
client_secret: '...',
|
|
45
|
+
code: req.query.code,
|
|
46
|
+
redirect_uri: 'https://graph.clonecommand.com/login/proxy/callback' // <--- CRITICAL
|
|
47
|
+
})
|
|
48
|
+
});
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Agent Notes
|
|
52
|
+
|
|
53
|
+
- **Stability**: This feature ensures that authentication flows work immediately in any new environment an agent creates.
|
|
54
|
+
- **Zero Config**: No need to ask the user to update their OAuth provider settings when deploying new branches.
|
package/docs/storage.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# 📦 CloneCommand Storage Service
|
|
2
|
+
|
|
3
|
+
Managed file storage with global CDN, automatic SSL, and custom domain support.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
### Uploading Files
|
|
8
|
+
|
|
9
|
+
The `importFileFromUrl` method allows you to upload assets from external sources (e.g., social media avatars, public APIs) directly to your project's storage bucket.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
import { ccc } from '@clonecommand/cloud';
|
|
13
|
+
|
|
14
|
+
const file = await ccc.storage.importFileFromUrl('https://example.com/image.png');
|
|
15
|
+
|
|
16
|
+
console.log(file);
|
|
17
|
+
// {
|
|
18
|
+
// id: "...",
|
|
19
|
+
// fileId: "xyz-123",
|
|
20
|
+
// publicUrl: "https://my-project.clonecommand.media/xyz-123/original.png",
|
|
21
|
+
// ...
|
|
22
|
+
// }
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
### Retrieving File URLs
|
|
26
|
+
|
|
27
|
+
Generate the public CDN URL for a file using its `fileId`.
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
const url = ccc.storage.getFileUrl('xyz-123');
|
|
31
|
+
// -> https://my-project.clonecommand.media/xyz-123/original
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Custom Domains
|
|
35
|
+
|
|
36
|
+
If your project has a custom media domain configured (e.g., `cdn.myapp.com`), `getFileUrl` and `importFileFromUrl` will automatically return URLs using that domain.
|
|
37
|
+
|
|
38
|
+
## Authentication
|
|
39
|
+
|
|
40
|
+
Storage operations require the `CC_PROJECT_TOKEN` environment variable, which is automatically injected in CloneCommand deployments. For local development, use `clones run`.
|
package/package.json
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clonecommand/cloud",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The official SDK for CloneCommand managed services",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"dist",
|
|
10
|
-
"README.md"
|
|
10
|
+
"README.md",
|
|
11
|
+
"docs"
|
|
11
12
|
],
|
|
12
13
|
"publishConfig": {
|
|
13
14
|
"access": "public"
|