@dsnp/graph-sdk
Advanced tools
Comparing version 0.0.5 to 0.0.6
@@ -180,7 +180,7 @@ "use strict"; | ||
}, | ||
dsnpKeys: { | ||
dsnpUserId: "2", | ||
keysHash: 100, | ||
keys: [], | ||
}, | ||
// dsnpKeys: { | ||
// dsnpUserId: "2", | ||
// keysHash: 100, | ||
// keys: [], | ||
// } as DsnpKeys, | ||
}; | ||
@@ -210,7 +210,7 @@ actions.push(action_1); | ||
}, | ||
// dsnpKeys: { | ||
// dsnpUserId: "2", | ||
// keysHash: 100, | ||
// keys: [], | ||
// } as DsnpKeys, | ||
dsnpKeys: { | ||
dsnpUserId: "2", | ||
keysHash: 100, | ||
keys: [], | ||
}, | ||
}; | ||
@@ -267,6 +267,6 @@ actions.push(action_1); | ||
test('Create and export a new graph', async () => { | ||
let mainnet_environment = { environmentType: environment_1.EnvironmentType.Mainnet }; | ||
let graph = new graph_1.Graph(mainnet_environment); | ||
let public_follow_graph_schema_id = await graph.getSchemaIdFromConfig(mainnet_environment, config_1.ConnectionType.Follow, config_1.PrivacyType.Public); | ||
let connect_action = { | ||
const mainnet_environment = { environmentType: environment_1.EnvironmentType.Mainnet }; | ||
const graph = new graph_1.Graph(mainnet_environment); | ||
const public_follow_graph_schema_id = await graph.getSchemaIdFromConfig(mainnet_environment, config_1.ConnectionType.Follow, config_1.PrivacyType.Public); | ||
const connect_action = { | ||
type: "Connect", | ||
@@ -284,10 +284,10 @@ ownerDsnpUserId: "1", | ||
}; | ||
let actions = []; | ||
const actions = []; | ||
actions.push(connect_action); | ||
let applied = await graph.applyActions(actions); | ||
const applied = await graph.applyActions(actions); | ||
expect(applied).toEqual(true); | ||
let connections_including_pending = await graph.getConnectionsForUserGraph("1", public_follow_graph_schema_id, true); | ||
const connections_including_pending = await graph.getConnectionsForUserGraph("1", public_follow_graph_schema_id, true); | ||
expect(connections_including_pending).toBeDefined(); | ||
expect(connections_including_pending.length).toEqual(1); | ||
let exported = await graph.exportUpdates(); | ||
const exported = await graph.exportUpdates(); | ||
expect(exported).toBeDefined(); | ||
@@ -318,9 +318,9 @@ expect(exported.length).toEqual(1); | ||
test('Read and deserialize published graph keys', async () => { | ||
let dsnp_key_owner = 1000; | ||
const dsnp_key_owner = 1000; | ||
// published keys blobs fetched from blockchain | ||
let published_keys_blob = [ | ||
const published_keys_blob = [ | ||
64, 15, 234, 44, 175, 171, 220, 131, 117, 43, 227, 111, 165, 52, 150, 64, 218, 44, 130, | ||
138, 221, 10, 41, 13, 241, 60, 210, 216, 23, 62, 178, 73, 111, | ||
]; | ||
let dsnp_keys = { | ||
const dsnp_keys = { | ||
dsnpUserId: dsnp_key_owner.toString(), | ||
@@ -335,3 +335,2 @@ keysHash: 100, | ||
}; | ||
const environment = { environmentType: environment_1.EnvironmentType.Mainnet }; | ||
const deserialized_keys = await graph_1.Graph.deserializeDsnpKeys(dsnp_keys); | ||
@@ -338,0 +337,0 @@ expect(deserialized_keys).toBeDefined(); |
@@ -1,2 +0,2 @@ | ||
import { GraphKeyPair, DsnpKeys, ImportBundle, PageData } from "./models"; | ||
import { GraphKeyType, GraphKeyPair, DsnpKeys, ImportBundle, PageData } from "./models"; | ||
export interface IImportBundleBuilder { | ||
@@ -14,3 +14,3 @@ dsnpUserId?: string; | ||
withSchemaId(schemaId: number): ImportBundleBuilder; | ||
withGraphKeyPairs(keys: GraphKeyPair[]): ImportBundleBuilder; | ||
withGraphKeyPair(keyType: GraphKeyType, publicKey: Uint8Array, secretKey: Uint8Array): ImportBundleBuilder; | ||
withDsnpKeys(dsnpKeys: DsnpKeys): ImportBundleBuilder; | ||
@@ -17,0 +17,0 @@ withPageData(pageId: number, content: Uint8Array, contentHash: number): ImportBundleBuilder; |
@@ -17,5 +17,5 @@ "use strict"; | ||
} | ||
withGraphKeyPairs(keys) { | ||
withGraphKeyPair(keyType, publicKey, secretKey) { | ||
const keyPairs = this.values.keyPairs ? [...this.values.keyPairs] : []; | ||
keyPairs.push(...keys); | ||
keyPairs.push({ keyType, publicKey, secretKey }); | ||
return new ImportBundleBuilder({ ...this.values, keyPairs }); | ||
@@ -36,3 +36,3 @@ } | ||
keyPairs: this.values.keyPairs || [], | ||
dsnpKeys: this.values.dsnpKeys || { dsnpUserId: '', keysHash: 0, keys: [] }, | ||
dsnpKeys: this.values.dsnpKeys, | ||
pages: this.values.pages || [], | ||
@@ -39,0 +39,0 @@ }; |
@@ -32,3 +32,3 @@ "use strict"; | ||
.withSchemaId(schemaId) | ||
.withGraphKeyPairs([{ keyType: models_1.GraphKeyType.X25519, publicKey: new Uint8Array([1, 2, 3]), secretKey: new Uint8Array([4, 5, 6]) }]) | ||
.withGraphKeyPair(models_1.GraphKeyType.X25519, new Uint8Array([1, 2, 3]), new Uint8Array([4, 5, 6])) | ||
.withDsnpKeys(dsnpKeys) | ||
@@ -35,0 +35,0 @@ .withPageData(1, new Uint8Array([10, 11, 12]), 789); |
@@ -26,3 +26,3 @@ "use strict"; | ||
const graph = new graph_1.Graph(environment); | ||
await graph.printHelloGraph(); | ||
graph.printHelloGraph(); | ||
expect(consoleLogMock).toHaveBeenCalledWith('Hello, Graph!'); | ||
@@ -29,0 +29,0 @@ await graph.freeGraphState(); |
@@ -27,5 +27,5 @@ export interface KeyData { | ||
keyPairs: GraphKeyPair[]; | ||
dsnpKeys: DsnpKeys; | ||
dsnpKeys?: DsnpKeys; | ||
pages: PageData[]; | ||
} | ||
//# sourceMappingURL=import_bundle.d.ts.map |
{ | ||
"name": "@dsnp/graph-sdk", | ||
"version": "0.0.5", | ||
"version": "0.0.6", | ||
"author": "Amplica Labs", | ||
@@ -5,0 +5,0 @@ "license": "ISC", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
6377861
833