@salesforce/packaging 5.0.9-spi.3 → 5.0.9-spi.5
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.
|
@@ -193,6 +193,31 @@ export type PackageTrustLinkRecord = {
|
|
|
193
193
|
EstablishedDate: string | null;
|
|
194
194
|
RevokedDate: string | null;
|
|
195
195
|
};
|
|
196
|
+
export type PackageTrustLinkSelectorOptions = {
|
|
197
|
+
requestId?: string;
|
|
198
|
+
authoringOrgId?: string;
|
|
199
|
+
};
|
|
200
|
+
export type PackageTrustLinkApproveOptions = PackageTrustLinkSelectorOptions;
|
|
201
|
+
export type PackageTrustLinkDenyOptions = PackageTrustLinkSelectorOptions;
|
|
202
|
+
export type PackageTrustLinkRevokeOptions = PackageTrustLinkSelectorOptions;
|
|
203
|
+
export type PackageTrustLinkApproveResult = {
|
|
204
|
+
LinkRequestId: string;
|
|
205
|
+
AuthoringOrgId: string;
|
|
206
|
+
VerifiedOrgId: string;
|
|
207
|
+
Status: 'Accepted';
|
|
208
|
+
};
|
|
209
|
+
export type PackageTrustLinkDenyResult = {
|
|
210
|
+
LinkRequestId: string;
|
|
211
|
+
AuthoringOrgId: string;
|
|
212
|
+
VerifiedOrgId: string;
|
|
213
|
+
Status: 'Declined';
|
|
214
|
+
};
|
|
215
|
+
export type PackageTrustLinkRevokeResult = {
|
|
216
|
+
LinkRequestId: string;
|
|
217
|
+
AuthoringOrgId: string;
|
|
218
|
+
VerifiedOrgId: string;
|
|
219
|
+
Status: 'Revoked';
|
|
220
|
+
};
|
|
196
221
|
export type PackageTrustLinkUnlinkResult = {
|
|
197
222
|
removed: boolean;
|
|
198
223
|
LinkRequestId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { 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
|
/**
|
|
@@ -34,6 +34,36 @@ export declare class PackageTrustLink {
|
|
|
34
34
|
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
35
35
|
*/
|
|
36
36
|
static list(connection: Connection, status?: PackageTrustLinkListStatusFilter): Promise<PackageTrustLinkRecord[]>;
|
|
37
|
+
/**
|
|
38
|
+
* Approve a pending Public Secure (VerifiedDev) trust-link request for the connected Verified PBO.
|
|
39
|
+
*
|
|
40
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
41
|
+
* @param options - Exactly one request ID or authoring org ID identifying the pending request.
|
|
42
|
+
* @returns the accepted trust relationship details.
|
|
43
|
+
*/
|
|
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>;
|
|
37
67
|
/**
|
|
38
68
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
39
69
|
* `Not Linked` state.
|
|
@@ -132,6 +132,42 @@ class PackageTrustLink {
|
|
|
132
132
|
RevokedDate: RevokedDate ?? null,
|
|
133
133
|
}));
|
|
134
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Approve a pending Public Secure (VerifiedDev) trust-link request for the connected Verified PBO.
|
|
137
|
+
*
|
|
138
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
139
|
+
* @param options - Exactly one request ID or authoring org ID identifying the pending request.
|
|
140
|
+
* @returns the accepted trust relationship details.
|
|
141
|
+
*/
|
|
142
|
+
static async approve(connection, options) {
|
|
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');
|
|
170
|
+
}
|
|
135
171
|
/**
|
|
136
172
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
137
173
|
* `Not Linked` state.
|
|
@@ -164,6 +200,57 @@ class PackageTrustLink {
|
|
|
164
200
|
}
|
|
165
201
|
}
|
|
166
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
|
+
}
|
|
167
254
|
async function queryExistingTrustLink(connection) {
|
|
168
255
|
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
169
256
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
@@ -18,6 +18,26 @@ Unable to determine the target org ID from the current connection.
|
|
|
18
18
|
|
|
19
19
|
The status %s is invalid. Valid values are: pending, approved, declined, revoked.
|
|
20
20
|
|
|
21
|
+
# exactlyOneApproveSelector
|
|
22
|
+
|
|
23
|
+
Specify exactly one trust link selector: a request ID or an authoring org ID.
|
|
24
|
+
|
|
25
|
+
# invalidTrustLinkRequestId
|
|
26
|
+
|
|
27
|
+
The trust link request ID %s isn't valid. Specify a valid 15- or 18-character Salesforce ID and retry the command.
|
|
28
|
+
|
|
29
|
+
# invalidAuthoringOrgId
|
|
30
|
+
|
|
31
|
+
The Authoring Org ID %s isn't valid. Specify a valid organization ID (starts with 00D and is 15 or 18 characters) and retry the command.
|
|
32
|
+
|
|
33
|
+
# pendingTrustLinkNotFound
|
|
34
|
+
|
|
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
|
+
|
|
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
|
+
|
|
21
41
|
# trustLinkNotFound
|
|
22
42
|
|
|
23
43
|
This org has no trust link to remove; it's already in the Not Linked state.
|