@qidcloud/sdk 1.1.0 → 1.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/README.md +99 -256
- package/dist/components/QidSignInButton.d.ts +12 -0
- package/dist/index.d.ts +23 -4
- package/dist/index.js +2249 -5
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +2243 -0
- package/dist/index.mjs.map +1 -0
- package/dist/modules/auth.d.ts +23 -0
- package/dist/modules/db.d.ts +21 -0
- package/dist/modules/edge.d.ts +33 -0
- package/dist/modules/logs.d.ts +20 -0
- package/dist/modules/vault.d.ts +34 -0
- package/dist/types.d.ts +46 -0
- package/package.json +36 -15
- package/dist/QidCloud.d.ts +0 -31
- package/dist/QidCloud.js +0 -142
- package/dist/crypto/pqc.d.ts +0 -12
- package/dist/crypto/pqc.js +0 -91
- package/dist/storage/index.d.ts +0 -18
- package/dist/storage/index.js +0 -58
- package/dist/utils.d.ts +0 -5
- package/dist/utils.js +0 -46
- package/src/QidCloud.ts +0 -171
- package/src/crypto/pqc.ts +0 -79
- package/src/index.ts +0 -7
- package/src/storage/index.ts +0 -49
- package/src/utils.ts +0 -48
- package/tsconfig.json +0 -20
- package/verify_sdk.ts +0 -53
package/src/storage/index.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export interface IStorage {
|
|
2
|
-
getItem(key: string): Promise<string | null>;
|
|
3
|
-
setItem(key: string, value: string): Promise<void>;
|
|
4
|
-
removeItem(key: string): Promise<void>;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export class MemoryStorage implements IStorage {
|
|
8
|
-
private storage: Map<string, string> = new Map();
|
|
9
|
-
|
|
10
|
-
async getItem(key: string): Promise<string | null> {
|
|
11
|
-
return this.storage.get(key) || null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
async setItem(key: string, value: string): Promise<void> {
|
|
15
|
-
this.storage.set(key, value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
async removeItem(key: string): Promise<void> {
|
|
19
|
-
this.storage.delete(key);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export class LocalStorageAdapter implements IStorage {
|
|
24
|
-
async getItem(key: string): Promise<string | null> {
|
|
25
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
26
|
-
return window.localStorage.getItem(key);
|
|
27
|
-
}
|
|
28
|
-
return null;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
async setItem(key: string, value: string): Promise<void> {
|
|
32
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
33
|
-
window.localStorage.setItem(key, value);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
async removeItem(key: string): Promise<void> {
|
|
38
|
-
if (typeof window !== 'undefined' && window.localStorage) {
|
|
39
|
-
window.localStorage.removeItem(key);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// Default export: Auto-detect
|
|
45
|
-
const storage = typeof window !== 'undefined' && window.localStorage
|
|
46
|
-
? new LocalStorageAdapter()
|
|
47
|
-
: new MemoryStorage();
|
|
48
|
-
|
|
49
|
-
export default storage;
|
package/src/utils.ts
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
export function generateUUID(): string {
|
|
2
|
-
if (typeof crypto !== 'undefined' && crypto.randomUUID) {
|
|
3
|
-
return crypto.randomUUID();
|
|
4
|
-
}
|
|
5
|
-
// Fallback for environments without randomUUID
|
|
6
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
7
|
-
var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
|
|
8
|
-
return v.toString(16);
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function buf2hex(buffer: Uint8Array): string {
|
|
13
|
-
return Array.prototype.map.call(new Uint8Array(buffer), (x: number) => ('00' + x.toString(16)).slice(-2)).join('');
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function hex2buf(hex: string): Uint8Array {
|
|
17
|
-
if (!hex) return new Uint8Array(0);
|
|
18
|
-
const bytes = new Uint8Array(Math.ceil(hex.length / 2));
|
|
19
|
-
for (let i = 0; i < bytes.length; i++) bytes[i] = parseInt(hex.substr(i * 2, 2), 16);
|
|
20
|
-
return bytes;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export function toBase64(bytes: Uint8Array): string {
|
|
24
|
-
if (typeof Buffer !== 'undefined') {
|
|
25
|
-
return Buffer.from(bytes).toString('base64');
|
|
26
|
-
}
|
|
27
|
-
// Browser fallback
|
|
28
|
-
let binary = '';
|
|
29
|
-
const len = bytes.byteLength;
|
|
30
|
-
for (let i = 0; i < len; i++) {
|
|
31
|
-
binary += String.fromCharCode(bytes[i]);
|
|
32
|
-
}
|
|
33
|
-
return window.btoa(binary);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function fromBase64(base64: string): Uint8Array {
|
|
37
|
-
if (typeof Buffer !== 'undefined') {
|
|
38
|
-
return new Uint8Array(Buffer.from(base64, 'base64'));
|
|
39
|
-
}
|
|
40
|
-
// Browser fallback
|
|
41
|
-
const binary_string = window.atob(base64);
|
|
42
|
-
const len = binary_string.length;
|
|
43
|
-
const bytes = new Uint8Array(len);
|
|
44
|
-
for (let i = 0; i < len; i++) {
|
|
45
|
-
bytes[i] = binary_string.charCodeAt(i);
|
|
46
|
-
}
|
|
47
|
-
return bytes;
|
|
48
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES6",
|
|
4
|
-
"module": "ESNext",
|
|
5
|
-
"moduleResolution": "bundler",
|
|
6
|
-
"lib": [
|
|
7
|
-
"DOM",
|
|
8
|
-
"ES2017"
|
|
9
|
-
],
|
|
10
|
-
"declaration": true,
|
|
11
|
-
"outDir": "./dist",
|
|
12
|
-
"strict": true,
|
|
13
|
-
"esModuleInterop": true,
|
|
14
|
-
"skipLibCheck": true,
|
|
15
|
-
"forceConsistentCasingInFileNames": true
|
|
16
|
-
},
|
|
17
|
-
"include": [
|
|
18
|
-
"src/**/*"
|
|
19
|
-
]
|
|
20
|
-
}
|
package/verify_sdk.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import { QGateClient } from './src';
|
|
2
|
-
import * as PQC from './src/crypto/pqc';
|
|
3
|
-
|
|
4
|
-
async function verify() {
|
|
5
|
-
console.log('--- QGate SDK Verification ---');
|
|
6
|
-
|
|
7
|
-
// 1. Verify Exports
|
|
8
|
-
if (!QGateClient) {
|
|
9
|
-
throw new Error('QGateClient export missing');
|
|
10
|
-
}
|
|
11
|
-
console.log('✅ QGateClient exported');
|
|
12
|
-
|
|
13
|
-
// 2. Verify PQC Generation (Dilithium)
|
|
14
|
-
console.log('Testing Dilithium Seed Generation...');
|
|
15
|
-
const seed = await PQC.generateDilithiumSeed();
|
|
16
|
-
console.log('Generated Seed:', seed);
|
|
17
|
-
if (!seed || seed.length !== 64) { // 32 bytes hex
|
|
18
|
-
throw new Error('Invalid seed generated');
|
|
19
|
-
}
|
|
20
|
-
console.log('✅ Dilithium Seed Generated');
|
|
21
|
-
|
|
22
|
-
// 3. Verify Key Derivation
|
|
23
|
-
console.log('Deriving Keys...');
|
|
24
|
-
const keys = await PQC.getKeysFromSeed(seed);
|
|
25
|
-
if (!keys.publicKey || !keys.privateKey) {
|
|
26
|
-
throw new Error('Failed to derive keys');
|
|
27
|
-
}
|
|
28
|
-
console.log('✅ Keys Derived');
|
|
29
|
-
|
|
30
|
-
// 4. Verify Signing
|
|
31
|
-
console.log('Testing Signing...');
|
|
32
|
-
const msg = "Hello QGate";
|
|
33
|
-
const sig = keys.sign(new TextEncoder().encode(msg));
|
|
34
|
-
console.log('Signature Length:', sig.length);
|
|
35
|
-
if (sig.length === 0) {
|
|
36
|
-
throw new Error('Signature failed');
|
|
37
|
-
}
|
|
38
|
-
console.log('✅ Signing Success'); // Verification requires Dilithium library verify which we didn't export in PQC yet but sign works.
|
|
39
|
-
|
|
40
|
-
// 5. Verify Client Instantiation
|
|
41
|
-
const client = new QGateClient({
|
|
42
|
-
baseUrl: 'http://localhost:3000',
|
|
43
|
-
apiKey: 'test-key'
|
|
44
|
-
});
|
|
45
|
-
console.log('✅ Client Instantiated');
|
|
46
|
-
|
|
47
|
-
console.log('--- SDK VERIFIED ---');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
verify().catch(err => {
|
|
51
|
-
console.error('❌ VERIFICATION FAILED:', err);
|
|
52
|
-
process.exit(1);
|
|
53
|
-
});
|