@salesforce/packaging 5.0.9-spi.1 → 5.0.9-spi.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.
|
@@ -170,14 +170,19 @@ export type PackageTrustLinkRequestResult = {
|
|
|
170
170
|
VerifiedOrgId: string;
|
|
171
171
|
Status: string;
|
|
172
172
|
};
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
173
|
+
/** CLI --status values for `sf package trust link list` (PBO-admin). */
|
|
174
|
+
export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
|
|
175
|
+
/** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
|
|
176
|
+
export type PackageTrustLinkStatus = 'Pending' | 'Accepted' | 'Declined' | 'Revoked' | 'Failed';
|
|
177
|
+
export type PackageTrustLinkRecord = {
|
|
178
|
+
Id: string;
|
|
179
|
+
AuthoringOrg: string;
|
|
180
|
+
VerifiedOrg: string;
|
|
181
|
+
Status: PackageTrustLinkStatus;
|
|
182
|
+
RequestedBy: string | null;
|
|
183
|
+
CreatedDate: string;
|
|
184
|
+
EstablishedDate: string | null;
|
|
185
|
+
RevokedDate: string | null;
|
|
181
186
|
};
|
|
182
187
|
export type PackageTrustLinkUnlinkResult = {
|
|
183
188
|
removed: boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult,
|
|
2
|
+
import { PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
3
3
|
export declare class PackageTrustLink {
|
|
4
4
|
constructor();
|
|
5
5
|
/**
|
|
@@ -15,17 +15,13 @@ export declare class PackageTrustLink {
|
|
|
15
15
|
*/
|
|
16
16
|
static request(connection: Connection, options: PackageTrustLinkRequestOptions): Promise<PackageTrustLinkRequestResult>;
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
19
19
|
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
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.
|
|
20
|
+
* Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
|
|
21
|
+
* self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
|
|
22
|
+
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
27
23
|
*/
|
|
28
|
-
static
|
|
24
|
+
static list(connection: Connection, status?: PackageTrustLinkListStatusFilter): Promise<PackageTrustLinkRecord[]>;
|
|
29
25
|
/**
|
|
30
26
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
31
27
|
* `Not Linked` state.
|
|
@@ -8,9 +8,21 @@ const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_
|
|
|
8
8
|
// Tooling API SObject backing the VerifiedDev (Public Secure) org-level trust relationship
|
|
9
9
|
// between the connected authoring org and a Verified PBO. See W-23970567 / SPI CLI design doc.
|
|
10
10
|
const TRUST_LINK_SOBJECT = 'PkgVrfyAuthOrgTrustRela';
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const
|
|
11
|
+
const MINIMUM_API_VERSION = '68.0';
|
|
12
|
+
const ORGANIZATION_TYPE_VERIFIED = 'Verified';
|
|
13
|
+
const STATUS_FILTER_TO_API = {
|
|
14
|
+
pending: 'Pending',
|
|
15
|
+
approved: 'Accepted',
|
|
16
|
+
declined: 'Declined',
|
|
17
|
+
revoked: 'Revoked',
|
|
18
|
+
};
|
|
19
|
+
const isStatusFilter = (status) => Object.prototype.hasOwnProperty.call(STATUS_FILTER_TO_API, status);
|
|
20
|
+
const toApiStatus = (status) => {
|
|
21
|
+
if (!isStatusFilter(status)) {
|
|
22
|
+
throw messages.createError('invalidStatus', [status]);
|
|
23
|
+
}
|
|
24
|
+
return STATUS_FILTER_TO_API[status];
|
|
25
|
+
};
|
|
14
26
|
class PackageTrustLink {
|
|
15
27
|
constructor() { }
|
|
16
28
|
/**
|
|
@@ -55,34 +67,37 @@ class PackageTrustLink {
|
|
|
55
67
|
};
|
|
56
68
|
}
|
|
57
69
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* Read-only developer/authoring-org side operation. An authoring org holds at most one trust
|
|
61
|
-
* relationship, so this returns that org's link if one exists — its status (`Pending`, `Accepted`,
|
|
62
|
-
* `Declined`, `Revoked`, or `Failed`) and the relevant timestamps — or the synthetic `Not Linked`
|
|
63
|
-
* state when the org has no link at all. It never mutates anything.
|
|
70
|
+
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
64
71
|
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
72
|
+
* Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
|
|
73
|
+
* self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
|
|
74
|
+
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
67
75
|
*/
|
|
68
|
-
static async
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const existing = await queryExistingTrustLink(connection);
|
|
72
|
-
if (!existing) {
|
|
73
|
-
return { Status: NOT_LINKED, linked: false };
|
|
76
|
+
static async list(connection, status) {
|
|
77
|
+
if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
|
|
78
|
+
throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
|
|
74
79
|
}
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
80
|
+
const orgId = connection.getAuthInfoFields()?.orgId;
|
|
81
|
+
if (!orgId) {
|
|
82
|
+
throw messages.createError('missingOrgId');
|
|
83
|
+
}
|
|
84
|
+
const verifiedOrgId = (0, core_1.trimTo15)(orgId);
|
|
85
|
+
const statusFilter = status ? toApiStatus(status) : undefined;
|
|
86
|
+
const statusClause = statusFilter ? ` AND Status = '${statusFilter}'` : '';
|
|
87
|
+
const query = 'SELECT Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate FROM ' +
|
|
88
|
+
`${TRUST_LINK_SOBJECT} WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
|
|
89
|
+
`AND AuthoringOrg != '${verifiedOrgId}'${statusClause} ORDER BY CreatedDate DESC`;
|
|
90
|
+
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
91
|
+
return (result.records ?? []).map(({ Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate }) => ({
|
|
92
|
+
Id,
|
|
93
|
+
AuthoringOrg,
|
|
94
|
+
VerifiedOrg,
|
|
95
|
+
Status,
|
|
96
|
+
RequestedBy: RequestedBy ?? null,
|
|
97
|
+
CreatedDate,
|
|
98
|
+
EstablishedDate: EstablishedDate ?? null,
|
|
99
|
+
RevokedDate: RevokedDate ?? null,
|
|
100
|
+
}));
|
|
86
101
|
}
|
|
87
102
|
/**
|
|
88
103
|
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
@@ -117,7 +132,7 @@ class PackageTrustLink {
|
|
|
117
132
|
}
|
|
118
133
|
exports.PackageTrustLink = PackageTrustLink;
|
|
119
134
|
async function queryExistingTrustLink(connection) {
|
|
120
|
-
const query = `SELECT Id, VerifiedOrg, Status
|
|
135
|
+
const query = `SELECT Id, VerifiedOrg, Status FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
121
136
|
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
122
137
|
return result.records?.[0];
|
|
123
138
|
}
|
|
@@ -6,6 +6,18 @@ The Verified Org ID %s isn't valid. Specify a valid organization ID (starts with
|
|
|
6
6
|
|
|
7
7
|
This org already has a trust link to Verified Org %s with status '%s'. An org can have only one trust link at a time; delete the existing trust link before requesting a new one.
|
|
8
8
|
|
|
9
|
+
# apiVersionTooLow
|
|
10
|
+
|
|
11
|
+
Package link requires API version %s or later.
|
|
12
|
+
|
|
13
|
+
# missingOrgId
|
|
14
|
+
|
|
15
|
+
Unable to determine the target org ID from the current connection.
|
|
16
|
+
|
|
17
|
+
# invalidStatus
|
|
18
|
+
|
|
19
|
+
The status %s is invalid. Valid values are: pending, approved, declined, revoked.
|
|
20
|
+
|
|
9
21
|
# trustLinkNotFound
|
|
10
22
|
|
|
11
23
|
This org has no trust link to remove; it's already in the Not Linked state.
|