@@ -88,6 +88,28 @@ To verify the signature in the App Builder action, set the `raw-http` annotation
88
88
raw-http : true
89
89
` ` `
90
90
91
+ Store the public key in the ` PUBLIC_KEY` parameter in the `.env` file in the same format as provided in the Adobe Commerce admin UI:
92
+
93
+ ` ` ` env
94
+ # Other secrets and configuration
95
+ # ...............................
96
+
97
+ PUBLIC_KEY="-----BEGIN PUBLIC KEY-----
98
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAtglXYVz5pVn3HDluGG5T
99
+ t9coO5NKSWjx3xCDMHVa3CEqVM76PKg8UJH9fQOA57xoNv7Llc916pF0UswtudQh
100
+ Fyg+WQCFFadqGZOyL2nUKI9xWBiUi4dN8+9yMd3TE1fszVUBnk/XdLKNDQn4O6ic
101
+ doQZi5arrjNjInkimtcT2jPXs34p9G9P5CvCubPUmbGsWDgwo5an9LEX/nJfnCdZ
102
+ R10XPkRWzEM7o1OGzf7CYo06Xl+msGVM02Er265PsMAWB11cWwKmyg6dLPa8q+Qh
103
+ KNXZiEMvdVusV8aA6EkCZYFdWSBXv+jltn6NnY5qvYcuQ3SujQ9xKEANjeMWcW90
104
+ PwIDAQAB
105
+ -----END PUBLIC KEY-----"
106
+ ` ` `
107
+
108
+ **Note:** The `.env` file should not be committed to version control.
109
+
110
+ More information on [.env file usage](https://developer.adobe.com/app-builder/docs/guides/configuration/#env).
111
+
112
+
91
113
The following code example below shows how the signature can be verified in the App Builder action :
92
114
93
115
` ` ` javascript
@@ -109,9 +131,20 @@ async function main (params) {
109
131
if (isSignatureValid) {
110
132
logger.info('The signature is valid.');
111
133
// Here will be performed real action logic
112
- operations.push({
113
- op : ' success'
114
- });
134
+ // payload is base64 encoded, so we need to decode it before using
135
+ const payload = JSON.parse(atob(params.__ow_body))
136
+
137
+ // a simple validation if the provided postcode from Commerce webhook is less than 50000
138
+ if (payload.address.postcode > 50000) {
139
+ operations.push({
140
+ op: 'exception',
141
+ message: 'The postcode is not allowed. Provided postcode: ' + payload.address.postcode
142
+ });
143
+ } else {
144
+ operations.push({
145
+ op: 'success'
146
+ });
147
+ }
115
148
} else {
116
149
logger.info('The signature is invalid.');
117
150
operations.push({
0 commit comments