@azure-rest/confidential-ledger 1.0.0-beta.2 → 1.0.1-alpha.20220908.1
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/README.md +101 -35
- package/dist/index.js +233 -42
- package/dist/index.js.map +1 -1
- package/dist-esm/src/confidentialLedger.js +15 -7
- package/dist-esm/src/confidentialLedger.js.map +1 -1
- package/dist-esm/src/generated/src/clientDefinitions.js +4 -0
- package/dist-esm/src/generated/src/clientDefinitions.js.map +1 -0
- package/dist-esm/src/generated/src/confidentialLedger.js +13 -5
- package/dist-esm/src/generated/src/confidentialLedger.js.map +1 -1
- package/dist-esm/src/generated/src/index.js +5 -1
- package/dist-esm/src/generated/src/index.js.map +1 -1
- package/dist-esm/src/generated/src/isUnexpected.js +77 -0
- package/dist-esm/src/generated/src/isUnexpected.js.map +1 -0
- package/dist-esm/src/generated/src/models.js.map +1 -1
- package/dist-esm/src/generated/src/outputModels.js +4 -0
- package/dist-esm/src/generated/src/outputModels.js.map +1 -0
- package/dist-esm/src/generated/src/paginateHelper.js +116 -0
- package/dist-esm/src/generated/src/paginateHelper.js.map +1 -0
- package/dist-esm/src/generated/src/parameters.js.map +1 -1
- package/dist-esm/src/generated/src/responses.js.map +1 -1
- package/dist-esm/src/getLedgerIdentity.js +12 -11
- package/dist-esm/src/getLedgerIdentity.js.map +1 -1
- package/dist-esm/src/index.js +4 -0
- package/dist-esm/src/index.js.map +1 -1
- package/package.json +32 -31
- package/types/confidential-ledger.d.ts +322 -190
- package/CHANGELOG.md +0 -5
- package/dist-esm/src/certificatePolicy.browser.js +0 -14
- package/dist-esm/src/certificatePolicy.browser.js.map +0 -1
- package/dist-esm/src/certificatePolicy.js +0 -23
- package/dist-esm/src/certificatePolicy.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,7 +5,12 @@ portfolio, Azure Confidential Ledger runs in SGX enclaves. It is built on Micros
|
|
|
5
5
|
|
|
6
6
|
**Please rely heavily on the [service's documentation][confidential_ledger_docs] and our [Rest client docs][rest_client] to use this library**
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Key links:
|
|
9
|
+
|
|
10
|
+
- [Source code][source_code]
|
|
11
|
+
- [Package (NPM)][confidentialledger_npm]
|
|
12
|
+
- [API reference documentation][ref_docs]
|
|
13
|
+
- [Product documentation][confidential_ledger_docs]
|
|
9
14
|
|
|
10
15
|
## Getting started
|
|
11
16
|
|
|
@@ -31,7 +36,7 @@ npm install @azure-rest/confidential-ledger
|
|
|
31
36
|
|
|
32
37
|
#### Using Azure Active Directory
|
|
33
38
|
|
|
34
|
-
This document demonstrates using [DefaultAzureCredential][default_azure_credential] to authenticate to the Confidential Ledger via Azure Active Directory. However, `ConfidentialLedger` accepts any [@azure/identity][azure_identity_credentials] credential.
|
|
39
|
+
This document demonstrates using [DefaultAzureCredential][default_azure_credential] to authenticate to the Confidential Ledger via Azure Active Directory. You can find the environment variables in the Azure Portal. However, `ConfidentialLedger` accepts any [@azure/identity][azure_identity_credentials] credential.
|
|
35
40
|
|
|
36
41
|
`DefaultAzureCredential` will automatically handle most Azure SDK client scenarios. To get started, set the values of client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`.
|
|
37
42
|
|
|
@@ -42,18 +47,18 @@ Creating the client also requires your Confidential Ledger's URL and id, which y
|
|
|
42
47
|
Because Confidential Ledgers use self-signed certificates securely generated and stored in an enclave, the signing certificate for each Confidential Ledger must first be retrieved from the Confidential Ledger Identity Service.
|
|
43
48
|
|
|
44
49
|
```typescript
|
|
45
|
-
import ConfidentialLedger, { getLedgerIdentity } from "
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
//
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
);
|
|
50
|
+
import ConfidentialLedger, { getLedgerIdentity } from "../../src";
|
|
51
|
+
|
|
52
|
+
const { ledgerIdentityCertificate } = await getLedgerIdentity(
|
|
53
|
+
// for example, test-ledger-name
|
|
54
|
+
LEDGER_IDENTITY,
|
|
55
|
+
// for example, https://identity.confidential-ledger.core.azure.com
|
|
56
|
+
IDENTITY_SERVICE_URL
|
|
57
|
+
);
|
|
58
|
+
const credential = new DefaultAzureCredential();
|
|
59
|
+
|
|
60
|
+
// ENDPOINT example: https://test-ledger-name.confidential-ledger.azure.com
|
|
61
|
+
const ledgerClient = ConfidentialLedger(ENDPOINT, ledgerIdentityCertificate, credential);
|
|
57
62
|
```
|
|
58
63
|
|
|
59
64
|
#### Using a client certificate
|
|
@@ -62,15 +67,23 @@ As an alternative to Azure Active Directory, clients may choose to authenticate
|
|
|
62
67
|
|
|
63
68
|
```typescript
|
|
64
69
|
import ConfidentialLedger, { getLedgerIdentity } from "@azure-rest/confidential-ledger";
|
|
70
|
+
|
|
65
71
|
// Get the signing certificate from the Confidential Ledger Identity Service
|
|
66
|
-
const
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const { ledgerIdentityCertificate } = await getLedgerIdentity(
|
|
73
|
+
LEDGER_IDENTITY,
|
|
74
|
+
IDENTITY_SERVICE_URL
|
|
75
|
+
);
|
|
76
|
+
// both cert (certificate key) and key (private key) are in PEM format
|
|
77
|
+
const cert = PUBLIC_KEY;
|
|
78
|
+
const key = PRIVATE_KEY;
|
|
79
|
+
// Create the Confidential Ledger Client
|
|
80
|
+
// ENDPOINT example: https://test-ledger-name.confidential-ledger.azure.com
|
|
81
|
+
const ledgerClient = ConfidentialLedger(env.ENDPOINT, ledgerIdentityCertificate, {
|
|
82
|
+
tlsOptions: {
|
|
83
|
+
cert,
|
|
84
|
+
key,
|
|
85
|
+
},
|
|
86
|
+
});
|
|
74
87
|
```
|
|
75
88
|
|
|
76
89
|
## Key concepts
|
|
@@ -83,11 +96,11 @@ Every write to Azure Confidential Ledger generates an immutable ledger entry in
|
|
|
83
96
|
|
|
84
97
|
State changes to the Confidential Ledger are saved in a data structure called a Merkle tree. To cryptographically verify that writes were correctly saved, a Merkle proof, or receipt, can be retrieved for any transaction id.
|
|
85
98
|
|
|
86
|
-
###
|
|
99
|
+
### Collections
|
|
87
100
|
|
|
88
|
-
While most use cases will involve one ledger, we provide the
|
|
101
|
+
While most use cases will involve one ledger, we provide the collection feature in case semantically or logically different groups of data need to be stored in the same Confidential Ledger.
|
|
89
102
|
|
|
90
|
-
Ledger entries are retrieved by their
|
|
103
|
+
Ledger entries are retrieved by their collection identifier. The Confidential Ledger will always assume a constant, service-determined collection id for entries submitted without a collection specified.
|
|
91
104
|
|
|
92
105
|
### Users
|
|
93
106
|
|
|
@@ -105,24 +118,77 @@ Azure Confidential Ledger is built on Microsoft Research's open-source [Confiden
|
|
|
105
118
|
|
|
106
119
|
This section contains code snippets for the following samples:
|
|
107
120
|
|
|
121
|
+
- [Post Ledger Entry](#post-ledger-entry "Post Ledger Entry")
|
|
122
|
+
- [Get a Ledger Entry By Transaction Id](#get-a-ledger-entry "Get a Ledger Entry By Transaction Id")
|
|
123
|
+
- [Get All Ledger Entries](#get-all-ledger-entries "Get All Ledger Entries")
|
|
124
|
+
- [Get All Collections](#get-all-collections "Get All Collections")
|
|
125
|
+
- [Get Transactions for a Collection](#transactions-for-collection "Get Transactions for a Collection")
|
|
108
126
|
- [List Enclave Quotes](#list-enclave-quotes "List Enclave Quotes")
|
|
109
127
|
|
|
128
|
+
### Post Ledger Entry
|
|
129
|
+
```typescript
|
|
130
|
+
const entry: LedgerEntry = {
|
|
131
|
+
contents: contentBody,
|
|
132
|
+
};
|
|
133
|
+
const ledgerEntry: CreateLedgerEntryParameters = {
|
|
134
|
+
contentType: "application/json",
|
|
135
|
+
body: entry,
|
|
136
|
+
};
|
|
137
|
+
const result = await client.path("/app/transactions").post(ledgerEntry);
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
### Get a Ledger Entry By Transaction Id
|
|
141
|
+
```typescript
|
|
142
|
+
const status = await client
|
|
143
|
+
.path("/app/transactions/{transactionId}/status", transactionId)
|
|
144
|
+
.get();
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Get All Ledger Entries
|
|
148
|
+
```typescript
|
|
149
|
+
const ledgerEntries = await client.path("/app/transactions");
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
### Get All Collections
|
|
153
|
+
```typescript
|
|
154
|
+
const result = await client.path("/app/collections").get();
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
### Get Transactions for a Collection
|
|
158
|
+
```typescript
|
|
159
|
+
const getLedgerEntriesParams = { queryParameters: { collectionId: "my collection" } };
|
|
160
|
+
const ledgerEntries = await client.path("/app/transactions").get(getLedgerEntriesParams);
|
|
161
|
+
```
|
|
162
|
+
|
|
110
163
|
### List Enclave Quotes
|
|
164
|
+
```typescript
|
|
165
|
+
// Get enclave quotes
|
|
166
|
+
const enclaveQuotes = await confidentialLedger.path("/app/enclaveQuotes").get();
|
|
167
|
+
|
|
168
|
+
// Check for non-success response
|
|
169
|
+
if (enclaveQuotes.status !== "200") {
|
|
170
|
+
throw enclaveQuotes.body.error;
|
|
171
|
+
}
|
|
111
172
|
|
|
173
|
+
// Log all the enclave quotes' nodeId
|
|
174
|
+
Object.keys(enclaveQuotes.body.enclaveQuotes).forEach((key) => {
|
|
175
|
+
console.log(enclaveQuotes.body.enclaveQuotes[key].nodeId);
|
|
176
|
+
});
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### Full Example
|
|
112
180
|
```typescript
|
|
113
181
|
import ConfidentialLedger, { getLedgerIdentity } from "@azure-rest/confidential-ledger";
|
|
114
182
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
115
183
|
|
|
116
184
|
export async function main() {
|
|
117
|
-
console.log("== List Enclave Quotes ==");
|
|
118
|
-
|
|
119
185
|
// Get the signing certificate from the Confidential Ledger Identity Service
|
|
120
186
|
const ledgerIdentity = await getLedgerIdentity("<my-ledger-id>");
|
|
121
187
|
|
|
122
188
|
// Create the Confidential Ledger Client
|
|
123
189
|
const confidentialLedger = ConfidentialLedger(
|
|
124
190
|
"https://<ledger-name>.eastus.cloudapp.azure.com",
|
|
125
|
-
ledgerIdentity.
|
|
191
|
+
ledgerIdentity.ledgerIdentityCertificate,
|
|
126
192
|
new DefaultAzureCredential()
|
|
127
193
|
);
|
|
128
194
|
|
|
@@ -157,15 +223,15 @@ import { setLogLevel } from "@azure/logger";
|
|
|
157
223
|
setLogLevel("info");
|
|
158
224
|
```
|
|
159
225
|
|
|
160
|
-
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/
|
|
226
|
+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
161
227
|
|
|
162
228
|
## Next steps
|
|
163
229
|
|
|
164
|
-
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/
|
|
230
|
+
Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/confidentialledger/confidential-ledger-rest/samples) directory for detailed examples on how to use this library.
|
|
165
231
|
|
|
166
232
|
## Contributing
|
|
167
233
|
|
|
168
|
-
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/
|
|
234
|
+
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
169
235
|
|
|
170
236
|
## Related projects
|
|
171
237
|
|
|
@@ -178,11 +244,11 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
178
244
|
[ccf]: https://github.com/Microsoft/CCF
|
|
179
245
|
[azure_confidential_computing]: https://azure.microsoft.com/solutions/confidential-compute
|
|
180
246
|
[confidential_ledger_docs]: https://aka.ms/confidentialledger-servicedocs
|
|
181
|
-
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/
|
|
182
|
-
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
247
|
+
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md
|
|
248
|
+
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/confidentialledger/confidential-ledger-rest
|
|
183
249
|
[confidentialledger_npm]: https://www.npmjs.com/package/@azure-rest/confidential-ledger
|
|
184
250
|
[ref_docs]: https://azure.github.io/azure-sdk-for-js
|
|
185
251
|
[azure_sub]: https://azure.microsoft.com/free/
|
|
186
|
-
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
187
|
-
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
252
|
+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials
|
|
253
|
+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
|
|
188
254
|
[azure_resource_manager]: https://docs.microsoft.com/azure/azure-resource-manager/management/overview
|
package/dist/index.js
CHANGED
|
@@ -2,67 +2,258 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var coreAuth = require('@azure/core-auth');
|
|
5
6
|
var coreClient = require('@azure-rest/core-client');
|
|
6
|
-
var
|
|
7
|
-
var tslib = require('tslib');
|
|
7
|
+
var corePaging = require('@azure/core-paging');
|
|
8
8
|
|
|
9
9
|
// Copyright (c) Microsoft Corporation.
|
|
10
|
-
function
|
|
11
|
-
// Create default agent and options if they don't exist
|
|
12
|
-
let agentOptions = {
|
|
13
|
-
// Add CA to trust Confidential Ledger self signed certificate
|
|
14
|
-
ca: ledgerTlsCertificate,
|
|
15
|
-
};
|
|
16
|
-
// Add certificate for authentication if one was provided
|
|
17
|
-
if (coreClient.isCertificateCredential(credential)) {
|
|
18
|
-
agentOptions = Object.assign(Object.assign({}, agentOptions), { cert: credential.cert, key: credential.certKey });
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
name: "ledgerTlsCertificatePolicy",
|
|
22
|
-
sendRequest: (request, next) => {
|
|
23
|
-
request.agent = new https.Agent(agentOptions);
|
|
24
|
-
return next(request);
|
|
25
|
-
},
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
// Copyright (c) Microsoft Corporation.
|
|
30
|
-
function ConfidentialLedger(ledgerUri, credentials, options = {}) {
|
|
10
|
+
function createClient(ledgerEndpoint, credentials, options = {}) {
|
|
31
11
|
var _a, _b;
|
|
32
|
-
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${
|
|
33
|
-
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "
|
|
12
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${ledgerEndpoint}`;
|
|
13
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-05-13";
|
|
34
14
|
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
35
|
-
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
15
|
+
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
16
|
+
} });
|
|
17
|
+
const userAgentInfo = `azsdk-js-confidential-ledger-rest/1.0.0`;
|
|
18
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
19
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
20
|
+
: `${userAgentInfo}`;
|
|
21
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
22
|
+
userAgentPrefix
|
|
36
23
|
} });
|
|
37
|
-
|
|
24
|
+
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
25
|
+
return client;
|
|
38
26
|
}
|
|
39
27
|
|
|
40
28
|
// Copyright (c) Microsoft Corporation.
|
|
41
|
-
function ConfidentialLedger
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
29
|
+
function ConfidentialLedger(ledgerEndpoint, ledgerIdentityCertificate, credentialsOrOptions, opts) {
|
|
30
|
+
var _a;
|
|
31
|
+
let credentials;
|
|
32
|
+
let options;
|
|
33
|
+
if (coreAuth.isTokenCredential(credentialsOrOptions)) {
|
|
34
|
+
credentials = credentialsOrOptions;
|
|
35
|
+
options = opts !== null && opts !== void 0 ? opts : {};
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
options = credentialsOrOptions !== null && credentialsOrOptions !== void 0 ? credentialsOrOptions : {};
|
|
39
|
+
}
|
|
40
|
+
const tlsOptions = (_a = options === null || options === void 0 ? void 0 : options.tlsOptions) !== null && _a !== void 0 ? _a : {};
|
|
41
|
+
tlsOptions.ca = ledgerIdentityCertificate;
|
|
42
|
+
const confidentialLedger = createClient(ledgerEndpoint, credentials, Object.assign(Object.assign({}, options), { tlsOptions }));
|
|
46
43
|
return confidentialLedger;
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
// Copyright (c) Microsoft Corporation.
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
// Licensed under the MIT license.
|
|
48
|
+
const responseMap = {
|
|
49
|
+
"GET /app/governance/constitution": ["200"],
|
|
50
|
+
"GET /app/governance/members": ["200"],
|
|
51
|
+
"GET /app/enclaveQuotes": ["200"],
|
|
52
|
+
"GET /app/collections": ["200"],
|
|
53
|
+
"GET /app/transactions": ["200"],
|
|
54
|
+
"POST /app/transactions": ["200"],
|
|
55
|
+
"GET /app/transactions/{transactionId}": ["200"],
|
|
56
|
+
"GET /app/transactions/{transactionId}/receipt": ["200"],
|
|
57
|
+
"GET /app/transactions/{transactionId}/status": ["200"],
|
|
58
|
+
"GET /app/transactions/current": ["200"],
|
|
59
|
+
"DELETE /app/users/{userId}": ["204"],
|
|
60
|
+
"GET /app/users/{userId}": ["200"],
|
|
61
|
+
"PATCH /app/users/{userId}": ["200"]
|
|
62
|
+
};
|
|
63
|
+
function isUnexpected(response) {
|
|
64
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
65
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
66
|
+
const method = response.request.method;
|
|
67
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
68
|
+
if (!pathDetails) {
|
|
69
|
+
pathDetails = geParametrizedPathSuccess(url.pathname);
|
|
70
|
+
}
|
|
71
|
+
return !pathDetails.includes(response.status);
|
|
72
|
+
}
|
|
73
|
+
function geParametrizedPathSuccess(path) {
|
|
74
|
+
const pathParts = path.split("/");
|
|
75
|
+
// Iterate the responseMap to find a match
|
|
76
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
77
|
+
// Extracting the path from the map key which is in format
|
|
78
|
+
// GET /path/foo
|
|
79
|
+
const candidatePath = getPathFromMapKey(key);
|
|
80
|
+
// Get each part of the url path
|
|
81
|
+
const candidateParts = candidatePath.split("/");
|
|
82
|
+
// If the candidate and actual paths don't match in size
|
|
83
|
+
// we move on to the next candidate path
|
|
84
|
+
if (candidateParts.length === pathParts.length &&
|
|
85
|
+
hasParametrizedPath(key)) {
|
|
86
|
+
// track if we have found a match to return the values found.
|
|
87
|
+
let found = true;
|
|
88
|
+
for (let i = 0; i < candidateParts.length; i++) {
|
|
89
|
+
if (candidateParts[i].startsWith("{") &&
|
|
90
|
+
candidateParts[i].endsWith("}")) {
|
|
91
|
+
// If the current part of the candidate is a "template" part
|
|
92
|
+
// it is a match with the actual path part on hand
|
|
93
|
+
// skip as the parameterized part can match anything
|
|
94
|
+
continue;
|
|
95
|
+
}
|
|
96
|
+
// If the candidate part is not a template and
|
|
97
|
+
// the parts don't match mark the candidate as not found
|
|
98
|
+
// to move on with the next candidate path.
|
|
99
|
+
if (candidateParts[i] !== pathParts[i]) {
|
|
100
|
+
found = false;
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
// We finished evaluating the current candidate parts
|
|
105
|
+
// if all parts matched we return the success values form
|
|
106
|
+
// the path mapping.
|
|
107
|
+
if (found) {
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// No match was found, return an empty array.
|
|
113
|
+
return [];
|
|
114
|
+
}
|
|
115
|
+
function hasParametrizedPath(path) {
|
|
116
|
+
return path.includes("/{");
|
|
117
|
+
}
|
|
118
|
+
function getPathFromMapKey(mapKey) {
|
|
119
|
+
const pathStart = mapKey.indexOf("/");
|
|
120
|
+
return mapKey.slice(pathStart);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Copyright (c) Microsoft Corporation.
|
|
124
|
+
/**
|
|
125
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
126
|
+
* @param client - Client to use for sending the next page requests
|
|
127
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
128
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
129
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
130
|
+
*/
|
|
131
|
+
function paginate(client, initialResponse, options = {}) {
|
|
132
|
+
let firstRun = true;
|
|
133
|
+
// We need to check the response for success before trying to inspect it looking for
|
|
134
|
+
// the properties to use for nextLink and itemName
|
|
135
|
+
checkPagingRequest(initialResponse);
|
|
136
|
+
const { itemName, nextLinkName } = getPaginationProperties(initialResponse);
|
|
137
|
+
const { customGetPage } = options;
|
|
138
|
+
const pagedResult = {
|
|
139
|
+
firstPageLink: "",
|
|
140
|
+
getPage: typeof customGetPage === "function"
|
|
141
|
+
? customGetPage
|
|
142
|
+
: async (pageLink) => {
|
|
143
|
+
const result = firstRun
|
|
144
|
+
? initialResponse
|
|
145
|
+
: await client.pathUnchecked(pageLink).get();
|
|
146
|
+
firstRun = false;
|
|
147
|
+
checkPagingRequest(result);
|
|
148
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
149
|
+
const values = getElements(result.body, itemName);
|
|
150
|
+
return {
|
|
151
|
+
page: values,
|
|
152
|
+
nextPageLink: nextLink
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Gets for the value of nextLink in the body
|
|
160
|
+
*/
|
|
161
|
+
function getNextLink(body, nextLinkName) {
|
|
162
|
+
if (!nextLinkName) {
|
|
163
|
+
return undefined;
|
|
164
|
+
}
|
|
165
|
+
const nextLink = body[nextLinkName];
|
|
166
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
167
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
168
|
+
}
|
|
169
|
+
return nextLink;
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* Gets the elements of the current request in the body.
|
|
173
|
+
*/
|
|
174
|
+
function getElements(body, itemName) {
|
|
175
|
+
const value = body[itemName];
|
|
176
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
177
|
+
// The fact that this must be an array is used above to calculate the
|
|
178
|
+
// type of elements in the page in PaginateReturn
|
|
179
|
+
if (!Array.isArray(value)) {
|
|
180
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
181
|
+
}
|
|
182
|
+
return value !== null && value !== void 0 ? value : [];
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Checks if a request failed
|
|
186
|
+
*/
|
|
187
|
+
function checkPagingRequest(response) {
|
|
188
|
+
const Http2xxStatusCodes = [
|
|
189
|
+
"200",
|
|
190
|
+
"201",
|
|
191
|
+
"202",
|
|
192
|
+
"203",
|
|
193
|
+
"204",
|
|
194
|
+
"205",
|
|
195
|
+
"206",
|
|
196
|
+
"207",
|
|
197
|
+
"208",
|
|
198
|
+
"226"
|
|
199
|
+
];
|
|
200
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
201
|
+
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Extracts the itemName and nextLinkName from the initial response to use them for pagination
|
|
206
|
+
*/
|
|
207
|
+
function getPaginationProperties(initialResponse) {
|
|
208
|
+
// Build a set with the passed custom nextLinkNames
|
|
209
|
+
const nextLinkNames = new Set(["nextLink", "@nextLink"]);
|
|
210
|
+
// Build a set with the passed custom set of itemNames
|
|
211
|
+
const itemNames = new Set(["value", "members", "collections", "entries"]);
|
|
212
|
+
let nextLinkName;
|
|
213
|
+
let itemName;
|
|
214
|
+
for (const name of nextLinkNames) {
|
|
215
|
+
const nextLink = initialResponse.body[name];
|
|
216
|
+
if (nextLink) {
|
|
217
|
+
nextLinkName = name;
|
|
218
|
+
break;
|
|
56
219
|
}
|
|
57
|
-
|
|
58
|
-
|
|
220
|
+
}
|
|
221
|
+
for (const name of itemNames) {
|
|
222
|
+
const item = initialResponse.body[name];
|
|
223
|
+
if (item) {
|
|
224
|
+
itemName = name;
|
|
225
|
+
break;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
if (!itemName) {
|
|
229
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${[
|
|
230
|
+
...itemNames
|
|
231
|
+
].join(" OR ")}`);
|
|
232
|
+
}
|
|
233
|
+
return { itemName, nextLinkName };
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
// Copyright (c) Microsoft Corporation.
|
|
237
|
+
async function getLedgerIdentity(ledgerId, identityServiceBaseUrl = "https://identity.confidential-ledger.core.azure.com") {
|
|
238
|
+
const client = coreClient.getClient(identityServiceBaseUrl);
|
|
239
|
+
const cert = await client.pathUnchecked("/ledgerIdentity/{ledgerId}", ledgerId).get();
|
|
240
|
+
const updatedCert = {
|
|
241
|
+
ledgerIdentityCertificate: cert.body["ledgerTlsCertificate"],
|
|
242
|
+
ledgerId: cert.body["ledgerId"],
|
|
243
|
+
};
|
|
244
|
+
if (!isLedgerIdentity(updatedCert)) {
|
|
245
|
+
throw new Error("Body received from Confidential Ledger Identity is invalid. It must contain ledgerId and ledgerIdentityCertificate");
|
|
246
|
+
}
|
|
247
|
+
return updatedCert;
|
|
59
248
|
}
|
|
60
249
|
function isLedgerIdentity(identity) {
|
|
61
|
-
return identity.
|
|
250
|
+
return identity.ledgerIdentityCertificate && identity.ledgerId;
|
|
62
251
|
}
|
|
63
252
|
|
|
64
253
|
// Copyright (c) Microsoft Corporation.
|
|
65
254
|
|
|
66
|
-
exports
|
|
255
|
+
exports["default"] = ConfidentialLedger;
|
|
67
256
|
exports.getLedgerIdentity = getLedgerIdentity;
|
|
257
|
+
exports.isUnexpected = isUnexpected;
|
|
258
|
+
exports.paginate = paginate;
|
|
68
259
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/certificatePolicy.ts","../src/generated/src/confidentialLedger.ts","../src/confidentialLedger.ts","../src/getLedgerIdentity.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { PipelinePolicy } from \"@azure/core-rest-pipeline\";\nimport { CertificateCredential, isCertificateCredential } from \"@azure-rest/core-client\";\nimport { Agent } from \"https\";\ninterface AgentOptions {\n /** Custom certificate authority to trust Self-Signed certificate */\n ca: string;\n /** Client certificate for authentication */\n cert?: string;\n /** Client private key for certificate authentication */\n key?: string;\n}\n\nexport function certificatePolicy(\n ledgerTlsCertificate: string,\n credential: TokenCredential | CertificateCredential\n): PipelinePolicy {\n // Create default agent and options if they don't exist\n let agentOptions: AgentOptions = {\n // Add CA to trust Confidential Ledger self signed certificate\n ca: ledgerTlsCertificate,\n };\n\n // Add certificate for authentication if one was provided\n if (isCertificateCredential(credential)) {\n agentOptions = { ...agentOptions, cert: credential.cert, key: credential.certKey };\n }\n\n return {\n name: \"ledgerTlsCertificatePolicy\",\n sendRequest: (request, next) => {\n request.agent = new Agent(agentOptions);\n return next(request);\n },\n };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GetConstitutionParameters,\n GetConsortiumMembersParameters,\n GetEnclaveQuotesParameters,\n GetLedgerEntriesParameters,\n PostLedgerEntryParameters,\n GetLedgerEntryParameters,\n GetReceiptParameters,\n GetTransactionStatusParameters,\n GetCurrentLedgerEntryParameters,\n DeleteUserParameters,\n GetUserParameters,\n CreateOrUpdateUserParameters,\n} from \"./parameters\";\nimport {\n GetConstitution200Response,\n GetConstitutiondefaultResponse,\n GetConsortiumMembers200Response,\n GetConsortiumMembersdefaultResponse,\n GetEnclaveQuotes200Response,\n GetEnclaveQuotesdefaultResponse,\n GetLedgerEntries200Response,\n GetLedgerEntriesdefaultResponse,\n PostLedgerEntry200Response,\n PostLedgerEntrydefaultResponse,\n GetLedgerEntry200Response,\n GetLedgerEntrydefaultResponse,\n GetReceipt200Response,\n GetReceiptdefaultResponse,\n GetTransactionStatus200Response,\n GetTransactionStatusdefaultResponse,\n GetCurrentLedgerEntry200Response,\n GetCurrentLedgerEntrydefaultResponse,\n DeleteUser204Response,\n DeleteUserdefaultResponse,\n GetUser200Response,\n GetUserdefaultResponse,\n CreateOrUpdateUser200Response,\n CreateOrUpdateUserdefaultResponse,\n} from \"./responses\";\nimport { getClient, ClientOptions, Client } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nexport interface GetConstitution {\n /** The constitution is a script that assesses and applies proposals from consortium members. */\n get(\n options?: GetConstitutionParameters\n ): Promise<GetConstitution200Response | GetConstitutiondefaultResponse>;\n}\n\nexport interface GetConsortiumMembers {\n /** Consortium members can manage the Confidential Ledger. */\n get(\n options?: GetConsortiumMembersParameters\n ): Promise<GetConsortiumMembers200Response | GetConsortiumMembersdefaultResponse>;\n}\n\nexport interface GetEnclaveQuotes {\n /** A quote is an SGX enclave measurement that can be used to verify the validity of a node and its enclave. */\n get(\n options?: GetEnclaveQuotesParameters\n ): Promise<GetEnclaveQuotes200Response | GetEnclaveQuotesdefaultResponse>;\n}\n\nexport interface PostLedgerEntry {\n /** A sub-ledger id may optionally be specified. Only entries in the specified (or default) sub-ledger will be returned. */\n get(\n options?: GetLedgerEntriesParameters\n ): Promise<GetLedgerEntries200Response | GetLedgerEntriesdefaultResponse>;\n /** A sub-ledger id may optionally be specified. */\n post(\n options?: PostLedgerEntryParameters\n ): Promise<PostLedgerEntry200Response | PostLedgerEntrydefaultResponse>;\n}\n\nexport interface GetLedgerEntry {\n /** To return older ledger entries, the relevant sections of the ledger must be read from disk and validated. To prevent blocking within the enclave, the response will indicate whether the entry is ready and part of the response, or if the loading is still ongoing. */\n get(\n options?: GetLedgerEntryParameters\n ): Promise<GetLedgerEntry200Response | GetLedgerEntrydefaultResponse>;\n}\n\nexport interface GetReceipt {\n /** Gets a receipt certifying ledger contents at a particular transaction id. */\n get(options?: GetReceiptParameters): Promise<GetReceipt200Response | GetReceiptdefaultResponse>;\n}\n\nexport interface GetTransactionStatus {\n /** Gets the status of an entry identified by a transaction id. */\n get(\n options?: GetTransactionStatusParameters\n ): Promise<GetTransactionStatus200Response | GetTransactionStatusdefaultResponse>;\n}\n\nexport interface GetCurrentLedgerEntry {\n /** A sub-ledger id may optionally be specified. */\n get(\n options?: GetCurrentLedgerEntryParameters\n ): Promise<GetCurrentLedgerEntry200Response | GetCurrentLedgerEntrydefaultResponse>;\n}\n\nexport interface CreateOrUpdateUser {\n /** Deletes a user from the Confidential Ledger. */\n delete(\n options?: DeleteUserParameters\n ): Promise<DeleteUser204Response | DeleteUserdefaultResponse>;\n /** Gets a user. */\n get(options?: GetUserParameters): Promise<GetUser200Response | GetUserdefaultResponse>;\n /** A JSON merge patch is applied for existing users */\n patch(\n options: CreateOrUpdateUserParameters\n ): Promise<CreateOrUpdateUser200Response | CreateOrUpdateUserdefaultResponse>;\n}\n\nexport interface Routes {\n /** Resource for '/app/governance/constitution' has methods for the following verbs: get */\n (path: \"/app/governance/constitution\"): GetConstitution;\n /** Resource for '/app/governance/members' has methods for the following verbs: get */\n (path: \"/app/governance/members\"): GetConsortiumMembers;\n /** Resource for '/app/enclaveQuotes' has methods for the following verbs: get */\n (path: \"/app/enclaveQuotes\"): GetEnclaveQuotes;\n /** Resource for '/app/transactions' has methods for the following verbs: get, post */\n (path: \"/app/transactions\"): PostLedgerEntry;\n /** Resource for '/app/transactions/\\{transactionId\\}' has methods for the following verbs: get */\n (path: \"/app/transactions/{transactionId}\", transactionId: string): GetLedgerEntry;\n /** Resource for '/app/transactions/\\{transactionId\\}/receipt' has methods for the following verbs: get */\n (path: \"/app/transactions/{transactionId}/receipt\", transactionId: string): GetReceipt;\n /** Resource for '/app/transactions/\\{transactionId\\}/status' has methods for the following verbs: get */\n (path: \"/app/transactions/{transactionId}/status\", transactionId: string): GetTransactionStatus;\n /** Resource for '/app/transactions/current' has methods for the following verbs: get */\n (path: \"/app/transactions/current\"): GetCurrentLedgerEntry;\n /** Resource for '/app/users/\\{userId\\}' has methods for the following verbs: delete, get, patch */\n (path: \"/app/users/{userId}\", userId: string): CreateOrUpdateUser;\n}\n\nexport type ConfidentialLedgerRestClient = Client & {\n path: Routes;\n};\n\nexport default function ConfidentialLedger(\n ledgerUri: string,\n credentials?: TokenCredential,\n options: ClientOptions = {}\n): ConfidentialLedgerRestClient {\n const baseUrl = options.baseUrl ?? `${ledgerUri}`;\n options.apiVersion = options.apiVersion ?? \"0.1-preview\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://confidential-ledger.azure.com/.default\"],\n },\n };\n\n return getClient(baseUrl, credentials, options) as ConfidentialLedgerRestClient;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n ClientOptions,\n CertificateCredential,\n isCertificateCredential,\n} from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\n\nimport { certificatePolicy } from \"./certificatePolicy\";\nimport GeneratedConfidentialLedger, {\n ConfidentialLedgerRestClient,\n} from \"./generated/src/confidentialLedger\";\n\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerTlsCertificate: string,\n credentials: TokenCredential | CertificateCredential,\n options?: ClientOptions\n): ConfidentialLedgerRestClient {\n // If certificate credential is passed, we'll handle auth\n const creds = isCertificateCredential(credentials) ? undefined : credentials;\n\n const confidentialLedger = GeneratedConfidentialLedger(ledgerBaseUrl, creds, options);\n\n confidentialLedger.pipeline.addPolicy(certificatePolicy(ledgerTlsCertificate, credentials));\n\n return confidentialLedger;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient } from \"@azure-rest/core-client\";\n\nexport interface LedgerIdentity {\n ledgerTlsCertificate: string;\n ledgerId: string;\n}\n\nexport async function getLedgerIdentity(\n ledgerId: string,\n identityServiceBaseUrl: string = \"https://identity.accledger.azure.com\"\n): Promise<LedgerIdentity> {\n const client = getClient(identityServiceBaseUrl);\n\n const cert = await client.pathUnchecked(\"/ledgerIdentity/{ledgerId}\", ledgerId).get();\n\n if (!isLedgerIdentity(cert.body)) {\n throw new Error(\n \"Body received from Confidential Ledger Identity is invalid. It must contain ledgerId and ledgerTlsCertificate\"\n );\n }\n\n return cert.body;\n}\n\nfunction isLedgerIdentity(identity: any): identity is LedgerIdentity {\n return identity.ledgerTlsCertificate && identity.ledgerId;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport ConfidentialLedger from \"./confidentialLedger\";\nexport * from \"./generated/src/confidentialLedger\";\nexport * from \"./generated/src/models\";\nexport * from \"./generated/src/parameters\";\nexport * from \"./generated/src/responses\";\nexport { LedgerIdentity, getLedgerIdentity } from \"./getLedgerIdentity\";\nexport default ConfidentialLedger;\n"],"names":["isCertificateCredential","Agent","getClient","ConfidentialLedger","Generated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AC,iBAAiB,CAAC,oBAAoB,EAAE,WAAW,CAAC,CAAC,CAAC;IAE5F,OAAO,kBAAkB,CAAC;AAC5B,CAAC;;AC7BD;AACA,SASsB,iBAAiB,CACrC,QAAgB,EAChB,yBAAiC,sCAAsC;;QAEvE,MAAM,MAAM,GAAGF,oBAAS,CAAC,sBAAsB,CAAC,CAAC;QAEjD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;QAEtF,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;YAChC,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;SACH;QAED,OAAO,IAAI,CAAC,IAAI,CAAC;KAClB;CAAA;AAED,SAAS,gBAAgB,CAAC,QAAa;IACrC,OAAO,QAAQ,CAAC,oBAAoB,IAAI,QAAQ,CAAC,QAAQ,CAAC;AAC5D,CAAC;;AC7BD,uCAAuC;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/generated/src/confidentialLedger.ts","../src/confidentialLedger.ts","../src/generated/src/isUnexpected.ts","../src/generated/src/paginateHelper.ts","../src/getLedgerIdentity.ts","../src/index.ts"],"sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { TokenCredential } from \"@azure/core-auth\";\nimport { ConfidentialLedgerClient } from \"./clientDefinitions\";\n\nexport default function createClient(\n ledgerEndpoint: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): ConfidentialLedgerClient {\n const baseUrl = options.baseUrl ?? `${ledgerEndpoint}`;\n options.apiVersion = options.apiVersion ?? \"2022-05-13\";\n options = {\n ...options,\n credentials: {\n scopes: [\"https://confidential-ledger.azure.com/.default\"]\n }\n };\n\n const userAgentInfo = `azsdk-js-confidential-ledger-rest/1.0.0`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix\n }\n };\n\n const client = getClient(\n baseUrl,\n credentials,\n options\n ) as ConfidentialLedgerClient;\n\n return client;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\nimport { ConfidentialLedgerClient } from \"./generated/src/clientDefinitions\";\nimport GeneratedConfidentialLedger from \"./generated/src/confidentialLedger\";\n\nexport default function ConfidentialLedger(\n ledgerEndpoint: string,\n ledgerIdentityCertificate: string,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerEndpoint: string,\n ledgerIdentityCertificate: string,\n credentials: TokenCredential,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerEndpoint: string,\n ledgerIdentityCertificate: string,\n credentialsOrOptions?: TokenCredential | ClientOptions,\n opts?: ClientOptions\n): ConfidentialLedgerClient {\n let credentials: TokenCredential | undefined;\n let options: ClientOptions;\n\n if (isTokenCredential(credentialsOrOptions)) {\n credentials = credentialsOrOptions;\n options = opts ?? {};\n } else {\n options = credentialsOrOptions ?? {};\n }\n\n const tlsOptions = options?.tlsOptions ?? {};\n tlsOptions.ca = ledgerIdentityCertificate;\n const confidentialLedger = GeneratedConfidentialLedger(ledgerEndpoint, credentials!, {\n ...options,\n tlsOptions,\n });\n return confidentialLedger;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GetConstitution200Response,\n GetConstitutiondefaultResponse,\n ListConsortiumMembers200Response,\n ListConsortiumMembersdefaultResponse,\n GetEnclaveQuotes200Response,\n GetEnclaveQuotesdefaultResponse,\n ListCollections200Response,\n ListCollectionsdefaultResponse,\n ListLedgerEntries200Response,\n ListLedgerEntriesdefaultResponse,\n CreateLedgerEntry200Response,\n CreateLedgerEntrydefaultResponse,\n GetLedgerEntry200Response,\n GetLedgerEntrydefaultResponse,\n GetReceipt200Response,\n GetReceiptdefaultResponse,\n GetTransactionStatus200Response,\n GetTransactionStatusdefaultResponse,\n GetCurrentLedgerEntry200Response,\n GetCurrentLedgerEntrydefaultResponse,\n DeleteUser204Response,\n DeleteUserdefaultResponse,\n GetUser200Response,\n GetUserdefaultResponse,\n CreateOrUpdateUser200Response,\n CreateOrUpdateUserdefaultResponse\n} from \"./responses\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /app/governance/constitution\": [\"200\"],\n \"GET /app/governance/members\": [\"200\"],\n \"GET /app/enclaveQuotes\": [\"200\"],\n \"GET /app/collections\": [\"200\"],\n \"GET /app/transactions\": [\"200\"],\n \"POST /app/transactions\": [\"200\"],\n \"GET /app/transactions/{transactionId}\": [\"200\"],\n \"GET /app/transactions/{transactionId}/receipt\": [\"200\"],\n \"GET /app/transactions/{transactionId}/status\": [\"200\"],\n \"GET /app/transactions/current\": [\"200\"],\n \"DELETE /app/users/{userId}\": [\"204\"],\n \"GET /app/users/{userId}\": [\"200\"],\n \"PATCH /app/users/{userId}\": [\"200\"]\n};\n\nexport function isUnexpected(\n response: GetConstitution200Response | GetConstitutiondefaultResponse\n): response is GetConstitutiondefaultResponse;\nexport function isUnexpected(\n response:\n | ListConsortiumMembers200Response\n | ListConsortiumMembersdefaultResponse\n): response is ListConsortiumMembersdefaultResponse;\nexport function isUnexpected(\n response: GetEnclaveQuotes200Response | GetEnclaveQuotesdefaultResponse\n): response is GetEnclaveQuotesdefaultResponse;\nexport function isUnexpected(\n response: ListCollections200Response | ListCollectionsdefaultResponse\n): response is ListCollectionsdefaultResponse;\nexport function isUnexpected(\n response: ListLedgerEntries200Response | ListLedgerEntriesdefaultResponse\n): response is ListLedgerEntriesdefaultResponse;\nexport function isUnexpected(\n response: CreateLedgerEntry200Response | CreateLedgerEntrydefaultResponse\n): response is CreateLedgerEntrydefaultResponse;\nexport function isUnexpected(\n response: GetLedgerEntry200Response | GetLedgerEntrydefaultResponse\n): response is GetLedgerEntrydefaultResponse;\nexport function isUnexpected(\n response: GetReceipt200Response | GetReceiptdefaultResponse\n): response is GetReceiptdefaultResponse;\nexport function isUnexpected(\n response:\n | GetTransactionStatus200Response\n | GetTransactionStatusdefaultResponse\n): response is GetTransactionStatusdefaultResponse;\nexport function isUnexpected(\n response:\n | GetCurrentLedgerEntry200Response\n | GetCurrentLedgerEntrydefaultResponse\n): response is GetCurrentLedgerEntrydefaultResponse;\nexport function isUnexpected(\n response: DeleteUser204Response | DeleteUserdefaultResponse\n): response is DeleteUserdefaultResponse;\nexport function isUnexpected(\n response: GetUser200Response | GetUserdefaultResponse\n): response is GetUserdefaultResponse;\nexport function isUnexpected(\n response: CreateOrUpdateUser200Response | CreateOrUpdateUserdefaultResponse\n): response is CreateOrUpdateUserdefaultResponse;\nexport function isUnexpected(\n response:\n | GetConstitution200Response\n | GetConstitutiondefaultResponse\n | ListConsortiumMembers200Response\n | ListConsortiumMembersdefaultResponse\n | GetEnclaveQuotes200Response\n | GetEnclaveQuotesdefaultResponse\n | ListCollections200Response\n | ListCollectionsdefaultResponse\n | ListLedgerEntries200Response\n | ListLedgerEntriesdefaultResponse\n | CreateLedgerEntry200Response\n | CreateLedgerEntrydefaultResponse\n | GetLedgerEntry200Response\n | GetLedgerEntrydefaultResponse\n | GetReceipt200Response\n | GetReceiptdefaultResponse\n | GetTransactionStatus200Response\n | GetTransactionStatusdefaultResponse\n | GetCurrentLedgerEntry200Response\n | GetCurrentLedgerEntrydefaultResponse\n | DeleteUser204Response\n | DeleteUserdefaultResponse\n | GetUser200Response\n | GetUserdefaultResponse\n | CreateOrUpdateUser200Response\n | CreateOrUpdateUserdefaultResponse\n): response is\n | GetConstitutiondefaultResponse\n | ListConsortiumMembersdefaultResponse\n | GetEnclaveQuotesdefaultResponse\n | ListCollectionsdefaultResponse\n | ListLedgerEntriesdefaultResponse\n | CreateLedgerEntrydefaultResponse\n | GetLedgerEntrydefaultResponse\n | GetReceiptdefaultResponse\n | GetTransactionStatusdefaultResponse\n | GetCurrentLedgerEntrydefaultResponse\n | DeleteUserdefaultResponse\n | GetUserdefaultResponse\n | CreateOrUpdateUserdefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = geParametrizedPathSuccess(url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction geParametrizedPathSuccess(path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // If the candidate and actual paths don't match in size\n // we move on to the next candidate path\n if (\n candidateParts.length === pathParts.length &&\n hasParametrizedPath(key)\n ) {\n // track if we have found a match to return the values found.\n let found = true;\n for (let i = 0; i < candidateParts.length; i++) {\n if (\n candidateParts[i].startsWith(\"{\") &&\n candidateParts[i].endsWith(\"}\")\n ) {\n // If the current part of the candidate is a \"template\" part\n // it is a match with the actual path part on hand\n // skip as the parameterized part can match anything\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[i]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // if all parts matched we return the success values form\n // the path mapping.\n if (found) {\n return value;\n }\n }\n }\n\n // No match was found, return an empty array.\n return [];\n}\n\nfunction hasParametrizedPath(path: string): boolean {\n return path.includes(\"/{\");\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n getPagedAsyncIterator,\n PagedAsyncIterableIterator,\n PagedResult\n} from \"@azure/core-paging\";\nimport {\n Client,\n createRestError,\n PathUncheckedResponse\n} from \"@azure-rest/core-client\";\n\n/**\n * Helper type to extract the type of an array\n */\nexport type GetArrayType<T> = T extends Array<infer TData> ? TData : never;\n\n/**\n * The type of a custom function that defines how to get a page and a link to the next one if any.\n */\nexport type GetPage<TPage> = (\n pageLink: string,\n maxPageSize?: number\n) => Promise<{\n page: TPage;\n nextPageLink?: string;\n}>;\n\n/**\n * Options for the paging helper\n */\nexport interface PagingOptions<TResponse> {\n /**\n * Custom function to extract pagination details for crating the PagedAsyncIterableIterator\n */\n customGetPage?: GetPage<PaginateReturn<TResponse>[]>;\n}\n\n/**\n * Helper type to infer the Type of the paged elements from the response type\n * This type is generated based on the swagger information for x-ms-pageable\n * specifically on the itemName property which indicates the property of the response\n * where the page items are found. The default value is `value`.\n * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter\n */\nexport type PaginateReturn<TResult> = TResult extends\n | {\n body: { value?: infer TPage };\n }\n | {\n body: { members?: infer TPage };\n }\n | {\n body: { collections?: infer TPage };\n }\n | {\n body: { entries?: infer TPage };\n }\n ? GetArrayType<TPage>\n : Array<unknown>;\n\n/**\n * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension\n * @param client - Client to use for sending the next page requests\n * @param initialResponse - Initial response containing the nextLink and current page of elements\n * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results\n * @returns - PagedAsyncIterableIterator to iterate the elements\n */\nexport function paginate<TResponse extends PathUncheckedResponse>(\n client: Client,\n initialResponse: TResponse,\n options: PagingOptions<TResponse> = {}\n): PagedAsyncIterableIterator<PaginateReturn<TResponse>> {\n // Extract element type from initial response\n type TElement = PaginateReturn<TResponse>;\n let firstRun = true;\n // We need to check the response for success before trying to inspect it looking for\n // the properties to use for nextLink and itemName\n checkPagingRequest(initialResponse);\n const { itemName, nextLinkName } = getPaginationProperties(initialResponse);\n const { customGetPage } = options;\n const pagedResult: PagedResult<TElement[]> = {\n firstPageLink: \"\",\n getPage:\n typeof customGetPage === \"function\"\n ? customGetPage\n : async (pageLink: string) => {\n const result = firstRun\n ? initialResponse\n : await client.pathUnchecked(pageLink).get();\n firstRun = false;\n checkPagingRequest(result);\n const nextLink = getNextLink(result.body, nextLinkName);\n const values = getElements<TElement>(result.body, itemName);\n return {\n page: values,\n nextPageLink: nextLink\n };\n }\n };\n\n return getPagedAsyncIterator(pagedResult);\n}\n\n/**\n * Gets for the value of nextLink in the body\n */\nfunction getNextLink(body: unknown, nextLinkName?: string): string | undefined {\n if (!nextLinkName) {\n return undefined;\n }\n\n const nextLink = (body as Record<string, unknown>)[nextLinkName];\n\n if (typeof nextLink !== \"string\" && typeof nextLink !== \"undefined\") {\n throw new Error(\n `Body Property ${nextLinkName} should be a string or undefined`\n );\n }\n\n return nextLink;\n}\n\n/**\n * Gets the elements of the current request in the body.\n */\nfunction getElements<T = unknown>(body: unknown, itemName: string): T[] {\n const value = (body as Record<string, unknown>)[itemName] as T[];\n\n // value has to be an array according to the x-ms-pageable extension.\n // The fact that this must be an array is used above to calculate the\n // type of elements in the page in PaginateReturn\n if (!Array.isArray(value)) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${itemName}`\n );\n }\n\n return value ?? [];\n}\n\n/**\n * Checks if a request failed\n */\nfunction checkPagingRequest(response: PathUncheckedResponse): void {\n const Http2xxStatusCodes = [\n \"200\",\n \"201\",\n \"202\",\n \"203\",\n \"204\",\n \"205\",\n \"206\",\n \"207\",\n \"208\",\n \"226\"\n ];\n if (!Http2xxStatusCodes.includes(response.status)) {\n throw createRestError(\n `Pagination failed with unexpected statusCode ${response.status}`,\n response\n );\n }\n}\n\n/**\n * Extracts the itemName and nextLinkName from the initial response to use them for pagination\n */\nfunction getPaginationProperties(initialResponse: PathUncheckedResponse) {\n // Build a set with the passed custom nextLinkNames\n const nextLinkNames = new Set([\"nextLink\", \"@nextLink\"]);\n\n // Build a set with the passed custom set of itemNames\n const itemNames = new Set([\"value\", \"members\", \"collections\", \"entries\"]);\n\n let nextLinkName: string | undefined;\n let itemName: string | undefined;\n\n for (const name of nextLinkNames) {\n const nextLink = (initialResponse.body as Record<string, unknown>)[\n name\n ] as string;\n if (nextLink) {\n nextLinkName = name;\n break;\n }\n }\n\n for (const name of itemNames) {\n const item = (initialResponse.body as Record<string, unknown>)[\n name\n ] as string;\n if (item) {\n itemName = name;\n break;\n }\n }\n\n if (!itemName) {\n throw new Error(\n `Couldn't paginate response\\n Body doesn't contain an array property with name: ${[\n ...itemNames\n ].join(\" OR \")}`\n );\n }\n\n return { itemName, nextLinkName };\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { getClient } from \"@azure-rest/core-client\";\n\nexport interface LedgerIdentity {\n ledgerIdentityCertificate: string;\n ledgerId: string;\n}\n\nexport async function getLedgerIdentity(\n ledgerId: string,\n identityServiceBaseUrl: string = \"https://identity.confidential-ledger.core.azure.com\"\n): Promise<LedgerIdentity> {\n const client = getClient(identityServiceBaseUrl);\n\n const cert = await client.pathUnchecked(\"/ledgerIdentity/{ledgerId}\", ledgerId).get();\n\n const updatedCert = {\n ledgerIdentityCertificate: cert.body[\"ledgerTlsCertificate\"],\n ledgerId: cert.body[\"ledgerId\"],\n };\n\n if (!isLedgerIdentity(updatedCert)) {\n throw new Error(\n \"Body received from Confidential Ledger Identity is invalid. It must contain ledgerId and ledgerIdentityCertificate\"\n );\n }\n\n return updatedCert;\n}\n\nfunction isLedgerIdentity(identity: any): identity is LedgerIdentity {\n return identity.ledgerIdentityCertificate && identity.ledgerId;\n}\n","// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport ConfidentialLedger from \"./confidentialLedger\";\nexport * from \"./generated/src/confidentialLedger\";\nexport * from \"./generated/src/models\";\nexport * from \"./generated/src/parameters\";\nexport * from \"./generated/src/responses\";\nexport * from \"./generated/src/clientDefinitions\";\nexport * from \"./generated/src/isUnexpected\";\nexport * from \"./generated/src/outputModels\";\nexport * from \"./generated/src/paginateHelper\";\nexport { LedgerIdentity, getLedgerIdentity } from \"./getLedgerIdentity\";\nexport default ConfidentialLedger;\n"],"names":["getClient","isTokenCredential","GeneratedConfidentialLedger","getPagedAsyncIterator","createRestError"],"mappings":";;;;;;;;AAAA;AAOc,SAAU,YAAY,CAClC,cAAsB,EACtB,WAA4B,EAC5B,OAAA,GAAyB,EAAE,EAAA;;IAE3B,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,OAAO,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAG,cAAc,CAAA,CAAE,CAAC;IACvD,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,YAAY,CAAC;AACxD,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,WAAW,EAAE;YACX,MAAM,EAAE,CAAC,gDAAgD,CAAC;AAC3D,SAAA,EAAA,CACF,CAAC;IAEF,MAAM,aAAa,GAAG,CAAA,uCAAA,CAAyC,CAAC;IAChE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;UAChE,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,CAAI,CAAA,EAAA,aAAa,CAAE,CAAA;AAChE,UAAE,CAAA,EAAG,aAAa,CAAA,CAAE,CAAC;AACzB,IAAA,OAAO,GACF,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,OAAO,CACV,EAAA,EAAA,gBAAgB,EAAE;YAChB,eAAe;AAChB,SAAA,EAAA,CACF,CAAC;IAEF,MAAM,MAAM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,CAAC,QAAQ,CAAC;AACjE;;AClCA;;;;;;;"}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import {
|
|
4
|
-
import { certificatePolicy } from "./certificatePolicy";
|
|
3
|
+
import { isTokenCredential } from "@azure/core-auth";
|
|
5
4
|
import GeneratedConfidentialLedger from "./generated/src/confidentialLedger";
|
|
6
|
-
export default function ConfidentialLedger(
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
5
|
+
export default function ConfidentialLedger(ledgerEndpoint, ledgerIdentityCertificate, credentialsOrOptions, opts) {
|
|
6
|
+
var _a;
|
|
7
|
+
let credentials;
|
|
8
|
+
let options;
|
|
9
|
+
if (isTokenCredential(credentialsOrOptions)) {
|
|
10
|
+
credentials = credentialsOrOptions;
|
|
11
|
+
options = opts !== null && opts !== void 0 ? opts : {};
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
options = credentialsOrOptions !== null && credentialsOrOptions !== void 0 ? credentialsOrOptions : {};
|
|
15
|
+
}
|
|
16
|
+
const tlsOptions = (_a = options === null || options === void 0 ? void 0 : options.tlsOptions) !== null && _a !== void 0 ? _a : {};
|
|
17
|
+
tlsOptions.ca = ledgerIdentityCertificate;
|
|
18
|
+
const confidentialLedger = GeneratedConfidentialLedger(ledgerEndpoint, credentials, Object.assign(Object.assign({}, options), { tlsOptions }));
|
|
11
19
|
return confidentialLedger;
|
|
12
20
|
}
|
|
13
21
|
//# sourceMappingURL=confidentialLedger.js.map
|