@webqit/webflo 0.8.55-0 → 0.8.58
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/package.json
CHANGED
|
@@ -133,7 +133,7 @@ export default function(layout, params) {
|
|
|
133
133
|
// Thus the origin server would still not be contacted by the self.fetch() below, leading to inconsistencies in responses.
|
|
134
134
|
// So, we detect this scenerio and avoid it.
|
|
135
135
|
if (evt.request.mode === 'navigate' && evt.request.cache === 'force-cache' && evt.request.destination === 'document') {
|
|
136
|
-
return cache_fetch(evt,
|
|
136
|
+
return cache_fetch(evt/** , truecacheRefresh */);
|
|
137
137
|
}
|
|
138
138
|
if (_any((params.cache_first_url_list || []).map(c => c.trim()).filter(c => c), pattern => Minimatch.Minimatch(evt.request.url, pattern))) {
|
|
139
139
|
return cache_fetch(evt, true/** cacheRefresh */);
|
|
@@ -144,6 +144,9 @@ export default function(layout, params) {
|
|
|
144
144
|
return network_fetch(evt);
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
+
//evt.request.mode navigate evt.request.cache force-cache evt.request.destination document request.headers.get('Accept') text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
|
|
148
|
+
//evt.request.mode navigate evt.request.cache force-cache evt.request.destination document request.headers.get('Accept') text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
|
|
149
|
+
|
|
147
150
|
const getCacheName = request => request.headers.get('Accept') === 'application/json'
|
|
148
151
|
? params.cache_name + '_json'
|
|
149
152
|
: params.cache_name;
|
|
@@ -140,28 +140,24 @@ export async function deploy(Ui, origin, flags = {}, layout = {}) {
|
|
|
140
140
|
*/
|
|
141
141
|
export async function hook(Ui, event, deployCallback, flags = {}, layout = {}) {
|
|
142
142
|
const eventHandler = Webhooks.createEventHandler();
|
|
143
|
-
console.log('-------------------------event.request.headers', event.request.headers)
|
|
144
143
|
if (event.request.headers.has('user-agent') && event.request.headers.get('user-agent').startsWith('GitHub-Hookshot/')) {
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
console.log('-------------------------submits', submits)
|
|
148
|
-
const matches = (await origins.match(submits.payload.repository.full_name, flags, layout)).filter(o => o.autodeploy);
|
|
149
|
-
console.log('-------------------------matches', matches)
|
|
144
|
+
const payload = await event.request.json();
|
|
145
|
+
const matches = (await origins.match(payload.repository.full_name, flags, layout)).filter(o => o.autodeploy);
|
|
150
146
|
var deployParams;
|
|
151
147
|
if (!(deployParams = matches[0])) {
|
|
152
148
|
return;
|
|
153
149
|
}
|
|
154
150
|
if (matches.length > 1) {
|
|
155
|
-
throw new Error(`Failed deploy attempt (${
|
|
151
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Multiple deploy settings found.`);
|
|
156
152
|
}
|
|
157
153
|
if (!deployParams.autodeploy_secret) {
|
|
158
|
-
throw new Error(`Failed deploy attempt (${
|
|
154
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): The deploy settings do not contain a secret.`);
|
|
159
155
|
}
|
|
160
|
-
if (!Webhooks.verify(deployParams.autodeploy_secret,
|
|
161
|
-
throw new Error(`Failed deploy attempt (${
|
|
156
|
+
if (!Webhooks.verify(deployParams.autodeploy_secret, payload, event.request.headers.get('x-hub-signature'))) {
|
|
157
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Signature mismatch.`);
|
|
162
158
|
}
|
|
163
|
-
if (
|
|
164
|
-
throw new Error(`Failed deploy attempt (${
|
|
159
|
+
if (payload.repository.disabled || payload.repository.archived) {
|
|
160
|
+
throw new Error(`Failed deploy attempt (${payload.repository.full_name}): Repository disabled or archived.`);
|
|
165
161
|
}
|
|
166
162
|
eventHandler.on('push', async ({ name, payload }) => {
|
|
167
163
|
Ui.log('---------------------------');
|
|
@@ -182,37 +178,9 @@ export async function hook(Ui, event, deployCallback, flags = {}, layout = {}) {
|
|
|
182
178
|
}
|
|
183
179
|
});
|
|
184
180
|
return eventHandler.receive({
|
|
185
|
-
id: event.request.headers
|
|
186
|
-
name: event.request.headers
|
|
187
|
-
payload:
|
|
181
|
+
id: event.request.headers.get('x-github-delivery'),
|
|
182
|
+
name: event.request.headers.get('x-github-event'),
|
|
183
|
+
payload: payload /* JSON object */,
|
|
188
184
|
});
|
|
189
185
|
}
|
|
190
|
-
}
|
|
191
|
-
-------------------------event.request.headers Headers {
|
|
192
|
-
[Symbol(map)]: [Object: null prototype] {
|
|
193
|
-
host: [ 'webqit.io' ],
|
|
194
|
-
'user-agent': [ 'GitHub-Hookshot/0b09aa9' ],
|
|
195
|
-
'content-length': [ '8832' ],
|
|
196
|
-
Accept: [ '*/*' ],
|
|
197
|
-
'x-github-delivery': [ 'df789d9e-6a54-11ec-8718-4cd5824afac9' ],
|
|
198
|
-
'x-github-event': [ 'push' ],
|
|
199
|
-
'x-github-hook-id': [ '276190607' ],
|
|
200
|
-
'x-github-hook-installation-target-id': [ '319800404' ],
|
|
201
|
-
'x-github-hook-installation-target-type': [ 'repository' ],
|
|
202
|
-
'x-hub-signature': [ 'sha1=498b45d6bf3403f5e28c17c9c77ff6666e9e4529' ],
|
|
203
|
-
'x-hub-signature-256': [
|
|
204
|
-
'sha256=034225e0d05dedd523bb429ddf9e61a4863ac7b45de3bb0b429205664e795b8f'
|
|
205
|
-
],
|
|
206
|
-
'content-type': [ 'application/json' ],
|
|
207
|
-
connection: [ 'close' ]
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
-------------------------event.request.headers Headers {
|
|
211
|
-
[Symbol(map)]: [Object: null prototype] {
|
|
212
|
-
Accept: [ '*/*' ],
|
|
213
|
-
'user-agent': [ 'node-fetch/1.0 (+https://github.com/bitinn/node-fetch)' ],
|
|
214
|
-
'accept-encoding': [ 'gzip,deflate' ],
|
|
215
|
-
connection: [ 'close' ],
|
|
216
|
-
host: [ 'webqit.io' ]
|
|
217
|
-
}
|
|
218
|
-
}
|
|
186
|
+
}
|