@paklo/core 0.1.0 → 0.3.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/dist/{node/azure.d.ts → azure/index.d.ts} +32 -10
- package/dist/{node/azure.js → azure/index.js} +39 -19
- package/dist/azure/index.js.map +1 -0
- package/dist/dependabot/index.d.ts +3 -0
- package/dist/dependabot/index.js +6 -0
- package/dist/{node/dependabot-BteoKZVy.js → dependabot-B5pw4XDa.js} +11 -5
- package/dist/dependabot-B5pw4XDa.js.map +1 -0
- package/dist/{node/environment.d.ts → environment/index.d.ts} +1 -1
- package/dist/environment/index.js +3 -0
- package/dist/environment-DX5CD-dD.js.map +1 -0
- package/dist/{node/github.d.ts → github/index.d.ts} +1 -1
- package/dist/{node/github.js → github/index.js} +4 -4
- package/dist/github/index.js.map +1 -0
- package/dist/{node/http.d.ts → http/index.d.ts} +8 -8
- package/dist/{node/http.js → http/index.js} +2 -2
- package/dist/{node/http-BG_-s47I.js → http-Be3uWaqn.js} +1 -1
- package/dist/http-Be3uWaqn.js.map +1 -0
- package/dist/{node/index-DP9JfUPG.d.ts → index-Dr0PB1As.d.ts} +392 -69
- package/dist/{node/job-Crr4kh3e.js → job-CxYcRj_D.js} +55 -19
- package/dist/job-CxYcRj_D.js.map +1 -0
- package/dist/logger-bWnHxtAf.js.map +1 -0
- package/dist/{node/shared-data.d.ts → shared-data/index.d.ts} +1 -1
- package/dist/{node/shared-data.js → shared-data/index.js} +1 -1
- package/dist/shared-data/index.js.map +1 -0
- package/dist/{node/usage.d.ts → usage.d.ts} +12 -9
- package/dist/{node/usage.js → usage.js} +1 -1
- package/dist/usage.js.map +1 -0
- package/package.json +28 -33
- package/dist/browser/defineProperty-ie4tC-F5.js +0 -43
- package/dist/browser/environment-DinhzwQn.js +0 -139
- package/dist/browser/environment-DinhzwQn.js.map +0 -1
- package/dist/browser/environment.d.ts +0 -33
- package/dist/browser/environment.js +0 -3
- package/dist/browser/github.d.ts +0 -151
- package/dist/browser/github.js +0 -199
- package/dist/browser/github.js.map +0 -1
- package/dist/browser/http.d.ts +0 -121
- package/dist/browser/http.js +0 -248
- package/dist/browser/http.js.map +0 -1
- package/dist/browser/logger-B7HLv660.js +0 -31
- package/dist/browser/logger-B7HLv660.js.map +0 -1
- package/dist/browser/logger.js +0 -4
- package/dist/browser/shared-data.d.ts +0 -22
- package/dist/browser/shared-data.js +0 -23
- package/dist/browser/shared-data.js.map +0 -1
- package/dist/browser/usage.d.ts +0 -99
- package/dist/browser/usage.js +0 -383
- package/dist/browser/usage.js.map +0 -1
- package/dist/node/azure.js.map +0 -1
- package/dist/node/dependabot-BteoKZVy.js.map +0 -1
- package/dist/node/dependabot.d.ts +0 -3
- package/dist/node/dependabot.js +0 -6
- package/dist/node/environment-DX5CD-dD.js.map +0 -1
- package/dist/node/environment.js +0 -3
- package/dist/node/github.js.map +0 -1
- package/dist/node/http-BG_-s47I.js.map +0 -1
- package/dist/node/job-Crr4kh3e.js.map +0 -1
- package/dist/node/logger-bWnHxtAf.js.map +0 -1
- package/dist/node/logger.d.ts +0 -23
- package/dist/node/shared-data.js.map +0 -1
- package/dist/node/usage.js.map +0 -1
- /package/dist/{node/environment-DX5CD-dD.js → environment-DX5CD-dD.js} +0 -0
- /package/dist/{node/index-3wZw74Ah.d.ts → index-3wZw74Ah.d.ts} +0 -0
- /package/dist/{node/logger-bWnHxtAf.js → logger-bWnHxtAf.js} +0 -0
- /package/dist/{browser/logger.d.ts → logger.d.ts} +0 -0
- /package/dist/{node/logger.js → logger.js} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"environment-DinhzwQn.js","names":[],"sources":["../../src/environment/git.ts","../../src/environment/platform.ts","../../src/environment/site-url.ts","../../src/environment/index.ts"],"sourcesContent":["/**\n * Retrieves the name of the current Git branch from the environment variables or from Git itself.\n * The priority order for retrieving the branch name is as follows:\n * 1. `process.env.GITHUB_REF_NAME`\n * 2. `process.env.VERCEL_GIT_COMMIT_REF`\n * 3. `process.env.CF_PAGES_BRANCH`\n * 4. Retrieve the branch name from Git using the `getBranchFromGit` function.\n * @returns The name of the current Git branch, or undefined if it cannot be determined.\n */\nexport function getBranch(): string | undefined {\n // GITHUB_REF_NAME may change on every build and we do not want the turbo cache to be invalidated on every build\n return (\n process.env.GITHUB_REF_NAME ||\n process.env.VERCEL_GIT_COMMIT_REF ||\n process.env.CF_PAGES_BRANCH ||\n getBranchFromGit()\n );\n}\n\n/**\n * Retrieves the Git SHA (commit hash) from the environment variables or from Git itself.\n * The priority order for retrieving the Git SHA is as follows:\n * 1. `process.env.GITHUB_SHA`\n * 2. `process.env.VERCEL_GIT_COMMIT_SHA`\n * 3. `process.env.CF_PAGES_COMMIT_SHA`\n * 4. Retrieve the SHA from Git using the `getShaFromGit` function.\n * @returns The Git SHA (commit hash) if available, otherwise `undefined`.\n */\nexport function getSha(): string | undefined {\n // GITHUB_SHA changes on every build and we do not want the turbo cache to be invalidated on every build\n return (\n process?.env.GITHUB_SHA || process?.env.VERCEL_GIT_COMMIT_SHA || process?.env.CF_PAGES_COMMIT_SHA || getShaFromGit()\n );\n}\n\n/**\n * Retrieves the SHA (commit hash) from the Git repository.\n * @returns The SHA (commit hash) as a string, or undefined if it cannot be retrieved.\n */\nfunction getShaFromGit(): string | undefined {\n try {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n const { execSync } = require('node:child_process');\n return execSync('git rev-parse HEAD').toString().trim();\n }\n } catch {\n return undefined;\n }\n}\n\n/**\n * Retrieves the current branch name from Git.\n * @returns The name of the current branch, or 'unknown' if an error occurs.\n */\nfunction getBranchFromGit(): string | undefined {\n try {\n if (process.env.NEXT_RUNTIME === 'nodejs') {\n const { execSync } = require('node:child_process');\n return execSync('git rev-parse --abbrev-ref HEAD').toString().trim();\n }\n } catch {\n return undefined;\n }\n}\n","export type Platform =\n | 'azure_app_service'\n | 'azure_container_apps'\n | 'azure_static_web_app'\n | 'cloudflare_pages'\n | 'vercel'\n | undefined;\n\nexport function getPlatform(): Platform {\n if (process.env.CONTAINER_APP_ENV_DNS_SUFFIX) return 'azure_container_apps';\n // SWA is a special case of Azure App Service so we need to check it first\n else if (process.env.WEBSITE_STATICWEBAPP_RESOURCE_ID) return 'azure_static_web_app';\n else if (process.env.WEBSITE_HOSTNAME) return 'azure_app_service';\n else if (process.env.CF_PAGES_URL) return 'cloudflare_pages';\n else if (process.env.VERCEL_BRANCH_URL) return 'vercel';\n\n return undefined;\n}\n","interface SiteUrlOptions {\n /** Whether the current environment is development. */\n development: boolean;\n\n /** Whether the current branch is the main branch. */\n main: boolean;\n\n /** The default URL to use if no other URL is found. */\n defaultValue: string;\n}\n\n/**\n * Get the site URL based on the environment variables.\n * @param options - The options to use.\n * @returns The site URL.\n */\nexport function getSiteUrlCombined({ development, main, defaultValue }: SiteUrlOptions) {\n // if we are in development, use localhost\n if (development) return `http://localhost:${process.env.PORT || 3000}`;\n\n // if we are on the main branch, use the known URL\n if (main) return defaultValue;\n\n // if we are on Azure ContainerApps, use the provided URL\n let value = getSiteUrlForAca();\n if (value && value.length > 0) return value;\n\n // if we are on Azure App Service, use the provided URL\n value = getSiteUrlForAppService();\n if (value && value.length > 0) return value;\n\n // if we are on Azure Static WebApps, use the provided URL\n value = getSiteUrlForSwa();\n if (value && value.length > 0) return value;\n\n // if we are on Vercel, use the provided URL\n value = process.env.VERCEL_BRANCH_URL;\n if (value && value.length > 0) return `https://${value}`;\n\n // if we are on Cloudflare Pages, use the provided URL\n value = process.env.CF_PAGES_URL;\n if (value && value.length > 0) return value;\n\n return defaultValue; // fallback (edge cases)\n}\n\nexport function getSiteUrlForAca(): string | undefined {\n /*\n * Having looked at the available ENV variables when deployed, we can form the URL from\n * combinations of the following variables:\n * CONTAINER_APP_ENV_DNS_SUFFIX (e.g. \"jollyplant-9349db20.westeurope.azurecontainerapps.io\")\n * CONTAINER_APP_NAME (e.g. \"paklo-website\")\n */\n\n const suffix = process.env.CONTAINER_APP_ENV_DNS_SUFFIX;\n const name = process.env.CONTAINER_APP_NAME;\n if (!suffix || !name) return undefined;\n return `https://${name}.${suffix}`;\n}\n\nexport function getSiteUrlForAppService(): string | undefined {\n /*\n * Environment variables for Azure App Service are documented at\n * https://learn.microsoft.com/en-us/azure/app-service/reference-app-settings?tabs=kudu%2Cdotnet#app-environment\n *\n * WEBSITE_HOSTNAME (e.g. \"paklo-website.azurewebsites.net\")\n */\n\n const value = process.env.WEBSITE_HOSTNAME;\n return value ? `https://${value}` : undefined;\n}\n\nexport function getSiteUrlForSwa(): string | undefined {\n /*\n * Having looked at the available ENV variables when deployed to both production and preview environments,\n * only the WEBSITE_AUTH_V2_CONFIG_JSON has values we can use for this.\n *\n * Sample value for production:\n * {\\\"platform\\\":{\\\"enabled\\\":true},\\\"globalValidation\\\":{\\\"excludedPaths\\\":[\\\"/.swa/health.html\\\"]},\\\"identityProviders\\\":{\\\"azureStaticWebApps\\\":{\\\"registration\\\":{\\\"clientId\\\":\\\"black-bush-020715303.5.azurestaticapps.net\\\"}}},\\\"legacyProperties\\\":{\\\"configVersion\\\":\\\"v2\\\",\\\"legacyVersion\\\":\\\"V2\\\"}}\n *\n * Sample value for preview environment (named 331):\n * {\\\"platform\\\":{\\\"enabled\\\":true},\\\"globalValidation\\\":{\\\"excludedPaths\\\":[\\\"/.swa/health.html\\\"]},\\\"identityProviders\\\":{\\\"azureStaticWebApps\\\":{\\\"registration\\\":{\\\"clientId\\\":\\\"black-bush-020715303-331.westeurope.5.azurestaticapps.net\\\"}}},\\\"legacyProperties\\\":{\\\"configVersion\\\":\\\"v2\\\",\\\"legacyVersion\\\":\\\"V2\\\"}}\n *\n * The part we are interested in is the clientId value. We can extract this value and use it as the domain to form the siteUrl.\n */\n\n const config = process.env.WEBSITE_AUTH_V2_CONFIG_JSON;\n const clientIdMatch = config?.match(/\"clientId\":\"([^\"]+)\"/);\n return clientIdMatch ? `https://${clientIdMatch[1]}` : undefined;\n}\n","import { getBranch, getSha } from './git';\nimport { getPlatform, type Platform } from './platform';\nimport { getSiteUrlCombined } from './site-url';\n\nexport type Environment = {\n /** The current environment. */\n name?: 'development' | 'production' | 'test';\n\n /** Whether the current environment is development. */\n development: boolean;\n\n /** Whether the current environment is production. */\n production: boolean;\n\n /** Whether the current environment is test. */\n test: boolean;\n\n /** The current platform. */\n platform: Platform;\n\n /** The current commit SHA. */\n sha?: string;\n\n /** The current branch name. */\n branch?: string;\n\n /** Whether the current branch is the main branch. */\n main: boolean;\n};\n\nfunction getEnvironment(): Environment {\n const env = process.env.NODE_ENV as Environment['name'];\n const branch = getBranch();\n const sha = getSha();\n const platform = getPlatform();\n\n return {\n name: env,\n development: env === 'development',\n production: env === 'production',\n test: env === 'test',\n platform,\n sha,\n branch,\n main: branch === 'main',\n };\n}\n\nexport const environment = getEnvironment();\n\nexport interface SiteUrlOptions {\n /** The default URL to use if no other URL is found. */\n defaultValue: string;\n}\n\nexport function getSiteUrl({ defaultValue }: SiteUrlOptions): string {\n const { development, main } = environment;\n return getSiteUrlCombined({ development, main, defaultValue: defaultValue });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,SAAgB,YAAgC;AAE9C,QACE,QAAQ,IAAI,mBACZ,QAAQ,IAAI,yBACZ,QAAQ,IAAI,mBACZ,kBAAkB;;;;;;;;;;;AAatB,SAAgB,SAA6B;AAE3C,QACE,SAAS,IAAI,cAAc,SAAS,IAAI,yBAAyB,SAAS,IAAI,uBAAuB,eAAe;;;;;;AAQxH,SAAS,gBAAoC;AAC3C,KAAI;AACF,MAAI,QAAQ,IAAI,iBAAiB,UAAU;GACzC,MAAM,EAAE,uBAAqB,qBAAqB;AAClD,UAAO,SAAS,qBAAqB,CAAC,UAAU,CAAC,MAAM;;SAEnD;AACN;;;;;;;AAQJ,SAAS,mBAAuC;AAC9C,KAAI;AACF,MAAI,QAAQ,IAAI,iBAAiB,UAAU;GACzC,MAAM,EAAE,uBAAqB,qBAAqB;AAClD,UAAO,SAAS,kCAAkC,CAAC,UAAU,CAAC,M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aAAa,QAAQ;EACrB,YAAY,QAAQ;EACpB,MAAM,QAAQ;EACd;EACA;EACA;EACA,MAAM,WAAW;EAClB;;AAGH,MAAa,cAAc,gBAAgB;AAO3C,SAAgB,WAAW,EAAE,gBAAwC;CACnE,MAAM,EAAE,aAAa,SAAS;AAC9B,QAAO,mBAAmB;EAAE;EAAa;EAAoB;EAAc,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
//#region src/environment/platform.d.ts
|
|
2
|
-
type Platform = 'azure_app_service' | 'azure_container_apps' | 'azure_static_web_app' | 'cloudflare_pages' | 'vercel' | undefined;
|
|
3
|
-
//#endregion
|
|
4
|
-
//#region src/environment/index.d.ts
|
|
5
|
-
type Environment = {
|
|
6
|
-
/** The current environment. */
|
|
7
|
-
name?: 'development' | 'production' | 'test';
|
|
8
|
-
/** Whether the current environment is development. */
|
|
9
|
-
development: boolean;
|
|
10
|
-
/** Whether the current environment is production. */
|
|
11
|
-
production: boolean;
|
|
12
|
-
/** Whether the current environment is test. */
|
|
13
|
-
test: boolean;
|
|
14
|
-
/** The current platform. */
|
|
15
|
-
platform: Platform;
|
|
16
|
-
/** The current commit SHA. */
|
|
17
|
-
sha?: string;
|
|
18
|
-
/** The current branch name. */
|
|
19
|
-
branch?: string;
|
|
20
|
-
/** Whether the current branch is the main branch. */
|
|
21
|
-
main: boolean;
|
|
22
|
-
};
|
|
23
|
-
declare const environment: Environment;
|
|
24
|
-
interface SiteUrlOptions {
|
|
25
|
-
/** The default URL to use if no other URL is found. */
|
|
26
|
-
defaultValue: string;
|
|
27
|
-
}
|
|
28
|
-
declare function getSiteUrl({
|
|
29
|
-
defaultValue
|
|
30
|
-
}: SiteUrlOptions): string;
|
|
31
|
-
//#endregion
|
|
32
|
-
export { Environment, SiteUrlOptions, environment, getSiteUrl };
|
|
33
|
-
//# sourceMappingURL=environment.d.ts.map
|
package/dist/browser/github.d.ts
DELETED
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { z } from "zod/v4";
|
|
2
|
-
|
|
3
|
-
//#region src/github/ghsa.d.ts
|
|
4
|
-
declare const PackageEcosystemSchema: z.ZodEnum<{
|
|
5
|
-
COMPOSER: "COMPOSER";
|
|
6
|
-
ERLANG: "ERLANG";
|
|
7
|
-
GO: "GO";
|
|
8
|
-
ACTIONS: "ACTIONS";
|
|
9
|
-
MAVEN: "MAVEN";
|
|
10
|
-
NPM: "NPM";
|
|
11
|
-
NUGET: "NUGET";
|
|
12
|
-
PIP: "PIP";
|
|
13
|
-
PUB: "PUB";
|
|
14
|
-
RUBYGEMS: "RUBYGEMS";
|
|
15
|
-
RUST: "RUST";
|
|
16
|
-
SWIFT: "SWIFT";
|
|
17
|
-
}>;
|
|
18
|
-
type PackageEcosystem = z.infer<typeof PackageEcosystemSchema>;
|
|
19
|
-
declare const PackageSchema: z.ZodObject<{
|
|
20
|
-
name: z.ZodString;
|
|
21
|
-
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
22
|
-
}, z.core.$strip>;
|
|
23
|
-
type Package = z.infer<typeof PackageSchema>;
|
|
24
|
-
declare const SecurityAdvisoryIdentifierSchema: z.ZodEnum<{
|
|
25
|
-
CVE: "CVE";
|
|
26
|
-
GHSA: "GHSA";
|
|
27
|
-
}>;
|
|
28
|
-
type SecurityAdvisoryIdentifierType = z.infer<typeof SecurityAdvisoryIdentifierSchema>;
|
|
29
|
-
declare const SecurityAdvisorySeveritySchema: z.ZodEnum<{
|
|
30
|
-
LOW: "LOW";
|
|
31
|
-
MODERATE: "MODERATE";
|
|
32
|
-
HIGH: "HIGH";
|
|
33
|
-
CRITICAL: "CRITICAL";
|
|
34
|
-
}>;
|
|
35
|
-
type SecurityAdvisorySeverity = z.infer<typeof SecurityAdvisorySeveritySchema>;
|
|
36
|
-
declare const SecurityAdvisorySchema: z.ZodObject<{
|
|
37
|
-
identifiers: z.ZodArray<z.ZodObject<{
|
|
38
|
-
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
39
|
-
CVE: "CVE";
|
|
40
|
-
GHSA: "GHSA";
|
|
41
|
-
}>, z.ZodString]>;
|
|
42
|
-
value: z.ZodString;
|
|
43
|
-
}, z.core.$strip>>;
|
|
44
|
-
severity: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
45
|
-
LOW: "LOW";
|
|
46
|
-
MODERATE: "MODERATE";
|
|
47
|
-
HIGH: "HIGH";
|
|
48
|
-
CRITICAL: "CRITICAL";
|
|
49
|
-
}>>>;
|
|
50
|
-
summary: z.ZodString;
|
|
51
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
52
|
-
references: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
53
|
-
url: z.ZodString;
|
|
54
|
-
}, z.core.$strip>>>>;
|
|
55
|
-
cvss: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
56
|
-
score: z.ZodNumber;
|
|
57
|
-
vectorString: z.ZodString;
|
|
58
|
-
}, z.core.$strip>>>;
|
|
59
|
-
epss: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
60
|
-
percentage: z.ZodNumber;
|
|
61
|
-
percentile: z.ZodNumber;
|
|
62
|
-
}, z.core.$strip>>>;
|
|
63
|
-
cwes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
64
|
-
cweId: z.ZodString;
|
|
65
|
-
name: z.ZodString;
|
|
66
|
-
description: z.ZodString;
|
|
67
|
-
}, z.core.$strip>>>>;
|
|
68
|
-
publishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
69
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
70
|
-
withdrawnAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
71
|
-
permalink: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
72
|
-
}, z.core.$strip>;
|
|
73
|
-
type SecurityAdvisory = z.infer<typeof SecurityAdvisorySchema>;
|
|
74
|
-
declare const FirstPatchedVersionSchema: z.ZodObject<{
|
|
75
|
-
identifier: z.ZodString;
|
|
76
|
-
}, z.core.$strip>;
|
|
77
|
-
type FirstPatchedVersion = z.infer<typeof FirstPatchedVersionSchema>;
|
|
78
|
-
declare const SecurityVulnerabilitySchema: z.ZodObject<{
|
|
79
|
-
package: z.ZodObject<{
|
|
80
|
-
name: z.ZodString;
|
|
81
|
-
version: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
82
|
-
}, z.core.$strip>;
|
|
83
|
-
advisory: z.ZodObject<{
|
|
84
|
-
identifiers: z.ZodArray<z.ZodObject<{
|
|
85
|
-
type: z.ZodUnion<readonly [z.ZodEnum<{
|
|
86
|
-
CVE: "CVE";
|
|
87
|
-
GHSA: "GHSA";
|
|
88
|
-
}>, z.ZodString]>;
|
|
89
|
-
value: z.ZodString;
|
|
90
|
-
}, z.core.$strip>>;
|
|
91
|
-
severity: z.ZodOptional<z.ZodNullable<z.ZodEnum<{
|
|
92
|
-
LOW: "LOW";
|
|
93
|
-
MODERATE: "MODERATE";
|
|
94
|
-
HIGH: "HIGH";
|
|
95
|
-
CRITICAL: "CRITICAL";
|
|
96
|
-
}>>>;
|
|
97
|
-
summary: z.ZodString;
|
|
98
|
-
description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
99
|
-
references: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
100
|
-
url: z.ZodString;
|
|
101
|
-
}, z.core.$strip>>>>;
|
|
102
|
-
cvss: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
103
|
-
score: z.ZodNumber;
|
|
104
|
-
vectorString: z.ZodString;
|
|
105
|
-
}, z.core.$strip>>>;
|
|
106
|
-
epss: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
107
|
-
percentage: z.ZodNumber;
|
|
108
|
-
percentile: z.ZodNumber;
|
|
109
|
-
}, z.core.$strip>>>;
|
|
110
|
-
cwes: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodObject<{
|
|
111
|
-
cweId: z.ZodString;
|
|
112
|
-
name: z.ZodString;
|
|
113
|
-
description: z.ZodString;
|
|
114
|
-
}, z.core.$strip>>>>;
|
|
115
|
-
publishedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
116
|
-
updatedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
117
|
-
withdrawnAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
118
|
-
permalink: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
119
|
-
}, z.core.$strip>;
|
|
120
|
-
vulnerableVersionRange: z.ZodString;
|
|
121
|
-
firstPatchedVersion: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
122
|
-
identifier: z.ZodString;
|
|
123
|
-
}, z.core.$strip>>>;
|
|
124
|
-
}, z.core.$strip>;
|
|
125
|
-
type SecurityVulnerability = z.infer<typeof SecurityVulnerabilitySchema>;
|
|
126
|
-
declare function getGhsaPackageEcosystemFromDependabotPackageManager(dependabotPackageManager: string): PackageEcosystem;
|
|
127
|
-
/**
|
|
128
|
-
* GitHub GraphQL client
|
|
129
|
-
*/
|
|
130
|
-
declare class GitHubGraphClient {
|
|
131
|
-
private readonly accessToken;
|
|
132
|
-
constructor(accessToken: string);
|
|
133
|
-
/**
|
|
134
|
-
* Get the list of security vulnerabilities for a given package ecosystem and list of packages
|
|
135
|
-
* @param packageEcosystem
|
|
136
|
-
* @param packages
|
|
137
|
-
*/
|
|
138
|
-
getSecurityVulnerabilitiesAsync(packageEcosystem: PackageEcosystem, packages: Package[]): Promise<SecurityVulnerability[]>;
|
|
139
|
-
/**
|
|
140
|
-
* Batch requests in parallel to speed up the process when we are forced to do a N+1 query
|
|
141
|
-
* @param batchSize
|
|
142
|
-
* @param items
|
|
143
|
-
* @param action
|
|
144
|
-
* @returns
|
|
145
|
-
*/
|
|
146
|
-
private batchGraphQueryAsync;
|
|
147
|
-
}
|
|
148
|
-
declare function filterVulnerabilities(securityVulnerabilities: SecurityVulnerability[]): SecurityVulnerability[];
|
|
149
|
-
//#endregion
|
|
150
|
-
export { FirstPatchedVersion, GitHubGraphClient, Package, PackageEcosystem, PackageEcosystemSchema, PackageSchema, SecurityAdvisory, SecurityAdvisoryIdentifierSchema, SecurityAdvisoryIdentifierType, SecurityAdvisorySchema, SecurityAdvisorySeverity, SecurityAdvisorySeveritySchema, SecurityVulnerability, SecurityVulnerabilitySchema, filterVulnerabilities, getGhsaPackageEcosystemFromDependabotPackageManager };
|
|
151
|
-
//# sourceMappingURL=github.d.ts.map
|
package/dist/browser/github.js
DELETED
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import "./environment-DinhzwQn.js";
|
|
2
|
-
import { n as logger } from "./logger-B7HLv660.js";
|
|
3
|
-
import { t as _defineProperty } from "./defineProperty-ie4tC-F5.js";
|
|
4
|
-
import * as semver from "semver";
|
|
5
|
-
import { z } from "zod/v4";
|
|
6
|
-
|
|
7
|
-
//#region src/github/ghsa.ts
|
|
8
|
-
const GHSA_GRAPHQL_API = "https://api.github.com/graphql";
|
|
9
|
-
const GHSA_SECURITY_VULNERABILITIES_QUERY = `
|
|
10
|
-
query($ecosystem: SecurityAdvisoryEcosystem, $package: String) {
|
|
11
|
-
securityVulnerabilities(first: 100, ecosystem: $ecosystem, package: $package) {
|
|
12
|
-
nodes {
|
|
13
|
-
advisory {
|
|
14
|
-
identifiers {
|
|
15
|
-
type,
|
|
16
|
-
value
|
|
17
|
-
},
|
|
18
|
-
severity,
|
|
19
|
-
summary,
|
|
20
|
-
description,
|
|
21
|
-
references {
|
|
22
|
-
url
|
|
23
|
-
}
|
|
24
|
-
cvss {
|
|
25
|
-
score
|
|
26
|
-
vectorString
|
|
27
|
-
}
|
|
28
|
-
epss {
|
|
29
|
-
percentage
|
|
30
|
-
percentile
|
|
31
|
-
}
|
|
32
|
-
cwes (first: 100) {
|
|
33
|
-
nodes {
|
|
34
|
-
cweId
|
|
35
|
-
name
|
|
36
|
-
description
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
publishedAt
|
|
40
|
-
updatedAt
|
|
41
|
-
withdrawnAt
|
|
42
|
-
permalink
|
|
43
|
-
}
|
|
44
|
-
vulnerableVersionRange
|
|
45
|
-
firstPatchedVersion {
|
|
46
|
-
identifier
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
`;
|
|
52
|
-
const PackageEcosystemSchema = z.enum([
|
|
53
|
-
"COMPOSER",
|
|
54
|
-
"ERLANG",
|
|
55
|
-
"GO",
|
|
56
|
-
"ACTIONS",
|
|
57
|
-
"MAVEN",
|
|
58
|
-
"NPM",
|
|
59
|
-
"NUGET",
|
|
60
|
-
"PIP",
|
|
61
|
-
"PUB",
|
|
62
|
-
"RUBYGEMS",
|
|
63
|
-
"RUST",
|
|
64
|
-
"SWIFT"
|
|
65
|
-
]);
|
|
66
|
-
const PackageSchema = z.object({
|
|
67
|
-
name: z.string(),
|
|
68
|
-
version: z.string().nullish()
|
|
69
|
-
});
|
|
70
|
-
const SecurityAdvisoryIdentifierSchema = z.enum(["CVE", "GHSA"]);
|
|
71
|
-
const SecurityAdvisorySeveritySchema = z.enum([
|
|
72
|
-
"LOW",
|
|
73
|
-
"MODERATE",
|
|
74
|
-
"HIGH",
|
|
75
|
-
"CRITICAL"
|
|
76
|
-
]);
|
|
77
|
-
const SecurityAdvisorySchema = z.object({
|
|
78
|
-
identifiers: z.array(z.object({
|
|
79
|
-
type: z.union([SecurityAdvisoryIdentifierSchema, z.string()]),
|
|
80
|
-
value: z.string()
|
|
81
|
-
})),
|
|
82
|
-
severity: SecurityAdvisorySeveritySchema.nullish(),
|
|
83
|
-
summary: z.string(),
|
|
84
|
-
description: z.string().nullish(),
|
|
85
|
-
references: z.array(z.object({ url: z.string() })).nullish(),
|
|
86
|
-
cvss: z.object({
|
|
87
|
-
score: z.number(),
|
|
88
|
-
vectorString: z.string()
|
|
89
|
-
}).nullish(),
|
|
90
|
-
epss: z.object({
|
|
91
|
-
percentage: z.number(),
|
|
92
|
-
percentile: z.number()
|
|
93
|
-
}).nullish(),
|
|
94
|
-
cwes: z.array(z.object({
|
|
95
|
-
cweId: z.string(),
|
|
96
|
-
name: z.string(),
|
|
97
|
-
description: z.string()
|
|
98
|
-
})).nullish(),
|
|
99
|
-
publishedAt: z.string().nullish(),
|
|
100
|
-
updatedAt: z.string().nullish(),
|
|
101
|
-
withdrawnAt: z.string().nullish(),
|
|
102
|
-
permalink: z.string().nullish()
|
|
103
|
-
});
|
|
104
|
-
const FirstPatchedVersionSchema = z.object({ identifier: z.string() });
|
|
105
|
-
const SecurityVulnerabilitySchema = z.object({
|
|
106
|
-
package: PackageSchema,
|
|
107
|
-
advisory: SecurityAdvisorySchema,
|
|
108
|
-
vulnerableVersionRange: z.string(),
|
|
109
|
-
firstPatchedVersion: FirstPatchedVersionSchema.nullish()
|
|
110
|
-
});
|
|
111
|
-
function getGhsaPackageEcosystemFromDependabotPackageManager(dependabotPackageManager) {
|
|
112
|
-
switch (dependabotPackageManager) {
|
|
113
|
-
case "composer": return "COMPOSER";
|
|
114
|
-
case "elm": return "ERLANG";
|
|
115
|
-
case "github_actions": return "ACTIONS";
|
|
116
|
-
case "go_modules": return "GO";
|
|
117
|
-
case "maven": return "MAVEN";
|
|
118
|
-
case "npm_and_yarn": return "NPM";
|
|
119
|
-
case "nuget": return "NUGET";
|
|
120
|
-
case "pip": return "PIP";
|
|
121
|
-
case "pub": return "PUB";
|
|
122
|
-
case "bundler": return "RUBYGEMS";
|
|
123
|
-
case "cargo": return "RUST";
|
|
124
|
-
case "swift": return "SWIFT";
|
|
125
|
-
default: throw new Error(`Unknown dependabot package manager: ${dependabotPackageManager}`);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* GitHub GraphQL client
|
|
130
|
-
*/
|
|
131
|
-
var GitHubGraphClient = class {
|
|
132
|
-
constructor(accessToken) {
|
|
133
|
-
_defineProperty(this, "accessToken", void 0);
|
|
134
|
-
this.accessToken = accessToken;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Get the list of security vulnerabilities for a given package ecosystem and list of packages
|
|
138
|
-
* @param packageEcosystem
|
|
139
|
-
* @param packages
|
|
140
|
-
*/
|
|
141
|
-
async getSecurityVulnerabilitiesAsync(packageEcosystem, packages) {
|
|
142
|
-
return await this.batchGraphQueryAsync(100, packages, async (pkg) => {
|
|
143
|
-
const variables = {
|
|
144
|
-
ecosystem: packageEcosystem,
|
|
145
|
-
package: pkg.name
|
|
146
|
-
};
|
|
147
|
-
const response = await fetch(GHSA_GRAPHQL_API, {
|
|
148
|
-
method: "POST",
|
|
149
|
-
headers: {
|
|
150
|
-
Authorization: `Bearer ${this.accessToken}`,
|
|
151
|
-
"Content-Type": "application/json"
|
|
152
|
-
},
|
|
153
|
-
body: JSON.stringify({
|
|
154
|
-
query: GHSA_SECURITY_VULNERABILITIES_QUERY,
|
|
155
|
-
variables
|
|
156
|
-
})
|
|
157
|
-
});
|
|
158
|
-
if (!response.ok) throw new Error(`GHSA GraphQL request failed with response: ${response.status} ${response.statusText}`);
|
|
159
|
-
const responseData = await response.json();
|
|
160
|
-
const errors = responseData?.errors;
|
|
161
|
-
if (errors) throw new Error(`GHSA GraphQL request failed with errors: ${JSON.stringify(errors)}`);
|
|
162
|
-
return (responseData?.data?.securityVulnerabilities?.nodes)?.filter((v) => v?.advisory)?.map((v) => ({
|
|
163
|
-
package: pkg,
|
|
164
|
-
...v
|
|
165
|
-
}));
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Batch requests in parallel to speed up the process when we are forced to do a N+1 query
|
|
170
|
-
* @param batchSize
|
|
171
|
-
* @param items
|
|
172
|
-
* @param action
|
|
173
|
-
* @returns
|
|
174
|
-
*/
|
|
175
|
-
async batchGraphQueryAsync(batchSize, items, action) {
|
|
176
|
-
const results = [];
|
|
177
|
-
for (let i = 0; i < items.length; i += batchSize) {
|
|
178
|
-
const batch = items.slice(i, i + batchSize);
|
|
179
|
-
if (batch?.length) try {
|
|
180
|
-
const batchResults = await Promise.all(batch.map(action));
|
|
181
|
-
if (batchResults?.length) results.push(...batchResults.flat());
|
|
182
|
-
} catch (error) {
|
|
183
|
-
logger.warn(`Request batch [${i}-${i + batchSize}] failed; The data may be incomplete. ${error}`);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return results;
|
|
187
|
-
}
|
|
188
|
-
};
|
|
189
|
-
function filterVulnerabilities(securityVulnerabilities) {
|
|
190
|
-
return securityVulnerabilities.filter((v) => !v.advisory.withdrawnAt).filter((v) => {
|
|
191
|
-
const pkg = v.package;
|
|
192
|
-
if (!pkg || !pkg.version || !v.vulnerableVersionRange) return false;
|
|
193
|
-
return v.vulnerableVersionRange.split(",").map((v$1) => v$1.trim()).every((r) => pkg.version && semver.satisfies(pkg.version, r));
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
//#endregion
|
|
198
|
-
export { GitHubGraphClient, PackageEcosystemSchema, PackageSchema, SecurityAdvisoryIdentifierSchema, SecurityAdvisorySchema, SecurityAdvisorySeveritySchema, SecurityVulnerabilitySchema, filterVulnerabilities, getGhsaPackageEcosystemFromDependabotPackageManager };
|
|
199
|
-
//# sourceMappingURL=github.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"github.js","names":["results: T2[]","v"],"sources":["../../src/github/ghsa.ts"],"sourcesContent":["import * as semver from 'semver';\nimport { z } from 'zod/v4';\n\nimport { logger } from '@/logger';\n\n// we use nullish() because it does optional() and allows the value to be set to null\n\nconst GHSA_GRAPHQL_API = 'https://api.github.com/graphql';\n\nconst GHSA_SECURITY_VULNERABILITIES_QUERY = `\n query($ecosystem: SecurityAdvisoryEcosystem, $package: String) {\n securityVulnerabilities(first: 100, ecosystem: $ecosystem, package: $package) {\n nodes {\n advisory {\n identifiers {\n type,\n value\n },\n severity,\n summary,\n description,\n references {\n url\n }\n cvss {\n score\n vectorString\n }\n epss {\n percentage\n percentile\n }\n cwes (first: 100) {\n nodes {\n cweId\n name\n description\n }\n }\n publishedAt\n updatedAt\n withdrawnAt\n permalink\n }\n vulnerableVersionRange\n firstPatchedVersion {\n identifier\n }\n }\n }\n }\n`;\n\nexport const PackageEcosystemSchema = z.enum([\n 'COMPOSER',\n 'ERLANG',\n 'GO',\n 'ACTIONS',\n 'MAVEN',\n 'NPM',\n 'NUGET',\n 'PIP',\n 'PUB',\n 'RUBYGEMS',\n 'RUST',\n 'SWIFT',\n]);\nexport type PackageEcosystem = z.infer<typeof PackageEcosystemSchema>;\n\nexport const PackageSchema = z.object({\n name: z.string(),\n version: z.string().nullish(),\n});\nexport type Package = z.infer<typeof PackageSchema>;\n\nexport const SecurityAdvisoryIdentifierSchema = z.enum(['CVE', 'GHSA']);\nexport type SecurityAdvisoryIdentifierType = z.infer<typeof SecurityAdvisoryIdentifierSchema>;\n\nexport const SecurityAdvisorySeveritySchema = z.enum(['LOW', 'MODERATE', 'HIGH', 'CRITICAL']);\nexport type SecurityAdvisorySeverity = z.infer<typeof SecurityAdvisorySeveritySchema>;\n\nexport const SecurityAdvisorySchema = z.object({\n identifiers: z.array(\n z.object({\n type: z.union([SecurityAdvisoryIdentifierSchema, z.string()]),\n value: z.string(),\n }),\n ),\n severity: SecurityAdvisorySeveritySchema.nullish(),\n summary: z.string(),\n description: z.string().nullish(),\n references: z.array(z.object({ url: z.string() })).nullish(),\n cvss: z\n .object({\n score: z.number(),\n vectorString: z.string(),\n })\n .nullish(),\n epss: z\n .object({\n percentage: z.number(),\n percentile: z.number(),\n })\n .nullish(),\n cwes: z\n .array(\n z.object({\n cweId: z.string(),\n name: z.string(),\n description: z.string(),\n }),\n )\n .nullish(),\n publishedAt: z.string().nullish(),\n updatedAt: z.string().nullish(),\n withdrawnAt: z.string().nullish(),\n permalink: z.string().nullish(),\n});\nexport type SecurityAdvisory = z.infer<typeof SecurityAdvisorySchema>;\n\nconst FirstPatchedVersionSchema = z.object({ identifier: z.string() });\nexport type FirstPatchedVersion = z.infer<typeof FirstPatchedVersionSchema>;\n\nexport const SecurityVulnerabilitySchema = z.object({\n package: PackageSchema,\n advisory: SecurityAdvisorySchema,\n vulnerableVersionRange: z.string(),\n firstPatchedVersion: FirstPatchedVersionSchema.nullish(),\n});\nexport type SecurityVulnerability = z.infer<typeof SecurityVulnerabilitySchema>;\n\nexport function getGhsaPackageEcosystemFromDependabotPackageManager(\n dependabotPackageManager: string,\n): PackageEcosystem {\n switch (dependabotPackageManager) {\n case 'composer':\n return 'COMPOSER';\n case 'elm':\n return 'ERLANG';\n case 'github_actions':\n return 'ACTIONS';\n case 'go_modules':\n return 'GO';\n case 'maven':\n return 'MAVEN';\n case 'npm_and_yarn':\n return 'NPM';\n case 'nuget':\n return 'NUGET';\n case 'pip':\n return 'PIP';\n case 'pub':\n return 'PUB';\n case 'bundler':\n return 'RUBYGEMS';\n case 'cargo':\n return 'RUST';\n case 'swift':\n return 'SWIFT';\n default:\n throw new Error(`Unknown dependabot package manager: ${dependabotPackageManager}`);\n }\n}\n\n/**\n * GitHub GraphQL client\n */\nexport class GitHubGraphClient {\n private readonly accessToken: string;\n\n constructor(accessToken: string) {\n this.accessToken = accessToken;\n }\n\n /**\n * Get the list of security vulnerabilities for a given package ecosystem and list of packages\n * @param packageEcosystem\n * @param packages\n */\n public async getSecurityVulnerabilitiesAsync(\n packageEcosystem: PackageEcosystem,\n packages: Package[],\n ): Promise<SecurityVulnerability[]> {\n // GitHub API doesn't support querying multiple package at once, so we need to make a request for each package individually.\n // To speed up the process, we can make the requests in parallel, 100 at a time. We batch the requests to avoid hitting the rate limit too quickly.\n // https://docs.github.com/en/graphql/overview/rate-limits-and-node-limits-for-the-graphql-api\n const securityVulnerabilities = await this.batchGraphQueryAsync<Package, SecurityVulnerability>(\n 100,\n packages,\n async (pkg) => {\n const variables = {\n ecosystem: packageEcosystem,\n package: pkg.name,\n };\n const response = await fetch(GHSA_GRAPHQL_API, {\n method: 'POST',\n headers: {\n Authorization: `Bearer ${this.accessToken}`,\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n query: GHSA_SECURITY_VULNERABILITIES_QUERY,\n variables: variables,\n }),\n });\n if (!response.ok) {\n throw new Error(`GHSA GraphQL request failed with response: ${response.status} ${response.statusText}`);\n }\n const responseData = await response.json();\n const errors = responseData?.errors;\n if (errors) {\n throw new Error(`GHSA GraphQL request failed with errors: ${JSON.stringify(errors)}`);\n }\n\n const vulnerabilities = responseData?.data?.securityVulnerabilities?.nodes;\n // biome-ignore lint/suspicious/noExplicitAny: generic\n return vulnerabilities?.filter((v: any) => v?.advisory)?.map((v: any) => ({ package: pkg, ...v }));\n },\n );\n\n return securityVulnerabilities;\n }\n\n /**\n * Batch requests in parallel to speed up the process when we are forced to do a N+1 query\n * @param batchSize\n * @param items\n * @param action\n * @returns\n */\n private async batchGraphQueryAsync<T1, T2>(batchSize: number, items: T1[], action: (item: T1) => Promise<T2[]>) {\n const results: T2[] = [];\n for (let i = 0; i < items.length; i += batchSize) {\n const batch = items.slice(i, i + batchSize);\n if (batch?.length) {\n try {\n const batchResults = await Promise.all(batch.map(action));\n if (batchResults?.length) {\n results.push(...batchResults.flat());\n }\n } catch (error) {\n logger.warn(`Request batch [${i}-${i + batchSize}] failed; The data may be incomplete. ${error}`);\n }\n }\n }\n return results;\n }\n}\n\nexport function filterVulnerabilities(securityVulnerabilities: SecurityVulnerability[]): SecurityVulnerability[] {\n // Filter out vulnerabilities that have been withdrawn or that are not relevant the current version of the package\n const affectedVulnerabilities = securityVulnerabilities\n .filter((v) => !v.advisory.withdrawnAt)\n .filter((v) => {\n const pkg = v.package;\n if (!pkg || !pkg.version || !v.vulnerableVersionRange) {\n return false;\n }\n\n /**\n * The vulnerable version range follows a basic syntax with a few forms:\n * `= 0.2.0` denotes a single vulnerable version\n * `<= 1.0.8` denotes a version range up to and including the specified version\n * `< 0.1.11` denotes a version range up to, but excluding, the specified version\n * `>= 4.3.0, < 4.3.5` denotes a version range with a known minimum and maximum version\n * `>= 0.0.1` denotes a version range with a known minimum, but no known maximum\n */\n const versionRangeRequirements = v.vulnerableVersionRange.split(',').map((v) => v.trim());\n return versionRangeRequirements.every((r) => pkg.version && semver.satisfies(pkg.version, r));\n });\n return affectedVulnerabilities;\n}\n"],"mappings":";;;;;;;AAOA,MAAM,mBAAmB;AAEzB,MAAM,sCAAsC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4C5C,MAAa,yBAAyB,EAAE,KAAK;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD,CAAC;AAGF,MAAa,gBAAgB,EAAE,OAAO;CACpC,MAAM,EAAE,QAAQ;CAChB,SAAS,EAAE,QAAQ,CAAC,SAAS;CAC9B,CAAC;AAGF,MAAa,mCAAmC,EAAE,KAAK,CAAC,OAAO,OAAO,CAAC;AAGvE,MAAa,iCAAiC,EAAE,KAAK;CAAC;CAAO;CAAY;CAAQ;CAAW,CAAC;AAG7F,MAAa,yBAAyB,EAAE,OAAO;CAC7C,aAAa,EAAE,MACb,EAAE,OAAO;EACP,MAAM,EAAE,MAAM,CAAC,kCAAkC,EAAE,QAAQ,CAAC,CAAC;EAC7D,OAAO,EAAE,QAAQ;EAClB,CAAC,CACH;CACD,UAAU,+BAA+B,SAAS;CAClD,SAAS,EAAE,QAAQ;CACnB,aAAa,EAAE,QAAQ,CAAC,SAAS;CACjC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,SAAS;CAC5D,MAAM,EACH,OAAO;EACN,OAAO,EAAE,QAAQ;EACjB,cAAc,EAAE,QAAQ;EACzB,CAAC,CACD,SAAS;CACZ,MAAM,EACH,OAAO;EACN,YAAY,EAAE,QAAQ;EACtB,YAAY,EAAE,QAAQ;EACvB,CAAC,CACD,SAAS;CACZ,MAAM,EACH,MACC,EAAE,OAAO;EACP,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|
4
|
-
declare const HEADER_NAME_CONTENT_DISPOSITION = "Content-Disposition";
|
|
5
|
-
declare const HEADER_NAME_CONTENT_TYPE = "Content-Type";
|
|
6
|
-
declare const HEADER_NAME_ACCEPT = "Accept";
|
|
7
|
-
declare const HEADER_NAME_USER_AGENT = "User-Agent";
|
|
8
|
-
declare const HEADER_NAME_AUTHORIZATION = "Authorization";
|
|
9
|
-
//#endregion
|
|
10
|
-
//#region src/http/multipart.d.ts
|
|
11
|
-
declare class MultipartFormDataBody {
|
|
12
|
-
private type;
|
|
13
|
-
private boundary;
|
|
14
|
-
private parts;
|
|
15
|
-
encode(): Promise<Buffer>;
|
|
16
|
-
getBoundary(): string;
|
|
17
|
-
getContentType(): string;
|
|
18
|
-
add(name: string, value: string): void;
|
|
19
|
-
addFile(name: string, file: File): void;
|
|
20
|
-
}
|
|
21
|
-
//#endregion
|
|
22
|
-
//#region src/http/problem.d.ts
|
|
23
|
-
interface ProblemDetails {
|
|
24
|
-
type?: string;
|
|
25
|
-
/** The name/title of the error.*/
|
|
26
|
-
title: string;
|
|
27
|
-
/** A brief explanation/definition into the nature of the error. */
|
|
28
|
-
detail?: string | null;
|
|
29
|
-
/** Any additional error arguments passed to the client. */
|
|
30
|
-
extras?: unknown;
|
|
31
|
-
/** The HTTP status code */
|
|
32
|
-
status?: number;
|
|
33
|
-
statusText?: string;
|
|
34
|
-
errors?: Record<string, string[] | undefined>;
|
|
35
|
-
traceId?: string;
|
|
36
|
-
}
|
|
37
|
-
//#endregion
|
|
38
|
-
//#region src/http/inner.d.ts
|
|
39
|
-
type CreateInnerApiClientOptions = {
|
|
40
|
-
/**
|
|
41
|
-
* The base URL to use for the API.
|
|
42
|
-
* @example 'https://api.paklo.app'
|
|
43
|
-
*/
|
|
44
|
-
baseUrl: string;
|
|
45
|
-
/** The token to use for authentication. This can be a JWT or specialized key. */
|
|
46
|
-
token?: string;
|
|
47
|
-
};
|
|
48
|
-
type RequestOptions = {
|
|
49
|
-
/**
|
|
50
|
-
* Value for the `User-Agent` header.
|
|
51
|
-
* This prepends the default value (e.g. `paklo/ab26320`)
|
|
52
|
-
* which is important when we need to propagate the browser information to the server.
|
|
53
|
-
*/
|
|
54
|
-
userAgent?: string;
|
|
55
|
-
};
|
|
56
|
-
type ResourceResponse<T$1 = Record<string, unknown>> = {
|
|
57
|
-
/** The headers of the response. */
|
|
58
|
-
headers: Headers;
|
|
59
|
-
/** Whether the request was successful. */
|
|
60
|
-
successful: boolean;
|
|
61
|
-
/** The status code of the response. */
|
|
62
|
-
status: number;
|
|
63
|
-
/** The status text of the response. */
|
|
64
|
-
statusText: string;
|
|
65
|
-
/** The data of the response. */
|
|
66
|
-
data?: T$1;
|
|
67
|
-
/** The error of the response. */
|
|
68
|
-
error?: ProblemDetails;
|
|
69
|
-
};
|
|
70
|
-
type InnerRequestOptions<T$1> = RequestOptions & {
|
|
71
|
-
/**
|
|
72
|
-
* The base URL to use for the request.
|
|
73
|
-
* This overrides the default base URL.
|
|
74
|
-
* @example 'https://api.paklo.app'
|
|
75
|
-
*/
|
|
76
|
-
baseUrl?: string;
|
|
77
|
-
/** Additional headers to use for the request. */
|
|
78
|
-
headers?: HeadersInit;
|
|
79
|
-
/** The payload to use for the request. */
|
|
80
|
-
payload?: Record<string, unknown> | MultipartFormDataBody | ReadableStream | XMLHttpRequestBodyInit;
|
|
81
|
-
/** The schema to use when parsing the response. */
|
|
82
|
-
schema?: ZodType<T$1>;
|
|
83
|
-
};
|
|
84
|
-
type InnerRequestOptionsComplete<T$1> = InnerRequestOptions<T$1> & {
|
|
85
|
-
/** The method to use for the request. */
|
|
86
|
-
method: 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
|
|
87
|
-
/** The URL to use for the request. */
|
|
88
|
-
url: string;
|
|
89
|
-
};
|
|
90
|
-
declare class InnerApiClient {
|
|
91
|
-
private readonly baseUrl;
|
|
92
|
-
private readonly headers;
|
|
93
|
-
private readonly token?;
|
|
94
|
-
/**
|
|
95
|
-
* Create a new API client.
|
|
96
|
-
* @param options The options to use for the client.
|
|
97
|
-
*/
|
|
98
|
-
constructor({
|
|
99
|
-
baseUrl,
|
|
100
|
-
token
|
|
101
|
-
}: CreateInnerApiClientOptions);
|
|
102
|
-
get<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
103
|
-
post<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
104
|
-
put<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
105
|
-
patch<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
106
|
-
delete<T>(url: string, options?: InnerRequestOptions<T>): Promise<ResourceResponse<T>>;
|
|
107
|
-
request<T>(options: InnerRequestOptionsComplete<T>): Promise<ResourceResponse<T>>;
|
|
108
|
-
private makeUrl;
|
|
109
|
-
}
|
|
110
|
-
/** Http request error */
|
|
111
|
-
declare class HttpRequestError extends Error {
|
|
112
|
-
code: number;
|
|
113
|
-
constructor(message: string, code: number);
|
|
114
|
-
}
|
|
115
|
-
declare function isErrorTemporaryFailure(e?: {
|
|
116
|
-
code?: string | number;
|
|
117
|
-
message?: string;
|
|
118
|
-
} | null): boolean;
|
|
119
|
-
//#endregion
|
|
120
|
-
export { CreateInnerApiClientOptions, HEADER_NAME_ACCEPT, HEADER_NAME_AUTHORIZATION, HEADER_NAME_CONTENT_DISPOSITION, HEADER_NAME_CONTENT_TYPE, HEADER_NAME_USER_AGENT, HttpRequestError, InnerApiClient, InnerRequestOptions, ProblemDetails, RequestOptions, ResourceResponse, isErrorTemporaryFailure };
|
|
121
|
-
//# sourceMappingURL=http.d.ts.map
|