@azure-rest/confidential-ledger 1.0.0-alpha.20220527.1 → 1.0.0-alpha.20220712.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 +89 -27
- package/dist/index.js +218 -13
- package/dist/index.js.map +1 -1
- package/dist-esm/src/confidentialLedger.js +3 -3
- 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 +12 -4
- 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 +9 -5
- 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 +9 -7
- package/types/confidential-ledger.d.ts +284 -164
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@ portfolio, Azure Confidential Ledger runs in SGX enclaves. It is built on Micros
|
|
|
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
|
+
|
|
9
10
|
- [Source code][source_code]
|
|
10
11
|
- [Package (NPM)][confidentialledger_npm]
|
|
11
12
|
- [API reference documentation][ref_docs]
|
|
@@ -35,7 +36,7 @@ npm install @azure-rest/confidential-ledger
|
|
|
35
36
|
|
|
36
37
|
#### Using Azure Active Directory
|
|
37
38
|
|
|
38
|
-
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.
|
|
39
40
|
|
|
40
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`.
|
|
41
42
|
|
|
@@ -46,18 +47,18 @@ Creating the client also requires your Confidential Ledger's URL and id, which y
|
|
|
46
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.
|
|
47
48
|
|
|
48
49
|
```typescript
|
|
49
|
-
import ConfidentialLedger, { getLedgerIdentity } from "
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
//
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
);
|
|
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);
|
|
61
62
|
```
|
|
62
63
|
|
|
63
64
|
#### Using a client certificate
|
|
@@ -66,15 +67,23 @@ As an alternative to Azure Active Directory, clients may choose to authenticate
|
|
|
66
67
|
|
|
67
68
|
```typescript
|
|
68
69
|
import ConfidentialLedger, { getLedgerIdentity } from "@azure-rest/confidential-ledger";
|
|
70
|
+
|
|
69
71
|
// Get the signing certificate from the Confidential Ledger Identity Service
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
});
|
|
78
87
|
```
|
|
79
88
|
|
|
80
89
|
## Key concepts
|
|
@@ -87,11 +96,11 @@ Every write to Azure Confidential Ledger generates an immutable ledger entry in
|
|
|
87
96
|
|
|
88
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.
|
|
89
98
|
|
|
90
|
-
###
|
|
99
|
+
### Collections
|
|
91
100
|
|
|
92
|
-
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.
|
|
93
102
|
|
|
94
|
-
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.
|
|
95
104
|
|
|
96
105
|
### Users
|
|
97
106
|
|
|
@@ -109,24 +118,77 @@ Azure Confidential Ledger is built on Microsoft Research's open-source [Confiden
|
|
|
109
118
|
|
|
110
119
|
This section contains code snippets for the following samples:
|
|
111
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")
|
|
112
126
|
- [List Enclave Quotes](#list-enclave-quotes "List Enclave Quotes")
|
|
113
127
|
|
|
128
|
+
### Post Ledger Entry
|
|
129
|
+
```typescript
|
|
130
|
+
const entry: LedgerEntry = {
|
|
131
|
+
contents: contentBody,
|
|
132
|
+
};
|
|
133
|
+
const ledgerEntry: PostLedgerEntryParameters = {
|
|
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
|
+
|
|
114
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
|
+
}
|
|
115
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
|
|
116
180
|
```typescript
|
|
117
181
|
import ConfidentialLedger, { getLedgerIdentity } from "@azure-rest/confidential-ledger";
|
|
118
182
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
119
183
|
|
|
120
184
|
export async function main() {
|
|
121
|
-
console.log("== List Enclave Quotes ==");
|
|
122
|
-
|
|
123
185
|
// Get the signing certificate from the Confidential Ledger Identity Service
|
|
124
186
|
const ledgerIdentity = await getLedgerIdentity("<my-ledger-id>");
|
|
125
187
|
|
|
126
188
|
// Create the Confidential Ledger Client
|
|
127
189
|
const confidentialLedger = ConfidentialLedger(
|
|
128
190
|
"https://<ledger-name>.eastus.cloudapp.azure.com",
|
|
129
|
-
ledgerIdentity.
|
|
191
|
+
ledgerIdentity.ledgerIdentityCertificate,
|
|
130
192
|
new DefaultAzureCredential()
|
|
131
193
|
);
|
|
132
194
|
|
package/dist/index.js
CHANGED
|
@@ -2,22 +2,31 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var coreClient = require('@azure-rest/core-client');
|
|
6
5
|
var coreAuth = require('@azure/core-auth');
|
|
6
|
+
var coreClient = require('@azure-rest/core-client');
|
|
7
|
+
var corePaging = require('@azure/core-paging');
|
|
7
8
|
|
|
8
9
|
// Copyright (c) Microsoft Corporation.
|
|
9
|
-
function
|
|
10
|
+
function createClient(ledgerUri, credentials, options = {}) {
|
|
10
11
|
var _a, _b;
|
|
11
12
|
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${ledgerUri}`;
|
|
12
|
-
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "
|
|
13
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-05-13";
|
|
13
14
|
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
14
|
-
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
15
|
+
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
15
16
|
} });
|
|
16
|
-
|
|
17
|
+
const userAgentInfo = `azsdk-js-confidential-ledger-rest/1.0.0-beta.3`;
|
|
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
|
|
23
|
+
} });
|
|
24
|
+
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
25
|
+
return client;
|
|
17
26
|
}
|
|
18
27
|
|
|
19
28
|
// Copyright (c) Microsoft Corporation.
|
|
20
|
-
function ConfidentialLedger(ledgerBaseUrl,
|
|
29
|
+
function ConfidentialLedger(ledgerBaseUrl, ledgerIdentityCertificate, credentialsOrOptions, opts) {
|
|
21
30
|
var _a;
|
|
22
31
|
let credentials;
|
|
23
32
|
let options;
|
|
@@ -29,26 +38,222 @@ function ConfidentialLedger(ledgerBaseUrl, ledgerTlsCertificate, credentialsOrOp
|
|
|
29
38
|
options = credentialsOrOptions !== null && credentialsOrOptions !== void 0 ? credentialsOrOptions : {};
|
|
30
39
|
}
|
|
31
40
|
const tlsOptions = (_a = options === null || options === void 0 ? void 0 : options.tlsOptions) !== null && _a !== void 0 ? _a : {};
|
|
32
|
-
tlsOptions.ca =
|
|
33
|
-
const confidentialLedger =
|
|
41
|
+
tlsOptions.ca = ledgerIdentityCertificate;
|
|
42
|
+
const confidentialLedger = createClient(ledgerBaseUrl, credentials, Object.assign(Object.assign({}, options), { tlsOptions }));
|
|
34
43
|
return confidentialLedger;
|
|
35
44
|
}
|
|
36
45
|
|
|
37
46
|
// Copyright (c) Microsoft Corporation.
|
|
38
|
-
|
|
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", "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;
|
|
219
|
+
}
|
|
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") {
|
|
39
238
|
const client = coreClient.getClient(identityServiceBaseUrl);
|
|
40
239
|
const cert = await client.pathUnchecked("/ledgerIdentity/{ledgerId}", ledgerId).get();
|
|
41
|
-
|
|
42
|
-
|
|
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");
|
|
43
246
|
}
|
|
44
|
-
return
|
|
247
|
+
return updatedCert;
|
|
45
248
|
}
|
|
46
249
|
function isLedgerIdentity(identity) {
|
|
47
|
-
return identity.
|
|
250
|
+
return identity.ledgerIdentityCertificate && identity.ledgerId;
|
|
48
251
|
}
|
|
49
252
|
|
|
50
253
|
// Copyright (c) Microsoft Corporation.
|
|
51
254
|
|
|
52
255
|
exports["default"] = ConfidentialLedger;
|
|
53
256
|
exports.getLedgerIdentity = getLedgerIdentity;
|
|
257
|
+
exports.isUnexpected = isUnexpected;
|
|
258
|
+
exports.paginate = paginate;
|
|
54
259
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../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 {\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 GeneratedConfidentialLedger, {\n ConfidentialLedgerRestClient,\n} from \"./generated/src/confidentialLedger\";\nimport { TokenCredential, isTokenCredential } from \"@azure/core-auth\";\n\nimport { ClientOptions } from \"@azure-rest/core-client\";\n\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerTlsCertificate: string,\n options?: ClientOptions\n): ConfidentialLedgerRestClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerTlsCertificate: string,\n credentials: TokenCredential,\n options?: ClientOptions\n): ConfidentialLedgerRestClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerTlsCertificate: string,\n credentialsOrOptions?: TokenCredential | ClientOptions,\n opts?: ClientOptions\n): ConfidentialLedgerRestClient {\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 = ledgerTlsCertificate;\n const confidentialLedger = GeneratedConfidentialLedger(ledgerBaseUrl, credentials, {\n ...options,\n tlsOptions,\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":["ConfidentialLedger","getClient","isTokenCredential","GeneratedConfidentialLedger"],"mappings":";;;;;;;AAAA;AA8Ic,SAAUA,oBAAkB,CACxC,SAAiB,EACjB,WAA6B,EAC7B,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,SAAS,CAAA,CAAE,CAAC;IAClD,OAAO,CAAC,UAAU,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC,UAAU,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,aAAa,CAAC;AACzD,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,O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C,GAAG,EAAE,CAAC;AAEtF,IAAA,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;AAChC,QAAA,MAAM,IAAI,KAAK,CACb,+GAA+G,CAChH,CAAC;AACH,KAAA;IAED,OAAO,IAAI,CAAC,IAAI,CAAC;AACnB,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAa,EAAA;AACrC,IAAA,OAAO,QAAQ,CAAC,oBAAoB,IAAI,QAAQ,CAAC,QAAQ,CAAC;AAC5D;;AC7BA;;;;;"}
|
|
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 ledgerUri: string,\n credentials: TokenCredential,\n options: ClientOptions = {}\n): ConfidentialLedgerClient {\n const baseUrl = options.baseUrl ?? `${ledgerUri}`;\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-beta.3`;\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 ledgerBaseUrl: string,\n ledgerIdentityCertificate: string,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerIdentityCertificate: string,\n credentials: TokenCredential,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: 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(ledgerBaseUrl, 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 GetConsortiumMembers200Response,\n GetConsortiumMembersdefaultResponse,\n GetEnclaveQuotes200Response,\n GetEnclaveQuotesdefaultResponse,\n ListCollections200Response,\n ListCollectionsdefaultResponse,\n ListLedgerEntries200Response,\n ListLedgerEntriesdefaultResponse,\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\";\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 | GetConsortiumMembers200Response\n | GetConsortiumMembersdefaultResponse\n): response is GetConsortiumMembersdefaultResponse;\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: PostLedgerEntry200Response | PostLedgerEntrydefaultResponse\n): response is PostLedgerEntrydefaultResponse;\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 | GetConsortiumMembers200Response\n | GetConsortiumMembersdefaultResponse\n | GetEnclaveQuotes200Response\n | GetEnclaveQuotesdefaultResponse\n | ListCollections200Response\n | ListCollectionsdefaultResponse\n | ListLedgerEntries200Response\n | ListLedgerEntriesdefaultResponse\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): response is\n | GetConstitutiondefaultResponse\n | GetConsortiumMembersdefaultResponse\n | GetEnclaveQuotesdefaultResponse\n | ListCollectionsdefaultResponse\n | ListLedgerEntriesdefaultResponse\n | PostLedgerEntrydefaultResponse\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: { 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\", \"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,SAAiB,EACjB,WAA4B,EAC5B,OAAA,GAAyB,EAAE,EAAA;;IAE3B,MAAM,OAAO,GAAG,CAAA,EAAA,GAAA,OAAO,CAAC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AA;AAChF,YAAA,GAAG,SAAS;AACb,SAAA,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA,CAAE,CACjB,CAAC;AACH,KAAA;AAED,IAAA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC;AACpC;;AC3MA;AAUO,eAAe,iBAAiB,CACrC,QAAgB,EAChB,yBAAiC,qDAAqD,EAAA;AAEtF,IAAA,MAAM,MAAM,GAAGJ,oBAAS,CAAC,sBAAsB,CAAC,CAAC;AAEjD,IAAA,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,4BAA4B,EAAE,QAAQ,CAAC,CAAC,GAAG,EAAE,CAAC;AAEtF,IAAA,MAAM,WAAW,GAAG;AAClB,QAAA,yBAAyB,EAAE,IAAI,CAAC,IAAI,CAAC,sBAAsB,CAAC;AAC5D,QAAA,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC;KAChC,CAAC;AAEF,IAAA,IAAI,CAAC,gBAAgB,CAAC,WAAW,CAAC,EAAE;AAClC,QAAA,MAAM,IAAI,KAAK,CACb,oHAAoH,CACrH,CAAC;AACH,KAAA;AAED,IAAA,OAAO,WAAW,CAAC;AACrB,CAAC;AAED,SAAS,gBAAgB,CAAC,QAAa,EAAA;AACrC,IAAA,OAAO,QAAQ,CAAC,yBAAyB,IAAI,QAAQ,CAAC,QAAQ,CAAC;AACjE;;AClCA;;;;;;;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
|
-
import GeneratedConfidentialLedger from "./generated/src/confidentialLedger";
|
|
4
3
|
import { isTokenCredential } from "@azure/core-auth";
|
|
5
|
-
|
|
4
|
+
import GeneratedConfidentialLedger from "./generated/src/confidentialLedger";
|
|
5
|
+
export default function ConfidentialLedger(ledgerBaseUrl, ledgerIdentityCertificate, credentialsOrOptions, opts) {
|
|
6
6
|
var _a;
|
|
7
7
|
let credentials;
|
|
8
8
|
let options;
|
|
@@ -14,7 +14,7 @@ export default function ConfidentialLedger(ledgerBaseUrl, ledgerTlsCertificate,
|
|
|
14
14
|
options = credentialsOrOptions !== null && credentialsOrOptions !== void 0 ? credentialsOrOptions : {};
|
|
15
15
|
}
|
|
16
16
|
const tlsOptions = (_a = options === null || options === void 0 ? void 0 : options.tlsOptions) !== null && _a !== void 0 ? _a : {};
|
|
17
|
-
tlsOptions.ca =
|
|
17
|
+
tlsOptions.ca = ledgerIdentityCertificate;
|
|
18
18
|
const confidentialLedger = GeneratedConfidentialLedger(ledgerBaseUrl, credentials, Object.assign(Object.assign({}, options), { tlsOptions }));
|
|
19
19
|
return confidentialLedger;
|
|
20
20
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"confidentialLedger.js","sourceRoot":"","sources":["../../src/confidentialLedger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,
|
|
1
|
+
{"version":3,"file":"confidentialLedger.js","sourceRoot":"","sources":["../../src/confidentialLedger.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAItE,OAAO,2BAA2B,MAAM,oCAAoC,CAAC;AAa7E,MAAM,CAAC,OAAO,UAAU,kBAAkB,CACxC,aAAqB,EACrB,yBAAiC,EACjC,oBAAsD,EACtD,IAAoB;;IAEpB,IAAI,WAAwC,CAAC;IAC7C,IAAI,OAAsB,CAAC;IAE3B,IAAI,iBAAiB,CAAC,oBAAoB,CAAC,EAAE;QAC3C,WAAW,GAAG,oBAAoB,CAAC;QACnC,OAAO,GAAG,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,EAAE,CAAC;KACtB;SAAM;QACL,OAAO,GAAG,oBAAoB,aAApB,oBAAoB,cAApB,oBAAoB,GAAI,EAAE,CAAC;KACtC;IAED,MAAM,UAAU,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU,mCAAI,EAAE,CAAC;IAC7C,UAAU,CAAC,EAAE,GAAG,yBAAyB,CAAC;IAC1C,MAAM,kBAAkB,GAAG,2BAA2B,CAAC,aAAa,EAAE,WAAY,kCAC7E,OAAO,KACV,UAAU,IACV,CAAC;IACH,OAAO,kBAAkB,CAAC;AAC5B,CAAC","sourcesContent":["// 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 ledgerBaseUrl: string,\n ledgerIdentityCertificate: string,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: string,\n ledgerIdentityCertificate: string,\n credentials: TokenCredential,\n options?: ClientOptions\n): ConfidentialLedgerClient;\nexport default function ConfidentialLedger(\n ledgerBaseUrl: 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(ledgerBaseUrl, credentials!, {\n ...options,\n tlsOptions,\n });\n return confidentialLedger;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientDefinitions.js","sourceRoot":"","sources":["../../../../src/generated/src/clientDefinitions.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n GetConstitutionParameters,\n GetConsortiumMembersParameters,\n GetEnclaveQuotesParameters,\n ListCollectionsParameters,\n ListLedgerEntriesParameters,\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 ListCollections200Response,\n ListCollectionsdefaultResponse,\n ListLedgerEntries200Response,\n ListLedgerEntriesdefaultResponse,\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 { Client, StreamableMethod } from \"@azure-rest/core-client\";\n\nexport interface GetConstitution {\n /** The constitution is a script that assesses and applies proposals from consortium members. */\n get(\n options?: GetConstitutionParameters\n ): StreamableMethod<\n GetConstitution200Response | GetConstitutiondefaultResponse\n >;\n}\n\nexport interface GetConsortiumMembers {\n /** Consortium members can manage the Confidential Ledger. */\n get(\n options?: GetConsortiumMembersParameters\n ): StreamableMethod<\n GetConsortiumMembers200Response | GetConsortiumMembersdefaultResponse\n >;\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 ): StreamableMethod<\n GetEnclaveQuotes200Response | GetEnclaveQuotesdefaultResponse\n >;\n}\n\nexport interface ListCollections {\n /** Collection ids are user-created collections of ledger entries */\n get(\n options?: ListCollectionsParameters\n ): StreamableMethod<\n ListCollections200Response | ListCollectionsdefaultResponse\n >;\n}\n\nexport interface ListLedgerEntries {\n /** A collection id may optionally be specified. Only entries in the specified (or default) collection will be returned. */\n get(\n options?: ListLedgerEntriesParameters\n ): StreamableMethod<\n ListLedgerEntries200Response | ListLedgerEntriesdefaultResponse\n >;\n /** A collection id may optionally be specified. */\n post(\n options: PostLedgerEntryParameters\n ): StreamableMethod<\n PostLedgerEntry200Response | PostLedgerEntrydefaultResponse\n >;\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 ): StreamableMethod<\n GetLedgerEntry200Response | GetLedgerEntrydefaultResponse\n >;\n}\n\nexport interface GetReceipt {\n /** Gets a receipt certifying ledger contents at a particular transaction id. */\n get(\n options?: GetReceiptParameters\n ): StreamableMethod<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 ): StreamableMethod<\n GetTransactionStatus200Response | GetTransactionStatusdefaultResponse\n >;\n}\n\nexport interface GetCurrentLedgerEntry {\n /** A collection id may optionally be specified. */\n get(\n options?: GetCurrentLedgerEntryParameters\n ): StreamableMethod<\n GetCurrentLedgerEntry200Response | GetCurrentLedgerEntrydefaultResponse\n >;\n}\n\nexport interface DeleteUser {\n /** Deletes a user from the Confidential Ledger. */\n delete(\n options?: DeleteUserParameters\n ): StreamableMethod<DeleteUser204Response | DeleteUserdefaultResponse>;\n /** Gets a user. */\n get(\n options?: GetUserParameters\n ): StreamableMethod<GetUser200Response | GetUserdefaultResponse>;\n /** A JSON merge patch is applied for existing users */\n patch(\n options: CreateOrUpdateUserParameters\n ): StreamableMethod<\n CreateOrUpdateUser200Response | CreateOrUpdateUserdefaultResponse\n >;\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/collections' has methods for the following verbs: get */\n (path: \"/app/collections\"): ListCollections;\n /** Resource for '/app/transactions' has methods for the following verbs: get, post */\n (path: \"/app/transactions\"): ListLedgerEntries;\n /** Resource for '/app/transactions/\\{transactionId\\}' has methods for the following verbs: get */\n (\n path: \"/app/transactions/{transactionId}\",\n transactionId: string\n ): GetLedgerEntry;\n /** Resource for '/app/transactions/\\{transactionId\\}/receipt' has methods for the following verbs: get */\n (\n path: \"/app/transactions/{transactionId}/receipt\",\n transactionId: string\n ): GetReceipt;\n /** Resource for '/app/transactions/\\{transactionId\\}/status' has methods for the following verbs: get */\n (\n path: \"/app/transactions/{transactionId}/status\",\n transactionId: string\n ): 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): DeleteUser;\n}\n\nexport type ConfidentialLedgerClient = Client & {\n path: Routes;\n};\n"]}
|
|
@@ -1,13 +1,21 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { getClient } from "@azure-rest/core-client";
|
|
4
|
-
export default function
|
|
4
|
+
export default function createClient(ledgerUri, credentials, options = {}) {
|
|
5
5
|
var _a, _b;
|
|
6
6
|
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${ledgerUri}`;
|
|
7
|
-
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "
|
|
7
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-05-13";
|
|
8
8
|
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
9
|
-
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
9
|
+
scopes: ["https://confidential-ledger.azure.com/.default"]
|
|
10
10
|
} });
|
|
11
|
-
|
|
11
|
+
const userAgentInfo = `azsdk-js-confidential-ledger-rest/1.0.0-beta.3`;
|
|
12
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
13
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
14
|
+
: `${userAgentInfo}`;
|
|
15
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
16
|
+
userAgentPrefix
|
|
17
|
+
} });
|
|
18
|
+
const client = getClient(baseUrl, credentials, options);
|
|
19
|
+
return client;
|
|
12
20
|
}
|
|
13
21
|
//# sourceMappingURL=confidentialLedger.js.map
|