pico-engine 1.6.2 → 1.8.0
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 -14
- package/dist/RulesetRegistryLoaderFs.js +24 -8
- package/dist/auth/cookies.js +32 -0
- package/dist/auth/index.js +6 -1
- package/dist/bundledKrl.js +129 -11
- package/dist/channelIdentityPolicy.js +22 -0
- package/dist/cli.js +105 -46
- package/dist/engineConfig.js +280 -0
- package/dist/identity/IdentityService.js +90 -0
- package/dist/identity/crossPico.js +106 -30
- package/dist/identity/didoModule.js +80 -18
- package/dist/identity/establishSubscription.js +2 -2
- package/dist/identity/identityPortable.js +92 -0
- package/dist/identity/index.js +10 -1
- package/dist/identity/localPeerReconcile.js +65 -0
- package/dist/identity/peerDid4.js +175 -0
- package/dist/identity/peerDid4Create.js +90 -0
- package/dist/identity/portableExportPrepare.js +196 -0
- package/dist/identity/portableMove.js +87 -0
- package/dist/identity/skyIntro.js +10 -4
- package/dist/identity/skyProtocol.js +26 -1
- package/dist/identity/skyRotation.js +121 -0
- package/dist/identity/store.js +5 -1
- package/dist/identity/subscriptionEntSync.js +72 -0
- package/dist/identity/veramoDidComm.js +41 -2
- package/dist/identity/webvh.js +4 -2
- package/dist/identity/webvhRelocation.js +115 -0
- package/dist/index.js +127 -34
- package/dist/levelDb.js +102 -0
- package/dist/logging.js +47 -8
- package/dist/oauth/OAuthService.js +12 -5
- package/dist/oauth/channelEligibility.js +7 -1
- package/dist/oauth/index.js +3 -1
- package/dist/policyConfigFromJson.js +112 -0
- package/dist/runMcp.js +27 -0
- package/dist/server.js +95 -24
- package/dist/subtreeWrangler.js +180 -0
- package/dist/uiChannelPolicies.js +16 -0
- package/krl/io.picolabs.oauth.krl +51 -5
- package/krl/io.picolabs.pds.krl +131 -10
- package/krl/io.picolabs.pico-engine-ui.krl +219 -22
- package/krl/io.picolabs.portable_subtree.krl +97 -0
- package/krl/io.picolabs.subscription.krl +226 -72
- package/krl/io.picolabs.wrangler.krl +300 -58
- package/mcp/devResources.js +118 -0
- package/mcp/devTools.js +351 -0
- package/mcp/engineClient.js +133 -0
- package/mcp/meshHttp.js +137 -0
- package/mcp/meshTools.js +189 -0
- package/mcp/runStdio.js +34 -0
- package/mcp/schemaToZod.js +56 -0
- package/package.json +22 -8
- package/public/docs/_sidebar.md +2 -1
- package/public/docs/llms-full.txt +479 -0
- package/public/docs/llms.txt +37 -0
- package/public/docs/openapi.yaml +78 -0
- package/public/docs/pico-engine.md +235 -4
- package/public/docs/pico-overview.md +117 -0
- package/public/docs/pico.md +3 -1
- package/public/docs/rulesets/README.md +25 -0
- package/public/docs/rulesets/io.picolabs.oauth.md +71 -0
- package/public/docs/rulesets/io.picolabs.pds.md +327 -0
- package/public/docs/rulesets/io.picolabs.pico-engine-ui.md +65 -0
- package/public/docs/rulesets/io.picolabs.portable_subtree.md +94 -0
- package/public/docs/rulesets/io.picolabs.subscription.md +398 -0
- package/public/docs/rulesets/io.picolabs.wrangler.md +471 -0
- package/public/pico-engine-ui.css +1 -1
- package/public/pico-engine-ui.js +28 -26
- package/src/RulesetRegistryLoaderFs.ts +43 -11
- package/src/auth/cookies.ts +34 -0
- package/src/auth/index.ts +7 -0
- package/src/bundledKrl.ts +150 -12
- package/src/channelIdentityPolicy.ts +29 -0
- package/src/cli.ts +98 -40
- package/src/engineConfig.ts +345 -0
- package/src/identity/IdentityService.ts +189 -1
- package/src/identity/crossPico.ts +161 -41
- package/src/identity/didoModule.ts +140 -23
- package/src/identity/establishSubscription.ts +2 -2
- package/src/identity/identityPortable.ts +153 -0
- package/src/identity/index.ts +14 -0
- package/src/identity/localPeerReconcile.ts +97 -0
- package/src/identity/peerDid4.ts +197 -0
- package/src/identity/peerDid4Create.ts +121 -0
- package/src/identity/portableExportPrepare.ts +302 -0
- package/src/identity/portableMove.ts +193 -0
- package/src/identity/skyIntro.ts +16 -12
- package/src/identity/skyProtocol.ts +46 -0
- package/src/identity/skyRotation.ts +211 -0
- package/src/identity/store.ts +5 -1
- package/src/identity/subscriptionEntSync.ts +97 -0
- package/src/identity/veramoDidComm.ts +52 -2
- package/src/identity/webvh.ts +4 -4
- package/src/identity/webvhRelocation.ts +167 -0
- package/src/index.ts +179 -39
- package/src/levelDb.ts +122 -0
- package/src/logging.ts +63 -11
- package/src/oauth/OAuthService.ts +20 -6
- package/src/oauth/channelEligibility.ts +9 -0
- package/src/oauth/index.ts +7 -1
- package/src/policyConfigFromJson.ts +131 -0
- package/src/runMcp.ts +30 -0
- package/src/server.ts +133 -27
- package/src/subtreeWrangler.ts +278 -0
- package/src/uiChannelPolicies.ts +16 -0
- package/krl/io.picolabs.did-o.krl +0 -349
- package/krl/test/didtestdid.krl +0 -78
|
@@ -1,349 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
DID-O V 1.0.0
|
|
3
|
-
⠀⠀⠀⢠⡜⠛⠛⠿⣤⠀⠀⣤⡼⠿⠿⢧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
4
|
-
⠀⣀⡶⠎⠁⠀⠀⠀⠉⠶⠶⠉⠁⠀⠀⠈⠹⢆⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
|
|
5
|
-
⣀⡿⠇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠶⠶⠶⠶⣆⡀⠀⠀⠀⠀
|
|
6
|
-
⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢣⡄⠀⠀⠀
|
|
7
|
-
⠛⣧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⠃⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀
|
|
8
|
-
⠀⠛⣧⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠿⠀⠀⠀⠀⢠⡼⠃⠀⠀
|
|
9
|
-
⠀⠀⠿⢇⡀⠀⠀⠀⠀⠀⠀⠀⠰⠶⠶⢆⣀⣀⣀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀
|
|
10
|
-
⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠉⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀⠀
|
|
11
|
-
⠀⠀⠀⢸⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇⠀⠀
|
|
12
|
-
⠀⠀⣿⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⢣⣤
|
|
13
|
-
⠀⣶⡏⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿
|
|
14
|
-
⠀⠿⣇⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣀⣀⣀⣀⣀⣀⠀⠀⠀⠀⢀⣀⣸⠿
|
|
15
|
-
⠀⠀⠙⢳⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⣶⡞⠛⠛⠛⠛⠛⠛⣶⣶⣶⣶⡞⠛⠃⠀
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
ruleset io.picolabs.did-o {
|
|
19
|
-
meta {
|
|
20
|
-
name "did-o"
|
|
21
|
-
description
|
|
22
|
-
<<
|
|
23
|
-
DEPRECATED (pico-engine 1.6+): Layer 2 identity folds DIDComm routing into the
|
|
24
|
-
engine dido module and wrangler core. Do not install on new picos. Use
|
|
25
|
-
wrangler:myDid(), event:send({did: ...}), and wrangler:picoQuery with DID targets instead.
|
|
26
|
-
|
|
27
|
-
Legacy ruleset for DIDComm v2 communication using picos (did:peer:2 era).
|
|
28
|
-
>>
|
|
29
|
-
author "Rembrand Paul Pardo, Kekoapoaono Montalbo, Josh Mann"
|
|
30
|
-
|
|
31
|
-
provides addRoute, routes, send, sendEvent, sendQuery, didMap, clearDidMap, didDocs, clearDidDocs, pendingRotations, clearPendingRotations, generate_invitation, generate_message
|
|
32
|
-
|
|
33
|
-
shares routes, addRoute, didDocs, clearDidDocs, didMap, clearDidMap, pendingRotations, clearPendingRotations, generate_invitation, generate_message
|
|
34
|
-
|
|
35
|
-
use module io.picolabs.wrangler alias wrangler
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
global {
|
|
40
|
-
///////////////////////////////////////////// ROUTING //////////////////////////////////////////////
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Adds a route to the routes stored in the dido.ts library. The type should be a valid Protocol URI.
|
|
44
|
-
* The domain and name are the domain and name of the event that will be raised when a message of the specified type is received.
|
|
45
|
-
*/
|
|
46
|
-
addRoute = function(type, _domain, name) {
|
|
47
|
-
dido:addRoute(type, _domain, name)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Queries the existing routes.
|
|
52
|
-
*/
|
|
53
|
-
routes = function() {
|
|
54
|
-
ent:routes
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Send a message to the specified DID. did is the recipient DID and message is a valid DIDComm v2 message.
|
|
59
|
-
*/
|
|
60
|
-
send = function(did, message) {
|
|
61
|
-
dido:send(did, message)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Send an event to the specified DID. did is the recipient DID and the event is formatted as follows:
|
|
66
|
-
* event = {
|
|
67
|
-
* "domain": domain: string,
|
|
68
|
-
* "name": name: string,
|
|
69
|
-
* "attrs": attrs: {[name: string]: any}
|
|
70
|
-
* }
|
|
71
|
-
*/
|
|
72
|
-
sendEvent = function(did, event) {
|
|
73
|
-
message = dido:generateMessage({
|
|
74
|
-
"type": "https://picolabs.io/event/1.0/event",
|
|
75
|
-
"from": ent:didMap{did},
|
|
76
|
-
"to": [did],
|
|
77
|
-
"body": event
|
|
78
|
-
})
|
|
79
|
-
dido:send(did, message)
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Send a query to the specified DID. did is the recipient DID and the query is formatted as follows:
|
|
84
|
-
* query = {
|
|
85
|
-
* "rid": rid: string,
|
|
86
|
-
* "name": name: string,
|
|
87
|
-
* "args": args: {[name: string]: any}
|
|
88
|
-
* }
|
|
89
|
-
*/
|
|
90
|
-
sendQuery = function(did, _query) {
|
|
91
|
-
message = dido:generateMessage({
|
|
92
|
-
"type": "https://picolabs.io/query/1.0/query",
|
|
93
|
-
"from": ent:didMap{did},
|
|
94
|
-
"to": [did],
|
|
95
|
-
"body": _query
|
|
96
|
-
})
|
|
97
|
-
dido:sendQuery(did, message)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
///////////////////////////////////////////// DID MANAGEMENT //////////////////////////////////////////////
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Return the map of DID relationships stored in the pattern [ thier_did : your_did ].
|
|
104
|
-
*/
|
|
105
|
-
didMap = function() {
|
|
106
|
-
ent:didMap
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Clear the map of DID relationships.
|
|
111
|
-
*/
|
|
112
|
-
clearDidMap = function() {
|
|
113
|
-
dido:clearDidMap()
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Return all the DIDs and DIDDocs stored in the pattern [ did : diddoc ].
|
|
118
|
-
*/
|
|
119
|
-
didDocs = function() {
|
|
120
|
-
ent:didDocs
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
/**
|
|
124
|
-
* Clear all the DIDs and DIDDocs.
|
|
125
|
-
*/
|
|
126
|
-
clearDidDocs = function() {
|
|
127
|
-
dido:clearDidDocs()
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
/**
|
|
131
|
-
* Return all the pending rotations stored in the pattern [ new_did : from_prior ].
|
|
132
|
-
*/
|
|
133
|
-
pendingRotations = function() {
|
|
134
|
-
ent:pendingRotations
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
/**
|
|
138
|
-
* Clear all the pending rotations.
|
|
139
|
-
*/
|
|
140
|
-
clearPendingRotations = function() {
|
|
141
|
-
dido:clearPendingRotations()
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
///////////////////////////////////////////// MESSAGE CREATORS //////////////////////////////////////////////
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Generates and returns a DIDComm v2 message with the given message.
|
|
148
|
-
* message is formatted as follows:
|
|
149
|
-
* {
|
|
150
|
-
* type: string,
|
|
151
|
-
* body: any,
|
|
152
|
-
* from?: string,
|
|
153
|
-
* to?: [string],
|
|
154
|
-
* thid?: string,
|
|
155
|
-
* pthid?: string,
|
|
156
|
-
* expires_time?: number,
|
|
157
|
-
* attachments?: [Attachment]
|
|
158
|
-
* }
|
|
159
|
-
*
|
|
160
|
-
* Refer to didcomm-node package for Attachment object specifics.
|
|
161
|
-
*/
|
|
162
|
-
generate_message = function(message) {
|
|
163
|
-
dido:generateMessage(message)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Creates an invitation OOB URL that can be used to establish DID based relationships.
|
|
168
|
-
* This automates the DID, channel, and message creation and encodes it into a base64 Out-of-Band URL.
|
|
169
|
-
*/
|
|
170
|
-
generate_invitation = function(label) {
|
|
171
|
-
DIDdoc = dido:generateDID(true)
|
|
172
|
-
new_did = DIDdoc{"id"}
|
|
173
|
-
invitation = dido:generateMessage({
|
|
174
|
-
"type": "https://didcomm.org/out-of-band/2.0/invitation",
|
|
175
|
-
"from": new_did,
|
|
176
|
-
"body": {
|
|
177
|
-
"goal_code": "exchange-did",
|
|
178
|
-
"goal": "ExchangeDid",
|
|
179
|
-
"label": label || "PicoInvite",
|
|
180
|
-
"accept": [
|
|
181
|
-
"didcomm/v2"
|
|
182
|
-
]
|
|
183
|
-
}
|
|
184
|
-
})
|
|
185
|
-
base64 = math:base64encode(invitation.encode())
|
|
186
|
-
dido:createInviteUrl(base64)
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Creates a trust ping message according to the DIDComm v2 protocol and returns it. The to parameter is the DID of the recipient.
|
|
191
|
-
*/
|
|
192
|
-
generate_trust_ping_message = function(to) {
|
|
193
|
-
dido:generateMessage({
|
|
194
|
-
"type": "https://didcomm.org/trust_ping/2.0/ping",
|
|
195
|
-
"from": ent:didMap{to},
|
|
196
|
-
"to": [to],
|
|
197
|
-
"body": {
|
|
198
|
-
"response_requested": true
|
|
199
|
-
}
|
|
200
|
-
})
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
/**
|
|
204
|
-
* Creates a trust ping response message according to the DIDComm v2 protocol and returns it.
|
|
205
|
-
* The thid parameter is the id of the ping that you are responding to, and the to parameter is the DID of the recipient.
|
|
206
|
-
*/
|
|
207
|
-
generate_trust_ping_response = function(thid, to) {
|
|
208
|
-
dido:generateMessage({
|
|
209
|
-
"type": "https://didcomm.org/trust_ping/2.0/ping_response",
|
|
210
|
-
"thid": thid,
|
|
211
|
-
"from": ent:didMap{to},
|
|
212
|
-
"to": [to],
|
|
213
|
-
"body": {}
|
|
214
|
-
})
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
///////////////////////////////////////////// INITIAILIZATION //////////////////////////////////////////////
|
|
219
|
-
|
|
220
|
-
/**
|
|
221
|
-
* The initialize rule subscribes to the wrangler:ruleset_installed event and is called when the ruleset is installed and initializes the routes.
|
|
222
|
-
*/
|
|
223
|
-
rule intialize {
|
|
224
|
-
select when wrangler ruleset_installed where event:attrs{"rids"} >< meta:rid
|
|
225
|
-
pre {
|
|
226
|
-
ping = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping", "dido", "receive_trust_ping")
|
|
227
|
-
ping_response = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping_response", "dido", "receive_trust_ping_response")
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* The pico_root_created rule subscribes to the engine_ui:setup event and is called when the engine starts and initializes the routes.
|
|
233
|
-
* This is used in addition to the initialize rule to verify routes exist when a new engine is started.
|
|
234
|
-
*/
|
|
235
|
-
rule pico_root_created {
|
|
236
|
-
select when engine_ui setup
|
|
237
|
-
if ent:routes.isnull() then noop()
|
|
238
|
-
fired {
|
|
239
|
-
ping = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping", "dido", "receive_trust_ping")
|
|
240
|
-
ping_response = dido:addRoute("https://didcomm.org/trust_ping/2.0/ping_response", "dido", "receive_trust_ping_response")
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
///////////////////////////////////////////// ROUTING //////////////////////////////////////////////
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* The route_message rule subscribes to the dido:didcommv2_message event. It calls the dido library,
|
|
248
|
-
* unpacks the message, and looks for the proper route based on the message type. It then raises the
|
|
249
|
-
* appropriate event and passes along the unpacked message.
|
|
250
|
-
*/
|
|
251
|
-
rule route_message {
|
|
252
|
-
select when dido didcommv2_message
|
|
253
|
-
pre {
|
|
254
|
-
response = dido:route(event:attrs.delete("_headers"))
|
|
255
|
-
}
|
|
256
|
-
if response then send_directive("response", {}.put(response))
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
///////////////////////////////////////////// INVITATIONS //////////////////////////////////////////////
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* The receive_invite rule subscribes to the dido:receive_invite event and receives an invite URL (example.com/invite?_oob=abc...123)
|
|
263
|
-
* from event:attrs{"invite"}. The invite URL is a base 64 encoded invite. The rule then creates a new DID and channel.
|
|
264
|
-
* After that, it raises the dido:send_trust_ping event.
|
|
265
|
-
*/
|
|
266
|
-
rule receive_invite {
|
|
267
|
-
select when dido receive_invite
|
|
268
|
-
pre {
|
|
269
|
-
url = event:attrs{"invite"}
|
|
270
|
-
base64 = url.split("_oob=")[1]
|
|
271
|
-
invite = math:base64decode(base64).decode()
|
|
272
|
-
new_did = dido:generateDID()
|
|
273
|
-
didMap = dido:mapDid(invite{"from"}, new_did{"id"})
|
|
274
|
-
stored_doc = dido:storeDidDoc(invite{"from"})
|
|
275
|
-
}
|
|
276
|
-
fired {
|
|
277
|
-
raise dido event "send_trust_ping" attributes event:attrs.put("did", invite{"from"})
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
///////////////////////////////////////////// TRUST PING //////////////////////////////////////////////
|
|
282
|
-
|
|
283
|
-
/**
|
|
284
|
-
* The send_trust_ping rule subscribes to the dido:send_trust_ping event and requires the DID of the recipient
|
|
285
|
-
* from event:attrs{"did"}. It then sends a generated trust ping message to the provided DID.
|
|
286
|
-
*/
|
|
287
|
-
rule send_trust_ping {
|
|
288
|
-
select when dido send_trust_ping
|
|
289
|
-
pre {
|
|
290
|
-
their_did = event:attrs{"did"}
|
|
291
|
-
message = generate_trust_ping_message(their_did)
|
|
292
|
-
send = dido:send(their_did, message)
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* The receive_trust_ping rule subscibes to the did:receive_trust_ping event and requires the ping message from
|
|
298
|
-
* event:attrs{"message"}. It then checks if the message was received from an invite. If it was, it rotates the
|
|
299
|
-
* invite DID. Then it generates the response and sends it back.
|
|
300
|
-
*/
|
|
301
|
-
rule receive_trust_ping {
|
|
302
|
-
select when dido receive_trust_ping
|
|
303
|
-
pre {
|
|
304
|
-
message = event:attrs{"message"}
|
|
305
|
-
their_did = message{"from"}
|
|
306
|
-
needsRotation = dido:rotateInviteDID(message{"to"}[0], message{"from"})
|
|
307
|
-
response = generate_trust_ping_response(message{"id"}, their_did)
|
|
308
|
-
send = dido:send(their_did, response)
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
/*
|
|
315
|
-
DID-O - V 1.0.0
|
|
316
|
-
,--._
|
|
317
|
-
| `...
|
|
318
|
-
,.-------" `.
|
|
319
|
-
/ " `-.__
|
|
320
|
-
. " _, `._
|
|
321
|
-
| __..-" `.
|
|
322
|
-
| ''"' `._
|
|
323
|
-
| `"-.
|
|
324
|
-
' `.
|
|
325
|
-
. |
|
|
326
|
-
/ |
|
|
327
|
-
_,' ,'
|
|
328
|
-
," /
|
|
329
|
-
. /
|
|
330
|
-
| /
|
|
331
|
-
| .
|
|
332
|
-
' |
|
|
333
|
-
`. |
|
|
334
|
-
`. |
|
|
335
|
-
`. '
|
|
336
|
-
. .
|
|
337
|
-
| `.
|
|
338
|
-
' |
|
|
339
|
-
,' |
|
|
340
|
-
,' '
|
|
341
|
-
/ _...._ /
|
|
342
|
-
. ,-' `"'--'
|
|
343
|
-
| ,'
|
|
344
|
-
.' ,'
|
|
345
|
-
/ _,....__ _,'
|
|
346
|
-
| ,.' `---'
|
|
347
|
-
'_ ,--`
|
|
348
|
-
`---'
|
|
349
|
-
*/
|
package/krl/test/didtestdid.krl
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
ruleset didtestdid {
|
|
2
|
-
meta {
|
|
3
|
-
name "didtestdid"
|
|
4
|
-
description
|
|
5
|
-
<<
|
|
6
|
-
A Test Ruleset Orchestrator for using DIDs with event:send() and wrangler:picoQuery()
|
|
7
|
-
>>
|
|
8
|
-
author "Josh Mann"
|
|
9
|
-
shares child1DidMap, child2DidMap
|
|
10
|
-
use module io.picolabs.wrangler alias wrangler
|
|
11
|
-
use module io.picolabs.did-o alias didx
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
global {
|
|
15
|
-
child1DidMap = function() {
|
|
16
|
-
wrangler:picoQuery(ent:child1, "io.picolabs.did-o", "didMap", {})
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
child2DidMap = function() {
|
|
20
|
-
wrangler:picoQuery(ent:child2, "io.picolabs.did-o", "didMap", {})
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
rule createChildren {
|
|
25
|
-
select when didtestdid createChildren
|
|
26
|
-
always {
|
|
27
|
-
raise wrangler event "new_child_request" attributes {"name": "child1", "backgroundColor": "#ae85fa"}
|
|
28
|
-
raise wrangler event "new_child_request" attributes {"name": "child2", "backgroundColor": "#fef1b4"}
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
rule createDIDRelationshipWithChildren {
|
|
33
|
-
select when didtestdid createDIDRelationshipWithChildren
|
|
34
|
-
foreach ctx:children setting(child)
|
|
35
|
-
pre {
|
|
36
|
-
invitation = didx:generate_invitation()
|
|
37
|
-
}
|
|
38
|
-
event:send({
|
|
39
|
-
"eci": child,
|
|
40
|
-
"domain": "dido",
|
|
41
|
-
"name": "receive_invite",
|
|
42
|
-
"attrs": {"invite": invitation}
|
|
43
|
-
})
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
rule saveChildDids {
|
|
47
|
-
select when didtestdid saveChildDids
|
|
48
|
-
always {
|
|
49
|
-
ent:child1 := didx:didMap().keys()[0]
|
|
50
|
-
ent:child2 := didx:didMap().keys()[1]
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
rule createDIDRelationship {
|
|
55
|
-
select when didtestdid createDIDRelationship
|
|
56
|
-
pre {
|
|
57
|
-
child1 = ent:child1.klog("Child1: ")
|
|
58
|
-
child2 = ent:child2.klog("Child2: ")
|
|
59
|
-
invitation = wrangler:picoQuery(child1, "io.picolabs.did-o", "generate_invitation", {}).klog("Invitation: ")
|
|
60
|
-
}
|
|
61
|
-
event:send({
|
|
62
|
-
"did": child2,
|
|
63
|
-
"domain": "dido",
|
|
64
|
-
"name": "receive_invite",
|
|
65
|
-
"attrs": {
|
|
66
|
-
"invite": invitation
|
|
67
|
-
}
|
|
68
|
-
})
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
rule deleteChildren {
|
|
72
|
-
select when didtestdid deleteChildren
|
|
73
|
-
foreach ctx:children setting(child)
|
|
74
|
-
always {
|
|
75
|
-
raise wrangler event "child_deletion_request" attributes {"eci": child}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|