partner-center-broker 1.1.0 → 1.2.1
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/.github/workflows/main.yml +6 -7
- package/.github/workflows/npm-publish.yml +54 -34
- package/lib/index.d.ts +7 -1
- package/lib/index.js +269 -295
- package/package.json +18 -17
|
@@ -16,15 +16,14 @@ jobs:
|
|
|
16
16
|
- uses: actions/checkout@v2
|
|
17
17
|
- uses: actions/setup-node@v2
|
|
18
18
|
with:
|
|
19
|
-
node-version: '
|
|
19
|
+
node-version: '24'
|
|
20
20
|
registry-url: https://registry.npmjs.org/
|
|
21
21
|
- run: |
|
|
22
22
|
npm ci
|
|
23
23
|
npm install
|
|
24
|
-
npm run
|
|
25
|
-
npm run test
|
|
24
|
+
npm run prep
|
|
26
25
|
env:
|
|
27
|
-
PARTNER_CENTER_TENANT_ID: ${{
|
|
28
|
-
PARTNER_CENTER_CLIENT_ID: ${{
|
|
29
|
-
PARTNER_CENTER_CLIENT_SECRET: ${{
|
|
30
|
-
PARTNER_CENTER_APP_ID: ${{
|
|
26
|
+
PARTNER_CENTER_TENANT_ID: ${{secrets.TENANT_ID}}
|
|
27
|
+
PARTNER_CENTER_CLIENT_ID: ${{secrets.CLIENT_ID}}
|
|
28
|
+
PARTNER_CENTER_CLIENT_SECRET: ${{secrets.CLIENT_SECRET}}
|
|
29
|
+
PARTNER_CENTER_APP_ID: ${{secrets.DVLUP_PWA_APP_ID}}
|
|
@@ -1,58 +1,78 @@
|
|
|
1
|
-
name:
|
|
1
|
+
name: Publish Packages
|
|
2
2
|
|
|
3
3
|
on:
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- '**/*.gitignore'
|
|
10
|
-
- '**/*.gitattributes'
|
|
4
|
+
workflow_dispatch:
|
|
5
|
+
|
|
6
|
+
permissions:
|
|
7
|
+
id-token: write # for npm OIDC
|
|
8
|
+
contents: write # for github releases
|
|
11
9
|
|
|
12
10
|
jobs:
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
test:
|
|
12
|
+
name: Build and Test
|
|
15
13
|
runs-on: ubuntu-latest
|
|
16
14
|
steps:
|
|
17
15
|
- uses: actions/checkout@v2
|
|
18
16
|
- uses: actions/setup-node@v2
|
|
19
17
|
with:
|
|
20
|
-
node-version: '
|
|
21
|
-
-
|
|
18
|
+
node-version: '24'
|
|
19
|
+
- name: Run tests
|
|
20
|
+
run: |
|
|
22
21
|
npm ci
|
|
22
|
+
npm install
|
|
23
23
|
npm run prep
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
|
|
26
26
|
publish-npm:
|
|
27
|
-
|
|
27
|
+
name: Publish to npmjs.org
|
|
28
|
+
needs: [test]
|
|
28
29
|
runs-on: ubuntu-latest
|
|
29
30
|
steps:
|
|
30
31
|
- uses: actions/checkout@v2
|
|
31
32
|
- uses: actions/setup-node@v2
|
|
32
33
|
with:
|
|
33
|
-
node-version: '
|
|
34
|
+
node-version: '24'
|
|
34
35
|
registry-url: https://registry.npmjs.org/
|
|
35
|
-
|
|
36
|
+
|
|
37
|
+
- name: Delete existing version if present
|
|
38
|
+
continue-on-error: true
|
|
39
|
+
run: |
|
|
40
|
+
VERSION=$(node -p "require('./package.json').version")
|
|
41
|
+
npm unpublish partner-center-broker@$VERSION --registry=https://registry.npmjs.org/ || true
|
|
42
|
+
|
|
43
|
+
- name: Publish
|
|
44
|
+
run: |
|
|
36
45
|
npm ci
|
|
37
|
-
npm run
|
|
38
|
-
npm
|
|
39
|
-
npm publish
|
|
46
|
+
npm run package
|
|
47
|
+
npm publish --registry=https://registry.npmjs.org/
|
|
48
|
+
npm run publish-docs
|
|
49
|
+
|
|
50
|
+
- name: Get package version number
|
|
51
|
+
id: package-version
|
|
52
|
+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
|
|
53
|
+
|
|
54
|
+
- uses: actions/upload-artifact@v4
|
|
55
|
+
with:
|
|
56
|
+
name: partner-center-broker-v${{steps.package-version.outputs.version}}
|
|
57
|
+
path: partner-center-broker-${{steps.package-version.outputs.version}}.tgz
|
|
58
|
+
|
|
59
|
+
- name: Create GitHub release
|
|
60
|
+
id: create-release
|
|
61
|
+
uses: actions/create-release@v1
|
|
62
|
+
with:
|
|
63
|
+
tag_name: v${{steps.package-version.outputs.version}}
|
|
64
|
+
release_name: v${{steps.package-version.outputs.version}}
|
|
65
|
+
draft: false
|
|
66
|
+
prerelease: false
|
|
40
67
|
env:
|
|
41
|
-
|
|
68
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
|
42
69
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
runs-on: ubuntu-latest
|
|
46
|
-
steps:
|
|
47
|
-
- uses: actions/checkout@v2
|
|
48
|
-
- uses: actions/setup-node@v2
|
|
70
|
+
- name: Upload package to release
|
|
71
|
+
uses: actions/upload-release-asset@v1
|
|
49
72
|
with:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
npm run rebuild
|
|
55
|
-
npm pack
|
|
56
|
-
npm publish
|
|
73
|
+
upload_url: ${{steps.create-release.outputs.upload_url}}
|
|
74
|
+
asset_path: partner-center-broker-${{steps.package-version.outputs.version}}.tgz
|
|
75
|
+
asset_name: partner-center-broker-${{steps.package-version.outputs.version}}.tgz
|
|
76
|
+
asset_content_type: application/gzip
|
|
57
77
|
env:
|
|
58
|
-
|
|
78
|
+
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { GetSubmissionResult, SubmissionStatusResult, ServiceAuthenticationResult, CommitSubmissionResult, CreateAppSubmissionResult, AppResourceResult, UpdateSubmissionResult, SubmissionData } from './interfaces';
|
|
1
|
+
import { GetSubmissionResult, SubmissionStatusResult, ServiceAuthenticationResult, CommitSubmissionResult, CreateAppSubmissionResult, AppResourceResult, UpdateSubmissionResult, SubmissionData, ApplicationSubmission, AllowTargetFutureDeviceFamilies, ApplicationPackage, Listings, PackageDeliveryOptions, Pricing, StatusDetails, EnUs, BaseListing, Image, PlatformOverrides, Windows81, PackageRollout, MarketSpecificPricings } from './interfaces';
|
|
2
|
+
/**
|
|
3
|
+
* @namespace DevCenter
|
|
4
|
+
*/
|
|
5
|
+
declare namespace DevCenter {
|
|
6
|
+
export type { ServiceAuthenticationResult, CommitSubmissionResult, CreateAppSubmissionResult, AppResourceResult, GetSubmissionResult, SubmissionStatusResult, UpdateSubmissionResult, SubmissionData, ApplicationSubmission, AllowTargetFutureDeviceFamilies, ApplicationPackage, Listings, PackageDeliveryOptions, Pricing, StatusDetails, EnUs, BaseListing, Image, PlatformOverrides, Windows81, PackageRollout, MarketSpecificPricings };
|
|
7
|
+
}
|
|
2
8
|
declare class DevCenter {
|
|
3
9
|
tenantId: string;
|
|
4
10
|
clientId: string;
|
package/lib/index.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
4
|
};
|
|
@@ -31,331 +22,314 @@ class DevCenter {
|
|
|
31
22
|
this.clientId = _clientId;
|
|
32
23
|
this.clientSecret = _clientSecret;
|
|
33
24
|
}
|
|
34
|
-
GetAppInfo(appId) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
54
|
-
}
|
|
55
|
-
else if (response.statusCode === 409) {
|
|
56
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
57
|
-
}
|
|
58
|
-
else {
|
|
59
|
-
throw console.error(response.statusMessage);
|
|
60
|
-
}
|
|
25
|
+
async GetAppInfo(appId) {
|
|
26
|
+
try {
|
|
27
|
+
let auth = await this.authorize();
|
|
28
|
+
// https://docs.microsoft.com/en-us/windows/uwp/monetize/get-app-data
|
|
29
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}"`;
|
|
30
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
31
|
+
method: 'get',
|
|
32
|
+
headers: {
|
|
33
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
if (response.statusCode == 200) {
|
|
37
|
+
return converters_1.Convert.toAppInfoResult(response.body);
|
|
38
|
+
}
|
|
39
|
+
else if (response.statusCode === 400) {
|
|
40
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
41
|
+
}
|
|
42
|
+
else if (response.statusCode === 404) {
|
|
43
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
61
44
|
}
|
|
62
|
-
|
|
63
|
-
throw
|
|
45
|
+
else if (response.statusCode === 409) {
|
|
46
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
64
47
|
}
|
|
65
|
-
|
|
48
|
+
else {
|
|
49
|
+
throw console.error(response.statusMessage);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
catch (err) {
|
|
53
|
+
throw err;
|
|
54
|
+
}
|
|
66
55
|
}
|
|
67
|
-
CreateAppSubmission(appId) {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
88
|
-
}
|
|
89
|
-
else if (response.statusCode === 409) {
|
|
90
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
throw console.error(response.statusMessage);
|
|
94
|
-
}
|
|
56
|
+
async CreateAppSubmission(appId) {
|
|
57
|
+
try {
|
|
58
|
+
let auth = await this.authorize();
|
|
59
|
+
// https://docs.microsoft.com/en-us/windows/uwp/monetize/create-an-app-submission
|
|
60
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}/submissions"`;
|
|
61
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
62
|
+
method: 'post',
|
|
63
|
+
headers: {
|
|
64
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`,
|
|
65
|
+
ContentType: 'application/json'
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
if (response.statusCode == 200) {
|
|
69
|
+
return converters_1.Convert.toCreateAppSubmissionResult(response.body);
|
|
70
|
+
}
|
|
71
|
+
else if (response.statusCode === 400) {
|
|
72
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
73
|
+
}
|
|
74
|
+
else if (response.statusCode === 404) {
|
|
75
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
95
76
|
}
|
|
96
|
-
|
|
97
|
-
throw console.error(
|
|
77
|
+
else if (response.statusCode === 409) {
|
|
78
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
98
79
|
}
|
|
99
|
-
|
|
80
|
+
else {
|
|
81
|
+
throw console.error(response.statusMessage);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw console.error(err);
|
|
86
|
+
}
|
|
100
87
|
}
|
|
101
|
-
UpdateSubmission(appId, submissionId, data) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
124
|
-
}
|
|
125
|
-
else if (response.statusCode === 409) {
|
|
126
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
127
|
-
}
|
|
128
|
-
else {
|
|
129
|
-
throw console.error(response.statusMessage);
|
|
130
|
-
}
|
|
88
|
+
async UpdateSubmission(appId, submissionId, data) {
|
|
89
|
+
try {
|
|
90
|
+
let auth = await this.authorize();
|
|
91
|
+
// Special Note: carefully read Request Body section in the documentation
|
|
92
|
+
// https://docs.microsoft.com/en-us/windows/uwp/monetize/update-an-app-submission
|
|
93
|
+
const requestUrl = 'https://manage.devcenter.microsoft.com/v1.0/my/applications/{applicationId}/submissions/{submissionId}';
|
|
94
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
95
|
+
method: 'post',
|
|
96
|
+
headers: {
|
|
97
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`,
|
|
98
|
+
ContentType: 'application/json'
|
|
99
|
+
},
|
|
100
|
+
body: converters_1.Convert.submissionDataToJson(data)
|
|
101
|
+
});
|
|
102
|
+
if (response.statusCode == 200) {
|
|
103
|
+
return converters_1.Convert.toUpdateSubmissionResult(response.body);
|
|
104
|
+
}
|
|
105
|
+
else if (response.statusCode === 400) {
|
|
106
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
107
|
+
}
|
|
108
|
+
else if (response.statusCode === 404) {
|
|
109
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
131
110
|
}
|
|
132
|
-
|
|
133
|
-
throw console.error(
|
|
111
|
+
else if (response.statusCode === 409) {
|
|
112
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
134
113
|
}
|
|
135
|
-
|
|
114
|
+
else {
|
|
115
|
+
throw console.error(response.statusMessage);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
throw console.error(err);
|
|
120
|
+
}
|
|
136
121
|
}
|
|
137
|
-
CommitSubmission(appId, submissionId) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
return converters_1.Convert.toCommitSubmissionResult(response.body);
|
|
151
|
-
}
|
|
152
|
-
else if (response.statusCode === 400) {
|
|
153
|
-
throw console.error('400 - The request parameters are invalid.');
|
|
154
|
-
}
|
|
155
|
-
else if (response.statusCode === 404) {
|
|
156
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
157
|
-
}
|
|
158
|
-
else if (response.statusCode === 409) {
|
|
159
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
throw console.error(response.statusMessage);
|
|
163
|
-
}
|
|
122
|
+
async CommitSubmission(appId, submissionId) {
|
|
123
|
+
try {
|
|
124
|
+
let auth = await this.authorize();
|
|
125
|
+
// https://docs.microsoft.com/en-us/windows/uwp/monetize/commit-an-app-submission
|
|
126
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}/submissions/${submissionId}/commit"`;
|
|
127
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
128
|
+
method: 'post',
|
|
129
|
+
headers: {
|
|
130
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
if (response.statusCode == 200) {
|
|
134
|
+
return converters_1.Convert.toCommitSubmissionResult(response.body);
|
|
164
135
|
}
|
|
165
|
-
|
|
166
|
-
throw
|
|
136
|
+
else if (response.statusCode === 400) {
|
|
137
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
167
138
|
}
|
|
168
|
-
|
|
139
|
+
else if (response.statusCode === 404) {
|
|
140
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
141
|
+
}
|
|
142
|
+
else if (response.statusCode === 409) {
|
|
143
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
throw console.error(response.statusMessage);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
catch (err) {
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
169
152
|
}
|
|
170
153
|
// https://docs.microsoft.com/en-us/windows/uwp/monetize/get-an-app-submission
|
|
171
|
-
GetSubmission(appId, submissionId) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
190
|
-
}
|
|
191
|
-
else if (response.statusCode === 409) {
|
|
192
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
throw console.error(response.statusMessage);
|
|
196
|
-
}
|
|
154
|
+
async GetSubmission(appId, submissionId) {
|
|
155
|
+
try {
|
|
156
|
+
let auth = await this.authorize();
|
|
157
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}/submissions/${submissionId}"`;
|
|
158
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
159
|
+
method: 'post',
|
|
160
|
+
headers: {
|
|
161
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
if (response.statusCode == 200) {
|
|
165
|
+
return converters_1.Convert.toGetSubmissionResult(response.body);
|
|
166
|
+
}
|
|
167
|
+
else if (response.statusCode === 400) {
|
|
168
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
169
|
+
}
|
|
170
|
+
else if (response.statusCode === 404) {
|
|
171
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
197
172
|
}
|
|
198
|
-
|
|
199
|
-
throw console.error(
|
|
173
|
+
else if (response.statusCode === 409) {
|
|
174
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
200
175
|
}
|
|
201
|
-
|
|
176
|
+
else {
|
|
177
|
+
throw console.error(response.statusMessage);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
catch (err) {
|
|
181
|
+
throw console.error(err);
|
|
182
|
+
}
|
|
202
183
|
}
|
|
203
184
|
// https://docs.microsoft.com/en-us/windows/uwp/monetize/get-status-for-an-app-submission
|
|
204
|
-
GetSubmissionStatus(appId, submissionId) {
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
223
|
-
}
|
|
224
|
-
else if (response.statusCode === 409) {
|
|
225
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
226
|
-
}
|
|
227
|
-
else {
|
|
228
|
-
throw console.error(response.statusMessage);
|
|
229
|
-
}
|
|
185
|
+
async GetSubmissionStatus(appId, submissionId) {
|
|
186
|
+
try {
|
|
187
|
+
let auth = await this.authorize();
|
|
188
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}/submissions/${submissionId}/status"`;
|
|
189
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
190
|
+
method: 'get',
|
|
191
|
+
headers: {
|
|
192
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (response.statusCode == 200) {
|
|
196
|
+
return converters_1.Convert.toSubmissionStatusResult(response.body);
|
|
197
|
+
}
|
|
198
|
+
else if (response.statusCode === 400) {
|
|
199
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
200
|
+
}
|
|
201
|
+
else if (response.statusCode === 404) {
|
|
202
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
230
203
|
}
|
|
231
|
-
|
|
232
|
-
throw console.error(
|
|
204
|
+
else if (response.statusCode === 409) {
|
|
205
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
233
206
|
}
|
|
234
|
-
|
|
207
|
+
else {
|
|
208
|
+
throw console.error(response.statusMessage);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
catch (err) {
|
|
212
|
+
throw console.error(err);
|
|
213
|
+
}
|
|
235
214
|
}
|
|
236
215
|
// https://docs.microsoft.com/en-us/windows/uwp/monetize/delete-an-app-submission
|
|
237
|
-
DeleteSubmission(appId, submissionId) {
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
throw console.error('400 - The request parameters are invalid.');
|
|
253
|
-
}
|
|
254
|
-
else if (response.statusCode === 404) {
|
|
255
|
-
throw console.error('404 - The specified submission could not be found.');
|
|
256
|
-
}
|
|
257
|
-
else if (response.statusCode === 409) {
|
|
258
|
-
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
259
|
-
}
|
|
260
|
-
else {
|
|
261
|
-
return false;
|
|
262
|
-
}
|
|
216
|
+
async DeleteSubmission(appId, submissionId) {
|
|
217
|
+
try {
|
|
218
|
+
let auth = await this.authorize();
|
|
219
|
+
const requestUrl = `"https://manage.devcenter.microsoft.com/v1.0/my/applications/${appId}/submissions/${submissionId}"`;
|
|
220
|
+
const response = await (0, got_1.default)(requestUrl, {
|
|
221
|
+
method: 'post',
|
|
222
|
+
headers: {
|
|
223
|
+
Authorization: `"${auth.token_type} ${auth.access_token}"`
|
|
224
|
+
}
|
|
225
|
+
});
|
|
226
|
+
if (response.statusCode == 200) {
|
|
227
|
+
return true;
|
|
228
|
+
}
|
|
229
|
+
else if (response.statusCode === 400) {
|
|
230
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
263
231
|
}
|
|
264
|
-
|
|
265
|
-
throw console.error(
|
|
232
|
+
else if (response.statusCode === 404) {
|
|
233
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
266
234
|
}
|
|
267
|
-
|
|
235
|
+
else if (response.statusCode === 409) {
|
|
236
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (err) {
|
|
243
|
+
throw console.error(err);
|
|
244
|
+
}
|
|
268
245
|
}
|
|
269
|
-
authorize() {
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
needsNewToken = true;
|
|
276
|
-
}
|
|
277
|
-
else if (Number(this.authResult.expires_on) < new Date('1970-01-01T0:0:0Z').getSeconds()) {
|
|
278
|
-
// If the previous authentication has expired.
|
|
279
|
-
needsNewToken = true;
|
|
280
|
-
}
|
|
281
|
-
if (needsNewToken) {
|
|
282
|
-
this.authResult = yield this.signin();
|
|
283
|
-
}
|
|
284
|
-
if (this.authResult == null) {
|
|
285
|
-
throw new Error('You could not be authenticated, double check the TenantID, ClientID and ClientSecret. See readme for more info.');
|
|
286
|
-
}
|
|
287
|
-
else {
|
|
288
|
-
return this.authResult;
|
|
289
|
-
}
|
|
246
|
+
async authorize() {
|
|
247
|
+
try {
|
|
248
|
+
let needsNewToken = false;
|
|
249
|
+
if (this.authResult == undefined) {
|
|
250
|
+
// First time authentication.
|
|
251
|
+
needsNewToken = true;
|
|
290
252
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
253
|
+
else if (Number(this.authResult.expires_on) < new Date('1970-01-01T0:0:0Z').getSeconds()) {
|
|
254
|
+
// If the previous authentication has expired.
|
|
255
|
+
needsNewToken = true;
|
|
256
|
+
}
|
|
257
|
+
if (needsNewToken) {
|
|
258
|
+
this.authResult = await this.signin();
|
|
259
|
+
}
|
|
260
|
+
if (this.authResult == null) {
|
|
261
|
+
throw new Error('You could not be authenticated, double check the TenantID, ClientID and ClientSecret. See readme for more info.');
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
return this.authResult;
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
catch (ex1) {
|
|
268
|
+
try {
|
|
269
|
+
const error = ex1;
|
|
270
|
+
if (error.statusCode === 401) {
|
|
271
|
+
// If we got a 401 during a call, we need to get a new token anyways.
|
|
272
|
+
this.authResult = await this.signin();
|
|
273
|
+
if (this.authResult == null) {
|
|
274
|
+
throw new Error('You could not be authenticated, double check the TenantID, ClientID and ClientSecret. See readme for more info.');
|
|
311
275
|
}
|
|
312
276
|
else {
|
|
313
|
-
|
|
277
|
+
return this.authResult;
|
|
314
278
|
}
|
|
315
279
|
}
|
|
316
|
-
|
|
317
|
-
throw ex;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
// https://docs.microsoft.com/en-us/windows/uwp/monetize/create-and-manage-submissions-using-windows-store-services
|
|
323
|
-
signin() {
|
|
324
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
325
|
-
try {
|
|
326
|
-
const rootUrl = `"https://login.microsoftonline.com/${this.tenantId}/oauth2/token HTTP/1.1`;
|
|
327
|
-
let response = yield got_1.default(rootUrl, {
|
|
328
|
-
method: 'post',
|
|
329
|
-
headers: {
|
|
330
|
-
'content-type': 'application/x-www-form-urlencoded'
|
|
331
|
-
},
|
|
332
|
-
body: querystring_1.default.stringify({
|
|
333
|
-
grant_type: 'client_credentials',
|
|
334
|
-
resource: 'https://manage.devcenter.microsoft.com',
|
|
335
|
-
client_id: this.clientId,
|
|
336
|
-
client_secret: this.clientSecret
|
|
337
|
-
})
|
|
338
|
-
});
|
|
339
|
-
if (response.statusCode == 200) {
|
|
340
|
-
return converters_1.Convert.toServiceAuthenticationResult(response.body);
|
|
341
|
-
}
|
|
342
|
-
else if (response.statusCode === 400) {
|
|
280
|
+
else if (error.statusCode === 400) {
|
|
343
281
|
throw console.error('400 - The request parameters are invalid.');
|
|
344
282
|
}
|
|
345
|
-
else if (
|
|
283
|
+
else if (error.statusCode === 404) {
|
|
346
284
|
throw console.error('404 - The specified submission could not be found.');
|
|
347
285
|
}
|
|
348
|
-
else if (
|
|
286
|
+
else if (error.statusCode === 409) {
|
|
349
287
|
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
350
288
|
}
|
|
351
289
|
else {
|
|
352
|
-
throw console.error(
|
|
290
|
+
throw console.error(error.statusMessage);
|
|
353
291
|
}
|
|
354
292
|
}
|
|
355
|
-
catch (
|
|
356
|
-
throw
|
|
293
|
+
catch (ex2) {
|
|
294
|
+
throw ex2;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
// https://docs.microsoft.com/en-us/windows/uwp/monetize/create-and-manage-submissions-using-windows-store-services
|
|
299
|
+
async signin() {
|
|
300
|
+
try {
|
|
301
|
+
const rootUrl = `"https://login.microsoftonline.com/${this.tenantId}/oauth2/token HTTP/1.1`;
|
|
302
|
+
let response = await (0, got_1.default)(rootUrl, {
|
|
303
|
+
method: 'post',
|
|
304
|
+
headers: {
|
|
305
|
+
'content-type': 'application/x-www-form-urlencoded'
|
|
306
|
+
},
|
|
307
|
+
body: querystring_1.default.stringify({
|
|
308
|
+
grant_type: 'client_credentials',
|
|
309
|
+
resource: 'https://manage.devcenter.microsoft.com',
|
|
310
|
+
client_id: this.clientId,
|
|
311
|
+
client_secret: this.clientSecret
|
|
312
|
+
})
|
|
313
|
+
});
|
|
314
|
+
if (response.statusCode == 200) {
|
|
315
|
+
return converters_1.Convert.toServiceAuthenticationResult(response.body);
|
|
316
|
+
}
|
|
317
|
+
else if (response.statusCode === 400) {
|
|
318
|
+
throw console.error('400 - The request parameters are invalid.');
|
|
319
|
+
}
|
|
320
|
+
else if (response.statusCode === 404) {
|
|
321
|
+
throw console.error('404 - The specified submission could not be found.');
|
|
357
322
|
}
|
|
358
|
-
|
|
323
|
+
else if (response.statusCode === 409) {
|
|
324
|
+
throw console.error('Error 409 - The specified submission was found but it could not be committed in its current state, or the app uses a Partner Center feature that is currently not supported by the Microsoft Store submission API.');
|
|
325
|
+
}
|
|
326
|
+
else {
|
|
327
|
+
throw console.error(response.statusMessage);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
catch (err) {
|
|
331
|
+
throw console.error(err);
|
|
332
|
+
}
|
|
359
333
|
}
|
|
360
334
|
}
|
|
361
335
|
module.exports = DevCenter;
|
package/package.json
CHANGED
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "partner-center-broker",
|
|
3
|
-
"version": "1.1
|
|
3
|
+
"version": "1.2.1",
|
|
4
4
|
"description": "A helper library that lets you manage your Microsoft Partner Center application submissions.",
|
|
5
5
|
"main": "./lib/devCenter.js",
|
|
6
6
|
"types": "./lib/devCenter.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"clean": "rimraf lib",
|
|
9
|
-
"build": "
|
|
10
|
-
"rebuild": "
|
|
9
|
+
"build": "tsc",
|
|
10
|
+
"rebuild": "rimraf lib && tsc",
|
|
11
11
|
"test": "jest",
|
|
12
|
-
"docs": "rimraf ./docs && typedoc src/ --out docs --
|
|
12
|
+
"generate-docs": "rimraf ./docs && typedoc src/ --out docs --excludePrivate",
|
|
13
|
+
"publish-docs": "npm run generate-docs && gh-pages -d docs -t",
|
|
13
14
|
"format-write": "prettier --write **/*.ts",
|
|
14
15
|
"format-check": "prettier --check **/*.ts",
|
|
15
|
-
"prep": "npm run rebuild && npm run format-write",
|
|
16
|
-
"package": "npm run
|
|
17
|
-
"publish": "npm run package && npm publish"
|
|
16
|
+
"prep": "npm run rebuild && npm run format-write && npm run test && npm run generate-docs",
|
|
17
|
+
"package": "npm run prep && npm pack",
|
|
18
|
+
"local-publish": "npm run package && npm publish && npm run publish-docs"
|
|
18
19
|
},
|
|
19
20
|
"repository": {
|
|
20
21
|
"type": "git",
|
|
@@ -47,17 +48,17 @@
|
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
50
|
"@types/got": "^9.6.11",
|
|
50
|
-
"@types/jest": "^
|
|
51
|
-
"@types/node": "^
|
|
52
|
-
"gh-pages": "^
|
|
53
|
-
"jest": "^
|
|
54
|
-
"jest-circus": "^
|
|
55
|
-
"prettier": "^
|
|
56
|
-
"rimraf": "^
|
|
57
|
-
"ts-jest": "^
|
|
51
|
+
"@types/jest": "^29.5.0",
|
|
52
|
+
"@types/node": "^20.0.0",
|
|
53
|
+
"gh-pages": "^6.0.0",
|
|
54
|
+
"jest": "^29.5.0",
|
|
55
|
+
"jest-circus": "^29.5.0",
|
|
56
|
+
"prettier": "^3.0.0",
|
|
57
|
+
"rimraf": "^5.0.0",
|
|
58
|
+
"ts-jest": "^29.1.0",
|
|
58
59
|
"tslint": "^6.1.3",
|
|
59
60
|
"tslint-config-standard": "^9.0.0",
|
|
60
|
-
"typedoc": "^0.
|
|
61
|
-
"typescript": "^
|
|
61
|
+
"typedoc": "^0.24.0",
|
|
62
|
+
"typescript": "^5.0.0"
|
|
62
63
|
}
|
|
63
64
|
}
|