@coasys/ad4m 0.8.0-fix → 0.8.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 +229 -229
- package/jest.config.js +5 -5
- package/jsdoc.json +27 -27
- package/lib/index.cjs +4522 -4571
- package/lib/index.js +4522 -4571
- package/lib/shims/type-graphql.d.ts +32 -32
- package/lib/shims/type-graphql.js +70 -70
- package/lib/src/Ad4mClient.d.ts +26 -26
- package/lib/src/Ad4mClient.js +66 -66
- package/lib/src/Address.d.ts +1 -1
- package/lib/src/Address.js +1 -1
- package/lib/src/DID.d.ts +1 -1
- package/lib/src/DID.js +1 -1
- package/lib/src/Exception.d.ts +6 -6
- package/lib/src/Exception.js +7 -7
- package/lib/src/Literal.d.ts +7 -7
- package/lib/src/Literal.js +76 -76
- package/lib/src/PubSub.d.ts +14 -14
- package/lib/src/PubSub.js +14 -14
- package/lib/src/SmartLiteral.d.ts +12 -12
- package/lib/src/SmartLiteral.js +74 -74
- package/lib/src/agent/Agent.d.ts +104 -104
- package/lib/src/agent/Agent.js +337 -337
- package/lib/src/agent/AgentClient.d.ts +57 -57
- package/lib/src/agent/AgentClient.js +431 -431
- package/lib/src/agent/AgentResolver.d.ts +30 -30
- package/lib/src/agent/AgentResolver.js +325 -325
- package/lib/src/agent/AgentStatus.d.ts +8 -8
- package/lib/src/agent/AgentStatus.js +61 -61
- package/lib/src/buildSchema.d.ts +1 -1
- package/lib/src/buildSchema.js +36 -36
- package/lib/src/expression/Expression.d.ts +28 -28
- package/lib/src/expression/Expression.js +143 -143
- package/lib/src/expression/ExpressionClient.d.ts +13 -13
- package/lib/src/expression/ExpressionClient.js +102 -102
- package/lib/src/expression/ExpressionRef.d.ts +9 -9
- package/lib/src/expression/ExpressionRef.js +67 -67
- package/lib/src/expression/ExpressionResolver.d.ts +10 -10
- package/lib/src/expression/ExpressionResolver.js +106 -106
- package/lib/src/index.d.ts +30 -30
- package/lib/src/index.js +30 -30
- package/lib/src/jestSetup.d.ts +1 -1
- package/lib/src/jestSetup.js +1 -1
- package/lib/src/language/Icon.d.ts +4 -4
- package/lib/src/language/Icon.js +24 -24
- package/lib/src/language/Language.d.ts +195 -195
- package/lib/src/language/Language.js +79 -79
- package/lib/src/language/LanguageClient.d.ts +17 -17
- package/lib/src/language/LanguageClient.js +137 -137
- package/lib/src/language/LanguageContext.d.ts +37 -37
- package/lib/src/language/LanguageContext.js +2 -2
- package/lib/src/language/LanguageHandle.d.ts +9 -9
- package/lib/src/language/LanguageHandle.js +41 -41
- package/lib/src/language/LanguageMeta.d.ts +35 -35
- package/lib/src/language/LanguageMeta.js +89 -89
- package/lib/src/language/LanguageRef.d.ts +6 -6
- package/lib/src/language/LanguageRef.js +30 -30
- package/lib/src/language/LanguageResolver.d.ts +19 -19
- package/lib/src/language/LanguageResolver.js +143 -143
- package/lib/src/links/Links.d.ts +39 -39
- package/lib/src/links/Links.js +148 -148
- package/lib/src/links/Links.test.d.ts +1 -1
- package/lib/src/links/Links.test.js +33 -33
- package/lib/src/neighbourhood/Neighbourhood.d.ts +10 -10
- package/lib/src/neighbourhood/Neighbourhood.js +38 -38
- package/lib/src/neighbourhood/NeighbourhoodClient.d.ts +25 -25
- package/lib/src/neighbourhood/NeighbourhoodClient.js +256 -256
- package/lib/src/neighbourhood/NeighbourhoodProxy.d.ts +19 -19
- package/lib/src/neighbourhood/NeighbourhoodProxy.js +54 -54
- package/lib/src/neighbourhood/NeighbourhoodResolver.d.ts +24 -24
- package/lib/src/neighbourhood/NeighbourhoodResolver.js +180 -180
- package/lib/src/perspectives/LinkQuery.d.ts +11 -11
- package/lib/src/perspectives/LinkQuery.js +80 -80
- package/lib/src/perspectives/Perspective.d.ts +38 -38
- package/lib/src/perspectives/Perspective.js +144 -144
- package/lib/src/perspectives/Perspective.test.d.ts +1 -1
- package/lib/src/perspectives/Perspective.test.js +20 -20
- package/lib/src/perspectives/PerspectiveClient.d.ts +55 -54
- package/lib/src/perspectives/PerspectiveClient.js +418 -410
- package/lib/src/perspectives/PerspectiveDiff.d.ts +9 -9
- package/lib/src/perspectives/PerspectiveDiff.js +33 -33
- package/lib/src/perspectives/PerspectiveHandle.d.ts +16 -16
- package/lib/src/perspectives/PerspectiveHandle.js +59 -59
- package/lib/src/perspectives/PerspectiveProxy.d.ts +178 -178
- package/lib/src/perspectives/PerspectiveProxy.js +501 -540
- package/lib/src/perspectives/PerspectiveResolver.d.ts +38 -37
- package/lib/src/perspectives/PerspectiveResolver.js +376 -362
- package/lib/src/runtime/RuntimeClient.d.ts +33 -33
- package/lib/src/runtime/RuntimeClient.js +263 -263
- package/lib/src/runtime/RuntimeResolver.d.ts +47 -47
- package/lib/src/runtime/RuntimeResolver.js +328 -328
- package/lib/src/schema.gql +1 -0
- package/lib/src/subject/SDNADecorators.d.ts +45 -45
- package/lib/src/subject/SDNADecorators.js +250 -250
- package/lib/src/subject/Subject.d.ts +7 -7
- package/lib/src/subject/Subject.js +160 -160
- package/lib/src/subject/SubjectEntity.d.ts +31 -31
- package/lib/src/subject/SubjectEntity.js +250 -250
- package/lib/src/subject/util.d.ts +12 -12
- package/lib/src/subject/util.js +73 -73
- package/lib/src/typeDefs.d.ts +1 -1
- package/lib/src/typeDefs.js +1 -0
- package/lib/src/unwrapApolloResult.d.ts +2 -2
- package/lib/src/unwrapApolloResult.js +14 -12
- package/lib/src/utils.d.ts +2 -2
- package/lib/src/utils.js +21 -21
- package/package.json +61 -61
- package/rollup.config.js +26 -26
- package/shims/type-graphql.ts +75 -75
- package/src/Ad4mClient.test.ts +1089 -1084
- package/src/Ad4mClient.ts +62 -62
- package/src/Address.ts +1 -1
- package/src/Exception.ts +6 -6
- package/src/Literal.test.ts +30 -30
- package/src/Literal.ts +80 -80
- package/src/PubSub.ts +13 -13
- package/src/SmartLiteral.ts +74 -74
- package/src/agent/Agent.ts +293 -293
- package/src/agent/AgentClient.ts +531 -531
- package/src/agent/AgentResolver.ts +263 -263
- package/src/agent/AgentStatus.ts +43 -43
- package/src/buildSchema.ts +41 -41
- package/src/expression/Expression.ts +99 -99
- package/src/expression/ExpressionClient.ts +98 -98
- package/src/expression/ExpressionRef.ts +62 -62
- package/src/expression/ExpressionResolver.ts +63 -63
- package/src/index.ts +30 -30
- package/src/language/Icon.ts +10 -10
- package/src/language/Language.ts +266 -266
- package/src/language/LanguageClient.ts +159 -159
- package/src/language/LanguageContext.ts +37 -37
- package/src/language/LanguageHandle.ts +23 -23
- package/src/language/LanguageMeta.ts +69 -69
- package/src/language/LanguageRef.ts +18 -18
- package/src/language/LanguageResolver.ts +98 -98
- package/src/links/Links.test.ts +39 -39
- package/src/links/Links.ts +107 -107
- package/src/neighbourhood/Neighbourhood.ts +22 -22
- package/src/neighbourhood/NeighbourhoodClient.ts +275 -275
- package/src/neighbourhood/NeighbourhoodProxy.ts +58 -58
- package/src/neighbourhood/NeighbourhoodResolver.ts +99 -99
- package/src/perspectives/LinkQuery.ts +65 -65
- package/src/perspectives/Perspective.test.ts +22 -22
- package/src/perspectives/Perspective.ts +118 -118
- package/src/perspectives/PerspectiveClient.ts +452 -443
- package/src/perspectives/PerspectiveDiff.ts +15 -15
- package/src/perspectives/PerspectiveHandle.ts +39 -39
- package/src/perspectives/PerspectiveProxy.ts +576 -610
- package/src/perspectives/PerspectiveResolver.ts +224 -219
- package/src/runtime/RuntimeClient.ts +282 -282
- package/src/runtime/RuntimeResolver.ts +192 -192
- package/src/subject/SDNADecorators.ts +333 -333
- package/src/subject/Subject.ts +152 -152
- package/src/subject/SubjectEntity.ts +291 -291
- package/src/subject/util.ts +84 -84
- package/src/typeDefs.ts +5 -5
- package/src/unwrapApolloResult.ts +15 -13
- package/src/utils.ts +25 -25
- package/tsconfig-browser.json +82 -82
- package/tsconfig.json +80 -80
- package/yarn-error.log +0 -22814
|
@@ -1,263 +1,263 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Arg,
|
|
3
|
-
Mutation,
|
|
4
|
-
Query,
|
|
5
|
-
Resolver,
|
|
6
|
-
Subscription,
|
|
7
|
-
PubSub,
|
|
8
|
-
} from "type-graphql";
|
|
9
|
-
import { Perspective, PerspectiveInput } from "../perspectives/Perspective";
|
|
10
|
-
import {
|
|
11
|
-
Agent,
|
|
12
|
-
AgentSignature,
|
|
13
|
-
Apps,
|
|
14
|
-
AuthInfoInput,
|
|
15
|
-
EntanglementProof,
|
|
16
|
-
EntanglementProofInput,
|
|
17
|
-
} from "./Agent";
|
|
18
|
-
import { AgentStatus } from "./AgentStatus";
|
|
19
|
-
import { AGENT_STATUS_CHANGED, AGENT_UPDATED, APPS_CHANGED } from "../PubSub";
|
|
20
|
-
|
|
21
|
-
export const TEST_AGENT_DID = "did:ad4m:test";
|
|
22
|
-
|
|
23
|
-
@Resolver()
|
|
24
|
-
export default class AgentResolver {
|
|
25
|
-
@Query((returns) => Agent)
|
|
26
|
-
agent(): Agent {
|
|
27
|
-
return new Agent(TEST_AGENT_DID);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
@Query((returns) => AgentStatus)
|
|
31
|
-
agentStatus(): AgentStatus {
|
|
32
|
-
return new AgentStatus({ did: TEST_AGENT_DID });
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
@Mutation((returns) => AgentStatus)
|
|
36
|
-
agentGenerate(
|
|
37
|
-
@Arg("passphrase") passphrase: string,
|
|
38
|
-
@PubSub() pubSub: any
|
|
39
|
-
): AgentStatus {
|
|
40
|
-
const status = new AgentStatus({
|
|
41
|
-
did: TEST_AGENT_DID,
|
|
42
|
-
didDocument: "did document",
|
|
43
|
-
isInitialized: true,
|
|
44
|
-
isUnlocked: true,
|
|
45
|
-
});
|
|
46
|
-
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
47
|
-
return status;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
@Mutation((returns) => AgentStatus)
|
|
51
|
-
agentImport(
|
|
52
|
-
@Arg("did") did: string,
|
|
53
|
-
@Arg("didDocument") didDocument: string,
|
|
54
|
-
@Arg("keystore") keystore: string,
|
|
55
|
-
@Arg("passphrase") passphrase: string
|
|
56
|
-
): AgentStatus {
|
|
57
|
-
return new AgentStatus({
|
|
58
|
-
did,
|
|
59
|
-
didDocument,
|
|
60
|
-
isInitialized: true,
|
|
61
|
-
isUnlocked: true,
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
@Mutation((returns) => AgentStatus)
|
|
66
|
-
agentLock(
|
|
67
|
-
@Arg("passphrase") passphrase: string,
|
|
68
|
-
@PubSub() pubSub: any
|
|
69
|
-
): AgentStatus {
|
|
70
|
-
const status = new AgentStatus({
|
|
71
|
-
isInitialized: true,
|
|
72
|
-
did: TEST_AGENT_DID,
|
|
73
|
-
});
|
|
74
|
-
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
75
|
-
return status;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
@Mutation((returns) => AgentStatus)
|
|
79
|
-
agentUnlock(
|
|
80
|
-
@Arg("passphrase") passphrase: string,
|
|
81
|
-
@Arg("holochain") holochain: boolean,
|
|
82
|
-
@PubSub() pubSub: any
|
|
83
|
-
): AgentStatus {
|
|
84
|
-
const status = new AgentStatus({
|
|
85
|
-
isInitialized: true,
|
|
86
|
-
isUnlocked: true,
|
|
87
|
-
did: TEST_AGENT_DID,
|
|
88
|
-
});
|
|
89
|
-
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
90
|
-
return status;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
@Query((returns) => Agent, { nullable: true })
|
|
94
|
-
agentByDID(@Arg("did") did: string): Agent {
|
|
95
|
-
return new Agent(did);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
@Mutation((returns) => Agent)
|
|
99
|
-
agentUpdatePublicPerspective(
|
|
100
|
-
@Arg("perspective") perspective: PerspectiveInput,
|
|
101
|
-
@PubSub() pubSub: any
|
|
102
|
-
): Agent {
|
|
103
|
-
const agent = new Agent(TEST_AGENT_DID, perspective as Perspective);
|
|
104
|
-
agent.directMessageLanguage = "lang://test";
|
|
105
|
-
pubSub.publish(AGENT_UPDATED, { agent });
|
|
106
|
-
return agent;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
@Mutation((returns) => Agent)
|
|
110
|
-
agentUpdateDirectMessageLanguage(
|
|
111
|
-
@Arg("directMessageLanguage") directMessageLanguage: string,
|
|
112
|
-
@PubSub() pubSub: any
|
|
113
|
-
): Agent {
|
|
114
|
-
const agent = new Agent(TEST_AGENT_DID, new Perspective());
|
|
115
|
-
agent.directMessageLanguage = directMessageLanguage;
|
|
116
|
-
pubSub.publish(AGENT_UPDATED, { agent });
|
|
117
|
-
return agent;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
@Subscription({ topics: AGENT_UPDATED, nullable: true })
|
|
121
|
-
agentUpdated(): Agent {
|
|
122
|
-
return new Agent(TEST_AGENT_DID);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
@Subscription({ topics: AGENT_STATUS_CHANGED, nullable: true })
|
|
126
|
-
agentStatusChanged(): AgentStatus {
|
|
127
|
-
return new AgentStatus({ isInitialized: true, did: TEST_AGENT_DID });
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
@Mutation((returns) => [EntanglementProof])
|
|
131
|
-
agentAddEntanglementProofs(
|
|
132
|
-
@Arg("proofs", (type) => [EntanglementProofInput])
|
|
133
|
-
proofs: EntanglementProofInput[]
|
|
134
|
-
): EntanglementProof[] {
|
|
135
|
-
return [
|
|
136
|
-
new EntanglementProof(
|
|
137
|
-
"did:key:hash",
|
|
138
|
-
"did-key-id",
|
|
139
|
-
"ethereum",
|
|
140
|
-
"ethAddr",
|
|
141
|
-
"sig",
|
|
142
|
-
"sig2"
|
|
143
|
-
),
|
|
144
|
-
];
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
@Mutation((returns) => [EntanglementProof])
|
|
148
|
-
agentDeleteEntanglementProofs(
|
|
149
|
-
@Arg("proofs", (type) => [EntanglementProofInput])
|
|
150
|
-
proofs: EntanglementProofInput[]
|
|
151
|
-
): EntanglementProof[] {
|
|
152
|
-
return [
|
|
153
|
-
new EntanglementProof(
|
|
154
|
-
"did:key:hash",
|
|
155
|
-
"did-key-id",
|
|
156
|
-
"ethereum",
|
|
157
|
-
"ethAddr",
|
|
158
|
-
"sig",
|
|
159
|
-
"sig2"
|
|
160
|
-
),
|
|
161
|
-
];
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
@Query((returns) => [EntanglementProof])
|
|
165
|
-
agentGetEntanglementProofs(): EntanglementProof[] {
|
|
166
|
-
return [
|
|
167
|
-
new EntanglementProof(
|
|
168
|
-
"did:key:hash",
|
|
169
|
-
"did-key-id",
|
|
170
|
-
"ethereum",
|
|
171
|
-
"ethAddr",
|
|
172
|
-
"sig",
|
|
173
|
-
"sig2"
|
|
174
|
-
),
|
|
175
|
-
];
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
@Mutation((returns) => EntanglementProof)
|
|
179
|
-
agentEntanglementProofPreFlight(
|
|
180
|
-
@Arg("deviceKey") deviceKey: string,
|
|
181
|
-
@Arg("deviceKeyType") deviceKeyType: string
|
|
182
|
-
): EntanglementProof {
|
|
183
|
-
return new EntanglementProof(
|
|
184
|
-
"did:key:hash",
|
|
185
|
-
"did-key-id",
|
|
186
|
-
deviceKeyType,
|
|
187
|
-
deviceKey,
|
|
188
|
-
"sig"
|
|
189
|
-
);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
@Mutation((returns) => String)
|
|
193
|
-
agentRequestCapability(@Arg("authInfo") authInfo: AuthInfoInput): String {
|
|
194
|
-
return "test-request-id";
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
@Mutation((returns) => String)
|
|
198
|
-
agentPermitCapability(@Arg("auth") auth: string): String {
|
|
199
|
-
return "123";
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
@Mutation((returns) => String)
|
|
203
|
-
agentGenerateJwt(
|
|
204
|
-
@Arg("requestId") requestId: string,
|
|
205
|
-
@Arg("rand") rand: string
|
|
206
|
-
): String {
|
|
207
|
-
return "test-jwt";
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
@Query((returns) => Boolean)
|
|
211
|
-
agentIsLocked(): Boolean {
|
|
212
|
-
return false;
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
@Query((returns) => [Apps])
|
|
216
|
-
agentGetApps(): [] {
|
|
217
|
-
return [];
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
@Subscription((returns) => [Apps], { topics: APPS_CHANGED, nullable: true })
|
|
222
|
-
agentAppsChanged(): null {
|
|
223
|
-
return null;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
@Mutation((returns) => [Apps])
|
|
228
|
-
agentRemoveApp(@Arg("requestId") requestId: string, @PubSub() pubSub: any): [] {
|
|
229
|
-
pubSub.publish(APPS_CHANGED, { });
|
|
230
|
-
return [];
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
@Mutation((returns) => [Apps])
|
|
234
|
-
agentRevokeToken(@Arg("requestId") requestId: string): any[] {
|
|
235
|
-
return [
|
|
236
|
-
{
|
|
237
|
-
revoked: true,
|
|
238
|
-
requestId: "test-request-id",
|
|
239
|
-
auth: {
|
|
240
|
-
appName: "test-app",
|
|
241
|
-
appDesc: "-",
|
|
242
|
-
appUrl: "-",
|
|
243
|
-
appIconPath: "_",
|
|
244
|
-
capabilities: [
|
|
245
|
-
{
|
|
246
|
-
with: {
|
|
247
|
-
domain: "*",
|
|
248
|
-
pointers: ["*"],
|
|
249
|
-
},
|
|
250
|
-
can: ["*"],
|
|
251
|
-
},
|
|
252
|
-
],
|
|
253
|
-
},
|
|
254
|
-
token: "test-token",
|
|
255
|
-
},
|
|
256
|
-
];
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
@Mutation((returns) => AgentSignature)
|
|
260
|
-
agentSignMessage(@Arg("message") message: string): AgentSignature {
|
|
261
|
-
return new AgentSignature("test-message-signature", "test-public-key");
|
|
262
|
-
}
|
|
263
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
Arg,
|
|
3
|
+
Mutation,
|
|
4
|
+
Query,
|
|
5
|
+
Resolver,
|
|
6
|
+
Subscription,
|
|
7
|
+
PubSub,
|
|
8
|
+
} from "type-graphql";
|
|
9
|
+
import { Perspective, PerspectiveInput } from "../perspectives/Perspective";
|
|
10
|
+
import {
|
|
11
|
+
Agent,
|
|
12
|
+
AgentSignature,
|
|
13
|
+
Apps,
|
|
14
|
+
AuthInfoInput,
|
|
15
|
+
EntanglementProof,
|
|
16
|
+
EntanglementProofInput,
|
|
17
|
+
} from "./Agent";
|
|
18
|
+
import { AgentStatus } from "./AgentStatus";
|
|
19
|
+
import { AGENT_STATUS_CHANGED, AGENT_UPDATED, APPS_CHANGED } from "../PubSub";
|
|
20
|
+
|
|
21
|
+
export const TEST_AGENT_DID = "did:ad4m:test";
|
|
22
|
+
|
|
23
|
+
@Resolver()
|
|
24
|
+
export default class AgentResolver {
|
|
25
|
+
@Query((returns) => Agent)
|
|
26
|
+
agent(): Agent {
|
|
27
|
+
return new Agent(TEST_AGENT_DID);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
@Query((returns) => AgentStatus)
|
|
31
|
+
agentStatus(): AgentStatus {
|
|
32
|
+
return new AgentStatus({ did: TEST_AGENT_DID });
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
@Mutation((returns) => AgentStatus)
|
|
36
|
+
agentGenerate(
|
|
37
|
+
@Arg("passphrase") passphrase: string,
|
|
38
|
+
@PubSub() pubSub: any
|
|
39
|
+
): AgentStatus {
|
|
40
|
+
const status = new AgentStatus({
|
|
41
|
+
did: TEST_AGENT_DID,
|
|
42
|
+
didDocument: "did document",
|
|
43
|
+
isInitialized: true,
|
|
44
|
+
isUnlocked: true,
|
|
45
|
+
});
|
|
46
|
+
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
47
|
+
return status;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@Mutation((returns) => AgentStatus)
|
|
51
|
+
agentImport(
|
|
52
|
+
@Arg("did") did: string,
|
|
53
|
+
@Arg("didDocument") didDocument: string,
|
|
54
|
+
@Arg("keystore") keystore: string,
|
|
55
|
+
@Arg("passphrase") passphrase: string
|
|
56
|
+
): AgentStatus {
|
|
57
|
+
return new AgentStatus({
|
|
58
|
+
did,
|
|
59
|
+
didDocument,
|
|
60
|
+
isInitialized: true,
|
|
61
|
+
isUnlocked: true,
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@Mutation((returns) => AgentStatus)
|
|
66
|
+
agentLock(
|
|
67
|
+
@Arg("passphrase") passphrase: string,
|
|
68
|
+
@PubSub() pubSub: any
|
|
69
|
+
): AgentStatus {
|
|
70
|
+
const status = new AgentStatus({
|
|
71
|
+
isInitialized: true,
|
|
72
|
+
did: TEST_AGENT_DID,
|
|
73
|
+
});
|
|
74
|
+
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
75
|
+
return status;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Mutation((returns) => AgentStatus)
|
|
79
|
+
agentUnlock(
|
|
80
|
+
@Arg("passphrase") passphrase: string,
|
|
81
|
+
@Arg("holochain") holochain: boolean,
|
|
82
|
+
@PubSub() pubSub: any
|
|
83
|
+
): AgentStatus {
|
|
84
|
+
const status = new AgentStatus({
|
|
85
|
+
isInitialized: true,
|
|
86
|
+
isUnlocked: true,
|
|
87
|
+
did: TEST_AGENT_DID,
|
|
88
|
+
});
|
|
89
|
+
pubSub.publish(AGENT_STATUS_CHANGED, { status });
|
|
90
|
+
return status;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@Query((returns) => Agent, { nullable: true })
|
|
94
|
+
agentByDID(@Arg("did") did: string): Agent {
|
|
95
|
+
return new Agent(did);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
@Mutation((returns) => Agent)
|
|
99
|
+
agentUpdatePublicPerspective(
|
|
100
|
+
@Arg("perspective") perspective: PerspectiveInput,
|
|
101
|
+
@PubSub() pubSub: any
|
|
102
|
+
): Agent {
|
|
103
|
+
const agent = new Agent(TEST_AGENT_DID, perspective as Perspective);
|
|
104
|
+
agent.directMessageLanguage = "lang://test";
|
|
105
|
+
pubSub.publish(AGENT_UPDATED, { agent });
|
|
106
|
+
return agent;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
@Mutation((returns) => Agent)
|
|
110
|
+
agentUpdateDirectMessageLanguage(
|
|
111
|
+
@Arg("directMessageLanguage") directMessageLanguage: string,
|
|
112
|
+
@PubSub() pubSub: any
|
|
113
|
+
): Agent {
|
|
114
|
+
const agent = new Agent(TEST_AGENT_DID, new Perspective());
|
|
115
|
+
agent.directMessageLanguage = directMessageLanguage;
|
|
116
|
+
pubSub.publish(AGENT_UPDATED, { agent });
|
|
117
|
+
return agent;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
@Subscription({ topics: AGENT_UPDATED, nullable: true })
|
|
121
|
+
agentUpdated(): Agent {
|
|
122
|
+
return new Agent(TEST_AGENT_DID);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
@Subscription({ topics: AGENT_STATUS_CHANGED, nullable: true })
|
|
126
|
+
agentStatusChanged(): AgentStatus {
|
|
127
|
+
return new AgentStatus({ isInitialized: true, did: TEST_AGENT_DID });
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
@Mutation((returns) => [EntanglementProof])
|
|
131
|
+
agentAddEntanglementProofs(
|
|
132
|
+
@Arg("proofs", (type) => [EntanglementProofInput])
|
|
133
|
+
proofs: EntanglementProofInput[]
|
|
134
|
+
): EntanglementProof[] {
|
|
135
|
+
return [
|
|
136
|
+
new EntanglementProof(
|
|
137
|
+
"did:key:hash",
|
|
138
|
+
"did-key-id",
|
|
139
|
+
"ethereum",
|
|
140
|
+
"ethAddr",
|
|
141
|
+
"sig",
|
|
142
|
+
"sig2"
|
|
143
|
+
),
|
|
144
|
+
];
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
@Mutation((returns) => [EntanglementProof])
|
|
148
|
+
agentDeleteEntanglementProofs(
|
|
149
|
+
@Arg("proofs", (type) => [EntanglementProofInput])
|
|
150
|
+
proofs: EntanglementProofInput[]
|
|
151
|
+
): EntanglementProof[] {
|
|
152
|
+
return [
|
|
153
|
+
new EntanglementProof(
|
|
154
|
+
"did:key:hash",
|
|
155
|
+
"did-key-id",
|
|
156
|
+
"ethereum",
|
|
157
|
+
"ethAddr",
|
|
158
|
+
"sig",
|
|
159
|
+
"sig2"
|
|
160
|
+
),
|
|
161
|
+
];
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Query((returns) => [EntanglementProof])
|
|
165
|
+
agentGetEntanglementProofs(): EntanglementProof[] {
|
|
166
|
+
return [
|
|
167
|
+
new EntanglementProof(
|
|
168
|
+
"did:key:hash",
|
|
169
|
+
"did-key-id",
|
|
170
|
+
"ethereum",
|
|
171
|
+
"ethAddr",
|
|
172
|
+
"sig",
|
|
173
|
+
"sig2"
|
|
174
|
+
),
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
@Mutation((returns) => EntanglementProof)
|
|
179
|
+
agentEntanglementProofPreFlight(
|
|
180
|
+
@Arg("deviceKey") deviceKey: string,
|
|
181
|
+
@Arg("deviceKeyType") deviceKeyType: string
|
|
182
|
+
): EntanglementProof {
|
|
183
|
+
return new EntanglementProof(
|
|
184
|
+
"did:key:hash",
|
|
185
|
+
"did-key-id",
|
|
186
|
+
deviceKeyType,
|
|
187
|
+
deviceKey,
|
|
188
|
+
"sig"
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
@Mutation((returns) => String)
|
|
193
|
+
agentRequestCapability(@Arg("authInfo") authInfo: AuthInfoInput): String {
|
|
194
|
+
return "test-request-id";
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
@Mutation((returns) => String)
|
|
198
|
+
agentPermitCapability(@Arg("auth") auth: string): String {
|
|
199
|
+
return "123";
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
@Mutation((returns) => String)
|
|
203
|
+
agentGenerateJwt(
|
|
204
|
+
@Arg("requestId") requestId: string,
|
|
205
|
+
@Arg("rand") rand: string
|
|
206
|
+
): String {
|
|
207
|
+
return "test-jwt";
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
@Query((returns) => Boolean)
|
|
211
|
+
agentIsLocked(): Boolean {
|
|
212
|
+
return false;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
@Query((returns) => [Apps])
|
|
216
|
+
agentGetApps(): [] {
|
|
217
|
+
return [];
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
@Subscription((returns) => [Apps], { topics: APPS_CHANGED, nullable: true })
|
|
222
|
+
agentAppsChanged(): null {
|
|
223
|
+
return null;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
|
|
227
|
+
@Mutation((returns) => [Apps])
|
|
228
|
+
agentRemoveApp(@Arg("requestId") requestId: string, @PubSub() pubSub: any): [] {
|
|
229
|
+
pubSub.publish(APPS_CHANGED, { });
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
@Mutation((returns) => [Apps])
|
|
234
|
+
agentRevokeToken(@Arg("requestId") requestId: string): any[] {
|
|
235
|
+
return [
|
|
236
|
+
{
|
|
237
|
+
revoked: true,
|
|
238
|
+
requestId: "test-request-id",
|
|
239
|
+
auth: {
|
|
240
|
+
appName: "test-app",
|
|
241
|
+
appDesc: "-",
|
|
242
|
+
appUrl: "-",
|
|
243
|
+
appIconPath: "_",
|
|
244
|
+
capabilities: [
|
|
245
|
+
{
|
|
246
|
+
with: {
|
|
247
|
+
domain: "*",
|
|
248
|
+
pointers: ["*"],
|
|
249
|
+
},
|
|
250
|
+
can: ["*"],
|
|
251
|
+
},
|
|
252
|
+
],
|
|
253
|
+
},
|
|
254
|
+
token: "test-token",
|
|
255
|
+
},
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
@Mutation((returns) => AgentSignature)
|
|
260
|
+
agentSignMessage(@Arg("message") message: string): AgentSignature {
|
|
261
|
+
return new AgentSignature("test-message-signature", "test-public-key");
|
|
262
|
+
}
|
|
263
|
+
}
|
package/src/agent/AgentStatus.ts
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
|
-
import { Field, ObjectType } from "type-graphql";
|
|
2
|
-
|
|
3
|
-
@ObjectType()
|
|
4
|
-
export class AgentStatus {
|
|
5
|
-
@Field()
|
|
6
|
-
isInitialized: Boolean
|
|
7
|
-
|
|
8
|
-
@Field()
|
|
9
|
-
isUnlocked: Boolean
|
|
10
|
-
|
|
11
|
-
@Field({nullable: true})
|
|
12
|
-
did?: string
|
|
13
|
-
|
|
14
|
-
@Field({nullable: true})
|
|
15
|
-
didDocument?: string
|
|
16
|
-
|
|
17
|
-
@Field({nullable: true})
|
|
18
|
-
error?: string
|
|
19
|
-
|
|
20
|
-
constructor(obj?: object) {
|
|
21
|
-
if(obj) {
|
|
22
|
-
//@ts-ignore
|
|
23
|
-
this.isInitialized = obj.isInitialized
|
|
24
|
-
if(!this.isInitialized) {
|
|
25
|
-
this.isInitialized = false
|
|
26
|
-
}
|
|
27
|
-
//@ts-ignore
|
|
28
|
-
this.isUnlocked = obj.isUnlocked
|
|
29
|
-
if(!this.isUnlocked) {
|
|
30
|
-
this.isUnlocked = false
|
|
31
|
-
}
|
|
32
|
-
//@ts-ignore
|
|
33
|
-
this.did = obj.did
|
|
34
|
-
//@ts-ignore
|
|
35
|
-
this.didDocument = obj.didDocument
|
|
36
|
-
//@ts-ignore
|
|
37
|
-
this.error = obj.error
|
|
38
|
-
} else {
|
|
39
|
-
this.isInitialized = false
|
|
40
|
-
this.isUnlocked = false
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
}
|
|
1
|
+
import { Field, ObjectType } from "type-graphql";
|
|
2
|
+
|
|
3
|
+
@ObjectType()
|
|
4
|
+
export class AgentStatus {
|
|
5
|
+
@Field()
|
|
6
|
+
isInitialized: Boolean
|
|
7
|
+
|
|
8
|
+
@Field()
|
|
9
|
+
isUnlocked: Boolean
|
|
10
|
+
|
|
11
|
+
@Field({nullable: true})
|
|
12
|
+
did?: string
|
|
13
|
+
|
|
14
|
+
@Field({nullable: true})
|
|
15
|
+
didDocument?: string
|
|
16
|
+
|
|
17
|
+
@Field({nullable: true})
|
|
18
|
+
error?: string
|
|
19
|
+
|
|
20
|
+
constructor(obj?: object) {
|
|
21
|
+
if(obj) {
|
|
22
|
+
//@ts-ignore
|
|
23
|
+
this.isInitialized = obj.isInitialized
|
|
24
|
+
if(!this.isInitialized) {
|
|
25
|
+
this.isInitialized = false
|
|
26
|
+
}
|
|
27
|
+
//@ts-ignore
|
|
28
|
+
this.isUnlocked = obj.isUnlocked
|
|
29
|
+
if(!this.isUnlocked) {
|
|
30
|
+
this.isUnlocked = false
|
|
31
|
+
}
|
|
32
|
+
//@ts-ignore
|
|
33
|
+
this.did = obj.did
|
|
34
|
+
//@ts-ignore
|
|
35
|
+
this.didDocument = obj.didDocument
|
|
36
|
+
//@ts-ignore
|
|
37
|
+
this.error = obj.error
|
|
38
|
+
} else {
|
|
39
|
+
this.isInitialized = false
|
|
40
|
+
this.isUnlocked = false
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
}
|
|
44
44
|
}
|