@fabrika/provider-zerops 0.0.16 → 0.0.18
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 +5 -5
- package/src/source.ts +16 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/provider-zerops",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -32,9 +32,9 @@
|
|
|
32
32
|
"gen:schema": "bun scripts/generate-zerops-types.ts"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@fabrika/auth": "^0.0.
|
|
36
|
-
"@fabrika/auth-core": "^0.0.
|
|
37
|
-
"@fabrika/provider-contract": "^0.0.
|
|
38
|
-
"@fabrika/proxy-contract": "^0.0.
|
|
35
|
+
"@fabrika/auth": "^0.0.18",
|
|
36
|
+
"@fabrika/auth-core": "^0.0.18",
|
|
37
|
+
"@fabrika/provider-contract": "^0.0.18",
|
|
38
|
+
"@fabrika/proxy-contract": "^0.0.18"
|
|
39
39
|
}
|
|
40
40
|
}
|
package/src/source.ts
CHANGED
|
@@ -1030,6 +1030,21 @@ export function buildZeropsSourceCredentialStatusResponseV2(
|
|
|
1030
1030
|
return decodeZeropsSourceCredentialStatusResponseV2({ protocolVersion: ZEROPS_SOURCE_PROTOCOL_VERSION_V2, ...input })
|
|
1031
1031
|
}
|
|
1032
1032
|
|
|
1033
|
+
const WEBHOOK_PATH = '/webhooks/github'
|
|
1034
|
+
|
|
1035
|
+
/**
|
|
1036
|
+
* `/webhooks/github` is the legacy single-connection route; every keyed connection appends its own id
|
|
1037
|
+
* so one App's deliveries cannot be replayed against another. Requiring the bare path rejected every
|
|
1038
|
+
* multi-connection setup at `configureWebhook`.
|
|
1039
|
+
*/
|
|
1040
|
+
const isWebhookPath = (pathname: string): boolean => {
|
|
1041
|
+
if (pathname === WEBHOOK_PATH) return true
|
|
1042
|
+
if (!pathname.startsWith(`${WEBHOOK_PATH}/`)) return false
|
|
1043
|
+
const connectionId = pathname.slice(WEBHOOK_PATH.length + 1)
|
|
1044
|
+
// `ID_PATTERN` has no `%`, so a percent-escape in the path fails here rather than round-tripping.
|
|
1045
|
+
return connectionId.length > 0 && connectionId.length <= MAX_ID_LENGTH && ID_PATTERN.test(connectionId)
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1033
1048
|
const webhookUrl = (value: unknown, label: string): string => {
|
|
1034
1049
|
const candidate = boundedString(value, label, MAX_WEBHOOK_URL_LENGTH)
|
|
1035
1050
|
let parsed: URL
|
|
@@ -1040,7 +1055,7 @@ const webhookUrl = (value: unknown, label: string): string => {
|
|
|
1040
1055
|
}
|
|
1041
1056
|
if (
|
|
1042
1057
|
parsed.protocol !== 'https:' || parsed.port !== '' || parsed.username !== '' || parsed.password !== '' || parsed.search !== '' || parsed.hash !== ''
|
|
1043
|
-
|| parsed.pathname
|
|
1058
|
+
|| !isWebhookPath(parsed.pathname) || parsed.hostname === '' || candidate !== parsed.href
|
|
1044
1059
|
) throw new Error(`${label} must be an exact secure GitHub webhook URL`)
|
|
1045
1060
|
return candidate
|
|
1046
1061
|
}
|