@salesforce/packaging 5.0.9-spi.4 → 5.0.9
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 +0 -68
- package/lib/package/index.d.ts +0 -2
- package/lib/package/index.js +0 -2
- package/lib/package/package.d.ts +0 -6
- package/lib/package/package.js +0 -12
- package/messages/package.md +0 -4
- package/package.json +4 -4
- package/lib/package/packageAuthorization.d.ts +0 -10
- package/lib/package/packageAuthorization.js +0 -85
- package/lib/package/packageTrustLink.d.ts +0 -58
- package/lib/package/packageTrustLink.js +0 -235
- package/messages/package_authorize.md +0 -15
- package/messages/package_trust_link.md +0 -39
|
@@ -38,27 +38,6 @@ export type PackageUpdateOptions = {
|
|
|
38
38
|
AppAnalyticsEnabled?: boolean;
|
|
39
39
|
RecommendedVersionId?: string;
|
|
40
40
|
};
|
|
41
|
-
export type PackageAuthorizationOptions = {
|
|
42
|
-
connection: Connection;
|
|
43
|
-
subscriberPackageId?: string;
|
|
44
|
-
};
|
|
45
|
-
export type PackageAuthorizationRecord = {
|
|
46
|
-
Id: string;
|
|
47
|
-
SubscriberOrg: string;
|
|
48
|
-
SubscriberPackageId: string | null;
|
|
49
|
-
Status: 'Active' | 'Revoked';
|
|
50
|
-
CreatedDate: string;
|
|
51
|
-
CreatedById: string;
|
|
52
|
-
CreatedByUsername: string;
|
|
53
|
-
};
|
|
54
|
-
export type PackageAuthorizationAddResult = {
|
|
55
|
-
Id: string;
|
|
56
|
-
SubscriberOrg: string;
|
|
57
|
-
};
|
|
58
|
-
export type PackageAuthorizationRemoveResult = {
|
|
59
|
-
SubscriberOrg: string;
|
|
60
|
-
removed: boolean;
|
|
61
|
-
};
|
|
62
41
|
export type PackageIdType = 'PackageId' | 'SubscriberPackageVersionId' | 'PackageInstallRequestId' | 'PackageUninstallRequestId';
|
|
63
42
|
export type PackageVersionOptions1GP = Record<string, unknown>;
|
|
64
43
|
export type PackageVersionCreateRequestResult = {
|
|
@@ -162,53 +141,6 @@ export type PackagePushScheduleResult = {
|
|
|
162
141
|
ScheduledStartTime: string | undefined;
|
|
163
142
|
Status: string;
|
|
164
143
|
};
|
|
165
|
-
export type PackageTrustLinkRequestOptions = {
|
|
166
|
-
verifiedOrgId: string;
|
|
167
|
-
};
|
|
168
|
-
export type PackageTrustLinkRequestResult = {
|
|
169
|
-
LinkRequestId: string;
|
|
170
|
-
VerifiedOrgId: string;
|
|
171
|
-
Status: string;
|
|
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
|
-
};
|
|
182
|
-
/** CLI --status values for `sf package trust link list` (PBO-admin). */
|
|
183
|
-
export type PackageTrustLinkListStatusFilter = 'pending' | 'approved' | 'declined' | 'revoked';
|
|
184
|
-
/** Tooling API values for PkgVrfyAuthOrgTrustRela.Status */
|
|
185
|
-
export type PackageTrustLinkStatus = 'Pending' | 'Accepted' | 'Declined' | 'Revoked' | 'Failed';
|
|
186
|
-
export type PackageTrustLinkRecord = {
|
|
187
|
-
Id: string;
|
|
188
|
-
AuthoringOrg: string;
|
|
189
|
-
VerifiedOrg: string;
|
|
190
|
-
Status: PackageTrustLinkStatus;
|
|
191
|
-
RequestedBy: string | null;
|
|
192
|
-
CreatedDate: string;
|
|
193
|
-
EstablishedDate: string | null;
|
|
194
|
-
RevokedDate: string | null;
|
|
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
|
-
};
|
|
206
|
-
export type PackageTrustLinkUnlinkResult = {
|
|
207
|
-
removed: boolean;
|
|
208
|
-
LinkRequestId?: string;
|
|
209
|
-
VerifiedOrgId?: string;
|
|
210
|
-
Status?: string;
|
|
211
|
-
};
|
|
212
144
|
export type PackagePushRequestReportQueryOptions = {
|
|
213
145
|
packagePushRequestId: string;
|
|
214
146
|
};
|
package/lib/package/index.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
export * from './package';
|
|
2
|
-
export * from './packageAuthorization';
|
|
3
2
|
export * from './packageVersion';
|
|
4
3
|
export * from './subscriberPackageVersion';
|
|
5
4
|
export * from './packagePushUpgrade';
|
|
6
|
-
export * from './packageTrustLink';
|
|
7
5
|
export { VersionNumber } from './versionNumber';
|
|
8
6
|
export * from './packageBundle';
|
|
9
7
|
export * from './packageBundleVersion';
|
package/lib/package/index.js
CHANGED
|
@@ -31,11 +31,9 @@ exports.VersionNumber = void 0;
|
|
|
31
31
|
* limitations under the License.
|
|
32
32
|
*/
|
|
33
33
|
__exportStar(require("./package"), exports);
|
|
34
|
-
__exportStar(require("./packageAuthorization"), exports);
|
|
35
34
|
__exportStar(require("./packageVersion"), exports);
|
|
36
35
|
__exportStar(require("./subscriberPackageVersion"), exports);
|
|
37
36
|
__exportStar(require("./packagePushUpgrade"), exports);
|
|
38
|
-
__exportStar(require("./packageTrustLink"), exports);
|
|
39
37
|
var versionNumber_1 = require("./versionNumber");
|
|
40
38
|
Object.defineProperty(exports, "VersionNumber", { enumerable: true, get: function () { return versionNumber_1.VersionNumber; } });
|
|
41
39
|
__exportStar(require("./packageBundle"), exports);
|
package/lib/package/package.d.ts
CHANGED
|
@@ -100,12 +100,6 @@ export declare class Package {
|
|
|
100
100
|
* @returns {string} package ID (0Ho)
|
|
101
101
|
*/
|
|
102
102
|
getId(): string;
|
|
103
|
-
/**
|
|
104
|
-
* Returns the subscriber package ID associated with this package.
|
|
105
|
-
*
|
|
106
|
-
* @returns the subscriber package ID
|
|
107
|
-
*/
|
|
108
|
-
getSubscriberPackageId(): Promise<string>;
|
|
109
103
|
/**
|
|
110
104
|
* Returns the package type of the package.
|
|
111
105
|
*
|
package/lib/package/package.js
CHANGED
|
@@ -194,18 +194,6 @@ class Package {
|
|
|
194
194
|
getId() {
|
|
195
195
|
return this.packageId;
|
|
196
196
|
}
|
|
197
|
-
/**
|
|
198
|
-
* Returns the subscriber package ID associated with this package.
|
|
199
|
-
*
|
|
200
|
-
* @returns the subscriber package ID
|
|
201
|
-
*/
|
|
202
|
-
async getSubscriberPackageId() {
|
|
203
|
-
const packageData = await this.getPackageData();
|
|
204
|
-
if (!packageData?.SubscriberPackageId) {
|
|
205
|
-
throw messages.createError('subscriberPackageIdNotFound', [this.packageId]);
|
|
206
|
-
}
|
|
207
|
-
return packageData.SubscriberPackageId;
|
|
208
|
-
}
|
|
209
197
|
/**
|
|
210
198
|
* Returns the package type of the package.
|
|
211
199
|
*
|
package/messages/package.md
CHANGED
|
@@ -22,10 +22,6 @@ Package alias %s not found in project.
|
|
|
22
22
|
|
|
23
23
|
A package with id %s was not found.
|
|
24
24
|
|
|
25
|
-
# subscriberPackageIdNotFound
|
|
26
|
-
|
|
27
|
-
The subscriber package ID for package %s was not found.
|
|
28
|
-
|
|
29
25
|
# appAnalyticsEnabledApiPriorTo59Error
|
|
30
26
|
|
|
31
27
|
Enabling App Analytics is only possible with API version 59.0 or higher.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/packaging",
|
|
3
|
-
"version": "5.0.9
|
|
3
|
+
"version": "5.0.9",
|
|
4
4
|
"description": "Packaging library for the Salesforce packaging platform",
|
|
5
5
|
"main": "lib/exported",
|
|
6
6
|
"types": "lib/exported.d.ts",
|
|
@@ -42,11 +42,11 @@
|
|
|
42
42
|
"!lib/**/*.map"
|
|
43
43
|
],
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@jsforce/jsforce-node": "^3.10.
|
|
46
|
-
"@salesforce/core": "^9.
|
|
45
|
+
"@jsforce/jsforce-node": "^3.10.24",
|
|
46
|
+
"@salesforce/core": "^9.1.9",
|
|
47
47
|
"@salesforce/kit": "^4.0.0",
|
|
48
48
|
"@salesforce/schemas": "^1.10.3",
|
|
49
|
-
"@salesforce/source-deploy-retrieve": "^13.0
|
|
49
|
+
"@salesforce/source-deploy-retrieve": "^13.3.0",
|
|
50
50
|
"@salesforce/ts-types": "^3.0.1",
|
|
51
51
|
"@salesforce/types": "^1.8.0",
|
|
52
52
|
"fast-xml-parser": "^5.10.1",
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { PackageAuthorizationAddResult, PackageAuthorizationOptions, PackageAuthorizationRecord, PackageAuthorizationRemoveResult } from '../interfaces';
|
|
2
|
-
export declare class PackageAuthorization {
|
|
3
|
-
private readonly connection;
|
|
4
|
-
private readonly subscriberPackageId?;
|
|
5
|
-
constructor(options: PackageAuthorizationOptions);
|
|
6
|
-
add(subscriberOrgs: string[]): Promise<PackageAuthorizationAddResult[]>;
|
|
7
|
-
remove(subscriberOrg: string): Promise<PackageAuthorizationRemoveResult>;
|
|
8
|
-
list(): Promise<PackageAuthorizationRecord[]>;
|
|
9
|
-
private query;
|
|
10
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageAuthorization = void 0;
|
|
4
|
-
const core_1 = require("@salesforce/core");
|
|
5
|
-
const packageUtils_1 = require("../utils/packageUtils");
|
|
6
|
-
const PACKAGE_AUTHORIZATION_SOBJECT = 'PkgAuthOrgSbscrbTrustRela';
|
|
7
|
-
const MINIMUM_API_VERSION = '68.0';
|
|
8
|
-
core_1.Messages.importMessagesDirectory(__dirname);
|
|
9
|
-
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_authorize');
|
|
10
|
-
const normalizeSubscriberOrg = (subscriberOrg) => {
|
|
11
|
-
if (!subscriberOrg.startsWith('00D') || !(0, core_1.validateSalesforceId)(subscriberOrg)) {
|
|
12
|
-
throw messages.createError('invalidSubscriberOrg', [subscriberOrg]);
|
|
13
|
-
}
|
|
14
|
-
return (0, core_1.trimTo15)(subscriberOrg);
|
|
15
|
-
};
|
|
16
|
-
class PackageAuthorization {
|
|
17
|
-
connection;
|
|
18
|
-
subscriberPackageId;
|
|
19
|
-
constructor(options) {
|
|
20
|
-
if (Number(options.connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
|
|
21
|
-
throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
|
|
22
|
-
}
|
|
23
|
-
if (options.subscriberPackageId &&
|
|
24
|
-
(!options.subscriberPackageId.startsWith('033') || !(0, core_1.validateSalesforceId)(options.subscriberPackageId))) {
|
|
25
|
-
throw messages.createError('invalidSubscriberPackage', [options.subscriberPackageId]);
|
|
26
|
-
}
|
|
27
|
-
this.connection = options.connection;
|
|
28
|
-
this.subscriberPackageId = options.subscriberPackageId;
|
|
29
|
-
}
|
|
30
|
-
async add(subscriberOrgs) {
|
|
31
|
-
if (subscriberOrgs.length === 0) {
|
|
32
|
-
throw messages.createError('noSubscriberOrgs');
|
|
33
|
-
}
|
|
34
|
-
const normalizedSubscriberOrgs = subscriberOrgs.map(normalizeSubscriberOrg);
|
|
35
|
-
return normalizedSubscriberOrgs.reduce(async (resultsPromise, subscriberOrg) => {
|
|
36
|
-
const results = await resultsPromise;
|
|
37
|
-
const result = await this.connection.tooling.create(PACKAGE_AUTHORIZATION_SOBJECT, {
|
|
38
|
-
SubscriberOrg: subscriberOrg,
|
|
39
|
-
...(this.subscriberPackageId ? { SubscriberPackageId: this.subscriberPackageId } : {}),
|
|
40
|
-
Status: 'Active',
|
|
41
|
-
});
|
|
42
|
-
if (!result.success || !result.id) {
|
|
43
|
-
throw (0, packageUtils_1.combineSaveErrors)(PACKAGE_AUTHORIZATION_SOBJECT, 'create', result.errors);
|
|
44
|
-
}
|
|
45
|
-
results.push({ Id: result.id, SubscriberOrg: subscriberOrg });
|
|
46
|
-
return results;
|
|
47
|
-
}, Promise.resolve([]));
|
|
48
|
-
}
|
|
49
|
-
async remove(subscriberOrg) {
|
|
50
|
-
const normalizedSubscriberOrg = normalizeSubscriberOrg(subscriberOrg);
|
|
51
|
-
const subscriberPackageFilter = this.subscriberPackageId
|
|
52
|
-
? `SubscriberPackageId = '${this.subscriberPackageId}'`
|
|
53
|
-
: 'SubscriberPackageId = NULL';
|
|
54
|
-
const records = await this.query(`WHERE SubscriberOrg = '${normalizedSubscriberOrg}' AND ${subscriberPackageFilter} LIMIT 1`);
|
|
55
|
-
const record = records[0];
|
|
56
|
-
if (!record) {
|
|
57
|
-
return { SubscriberOrg: normalizedSubscriberOrg, removed: false };
|
|
58
|
-
}
|
|
59
|
-
const result = await this.connection.tooling.sobject(PACKAGE_AUTHORIZATION_SOBJECT).destroy(record.Id);
|
|
60
|
-
if (!result.success) {
|
|
61
|
-
throw (0, packageUtils_1.combineSaveErrors)(PACKAGE_AUTHORIZATION_SOBJECT, 'delete', result.errors);
|
|
62
|
-
}
|
|
63
|
-
return { SubscriberOrg: normalizedSubscriberOrg, removed: true };
|
|
64
|
-
}
|
|
65
|
-
async list() {
|
|
66
|
-
const packageFilter = this.subscriberPackageId ? `WHERE SubscriberPackageId = '${this.subscriberPackageId}' ` : '';
|
|
67
|
-
return this.query(`${packageFilter}ORDER BY SubscriberOrg`);
|
|
68
|
-
}
|
|
69
|
-
async query(whereClause) {
|
|
70
|
-
const query = 'SELECT Id, SubscriberOrg, SubscriberPackageId, Status, CreatedDate, CreatedById, CreatedBy.Username FROM ' +
|
|
71
|
-
`${PACKAGE_AUTHORIZATION_SOBJECT} ${whereClause}`;
|
|
72
|
-
const result = await this.connection.autoFetchQuery(query, { tooling: true });
|
|
73
|
-
return (result.records ?? []).map(({ Id, SubscriberOrg, SubscriberPackageId, Status, CreatedDate, CreatedById, CreatedBy }) => ({
|
|
74
|
-
Id,
|
|
75
|
-
SubscriberOrg,
|
|
76
|
-
SubscriberPackageId,
|
|
77
|
-
Status,
|
|
78
|
-
CreatedDate,
|
|
79
|
-
CreatedById,
|
|
80
|
-
CreatedByUsername: CreatedBy?.Username ?? CreatedById,
|
|
81
|
-
}));
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
exports.PackageAuthorization = PackageAuthorization;
|
|
85
|
-
//# sourceMappingURL=packageAuthorization.js.map
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import { Connection } from '@salesforce/core';
|
|
2
|
-
import { PackageTrustLinkApproveOptions, PackageTrustLinkApproveResult, PackageTrustLinkListStatusFilter, PackageTrustLinkRecord, PackageTrustLinkRequestOptions, PackageTrustLinkRequestResult, PackageTrustLinkStatusResult, PackageTrustLinkUnlinkResult } from '../interfaces';
|
|
3
|
-
export declare class PackageTrustLink {
|
|
4
|
-
constructor();
|
|
5
|
-
/**
|
|
6
|
-
* Request a Public Secure (VerifiedDev) trust link from the connected authoring org to a Verified PBO.
|
|
7
|
-
*
|
|
8
|
-
* Establishes the developer/authoring-org side of the two-way trust handshake by creating a
|
|
9
|
-
* `Pending` trust relationship. A PBO admin approves it separately. This does not change any
|
|
10
|
-
* package's distribution type — trust and enforcement are decoupled.
|
|
11
|
-
*
|
|
12
|
-
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
13
|
-
* @param options - the verified org (PBO) ID to request a trust link to.
|
|
14
|
-
* @returns the created trust relationship Id, verified org ID, and status.
|
|
15
|
-
*/
|
|
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>;
|
|
29
|
-
/**
|
|
30
|
-
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
31
|
-
*
|
|
32
|
-
* Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
|
|
33
|
-
* self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
|
|
34
|
-
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
35
|
-
*/
|
|
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
|
-
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
47
|
-
* `Not Linked` state.
|
|
48
|
-
*
|
|
49
|
-
* Deletes the authoring org's single trust relationship regardless of its current status. This is
|
|
50
|
-
* the developer/authoring-org side operation used both to abandon a request and to retry after a
|
|
51
|
-
* decline (unlink, then request again). It is idempotent: if the org has no trust link, it reports
|
|
52
|
-
* `removed: false` rather than erroring.
|
|
53
|
-
*
|
|
54
|
-
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
55
|
-
* @returns whether a link was removed and, when one existed, its Id, verified org ID, and status.
|
|
56
|
-
*/
|
|
57
|
-
static unlink(connection: Connection): Promise<PackageTrustLinkUnlinkResult>;
|
|
58
|
-
}
|
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.PackageTrustLink = void 0;
|
|
4
|
-
const core_1 = require("@salesforce/core");
|
|
5
|
-
const packageUtils_1 = require("../utils/packageUtils");
|
|
6
|
-
core_1.Messages.importMessagesDirectory(__dirname);
|
|
7
|
-
const messages = core_1.Messages.loadMessages('@salesforce/packaging', 'package_trust_link');
|
|
8
|
-
// Tooling API SObject backing the VerifiedDev (Public Secure) org-level trust relationship
|
|
9
|
-
// between the connected authoring org and a Verified PBO. See W-23970567 / SPI CLI design doc.
|
|
10
|
-
const TRUST_LINK_SOBJECT = 'PkgVrfyAuthOrgTrustRela';
|
|
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 SALESFORCE_ID_PATTERN = /^[a-zA-Z0-9]{15}([a-zA-Z0-9]{3})?$/;
|
|
20
|
-
const isStatusFilter = (status) => Object.prototype.hasOwnProperty.call(STATUS_FILTER_TO_API, status);
|
|
21
|
-
const toApiStatus = (status) => {
|
|
22
|
-
if (!isStatusFilter(status)) {
|
|
23
|
-
throw messages.createError('invalidStatus', [status]);
|
|
24
|
-
}
|
|
25
|
-
return STATUS_FILTER_TO_API[status];
|
|
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';
|
|
30
|
-
class PackageTrustLink {
|
|
31
|
-
constructor() { }
|
|
32
|
-
/**
|
|
33
|
-
* Request a Public Secure (VerifiedDev) trust link from the connected authoring org to a Verified PBO.
|
|
34
|
-
*
|
|
35
|
-
* Establishes the developer/authoring-org side of the two-way trust handshake by creating a
|
|
36
|
-
* `Pending` trust relationship. A PBO admin approves it separately. This does not change any
|
|
37
|
-
* package's distribution type — trust and enforcement are decoupled.
|
|
38
|
-
*
|
|
39
|
-
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
40
|
-
* @param options - the verified org (PBO) ID to request a trust link to.
|
|
41
|
-
* @returns the created trust relationship Id, verified org ID, and status.
|
|
42
|
-
*/
|
|
43
|
-
static async request(connection, options) {
|
|
44
|
-
if (!options.verifiedOrgId.startsWith('00D') || !(0, core_1.validateSalesforceId)(options.verifiedOrgId)) {
|
|
45
|
-
throw messages.createError('invalidVerifiedOrgId', [options.verifiedOrgId]);
|
|
46
|
-
}
|
|
47
|
-
// VerifiedOrg is a TEXT field that core stores as a 15-char ID, so normalize before
|
|
48
|
-
// insert to avoid 18-char mismatches.
|
|
49
|
-
const verifiedOrgId = (0, core_1.trimTo15)(options.verifiedOrgId);
|
|
50
|
-
// An authoring org can hold at most one trust relationship at a time. The Tooling API
|
|
51
|
-
// query below runs against the connected authoring org and only returns that org's own
|
|
52
|
-
// rows (AuthoringOrg is server-set), so any existing row (in any status, to any verified
|
|
53
|
-
// org) blocks a new request until it's deleted (unlinked).
|
|
54
|
-
const existing = await queryExistingTrustLink(connection);
|
|
55
|
-
if (existing) {
|
|
56
|
-
throw messages.createError('trustLinkAlreadyExists', [existing.VerifiedOrg, existing.Status]);
|
|
57
|
-
}
|
|
58
|
-
// Create the trust relationship via the Tooling API. Status is required and must be
|
|
59
|
-
// 'Pending' on create; the PBO admin advances it during the approval handshake.
|
|
60
|
-
const createResult = await connection.tooling.create(TRUST_LINK_SOBJECT, {
|
|
61
|
-
VerifiedOrg: verifiedOrgId,
|
|
62
|
-
Status: 'Pending',
|
|
63
|
-
});
|
|
64
|
-
if (!createResult.success || !createResult.id) {
|
|
65
|
-
throw (0, packageUtils_1.combineSaveErrors)(TRUST_LINK_SOBJECT, 'create', createResult.errors);
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
LinkRequestId: createResult.id,
|
|
69
|
-
VerifiedOrgId: verifiedOrgId,
|
|
70
|
-
Status: 'Pending',
|
|
71
|
-
};
|
|
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
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* List inbound Public Secure trust-link requests for the connected Verified PBO.
|
|
105
|
-
*
|
|
106
|
-
* Queries `PkgVrfyAuthOrgTrustRela` rows where this org is the Verified org, excluding the
|
|
107
|
-
* self-trust record (`AuthoringOrg != VerifiedOrg`). Optional `--status` CLI values map to
|
|
108
|
-
* Tooling statuses (`approved` → `Accepted`). Matches `sf package trust link list`.
|
|
109
|
-
*/
|
|
110
|
-
static async list(connection, status) {
|
|
111
|
-
if (Number(connection.getApiVersion()) < Number(MINIMUM_API_VERSION)) {
|
|
112
|
-
throw messages.createError('apiVersionTooLow', [MINIMUM_API_VERSION]);
|
|
113
|
-
}
|
|
114
|
-
const orgId = connection.getAuthInfoFields()?.orgId;
|
|
115
|
-
if (!orgId) {
|
|
116
|
-
throw messages.createError('missingOrgId');
|
|
117
|
-
}
|
|
118
|
-
const verifiedOrgId = (0, core_1.trimTo15)(orgId);
|
|
119
|
-
const statusFilter = status ? toApiStatus(status) : undefined;
|
|
120
|
-
const statusClause = statusFilter ? ` AND Status = '${statusFilter}'` : '';
|
|
121
|
-
const query = 'SELECT Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate FROM ' +
|
|
122
|
-
`${TRUST_LINK_SOBJECT} WHERE VerifiedOrg = '${verifiedOrgId}' AND OrganizationType = '${ORGANIZATION_TYPE_VERIFIED}' ` +
|
|
123
|
-
`AND AuthoringOrg != '${verifiedOrgId}'${statusClause} ORDER BY CreatedDate DESC`;
|
|
124
|
-
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
125
|
-
return (result.records ?? []).map(({ Id, AuthoringOrg, VerifiedOrg, Status, RequestedBy, CreatedDate, EstablishedDate, RevokedDate }) => ({
|
|
126
|
-
Id,
|
|
127
|
-
AuthoringOrg,
|
|
128
|
-
VerifiedOrg,
|
|
129
|
-
Status,
|
|
130
|
-
RequestedBy: RequestedBy ?? null,
|
|
131
|
-
CreatedDate,
|
|
132
|
-
EstablishedDate: EstablishedDate ?? null,
|
|
133
|
-
RevokedDate: RevokedDate ?? null,
|
|
134
|
-
}));
|
|
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
|
-
}
|
|
198
|
-
/**
|
|
199
|
-
* Clear the connected authoring org's Public Secure (VerifiedDev) trust link, returning it to the
|
|
200
|
-
* `Not Linked` state.
|
|
201
|
-
*
|
|
202
|
-
* Deletes the authoring org's single trust relationship regardless of its current status. This is
|
|
203
|
-
* the developer/authoring-org side operation used both to abandon a request and to retry after a
|
|
204
|
-
* decline (unlink, then request again). It is idempotent: if the org has no trust link, it reports
|
|
205
|
-
* `removed: false` rather than erroring.
|
|
206
|
-
*
|
|
207
|
-
* @param connection - Connection to the authoring org (the 1GP namespace org or 2GP Dev Hub).
|
|
208
|
-
* @returns whether a link was removed and, when one existed, its Id, verified org ID, and status.
|
|
209
|
-
*/
|
|
210
|
-
static async unlink(connection) {
|
|
211
|
-
// An authoring org holds at most one trust relationship, and the Tooling API query runs against
|
|
212
|
-
// the connected org (AuthoringOrg is server-set), so this returns that org's own link if any.
|
|
213
|
-
const existing = await queryExistingTrustLink(connection);
|
|
214
|
-
if (!existing) {
|
|
215
|
-
return { removed: false };
|
|
216
|
-
}
|
|
217
|
-
const deleteResult = await connection.tooling.sobject(TRUST_LINK_SOBJECT).destroy(existing.Id);
|
|
218
|
-
if (!deleteResult.success) {
|
|
219
|
-
throw (0, packageUtils_1.combineSaveErrors)(TRUST_LINK_SOBJECT, 'delete', deleteResult.errors);
|
|
220
|
-
}
|
|
221
|
-
return {
|
|
222
|
-
removed: true,
|
|
223
|
-
LinkRequestId: existing.Id,
|
|
224
|
-
VerifiedOrgId: existing.VerifiedOrg,
|
|
225
|
-
Status: existing.Status,
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
exports.PackageTrustLink = PackageTrustLink;
|
|
230
|
-
async function queryExistingTrustLink(connection) {
|
|
231
|
-
const query = `SELECT Id, VerifiedOrg, Status, EstablishedDate, RevokedDate, CreatedDate FROM ${TRUST_LINK_SOBJECT} LIMIT 1`;
|
|
232
|
-
const result = await connection.autoFetchQuery(query, { tooling: true });
|
|
233
|
-
return result.records?.[0];
|
|
234
|
-
}
|
|
235
|
-
//# sourceMappingURL=packageTrustLink.js.map
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
# invalidSubscriberOrg
|
|
2
|
-
|
|
3
|
-
The subscriber org ID %s is invalid. It must be a 15- or 18-character ID that starts with "00D".
|
|
4
|
-
|
|
5
|
-
# invalidSubscriberPackage
|
|
6
|
-
|
|
7
|
-
The subscriber package ID %s is invalid. It must be a 15- or 18-character ID that starts with "033".
|
|
8
|
-
|
|
9
|
-
# noSubscriberOrgs
|
|
10
|
-
|
|
11
|
-
Provide at least one subscriber org ID.
|
|
12
|
-
|
|
13
|
-
# apiVersionTooLow
|
|
14
|
-
|
|
15
|
-
Package authorization requires API version %s or later.
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
# invalidVerifiedOrgId
|
|
2
|
-
|
|
3
|
-
The Verified Org ID %s isn't valid. Specify a valid organization ID (starts with 00D and is 15 or 18 characters) for the Verified Partner Business Org and retry the command.
|
|
4
|
-
|
|
5
|
-
# trustLinkAlreadyExists
|
|
6
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
# trustLinkNotFound
|
|
38
|
-
|
|
39
|
-
This org has no trust link to remove; it's already in the Not Linked state.
|