@qidcloud/sdk 1.2.1 → 1.2.2

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.
Files changed (2) hide show
  1. package/README.md +107 -33
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,68 +1,142 @@
1
1
  # @qidcloud/sdk
2
2
 
3
- The official JavaScript/TypeScript SDK for QidCloud. Build PQC-secured, enclave-backed applications in minutes.
3
+ The official JavaScript/TypeScript SDK for QidCloud. Build PQC-secured, enclave-backed applications with ease.
4
4
 
5
- ## 🚀 30-Minute Quick Start
5
+ ## 🚀 Installation
6
6
 
7
- ### 1. Install
8
7
  ```bash
9
8
  npm install @qidcloud/sdk
10
9
  ```
11
10
 
12
- ### 2. Initialize
11
+ ## 🛠️ Initialization
12
+
13
13
  ```typescript
14
14
  import { QidCloud } from '@qidcloud/sdk';
15
15
 
16
16
  const qid = new QidCloud({
17
17
  apiKey: 'your_api_key', // Found in QidCloud Console -> Settings
18
- tenantId: 'your_project_id'
18
+ tenantId: 'your_project_id' // Optional, for project-scoped operations
19
19
  });
20
20
  ```
21
21
 
22
22
  ---
23
23
 
24
- ## 🔑 Identity (`qid.auth`)
25
-
26
- Enforce Pure Post-Quantum Identity with zero passwords.
24
+ ## 🛡️ Identity & Auth (`qid.auth`)
27
25
 
28
26
  ### `createSession()`
29
- Initiates a new QR handshake session.
30
- - **Returns**: `Promise<QidAuthSession>`
27
+ Initializes a new PQC handshake session for QR login.
28
+ - **Returns**: `Promise<{ sessionId: string, qrData: string, expiresAt: number }>`
29
+ ```typescript
30
+ const { sessionId, qrData } = await qid.auth.createSession();
31
+ ```
32
+
33
+ ### `getProfile(token)`
34
+ Verifies a session token and retrieves the user profile.
35
+ - **Returns**: `Promise<QidUser>`
36
+ ```typescript
37
+ const user = await qid.auth.getProfile(sessionToken);
38
+ ```
39
+
40
+ ### `listen(sessionId, onAuthorized, onDenied?)`
41
+ Listen for real-time authorization events via WebSocket.
42
+ ```typescript
43
+ qid.auth.listen(sessionId,
44
+ (token) => console.log('Authenticated:', token),
45
+ (error) => console.error('Denied:', error)
46
+ );
47
+ ```
31
48
 
32
49
  ---
33
50
 
34
- ## 🏗️ React Integration
51
+ ## 🗄️ Secure Vault (`qid.vault`)
52
+
53
+ ### `upload(file, name, metadata?, userToken?)`
54
+ Encrypt and upload a file to the secure enclave.
55
+ - **Returns**: `Promise<QidUploadResponse>`
56
+ ```typescript
57
+ await qid.vault.upload(fileBlob, 'secret.pdf', { tag: 'confidential' }, userToken);
58
+ ```
35
59
 
36
- The SDK provides powerful React tools for seamless integration.
60
+ ### `list(userToken?)`
61
+ List all encrypted files.
62
+ - **Returns**: `Promise<QidFile[]>`
63
+ ```typescript
64
+ const files = await qid.vault.list(userToken);
65
+ ```
37
66
 
38
- ### `useQidAuth(sdk)`
39
- The recommended way to manage auth state in React.
67
+ ### `download(fileId, userToken?)`
68
+ Download a file as an ArrayBuffer.
69
+ ```typescript
70
+ const buffer = await qid.vault.download('file_123', userToken);
71
+ ```
40
72
 
41
- ```tsx
42
- import { useQidAuth } from '@qidcloud/sdk';
73
+ ### `delete(fileId, userToken?)`
74
+ Soft delete a file (move to recycle bin).
75
+ ```typescript
76
+ await qid.vault.delete('file_123', userToken);
77
+ ```
43
78
 
44
- function MyComponent({ qid }) {
45
- const { user, token, session, login, initializing } = useQidAuth(qid);
79
+ ---
46
80
 
47
- if (user) return <p>Welcome, {user.username}</p>;
81
+ ## Edge Computing (`qid.edge`)
48
82
 
49
- return (
50
- <button onClick={login}>
51
- {initializing ? 'Connecting...' : 'Login'}
52
- </button>
53
- );
54
- }
83
+ ### `invoke(name, params?, userToken?)`
84
+ Invoke a serverless edge function.
85
+ - **Returns**: `Promise<QidEdgeResponse>`
86
+ ```typescript
87
+ const result = await qid.edge.invoke('secure-calc', { input: 42 }, userToken);
55
88
  ```
56
89
 
57
- ### `QidSignInButton`
58
- A plug-and-play button that handles the entire handshake UI.
90
+ ### `list()`
91
+ List all provisioned functions.
92
+ ```typescript
93
+ const functions = await qid.edge.list();
94
+ ```
95
+
96
+ ### `getLogs(name, userToken?)`
97
+ Get logs for a specific function.
98
+ ```typescript
99
+ const logs = await qid.edge.getLogs('my-function', userToken);
100
+ ```
101
+
102
+ ### `deploy(data, userToken?)`
103
+ Deploy or update a function.
104
+ ```typescript
105
+ await qid.edge.deploy({
106
+ name: 'new-func',
107
+ code: '...',
108
+ runtime: 'node18'
109
+ }, userToken);
110
+ ```
111
+
112
+ ---
113
+
114
+ ## 📊 Observability (`qid.logs`)
115
+
116
+ ### `write(message, source?, level?, meta?)`
117
+ Ingest custom telemetry into the enclave.
118
+ ```typescript
119
+ await qid.logs.write('User action detected', 'frontend', 'info', { userId: '123' });
120
+ ```
121
+
122
+ ### `fetch(query?)`
123
+ Retrieve project logs.
124
+ ```typescript
125
+ const logs = await qid.logs.fetch({ limit: 50, level: 'error' });
126
+ ```
127
+
128
+ ---
129
+
130
+ ## ⚛️ React Helpers
59
131
 
132
+ ### `useQidAuth(sdk)`
133
+ Hook for managing authentication state.
60
134
  ```tsx
61
- import { QidSignInButton } from '@qidcloud/sdk';
135
+ const { user, login, logout } = useQidAuth(qid);
136
+ ```
62
137
 
63
- <QidSignInButton
64
- sdk={qid}
65
- onSuccess={(user, token) => console.log(user)}
66
- onError={(err) => alert(err)}
67
- />
138
+ ### `QidSignInButton`
139
+ Pre-built component for PQC login.
140
+ ```tsx
141
+ <QidSignInButton sdk={qid} onSuccess={(user) => console.log(user)} />
68
142
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qidcloud/sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "The official JavaScript/TypeScript SDK for QidCloud Identity and Enclave Services.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",