@stacksjs/git 0.75.219 → 0.75.220
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/credentials.d.ts +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +21 -0
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Scope non-interactive Git HTTP authentication to one repository for a child
|
|
3
|
+
* process. Pass the caller's environment as the second argument and merge the
|
|
4
|
+
* result after it. Existing runtime Git config is retained. Do not log the map.
|
|
5
|
+
* No credential file, remote URL, Git config file or command argument receives
|
|
6
|
+
* the password. Redirects for this repository are refused rather than sending
|
|
7
|
+
* its authenticated requests to a different location.
|
|
8
|
+
*/
|
|
9
|
+
export declare function gitCredentialEnvironment(options: GitCredentialOptions, baseEnvironment?: Record<string, string | undefined>): Record<string, string>;
|
|
10
|
+
export declare interface GitCredentialOptions {
|
|
11
|
+
url: string
|
|
12
|
+
username: string
|
|
13
|
+
password: string
|
|
14
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export * from './credentials';
|
package/dist/index.js
CHANGED
|
@@ -1 +1,22 @@
|
|
|
1
1
|
// @bun
|
|
2
|
+
function T(n,a={}){let e;try{e=new URL(n.url)}catch{throw TypeError("Git credentials require an absolute HTTP(S) repository URL")}if(!["http:","https:"].includes(e.protocol)||e.username||e.password||e.search||e.hash||e.pathname==="/")throw TypeError("Git credentials require a repository URL without credentials, query or fragment");let i;try{i=decodeURIComponent(e.pathname.slice(1)).replace(/\/+$/,"")}catch{throw TypeError("Git credentials require a valid percent-encoded repository path")}if(!i||/[\r\n\0]/.test(i))throw TypeError("Git credentials require a single-line repository path");for(let r of[n.username,n.password])if(typeof r!=="string"||!r||/[\r\n\0]/.test(r))throw TypeError("Git credentials must be non-empty single-line values");let o=a.GIT_CONFIG_COUNT,t=o===void 0?0:Number(o);if(o!==void 0&&!/^\d+$/.test(o)||!Number.isSafeInteger(t)||t>Number.MAX_SAFE_INTEGER-4)throw TypeError("Git runtime configuration count must be a non-negative integer");for(let r=0;r<t;r++)if(!a[`GIT_CONFIG_KEY_${r}`]||a[`GIT_CONFIG_VALUE_${r}`]===void 0)throw TypeError("Git runtime configuration requires every existing key and value");let s={GIT_TERMINAL_PROMPT:"0",GCM_INTERACTIVE:"never",GIT_CONFIG_COUNT:String(t+4),STACKS_GIT_HTTP_PROTOCOL:e.protocol.slice(0,-1),STACKS_GIT_HTTP_HOST:e.host,STACKS_GIT_HTTP_PATH:i,STACKS_GIT_HTTP_USERNAME:n.username,STACKS_GIT_HTTP_PASSWORD:n.password},l=[["credential.helper",""],["credential.helper",`!f() {
|
|
3
|
+
[ "$1" = get ] || return 0
|
|
4
|
+
credential_protocol= credential_host= credential_path=
|
|
5
|
+
while IFS= read -r credential_line; do
|
|
6
|
+
[ -n "$credential_line" ] || break
|
|
7
|
+
case "$credential_line" in
|
|
8
|
+
protocol=*) credential_protocol=\${credential_line#protocol=} ;;
|
|
9
|
+
host=*) credential_host=\${credential_line#host=} ;;
|
|
10
|
+
path=*) credential_path=\${credential_line#path=} ;;
|
|
11
|
+
esac
|
|
12
|
+
done
|
|
13
|
+
[ "$credential_protocol" = "$STACKS_GIT_HTTP_PROTOCOL" ] || return 0
|
|
14
|
+
credential_host=$(printf '%s' "$credential_host" | tr '[:upper:]' '[:lower:]')
|
|
15
|
+
case "$credential_protocol" in
|
|
16
|
+
https) credential_host=\${credential_host%:443} ;;
|
|
17
|
+
http) credential_host=\${credential_host%:80} ;;
|
|
18
|
+
esac
|
|
19
|
+
[ "$credential_host" = "$STACKS_GIT_HTTP_HOST" ] || return 0
|
|
20
|
+
[ "\${credential_path%/}" = "$STACKS_GIT_HTTP_PATH" ] || return 0
|
|
21
|
+
printf 'username=%s\\npassword=%s\\n\\n' "$STACKS_GIT_HTTP_USERNAME" "$STACKS_GIT_HTTP_PASSWORD"
|
|
22
|
+
}; f`],["credential.useHttpPath","true"],[`http.${e.href}.followRedirects`,"false"]];for(let[r,[c,_]]of l.entries())s[`GIT_CONFIG_KEY_${t+r}`]=c,s[`GIT_CONFIG_VALUE_${t+r}`]=_;return s}export{T as gitCredentialEnvironment};
|