@@ -58,69 +58,71 @@ bedrock.events.on('bedrock.init', async () => {
58
58
} ) ;
59
59
60
60
bedrock . events . on ( 'bedrock.ready' , async ( ) => {
61
- // programmatically create workflow for interactions
62
- {
63
- // create some controller for the workflow
64
- const secret = '53ad64ce-8e1d-11ec-bb12-10bf48838a41' ;
65
- const handle = 'test' ;
66
- const capabilityAgent = await CapabilityAgent . fromSecret ( { secret, handle} ) ;
67
- const { baseUri} = bedrock . config . server ;
61
+ // programmatically create workflow for interactions...
68
62
69
- const meter = {
70
- id : idEncoder . encode ( await idGenerator . generate ( ) ) ,
71
- controller : capabilityAgent . id ,
72
- product : {
73
- id : mockData . productIdMap . get ( 'vc-workflow' )
74
- } ,
75
- serviceId : bedrock . config [ 'app-identity' ] . seeds . services [ 'vc-workflow' ] . id
76
- } ;
77
- await meters . insert ( { meter} ) ;
78
- const meterId = `${ baseUri } /meters/${ meter . id } ` ;
79
- await meterReporting . upsert ( { id : meterId , serviceType : 'vc-workflow' } ) ;
63
+ // create some controller for the workflow
64
+ const secret = '53ad64ce-8e1d-11ec-bb12-10bf48838a41' ;
65
+ const handle = 'test' ;
66
+ const capabilityAgent = await CapabilityAgent . fromSecret ( { secret, handle} ) ;
67
+ const { baseUri} = bedrock . config . server ;
80
68
81
- const localWorkflowId = idEncoder . encode ( await idGenerator . generate ( ) ) ;
82
- const config = {
83
- id : `${ baseUri } /workflows/${ localWorkflowId } ` ,
84
- sequence : 0 ,
85
- controller : capabilityAgent . id ,
86
- meterId,
87
- steps : {
88
- myStep : {
89
- stepTemplate : {
90
- type : 'jsonata' ,
91
- template : `
92
- {
93
- "inviteRequest": inviteRequest
94
- }`
95
- }
69
+ const meter = {
70
+ id : idEncoder . encode ( await idGenerator . generate ( ) ) ,
71
+ controller : capabilityAgent . id ,
72
+ product : {
73
+ id : mockData . productIdMap . get ( 'vc-workflow' )
74
+ } ,
75
+ serviceId : bedrock . config [ 'app-identity' ] . seeds . services [ 'vc-workflow' ] . id
76
+ } ;
77
+ await meters . insert ( { meter} ) ;
78
+ const meterId = `${ baseUri } /meters/${ meter . id } ` ;
79
+ await meterReporting . upsert ( { id : meterId , serviceType : 'vc-workflow' } ) ;
80
+
81
+ const localWorkflowId = idEncoder . encode ( await idGenerator . generate ( ) ) ;
82
+ const config = {
83
+ id : `${ baseUri } /workflows/${ localWorkflowId } ` ,
84
+ sequence : 0 ,
85
+ controller : capabilityAgent . id ,
86
+ meterId,
87
+ steps : {
88
+ finish : {
89
+ stepTemplate : {
90
+ type : 'jsonata' ,
91
+ template : `
92
+ {
93
+ "inviteRequest": true,
94
+ "callback": {
95
+ "url": pushCallbackUrl
96
+ }
97
+ }`
96
98
}
97
- } ,
98
- initialStep : 'myStep'
99
- } ;
100
- await workflowService . configStorage . insert ( { config} ) ;
99
+ }
100
+ } ,
101
+ initialStep : 'finish'
102
+ } ;
103
+ await workflowService . configStorage . insert ( { config} ) ;
101
104
102
- // delegate ability to read/write exchanges for workflow to app identity
103
- const signer = capabilityAgent . getSigner ( ) ;
104
- const zcapClient = new ZcapClient ( {
105
- invocationSigner : signer ,
106
- delegationSigner : signer ,
107
- SuiteClass : Ed25519Signature2020
108
- } ) ;
109
- const readWriteExchanges = await zcapClient . delegate ( {
110
- capability : `urn:zcap:root:${ encodeURIComponent ( config . id ) } ` ,
111
- invocationTarget : `${ config . id } /exchanges` ,
112
- controller : ZCAP_CLIENT . invocationSigner . id ,
113
- expires : new Date ( Date . now ( ) + 1000 * 60 * 60 ) ,
114
- allowedActions : [ 'read' , 'write' ]
115
- } ) ;
116
- // update interactions config
117
- const interactionsConfig = bedrock . config [ 'profile-http' ] . interactions ;
118
- interactionsConfig . enabled = true ;
119
- interactionsConfig . types . test . zcaps
120
- . readWriteExchanges = JSON . stringify ( readWriteExchanges ) ;
121
- // re-process interactions config
122
- processInteractionConfig ( ) ;
123
- }
105
+ // delegate ability to read/write exchanges for workflow to app identity
106
+ const signer = capabilityAgent . getSigner ( ) ;
107
+ const zcapClient = new ZcapClient ( {
108
+ invocationSigner : signer ,
109
+ delegationSigner : signer ,
110
+ SuiteClass : Ed25519Signature2020
111
+ } ) ;
112
+ const readWriteExchanges = await zcapClient . delegate ( {
113
+ capability : `urn:zcap:root:${ encodeURIComponent ( config . id ) } ` ,
114
+ invocationTarget : `${ config . id } /exchanges` ,
115
+ controller : ZCAP_CLIENT . invocationSigner . id ,
116
+ expires : new Date ( Date . now ( ) + 1000 * 60 * 60 ) ,
117
+ allowedActions : [ 'read' , 'write' ]
118
+ } ) ;
119
+ // update interactions config
120
+ const interactionsConfig = bedrock . config [ 'profile-http' ] . interactions ;
121
+ interactionsConfig . enabled = true ;
122
+ interactionsConfig . types . test . zcaps
123
+ . readWriteExchanges = JSON . stringify ( readWriteExchanges ) ;
124
+ // re-process interactions config
125
+ processInteractionConfig ( ) ;
124
126
} ) ;
125
127
126
128
import '@bedrock/test' ;
0 commit comments