@coasys/ad4m 0.8.0-fix
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 +229 -0
- package/jest-setup.ts +1 -0
- package/jest.config.js +6 -0
- package/jsdoc.json +28 -0
- package/lib/index.cjs +8165 -0
- package/lib/index.js +8130 -0
- package/lib/shims/reflect-metadata.d.ts +0 -0
- package/lib/shims/reflect-metadata.js +0 -0
- package/lib/shims/type-graphql.d.ts +32 -0
- package/lib/shims/type-graphql.js +70 -0
- package/lib/src/Ad4mClient.d.ts +26 -0
- package/lib/src/Ad4mClient.js +66 -0
- package/lib/src/Address.d.ts +1 -0
- package/lib/src/Address.js +1 -0
- package/lib/src/DID.d.ts +1 -0
- package/lib/src/DID.js +1 -0
- package/lib/src/Exception.d.ts +6 -0
- package/lib/src/Exception.js +7 -0
- package/lib/src/Literal.d.ts +7 -0
- package/lib/src/Literal.js +76 -0
- package/lib/src/PubSub.d.ts +14 -0
- package/lib/src/PubSub.js +14 -0
- package/lib/src/SmartLiteral.d.ts +12 -0
- package/lib/src/SmartLiteral.js +74 -0
- package/lib/src/agent/Agent.d.ts +104 -0
- package/lib/src/agent/Agent.js +337 -0
- package/lib/src/agent/AgentClient.d.ts +57 -0
- package/lib/src/agent/AgentClient.js +431 -0
- package/lib/src/agent/AgentResolver.d.ts +30 -0
- package/lib/src/agent/AgentResolver.js +325 -0
- package/lib/src/agent/AgentStatus.d.ts +8 -0
- package/lib/src/agent/AgentStatus.js +61 -0
- package/lib/src/buildSchema.d.ts +1 -0
- package/lib/src/buildSchema.js +36 -0
- package/lib/src/expression/Expression.d.ts +28 -0
- package/lib/src/expression/Expression.js +143 -0
- package/lib/src/expression/ExpressionClient.d.ts +13 -0
- package/lib/src/expression/ExpressionClient.js +102 -0
- package/lib/src/expression/ExpressionRef.d.ts +9 -0
- package/lib/src/expression/ExpressionRef.js +67 -0
- package/lib/src/expression/ExpressionResolver.d.ts +10 -0
- package/lib/src/expression/ExpressionResolver.js +106 -0
- package/lib/src/index.d.ts +30 -0
- package/lib/src/index.js +30 -0
- package/lib/src/jestSetup.d.ts +1 -0
- package/lib/src/jestSetup.js +1 -0
- package/lib/src/language/Icon.d.ts +4 -0
- package/lib/src/language/Icon.js +24 -0
- package/lib/src/language/Language.d.ts +195 -0
- package/lib/src/language/Language.js +79 -0
- package/lib/src/language/LanguageClient.d.ts +17 -0
- package/lib/src/language/LanguageClient.js +137 -0
- package/lib/src/language/LanguageContext.d.ts +37 -0
- package/lib/src/language/LanguageContext.js +2 -0
- package/lib/src/language/LanguageHandle.d.ts +9 -0
- package/lib/src/language/LanguageHandle.js +41 -0
- package/lib/src/language/LanguageMeta.d.ts +35 -0
- package/lib/src/language/LanguageMeta.js +89 -0
- package/lib/src/language/LanguageRef.d.ts +6 -0
- package/lib/src/language/LanguageRef.js +30 -0
- package/lib/src/language/LanguageResolver.d.ts +19 -0
- package/lib/src/language/LanguageResolver.js +143 -0
- package/lib/src/links/Links.d.ts +39 -0
- package/lib/src/links/Links.js +148 -0
- package/lib/src/links/Links.test.d.ts +1 -0
- package/lib/src/links/Links.test.js +33 -0
- package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -0
- package/lib/src/neighbourhood/Neighbourhood.js +38 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -0
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -0
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -0
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -0
- package/lib/src/perspectives/LinkQuery.d.ts +11 -0
- package/lib/src/perspectives/LinkQuery.js +80 -0
- package/lib/src/perspectives/Perspective.d.ts +38 -0
- package/lib/src/perspectives/Perspective.js +144 -0
- package/lib/src/perspectives/Perspective.test.d.ts +1 -0
- package/lib/src/perspectives/Perspective.test.js +20 -0
- package/lib/src/perspectives/PerspectiveClient.d.ts +54 -0
- package/lib/src/perspectives/PerspectiveClient.js +410 -0
- package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -0
- package/lib/src/perspectives/PerspectiveDiff.js +33 -0
- package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -0
- package/lib/src/perspectives/PerspectiveHandle.js +59 -0
- package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -0
- package/lib/src/perspectives/PerspectiveProxy.js +540 -0
- package/lib/src/perspectives/PerspectiveResolver.d.ts +37 -0
- package/lib/src/perspectives/PerspectiveResolver.js +362 -0
- package/lib/src/runtime/RuntimeClient.d.ts +33 -0
- package/lib/src/runtime/RuntimeClient.js +263 -0
- package/lib/src/runtime/RuntimeResolver.d.ts +47 -0
- package/lib/src/runtime/RuntimeResolver.js +328 -0
- package/lib/src/schema.gql +382 -0
- package/lib/src/subject/SDNADecorators.d.ts +45 -0
- package/lib/src/subject/SDNADecorators.js +250 -0
- package/lib/src/subject/Subject.d.ts +7 -0
- package/lib/src/subject/Subject.js +160 -0
- package/lib/src/subject/SubjectEntity.d.ts +31 -0
- package/lib/src/subject/SubjectEntity.js +250 -0
- package/lib/src/subject/util.d.ts +12 -0
- package/lib/src/subject/util.js +73 -0
- package/lib/src/typeDefs.d.ts +1 -0
- package/lib/src/typeDefs.js +379 -0
- package/lib/src/unwrapApolloResult.d.ts +2 -0
- package/lib/src/unwrapApolloResult.js +12 -0
- package/lib/src/utils.d.ts +2 -0
- package/lib/src/utils.js +21 -0
- package/package.json +61 -0
- package/rollup.config.js +27 -0
- package/shims/reflect-metadata.ts +0 -0
- package/shims/type-graphql.ts +75 -0
- package/src/Ad4mClient.test.ts +1085 -0
- package/src/Ad4mClient.ts +63 -0
- package/src/Address.ts +1 -0
- package/src/DID.ts +1 -0
- package/src/Exception.ts +6 -0
- package/src/Literal.test.ts +31 -0
- package/src/Literal.ts +81 -0
- package/src/PubSub.ts +14 -0
- package/src/SmartLiteral.ts +75 -0
- package/src/agent/Agent.ts +293 -0
- package/src/agent/AgentClient.ts +531 -0
- package/src/agent/AgentResolver.ts +263 -0
- package/src/agent/AgentStatus.ts +44 -0
- package/src/buildSchema.ts +41 -0
- package/src/expression/Expression.ts +99 -0
- package/src/expression/ExpressionClient.ts +99 -0
- package/src/expression/ExpressionRef.ts +63 -0
- package/src/expression/ExpressionResolver.ts +64 -0
- package/src/index.ts +30 -0
- package/src/jestSetup.ts +1 -0
- package/src/language/Icon.ts +11 -0
- package/src/language/Language.ts +266 -0
- package/src/language/LanguageClient.ts +160 -0
- package/src/language/LanguageContext.ts +37 -0
- package/src/language/LanguageHandle.ts +23 -0
- package/src/language/LanguageMeta.ts +70 -0
- package/src/language/LanguageRef.ts +18 -0
- package/src/language/LanguageResolver.ts +98 -0
- package/src/links/Links.test.ts +40 -0
- package/src/links/Links.ts +107 -0
- package/src/neighbourhood/Neighbourhood.ts +22 -0
- package/src/neighbourhood/NeighbourhoodClient.ts +276 -0
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -0
- package/src/neighbourhood/NeighbourhoodResolver.ts +100 -0
- package/src/perspectives/LinkQuery.ts +66 -0
- package/src/perspectives/Perspective.test.ts +23 -0
- package/src/perspectives/Perspective.ts +118 -0
- package/src/perspectives/PerspectiveClient.ts +444 -0
- package/src/perspectives/PerspectiveDiff.ts +15 -0
- package/src/perspectives/PerspectiveHandle.ts +39 -0
- package/src/perspectives/PerspectiveProxy.ts +611 -0
- package/src/perspectives/PerspectiveResolver.ts +220 -0
- package/src/runtime/RuntimeClient.ts +283 -0
- package/src/runtime/RuntimeResolver.ts +193 -0
- package/src/subject/SDNADecorators.ts +334 -0
- package/src/subject/Subject.ts +153 -0
- package/src/subject/SubjectEntity.ts +292 -0
- package/src/subject/util.ts +85 -0
- package/src/typeDefs.ts +6 -0
- package/src/unwrapApolloResult.ts +14 -0
- package/src/utils.ts +25 -0
- package/tsconfig-browser.json +82 -0
- package/tsconfig.json +80 -0
- package/yarn-error.log +22814 -0
|
@@ -0,0 +1,431 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _AgentClient_apolloClient, _AgentClient_appsChangedCallback, _AgentClient_updatedCallbacks, _AgentClient_agentStatusChangedCallbacks;
|
|
13
|
+
import { gql } from "@apollo/client/core";
|
|
14
|
+
import unwrapApolloResult from "../unwrapApolloResult";
|
|
15
|
+
import { Agent, } from "./Agent";
|
|
16
|
+
import { AgentStatus } from "./AgentStatus";
|
|
17
|
+
import { PerspectiveClient } from "../perspectives/PerspectiveClient";
|
|
18
|
+
const AGENT_SUBITEMS = `
|
|
19
|
+
did
|
|
20
|
+
directMessageLanguage
|
|
21
|
+
perspective {
|
|
22
|
+
links {
|
|
23
|
+
author, timestamp,
|
|
24
|
+
proof {
|
|
25
|
+
signature, key, valid, invalid
|
|
26
|
+
}
|
|
27
|
+
data {
|
|
28
|
+
source, predicate, target
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
33
|
+
const Apps_FIELDS = `
|
|
34
|
+
requestId
|
|
35
|
+
revoked
|
|
36
|
+
auth {
|
|
37
|
+
appName
|
|
38
|
+
appDesc
|
|
39
|
+
appUrl
|
|
40
|
+
appIconPath
|
|
41
|
+
capabilities {
|
|
42
|
+
with {
|
|
43
|
+
domain
|
|
44
|
+
pointers
|
|
45
|
+
}
|
|
46
|
+
can
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const AGENT_STATUS_FIELDS = `
|
|
51
|
+
isInitialized
|
|
52
|
+
isUnlocked
|
|
53
|
+
did
|
|
54
|
+
didDocument
|
|
55
|
+
error
|
|
56
|
+
`;
|
|
57
|
+
const ENTANGLEMENT_PROOF_FIELDS = `
|
|
58
|
+
did
|
|
59
|
+
didSigningKeyId
|
|
60
|
+
deviceKeyType
|
|
61
|
+
deviceKey
|
|
62
|
+
deviceKeySignedByDid
|
|
63
|
+
didSignedByDeviceKey
|
|
64
|
+
`;
|
|
65
|
+
const AGENT_SIGNATURE_FIELDS = `
|
|
66
|
+
signature
|
|
67
|
+
publicKey
|
|
68
|
+
`;
|
|
69
|
+
/**
|
|
70
|
+
* Provides access to all functions regarding the local agent,
|
|
71
|
+
* such as generating, locking, unlocking, importing the DID keystore,
|
|
72
|
+
* as well as updating the publicly shared Agent expression.
|
|
73
|
+
*/
|
|
74
|
+
export class AgentClient {
|
|
75
|
+
constructor(client, subscribe = true) {
|
|
76
|
+
_AgentClient_apolloClient.set(this, void 0);
|
|
77
|
+
_AgentClient_appsChangedCallback.set(this, void 0);
|
|
78
|
+
_AgentClient_updatedCallbacks.set(this, void 0);
|
|
79
|
+
_AgentClient_agentStatusChangedCallbacks.set(this, void 0);
|
|
80
|
+
__classPrivateFieldSet(this, _AgentClient_apolloClient, client, "f");
|
|
81
|
+
__classPrivateFieldSet(this, _AgentClient_updatedCallbacks, [], "f");
|
|
82
|
+
__classPrivateFieldSet(this, _AgentClient_agentStatusChangedCallbacks, [], "f");
|
|
83
|
+
__classPrivateFieldSet(this, _AgentClient_appsChangedCallback, [], "f");
|
|
84
|
+
if (subscribe) {
|
|
85
|
+
this.subscribeAgentUpdated();
|
|
86
|
+
this.subscribeAgentStatusChanged();
|
|
87
|
+
this.subscribeAppsChanged();
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Returns the Agent expression of the local agent as it is shared
|
|
92
|
+
* publicly via the AgentLanguage.
|
|
93
|
+
*
|
|
94
|
+
* I.e. this is the users profile.
|
|
95
|
+
*/
|
|
96
|
+
async me() {
|
|
97
|
+
const { agent } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").query({
|
|
98
|
+
query: gql `query agent { agent { ${AGENT_SUBITEMS} } }`,
|
|
99
|
+
}));
|
|
100
|
+
let agentObject = new Agent(agent.did, agent.perspective);
|
|
101
|
+
agentObject.directMessageLanguage = agent.directMessageLanguage;
|
|
102
|
+
return agentObject;
|
|
103
|
+
}
|
|
104
|
+
async status() {
|
|
105
|
+
const { agentStatus } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").query({
|
|
106
|
+
query: gql `query agentStatus {
|
|
107
|
+
agentStatus {
|
|
108
|
+
${AGENT_STATUS_FIELDS}
|
|
109
|
+
}
|
|
110
|
+
}`,
|
|
111
|
+
}));
|
|
112
|
+
return new AgentStatus(agentStatus);
|
|
113
|
+
}
|
|
114
|
+
async generate(passphrase) {
|
|
115
|
+
const { agentGenerate } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
116
|
+
mutation: gql `mutation agentGenerate(
|
|
117
|
+
$passphrase: String!
|
|
118
|
+
) {
|
|
119
|
+
agentGenerate(passphrase: $passphrase) {
|
|
120
|
+
${AGENT_STATUS_FIELDS}
|
|
121
|
+
}
|
|
122
|
+
}`,
|
|
123
|
+
variables: { passphrase },
|
|
124
|
+
}));
|
|
125
|
+
return new AgentStatus(agentGenerate);
|
|
126
|
+
}
|
|
127
|
+
async import(args) {
|
|
128
|
+
let { did, didDocument, keystore, passphrase } = args;
|
|
129
|
+
const { agentImport } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
130
|
+
mutation: gql `mutation agentImport(
|
|
131
|
+
$did: String!,
|
|
132
|
+
$didDocument: String!,
|
|
133
|
+
$keystore: String!,
|
|
134
|
+
$passphrase: String!
|
|
135
|
+
) {
|
|
136
|
+
agentImport(did: $did, didDocument: $didDocument, keystore: $keystore, passphrase: $passphrase) {
|
|
137
|
+
${AGENT_STATUS_FIELDS}
|
|
138
|
+
}
|
|
139
|
+
}`,
|
|
140
|
+
variables: { did, didDocument, keystore, passphrase },
|
|
141
|
+
}));
|
|
142
|
+
return new AgentStatus(agentImport);
|
|
143
|
+
}
|
|
144
|
+
async lock(passphrase) {
|
|
145
|
+
const { agentLock } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
146
|
+
mutation: gql `mutation agentLock($passphrase: String!) {
|
|
147
|
+
agentLock(passphrase: $passphrase) {
|
|
148
|
+
${AGENT_STATUS_FIELDS}
|
|
149
|
+
}
|
|
150
|
+
}`,
|
|
151
|
+
variables: { passphrase },
|
|
152
|
+
}));
|
|
153
|
+
return new AgentStatus(agentLock);
|
|
154
|
+
}
|
|
155
|
+
async unlock(passphrase, holochain = true) {
|
|
156
|
+
const { agentUnlock } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
157
|
+
mutation: gql `mutation agentUnlock($passphrase: String!, $holochain: Boolean!) {
|
|
158
|
+
agentUnlock(passphrase: $passphrase, holochain: $holochain) {
|
|
159
|
+
${AGENT_STATUS_FIELDS}
|
|
160
|
+
}
|
|
161
|
+
}`,
|
|
162
|
+
variables: { passphrase, holochain },
|
|
163
|
+
}));
|
|
164
|
+
return new AgentStatus(agentUnlock);
|
|
165
|
+
}
|
|
166
|
+
async byDID(did) {
|
|
167
|
+
const { agentByDID } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").query({
|
|
168
|
+
query: gql `query agentByDID($did: String!) {
|
|
169
|
+
agentByDID(did: $did) {
|
|
170
|
+
${AGENT_SUBITEMS}
|
|
171
|
+
}
|
|
172
|
+
}`,
|
|
173
|
+
variables: { did },
|
|
174
|
+
}));
|
|
175
|
+
return agentByDID;
|
|
176
|
+
}
|
|
177
|
+
async updatePublicPerspective(perspective) {
|
|
178
|
+
const cleanedPerspective = JSON.parse(JSON.stringify(perspective));
|
|
179
|
+
delete cleanedPerspective.__typename;
|
|
180
|
+
cleanedPerspective.links.forEach((link) => {
|
|
181
|
+
delete link.__typename;
|
|
182
|
+
delete link.data.__typename;
|
|
183
|
+
delete link.proof.__typename;
|
|
184
|
+
delete link.status;
|
|
185
|
+
});
|
|
186
|
+
const { agentUpdatePublicPerspective } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
187
|
+
mutation: gql `mutation agentUpdatePublicPerspective($perspective: PerspectiveInput!) {
|
|
188
|
+
agentUpdatePublicPerspective(perspective: $perspective) {
|
|
189
|
+
${AGENT_SUBITEMS}
|
|
190
|
+
}
|
|
191
|
+
}`,
|
|
192
|
+
variables: { perspective: cleanedPerspective },
|
|
193
|
+
}));
|
|
194
|
+
const a = agentUpdatePublicPerspective;
|
|
195
|
+
const agent = new Agent(a.did, a.perspective);
|
|
196
|
+
agent.directMessageLanguage = a.directMessageLanguage;
|
|
197
|
+
return agent;
|
|
198
|
+
}
|
|
199
|
+
async mutatePublicPerspective(mutations) {
|
|
200
|
+
const perspectiveClient = new PerspectiveClient(__classPrivateFieldGet(this, _AgentClient_apolloClient, "f"));
|
|
201
|
+
const agentClient = new AgentClient(__classPrivateFieldGet(this, _AgentClient_apolloClient, "f"));
|
|
202
|
+
//Create the proxy perspective and load existing links
|
|
203
|
+
const proxyPerspective = await perspectiveClient.add("Agent Perspective Proxy");
|
|
204
|
+
const agentMe = await agentClient.me();
|
|
205
|
+
if (agentMe.perspective) {
|
|
206
|
+
await proxyPerspective.loadSnapshot(agentMe.perspective);
|
|
207
|
+
}
|
|
208
|
+
//Make the mutations on the proxy perspective
|
|
209
|
+
for (const addition of mutations.additions) {
|
|
210
|
+
await proxyPerspective.add(addition);
|
|
211
|
+
}
|
|
212
|
+
for (const removal of mutations.removals) {
|
|
213
|
+
await proxyPerspective.remove(removal);
|
|
214
|
+
}
|
|
215
|
+
//Get the snapshot of the proxy perspective
|
|
216
|
+
const snapshot = await proxyPerspective.snapshot();
|
|
217
|
+
//Update the users public perspective
|
|
218
|
+
const agent = await this.updatePublicPerspective(snapshot);
|
|
219
|
+
//Cleanup and return
|
|
220
|
+
await perspectiveClient.remove(proxyPerspective.uuid);
|
|
221
|
+
return agent;
|
|
222
|
+
}
|
|
223
|
+
async updateDirectMessageLanguage(directMessageLanguage) {
|
|
224
|
+
const { agentUpdateDirectMessageLanguage } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
225
|
+
mutation: gql `mutation agentUpdateDirectMessageLanguage($directMessageLanguage: String!) {
|
|
226
|
+
agentUpdateDirectMessageLanguage(directMessageLanguage: $directMessageLanguage) {
|
|
227
|
+
${AGENT_SUBITEMS}
|
|
228
|
+
}
|
|
229
|
+
}`,
|
|
230
|
+
variables: { directMessageLanguage },
|
|
231
|
+
}));
|
|
232
|
+
const a = agentUpdateDirectMessageLanguage;
|
|
233
|
+
const agent = new Agent(a.did, a.perspective);
|
|
234
|
+
agent.directMessageLanguage = a.directMessageLanguage;
|
|
235
|
+
return agent;
|
|
236
|
+
}
|
|
237
|
+
async addEntanglementProofs(proofs) {
|
|
238
|
+
const { agentAddEntanglementProofs } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
239
|
+
mutation: gql `mutation agentAddEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
240
|
+
agentAddEntanglementProofs(proofs: $proofs) {
|
|
241
|
+
${ENTANGLEMENT_PROOF_FIELDS}
|
|
242
|
+
}
|
|
243
|
+
}`,
|
|
244
|
+
variables: { proofs },
|
|
245
|
+
}));
|
|
246
|
+
return agentAddEntanglementProofs;
|
|
247
|
+
}
|
|
248
|
+
async deleteEntanglementProofs(proofs) {
|
|
249
|
+
const { agentDeleteEntanglementProofs } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
250
|
+
mutation: gql `mutation agentDeleteEntanglementProofs($proofs: [EntanglementProofInput!]!) {
|
|
251
|
+
agentDeleteEntanglementProofs(proofs: $proofs) {
|
|
252
|
+
${ENTANGLEMENT_PROOF_FIELDS}
|
|
253
|
+
}
|
|
254
|
+
}`,
|
|
255
|
+
variables: { proofs },
|
|
256
|
+
}));
|
|
257
|
+
return agentDeleteEntanglementProofs;
|
|
258
|
+
}
|
|
259
|
+
async getEntanglementProofs() {
|
|
260
|
+
const { agentGetEntanglementProofs } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").query({
|
|
261
|
+
query: gql `query agentGetEntanglementProofs {
|
|
262
|
+
agentGetEntanglementProofs {
|
|
263
|
+
${ENTANGLEMENT_PROOF_FIELDS}
|
|
264
|
+
}
|
|
265
|
+
}`,
|
|
266
|
+
}));
|
|
267
|
+
return agentGetEntanglementProofs;
|
|
268
|
+
}
|
|
269
|
+
async entanglementProofPreFlight(deviceKey, deviceKeyType) {
|
|
270
|
+
const { agentEntanglementProofPreFlight } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
271
|
+
mutation: gql `mutation agentEntanglementProofPreFlight($deviceKey: String!, $deviceKeyType: String!) {
|
|
272
|
+
agentEntanglementProofPreFlight(deviceKey: $deviceKey, deviceKeyType: $deviceKeyType) {
|
|
273
|
+
${ENTANGLEMENT_PROOF_FIELDS}
|
|
274
|
+
}
|
|
275
|
+
}`,
|
|
276
|
+
variables: { deviceKey, deviceKeyType },
|
|
277
|
+
}));
|
|
278
|
+
return agentEntanglementProofPreFlight;
|
|
279
|
+
}
|
|
280
|
+
addUpdatedListener(listener) {
|
|
281
|
+
__classPrivateFieldGet(this, _AgentClient_updatedCallbacks, "f").push(listener);
|
|
282
|
+
}
|
|
283
|
+
addAppChangedListener(listener) {
|
|
284
|
+
__classPrivateFieldGet(this, _AgentClient_appsChangedCallback, "f").push(listener);
|
|
285
|
+
}
|
|
286
|
+
subscribeAgentUpdated() {
|
|
287
|
+
__classPrivateFieldGet(this, _AgentClient_apolloClient, "f")
|
|
288
|
+
.subscribe({
|
|
289
|
+
query: gql ` subscription {
|
|
290
|
+
agentUpdated { ${AGENT_SUBITEMS} }
|
|
291
|
+
}
|
|
292
|
+
`,
|
|
293
|
+
})
|
|
294
|
+
.subscribe({
|
|
295
|
+
next: (result) => {
|
|
296
|
+
const agent = result.data.agentUpdated;
|
|
297
|
+
__classPrivateFieldGet(this, _AgentClient_updatedCallbacks, "f").forEach((cb) => {
|
|
298
|
+
cb(agent);
|
|
299
|
+
});
|
|
300
|
+
},
|
|
301
|
+
error: (e) => console.error(e),
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
subscribeAppsChanged() {
|
|
305
|
+
__classPrivateFieldGet(this, _AgentClient_apolloClient, "f")
|
|
306
|
+
.subscribe({
|
|
307
|
+
query: gql ` subscription {
|
|
308
|
+
agentAppsChanged {
|
|
309
|
+
${Apps_FIELDS}
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
`,
|
|
313
|
+
})
|
|
314
|
+
.subscribe({
|
|
315
|
+
next: (result) => {
|
|
316
|
+
__classPrivateFieldGet(this, _AgentClient_appsChangedCallback, "f").forEach((cb) => {
|
|
317
|
+
cb();
|
|
318
|
+
});
|
|
319
|
+
},
|
|
320
|
+
error: (e) => console.error(e),
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
addAgentStatusChangedListener(listener) {
|
|
324
|
+
__classPrivateFieldGet(this, _AgentClient_agentStatusChangedCallbacks, "f").push(listener);
|
|
325
|
+
}
|
|
326
|
+
subscribeAgentStatusChanged() {
|
|
327
|
+
__classPrivateFieldGet(this, _AgentClient_apolloClient, "f")
|
|
328
|
+
.subscribe({
|
|
329
|
+
query: gql ` subscription {
|
|
330
|
+
agentStatusChanged { ${AGENT_STATUS_FIELDS} }
|
|
331
|
+
}
|
|
332
|
+
`,
|
|
333
|
+
})
|
|
334
|
+
.subscribe({
|
|
335
|
+
next: (result) => {
|
|
336
|
+
const agent = result.data.agentStatusChanged;
|
|
337
|
+
__classPrivateFieldGet(this, _AgentClient_agentStatusChangedCallbacks, "f").forEach((cb) => {
|
|
338
|
+
cb(agent);
|
|
339
|
+
});
|
|
340
|
+
},
|
|
341
|
+
error: (e) => console.error(e),
|
|
342
|
+
});
|
|
343
|
+
}
|
|
344
|
+
async requestCapability(authInfo) {
|
|
345
|
+
const { agentRequestCapability } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
346
|
+
mutation: gql `
|
|
347
|
+
mutation agentRequestCapability($authInfo: AuthInfoInput!) {
|
|
348
|
+
agentRequestCapability(authInfo: $authInfo)
|
|
349
|
+
}
|
|
350
|
+
`,
|
|
351
|
+
variables: { authInfo },
|
|
352
|
+
}));
|
|
353
|
+
return agentRequestCapability;
|
|
354
|
+
}
|
|
355
|
+
async permitCapability(auth) {
|
|
356
|
+
const { agentPermitCapability } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
357
|
+
mutation: gql `
|
|
358
|
+
mutation agentPermitCapability($auth: String!) {
|
|
359
|
+
agentPermitCapability(auth: $auth)
|
|
360
|
+
}
|
|
361
|
+
`,
|
|
362
|
+
variables: { auth },
|
|
363
|
+
}));
|
|
364
|
+
return agentPermitCapability;
|
|
365
|
+
}
|
|
366
|
+
async generateJwt(requestId, rand) {
|
|
367
|
+
const { agentGenerateJwt } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
368
|
+
mutation: gql `
|
|
369
|
+
mutation agentGenerateJwt($requestId: String!, $rand: String!) {
|
|
370
|
+
agentGenerateJwt(requestId: $requestId, rand: $rand)
|
|
371
|
+
}
|
|
372
|
+
`,
|
|
373
|
+
variables: { requestId, rand },
|
|
374
|
+
}));
|
|
375
|
+
return agentGenerateJwt;
|
|
376
|
+
}
|
|
377
|
+
async getApps() {
|
|
378
|
+
const { agentGetApps } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
379
|
+
mutation: gql `query agentGetApps {
|
|
380
|
+
agentGetApps {
|
|
381
|
+
${Apps_FIELDS}
|
|
382
|
+
}
|
|
383
|
+
}`,
|
|
384
|
+
}));
|
|
385
|
+
return agentGetApps;
|
|
386
|
+
}
|
|
387
|
+
async removeApp(requestId) {
|
|
388
|
+
const { agentRemoveApp } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
389
|
+
mutation: gql `mutation agentRemoveApp($requestId: String!) {
|
|
390
|
+
agentRemoveApp(requestId: $requestId) {
|
|
391
|
+
${Apps_FIELDS}
|
|
392
|
+
}
|
|
393
|
+
}`,
|
|
394
|
+
variables: { requestId },
|
|
395
|
+
}));
|
|
396
|
+
return agentRemoveApp;
|
|
397
|
+
}
|
|
398
|
+
async revokeToken(requestId) {
|
|
399
|
+
const { agentRevokeToken } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
400
|
+
mutation: gql `mutation agentRevokeToken($requestId: String!) {
|
|
401
|
+
agentRevokeToken(requestId: $requestId) {
|
|
402
|
+
${Apps_FIELDS}
|
|
403
|
+
}
|
|
404
|
+
}`,
|
|
405
|
+
variables: { requestId },
|
|
406
|
+
}));
|
|
407
|
+
return agentRevokeToken;
|
|
408
|
+
}
|
|
409
|
+
async isLocked() {
|
|
410
|
+
const { agentIsLocked } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
411
|
+
mutation: gql `
|
|
412
|
+
query agentIsLocked {
|
|
413
|
+
agentIsLocked
|
|
414
|
+
}
|
|
415
|
+
`,
|
|
416
|
+
}));
|
|
417
|
+
return agentIsLocked;
|
|
418
|
+
}
|
|
419
|
+
async signMessage(message) {
|
|
420
|
+
const { agentSignMessage } = unwrapApolloResult(await __classPrivateFieldGet(this, _AgentClient_apolloClient, "f").mutate({
|
|
421
|
+
mutation: gql `mutation agentSignMessage($message: String!) {
|
|
422
|
+
agentSignMessage(message: $message) {
|
|
423
|
+
${AGENT_SIGNATURE_FIELDS}
|
|
424
|
+
}
|
|
425
|
+
}`,
|
|
426
|
+
variables: { message },
|
|
427
|
+
}));
|
|
428
|
+
return agentSignMessage;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
_AgentClient_apolloClient = new WeakMap(), _AgentClient_appsChangedCallback = new WeakMap(), _AgentClient_updatedCallbacks = new WeakMap(), _AgentClient_agentStatusChangedCallbacks = new WeakMap();
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { PerspectiveInput } from "../perspectives/Perspective";
|
|
2
|
+
import { Agent, AgentSignature, AuthInfoInput, EntanglementProof, EntanglementProofInput } from "./Agent";
|
|
3
|
+
import { AgentStatus } from "./AgentStatus";
|
|
4
|
+
export declare const TEST_AGENT_DID = "did:ad4m:test";
|
|
5
|
+
export default class AgentResolver {
|
|
6
|
+
agent(): Agent;
|
|
7
|
+
agentStatus(): AgentStatus;
|
|
8
|
+
agentGenerate(passphrase: string, pubSub: any): AgentStatus;
|
|
9
|
+
agentImport(did: string, didDocument: string, keystore: string, passphrase: string): AgentStatus;
|
|
10
|
+
agentLock(passphrase: string, pubSub: any): AgentStatus;
|
|
11
|
+
agentUnlock(passphrase: string, holochain: boolean, pubSub: any): AgentStatus;
|
|
12
|
+
agentByDID(did: string): Agent;
|
|
13
|
+
agentUpdatePublicPerspective(perspective: PerspectiveInput, pubSub: any): Agent;
|
|
14
|
+
agentUpdateDirectMessageLanguage(directMessageLanguage: string, pubSub: any): Agent;
|
|
15
|
+
agentUpdated(): Agent;
|
|
16
|
+
agentStatusChanged(): AgentStatus;
|
|
17
|
+
agentAddEntanglementProofs(proofs: EntanglementProofInput[]): EntanglementProof[];
|
|
18
|
+
agentDeleteEntanglementProofs(proofs: EntanglementProofInput[]): EntanglementProof[];
|
|
19
|
+
agentGetEntanglementProofs(): EntanglementProof[];
|
|
20
|
+
agentEntanglementProofPreFlight(deviceKey: string, deviceKeyType: string): EntanglementProof;
|
|
21
|
+
agentRequestCapability(authInfo: AuthInfoInput): String;
|
|
22
|
+
agentPermitCapability(auth: string): String;
|
|
23
|
+
agentGenerateJwt(requestId: string, rand: string): String;
|
|
24
|
+
agentIsLocked(): Boolean;
|
|
25
|
+
agentGetApps(): [];
|
|
26
|
+
agentAppsChanged(): null;
|
|
27
|
+
agentRemoveApp(requestId: string, pubSub: any): [];
|
|
28
|
+
agentRevokeToken(requestId: string): any[];
|
|
29
|
+
agentSignMessage(message: string): AgentSignature;
|
|
30
|
+
}
|