@qpher/sdk 0.1.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 +266 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +55 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +106 -0
- package/dist/errors.js.map +1 -0
- package/dist/esm/client.d.ts +32 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +51 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.d.ts +35 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +93 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http-client.d.ts +21 -0
- package/dist/esm/http-client.d.ts.map +1 -0
- package/dist/esm/http-client.js +104 -0
- package/dist/esm/http-client.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kem.d.ts +24 -0
- package/dist/esm/kem.d.ts.map +1 -0
- package/dist/esm/kem.js +52 -0
- package/dist/esm/kem.js.map +1 -0
- package/dist/esm/keys.d.ts +52 -0
- package/dist/esm/keys.d.ts.map +1 -0
- package/dist/esm/keys.js +110 -0
- package/dist/esm/keys.js.map +1 -0
- package/dist/esm/signatures.d.ts +24 -0
- package/dist/esm/signatures.d.ts.map +1 -0
- package/dist/esm/signatures.js +49 -0
- package/dist/esm/signatures.js.map +1 -0
- package/dist/esm/types.d.ts +122 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/http-client.d.ts +21 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +108 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/kem.d.ts +24 -0
- package/dist/kem.d.ts.map +1 -0
- package/dist/kem.js +56 -0
- package/dist/kem.js.map +1 -0
- package/dist/keys.d.ts +52 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +114 -0
- package/dist/keys.js.map +1 -0
- package/dist/signatures.d.ts +24 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +53 -0
- package/dist/signatures.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Dilithium3 digital signature operations.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.SignaturesModule = void 0;
|
|
7
|
+
class SignaturesModule {
|
|
8
|
+
http;
|
|
9
|
+
constructor(http) {
|
|
10
|
+
this.http = http;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Sign a message using Dilithium3.
|
|
14
|
+
*
|
|
15
|
+
* @param input - Signing parameters
|
|
16
|
+
* @returns Signed result with signature bytes (3,293 bytes raw)
|
|
17
|
+
*/
|
|
18
|
+
async sign(input) {
|
|
19
|
+
const body = {
|
|
20
|
+
message: input.message.toString('base64'),
|
|
21
|
+
key_version: input.keyVersion,
|
|
22
|
+
};
|
|
23
|
+
const response = await this.http.post('/api/v1/signature/sign', body);
|
|
24
|
+
return {
|
|
25
|
+
signature: Buffer.from(response.data.signature, 'base64'),
|
|
26
|
+
keyVersion: response.data.key_version,
|
|
27
|
+
algorithm: response.data.algorithm,
|
|
28
|
+
requestId: response.request_id,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Verify a Dilithium3 signature.
|
|
33
|
+
*
|
|
34
|
+
* @param input - Verification parameters
|
|
35
|
+
* @returns Verification result with valid=true/false
|
|
36
|
+
*/
|
|
37
|
+
async verify(input) {
|
|
38
|
+
const body = {
|
|
39
|
+
message: input.message.toString('base64'),
|
|
40
|
+
signature: input.signature.toString('base64'),
|
|
41
|
+
key_version: input.keyVersion,
|
|
42
|
+
};
|
|
43
|
+
const response = await this.http.post('/api/v1/signature/verify', body);
|
|
44
|
+
return {
|
|
45
|
+
valid: response.data.valid,
|
|
46
|
+
keyVersion: response.data.key_version,
|
|
47
|
+
algorithm: response.data.algorithm,
|
|
48
|
+
requestId: response.request_id,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.SignaturesModule = SignaturesModule;
|
|
53
|
+
//# sourceMappingURL=signatures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatures.js","sourceRoot":"","sources":["../src/signatures.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAyBH,MAAa,gBAAgB;IACV,IAAI,CAAa;IAElC,YAAY,IAAgB;QAC1B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,KAAgB;QACzB,MAAM,IAAI,GAAG;YACX,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACzC,WAAW,EAAE,KAAK,CAAC,UAAU;SAC9B,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,wBAAwB,EACxB,IAAI,CACL,CAAC;QAEF,OAAO;YACL,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC;YACzD,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;YACrC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS;YAClC,SAAS,EAAE,QAAQ,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,KAAkB;QAC7B,MAAM,IAAI,GAAG;YACX,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC;YACzC,SAAS,EAAE,KAAK,CAAC,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAC7C,WAAW,EAAE,KAAK,CAAC,UAAU;SAC9B,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CACnC,0BAA0B,EAC1B,IAAI,CACL,CAAC;QAEF,OAAO;YACL,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK;YAC1B,UAAU,EAAE,QAAQ,CAAC,IAAI,CAAC,WAAW;YACrC,SAAS,EAAE,QAAQ,CAAC,IAAI,CAAC,SAAS;YAClC,SAAS,EAAE,QAAQ,CAAC,UAAU;SAC/B,CAAC;IACJ,CAAC;CACF;AAzDD,4CAyDC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript types for Qpher SDK.
|
|
3
|
+
*/
|
|
4
|
+
export interface QpherOptions {
|
|
5
|
+
apiKey: string;
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
timeout?: number;
|
|
8
|
+
maxRetries?: number;
|
|
9
|
+
}
|
|
10
|
+
export interface EncryptInput {
|
|
11
|
+
plaintext: Buffer;
|
|
12
|
+
keyVersion: number;
|
|
13
|
+
mode?: 'standard' | 'deterministic';
|
|
14
|
+
salt?: Buffer;
|
|
15
|
+
}
|
|
16
|
+
export interface EncryptResult {
|
|
17
|
+
ciphertext: Buffer;
|
|
18
|
+
keyVersion: number;
|
|
19
|
+
algorithm: string;
|
|
20
|
+
requestId: string;
|
|
21
|
+
}
|
|
22
|
+
export interface DecryptInput {
|
|
23
|
+
ciphertext: Buffer;
|
|
24
|
+
keyVersion: number;
|
|
25
|
+
}
|
|
26
|
+
export interface DecryptResult {
|
|
27
|
+
plaintext: Buffer;
|
|
28
|
+
keyVersion: number;
|
|
29
|
+
algorithm: string;
|
|
30
|
+
requestId: string;
|
|
31
|
+
}
|
|
32
|
+
export interface SignInput {
|
|
33
|
+
message: Buffer;
|
|
34
|
+
keyVersion: number;
|
|
35
|
+
}
|
|
36
|
+
export interface SignResult {
|
|
37
|
+
signature: Buffer;
|
|
38
|
+
keyVersion: number;
|
|
39
|
+
algorithm: string;
|
|
40
|
+
requestId: string;
|
|
41
|
+
}
|
|
42
|
+
export interface VerifyInput {
|
|
43
|
+
message: Buffer;
|
|
44
|
+
signature: Buffer;
|
|
45
|
+
keyVersion: number;
|
|
46
|
+
}
|
|
47
|
+
export interface VerifyResult {
|
|
48
|
+
valid: boolean;
|
|
49
|
+
keyVersion: number;
|
|
50
|
+
algorithm: string;
|
|
51
|
+
requestId: string;
|
|
52
|
+
}
|
|
53
|
+
export interface KeyInfo {
|
|
54
|
+
keyVersion: number;
|
|
55
|
+
algorithm: string;
|
|
56
|
+
status: string;
|
|
57
|
+
publicKey: Buffer;
|
|
58
|
+
createdAt: string;
|
|
59
|
+
}
|
|
60
|
+
export interface KeyListResult {
|
|
61
|
+
keys: KeyInfo[];
|
|
62
|
+
total: number;
|
|
63
|
+
requestId: string;
|
|
64
|
+
}
|
|
65
|
+
export interface GenerateInput {
|
|
66
|
+
algorithm: string;
|
|
67
|
+
}
|
|
68
|
+
export interface GenerateResult {
|
|
69
|
+
keyVersion: number;
|
|
70
|
+
algorithm: string;
|
|
71
|
+
status: string;
|
|
72
|
+
publicKey: Buffer;
|
|
73
|
+
createdAt: string;
|
|
74
|
+
requestId: string;
|
|
75
|
+
}
|
|
76
|
+
export interface RotateInput {
|
|
77
|
+
algorithm: string;
|
|
78
|
+
}
|
|
79
|
+
export interface RotateResult {
|
|
80
|
+
keyVersion: number;
|
|
81
|
+
algorithm: string;
|
|
82
|
+
publicKey: Buffer;
|
|
83
|
+
oldKeyVersion: number;
|
|
84
|
+
requestId: string;
|
|
85
|
+
}
|
|
86
|
+
export interface GetActiveInput {
|
|
87
|
+
algorithm: string;
|
|
88
|
+
}
|
|
89
|
+
export interface GetKeyInput {
|
|
90
|
+
algorithm: string;
|
|
91
|
+
keyVersion: number;
|
|
92
|
+
}
|
|
93
|
+
export interface ListKeysInput {
|
|
94
|
+
algorithm?: string;
|
|
95
|
+
status?: string;
|
|
96
|
+
}
|
|
97
|
+
export interface RetireInput {
|
|
98
|
+
algorithm: string;
|
|
99
|
+
keyVersion: number;
|
|
100
|
+
}
|
|
101
|
+
export interface RetireResult {
|
|
102
|
+
keyVersion: number;
|
|
103
|
+
algorithm: string;
|
|
104
|
+
status: string;
|
|
105
|
+
publicKey: Buffer;
|
|
106
|
+
createdAt: string;
|
|
107
|
+
requestId: string;
|
|
108
|
+
}
|
|
109
|
+
export interface ApiResponse<T> {
|
|
110
|
+
data: T;
|
|
111
|
+
requestId: string;
|
|
112
|
+
timestamp: string;
|
|
113
|
+
}
|
|
114
|
+
export interface ApiErrorResponse {
|
|
115
|
+
error: {
|
|
116
|
+
errorCode: string;
|
|
117
|
+
message: string;
|
|
118
|
+
};
|
|
119
|
+
requestId: string;
|
|
120
|
+
timestamp: string;
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAGD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;I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AAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE;QACL,SAAS,EAAE,MAAM,CAAC;QAClB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@qpher/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Official Node.js SDK for the Qpher Post-Quantum Cryptography API",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/esm/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"require": "./dist/index.js",
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json && tsc -p tsconfig.build.json --module ESNext --outDir dist/esm",
|
|
20
|
+
"test": "jest",
|
|
21
|
+
"test:coverage": "jest --coverage",
|
|
22
|
+
"lint": "eslint src tests",
|
|
23
|
+
"clean": "rm -rf dist"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"post-quantum",
|
|
27
|
+
"cryptography",
|
|
28
|
+
"pqc",
|
|
29
|
+
"kyber",
|
|
30
|
+
"dilithium",
|
|
31
|
+
"encryption",
|
|
32
|
+
"signatures",
|
|
33
|
+
"qpher"
|
|
34
|
+
],
|
|
35
|
+
"author": "Qpher <sdk@qpher.ai>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"repository": {
|
|
38
|
+
"type": "git",
|
|
39
|
+
"url": "git+https://github.com/qpher/qpher-node.git"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/qpher/qpher-node/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://qpher.ai",
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": ">=18.0.0"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@types/jest": "^29.5.0",
|
|
50
|
+
"@types/node": "^20.0.0",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"ts-jest": "^29.1.0",
|
|
53
|
+
"typescript": "^5.3.0"
|
|
54
|
+
}
|
|
55
|
+
}
|