@salesforce/packaging 5.0.9-spi.2 → 5.0.9-spi.4
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.
|
@@ -170,6 +170,15 @@ export type PackageTrustLinkRequestResult = {
|
|
|
170
170
|
VerifiedOrgId: string;
|
|
171
171
|
Status: string;
|
|
172
172
|
};
|
|
173
|
+
export type PackageTrustLinkStatusResult = {
|
|
174
|
+
Status: string;
|
|
175
|
+
linked: boolean;
|
|
176
|
+
LinkRequestId?: string;
|
|
177
|
+
VerifiedOrgId?: string;
|
|
178
|
+
RequestedDate?: string;
|
|
179
|
+
EstablishedDate?: string;
|
|
180
|
+
RevokedDate?: string;
|
|
181
|
+
};
|
|
173
182
|
/** CLI --status values for `sf package trust link list` (PBO-admin). */
|
|
174
183
|
export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
|
|
175
184
|
/** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
|
|
@@ -184,6 +193,16 @@ export type PackageTrustLinkRecord = {
|
|
|
184
193
|
EstablishedDate: string | null;
|
|
185
194
|
RevokedDate: string | null;
|
|
186
195
|
};
|
|
196
|
+
export type PackageTrustLinkApproveOptions = {
|
|
197
|
+
requestId?: string;
|
|
198
|
+
authoringOrgId?: string;
|
|
199
|
+
};
|
|
200
|
+
export type PackageTrustLinkApproveResult = {
|
|
201
|
+
LinkRequestId: string;
|
|
202
|
+
AuthoringOrgId: string;
|
|
203
|
+
VerifiedOrgId: string;
|
|
204
|
+
Status: 'Accepted';
|
|
205
|
+
};
|
|
187
206
|
export type PackageTrustLinkUnlinkResult = {
|
|
188
207
|
removed: boolean;
|
|
189
208
|
LinkRequestId?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
2
|
+
import { PackageTrustLinkApproveOptions, PackageTrustLinkApproveResult, PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
3
3
|
export declare class PackageTrustLink {
|
|
4
4
|
constructor();
|
|
5
5
|
/**
|
|
@@ -14,6 +14,18 @@ export declare class PackageTrustLink {
|
|
|
14
14
|
* @returns the created trust relationship Id, verified org ID, and status.
|
|
15
15
|
*/
|
|
16
16
|
static request(connection: Connection, options: PackageTrustLinkRequestOptions): Promise<PackageTrustLinkRequestResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Report the connected authoring org's Public Secure (VerifiedDev) trust link state.
|
|
19
|
+
*
|
|
20
|
+
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
21
|
+
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
22
|
+
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
23
|
+
* state when the org has no link at all. It never mutates anything.
|
|
24
|
+
*
|
|
25
|
+
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
26
|
+
* @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
|
|
27
|
+
*/
|
|
28
|
+
static status(connection: Connection): Promise<PackageTrustLinkStatusResult>;
|
|
17
29
|
/**
|
|
18
30
|
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
19
31
|
*
|
|
@@ -22,6 +34,14 @@ export declare class PackageTrustLink {
|
|
|
22
34
|
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
23
35
|
*/
|
|
24
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>;
|
|
25
45
|
/**
|
|
26
46
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
27
47
|
* `Not Linked` state.
|
|
@@ -16,6 +16,7 @@ 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})?$/;
|
|
19
20
|
const isStatusFilter = (status) => Object.prototype.hasOwnProperty.call(STATUS_FILTER_TO_API, status);
|
|
20
21
|
const toApiStatus = (status) => {
|
|
21
22
|
if (!isStatusFilter(status)) {
|
|
@@ -23,6 +24,9 @@ const toApiStatus = (status) => {
|
|
|
23
24
|
}
|
|
24
25
|
return STATUS_FILTER_TO_API[status];
|
|
25
26
|
};
|
|
27
|
+
// The absence of a trust link record is a valid state the CLI reports; the SObject Status
|
|
28
|
+
// picklist itself only covers the states an existing link can be in.
|
|
29
|
+
const NOT_LINKED = 'Not Linked';
|
|
26
30
|
class PackageTrustLink {
|
|
27
31
|
constructor() { }
|
|
28
32
|
/**
|
|
@@ -66,6 +70,36 @@ class PackageTrustLink {
|
|
|
66
70
|
Status: 'Pending',
|
|
67
71
|
};
|
|
68
72
|
}
|
|
73
|
+
/**
|
|
74
|
+
* Report the connected authoring org's Public Secure (VerifiedDev) trust link state.
|
|
75
|
+
*
|
|
76
|
+
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
77
|
+
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
78
|
+
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
79
|
+
* state when the org has no link at all. It never mutates anything.
|
|
80
|
+
*
|
|
81
|
+
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
82
|
+
* @returns the current link state and, when a link exists, its Id, verified org ID, and timestamps.
|
|
83
|
+
*/
|
|
84
|
+
static async status(connection) {
|
|
85
|
+
// The Tooling API query runs against the connected authoring org (AuthoringOrg is server-set),
|
|
86
|
+
// so this returns that org's own link if any. No record means the org was never linked.
|
|
87
|
+
const existing = await queryExistingTrustLink(connection);
|
|
88
|
+
if (!existing) {
|
|
89
|
+
return { Status: NOT_LINKED, linked: false };
|
|
90
|
+
}
|
|
91
|
+
// Only surface timestamps that are actually set — a Pending link has no EstablishedDate, and
|
|
92
|
+
// only a Revoked link has a RevokedDate. Emitting undefined keys would leak nulls into --json.
|
|
93
|
+
return {
|
|
94
|
+
Status: existing.Status,
|
|
95
|
+
linked: true,
|
|
96
|
+
LinkRequestId: existing.Id,
|
|
97
|
+
VerifiedOrgId: existing.VerifiedOrg,
|
|
98
|
+
...(existing.CreatedDate ? { RequestedDate: existing.CreatedDate } : {}),
|
|
99
|
+
...(existing.EstablishedDate ? { EstablishedDate: existing.EstablishedDate } : {}),
|
|
100
|
+
...(existing.RevokedDate ? { RevokedDate: existing.RevokedDate } : {}),
|
|
101
|
+
};
|
|
102
|
+
}
|
|
69
103
|
/**
|
|
70
104
|
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
71
105
|
*
|
|
@@ -99,6 +133,68 @@ class PackageTrustLink {
|
|
|
99
133
|
RevokedDate: RevokedDate ?? null,
|
|
100
134
|
}));
|
|
101
135
|
}
|
|
136
|
+
/**
|
|
137
|
+
* Approve a pending Public Secure (VerifiedDev) trust-link request for the connected Verified PBO.
|
|
138
|
+
*
|
|
139
|
+
* @param connection - Connection to the Verified Partner Business Org (PBO).
|
|
140
|
+
* @param options - Exactly one request ID or authoring org ID identifying the pending request.
|
|
141
|
+
* @returns the accepted trust relationship details.
|
|
142
|
+
*/
|
|
143
|
+
static async approve(connection, options) {
|
|
144
|
+
if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
|
|
145
|
+
throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
|
|
146
|
+
}
|
|
147
|
+
if (Boolean(options.requestId) === Boolean(options.authoringOrgId)) {
|
|
148
|
+
throw messages.createError('exactlyOneApproveSelector');
|
|
149
|
+
}
|
|
150
|
+
const orgId = connection.getAuthInfoFields()?.orgId;
|
|
151
|
+
if (!orgId) {
|
|
152
|
+
throw messages.createError('missingOrgId');
|
|
153
|
+
}
|
|
154
|
+
const verifiedOrgId = (0, core_1.trimTo15)(orgId);
|
|
155
|
+
let selector;
|
|
156
|
+
let selectorValue;
|
|
157
|
+
if (options.requestId) {
|
|
158
|
+
if (!options.requestId.startsWith('2vt') ||
|
|
159
|
+
!SALESFORCE_ID_PATTERN.test(options.requestId) ||
|
|
160
|
+
!(0, core_1.validateSalesforceId)(options.requestId)) {
|
|
161
|
+
throw messages.createError('invalidTrustLinkRequestId', [options.requestId]);
|
|
162
|
+
}
|
|
163
|
+
selector = `Id = '${options.requestId}'`;
|
|
164
|
+
selectorValue = options.requestId;
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const authoringOrgId = options.authoringOrgId;
|
|
168
|
+
if (!authoringOrgId.startsWith('00D') ||
|
|
169
|
+
!SALESFORCE_ID_PATTERN.test(authoringOrgId) ||
|
|
170
|
+
!(0, core_1.validateSalesforceId)(authoringOrgId)) {
|
|
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
|
+
};
|
|
197
|
+
}
|
|
102
198
|
/**
|
|
103
199
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
104
200
|
* `Not Linked` state.
|
|
@@ -132,7 +228,7 @@ class PackageTrustLink {
|
|
|
132
228
|
}
|
|
133
229
|
exports.PackageTrustLink = PackageTrustLink;
|
|
134
230
|
async function queryExistingTrustLink(connection) {
|
|
135
|
-
const query = `SELECT Id, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
231
|
+
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
136
232
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
137
233
|
return result.records?.[0];
|
|
138
234
|
}
|
|
@@ -18,6 +18,22 @@ 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
|
+
|
|
21
37
|
# trustLinkNotFound
|
|
22
38
|
|
|
23
39
|
This org has no trust link to remove; it's already in the Not Linked state.
|