chrome-webstore-upload 4.0.0 → 4.0.2
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/distribution/errors.d.ts +5 -0
- package/distribution/errors.js +42 -0
- package/distribution/types.d.ts +22 -0
- package/distribution/types.js +1 -0
- package/package.json +16 -24
- /package/{index.d.ts → distribution/index.d.ts} +0 -0
- /package/{index.js → distribution/index.js} +0 -0
- /package/{zip-dir.d.ts → distribution/zip-dir.d.ts} +0 -0
- /package/{zip-dir.js → distribution/zip-dir.js} +0 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
export class CWSError extends Error {
|
|
2
|
+
cause;
|
|
3
|
+
name = 'CWSError';
|
|
4
|
+
}
|
|
5
|
+
function parseErrorMessage(response) {
|
|
6
|
+
const errorResponse = response;
|
|
7
|
+
// Handle OAuth errors: { error: "invalid_grant", error_description: "Bad Request" }
|
|
8
|
+
if (typeof errorResponse.error === 'string') {
|
|
9
|
+
if (errorResponse.error === 'invalid_grant') {
|
|
10
|
+
return 'Invalid grant: The authentication keys are probably invalid or expired';
|
|
11
|
+
}
|
|
12
|
+
if (errorResponse.error === 'invalid_request') {
|
|
13
|
+
return `Invalid request: ${errorResponse.error_description ?? 'Missing required parameters'}`;
|
|
14
|
+
}
|
|
15
|
+
return errorResponse.error_description ?? errorResponse.error;
|
|
16
|
+
}
|
|
17
|
+
// Handle API errors: { error: { code: 400, message: "...", errors: [...] } }
|
|
18
|
+
if (errorResponse.error && typeof errorResponse.error === 'object') {
|
|
19
|
+
const { error } = errorResponse;
|
|
20
|
+
if (error.message) {
|
|
21
|
+
// Remove "Publish condition not met: " prefix if present
|
|
22
|
+
return error.message.replace(/^Publish condition not met: /, '');
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
// Handle item errors in ItemResource: { itemError: [{ error_code: "...", error_detail: "..." }] }
|
|
26
|
+
const itemResource = response;
|
|
27
|
+
if (itemResource.itemError && Array.isArray(itemResource.itemError) && itemResource.itemError.length > 0) {
|
|
28
|
+
const errorDetails = itemResource.itemError.map(error => error.error_detail).join('; ');
|
|
29
|
+
return errorDetails;
|
|
30
|
+
}
|
|
31
|
+
return 'Unknown error';
|
|
32
|
+
}
|
|
33
|
+
export function throwIfNotOk(request, response) {
|
|
34
|
+
// Check for upload failure even on HTTP 200
|
|
35
|
+
const itemResource = response;
|
|
36
|
+
if (!request.ok || itemResource.uploadState === 'FAILURE') {
|
|
37
|
+
const message = parseErrorMessage(response);
|
|
38
|
+
const error = new CWSError(message);
|
|
39
|
+
error.cause = response;
|
|
40
|
+
throw error;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type APIClientOptions = {
|
|
2
|
+
extensionId: string;
|
|
3
|
+
clientId: string;
|
|
4
|
+
refreshToken: string;
|
|
5
|
+
clientSecret: string | undefined;
|
|
6
|
+
};
|
|
7
|
+
export type ItemResource = {
|
|
8
|
+
kind: 'chromewebstore#item';
|
|
9
|
+
id: string;
|
|
10
|
+
publicKey: string;
|
|
11
|
+
uploadState: 'FAILURE' | 'IN_PROGRESS' | 'NOT_FOUND' | 'SUCCESS';
|
|
12
|
+
itemError: Array<{
|
|
13
|
+
error_code: string;
|
|
14
|
+
error_detail: string;
|
|
15
|
+
}>;
|
|
16
|
+
};
|
|
17
|
+
export type PublishResponse = {
|
|
18
|
+
kind: 'chromewebstore#item';
|
|
19
|
+
item_id: string;
|
|
20
|
+
status: Array<'OK' | 'NOT_AUTHORIZED' | 'INVALID_DEVELOPER' | 'DEVELOPER_NO_OWNERSHIP' | 'DEVELOPER_SUSPENDED' | 'ITEM_NOT_FOUND' | 'ITEM_PENDING_REVIEW' | 'ITEM_TAKEN_DOWN' | 'PUBLISHER_SUSPENDED'>;
|
|
21
|
+
statusDetail: string[];
|
|
22
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "chrome-webstore-upload",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Upload Chrome Extensions to the Chrome Web Store",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"chrome",
|
|
@@ -20,13 +20,10 @@
|
|
|
20
20
|
"Federico Brigante <me@fregante.com> (https://fregante.com)"
|
|
21
21
|
],
|
|
22
22
|
"type": "module",
|
|
23
|
-
"exports": "./index.js",
|
|
24
|
-
"types": "./index.d.ts",
|
|
23
|
+
"exports": "./distribution/index.js",
|
|
24
|
+
"types": "./distribution/index.d.ts",
|
|
25
25
|
"files": [
|
|
26
|
-
"
|
|
27
|
-
"index.d.ts",
|
|
28
|
-
"zip-dir.js",
|
|
29
|
-
"zip-dir.d.ts"
|
|
26
|
+
"distribution"
|
|
30
27
|
],
|
|
31
28
|
"scripts": {
|
|
32
29
|
"prebundle": "dot-json test/extension/manifest.json version $(utc-version)",
|
|
@@ -45,34 +42,29 @@
|
|
|
45
42
|
"object-curly-spacing": [
|
|
46
43
|
"error",
|
|
47
44
|
"always"
|
|
45
|
+
],
|
|
46
|
+
"@typescript-eslint/naming-convention": "off",
|
|
47
|
+
"@stylistic/object-curly-spacing": [
|
|
48
|
+
"error",
|
|
49
|
+
"always"
|
|
50
|
+
],
|
|
51
|
+
"@stylistic/block-spacing": [
|
|
52
|
+
"error",
|
|
53
|
+
"always"
|
|
48
54
|
]
|
|
49
55
|
},
|
|
50
|
-
"overrides": [
|
|
51
|
-
{
|
|
52
|
-
"files": [
|
|
53
|
-
"**/*.ts"
|
|
54
|
-
],
|
|
55
|
-
"rules": {
|
|
56
|
-
"@typescript-eslint/naming-convention": "off",
|
|
57
|
-
"@typescript-eslint/object-curly-spacing": [
|
|
58
|
-
"error",
|
|
59
|
-
"always"
|
|
60
|
-
]
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
],
|
|
64
56
|
"space": 4
|
|
65
57
|
},
|
|
66
58
|
"devDependencies": {
|
|
67
|
-
"@sindresorhus/tsconfig": "^
|
|
59
|
+
"@sindresorhus/tsconfig": "^8.0.1",
|
|
68
60
|
"@types/yazl": "^3.3.0",
|
|
69
61
|
"dot-json": "^1.3.0",
|
|
70
62
|
"fetch-mock": "^9.11.0",
|
|
71
63
|
"node-fetch": "^2.7.0",
|
|
72
|
-
"typescript": "^5.
|
|
64
|
+
"typescript": "^5.9.3",
|
|
73
65
|
"utc-version": "^2.0.2",
|
|
74
66
|
"vitest": "^3.2.4",
|
|
75
|
-
"xo": "^
|
|
67
|
+
"xo": "^1.2.3"
|
|
76
68
|
},
|
|
77
69
|
"engines": {
|
|
78
70
|
"node": ">=20"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|