@package-broker/shared 0.2.15
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/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +11 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/schemas/index.d.ts +134 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +57 -0
- package/dist/schemas/index.js.map +1 -0
- package/dist/types/credentials.d.ts +22 -0
- package/dist/types/credentials.d.ts.map +1 -0
- package/dist/types/credentials.js +100 -0
- package/dist/types/credentials.js.map +1 -0
- package/dist/types/index.d.ts +19 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +3 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +40 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,mBAAmB,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* PACKAGE.broker
|
|
3
|
+
* Copyright (C) 2025 Łukasz Bajsarowicz
|
|
4
|
+
* Licensed under AGPL-3.0
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* User-Agent string that mimics Composer 2.x
|
|
8
|
+
* Required by some repositories (like Amasty) that validate User-Agent headers
|
|
9
|
+
*/
|
|
10
|
+
export const COMPOSER_USER_AGENT = 'Composer/2.7.0 (Linux; PHP 8.2.0)';
|
|
11
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,mCAAmC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,cAAc,SAAS,CAAC;AACxB,cAAc,qBAAqB,CAAC;AACpC,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const credentialTypeSchema: z.ZodEnum<["http_basic", "github_token", "gitlab_token", "bitbucket_app_password", "bitbucket_api_token", "bitbucket_api_key", "bitbucket_server_pat", "bearer_token"]>;
|
|
3
|
+
export declare const vcsTypeSchema: z.ZodEnum<["git", "composer", "artifact"]>;
|
|
4
|
+
export declare const createRepositorySchema: z.ZodObject<{
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
vcs_type: z.ZodEnum<["git", "composer", "artifact"]>;
|
|
7
|
+
credential_type: z.ZodEnum<["http_basic", "github_token", "gitlab_token", "bitbucket_app_password", "bitbucket_api_token", "bitbucket_api_key", "bitbucket_server_pat", "bearer_token"]>;
|
|
8
|
+
auth_credentials: z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>;
|
|
9
|
+
composer_json_path: z.ZodOptional<z.ZodString>;
|
|
10
|
+
package_filter: z.ZodOptional<z.ZodString>;
|
|
11
|
+
}, "strip", z.ZodTypeAny, {
|
|
12
|
+
url: string;
|
|
13
|
+
vcs_type: "git" | "composer" | "artifact";
|
|
14
|
+
credential_type: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token";
|
|
15
|
+
auth_credentials: Record<string, string>;
|
|
16
|
+
composer_json_path?: string | undefined;
|
|
17
|
+
package_filter?: string | undefined;
|
|
18
|
+
}, {
|
|
19
|
+
url: string;
|
|
20
|
+
vcs_type: "git" | "composer" | "artifact";
|
|
21
|
+
credential_type: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token";
|
|
22
|
+
auth_credentials: Record<string, string>;
|
|
23
|
+
composer_json_path?: string | undefined;
|
|
24
|
+
package_filter?: string | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
export declare const updateRepositorySchema: z.ZodObject<{
|
|
27
|
+
url: z.ZodOptional<z.ZodString>;
|
|
28
|
+
vcs_type: z.ZodOptional<z.ZodEnum<["git", "composer", "artifact"]>>;
|
|
29
|
+
credential_type: z.ZodOptional<z.ZodEnum<["http_basic", "github_token", "gitlab_token", "bitbucket_app_password", "bitbucket_api_token", "bitbucket_api_key", "bitbucket_server_pat", "bearer_token"]>>;
|
|
30
|
+
auth_credentials: z.ZodOptional<z.ZodEffects<z.ZodRecord<z.ZodString, z.ZodString>, Record<string, string>, Record<string, string>>>;
|
|
31
|
+
composer_json_path: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
32
|
+
package_filter: z.ZodOptional<z.ZodOptional<z.ZodString>>;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
url?: string | undefined;
|
|
35
|
+
vcs_type?: "git" | "composer" | "artifact" | undefined;
|
|
36
|
+
credential_type?: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token" | undefined;
|
|
37
|
+
auth_credentials?: Record<string, string> | undefined;
|
|
38
|
+
composer_json_path?: string | undefined;
|
|
39
|
+
package_filter?: string | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
url?: string | undefined;
|
|
42
|
+
vcs_type?: "git" | "composer" | "artifact" | undefined;
|
|
43
|
+
credential_type?: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token" | undefined;
|
|
44
|
+
auth_credentials?: Record<string, string> | undefined;
|
|
45
|
+
composer_json_path?: string | undefined;
|
|
46
|
+
package_filter?: string | undefined;
|
|
47
|
+
}>;
|
|
48
|
+
export declare const repositoryResponseSchema: z.ZodObject<{
|
|
49
|
+
id: z.ZodString;
|
|
50
|
+
url: z.ZodString;
|
|
51
|
+
vcs_type: z.ZodEnum<["git", "composer", "artifact"]>;
|
|
52
|
+
credential_type: z.ZodEnum<["http_basic", "github_token", "gitlab_token", "bitbucket_app_password", "bitbucket_api_token", "bitbucket_api_key", "bitbucket_server_pat", "bearer_token"]>;
|
|
53
|
+
composer_json_path: z.ZodNullable<z.ZodString>;
|
|
54
|
+
package_filter: z.ZodNullable<z.ZodString>;
|
|
55
|
+
status: z.ZodEnum<["pending", "active", "error", "syncing"]>;
|
|
56
|
+
error_message: z.ZodNullable<z.ZodString>;
|
|
57
|
+
last_synced_at: z.ZodNullable<z.ZodNumber>;
|
|
58
|
+
created_at: z.ZodNumber;
|
|
59
|
+
}, "strip", z.ZodTypeAny, {
|
|
60
|
+
url: string;
|
|
61
|
+
vcs_type: "git" | "composer" | "artifact";
|
|
62
|
+
credential_type: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token";
|
|
63
|
+
status: "pending" | "active" | "error" | "syncing";
|
|
64
|
+
composer_json_path: string | null;
|
|
65
|
+
package_filter: string | null;
|
|
66
|
+
id: string;
|
|
67
|
+
error_message: string | null;
|
|
68
|
+
last_synced_at: number | null;
|
|
69
|
+
created_at: number;
|
|
70
|
+
}, {
|
|
71
|
+
url: string;
|
|
72
|
+
vcs_type: "git" | "composer" | "artifact";
|
|
73
|
+
credential_type: "http_basic" | "github_token" | "gitlab_token" | "bitbucket_app_password" | "bitbucket_api_token" | "bitbucket_api_key" | "bitbucket_server_pat" | "bearer_token";
|
|
74
|
+
status: "pending" | "active" | "error" | "syncing";
|
|
75
|
+
composer_json_path: string | null;
|
|
76
|
+
package_filter: string | null;
|
|
77
|
+
id: string;
|
|
78
|
+
error_message: string | null;
|
|
79
|
+
last_synced_at: number | null;
|
|
80
|
+
created_at: number;
|
|
81
|
+
}>;
|
|
82
|
+
export declare const tokenPermissionsSchema: z.ZodEnum<["readonly", "write"]>;
|
|
83
|
+
export declare const createTokenSchema: z.ZodObject<{
|
|
84
|
+
description: z.ZodString;
|
|
85
|
+
permissions: z.ZodDefault<z.ZodEnum<["readonly", "write"]>>;
|
|
86
|
+
rate_limit_max: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
|
|
87
|
+
expires_at: z.ZodOptional<z.ZodNumber>;
|
|
88
|
+
}, "strip", z.ZodTypeAny, {
|
|
89
|
+
description: string;
|
|
90
|
+
permissions: "readonly" | "write";
|
|
91
|
+
rate_limit_max: number | null;
|
|
92
|
+
expires_at?: number | undefined;
|
|
93
|
+
}, {
|
|
94
|
+
description: string;
|
|
95
|
+
permissions?: "readonly" | "write" | undefined;
|
|
96
|
+
rate_limit_max?: number | null | undefined;
|
|
97
|
+
expires_at?: number | undefined;
|
|
98
|
+
}>;
|
|
99
|
+
export declare const updateTokenSchema: z.ZodObject<{
|
|
100
|
+
description: z.ZodOptional<z.ZodString>;
|
|
101
|
+
rate_limit_max: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
|
|
102
|
+
}, "strip", z.ZodTypeAny, {
|
|
103
|
+
description?: string | undefined;
|
|
104
|
+
rate_limit_max?: number | null | undefined;
|
|
105
|
+
}, {
|
|
106
|
+
description?: string | undefined;
|
|
107
|
+
rate_limit_max?: number | null | undefined;
|
|
108
|
+
}>;
|
|
109
|
+
export declare const tokenResponseSchema: z.ZodObject<{
|
|
110
|
+
id: z.ZodString;
|
|
111
|
+
description: z.ZodString;
|
|
112
|
+
permissions: z.ZodEnum<["readonly", "write"]>;
|
|
113
|
+
rate_limit_max: z.ZodNullable<z.ZodNumber>;
|
|
114
|
+
created_at: z.ZodNumber;
|
|
115
|
+
expires_at: z.ZodNullable<z.ZodNumber>;
|
|
116
|
+
last_used_at: z.ZodNullable<z.ZodNumber>;
|
|
117
|
+
}, "strip", z.ZodTypeAny, {
|
|
118
|
+
id: string;
|
|
119
|
+
created_at: number;
|
|
120
|
+
description: string;
|
|
121
|
+
permissions: "readonly" | "write";
|
|
122
|
+
rate_limit_max: number | null;
|
|
123
|
+
expires_at: number | null;
|
|
124
|
+
last_used_at: number | null;
|
|
125
|
+
}, {
|
|
126
|
+
id: string;
|
|
127
|
+
created_at: number;
|
|
128
|
+
description: string;
|
|
129
|
+
permissions: "readonly" | "write";
|
|
130
|
+
rate_limit_max: number | null;
|
|
131
|
+
expires_at: number | null;
|
|
132
|
+
last_used_at: number | null;
|
|
133
|
+
}>;
|
|
134
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,oBAAoB,yKAS/B,CAAC;AAEH,eAAO,MAAM,aAAa,4CAA0C,CAAC;AAGrE,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAUjC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;EAAmC,CAAC;AAEvE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAWnC,CAAC;AAGH,eAAO,MAAM,sBAAsB,kCAAgC,CAAC;AAEpE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;EAK5B,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;EAG5B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;EAQ9B,CAAC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// Zod schemas for validation
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export const credentialTypeSchema = z.enum([
|
|
4
|
+
'http_basic',
|
|
5
|
+
'github_token',
|
|
6
|
+
'gitlab_token',
|
|
7
|
+
'bitbucket_app_password',
|
|
8
|
+
'bitbucket_api_token',
|
|
9
|
+
'bitbucket_api_key',
|
|
10
|
+
'bitbucket_server_pat',
|
|
11
|
+
'bearer_token',
|
|
12
|
+
]);
|
|
13
|
+
export const vcsTypeSchema = z.enum(['git', 'composer', 'artifact']);
|
|
14
|
+
// Repository schemas (inline to avoid circular dependency)
|
|
15
|
+
export const createRepositorySchema = z.object({
|
|
16
|
+
url: z.string().url('Invalid repository URL'),
|
|
17
|
+
vcs_type: vcsTypeSchema,
|
|
18
|
+
credential_type: credentialTypeSchema,
|
|
19
|
+
auth_credentials: z.record(z.string()).refine((fields) => Object.keys(fields).length > 0, 'At least one credential field is required'),
|
|
20
|
+
composer_json_path: z.string().optional(),
|
|
21
|
+
package_filter: z.string().optional(), // Comma-separated list of packages to sync
|
|
22
|
+
});
|
|
23
|
+
export const updateRepositorySchema = createRepositorySchema.partial();
|
|
24
|
+
export const repositoryResponseSchema = z.object({
|
|
25
|
+
id: z.string(),
|
|
26
|
+
url: z.string(),
|
|
27
|
+
vcs_type: vcsTypeSchema,
|
|
28
|
+
credential_type: credentialTypeSchema,
|
|
29
|
+
composer_json_path: z.string().nullable(),
|
|
30
|
+
package_filter: z.string().nullable(),
|
|
31
|
+
status: z.enum(['pending', 'active', 'error', 'syncing']),
|
|
32
|
+
error_message: z.string().nullable(),
|
|
33
|
+
last_synced_at: z.number().nullable(),
|
|
34
|
+
created_at: z.number(),
|
|
35
|
+
});
|
|
36
|
+
// Token schemas (inline to avoid circular dependency)
|
|
37
|
+
export const tokenPermissionsSchema = z.enum(['readonly', 'write']);
|
|
38
|
+
export const createTokenSchema = z.object({
|
|
39
|
+
description: z.string().min(1, 'Description is required'),
|
|
40
|
+
permissions: tokenPermissionsSchema.default('readonly'),
|
|
41
|
+
rate_limit_max: z.number().int().min(0).max(25000, 'Rate limit cannot exceed 25,000 requests/hour').nullable().default(1000),
|
|
42
|
+
expires_at: z.number().int().positive().optional(),
|
|
43
|
+
});
|
|
44
|
+
export const updateTokenSchema = z.object({
|
|
45
|
+
description: z.string().min(1, 'Description is required').optional(),
|
|
46
|
+
rate_limit_max: z.number().int().min(0).max(25000, 'Rate limit cannot exceed 25,000 requests/hour').nullable().optional(),
|
|
47
|
+
});
|
|
48
|
+
export const tokenResponseSchema = z.object({
|
|
49
|
+
id: z.string(),
|
|
50
|
+
description: z.string(),
|
|
51
|
+
permissions: tokenPermissionsSchema,
|
|
52
|
+
rate_limit_max: z.number().nullable(),
|
|
53
|
+
created_at: z.number(),
|
|
54
|
+
expires_at: z.number().nullable(),
|
|
55
|
+
last_used_at: z.number().nullable(),
|
|
56
|
+
});
|
|
57
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/schemas/index.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAE7B,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,CAAC,IAAI,CAAC;IACzC,YAAY;IACZ,cAAc;IACd,cAAc;IACd,wBAAwB;IACxB,qBAAqB;IACrB,mBAAmB;IACnB,sBAAsB;IACtB,cAAc;CACf,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,UAAU,EAAE,UA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,MAAM,EAAE,CAAC,QAAQ,EAAE;IACrC,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { CredentialType } from './index';
|
|
2
|
+
/**
|
|
3
|
+
* Credential field definitions for each credential type
|
|
4
|
+
*/
|
|
5
|
+
export declare const CREDENTIAL_FIELD_DEFINITIONS: Record<CredentialType, {
|
|
6
|
+
label: string;
|
|
7
|
+
fields: Array<{
|
|
8
|
+
name: string;
|
|
9
|
+
label: string;
|
|
10
|
+
type: 'text' | 'password';
|
|
11
|
+
}>;
|
|
12
|
+
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Credential types allowed for each source type
|
|
15
|
+
* Filters the credential dropdown based on what makes sense for the source
|
|
16
|
+
*/
|
|
17
|
+
export declare const CREDENTIALS_BY_SOURCE_TYPE: Record<string, CredentialType[]>;
|
|
18
|
+
/**
|
|
19
|
+
* Build authentication headers from credential config
|
|
20
|
+
*/
|
|
21
|
+
export declare function buildAuthHeaders(credentialType: CredentialType, fields: Record<string, string>): HeadersInit;
|
|
22
|
+
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,cAAc,EAAoB,MAAM,SAAS,CAAC;AAEhE;;GAEG;AACH,eAAO,MAAM,4BAA4B,EAAE,MAAM,CAC/C,cAAc,EACd;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC,CAAA;CAAE,CA4C7F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,EAAE,CAGvE,CAAC;AAEF;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC7B,WAAW,CAyCb"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
// Credential type definitions
|
|
2
|
+
/**
|
|
3
|
+
* Credential field definitions for each credential type
|
|
4
|
+
*/
|
|
5
|
+
export const CREDENTIAL_FIELD_DEFINITIONS = {
|
|
6
|
+
http_basic: {
|
|
7
|
+
label: 'HTTP Basic (Username/Password)',
|
|
8
|
+
fields: [
|
|
9
|
+
{ name: 'username', label: 'Username', type: 'text' },
|
|
10
|
+
{ name: 'password', label: 'Password', type: 'password' },
|
|
11
|
+
],
|
|
12
|
+
},
|
|
13
|
+
github_token: {
|
|
14
|
+
label: 'GitHub Token',
|
|
15
|
+
fields: [{ name: 'token', label: 'Personal Access Token', type: 'password' }],
|
|
16
|
+
},
|
|
17
|
+
gitlab_token: {
|
|
18
|
+
label: 'GitLab Token',
|
|
19
|
+
fields: [{ name: 'token', label: 'Personal/Project Access Token', type: 'password' }],
|
|
20
|
+
},
|
|
21
|
+
bitbucket_app_password: {
|
|
22
|
+
label: 'Bitbucket App Password',
|
|
23
|
+
fields: [
|
|
24
|
+
{ name: 'username', label: 'Username', type: 'text' },
|
|
25
|
+
{ name: 'password', label: 'App Password', type: 'password' },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
bitbucket_api_token: {
|
|
29
|
+
label: 'Bitbucket API Token',
|
|
30
|
+
fields: [{ name: 'token', label: 'Token', type: 'password' }],
|
|
31
|
+
},
|
|
32
|
+
bitbucket_api_key: {
|
|
33
|
+
label: 'Bitbucket API Key',
|
|
34
|
+
fields: [{ name: 'key', label: 'API Key', type: 'password' }],
|
|
35
|
+
},
|
|
36
|
+
bitbucket_server_pat: {
|
|
37
|
+
label: 'Bitbucket Server PAT',
|
|
38
|
+
fields: [{ name: 'token', label: 'Personal Access Token', type: 'password' }],
|
|
39
|
+
},
|
|
40
|
+
bearer_token: {
|
|
41
|
+
label: 'Bearer Token',
|
|
42
|
+
fields: [{ name: 'token', label: 'Token', type: 'password' }],
|
|
43
|
+
},
|
|
44
|
+
none: {
|
|
45
|
+
label: 'No Authentication',
|
|
46
|
+
fields: [],
|
|
47
|
+
},
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Credential types allowed for each source type
|
|
51
|
+
* Filters the credential dropdown based on what makes sense for the source
|
|
52
|
+
*/
|
|
53
|
+
export const CREDENTIALS_BY_SOURCE_TYPE = {
|
|
54
|
+
composer: ['http_basic', 'bearer_token'],
|
|
55
|
+
git: ['github_token', 'gitlab_token', 'bitbucket_app_password', 'bitbucket_api_token', 'bitbucket_api_key', 'bitbucket_server_pat'],
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* Build authentication headers from credential config
|
|
59
|
+
*/
|
|
60
|
+
export function buildAuthHeaders(credentialType, fields) {
|
|
61
|
+
const headers = {};
|
|
62
|
+
switch (credentialType) {
|
|
63
|
+
case 'http_basic': {
|
|
64
|
+
const username = fields.username || '';
|
|
65
|
+
const password = fields.password || '';
|
|
66
|
+
const credentials = btoa(`${username}:${password}`);
|
|
67
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
68
|
+
break;
|
|
69
|
+
}
|
|
70
|
+
case 'github_token':
|
|
71
|
+
case 'gitlab_token':
|
|
72
|
+
case 'bitbucket_api_token':
|
|
73
|
+
case 'bitbucket_server_pat':
|
|
74
|
+
case 'bearer_token': {
|
|
75
|
+
headers['Authorization'] = `Bearer ${fields.token || fields.password || fields.key || ''}`;
|
|
76
|
+
break;
|
|
77
|
+
}
|
|
78
|
+
case 'bitbucket_app_password': {
|
|
79
|
+
// Bitbucket App Password uses Basic Auth with username:password
|
|
80
|
+
const username = fields.username || '';
|
|
81
|
+
const password = fields.password || '';
|
|
82
|
+
const credentials = btoa(`${username}:${password}`);
|
|
83
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
case 'bitbucket_api_key': {
|
|
87
|
+
// Bitbucket API Key uses Basic Auth
|
|
88
|
+
const username = fields.username || fields.key || '';
|
|
89
|
+
const password = fields.password || '';
|
|
90
|
+
const credentials = btoa(`${username}:${password}`);
|
|
91
|
+
headers['Authorization'] = `Basic ${credentials}`;
|
|
92
|
+
break;
|
|
93
|
+
}
|
|
94
|
+
case 'none': {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
return headers;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../../src/types/credentials.ts"],"names":[],"mappings":"AAAA,8BAA8B;AAI9B;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAGrC;IACF,UAAU,EAAE;QACV,KAAK,EAAE,gCAAgC;QACvC,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE;YACrD,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE;SAC1D;KACF;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,uBAAuB,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC;KAC9E;IACD,YAAY,EAAE;QACZ,KAAK,EAAE,cAAc;QACrB,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,+BAA+B,EAAE,I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CAAC;YACrD,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC;YACvC,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,QAAQ,IAAI,QAAQ,EAAE,CAAC,CAAC;YACpD,OAAO,CAAC,eAAe,CAAC,GAAG,SAAS,WAAW,EAAE,CAAC;YAClD,MAAM;QACR,CAAC;QACD,KAAK,MAAM,CAAC,CAAC,CAAC;YACZ,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type CredentialType = 'http_basic' | 'github_token' | 'gitlab_token' | 'bitbucket_app_password' | 'bitbucket_api_token' | 'bitbucket_api_key' | 'bitbucket_server_pat' | 'bearer_token' | 'none';
|
|
2
|
+
export type VcsType = 'git' | 'composer' | 'artifact';
|
|
3
|
+
export interface CredentialConfig {
|
|
4
|
+
type: CredentialType;
|
|
5
|
+
fields: Record<string, string>;
|
|
6
|
+
}
|
|
7
|
+
export interface WorkerConfig {
|
|
8
|
+
storage: 'r2' | 's3';
|
|
9
|
+
s3Config?: S3Config;
|
|
10
|
+
metadataTTL?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface S3Config {
|
|
13
|
+
endpoint: string;
|
|
14
|
+
region: string;
|
|
15
|
+
accessKeyId: string;
|
|
16
|
+
secretAccessKey: string;
|
|
17
|
+
bucket: string;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,cAAc,GACtB,YAAY,GACZ,cAAc,GACd,cAAc,GACd,wBAAwB,GACxB,qBAAqB,GACrB,mBAAmB,GACnB,sBAAsB,GACtB,cAAc,GACd,MAAM,CAAC;AAGX,MAAM,MAAM,OAAO,GAAG,KAAK,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtD,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,cAAc,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,YAAY;IAC3B,OAAO,EAAE,IAAI,GAAG,IAAI,CAAC;IACrB,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,QAAQ;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,0BAA0B"}
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@package-broker/shared",
|
|
3
|
+
"version": "0.2.15",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"import": "./dist/index.js",
|
|
11
|
+
"default": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"dist",
|
|
16
|
+
"package.json",
|
|
17
|
+
"README.md"
|
|
18
|
+
],
|
|
19
|
+
"scripts": {
|
|
20
|
+
"lint": "echo 'no linting configured'",
|
|
21
|
+
"build": "tsc -p tsconfig.build.json",
|
|
22
|
+
"clean": "rm -rf dist",
|
|
23
|
+
"typecheck": "tsc --noEmit",
|
|
24
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"zod": "^3.22.4"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"typescript": "^5.3.3"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/package-broker/server",
|
|
35
|
+
"directory": "packages/shared"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|