@nihilium/client-sdk 0.1.1 → 0.1.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.
- package/dist/browser.esm-kreqNYRZ-BLoDyLFh.js +16271 -0
- package/dist/{browser/browser.esm-kreqNYRZ-CV3K9CfO-I-qnoSbY.mjs → browser.esm-kreqNYRZ-CV3K9CfO-DeSbuL7e.js} +1 -1
- package/dist/{browser/index-BbrmIoGc.mjs → index-78RSe_cY.js} +69008 -39334
- package/dist/{browser/index-CaU6sT7E-DPVApZD5.mjs → index-C3cHMpbE-BjZqbn-8.js} +38 -38
- package/dist/index-DFD-0QrS-BD9Z8naZ.js +1551 -0
- package/dist/index-DFD-0QrS-DqRwsoRk-DaSQ-uF-.js +1551 -0
- package/dist/index.d.ts +7079 -10
- package/dist/index.mjs +43 -0
- package/package.json +15 -12
- package/dist/api-endpoints/index.d.ts +0 -7
- package/dist/api-endpoints/index.js +0 -7
- package/dist/browser/index.es.js +0 -40
- package/dist/browser/index.umd.js +0 -614
- package/dist/index.js +0 -51
- package/dist/lib/endpoint-selection.d.ts +0 -14
- package/dist/lib/endpoint-selection.js +0 -79
- package/dist/lib/nihiliumapi.d.ts +0 -19
- package/dist/lib/nihiliumapi.js +0 -49
- package/dist/lib/server-client.d.ts +0 -7
- package/dist/lib/server-client.js +0 -31
- package/dist/lib/types.d.ts +0 -12
- package/dist/lib/types.js +0 -1
package/dist/index.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Example: re-export browser entry from privacy-lib
|
|
2
|
-
import * as nhsdk from '@nihilium/privacy-lib';
|
|
3
|
-
export * from '@nihilium/privacy-lib';
|
|
4
|
-
import { getDatastreams, getProcessors, getProcessorEndpoint } from './lib/endpoint-selection';
|
|
5
|
-
export { getFullDatastreams, getFullProcessors } from './lib/endpoint-selection';
|
|
6
|
-
export { getProcessorEndpoint, setApiEndpoint } from './lib/endpoint-selection';
|
|
7
|
-
export const cryptoTools = nhsdk.cryptoTools;
|
|
8
|
-
// export const devProcessorUrl:string = "https://processor1.nihilium.io";
|
|
9
|
-
// export const devDataStreamUrl:string = "https://datastream1.nihilium.io";
|
|
10
|
-
export async function check_if_reveal_value_is_published(datastream_url, reveal_value) {
|
|
11
|
-
const dataStream = new nhsdk.DataStreamClient(datastream_url);
|
|
12
|
-
await dataStream.initialize();
|
|
13
|
-
const isProvable = await dataStream.isProvable(reveal_value.toString());
|
|
14
|
-
return isProvable;
|
|
15
|
-
}
|
|
16
|
-
// export async function getSealingProcessing(
|
|
17
|
-
// processorEndpoint: SelectableProcessor,
|
|
18
|
-
// dataStream: SelectableDataStream,
|
|
19
|
-
// chainedProofCollection:nhsdk.ChainedProofCollection) {
|
|
20
|
-
// const resolvedProcessorEndpoint = await getProcessorEndpoint(processorEndpoint.url);
|
|
21
|
-
// const resolvedDataStream = new nhsdk.DataStreamClient(dataStream.url);
|
|
22
|
-
// const proofCollection = chainedProofCollection;
|
|
23
|
-
// const sealingProcess = new nhsdk.ClientSingleShareSealingProcess(
|
|
24
|
-
// resolvedProcessorEndpoint,
|
|
25
|
-
// proofCollection);
|
|
26
|
-
// return sealingProcess;
|
|
27
|
-
// }
|
|
28
|
-
export async function getDefaultSealingProcess(chainId = nhsdk.NETWORK_IDS.ANVIL) {
|
|
29
|
-
var dataStreams = await getDatastreams();
|
|
30
|
-
var dataStream = dataStreams[0];
|
|
31
|
-
const resolvedDataStream = new nhsdk.DataStreamClient(dataStream.url);
|
|
32
|
-
await resolvedDataStream.initialize();
|
|
33
|
-
var processorEndpoints = await getProcessors();
|
|
34
|
-
var processorEndpoint = processorEndpoints[0];
|
|
35
|
-
const resolvedProcessorEndpoint = await getProcessorEndpoint(processorEndpoint.url);
|
|
36
|
-
const genanche = nhsdk.deployedProtocolContracts[chainId];
|
|
37
|
-
const proofCollection = nhsdk.createRevealOnlyCollection(chainId);
|
|
38
|
-
const sealingProcess = new nhsdk.ClientSingleShareSealingProcess(resolvedProcessorEndpoint, [resolvedDataStream], proofCollection.template);
|
|
39
|
-
return sealingProcess;
|
|
40
|
-
}
|
|
41
|
-
export async function getDefaultUnsealingProcess(seal, chainId = nhsdk.NETWORK_IDS.ANVIL) {
|
|
42
|
-
const processorEndpoint = await getProcessorEndpoint(seal.public_package.processor_url);
|
|
43
|
-
const dataStream = new nhsdk.DataStreamClient(seal.public_package.data_stream_urls[0]);
|
|
44
|
-
await dataStream.initialize();
|
|
45
|
-
const proofCollectionClass = nhsdk.createRevealOnlyCollection(chainId);
|
|
46
|
-
// Spread the fields of reveal_collection_inputs as constructor arguments, then add [dataStream] as the last argument
|
|
47
|
-
proofCollectionClass.template = nhsdk.CollectionTemplateTypes.from_json(seal.private_package.unseal_template, nhsdk.proofLibrary, nhsdk.moduleLibrary);
|
|
48
|
-
var unsealingProcess = new nhsdk.ClientSingleShareUnsealingProcess(processorEndpoint, proofCollectionClass.collection, proofCollectionClass.template, { [dataStream.getAddress()]: dataStream }, seal);
|
|
49
|
-
return unsealingProcess;
|
|
50
|
-
}
|
|
51
|
-
export { nhsdk };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { SelectableDataStream, SelectableProcessor } from "./types";
|
|
2
|
-
import * as nhsdk from "@nihilium/privacy-lib";
|
|
3
|
-
export declare function setApiEndpoint(endpoint: string): void;
|
|
4
|
-
export declare function getProcessors(): Promise<SelectableProcessor[]>;
|
|
5
|
-
export declare function getDatastreams(): Promise<SelectableDataStream[]>;
|
|
6
|
-
export declare function getProcessorEndpoint(url: string): Promise<{
|
|
7
|
-
url: string;
|
|
8
|
-
is_tor: boolean;
|
|
9
|
-
public_verification_key: [bigint, bigint];
|
|
10
|
-
public_he_encryption_key: [bigint, bigint];
|
|
11
|
-
server_address: string;
|
|
12
|
-
}>;
|
|
13
|
-
export declare function getFullDatastreams(): Promise<nhsdk.DataStreamClient[]>;
|
|
14
|
-
export declare function getFullProcessors(): Promise<nhsdk.protocolTypes.ProcessorEndpoint[]>;
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { API_PATHS } from "../api-endpoints";
|
|
2
|
-
import * as nhsdk from "@nihilium/privacy-lib";
|
|
3
|
-
import axios from "axios";
|
|
4
|
-
var apiEndpoint = "https://api.nihilium.io";
|
|
5
|
-
//var apiEndpoint = "http://localhost:8080";
|
|
6
|
-
export function setApiEndpoint(endpoint) {
|
|
7
|
-
apiEndpoint = endpoint;
|
|
8
|
-
}
|
|
9
|
-
export async function getProcessors() {
|
|
10
|
-
const response = await fetch(`${apiEndpoint}/${API_PATHS.GET_PROCESSORS}`);
|
|
11
|
-
const data = await response.json();
|
|
12
|
-
return data;
|
|
13
|
-
// return [
|
|
14
|
-
// {
|
|
15
|
-
// url: "https://processor1.nihilium.io",
|
|
16
|
-
// is_tor: false,
|
|
17
|
-
// jurisdiction: "US",
|
|
18
|
-
// stake: BigInt(1000000000000000000),
|
|
19
|
-
// },
|
|
20
|
-
// {
|
|
21
|
-
// url: "https://processor2.nihilium.io",
|
|
22
|
-
// is_tor: false,
|
|
23
|
-
// jurisdiction: "US",
|
|
24
|
-
// stake: BigInt(1000000000000000000),
|
|
25
|
-
// },
|
|
26
|
-
// {
|
|
27
|
-
// url: "https://processor3.nihilium.io",
|
|
28
|
-
// is_tor: false,
|
|
29
|
-
// jurisdiction: "US",
|
|
30
|
-
// stake: BigInt(1000000000000000000),
|
|
31
|
-
// },
|
|
32
|
-
// ]
|
|
33
|
-
}
|
|
34
|
-
export async function getDatastreams() {
|
|
35
|
-
const response = await fetch(`${apiEndpoint}/${API_PATHS.GET_DATA_STREAMS}`);
|
|
36
|
-
const data = await response.json();
|
|
37
|
-
return data;
|
|
38
|
-
// return [
|
|
39
|
-
// {
|
|
40
|
-
// url: "https://datastream1.nihilium.io",
|
|
41
|
-
// is_tor: false,
|
|
42
|
-
// jurisdiction: "US",
|
|
43
|
-
// stake: BigInt(1000000000000000000),
|
|
44
|
-
// },
|
|
45
|
-
// {
|
|
46
|
-
// url: "https://datastream2.nihilium.io",
|
|
47
|
-
// is_tor: false,
|
|
48
|
-
// jurisdiction: "US",
|
|
49
|
-
// stake: BigInt(1000000000000000000),
|
|
50
|
-
// },
|
|
51
|
-
// {
|
|
52
|
-
// url: "https://datastream3.nihilium.io",
|
|
53
|
-
// is_tor: false,
|
|
54
|
-
// jurisdiction: "US",
|
|
55
|
-
// stake: BigInt(1000000000000000000),
|
|
56
|
-
// },
|
|
57
|
-
// ]
|
|
58
|
-
}
|
|
59
|
-
export async function getProcessorEndpoint(url) {
|
|
60
|
-
const response = await axios.get(url + "/get_public_keys");
|
|
61
|
-
const data = response.data;
|
|
62
|
-
const addsPubKey = [data.signing_public_key[0], data.signing_public_key[1]];
|
|
63
|
-
const he_encryption = [data.he_public_key[0], data.he_public_key[1]];
|
|
64
|
-
return {
|
|
65
|
-
url: url,
|
|
66
|
-
is_tor: false,
|
|
67
|
-
public_verification_key: [BigInt(addsPubKey[0]), BigInt(addsPubKey[1])],
|
|
68
|
-
public_he_encryption_key: [BigInt(he_encryption[0]), BigInt(he_encryption[1])],
|
|
69
|
-
server_address: "0x0000000000000000000000000000000000000000000000000000000000000000"
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
export async function getFullDatastreams() {
|
|
73
|
-
const dataStreams = await getDatastreams();
|
|
74
|
-
return dataStreams.map(dataStream => new nhsdk.DataStreamClient(dataStream.url));
|
|
75
|
-
}
|
|
76
|
-
export async function getFullProcessors() {
|
|
77
|
-
const processors = await getProcessors();
|
|
78
|
-
return Promise.all(processors.map(async (processor) => await getProcessorEndpoint(processor.url)));
|
|
79
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { SelectableDataStream, SelectableProcessor } from "./types";
|
|
2
|
-
export declare const API_PATHS: {
|
|
3
|
-
GET_PROCESSORS: string;
|
|
4
|
-
GET_DATA_STREAMS: string;
|
|
5
|
-
GET_PROCESSOR_TOKEN: string;
|
|
6
|
-
GET_DATA_STREAM_TOKEN: string;
|
|
7
|
-
};
|
|
8
|
-
export declare function exampleProcessorTokenRequest(endpoint: string, processorId: string, requestId: string): Promise<any>;
|
|
9
|
-
export declare function exampleDataStreamTokenRequest(endpoint: string, dataStreamId: string, requestId: string): Promise<any>;
|
|
10
|
-
export declare class NihiliumAPI {
|
|
11
|
-
protected endpoint: string;
|
|
12
|
-
protected processorTokenRequest: (processorId: string, requestId: string) => Promise<string>;
|
|
13
|
-
protected dataStreamTokenRequest: (dataStreamId: string, requestId: string) => Promise<string>;
|
|
14
|
-
constructor(endpoint: string, processorTokenRequest?: (processorId: string, requestId: string) => Promise<string>, dataStreamTokenRequest?: (dataStreamId: string, requestId: string) => Promise<string>);
|
|
15
|
-
getProcessors(): Promise<SelectableProcessor[]>;
|
|
16
|
-
getDatastreams(): Promise<SelectableDataStream[]>;
|
|
17
|
-
getProcessorToken(processorId: string, requestId: string): Promise<string>;
|
|
18
|
-
getDataStreamToken(dataStreamId: string, requestId: string): Promise<string>;
|
|
19
|
-
}
|
package/dist/lib/nihiliumapi.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
export const API_PATHS = {
|
|
2
|
-
GET_PROCESSORS: "api/get-processors",
|
|
3
|
-
GET_DATA_STREAMS: "api/get-datastreams",
|
|
4
|
-
GET_PROCESSOR_TOKEN: "api/get-processor-token",
|
|
5
|
-
GET_DATA_STREAM_TOKEN: "api/get-datastream-token"
|
|
6
|
-
};
|
|
7
|
-
export async function exampleProcessorTokenRequest(endpoint, processorId, requestId) {
|
|
8
|
-
const response = await fetch(`${endpoint}/${API_PATHS.GET_PROCESSOR_TOKEN}`, {
|
|
9
|
-
method: "POST",
|
|
10
|
-
body: JSON.stringify({ processorId, requestId }),
|
|
11
|
-
headers: {
|
|
12
|
-
"Content-Type": "application/json",
|
|
13
|
-
"X-API-Key": `user-key`
|
|
14
|
-
}
|
|
15
|
-
});
|
|
16
|
-
return response.json();
|
|
17
|
-
}
|
|
18
|
-
export async function exampleDataStreamTokenRequest(endpoint, dataStreamId, requestId) {
|
|
19
|
-
const response = await fetch(`${endpoint}/${API_PATHS.GET_DATA_STREAM_TOKEN}`, {
|
|
20
|
-
method: "POST",
|
|
21
|
-
body: JSON.stringify({ dataStreamId, requestId }),
|
|
22
|
-
headers: {
|
|
23
|
-
"Content-Type": "application/json",
|
|
24
|
-
"X-API-Key": `user-key`
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
return response.json();
|
|
28
|
-
}
|
|
29
|
-
export class NihiliumAPI {
|
|
30
|
-
constructor(endpoint, processorTokenRequest, dataStreamTokenRequest) {
|
|
31
|
-
this.endpoint = endpoint;
|
|
32
|
-
this.processorTokenRequest = processorTokenRequest || (async (processorId, requestId) => { return await exampleProcessorTokenRequest(this.endpoint, processorId, requestId); });
|
|
33
|
-
this.dataStreamTokenRequest = dataStreamTokenRequest || (async (dataStreamId, requestId) => { return await exampleDataStreamTokenRequest(this.endpoint, dataStreamId, requestId); });
|
|
34
|
-
}
|
|
35
|
-
async getProcessors() {
|
|
36
|
-
const response = await fetch(`${this.endpoint}/${API_PATHS.GET_PROCESSORS}`);
|
|
37
|
-
return response.json();
|
|
38
|
-
}
|
|
39
|
-
async getDatastreams() {
|
|
40
|
-
const response = await fetch(`${this.endpoint}/${API_PATHS.GET_DATA_STREAMS}`);
|
|
41
|
-
return response.json();
|
|
42
|
-
}
|
|
43
|
-
async getProcessorToken(processorId, requestId) {
|
|
44
|
-
return await this.processorTokenRequest(processorId, requestId);
|
|
45
|
-
}
|
|
46
|
-
async getDataStreamToken(dataStreamId, requestId) {
|
|
47
|
-
return await this.dataStreamTokenRequest(dataStreamId, requestId);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { NihiliumAPI } from "./nihiliumapi";
|
|
2
|
-
export declare class DevSDKAPIClient extends NihiliumAPI {
|
|
3
|
-
private apiKey;
|
|
4
|
-
constructor(endpoint: string, apiKey: string);
|
|
5
|
-
exampleProcessorTokenRequest(processorId: string, requestId: string): Promise<any>;
|
|
6
|
-
exampleDataStreamTokenRequest(dataStreamId: string, requestId: string): Promise<any>;
|
|
7
|
-
}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { NihiliumAPI, API_PATHS } from "./nihiliumapi";
|
|
2
|
-
export class DevSDKAPIClient extends NihiliumAPI {
|
|
3
|
-
constructor(endpoint, apiKey) {
|
|
4
|
-
super(endpoint);
|
|
5
|
-
this.apiKey = apiKey;
|
|
6
|
-
this.processorTokenRequest = this.exampleProcessorTokenRequest;
|
|
7
|
-
this.dataStreamTokenRequest = this.exampleDataStreamTokenRequest;
|
|
8
|
-
}
|
|
9
|
-
async exampleProcessorTokenRequest(processorId, requestId) {
|
|
10
|
-
const response = await fetch(`${this.endpoint}/${API_PATHS.GET_PROCESSOR_TOKEN}`, {
|
|
11
|
-
method: "POST",
|
|
12
|
-
body: JSON.stringify({ processorId, requestId }),
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/json",
|
|
15
|
-
"X-API-Key": this.apiKey
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
return response.json();
|
|
19
|
-
}
|
|
20
|
-
async exampleDataStreamTokenRequest(dataStreamId, requestId) {
|
|
21
|
-
const response = await fetch(`${this.endpoint}/${API_PATHS.GET_DATA_STREAM_TOKEN}`, {
|
|
22
|
-
method: "POST",
|
|
23
|
-
body: JSON.stringify({ dataStreamId, requestId }),
|
|
24
|
-
headers: {
|
|
25
|
-
"Content-Type": "application/json",
|
|
26
|
-
"X-API-Key": this.apiKey
|
|
27
|
-
}
|
|
28
|
-
});
|
|
29
|
-
return response.json();
|
|
30
|
-
}
|
|
31
|
-
}
|
package/dist/lib/types.d.ts
DELETED
package/dist/lib/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|