@salesforce/packaging 5.0.9-spi.4 → 5.0.9-spi.6
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/lib/interfaces/packagingInterfacesAndType.d.ts +33 -1
- package/lib/interfaces/packagingInterfacesAndType.js +5 -1
- package/lib/interfaces/packagingSObjects.d.ts +2 -1
- package/lib/package/package.js +8 -1
- package/lib/package/packageCreate.d.ts +10 -2
- package/lib/package/packageCreate.js +26 -0
- package/lib/package/packageTrustLink.d.ts +23 -1
- package/lib/package/packageTrustLink.js +78 -54
- package/messages/package.md +8 -0
- package/messages/package_trust_link.md +4 -0
- package/package.json +1 -1
|
@@ -37,6 +37,7 @@ export type PackageUpdateOptions = {
|
|
|
37
37
|
PackageErrorUsername?: string;
|
|
38
38
|
AppAnalyticsEnabled?: boolean;
|
|
39
39
|
RecommendedVersionId?: string;
|
|
40
|
+
DistributionType?: SettableDistributionType;
|
|
40
41
|
};
|
|
41
42
|
export type PackageAuthorizationOptions = {
|
|
42
43
|
connection: Connection;
|
|
@@ -193,16 +194,31 @@ export type PackageTrustLinkRecord = {
|
|
|
193
194
|
EstablishedDate: string | null;
|
|
194
195
|
RevokedDate: string | null;
|
|
195
196
|
};
|
|
196
|
-
export type
|
|
197
|
+
export type PackageTrustLinkSelectorOptions = {
|
|
197
198
|
requestId?: string;
|
|
198
199
|
authoringOrgId?: string;
|
|
199
200
|
};
|
|
201
|
+
export type PackageTrustLinkApproveOptions = PackageTrustLinkSelectorOptions;
|
|
202
|
+
export type PackageTrustLinkDenyOptions = PackageTrustLinkSelectorOptions;
|
|
203
|
+
export type PackageTrustLinkRevokeOptions = PackageTrustLinkSelectorOptions;
|
|
200
204
|
export type PackageTrustLinkApproveResult = {
|
|
201
205
|
LinkRequestId: string;
|
|
202
206
|
AuthoringOrgId: string;
|
|
203
207
|
VerifiedOrgId: string;
|
|
204
208
|
Status: 'Accepted';
|
|
205
209
|
};
|
|
210
|
+
export type PackageTrustLinkDenyResult = {
|
|
211
|
+
LinkRequestId: string;
|
|
212
|
+
AuthoringOrgId: string;
|
|
213
|
+
VerifiedOrgId: string;
|
|
214
|
+
Status: 'Declined';
|
|
215
|
+
};
|
|
216
|
+
export type PackageTrustLinkRevokeResult = {
|
|
217
|
+
LinkRequestId: string;
|
|
218
|
+
AuthoringOrgId: string;
|
|
219
|
+
VerifiedOrgId: string;
|
|
220
|
+
Status: 'Revoked';
|
|
221
|
+
};
|
|
206
222
|
export type PackageTrustLinkUnlinkResult = {
|
|
207
223
|
removed: boolean;
|
|
208
224
|
LinkRequestId?: string;
|
|
@@ -225,6 +241,21 @@ export type Package1Display = {
|
|
|
225
241
|
BuildNumber: number;
|
|
226
242
|
};
|
|
227
243
|
export type PackageType = 'Managed' | 'Unlocked';
|
|
244
|
+
/**
|
|
245
|
+
* The distribution type of a package, controlling install-time security.
|
|
246
|
+
*
|
|
247
|
+
* The Tooling API `Package2.DistributionType` field can hold any of these values, but only
|
|
248
|
+
* `PublicSecure` and `Limited` may be set from the CLI on create/update — `Public` and `Private`
|
|
249
|
+
* are backend-only states (`Public` is the legacy default the backend assigns; `Private` is not yet
|
|
250
|
+
* selectable). See {@link SettableDistributionType} for the CLI-settable subset.
|
|
251
|
+
*/
|
|
252
|
+
export type DistributionType = 'Public' | 'PublicSecure' | 'Limited' | 'Private';
|
|
253
|
+
/** The subset of {@link DistributionType} values a user may set via the CLI on create and update. */
|
|
254
|
+
export type SettableDistributionType = Extract<DistributionType, 'PublicSecure' | 'Limited'>;
|
|
255
|
+
/** The distribution type values a user may set via the CLI on create and update. */
|
|
256
|
+
export declare const SETTABLE_DISTRIBUTION_TYPES: readonly SettableDistributionType[];
|
|
257
|
+
/** Minimum Tooling API version that supports the `Package2.DistributionType` field. */
|
|
258
|
+
export declare const DISTRIBUTION_TYPE_MIN_API_VERSION = "68.0";
|
|
228
259
|
export type PackageCreateOptions = {
|
|
229
260
|
name: string;
|
|
230
261
|
description: string;
|
|
@@ -233,6 +264,7 @@ export type PackageCreateOptions = {
|
|
|
233
264
|
packageType: PackageType;
|
|
234
265
|
errorNotificationUsername: string;
|
|
235
266
|
path: string;
|
|
267
|
+
distributionType?: SettableDistributionType;
|
|
236
268
|
};
|
|
237
269
|
export type PackageDescriptorJson = Partial<NamedPackagingDir> & Partial<{
|
|
238
270
|
id: string;
|
|
@@ -15,10 +15,14 @@
|
|
|
15
15
|
* limitations under the License.
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
-
exports.Package1VersionEvents = exports.PackageVersionEvents = exports.PackageEvents = exports.PackageVersionCreateRequestResultInProgressStatuses = void 0;
|
|
18
|
+
exports.Package1VersionEvents = exports.PackageVersionEvents = exports.PackageEvents = exports.DISTRIBUTION_TYPE_MIN_API_VERSION = exports.SETTABLE_DISTRIBUTION_TYPES = exports.PackageVersionCreateRequestResultInProgressStatuses = void 0;
|
|
19
19
|
const packagingSObjects_1 = require("./packagingSObjects");
|
|
20
20
|
var Package2VersionStatus = packagingSObjects_1.PackagingSObjects.Package2VersionStatus;
|
|
21
21
|
exports.PackageVersionCreateRequestResultInProgressStatuses = Object.values(Package2VersionStatus).filter((status) => !['Queued', 'Success', 'Error'].includes(status));
|
|
22
|
+
/** The distribution type values a user may set via the CLI on create and update. */
|
|
23
|
+
exports.SETTABLE_DISTRIBUTION_TYPES = ['PublicSecure', 'Limited'];
|
|
24
|
+
/** Minimum Tooling API version that supports the `Package2.DistributionType` field. */
|
|
25
|
+
exports.DISTRIBUTION_TYPE_MIN_API_VERSION = '68.0';
|
|
22
26
|
exports.PackageEvents = {
|
|
23
27
|
convert: {
|
|
24
28
|
success: 'Package/convert-success',
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Nullable } from '@salesforce/ts-types';
|
|
2
|
-
import { CodeCoverage, CodeCoveragePercentages, PackageType } from './packagingInterfacesAndType';
|
|
2
|
+
import { CodeCoverage, CodeCoveragePercentages, DistributionType, PackageType } from './packagingInterfacesAndType';
|
|
3
3
|
export declare namespace PackagingSObjects {
|
|
4
4
|
type Package2 = {
|
|
5
5
|
Id: string;
|
|
@@ -20,6 +20,7 @@ export declare namespace PackagingSObjects {
|
|
|
20
20
|
PackageErrorUsername: string;
|
|
21
21
|
AppAnalyticsEnabled?: boolean;
|
|
22
22
|
RecommendedVersionId?: string;
|
|
23
|
+
DistributionType?: DistributionType;
|
|
23
24
|
};
|
|
24
25
|
type Package2Version = {
|
|
25
26
|
Id: string;
|
package/lib/package/package.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Package = exports.Package2Fields = void 0;
|
|
4
4
|
const core_1 = require("@salesforce/core");
|
|
5
5
|
const graphology_1 = require("graphology");
|
|
6
|
+
const interfaces_1 = require("../interfaces");
|
|
6
7
|
const packageUtils_1 = require("../utils/packageUtils");
|
|
7
8
|
const packageCreate_1 = require("./packageCreate");
|
|
8
9
|
const packageConvert_1 = require("./packageConvert");
|
|
@@ -40,6 +41,7 @@ exports.Package2Fields = [
|
|
|
40
41
|
'PackageErrorUsername',
|
|
41
42
|
'AppAnalyticsEnabled',
|
|
42
43
|
'RecommendedVersionId',
|
|
44
|
+
'DistributionType',
|
|
43
45
|
];
|
|
44
46
|
/**
|
|
45
47
|
* Provides the ability to list, create, update, delete, convert, and get version
|
|
@@ -184,7 +186,9 @@ class Package {
|
|
|
184
186
|
}
|
|
185
187
|
static getPackage2Fields(connection) {
|
|
186
188
|
const apiVersion = connection.getApiVersion();
|
|
187
|
-
return exports.Package2Fields.filter((field) => (apiVersion >= '59.0' ? true : field !== 'AppAnalyticsEnabled'))
|
|
189
|
+
return exports.Package2Fields.filter((field) => (apiVersion >= '59.0' ? true : field !== 'AppAnalyticsEnabled'))
|
|
190
|
+
.filter((field) => (apiVersion >= '66.0' ? true : field !== 'RecommendedVersionId'))
|
|
191
|
+
.filter((field) => apiVersion >= interfaces_1.DISTRIBUTION_TYPE_MIN_API_VERSION ? true : field !== 'DistributionType');
|
|
188
192
|
}
|
|
189
193
|
/**
|
|
190
194
|
* Returns the package ID of the package.
|
|
@@ -260,6 +264,9 @@ class Package {
|
|
|
260
264
|
if (opts.RecommendedVersionId !== undefined && this.options.connection.getApiVersion() < '66.0') {
|
|
261
265
|
throw messages.createError('recommendedVersionIdApiPriorTo66Error');
|
|
262
266
|
}
|
|
267
|
+
// Validates the API version and that the value is CLI-settable (PublicSecure/Limited).
|
|
268
|
+
// The backend enforces the allowed state transitions between distribution types on update.
|
|
269
|
+
(0, packageCreate_1.validateDistributionType)(this.options.connection, opts.DistributionType);
|
|
263
270
|
if (opts.RecommendedVersionId !== undefined) {
|
|
264
271
|
const trimmedId = opts.RecommendedVersionId.trim();
|
|
265
272
|
if (trimmedId === '' || !trimmedId.startsWith('04t') || (trimmedId.length !== 15 && trimmedId.length !== 18)) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Connection, SfProject } from '@salesforce/core';
|
|
2
2
|
import { PackagePackageDir } from '@salesforce/schemas';
|
|
3
|
-
import { PackageCreateOptions, PackagingSObjects } from '../interfaces';
|
|
4
|
-
type Package2Request = Pick<PackagingSObjects.Package2, 'Name' | 'Description' | 'NamespacePrefix' | 'ContainerOptions' | 'IsOrgDependent' | 'PackageErrorUsername'>;
|
|
3
|
+
import { PackageCreateOptions, PackagingSObjects, SettableDistributionType } from '../interfaces';
|
|
4
|
+
type Package2Request = Pick<PackagingSObjects.Package2, 'Name' | 'Description' | 'NamespacePrefix' | 'ContainerOptions' | 'IsOrgDependent' | 'PackageErrorUsername' | 'DistributionType'>;
|
|
5
5
|
export declare function createPackageRequestFromContext(project: SfProject, options: PackageCreateOptions): Package2Request;
|
|
6
6
|
/**
|
|
7
7
|
* Create packageDirectory json entry for this package that can be written to sfdx-project.json
|
|
@@ -11,6 +11,14 @@ export declare function createPackageRequestFromContext(project: SfProject, opti
|
|
|
11
11
|
* @private
|
|
12
12
|
*/
|
|
13
13
|
export declare function createPackageDirEntry(project: SfProject, options: PackageCreateOptions): PackagePackageDir;
|
|
14
|
+
/**
|
|
15
|
+
* Validate a user-supplied distribution type: it requires a minimum API version and must be one of
|
|
16
|
+
* the CLI-settable values (`PublicSecure` or `Limited`). `Public` and `Private` are backend-only.
|
|
17
|
+
* A no-op when `distributionType` is undefined (the backend then defaults it by package type).
|
|
18
|
+
*
|
|
19
|
+
* Shared by both create and update so the CLI surfaces the same errors before hitting the API.
|
|
20
|
+
*/
|
|
21
|
+
export declare function validateDistributionType(connection: Connection, distributionType: SettableDistributionType | undefined): void;
|
|
14
22
|
export declare function createPackage(connection: Connection, project: SfProject, options: PackageCreateOptions): Promise<{
|
|
15
23
|
Id: string;
|
|
16
24
|
}>;
|
|
@@ -50,12 +50,16 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
50
50
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
51
51
|
exports.createPackageRequestFromContext = createPackageRequestFromContext;
|
|
52
52
|
exports.createPackageDirEntry = createPackageDirEntry;
|
|
53
|
+
exports.validateDistributionType = validateDistributionType;
|
|
53
54
|
exports.createPackage = createPackage;
|
|
54
55
|
const core_1 = require("@salesforce/core");
|
|
55
56
|
const kit_1 = require("@salesforce/kit");
|
|
56
57
|
const project_1 = require("@salesforce/core/project");
|
|
57
58
|
const pkgUtils = __importStar(require("../utils/packageUtils"));
|
|
58
59
|
const packageUtils_1 = require("../utils/packageUtils");
|
|
60
|
+
const interfaces_1 = require("../interfaces");
|
|
61
|
+
core_1.Messages.importMessagesDirectory(__dirname);
|
|
62
|
+
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package');
|
|
59
63
|
function createPackageRequestFromContext(project, options) {
|
|
60
64
|
const namespace = options.noNamespace ? '' : project.getSfProjectJson().getContents().namespace ?? '';
|
|
61
65
|
return {
|
|
@@ -65,6 +69,9 @@ function createPackageRequestFromContext(project, options) {
|
|
|
65
69
|
ContainerOptions: options.packageType,
|
|
66
70
|
IsOrgDependent: options.orgDependent,
|
|
67
71
|
PackageErrorUsername: options.errorNotificationUsername,
|
|
72
|
+
// Only send DistributionType when the user provided one; otherwise the backend defaults it
|
|
73
|
+
// based on the package type (Managed -> PublicSecure, Unlocked -> Limited).
|
|
74
|
+
...(options.distributionType ? { DistributionType: options.distributionType } : {}),
|
|
68
75
|
};
|
|
69
76
|
}
|
|
70
77
|
/**
|
|
@@ -90,7 +97,26 @@ function createPackageDirEntry(project, options) {
|
|
|
90
97
|
versionDescription: options.description,
|
|
91
98
|
};
|
|
92
99
|
}
|
|
100
|
+
/**
|
|
101
|
+
* Validate a user-supplied distribution type: it requires a minimum API version and must be one of
|
|
102
|
+
* the CLI-settable values (`PublicSecure` or `Limited`). `Public` and `Private` are backend-only.
|
|
103
|
+
* A no-op when `distributionType` is undefined (the backend then defaults it by package type).
|
|
104
|
+
*
|
|
105
|
+
* Shared by both create and update so the CLI surfaces the same errors before hitting the API.
|
|
106
|
+
*/
|
|
107
|
+
function validateDistributionType(connection, distributionType) {
|
|
108
|
+
if (distributionType === undefined) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (connection.getApiVersion() < interfaces_1.DISTRIBUTION_TYPE_MIN_API_VERSION) {
|
|
112
|
+
throw messages.createError('distributionTypeApiPriorTo68Error');
|
|
113
|
+
}
|
|
114
|
+
if (!interfaces_1.SETTABLE_DISTRIBUTION_TYPES.includes(distributionType)) {
|
|
115
|
+
throw messages.createError('invalidDistributionTypeError', [distributionType]);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
93
118
|
async function createPackage(connection, project, options) {
|
|
119
|
+
validateDistributionType(connection, options.distributionType);
|
|
94
120
|
const cleanOptions = sanitizePackageCreateOptions(options);
|
|
95
121
|
const request = createPackageRequestFromContext(project, cleanOptions);
|
|
96
122
|
const createResult = await connection.tooling
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkApproveOptions, PackageTrustLinkApproveResult, PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
2
|
+
import { PackageTrustLinkApproveOptions, PackageTrustLinkApproveResult, PackageTrustLinkDenyOptions, PackageTrustLinkDenyResult, PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkRevokeOptions, PackageTrustLinkRevokeResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
3
3
|
export declare class PackageTrustLink {
|
|
4
4
|
constructor();
|
|
5
5
|
/**
|
|
@@ -42,6 +42,28 @@ export declare class PackageTrustLink {
|
|
|
42
42
|
* @returns the accepted trust relationship details.
|
|
43
43
|
*/
|
|
44
44
|
static approve(connection: Connection, options: PackageTrustLinkApproveOptions): Promise<PackageTrustLinkApproveResult>;
|
|
45
|
+
/**
|
|
46
|
+
* Deny a pending Public Secure (VerifiedDev) trust-link request for the connected Verified PBO.
|
|
47
|
+
*
|
|
48
|
+
* Core only allows Pending → Declined on the verified-org copy. This does not delete the
|
|
49
|
+
* relationship; the authoring org can unlink and request again.
|
|
50
|
+
*
|
|
51
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
52
|
+
* @param options - Exactly one request ID or authoring org ID identifying the pending request.
|
|
53
|
+
* @returns the declined trust relationship details.
|
|
54
|
+
*/
|
|
55
|
+
static deny(connection: Connection, options: PackageTrustLinkDenyOptions): Promise<PackageTrustLinkDenyResult>;
|
|
56
|
+
/**
|
|
57
|
+
* Revoke an accepted Public Secure (VerifiedDev) trust link for the connected Verified PBO.
|
|
58
|
+
*
|
|
59
|
+
* Core only allows Accepted → Revoked on the verified-org copy. Pending requests must be
|
|
60
|
+
* denied instead; already-declined or already-revoked links cannot be revoked again.
|
|
61
|
+
*
|
|
62
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
63
|
+
* @param options - Exactly one request ID or authoring org ID identifying the accepted link.
|
|
64
|
+
* @returns the revoked trust relationship details.
|
|
65
|
+
*/
|
|
66
|
+
static revoke(connection: Connection, options: PackageTrustLinkRevokeOptions): Promise<PackageTrustLinkRevokeResult>;
|
|
45
67
|
/**
|
|
46
68
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
47
69
|
* `Not Linked` state.
|
|
@@ -16,7 +16,6 @@ const STATUS_FILTER_TO_API = {
|
|
|
16
16
|
declined: 'Declined',
|
|
17
17
|
revoked: 'Revoked',
|
|
18
18
|
};
|
|
19
|
-
const SALESFORCE_ID_PATTERN = /^[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?$/;
|
|
20
19
|
const isStatusFilter = (status) => Object.prototype.hasOwnProperty.call(STATUS_FILTER_TO_API, status);
|
|
21
20
|
const toApiStatus = (status) => {
|
|
22
21
|
if (!isStatusFilter(status)) {
|
|
@@ -141,59 +140,33 @@ class PackageTrustLink {
|
|
|
141
140
|
* @returns the accepted trust relationship details.
|
|
142
141
|
*/
|
|
143
142
|
static async approve(connection, options) {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
throw messages.createError('invalidAuthoringOrgId', [authoringOrgId]);
|
|
172
|
-
}
|
|
173
|
-
selector = `AuthoringOrg = '${(0, core_1.trimTo15)(authoringOrgId)}'`;
|
|
174
|
-
selectorValue = authoringOrgId;
|
|
175
|
-
}
|
|
176
|
-
const query = `SELECT Id, AuthoringOrg, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} ` +
|
|
177
|
-
`WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
|
|
178
|
-
`AND AuthoringOrg != '${verifiedOrgId}' AND Status = 'Pending' AND ${selector} ORDER BY CreatedDate DESC LIMIT 1`;
|
|
179
|
-
const queryResult = await connection.autoFetchQuery(query, { tooling: true });
|
|
180
|
-
const pendingRequest = queryResult.records?.[0];
|
|
181
|
-
if (!pendingRequest) {
|
|
182
|
-
throw messages.createError('pendingTrustLinkNotFound', [selectorValue]);
|
|
183
|
-
}
|
|
184
|
-
const updateResult = await connection.tooling.update(TRUST_LINK_SOBJECT, {
|
|
185
|
-
Id: pendingRequest.Id,
|
|
186
|
-
Status: 'Accepted',
|
|
187
|
-
});
|
|
188
|
-
if (!updateResult.success) {
|
|
189
|
-
throw (0, packageUtils_1.combineSaveErrors)(TRUST_LINK_SOBJECT, 'update', updateResult.errors);
|
|
190
|
-
}
|
|
191
|
-
return {
|
|
192
|
-
LinkRequestId: pendingRequest.Id,
|
|
193
|
-
AuthoringOrgId: pendingRequest.AuthoringOrg,
|
|
194
|
-
VerifiedOrgId: pendingRequest.VerifiedOrg,
|
|
195
|
-
Status: 'Accepted',
|
|
196
|
-
};
|
|
143
|
+
return updateInboundTrustLink(connection, options, 'Pending', 'Accepted', 'pendingTrustLinkNotFound');
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Deny a pending Public Secure (VerifiedDev) trust-link request for the connected Verified PBO.
|
|
147
|
+
*
|
|
148
|
+
* Core only allows Pending → Declined on the verified-org copy. This does not delete the
|
|
149
|
+
* relationship; the authoring org can unlink and request again.
|
|
150
|
+
*
|
|
151
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
152
|
+
* @param options - Exactly one request ID or authoring org ID identifying the pending request.
|
|
153
|
+
* @returns the declined trust relationship details.
|
|
154
|
+
*/
|
|
155
|
+
static async deny(connection, options) {
|
|
156
|
+
return updateInboundTrustLink(connection, options, 'Pending', 'Declined', 'pendingTrustLinkNotFound');
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Revoke an accepted Public Secure (VerifiedDev) trust link for the connected Verified PBO.
|
|
160
|
+
*
|
|
161
|
+
* Core only allows Accepted → Revoked on the verified-org copy. Pending requests must be
|
|
162
|
+
* denied instead; already-declined or already-revoked links cannot be revoked again.
|
|
163
|
+
*
|
|
164
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
165
|
+
* @param options - Exactly one request ID or authoring org ID identifying the accepted link.
|
|
166
|
+
* @returns the revoked trust relationship details.
|
|
167
|
+
*/
|
|
168
|
+
static async revoke(connection, options) {
|
|
169
|
+
return updateInboundTrustLink(connection, options, 'Accepted', 'Revoked', 'acceptedTrustLinkNotFound');
|
|
197
170
|
}
|
|
198
171
|
/**
|
|
199
172
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
@@ -227,6 +200,57 @@ class PackageTrustLink {
|
|
|
227
200
|
}
|
|
228
201
|
}
|
|
229
202
|
exports.PackageTrustLink = PackageTrustLink;
|
|
203
|
+
async function updateInboundTrustLink(connection, options, requiredStatus, nextStatus, notFoundMessage) {
|
|
204
|
+
if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
|
|
205
|
+
throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
|
|
206
|
+
}
|
|
207
|
+
if (Boolean(options.requestId) === Boolean(options.authoringOrgId)) {
|
|
208
|
+
throw messages.createError('exactlyOneApproveSelector');
|
|
209
|
+
}
|
|
210
|
+
const orgId = connection.getAuthInfoFields()?.orgId;
|
|
211
|
+
if (!orgId) {
|
|
212
|
+
throw messages.createError('missingOrgId');
|
|
213
|
+
}
|
|
214
|
+
const verifiedOrgId = (0, core_1.trimTo15)(orgId);
|
|
215
|
+
let selector;
|
|
216
|
+
let selectorValue;
|
|
217
|
+
if (options.requestId) {
|
|
218
|
+
if (!options.requestId.startsWith('2vt') || !(0, core_1.validateSalesforceId)(options.requestId)) {
|
|
219
|
+
throw messages.createError('invalidTrustLinkRequestId', [options.requestId]);
|
|
220
|
+
}
|
|
221
|
+
selector = `Id = '${options.requestId}'`;
|
|
222
|
+
selectorValue = options.requestId;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
const authoringOrgId = options.authoringOrgId;
|
|
226
|
+
if (!authoringOrgId.startsWith('00D') || !(0, core_1.validateSalesforceId)(authoringOrgId)) {
|
|
227
|
+
throw messages.createError('invalidAuthoringOrgId', [authoringOrgId]);
|
|
228
|
+
}
|
|
229
|
+
selector = `AuthoringOrg = '${(0, core_1.trimTo15)(authoringOrgId)}'`;
|
|
230
|
+
selectorValue = authoringOrgId;
|
|
231
|
+
}
|
|
232
|
+
const query = `SELECT Id, AuthoringOrg, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} ` +
|
|
233
|
+
`WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
|
|
234
|
+
`AND AuthoringOrg != '${verifiedOrgId}' AND Status = '${requiredStatus}' AND ${selector} ORDER BY CreatedDate DESC LIMIT 1`;
|
|
235
|
+
const queryResult = await connection.autoFetchQuery(query, { tooling: true });
|
|
236
|
+
const matchingRequest = queryResult.records?.[0];
|
|
237
|
+
if (!matchingRequest) {
|
|
238
|
+
throw messages.createError(notFoundMessage, [selectorValue]);
|
|
239
|
+
}
|
|
240
|
+
const updateResult = await connection.tooling.update(TRUST_LINK_SOBJECT, {
|
|
241
|
+
Id: matchingRequest.Id,
|
|
242
|
+
Status: nextStatus,
|
|
243
|
+
});
|
|
244
|
+
if (!updateResult.success) {
|
|
245
|
+
throw (0, packageUtils_1.combineSaveErrors)(TRUST_LINK_SOBJECT, 'update', updateResult.errors);
|
|
246
|
+
}
|
|
247
|
+
return {
|
|
248
|
+
LinkRequestId: matchingRequest.Id,
|
|
249
|
+
AuthoringOrgId: matchingRequest.AuthoringOrg,
|
|
250
|
+
VerifiedOrgId: matchingRequest.VerifiedOrg,
|
|
251
|
+
Status: nextStatus,
|
|
252
|
+
};
|
|
253
|
+
}
|
|
230
254
|
async function queryExistingTrustLink(connection) {
|
|
231
255
|
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
232
256
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
package/messages/package.md
CHANGED
|
@@ -85,3 +85,11 @@ Provide a valid subscriber package version (04t) for the recommended version.
|
|
|
85
85
|
# unassociatedRecommendedVersionError
|
|
86
86
|
|
|
87
87
|
The provided recommended version isn't associated with this package.
|
|
88
|
+
|
|
89
|
+
# distributionTypeApiPriorTo68Error
|
|
90
|
+
|
|
91
|
+
Setting a distribution type is only possible with API version 68.0 or higher.
|
|
92
|
+
|
|
93
|
+
# invalidDistributionTypeError
|
|
94
|
+
|
|
95
|
+
Invalid distribution type "%s". When setting a distribution type from the CLI, the value must be either "PublicSecure" or "Limited".
|
|
@@ -34,6 +34,10 @@ The Authoring Org ID %s isn't valid. Specify a valid organization ID (starts wit
|
|
|
34
34
|
|
|
35
35
|
No pending trust link request matching %s was found for this Verified Org. Run "sf package trust link list --status pending" to review pending requests.
|
|
36
36
|
|
|
37
|
+
# acceptedTrustLinkNotFound
|
|
38
|
+
|
|
39
|
+
No accepted trust link matching %s was found for this Verified Org. Run "sf package trust link list --status approved" to review approved links.
|
|
40
|
+
|
|
37
41
|
# trustLinkNotFound
|
|
38
42
|
|
|
39
43
|
This org has no trust link to remove; it's already in the Not Linked state.
|