@cubist-labs/cubesigner-sdk 0.4.209 → 0.4.217
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/dist/package.json +1 -1
- package/dist/src/acl.d.ts +12 -0
- package/dist/src/acl.d.ts.map +1 -0
- package/dist/src/acl.js +3 -0
- package/dist/src/client/api_client.d.ts +24 -6
- package/dist/src/client/api_client.d.ts.map +1 -1
- package/dist/src/client/api_client.js +40 -14
- package/dist/src/client/base_client.d.ts +1 -0
- package/dist/src/client/base_client.d.ts.map +1 -1
- package/dist/src/client/base_client.js +1 -1
- package/dist/src/contact.d.ts +9 -1
- package/dist/src/contact.d.ts.map +1 -1
- package/dist/src/contact.js +14 -1
- package/dist/src/evm/index.d.ts +7 -0
- package/dist/src/evm/index.d.ts.map +1 -1
- package/dist/src/evm/index.js +28 -29
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +3 -1
- package/dist/src/org.d.ts +60 -19
- package/dist/src/org.d.ts.map +1 -1
- package/dist/src/org.js +82 -25
- package/dist/src/policy.d.ts +109 -35
- package/dist/src/policy.d.ts.map +1 -1
- package/dist/src/policy.js +88 -42
- package/dist/src/schema.d.ts +158 -16
- package/dist/src/schema.d.ts.map +1 -1
- package/dist/src/schema.js +1 -1
- package/dist/src/schema_types.d.ts +12 -2
- package/dist/src/schema_types.d.ts.map +1 -1
- package/dist/src/schema_types.js +1 -1
- package/dist/src/scopes.d.ts.map +1 -1
- package/dist/src/scopes.js +2 -1
- package/package.json +1 -1
- package/src/acl.ts +13 -0
- package/src/client/api_client.ts +54 -12
- package/src/client/base_client.ts +1 -1
- package/src/contact.ts +16 -1
- package/src/evm/index.ts +4 -4
- package/src/index.ts +2 -0
- package/src/org.ts +118 -31
- package/src/policy.ts +144 -49
- package/src/schema.ts +184 -25
- package/src/schema_types.ts +14 -3
- package/src/scopes.ts +1 -0
package/src/client/api_client.ts
CHANGED
|
@@ -58,6 +58,8 @@ import type {
|
|
|
58
58
|
DiffieHellmanRequest,
|
|
59
59
|
DiffieHellmanResponse,
|
|
60
60
|
KeyInfoJwt,
|
|
61
|
+
ContactLabel,
|
|
62
|
+
ContactAddressData,
|
|
61
63
|
} from "../schema_types";
|
|
62
64
|
import { encodeToBase64 } from "../util";
|
|
63
65
|
import {
|
|
@@ -983,7 +985,7 @@ export class ApiClient extends BaseClient {
|
|
|
983
985
|
|
|
984
986
|
// #endregion
|
|
985
987
|
|
|
986
|
-
// #region ORG CONTACTS: contactCreate, contactGet, contactsList, contactDelete, contactUpdate
|
|
988
|
+
// #region ORG CONTACTS: contactCreate, contactGet, contactsList, contactDelete, contactUpdate, contactLookupByAddress
|
|
987
989
|
|
|
988
990
|
/**
|
|
989
991
|
* Creates a new contact in the organization-wide address book. The
|
|
@@ -994,6 +996,7 @@ export class ApiClient extends BaseClient {
|
|
|
994
996
|
* @param addresses The addresses associated with the contact.
|
|
995
997
|
* @param metadata Metadata associated with the contact. Intended for use as a description.
|
|
996
998
|
* @param editPolicy The edit policy for the contact, determining when and who can edit this contact.
|
|
999
|
+
* @param labels The optional labels for the contact.
|
|
997
1000
|
* @returns The newly created contact.
|
|
998
1001
|
*/
|
|
999
1002
|
async contactCreate(
|
|
@@ -1001,6 +1004,7 @@ export class ApiClient extends BaseClient {
|
|
|
1001
1004
|
addresses?: AddressMap,
|
|
1002
1005
|
metadata?: JsonValue,
|
|
1003
1006
|
editPolicy?: EditPolicy,
|
|
1007
|
+
labels?: ContactLabel[],
|
|
1004
1008
|
): Promise<ContactInfo> {
|
|
1005
1009
|
const o = op("/v0/org/{org_id}/contacts", "post");
|
|
1006
1010
|
return this.exec(o, {
|
|
@@ -1009,6 +1013,7 @@ export class ApiClient extends BaseClient {
|
|
|
1009
1013
|
addresses,
|
|
1010
1014
|
metadata,
|
|
1011
1015
|
edit_policy: editPolicy,
|
|
1016
|
+
labels,
|
|
1012
1017
|
},
|
|
1013
1018
|
});
|
|
1014
1019
|
}
|
|
@@ -1030,20 +1035,43 @@ export class ApiClient extends BaseClient {
|
|
|
1030
1035
|
/**
|
|
1031
1036
|
* Lists contacts in the org.
|
|
1032
1037
|
*
|
|
1033
|
-
* @param page The optional pagination options. Defaults to getting every
|
|
1038
|
+
* @param page The optional pagination options. Defaults to getting every page.
|
|
1039
|
+
* @param search The optional search query. Either `label:...`, which will
|
|
1040
|
+
* return contacts with the label provided after the ':'; or an address
|
|
1041
|
+
* search, where all returned contacts will have an address starting with, or
|
|
1042
|
+
* equalling, the given search string.
|
|
1034
1043
|
* @returns Paginator for iterating over the contacts in the org.
|
|
1035
1044
|
*/
|
|
1036
|
-
contactsList(
|
|
1045
|
+
contactsList(
|
|
1046
|
+
page?: PageOpts,
|
|
1047
|
+
search?: `label:${ContactLabel}` | string,
|
|
1048
|
+
): Paginator<ListContactsResponse, ContactInfo[]> {
|
|
1037
1049
|
const o = op("/v0/org/{org_id}/contacts", "get");
|
|
1038
1050
|
|
|
1039
1051
|
return Paginator.items(
|
|
1040
1052
|
page ?? Page.default(),
|
|
1041
|
-
(
|
|
1053
|
+
(pageQuery) => this.exec(o, { params: { query: { search, ...pageQuery } } }),
|
|
1042
1054
|
(r) => r.contacts,
|
|
1043
1055
|
(r) => r.last_evaluated_key,
|
|
1044
1056
|
);
|
|
1045
1057
|
}
|
|
1046
1058
|
|
|
1059
|
+
/**
|
|
1060
|
+
* Returns all contacts in the org that have the given address.
|
|
1061
|
+
*
|
|
1062
|
+
* When querying with an EVM address without a chain, this endpoint returns
|
|
1063
|
+
* contacts with that address on *any* EVM chain, including those without a chain
|
|
1064
|
+
* defined.
|
|
1065
|
+
*
|
|
1066
|
+
* @param address The address all returned contacts must have.
|
|
1067
|
+
* @returns Contacts in the org with that address.
|
|
1068
|
+
*/
|
|
1069
|
+
async contactLookupByAddress(address: ContactAddressData): Promise<ContactInfo[]> {
|
|
1070
|
+
const o = op("/v0/org/{org_id}/contacts/by-address", "post");
|
|
1071
|
+
|
|
1072
|
+
return (await this.exec(o, { body: address })).contacts;
|
|
1073
|
+
}
|
|
1074
|
+
|
|
1047
1075
|
/**
|
|
1048
1076
|
* Delete a contact, specified by its ID.
|
|
1049
1077
|
*
|
|
@@ -1366,21 +1394,24 @@ export class ApiClient extends BaseClient {
|
|
|
1366
1394
|
* @param name The name of the policy.
|
|
1367
1395
|
* @param type The type of the policy.
|
|
1368
1396
|
* @param rules The policy rules.
|
|
1397
|
+
* @param acl Optional list of policy access control entries.
|
|
1369
1398
|
* @returns The the new policy's info.
|
|
1370
1399
|
*/
|
|
1371
1400
|
async policyCreate(
|
|
1372
1401
|
name: string,
|
|
1373
1402
|
type: PolicyType,
|
|
1374
1403
|
rules: KeyPolicy | RolePolicy | { hash: string }[],
|
|
1404
|
+
acl?: JsonValue[],
|
|
1375
1405
|
): Promise<PolicyInfo> {
|
|
1376
1406
|
const o = op("/v0/org/{org_id}/policies", "post");
|
|
1377
|
-
return await this.exec(o, {
|
|
1407
|
+
return (await this.exec(o, {
|
|
1378
1408
|
body: {
|
|
1379
1409
|
name,
|
|
1380
1410
|
policy_type: type,
|
|
1381
1411
|
rules,
|
|
1412
|
+
acl,
|
|
1382
1413
|
},
|
|
1383
|
-
});
|
|
1414
|
+
})) as PolicyInfo;
|
|
1384
1415
|
}
|
|
1385
1416
|
|
|
1386
1417
|
/**
|
|
@@ -1392,25 +1423,29 @@ export class ApiClient extends BaseClient {
|
|
|
1392
1423
|
*/
|
|
1393
1424
|
async policyGet(policyId: string, version: policy.Version): Promise<PolicyInfo> {
|
|
1394
1425
|
const o = op("/v0/org/{org_id}/policies/{policy_id}/{version}", "get");
|
|
1395
|
-
return this.exec(o, {
|
|
1426
|
+
return (await this.exec(o, {
|
|
1396
1427
|
params: { path: { policy_id: policyId, version } },
|
|
1397
|
-
});
|
|
1428
|
+
})) as PolicyInfo;
|
|
1398
1429
|
}
|
|
1399
1430
|
|
|
1400
1431
|
/**
|
|
1401
1432
|
* List all named policies in the org.
|
|
1402
1433
|
*
|
|
1403
1434
|
* @param page Pagination options. Defaults to fetching the entire result set.
|
|
1435
|
+
* @param policyType The optional type of policies to fetch. Defaults to fetching all named policies regardless of type.
|
|
1404
1436
|
* @returns Paginator for iterating over policies.
|
|
1405
1437
|
*/
|
|
1406
|
-
policiesList(
|
|
1438
|
+
policiesList(
|
|
1439
|
+
page?: PageOpts,
|
|
1440
|
+
policyType?: PolicyType,
|
|
1441
|
+
): Paginator<ListPoliciesResponse, PolicyInfo[]> {
|
|
1407
1442
|
const o = op("/v0/org/{org_id}/policies", "get");
|
|
1408
1443
|
return Paginator.items(
|
|
1409
1444
|
page ?? Page.default(),
|
|
1410
|
-
(
|
|
1445
|
+
(pageQuery) => this.exec(o, { params: { query: { policy_type: policyType, ...pageQuery } } }),
|
|
1411
1446
|
(r) => r.policies,
|
|
1412
1447
|
(r) => r.last_evaluated_key,
|
|
1413
|
-
)
|
|
1448
|
+
) as Paginator<ListPoliciesResponse, PolicyInfo[]>;
|
|
1414
1449
|
}
|
|
1415
1450
|
|
|
1416
1451
|
/**
|
|
@@ -1433,7 +1468,11 @@ export class ApiClient extends BaseClient {
|
|
|
1433
1468
|
body: request,
|
|
1434
1469
|
headers,
|
|
1435
1470
|
});
|
|
1436
|
-
return await CubeSignerResponse.create(
|
|
1471
|
+
return (await CubeSignerResponse.create(
|
|
1472
|
+
this.env,
|
|
1473
|
+
signFn,
|
|
1474
|
+
mfaReceipt,
|
|
1475
|
+
)) as CubeSignerResponse<PolicyInfo>;
|
|
1437
1476
|
}
|
|
1438
1477
|
|
|
1439
1478
|
/**
|
|
@@ -1526,6 +1565,7 @@ export class ApiClient extends BaseClient {
|
|
|
1526
1565
|
});
|
|
1527
1566
|
return signerSessionFromSessionInfo(this.sessionMeta, data, {
|
|
1528
1567
|
purpose,
|
|
1568
|
+
org_id: this.orgId,
|
|
1529
1569
|
});
|
|
1530
1570
|
}
|
|
1531
1571
|
|
|
@@ -1563,6 +1603,7 @@ export class ApiClient extends BaseClient {
|
|
|
1563
1603
|
return mapResponse(resp, (sessionInfo) =>
|
|
1564
1604
|
signerSessionFromSessionInfo(this.sessionMeta, sessionInfo, {
|
|
1565
1605
|
purpose,
|
|
1606
|
+
org_id: this.orgId,
|
|
1566
1607
|
}),
|
|
1567
1608
|
);
|
|
1568
1609
|
};
|
|
@@ -1600,6 +1641,7 @@ export class ApiClient extends BaseClient {
|
|
|
1600
1641
|
|
|
1601
1642
|
return signerSessionFromSessionInfo(this.sessionMeta, data, {
|
|
1602
1643
|
role_id: roleId,
|
|
1644
|
+
org_id: this.orgId,
|
|
1603
1645
|
purpose,
|
|
1604
1646
|
});
|
|
1605
1647
|
}
|
|
@@ -259,7 +259,7 @@ export class BaseClient extends EventEmitter<ClientEvents> {
|
|
|
259
259
|
export function signerSessionFromSessionInfo(
|
|
260
260
|
meta: SessionMetadata,
|
|
261
261
|
info: NewSessionResponse,
|
|
262
|
-
ctx: Partial<{ purpose: string; role_id: string }>,
|
|
262
|
+
ctx: Partial<{ purpose: string; role_id: string; org_id: string }>,
|
|
263
263
|
): SessionData {
|
|
264
264
|
return {
|
|
265
265
|
env: meta.env,
|
package/src/contact.ts
CHANGED
|
@@ -9,7 +9,7 @@ import type {
|
|
|
9
9
|
UpdateContactRequest,
|
|
10
10
|
} from ".";
|
|
11
11
|
import { CubeSignerClient } from ".";
|
|
12
|
-
import type { ContactInfo } from "./schema_types";
|
|
12
|
+
import type { ContactInfo, ContactLabel } from "./schema_types";
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* A representation of a contact within an org.
|
|
@@ -91,6 +91,21 @@ export class Contact {
|
|
|
91
91
|
await this.update({ owner });
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @returns The latest labels associated with the contact, if any
|
|
96
|
+
*/
|
|
97
|
+
async labels(): Promise<ContactLabel[] | undefined> {
|
|
98
|
+
const data = await this.fetch();
|
|
99
|
+
return data.labels;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* @param labels The new labels that the contact should hold
|
|
104
|
+
*/
|
|
105
|
+
async setLabels(labels: ContactLabel[]) {
|
|
106
|
+
await this.update({ labels });
|
|
107
|
+
}
|
|
108
|
+
|
|
94
109
|
/**
|
|
95
110
|
* Fetches and returns the latest metadata value for the contact. This will be null if there is no metadata defined.
|
|
96
111
|
*
|
package/src/evm/index.ts
CHANGED
|
@@ -87,7 +87,7 @@ export class EvmSigner {
|
|
|
87
87
|
*/
|
|
88
88
|
async signTransaction(req: EvmSignRequest): Promise<string> {
|
|
89
89
|
const res = await this.signEvm(req);
|
|
90
|
-
const data = await this
|
|
90
|
+
const data = await this.handleMfa(res);
|
|
91
91
|
return data.rlp_signed_tx;
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -115,7 +115,7 @@ export class EvmSigner {
|
|
|
115
115
|
async signEip712(req: Eip712SignRequest): Promise<string> {
|
|
116
116
|
const key = await this.key();
|
|
117
117
|
const res = await key.signEip712(req);
|
|
118
|
-
const data = await this
|
|
118
|
+
const data = await this.handleMfa(res);
|
|
119
119
|
return data.signature;
|
|
120
120
|
}
|
|
121
121
|
|
|
@@ -130,7 +130,7 @@ export class EvmSigner {
|
|
|
130
130
|
async signEip191(req: Eip191SignRequest): Promise<string> {
|
|
131
131
|
const key = await this.key();
|
|
132
132
|
const res = await key.signEip191(req);
|
|
133
|
-
const data = await this
|
|
133
|
+
const data = await this.handleMfa(res);
|
|
134
134
|
return data.signature;
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -177,7 +177,7 @@ export class EvmSigner {
|
|
|
177
177
|
* @param res The response of a sign request
|
|
178
178
|
* @returns The sign data after MFA approvals
|
|
179
179
|
*/
|
|
180
|
-
async
|
|
180
|
+
async handleMfa<U>(res: CubeSignerResponse<U>): Promise<U> {
|
|
181
181
|
let mfaId = undefined;
|
|
182
182
|
while ((mfaId = res.mfaId())) {
|
|
183
183
|
await new Promise((resolve) => setTimeout(resolve, this.#options.mfaPollIntervalMs));
|
package/src/index.ts
CHANGED
package/src/org.ts
CHANGED
|
@@ -18,19 +18,22 @@ import type {
|
|
|
18
18
|
AddressMap,
|
|
19
19
|
CreateOrgRequest,
|
|
20
20
|
RolePolicy,
|
|
21
|
-
|
|
21
|
+
C2FConfiguration,
|
|
22
22
|
MfaProtectedAction,
|
|
23
23
|
MfaType,
|
|
24
|
+
PolicyType,
|
|
25
|
+
PolicyAcl,
|
|
26
|
+
ContactLabel,
|
|
27
|
+
ContactAddressData,
|
|
24
28
|
} from ".";
|
|
25
29
|
import { Contact } from "./contact";
|
|
26
|
-
import { Key, MfaRequest, Role } from ".";
|
|
30
|
+
import { C2FFunction, Key, MfaRequest, Role } from ".";
|
|
27
31
|
import {
|
|
28
32
|
type NamedKeyPolicy,
|
|
29
33
|
NamedPolicy,
|
|
30
34
|
type NamedRolePolicy,
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
type WasmPolicyInfo,
|
|
35
|
+
uploadWasmFunction,
|
|
36
|
+
type C2FInfo,
|
|
34
37
|
} from "./policy";
|
|
35
38
|
|
|
36
39
|
/** Options pased to createKey and deriveKey */
|
|
@@ -526,14 +529,16 @@ export class Org {
|
|
|
526
529
|
* @param name The name of the policy.
|
|
527
530
|
* @param type The type of the policy.
|
|
528
531
|
* @param rules The policy rules.
|
|
532
|
+
* @param acl Optional list of policy access control entries.
|
|
529
533
|
* @returns The new policy.
|
|
530
534
|
*/
|
|
531
535
|
async createPolicy<Type extends "Key" | "Role">(
|
|
532
536
|
name: string,
|
|
533
537
|
type: Type,
|
|
534
538
|
rules: Type extends "Key" ? KeyPolicy : RolePolicy,
|
|
539
|
+
acl?: PolicyAcl,
|
|
535
540
|
): Promise<Type extends "Key" ? NamedKeyPolicy : NamedRolePolicy> {
|
|
536
|
-
const policyInfo = await this.#apiClient.policyCreate(name, type, rules);
|
|
541
|
+
const policyInfo = await this.#apiClient.policyCreate(name, type, rules, acl);
|
|
537
542
|
const policy = NamedPolicy.fromInfo(this.#apiClient, policyInfo);
|
|
538
543
|
return policy as Type extends "Key" ? NamedKeyPolicy : NamedRolePolicy;
|
|
539
544
|
}
|
|
@@ -549,47 +554,86 @@ export class Org {
|
|
|
549
554
|
return NamedPolicy.fromInfo(this.#apiClient, policyInfo);
|
|
550
555
|
}
|
|
551
556
|
|
|
557
|
+
/**
|
|
558
|
+
* Get a Confidential Cloud Function by name or named policy ID.
|
|
559
|
+
*
|
|
560
|
+
* @param functionId The name or named policy ID of the function to get.
|
|
561
|
+
* @returns The C2F function.
|
|
562
|
+
* @throws if name or ID is not associated to a C2F function (i.e. the name/id is for a key or role named policy)
|
|
563
|
+
*/
|
|
564
|
+
async getFunction(functionId: string): Promise<C2FFunction> {
|
|
565
|
+
const functionInfo = await this.#apiClient.policyGet(functionId, "latest");
|
|
566
|
+
if (functionInfo.policy_type !== "Wasm") {
|
|
567
|
+
throw new Error(
|
|
568
|
+
`${functionId} is not a Wasm function, it is a ${functionInfo.policy_type} named policy`,
|
|
569
|
+
);
|
|
570
|
+
}
|
|
571
|
+
return new C2FFunction(this.#apiClient, functionInfo as C2FInfo);
|
|
572
|
+
}
|
|
573
|
+
|
|
552
574
|
/**
|
|
553
575
|
* Gets all the named policies in the org.
|
|
554
576
|
*
|
|
555
|
-
* @param page
|
|
577
|
+
* @param page Pagination options. Defaults to fetching the entire result set.
|
|
578
|
+
* @param policyType The optional type of policies to fetch. Defaults to fetching all named policies regardless of type.
|
|
556
579
|
* @returns The policies.
|
|
557
580
|
*/
|
|
558
|
-
async policies(page
|
|
559
|
-
const policies = await this.#apiClient.policiesList(page).fetch();
|
|
581
|
+
async policies(page?: PageOpts, policyType?: PolicyType): Promise<NamedPolicy[]> {
|
|
582
|
+
const policies = await this.#apiClient.policiesList(page, policyType).fetch();
|
|
560
583
|
return policies.map((p) => NamedPolicy.fromInfo(this.#apiClient, p));
|
|
561
584
|
}
|
|
562
585
|
|
|
563
586
|
/**
|
|
564
|
-
*
|
|
587
|
+
* Gets all the C2F functions in the org.
|
|
565
588
|
*
|
|
566
|
-
* @param
|
|
567
|
-
* @
|
|
568
|
-
* @returns The new policy.
|
|
589
|
+
* @param page The paginator options.
|
|
590
|
+
* @returns The C2F functions.
|
|
569
591
|
*/
|
|
570
|
-
async
|
|
571
|
-
const
|
|
572
|
-
|
|
573
|
-
{
|
|
574
|
-
hash,
|
|
575
|
-
},
|
|
576
|
-
]);
|
|
577
|
-
return new NamedWasmPolicy(this.#apiClient, policyInfo as WasmPolicyInfo);
|
|
592
|
+
async functions(page?: PageOpts): Promise<C2FFunction[]> {
|
|
593
|
+
const policies = await this.#apiClient.policiesList(page, "Wasm").fetch();
|
|
594
|
+
return policies.map((data) => new C2FFunction(this.#apiClient, data as C2FInfo));
|
|
578
595
|
}
|
|
579
596
|
|
|
580
|
-
/**
|
|
581
|
-
|
|
597
|
+
/**
|
|
598
|
+
* Create a new Confidential Cloud Function.
|
|
599
|
+
*
|
|
600
|
+
* @param name The name of the function.
|
|
601
|
+
* @param policy The Wasm function.
|
|
602
|
+
* @param acl Optional list of policy access control entries.
|
|
603
|
+
* @returns The C2F function
|
|
604
|
+
*/
|
|
605
|
+
async createWasmFunction(
|
|
606
|
+
name: string,
|
|
607
|
+
policy: Uint8Array,
|
|
608
|
+
acl?: PolicyAcl,
|
|
609
|
+
): Promise<C2FFunction> {
|
|
610
|
+
const hash = await uploadWasmFunction(this.#apiClient, policy);
|
|
611
|
+
const policyInfo = await this.#apiClient.policyCreate(
|
|
612
|
+
name,
|
|
613
|
+
"Wasm",
|
|
614
|
+
[
|
|
615
|
+
{
|
|
616
|
+
hash,
|
|
617
|
+
},
|
|
618
|
+
],
|
|
619
|
+
acl,
|
|
620
|
+
);
|
|
621
|
+
return new C2FFunction(this.#apiClient, policyInfo as C2FInfo);
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
/** @returns the Confidential Cloud Functions configuration for the org. */
|
|
625
|
+
async c2fConfiguration(): Promise<C2FConfiguration | undefined> {
|
|
582
626
|
const data = await this.fetch();
|
|
583
627
|
return data.policy_engine_configuration;
|
|
584
628
|
}
|
|
585
629
|
|
|
586
630
|
/**
|
|
587
|
-
* Set the
|
|
631
|
+
* Set the Confidential Cloud Functions configuration for the org.
|
|
588
632
|
* Note that this overwrites any existing configuration.
|
|
589
633
|
*
|
|
590
|
-
* @param configs
|
|
634
|
+
* @param configs Confidential Cloud Functions configuration.
|
|
591
635
|
*/
|
|
592
|
-
async
|
|
636
|
+
async setC2FConfiguration(configs: C2FConfiguration) {
|
|
593
637
|
await this.update({
|
|
594
638
|
policy_engine_configuration: configs,
|
|
595
639
|
});
|
|
@@ -684,6 +728,7 @@ export class Org {
|
|
|
684
728
|
* @param addresses The addresses associated with the contact.
|
|
685
729
|
* @param metadata Metadata associated with the contact. Intended for use as a description.
|
|
686
730
|
* @param editPolicy The edit policy for the contact, determining when and who can edit this contact.
|
|
731
|
+
* @param labels The optional labels associated with the contact.
|
|
687
732
|
* @returns The newly-created contact.
|
|
688
733
|
*/
|
|
689
734
|
async createContact(
|
|
@@ -691,8 +736,15 @@ export class Org {
|
|
|
691
736
|
addresses?: AddressMap,
|
|
692
737
|
metadata?: JsonValue,
|
|
693
738
|
editPolicy?: EditPolicy,
|
|
739
|
+
labels?: ContactLabel[],
|
|
694
740
|
): Promise<Contact> {
|
|
695
|
-
const contactInfo = await this.#apiClient.contactCreate(
|
|
741
|
+
const contactInfo = await this.#apiClient.contactCreate(
|
|
742
|
+
name,
|
|
743
|
+
addresses,
|
|
744
|
+
metadata,
|
|
745
|
+
editPolicy,
|
|
746
|
+
labels,
|
|
747
|
+
);
|
|
696
748
|
|
|
697
749
|
return new Contact(this.#apiClient, contactInfo);
|
|
698
750
|
}
|
|
@@ -710,13 +762,25 @@ export class Org {
|
|
|
710
762
|
}
|
|
711
763
|
|
|
712
764
|
/**
|
|
713
|
-
* Get all contacts in the organization.
|
|
765
|
+
* Get all contacts in the organization, optionally matching the search query.
|
|
714
766
|
*
|
|
767
|
+
* @param search The optional search query. Either:
|
|
768
|
+
* - `label:...`, which will return contacts with the label provided after the ':',
|
|
769
|
+
* - an exact address search, which returns contacts with the provided ContactAddressData,
|
|
770
|
+
* - or an address prefix search, where all returned contacts will have an address starting with, or equaling, the given search string.
|
|
715
771
|
* @returns All contacts.
|
|
716
772
|
*/
|
|
717
|
-
async contacts(
|
|
718
|
-
|
|
719
|
-
|
|
773
|
+
async contacts(
|
|
774
|
+
search?: `label${ContactLabel}` | ContactAddressData | string,
|
|
775
|
+
): Promise<Contact[]> {
|
|
776
|
+
let contacts;
|
|
777
|
+
|
|
778
|
+
if (search !== undefined && typeof search !== "string") {
|
|
779
|
+
contacts = await this.#apiClient.contactLookupByAddress(search);
|
|
780
|
+
} else {
|
|
781
|
+
const paginator = this.#apiClient.contactsList(undefined, search);
|
|
782
|
+
contacts = await paginator.fetch();
|
|
783
|
+
}
|
|
720
784
|
|
|
721
785
|
return contacts.map((c) => new Contact(this.#apiClient, c));
|
|
722
786
|
}
|
|
@@ -899,4 +963,27 @@ export class Org {
|
|
|
899
963
|
const keys = await this.#apiClient.importKeys(body);
|
|
900
964
|
return keys.map((k) => new Key(this.#apiClient, k));
|
|
901
965
|
}
|
|
966
|
+
|
|
967
|
+
// Backwards compatibility aliases for Named Wasm Policy
|
|
968
|
+
|
|
969
|
+
/**
|
|
970
|
+
* Create a new Wasm policy.
|
|
971
|
+
*
|
|
972
|
+
* @param name The name of the policy.
|
|
973
|
+
* @param policy The Wasm policy object.
|
|
974
|
+
* @param acl Optional list of policy access control entries.
|
|
975
|
+
* @returns The new policy.
|
|
976
|
+
*/
|
|
977
|
+
createWasmPolicy = this.createWasmFunction;
|
|
978
|
+
|
|
979
|
+
/** @returns the Policy Engine configuration for the org. */
|
|
980
|
+
policyEngineConfiguration = this.c2fConfiguration;
|
|
981
|
+
|
|
982
|
+
/**
|
|
983
|
+
* Set the Policy Engine configuration for the org.
|
|
984
|
+
* Note that this overwrites any existing configuration.
|
|
985
|
+
*
|
|
986
|
+
* @param configs The Policy Engine configuration.
|
|
987
|
+
*/
|
|
988
|
+
setPolicyEngineConfiguration = this.setC2FConfiguration;
|
|
902
989
|
}
|