@qidcloud/sdk 1.2.2 → 1.2.4
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 +1584 -66
- package/dist/index.js +941 -1917
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +941 -1918
- package/dist/index.mjs.map +1 -1
- package/dist/src/components/QidCloudLogin.d.ts +16 -0
- package/dist/{hooks → src/hooks}/useQidAuth.d.ts +3 -0
- package/dist/{index.d.ts → src/index.d.ts} +9 -0
- package/dist/src/modules/auth.d.ts +155 -0
- package/dist/src/modules/billing.d.ts +57 -0
- package/dist/src/modules/db.d.ts +49 -0
- package/dist/src/modules/project.d.ts +112 -0
- package/dist/src/modules/resource.d.ts +25 -0
- package/dist/src/modules/sdk.d.ts +29 -0
- package/dist/{modules → src/modules}/vault.d.ts +26 -14
- package/dist/src/types.d.ts +126 -0
- package/package.json +21 -5
- package/dist/modules/auth.d.ts +0 -23
- package/dist/modules/db.d.ts +0 -21
- package/dist/types.d.ts +0 -46
- package/rollup.config.mjs +0 -26
- package/src/components/QidSignInButton.tsx +0 -174
- package/src/hooks/useQidAuth.ts +0 -104
- package/src/index.ts +0 -57
- package/src/modules/auth.ts +0 -77
- package/src/modules/db.ts +0 -40
- package/src/modules/edge.ts +0 -98
- package/src/modules/logs.ts +0 -30
- package/src/modules/vault.ts +0 -124
- package/src/types.ts +0 -52
- package/tsconfig.json +0 -31
- /package/dist/{components → src/components}/QidSignInButton.d.ts +0 -0
- /package/dist/{modules → src/modules}/edge.d.ts +0 -0
- /package/dist/{modules → src/modules}/logs.d.ts +0 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { QidCloud } from '../index';
|
|
3
|
+
import { QidUser } from '../types';
|
|
4
|
+
interface QidCloudLoginProps {
|
|
5
|
+
sdk: QidCloud;
|
|
6
|
+
onSuccess: (user: QidUser, token: string) => void;
|
|
7
|
+
onError?: (error: string) => void;
|
|
8
|
+
className?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A comprehensive login component for QidCloud.
|
|
12
|
+
* STRICT SECURITY: ONLY supports QR Scanning (Mobile App) for Post-Quantum security.
|
|
13
|
+
* Conventional login is not available in the SDK to prevent password transmission in third-party apps.
|
|
14
|
+
*/
|
|
15
|
+
export declare const QidCloudLogin: React.FC<QidCloudLoginProps>;
|
|
16
|
+
export {};
|
|
@@ -7,9 +7,12 @@ export interface UseQidAuthReturn {
|
|
|
7
7
|
error: string | null;
|
|
8
8
|
session: QidAuthSession | null;
|
|
9
9
|
initializing: boolean;
|
|
10
|
+
isExpired: boolean;
|
|
11
|
+
timeLeft: number;
|
|
10
12
|
login: () => Promise<void>;
|
|
11
13
|
logout: () => void;
|
|
12
14
|
cancel: () => void;
|
|
15
|
+
setAuthenticated: (user: QidUser, token: string) => void;
|
|
13
16
|
}
|
|
14
17
|
/**
|
|
15
18
|
* A React hook for managing QidCloud authentication lifecycle.
|
|
@@ -5,6 +5,10 @@ import { DbModule } from './modules/db';
|
|
|
5
5
|
import { EdgeModule } from './modules/edge';
|
|
6
6
|
import { VaultModule } from './modules/vault';
|
|
7
7
|
import { LogsModule } from './modules/logs';
|
|
8
|
+
import { ProjectModule } from './modules/project';
|
|
9
|
+
import { ResourceModule } from './modules/resource';
|
|
10
|
+
import { SdkModule } from './modules/sdk';
|
|
11
|
+
import { BillingModule } from './modules/billing';
|
|
8
12
|
export declare class QidCloud {
|
|
9
13
|
private config;
|
|
10
14
|
api: AxiosInstance;
|
|
@@ -13,6 +17,10 @@ export declare class QidCloud {
|
|
|
13
17
|
edge: EdgeModule;
|
|
14
18
|
vault: VaultModule;
|
|
15
19
|
logs: LogsModule;
|
|
20
|
+
projects: ProjectModule;
|
|
21
|
+
resources: ResourceModule;
|
|
22
|
+
sdk: SdkModule;
|
|
23
|
+
billing: BillingModule;
|
|
16
24
|
constructor(config: QidConfig);
|
|
17
25
|
/**
|
|
18
26
|
* Get the current project configuration
|
|
@@ -22,4 +30,5 @@ export declare class QidCloud {
|
|
|
22
30
|
export default QidCloud;
|
|
23
31
|
export * from './types';
|
|
24
32
|
export { QidSignInButton } from './components/QidSignInButton';
|
|
33
|
+
export { QidCloudLogin } from './components/QidCloudLogin';
|
|
25
34
|
export { useQidAuth } from './hooks/useQidAuth';
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
import { QidAuthSession, QidUser, QidSession } from '../types';
|
|
3
|
+
export declare class AuthModule {
|
|
4
|
+
private sdk;
|
|
5
|
+
private socket;
|
|
6
|
+
constructor(sdk: QidCloud);
|
|
7
|
+
/**
|
|
8
|
+
* Initialize a new handshake session for QR login
|
|
9
|
+
*/
|
|
10
|
+
createSession(): Promise<QidAuthSession>;
|
|
11
|
+
/**
|
|
12
|
+
* Listen for authorization events for a specific session
|
|
13
|
+
*/
|
|
14
|
+
listen(sessionId: string, onAuthorized: (token: string) => void, onDenied?: (msg: string) => void): void;
|
|
15
|
+
/**
|
|
16
|
+
* Terminate the session on the server
|
|
17
|
+
*/
|
|
18
|
+
logout(token: string): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Stop listening and disconnect socket
|
|
21
|
+
*/
|
|
22
|
+
disconnect(): void;
|
|
23
|
+
/**
|
|
24
|
+
* Fetch user profile using a session token
|
|
25
|
+
*/
|
|
26
|
+
getProfile(token: string): Promise<QidUser>;
|
|
27
|
+
/**
|
|
28
|
+
* Login using username and password
|
|
29
|
+
*/
|
|
30
|
+
login(credentials: {
|
|
31
|
+
username?: string;
|
|
32
|
+
email?: string;
|
|
33
|
+
password: string;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
token: string;
|
|
36
|
+
user: QidUser;
|
|
37
|
+
}>;
|
|
38
|
+
/**
|
|
39
|
+
* Register a new user
|
|
40
|
+
*/
|
|
41
|
+
register(data: {
|
|
42
|
+
username: string;
|
|
43
|
+
email: string;
|
|
44
|
+
password: string;
|
|
45
|
+
fullName?: string;
|
|
46
|
+
}): Promise<{
|
|
47
|
+
success: boolean;
|
|
48
|
+
message: string;
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Initiate registration (OTP based if configured)
|
|
52
|
+
*/
|
|
53
|
+
initiateRegistration(email: string): Promise<{
|
|
54
|
+
success: boolean;
|
|
55
|
+
message: string;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Verify OTP or mobile verification
|
|
59
|
+
*/
|
|
60
|
+
verify(data: {
|
|
61
|
+
email?: string;
|
|
62
|
+
otp?: string;
|
|
63
|
+
token?: string;
|
|
64
|
+
}): Promise<{
|
|
65
|
+
success: boolean;
|
|
66
|
+
token?: string;
|
|
67
|
+
}>;
|
|
68
|
+
/**
|
|
69
|
+
* Request a password reset link/OTP
|
|
70
|
+
*/
|
|
71
|
+
requestPasswordReset(email: string): Promise<{
|
|
72
|
+
success: boolean;
|
|
73
|
+
message: string;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Confirm password reset with OTP and new password
|
|
77
|
+
*/
|
|
78
|
+
confirmPasswordReset(data: {
|
|
79
|
+
email: string;
|
|
80
|
+
otp: string;
|
|
81
|
+
newPassword: string;
|
|
82
|
+
}): Promise<{
|
|
83
|
+
success: boolean;
|
|
84
|
+
message: string;
|
|
85
|
+
}>;
|
|
86
|
+
/**
|
|
87
|
+
* Change current password (requires current token)
|
|
88
|
+
*/
|
|
89
|
+
changePassword(token: string, data: {
|
|
90
|
+
currentPassword: string;
|
|
91
|
+
newPassword: string;
|
|
92
|
+
}): Promise<{
|
|
93
|
+
success: boolean;
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Delete user account
|
|
97
|
+
*/
|
|
98
|
+
deleteAccount(token: string): Promise<{
|
|
99
|
+
success: boolean;
|
|
100
|
+
}>;
|
|
101
|
+
/**
|
|
102
|
+
* Toggle MFA status (Enable/Disable)
|
|
103
|
+
*/
|
|
104
|
+
toggleMFA(token: string, data: {
|
|
105
|
+
enabled: boolean;
|
|
106
|
+
type: 'email' | 'totp' | 'mobile';
|
|
107
|
+
}): Promise<{
|
|
108
|
+
success: boolean;
|
|
109
|
+
message: string;
|
|
110
|
+
}>;
|
|
111
|
+
/**
|
|
112
|
+
* Verify MFA toggle request
|
|
113
|
+
*/
|
|
114
|
+
verifyMFA(token: string, otp: string): Promise<{
|
|
115
|
+
success: boolean;
|
|
116
|
+
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Refresh the current active session
|
|
119
|
+
*/
|
|
120
|
+
refreshSession(token: string): Promise<{
|
|
121
|
+
token: string;
|
|
122
|
+
}>;
|
|
123
|
+
/**
|
|
124
|
+
* List all active sessions for the user
|
|
125
|
+
*/
|
|
126
|
+
getSessions(token: string): Promise<QidSession[]>;
|
|
127
|
+
/**
|
|
128
|
+
* Revoke a specific session
|
|
129
|
+
*/
|
|
130
|
+
revokeSession(token: string, sessionToken: string): Promise<{
|
|
131
|
+
success: boolean;
|
|
132
|
+
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Initiate account recovery (password reset)
|
|
135
|
+
*/
|
|
136
|
+
initiateRecovery(email: string): Promise<{
|
|
137
|
+
success: boolean;
|
|
138
|
+
message: string;
|
|
139
|
+
}>;
|
|
140
|
+
/**
|
|
141
|
+
* Verify recovery OTP and set new password
|
|
142
|
+
*/
|
|
143
|
+
verifyRecovery(data: {
|
|
144
|
+
email: string;
|
|
145
|
+
otp: string;
|
|
146
|
+
newPassword: string;
|
|
147
|
+
}): Promise<{
|
|
148
|
+
success: boolean;
|
|
149
|
+
token: string;
|
|
150
|
+
}>;
|
|
151
|
+
/**
|
|
152
|
+
* Export all user data (GDPR requirement)
|
|
153
|
+
*/
|
|
154
|
+
exportUserData(token: string): Promise<any>;
|
|
155
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
import { QidBillingInfo, QidTransaction } from '../types';
|
|
3
|
+
export declare class BillingModule {
|
|
4
|
+
private sdk;
|
|
5
|
+
constructor(sdk: QidCloud);
|
|
6
|
+
/**
|
|
7
|
+
* Retrieve all available plans and their pricing
|
|
8
|
+
*/
|
|
9
|
+
getPlans(): Promise<any>;
|
|
10
|
+
/**
|
|
11
|
+
* Get detailed billing and usage info for a project
|
|
12
|
+
*/
|
|
13
|
+
getProjectBillingInfo(userToken: string, tenantId: string): Promise<QidBillingInfo>;
|
|
14
|
+
/**
|
|
15
|
+
* Sync payment status after a successful Razorpay transaction
|
|
16
|
+
* @param paymentId The Razorpay payment ID
|
|
17
|
+
*/
|
|
18
|
+
syncPaymentStatus(userToken: string, paymentId: string): Promise<{
|
|
19
|
+
success: boolean;
|
|
20
|
+
message: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Get transaction history for the current user
|
|
24
|
+
*/
|
|
25
|
+
getTransactions(userToken: string): Promise<QidTransaction[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Get usage analytics and history
|
|
28
|
+
*/
|
|
29
|
+
getUsageAnalytics(userToken: string): Promise<any>;
|
|
30
|
+
/**
|
|
31
|
+
* Get billing alerts for a specific project
|
|
32
|
+
*/
|
|
33
|
+
getBillingAlerts(userToken: string, tenantId: string): Promise<any[]>;
|
|
34
|
+
/**
|
|
35
|
+
* Create or update a billing alert
|
|
36
|
+
*/
|
|
37
|
+
createBillingAlert(userToken: string, tenantId: string, data: {
|
|
38
|
+
resource: string;
|
|
39
|
+
threshold: number;
|
|
40
|
+
}): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* Delete a billing alert
|
|
45
|
+
*/
|
|
46
|
+
deleteBillingAlert(userToken: string, alertId: string): Promise<{
|
|
47
|
+
success: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
/**
|
|
50
|
+
* Generate a consolidated financial report
|
|
51
|
+
*/
|
|
52
|
+
getConsolidatedReport(userToken: string, query?: {
|
|
53
|
+
year?: number;
|
|
54
|
+
startDate?: string;
|
|
55
|
+
endDate?: string;
|
|
56
|
+
}): Promise<any>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
import { QidDbResponse, QidMigration, QidMigrateResult } from '../types';
|
|
3
|
+
export declare class DbModule {
|
|
4
|
+
private sdk;
|
|
5
|
+
constructor(sdk: QidCloud);
|
|
6
|
+
/**
|
|
7
|
+
* Execute a SQL query against the project's enclave database
|
|
8
|
+
* @param sql The SQL query string
|
|
9
|
+
* @param params Parameterized values for the query
|
|
10
|
+
* @param userToken Optional session token for user-scoped access
|
|
11
|
+
*/
|
|
12
|
+
query<T = any>(sql: string, params?: any[], userToken?: string): Promise<QidDbResponse<T>>;
|
|
13
|
+
/**
|
|
14
|
+
* Initialize the project's enclave database schema
|
|
15
|
+
* Useful for first-time project setup
|
|
16
|
+
*/
|
|
17
|
+
setup(userToken?: string): Promise<{
|
|
18
|
+
success: boolean;
|
|
19
|
+
schemaName: string;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Run versioned migrations (Django-inspired).
|
|
23
|
+
* Only applies migrations that haven't been applied yet.
|
|
24
|
+
* Tracks applied migrations in a `_qid_migrations` table.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* await qid.db.migrate([
|
|
29
|
+
* { version: '001', name: 'create_users', up: async () => { await qid.db.query('CREATE TABLE ...') } },
|
|
30
|
+
* { version: '002', name: 'add_likes', up: async () => { await qid.db.query('ALTER TABLE ...') } },
|
|
31
|
+
* ]);
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* @param migrations Ordered array of migrations to apply
|
|
35
|
+
* @param userToken Optional session token
|
|
36
|
+
* @returns Result with applied/skipped counts
|
|
37
|
+
*/
|
|
38
|
+
migrate(migrations: QidMigration[], userToken?: string): Promise<QidMigrateResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Get the current migration status
|
|
41
|
+
* @param migrations The full list of registered migrations
|
|
42
|
+
* @param userToken Optional session token
|
|
43
|
+
*/
|
|
44
|
+
migrateStatus(migrations: QidMigration[], userToken?: string): Promise<{
|
|
45
|
+
applied: string[];
|
|
46
|
+
pending: string[];
|
|
47
|
+
total: number;
|
|
48
|
+
}>;
|
|
49
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
import { QidProject, QidProjectSettings } from '../types';
|
|
3
|
+
export declare class ProjectModule {
|
|
4
|
+
private sdk;
|
|
5
|
+
constructor(sdk: QidCloud);
|
|
6
|
+
/**
|
|
7
|
+
* Get all projects owned by the currently authenticated user
|
|
8
|
+
*/
|
|
9
|
+
getMyProjects(userToken: string): Promise<QidProject[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new project
|
|
12
|
+
*/
|
|
13
|
+
createProject(userToken: string, data: {
|
|
14
|
+
name: string;
|
|
15
|
+
tier?: string;
|
|
16
|
+
}): Promise<QidProject>;
|
|
17
|
+
/**
|
|
18
|
+
* Update project basic details (e.g. rename)
|
|
19
|
+
*/
|
|
20
|
+
updateProject(userToken: string, tenantId: string, data: {
|
|
21
|
+
name: string;
|
|
22
|
+
}): Promise<{
|
|
23
|
+
success: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Rotate the API key for a project
|
|
27
|
+
*/
|
|
28
|
+
rotateApiKey(userToken: string, tenantId: string): Promise<{
|
|
29
|
+
success: boolean;
|
|
30
|
+
apiKey: string;
|
|
31
|
+
}>;
|
|
32
|
+
/**
|
|
33
|
+
* Get project specific settings
|
|
34
|
+
*/
|
|
35
|
+
getSettings(userToken: string, tenantId: string): Promise<QidProjectSettings>;
|
|
36
|
+
/**
|
|
37
|
+
* Update project settings
|
|
38
|
+
*/
|
|
39
|
+
updateSettings(userToken: string, tenantId: string, settings: QidProjectSettings): Promise<{
|
|
40
|
+
success: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* Invite a new member to the project
|
|
44
|
+
*/
|
|
45
|
+
inviteMember(userToken: string, tenantId: string, data: {
|
|
46
|
+
email: string;
|
|
47
|
+
role: string;
|
|
48
|
+
}): Promise<{
|
|
49
|
+
success: boolean;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Remove a member from the project
|
|
53
|
+
*/
|
|
54
|
+
removeMember(userToken: string, tenantId: string, userId: string): Promise<{
|
|
55
|
+
success: boolean;
|
|
56
|
+
}>;
|
|
57
|
+
/**
|
|
58
|
+
* Get all users/members associated with a project
|
|
59
|
+
*/
|
|
60
|
+
getProjectUsers(userToken: string, tenantId: string): Promise<any[]>;
|
|
61
|
+
/**
|
|
62
|
+
* Get all invitations for the currently authenticated user
|
|
63
|
+
*/
|
|
64
|
+
getMyInvitations(userToken: string): Promise<any[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Accept or reject a project invitation
|
|
67
|
+
*/
|
|
68
|
+
handleInvitationAction(userToken: string, tenantId: string, action: 'accept' | 'reject'): Promise<{
|
|
69
|
+
success: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
/**
|
|
72
|
+
* Update a member's permissions within a project
|
|
73
|
+
*/
|
|
74
|
+
updateMemberPermissions(userToken: string, tenantId: string, userId: string, permissions: any): Promise<{
|
|
75
|
+
success: boolean;
|
|
76
|
+
}>;
|
|
77
|
+
/**
|
|
78
|
+
* Update a project user's status (active/suspended)
|
|
79
|
+
*/
|
|
80
|
+
updateProjectUserStatus(userToken: string, tenantId: string, regUserId: string, status: string): Promise<{
|
|
81
|
+
success: boolean;
|
|
82
|
+
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Unlink/Remove a user from the project identity enclave
|
|
85
|
+
*/
|
|
86
|
+
unlinkProjectUser(userToken: string, tenantId: string, regUserId: string): Promise<{
|
|
87
|
+
success: boolean;
|
|
88
|
+
}>;
|
|
89
|
+
/**
|
|
90
|
+
* Generate a new service key for the project
|
|
91
|
+
*/
|
|
92
|
+
generateServiceKey(userToken: string, tenantId: string, data: {
|
|
93
|
+
name: string;
|
|
94
|
+
permissions: any;
|
|
95
|
+
}): Promise<any>;
|
|
96
|
+
/**
|
|
97
|
+
* Revoke an existing service key
|
|
98
|
+
*/
|
|
99
|
+
revokeServiceKey(userToken: string, tenantId: string, keyId: string): Promise<{
|
|
100
|
+
success: boolean;
|
|
101
|
+
}>;
|
|
102
|
+
/**
|
|
103
|
+
* Permanently wipe the project's identity enclave data
|
|
104
|
+
*/
|
|
105
|
+
wipeProjectEnclave(userToken: string, tenantId: string): Promise<{
|
|
106
|
+
success: boolean;
|
|
107
|
+
}>;
|
|
108
|
+
/**
|
|
109
|
+
* Retrieve security and audit logs for the project
|
|
110
|
+
*/
|
|
111
|
+
getProjectSecurityLogs(userToken: string, tenantId: string): Promise<any[]>;
|
|
112
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
import { QidResourceStatus } from '../types';
|
|
3
|
+
export declare class ResourceModule {
|
|
4
|
+
private sdk;
|
|
5
|
+
constructor(sdk: QidCloud);
|
|
6
|
+
/**
|
|
7
|
+
* Get the status of all resources for a specific tenant
|
|
8
|
+
*/
|
|
9
|
+
getStatus(userToken: string, tenantId: string): Promise<QidResourceStatus[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Provision a new resource type for a project
|
|
12
|
+
* @param resourceType 'database' | 'storage' | 'edge'
|
|
13
|
+
*/
|
|
14
|
+
provision(userToken: string, tenantId: string, resourceType: string): Promise<{
|
|
15
|
+
success: boolean;
|
|
16
|
+
message: string;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* Dissolve (delete) an existing resource from a project
|
|
20
|
+
*/
|
|
21
|
+
dissolve(userToken: string, tenantId: string, resourceType: string): Promise<{
|
|
22
|
+
success: boolean;
|
|
23
|
+
message: string;
|
|
24
|
+
}>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { QidCloud } from '../index';
|
|
2
|
+
export declare class SdkModule {
|
|
3
|
+
private sdk;
|
|
4
|
+
constructor(sdk: QidCloud);
|
|
5
|
+
/**
|
|
6
|
+
* Get allowed origins for a project
|
|
7
|
+
*/
|
|
8
|
+
getOrigins(userToken: string, tenantId: string): Promise<string[]>;
|
|
9
|
+
/**
|
|
10
|
+
* Add an allowed origin for SDK requests
|
|
11
|
+
*/
|
|
12
|
+
addOrigin(userToken: string, tenantId: string, domain: string): Promise<{
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
}>;
|
|
16
|
+
/**
|
|
17
|
+
* Remove an allowed origin
|
|
18
|
+
*/
|
|
19
|
+
removeOrigin(userToken: string, tenantId: string, domain: string): Promise<{
|
|
20
|
+
success: boolean;
|
|
21
|
+
message: string;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Test if an origin is allowed
|
|
25
|
+
*/
|
|
26
|
+
testOrigin(userToken: string, tenantId: string, domain: string): Promise<{
|
|
27
|
+
allowed: boolean;
|
|
28
|
+
}>;
|
|
29
|
+
}
|
|
@@ -1,31 +1,48 @@
|
|
|
1
1
|
import { QidCloud } from '../index';
|
|
2
|
-
import { QidFile, QidUploadResponse } from '../types';
|
|
2
|
+
import { QidFile, QidUploadResponse, QidUploadOptions } from '../types';
|
|
3
3
|
export declare class VaultModule {
|
|
4
4
|
private sdk;
|
|
5
5
|
constructor(sdk: QidCloud);
|
|
6
6
|
/**
|
|
7
|
-
* Upload a file to the project's secure enclave storage
|
|
8
|
-
*
|
|
7
|
+
* Upload a file to the project's secure enclave storage.
|
|
8
|
+
*
|
|
9
|
+
* Files < 10MB use single-shot upload.
|
|
10
|
+
* Files >= 10MB automatically use chunked upload with progress tracking.
|
|
11
|
+
*
|
|
12
|
+
* @param file The file data (Buffer, Blob, or File)
|
|
9
13
|
* @param fileName Name of the file
|
|
10
14
|
* @param metadata Optional E2EE metadata or custom tags
|
|
11
15
|
* @param userToken Session token for user-scoped storage
|
|
16
|
+
* @param options Upload options (onProgress callback, custom chunk size)
|
|
12
17
|
*/
|
|
13
|
-
upload(file: any, fileName: string, metadata?: any, userToken?: string): Promise<QidUploadResponse>;
|
|
18
|
+
upload(file: any, fileName: string, metadata?: any, userToken?: string, options?: QidUploadOptions): Promise<QidUploadResponse>;
|
|
19
|
+
/**
|
|
20
|
+
* Single-shot upload for small files (< 10MB)
|
|
21
|
+
*/
|
|
22
|
+
private _singleUpload;
|
|
23
|
+
/**
|
|
24
|
+
* Chunked upload for large files (>= 10MB)
|
|
25
|
+
* Flow: init → upload chunks → complete
|
|
26
|
+
*/
|
|
27
|
+
private _chunkedUpload;
|
|
28
|
+
/**
|
|
29
|
+
* Get the status of a chunked upload (for resume support)
|
|
30
|
+
*/
|
|
31
|
+
getUploadStatus(uploadId: string, userToken?: string): Promise<any>;
|
|
32
|
+
/**
|
|
33
|
+
* Resume a partially completed chunked upload
|
|
34
|
+
*/
|
|
35
|
+
resumeUpload(uploadId: string, file: any, userToken?: string, options?: QidUploadOptions): Promise<QidUploadResponse>;
|
|
14
36
|
/**
|
|
15
37
|
* List files in the project enclave
|
|
16
|
-
* @param userToken Session token for user-scoped storage
|
|
17
38
|
*/
|
|
18
39
|
list(userToken?: string): Promise<QidFile[]>;
|
|
19
40
|
/**
|
|
20
41
|
* Download a file from storage
|
|
21
|
-
* @param fileId Unique ID of the file
|
|
22
|
-
* @param userToken Session token for user-scoped storage
|
|
23
42
|
*/
|
|
24
43
|
download(fileId: string, userToken?: string): Promise<ArrayBuffer>;
|
|
25
44
|
/**
|
|
26
45
|
* Delete a file from storage (Soft Delete)
|
|
27
|
-
* @param fileId Unique ID of the file
|
|
28
|
-
* @param userToken Session token for user-scoped storage
|
|
29
46
|
*/
|
|
30
47
|
delete(fileId: string, userToken?: string): Promise<{
|
|
31
48
|
success: boolean;
|
|
@@ -33,13 +50,10 @@ export declare class VaultModule {
|
|
|
33
50
|
}>;
|
|
34
51
|
/**
|
|
35
52
|
* List deleted files in the project enclave (Recycle Bin)
|
|
36
|
-
* @param userToken Session token for user-scoped storage
|
|
37
53
|
*/
|
|
38
54
|
listDeleted(userToken?: string): Promise<QidFile[]>;
|
|
39
55
|
/**
|
|
40
56
|
* Restore a deleted file from the recycle bin
|
|
41
|
-
* @param fileId Unique ID of the file
|
|
42
|
-
* @param userToken Session token for user-scoped storage
|
|
43
57
|
*/
|
|
44
58
|
restore(fileId: string, userToken?: string): Promise<{
|
|
45
59
|
success: boolean;
|
|
@@ -47,8 +61,6 @@ export declare class VaultModule {
|
|
|
47
61
|
}>;
|
|
48
62
|
/**
|
|
49
63
|
* Permanently purge a deleted file
|
|
50
|
-
* @param fileId Unique ID of the file
|
|
51
|
-
* @param userToken Session token for user-scoped storage
|
|
52
64
|
*/
|
|
53
65
|
purge(fileId: string, userToken?: string): Promise<{
|
|
54
66
|
success: boolean;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
export interface QidConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
tenantId?: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
export interface QidUser {
|
|
7
|
+
userId: string;
|
|
8
|
+
regUserId: string;
|
|
9
|
+
username: string;
|
|
10
|
+
email?: string;
|
|
11
|
+
role: string;
|
|
12
|
+
fullName?: string;
|
|
13
|
+
mfaEnabled?: boolean;
|
|
14
|
+
createdAt?: Date;
|
|
15
|
+
}
|
|
16
|
+
export interface QidSession {
|
|
17
|
+
token: string;
|
|
18
|
+
lastActive: Date;
|
|
19
|
+
ip?: string;
|
|
20
|
+
userAgent?: string;
|
|
21
|
+
}
|
|
22
|
+
export interface QidAuthSession {
|
|
23
|
+
sessionId: string;
|
|
24
|
+
qrData: string;
|
|
25
|
+
expiresAt: number;
|
|
26
|
+
}
|
|
27
|
+
export interface QidDbResponse<T = any> {
|
|
28
|
+
success: boolean;
|
|
29
|
+
data?: T;
|
|
30
|
+
error?: string;
|
|
31
|
+
count?: number;
|
|
32
|
+
meta?: any;
|
|
33
|
+
}
|
|
34
|
+
export interface QidEdgeResponse {
|
|
35
|
+
success: boolean;
|
|
36
|
+
result: any;
|
|
37
|
+
computeTime: string;
|
|
38
|
+
logs?: string[];
|
|
39
|
+
}
|
|
40
|
+
export interface QidFile {
|
|
41
|
+
fileId: string;
|
|
42
|
+
originalName: string;
|
|
43
|
+
mimeType: string;
|
|
44
|
+
size: number;
|
|
45
|
+
createdAt: string;
|
|
46
|
+
clientMetadata?: any;
|
|
47
|
+
}
|
|
48
|
+
export interface QidUploadResponse {
|
|
49
|
+
success: boolean;
|
|
50
|
+
message: string;
|
|
51
|
+
file: {
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
url: string;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
export interface QidProject {
|
|
58
|
+
_id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
tenantId: string;
|
|
61
|
+
apiKey: string;
|
|
62
|
+
owner: string;
|
|
63
|
+
tier: 'free' | 'pro' | 'elite' | 'enterprise';
|
|
64
|
+
status: 'active' | 'suspended' | 'pending';
|
|
65
|
+
}
|
|
66
|
+
export interface QidProjectSettings {
|
|
67
|
+
displayName?: string;
|
|
68
|
+
allowedOrigins?: string[];
|
|
69
|
+
enclaveConfig?: any;
|
|
70
|
+
}
|
|
71
|
+
export interface QidResourceStatus {
|
|
72
|
+
resourceType: string;
|
|
73
|
+
status: 'active' | 'provisioning' | 'failed' | 'dissolved';
|
|
74
|
+
endpoint?: string;
|
|
75
|
+
details?: any;
|
|
76
|
+
}
|
|
77
|
+
export interface QidBillingInfo {
|
|
78
|
+
plan: string;
|
|
79
|
+
profile: string;
|
|
80
|
+
estimatedMonthly: number;
|
|
81
|
+
estimatedHourly: string;
|
|
82
|
+
infraValueUSD: string;
|
|
83
|
+
currency: string;
|
|
84
|
+
activeEnclaves: string[];
|
|
85
|
+
billingNote?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface QidTransaction {
|
|
88
|
+
transactionId: string;
|
|
89
|
+
amount: number;
|
|
90
|
+
date: string;
|
|
91
|
+
status: string;
|
|
92
|
+
planId: string;
|
|
93
|
+
currency?: string;
|
|
94
|
+
}
|
|
95
|
+
export interface QidBillingAlert {
|
|
96
|
+
_id: string;
|
|
97
|
+
resource: string;
|
|
98
|
+
threshold: number;
|
|
99
|
+
status: string;
|
|
100
|
+
}
|
|
101
|
+
export interface QidMigration {
|
|
102
|
+
version: string;
|
|
103
|
+
name: string;
|
|
104
|
+
up: () => Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
export interface QidMigrateResult {
|
|
107
|
+
success: boolean;
|
|
108
|
+
applied: string[];
|
|
109
|
+
skipped: string[];
|
|
110
|
+
failed?: {
|
|
111
|
+
version: string;
|
|
112
|
+
error: string;
|
|
113
|
+
};
|
|
114
|
+
total: number;
|
|
115
|
+
}
|
|
116
|
+
export interface QidUploadProgress {
|
|
117
|
+
percent: number;
|
|
118
|
+
uploadedChunks: number;
|
|
119
|
+
totalChunks: number;
|
|
120
|
+
uploadedBytes: number;
|
|
121
|
+
totalBytes: number;
|
|
122
|
+
}
|
|
123
|
+
export interface QidUploadOptions {
|
|
124
|
+
onProgress?: (progress: QidUploadProgress) => void;
|
|
125
|
+
chunkSize?: number;
|
|
126
|
+
}
|