@privitty/privitty-core 0.3.1
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 +117 -0
- package/index.d.ts +16 -0
- package/index.js +86 -0
- package/package.json +45 -0
package/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# @privitty/privitty-core
|
|
2
|
+
|
|
3
|
+
Native binary wrapper for Privitty Core - JSON-RPC server for secure file encryption and access control.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @privitty/privitty-core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
The package automatically installs the correct platform-specific binary for your system.
|
|
12
|
+
|
|
13
|
+
## Supported Platforms
|
|
14
|
+
|
|
15
|
+
- **macOS**: darwin-arm64, darwin-x64
|
|
16
|
+
- **Windows**: win32-x64
|
|
17
|
+
- **Linux**: linux-x64
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
### Getting the Binary Path
|
|
22
|
+
|
|
23
|
+
```javascript
|
|
24
|
+
const { getBinaryPath } = require('@privitty/privitty-core');
|
|
25
|
+
|
|
26
|
+
const binaryPath = getBinaryPath();
|
|
27
|
+
console.log('Privitty binary:', binaryPath);
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Spawning the JSON-RPC Server
|
|
31
|
+
|
|
32
|
+
```javascript
|
|
33
|
+
const { spawn } = require('child_process');
|
|
34
|
+
const { getBinaryPath } = require('@privitty/privitty-core');
|
|
35
|
+
|
|
36
|
+
const binaryPath = getBinaryPath();
|
|
37
|
+
const serverProcess = spawn(binaryPath, {
|
|
38
|
+
env: {
|
|
39
|
+
// Your environment variables
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// Handle JSON-RPC over stdio
|
|
44
|
+
serverProcess.stdout.on('data', (data) => {
|
|
45
|
+
const response = JSON.parse(data.toString());
|
|
46
|
+
console.log('Response:', response);
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
serverProcess.stdin.write(JSON.stringify({
|
|
50
|
+
jsonrpc: '2.0',
|
|
51
|
+
method: 'switchProfile',
|
|
52
|
+
params: { username: 'alice', user_email: 'alice@example.com', user_id: '1' },
|
|
53
|
+
id: 1
|
|
54
|
+
}) + '\n');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
### Integration with Electron
|
|
58
|
+
|
|
59
|
+
See [client.ts example](/Users/milinddeore/PROJECTS/delta/privitty-desktop/packages/target-electron/src/privitty/client.ts) for a complete Electron integration.
|
|
60
|
+
|
|
61
|
+
## Platform Information
|
|
62
|
+
|
|
63
|
+
```javascript
|
|
64
|
+
const { getPlatformInfo } = require('@privitty/privitty-core');
|
|
65
|
+
|
|
66
|
+
const info = getPlatformInfo();
|
|
67
|
+
console.log(info);
|
|
68
|
+
// {
|
|
69
|
+
// platform: 'darwin',
|
|
70
|
+
// arch: 'arm64',
|
|
71
|
+
// binaryPath: '/path/to/binary'
|
|
72
|
+
// }
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Architecture
|
|
76
|
+
|
|
77
|
+
This is a meta-package that depends on platform-specific packages:
|
|
78
|
+
|
|
79
|
+
- `@privitty/privitty-core-darwin-arm64` - macOS Apple Silicon
|
|
80
|
+
- `@privitty/privitty-core-darwin-x64` - macOS Intel
|
|
81
|
+
- `@privitty/privitty-core-linux-x64` - Linux x86_64
|
|
82
|
+
- `@privitty/privitty-core-win32-x64` - Windows 64-bit
|
|
83
|
+
|
|
84
|
+
npm automatically installs only the package for your current platform.
|
|
85
|
+
|
|
86
|
+
## JSON-RPC API
|
|
87
|
+
|
|
88
|
+
The binary communicates via JSON-RPC 2.0 over stdio. Available methods:
|
|
89
|
+
|
|
90
|
+
- `switchProfile` - Switch user profile
|
|
91
|
+
- `getSystemState` - Get system state
|
|
92
|
+
- `getHealth` - Health check
|
|
93
|
+
- `initCreateGroup` - Create a group
|
|
94
|
+
- `initAddMemberToGroup` - Add member to group
|
|
95
|
+
- `processFileEncryptRequest` - Encrypt file
|
|
96
|
+
- `processFileDecryptRequest` - Decrypt file
|
|
97
|
+
- `processGroupFileEncryptRequest` - Encrypt group file
|
|
98
|
+
- `processGroupFileDecryptRequest` - Decrypt group file
|
|
99
|
+
- And more...
|
|
100
|
+
|
|
101
|
+
See platform-specific API documentation for complete details.
|
|
102
|
+
|
|
103
|
+
## Version
|
|
104
|
+
|
|
105
|
+
This package version is independent of the native binary version. Check the binary version:
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
./privitty-server --version
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
## License
|
|
112
|
+
|
|
113
|
+
Proprietary - Alanring Technologies Private Limited
|
|
114
|
+
|
|
115
|
+
## Support
|
|
116
|
+
|
|
117
|
+
For issues and questions, contact Alanring Technologies Private Limited.
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the path to the Privitty native binary for the current platform
|
|
3
|
+
* @returns Absolute path to the binary
|
|
4
|
+
* @throws {Error} If platform/architecture is not supported or binary is missing
|
|
5
|
+
*/
|
|
6
|
+
export function getBinaryPath(): string;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Get information about the current platform and binary
|
|
10
|
+
* @returns Platform information
|
|
11
|
+
*/
|
|
12
|
+
export function getPlatformInfo(): {
|
|
13
|
+
platform: string;
|
|
14
|
+
arch: string;
|
|
15
|
+
binaryPath: string;
|
|
16
|
+
};
|
package/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const { platform, arch } = require('os');
|
|
2
|
+
const { join } = require('path');
|
|
3
|
+
const { existsSync } = require('fs');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Get the path to the Privitty native binary for the current platform
|
|
7
|
+
* @returns {string} Absolute path to the binary
|
|
8
|
+
* @throws {Error} If platform/architecture is not supported or binary is missing
|
|
9
|
+
*/
|
|
10
|
+
function getBinaryPath() {
|
|
11
|
+
const platformName = platform();
|
|
12
|
+
const archName = arch();
|
|
13
|
+
|
|
14
|
+
// Map Node.js platform/arch to our package names
|
|
15
|
+
let packageName;
|
|
16
|
+
let binaryName;
|
|
17
|
+
|
|
18
|
+
if (platformName === 'darwin') {
|
|
19
|
+
if (archName === 'arm64') {
|
|
20
|
+
packageName = '@privitty/privitty-core-darwin-arm64';
|
|
21
|
+
binaryName = 'privitty-server';
|
|
22
|
+
} else if (archName === 'x64') {
|
|
23
|
+
packageName = '@privitty/privitty-core-darwin-x64';
|
|
24
|
+
binaryName = 'privitty-server';
|
|
25
|
+
} else {
|
|
26
|
+
throw new Error(`Unsupported macOS architecture: ${archName}`);
|
|
27
|
+
}
|
|
28
|
+
} else if (platformName === 'linux') {
|
|
29
|
+
if (archName === 'x64') {
|
|
30
|
+
packageName = '@privitty/privitty-core-linux-x64';
|
|
31
|
+
binaryName = 'privitty-server';
|
|
32
|
+
} else {
|
|
33
|
+
throw new Error(`Unsupported Linux architecture: ${archName}. Only x64 is supported.`);
|
|
34
|
+
}
|
|
35
|
+
} else if (platformName === 'win32') {
|
|
36
|
+
if (archName === 'x64') {
|
|
37
|
+
packageName = '@privitty/privitty-core-win32-x64';
|
|
38
|
+
binaryName = 'privitty-server.exe';
|
|
39
|
+
} else {
|
|
40
|
+
throw new Error(`Unsupported Windows architecture: ${archName}. Only x64 is supported.`);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
throw new Error(`Unsupported platform: ${platformName}`);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Try to require the platform-specific package
|
|
47
|
+
let binaryPath;
|
|
48
|
+
try {
|
|
49
|
+
const packagePath = require.resolve(packageName);
|
|
50
|
+
const packageDir = join(packagePath, '..', '..');
|
|
51
|
+
binaryPath = join(packageDir, binaryName);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
throw new Error(
|
|
54
|
+
`Platform-specific package not found: ${packageName}. ` +
|
|
55
|
+
`This usually means the optional dependency was not installed. ` +
|
|
56
|
+
`Platform: ${platformName}, Architecture: ${archName}`
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// Verify the binary exists
|
|
61
|
+
if (!existsSync(binaryPath)) {
|
|
62
|
+
throw new Error(
|
|
63
|
+
`Binary not found at expected path: ${binaryPath}. ` +
|
|
64
|
+
`Package: ${packageName}`
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return binaryPath;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Get information about the current platform and binary
|
|
73
|
+
* @returns {object} Platform information
|
|
74
|
+
*/
|
|
75
|
+
function getPlatformInfo() {
|
|
76
|
+
return {
|
|
77
|
+
platform: platform(),
|
|
78
|
+
arch: arch(),
|
|
79
|
+
binaryPath: getBinaryPath(),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = {
|
|
84
|
+
getBinaryPath,
|
|
85
|
+
getPlatformInfo,
|
|
86
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@privitty/privitty-core",
|
|
3
|
+
"version": "0.3.1",
|
|
4
|
+
"description": "Privitty Core - Native binary wrapper for JSON-RPC server",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"index.js",
|
|
9
|
+
"index.d.ts",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"scripts": {
|
|
13
|
+
"test": "node test.js"
|
|
14
|
+
},
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/privitty/privitty-core.git"
|
|
18
|
+
},
|
|
19
|
+
"keywords": [
|
|
20
|
+
"privitty",
|
|
21
|
+
"native",
|
|
22
|
+
"binary",
|
|
23
|
+
"jsonrpc",
|
|
24
|
+
"encryption"
|
|
25
|
+
],
|
|
26
|
+
"author": "Alanring Technologies Private Limited",
|
|
27
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
28
|
+
"optionalDependencies": {
|
|
29
|
+
"@privitty/privitty-core-darwin-arm64": "0.3.0",
|
|
30
|
+
"@privitty/privitty-core-linux-x64": "0.3.0",
|
|
31
|
+
"@privitty/privitty-core-win32-x64": "0.3.0"
|
|
32
|
+
},
|
|
33
|
+
"engines": {
|
|
34
|
+
"node": ">=14.0.0"
|
|
35
|
+
},
|
|
36
|
+
"os": [
|
|
37
|
+
"darwin",
|
|
38
|
+
"linux",
|
|
39
|
+
"win32"
|
|
40
|
+
],
|
|
41
|
+
"cpu": [
|
|
42
|
+
"x64",
|
|
43
|
+
"arm64"
|
|
44
|
+
]
|
|
45
|
+
}
|