@fluidframework/azure-client 1.2.0-106934 → 1.2.0
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/.eslintrc.js +5 -37
- package/.prettierignore +5 -0
- package/README.md +88 -29
- package/api-extractor.json +10 -10
- package/dist/AzureAudience.d.ts.map +1 -1
- package/dist/AzureAudience.js.map +1 -1
- package/dist/AzureClient.d.ts.map +1 -1
- package/dist/AzureClient.js.map +1 -1
- package/dist/AzureFunctionTokenProvider.d.ts +4 -0
- package/dist/AzureFunctionTokenProvider.d.ts.map +1 -1
- package/dist/AzureFunctionTokenProvider.js +4 -0
- package/dist/AzureFunctionTokenProvider.js.map +1 -1
- package/dist/AzureUrlResolver.d.ts +7 -0
- package/dist/AzureUrlResolver.d.ts.map +1 -1
- package/dist/AzureUrlResolver.js +7 -0
- package/dist/AzureUrlResolver.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/interfaces.d.ts.map +1 -1
- package/dist/interfaces.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.d.ts.map +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/lib/AzureAudience.d.ts.map +1 -1
- package/lib/AzureAudience.js.map +1 -1
- package/lib/AzureClient.d.ts.map +1 -1
- package/lib/AzureClient.js.map +1 -1
- package/lib/AzureFunctionTokenProvider.d.ts +4 -0
- package/lib/AzureFunctionTokenProvider.d.ts.map +1 -1
- package/lib/AzureFunctionTokenProvider.js +4 -0
- package/lib/AzureFunctionTokenProvider.js.map +1 -1
- package/lib/AzureUrlResolver.d.ts +7 -0
- package/lib/AzureUrlResolver.d.ts.map +1 -1
- package/lib/AzureUrlResolver.js +7 -0
- package/lib/AzureUrlResolver.js.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js.map +1 -1
- package/lib/interfaces.d.ts.map +1 -1
- package/lib/interfaces.js.map +1 -1
- package/lib/packageVersion.d.ts +1 -1
- package/lib/packageVersion.d.ts.map +1 -1
- package/lib/packageVersion.js +1 -1
- package/lib/packageVersion.js.map +1 -1
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js.map +1 -1
- package/package.json +92 -97
- package/src/AzureAudience.ts +19 -19
- package/src/AzureClient.ts +203 -203
- package/src/AzureFunctionTokenProvider.ts +35 -31
- package/src/AzureUrlResolver.ts +87 -80
- package/src/index.ts +13 -13
- package/src/interfaces.ts +66 -66
- package/src/packageVersion.ts +1 -1
- package/src/utils.ts +7 -7
- package/tsconfig.esnext.json +5 -5
- package/tsconfig.json +9 -9
package/src/AzureUrlResolver.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
6
6
|
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
DriverHeader,
|
|
8
|
+
IFluidResolvedUrl,
|
|
9
|
+
IResolvedUrl,
|
|
10
|
+
IUrlResolver,
|
|
11
11
|
} from "@fluidframework/driver-definitions";
|
|
12
12
|
|
|
13
13
|
/**
|
|
@@ -18,89 +18,96 @@ import {
|
|
|
18
18
|
* providers that fulfill the {@link @fluidframework/routerlicious-driver#ITokenProvider} interface.
|
|
19
19
|
*/
|
|
20
20
|
export class AzureUrlResolver implements IUrlResolver {
|
|
21
|
-
|
|
21
|
+
public constructor() {}
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
23
|
+
public async resolve(request: IRequest): Promise<IFluidResolvedUrl> {
|
|
24
|
+
const { ordererUrl, storageUrl, tenantId, containerId } = decodeAzureUrl(request.url);
|
|
25
|
+
// determine whether the request is for creating of a new container.
|
|
26
|
+
// such request has the `createNew` header set to true and doesn't have a container ID.
|
|
27
|
+
if (request.headers && request.headers[DriverHeader.createNew] === true) {
|
|
28
|
+
return {
|
|
29
|
+
endpoints: {
|
|
30
|
+
deltaStorageUrl: `${ordererUrl}/deltas/${tenantId}/new`,
|
|
31
|
+
ordererUrl,
|
|
32
|
+
storageUrl: `${storageUrl}/repos/${tenantId}`,
|
|
33
|
+
},
|
|
34
|
+
// id is a mandatory attribute, but it's ignored by the driver for new container requests.
|
|
35
|
+
id: "",
|
|
36
|
+
// tokens attribute is redundant as all tokens are generated via ITokenProvider
|
|
37
|
+
tokens: {},
|
|
38
|
+
type: "fluid",
|
|
39
|
+
url: `${ordererUrl}/${tenantId}/new`,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
if (containerId === undefined) {
|
|
43
|
+
throw new Error("Azure URL did not contain containerId");
|
|
44
|
+
}
|
|
45
|
+
const documentUrl = `${ordererUrl}/${tenantId}/${containerId}`;
|
|
46
|
+
return {
|
|
47
|
+
endpoints: {
|
|
48
|
+
deltaStorageUrl: `${ordererUrl}/deltas/${tenantId}/${containerId}`,
|
|
49
|
+
ordererUrl,
|
|
50
|
+
storageUrl: `${storageUrl}/repos/${tenantId}`,
|
|
51
|
+
},
|
|
52
|
+
id: containerId,
|
|
53
|
+
tokens: {},
|
|
54
|
+
type: "fluid",
|
|
55
|
+
url: documentUrl,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
59
|
+
public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
|
|
60
|
+
if (resolvedUrl.type !== "fluid") {
|
|
61
|
+
throw new Error("Invalid Resolved Url");
|
|
62
|
+
}
|
|
63
|
+
return `${resolvedUrl.url}/${relativeUrl}`;
|
|
64
|
+
}
|
|
65
65
|
}
|
|
66
66
|
|
|
67
67
|
function decodeAzureUrl(urlString: string): {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
68
|
+
ordererUrl: string;
|
|
69
|
+
storageUrl: string;
|
|
70
|
+
tenantId: string;
|
|
71
|
+
containerId?: string;
|
|
72
72
|
} {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
73
|
+
const url = new URL(urlString);
|
|
74
|
+
const ordererUrl = url.origin;
|
|
75
|
+
const searchParams = url.searchParams;
|
|
76
|
+
const storageUrl = searchParams.get("storage");
|
|
77
|
+
if (storageUrl === null) {
|
|
78
|
+
throw new Error("Azure URL did not contain a storage URL");
|
|
79
|
+
}
|
|
80
|
+
const tenantId = searchParams.get("tenantId");
|
|
81
|
+
if (tenantId === null) {
|
|
82
|
+
throw new Error("Azure URL did not contain a tenant ID");
|
|
83
|
+
}
|
|
84
|
+
const storageUrlDecoded = decodeURIComponent(storageUrl);
|
|
85
|
+
const tenantIdDecoded = decodeURIComponent(tenantId);
|
|
86
|
+
const containerId = searchParams.get("containerId");
|
|
87
|
+
const containerIdDecoded = containerId !== null ? decodeURIComponent(containerId) : undefined;
|
|
88
|
+
return {
|
|
89
|
+
ordererUrl,
|
|
90
|
+
storageUrl: storageUrlDecoded,
|
|
91
|
+
tenantId: tenantIdDecoded,
|
|
92
|
+
containerId: containerIdDecoded,
|
|
93
|
+
};
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
+
/**
|
|
97
|
+
* Creates a request object that can be passed to {@link @fluidframework/fluid-static#IFluidContainer.attach} to
|
|
98
|
+
* request creation of a new Fluid Container on the Azure service.
|
|
99
|
+
*
|
|
100
|
+
* @param endpointUrl - URI to the Azure Fluid Relay service discovery endpoint.
|
|
101
|
+
* @param tenantId - Unique tenant identifier.
|
|
102
|
+
*/
|
|
96
103
|
export const createAzureCreateNewRequest = (endpointUrl: string, tenantId: string): IRequest => {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
104
|
+
const url = new URL(endpointUrl);
|
|
105
|
+
url.searchParams.append("storage", encodeURIComponent(endpointUrl));
|
|
106
|
+
url.searchParams.append("tenantId", encodeURIComponent(tenantId));
|
|
107
|
+
return {
|
|
108
|
+
url: url.href,
|
|
109
|
+
headers: {
|
|
110
|
+
[DriverHeader.createNew]: true,
|
|
111
|
+
},
|
|
112
|
+
};
|
|
106
113
|
};
|
package/src/index.ts
CHANGED
|
@@ -13,19 +13,19 @@ export { AzureAudience } from "./AzureAudience";
|
|
|
13
13
|
export { AzureClient } from "./AzureClient";
|
|
14
14
|
export { AzureFunctionTokenProvider } from "./AzureFunctionTokenProvider";
|
|
15
15
|
export {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
16
|
+
AzureClientProps,
|
|
17
|
+
AzureConnectionConfig,
|
|
18
|
+
AzureConnectionConfigType,
|
|
19
|
+
AzureContainerServices,
|
|
20
|
+
AzureContainerVersion,
|
|
21
|
+
AzureGetVersionsOptions,
|
|
22
|
+
AzureLocalConnectionConfig,
|
|
23
|
+
AzureMember,
|
|
24
|
+
AzureRemoteConnectionConfig,
|
|
25
|
+
AzureUser,
|
|
26
|
+
IAzureAudience,
|
|
27
|
+
ITelemetryBaseEvent,
|
|
28
|
+
ITelemetryBaseLogger,
|
|
29
29
|
} from "./interfaces";
|
|
30
30
|
|
|
31
31
|
export { ITokenProvider, ITokenResponse } from "@fluidframework/routerlicious-driver";
|
package/src/interfaces.ts
CHANGED
|
@@ -14,40 +14,40 @@ export { ITelemetryBaseEvent, ITelemetryBaseLogger } from "@fluidframework/commo
|
|
|
14
14
|
* Props for initializing a new AzureClient instance
|
|
15
15
|
*/
|
|
16
16
|
export interface AzureClientProps {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Configuration for establishing a connection with the Azure Fluid Relay.
|
|
19
|
+
*/
|
|
20
|
+
readonly connection: AzureRemoteConnectionConfig | AzureLocalConnectionConfig;
|
|
21
|
+
/**
|
|
22
|
+
* Optional. A logger instance to receive diagnostic messages.
|
|
23
|
+
*/
|
|
24
|
+
readonly logger?: ITelemetryBaseLogger;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* Container version metadata.
|
|
29
29
|
*/
|
|
30
30
|
export interface AzureContainerVersion {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
/**
|
|
32
|
+
* Version ID
|
|
33
|
+
*/
|
|
34
|
+
id: string;
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
/**
|
|
37
|
+
* Time when version was generated.
|
|
38
|
+
* ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ
|
|
39
|
+
*/
|
|
40
|
+
date?: string;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/**
|
|
44
44
|
* Options for "Get Container Versions" API.
|
|
45
45
|
*/
|
|
46
46
|
export interface AzureGetVersionsOptions {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Max number of versions
|
|
49
|
+
*/
|
|
50
|
+
maxCount: number;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
/**
|
|
@@ -61,42 +61,42 @@ export type AzureConnectionConfigType = "local" | "remote";
|
|
|
61
61
|
* Parameters for establishing a connection with the Azure Fluid Relay.
|
|
62
62
|
*/
|
|
63
63
|
export interface AzureConnectionConfig {
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
64
|
+
/**
|
|
65
|
+
* The type of connection. Whether we're connecting to a remote Fluid relay server or a local instance.
|
|
66
|
+
*/
|
|
67
|
+
type: AzureConnectionConfigType;
|
|
68
|
+
/**
|
|
69
|
+
* URI to the Azure Fluid Relay service discovery endpoint.
|
|
70
|
+
*/
|
|
71
|
+
endpoint: string;
|
|
72
|
+
/**
|
|
73
|
+
* Instance that provides Azure Fluid Relay endpoint tokens.
|
|
74
|
+
*/
|
|
75
|
+
tokenProvider: ITokenProvider;
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Parameters for establishing a remote connection with the Azure Fluid Relay.
|
|
80
80
|
*/
|
|
81
81
|
export interface AzureRemoteConnectionConfig extends AzureConnectionConfig {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
82
|
+
/**
|
|
83
|
+
* The type of connection. Set to a remote connection.
|
|
84
|
+
*/
|
|
85
|
+
type: "remote";
|
|
86
|
+
/**
|
|
87
|
+
* Unique tenant identifier.
|
|
88
|
+
*/
|
|
89
|
+
tenantId: string;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
/**
|
|
93
93
|
* Parameters for establishing a local connection with a local instance of the Azure Fluid Relay.
|
|
94
94
|
*/
|
|
95
95
|
export interface AzureLocalConnectionConfig extends AzureConnectionConfig {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
/**
|
|
97
|
+
* The type of connection. Set to a remote connection.
|
|
98
|
+
*/
|
|
99
|
+
type: "local";
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
/**
|
|
@@ -107,11 +107,11 @@ export interface AzureLocalConnectionConfig extends AzureConnectionConfig {
|
|
|
107
107
|
* will not be included here but rather on the FluidContainer class itself.
|
|
108
108
|
*/
|
|
109
109
|
export interface AzureContainerServices {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
/**
|
|
111
|
+
* Provides an object that can be used to get the users that are present in this Fluid session and
|
|
112
|
+
* listeners for when the roster has any changes from users joining/leaving the session
|
|
113
|
+
*/
|
|
114
|
+
audience: IAzureAudience;
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
/**
|
|
@@ -125,15 +125,15 @@ export interface AzureContainerServices {
|
|
|
125
125
|
// TODO: this should be updated to use something other than `any` (unknown)
|
|
126
126
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
127
|
export interface AzureUser<T = any> extends IUser {
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
128
|
+
/**
|
|
129
|
+
* The user's name
|
|
130
|
+
*/
|
|
131
|
+
name: string;
|
|
132
132
|
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
133
|
+
/**
|
|
134
|
+
* Custom, app-specific user information
|
|
135
|
+
*/
|
|
136
|
+
additionalDetails?: T;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
139
|
/**
|
|
@@ -148,15 +148,15 @@ export interface AzureUser<T = any> extends IUser {
|
|
|
148
148
|
// TODO: this should be updated to use something other than `any` (unknown)
|
|
149
149
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
150
150
|
export interface AzureMember<T = any> extends IMember {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
151
|
+
/**
|
|
152
|
+
* {@inheritDoc AzureUser.name}
|
|
153
|
+
*/
|
|
154
|
+
userName: string;
|
|
155
155
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
156
|
+
/**
|
|
157
|
+
* {@inheritDoc AzureUser.additionalDetails}
|
|
158
|
+
*/
|
|
159
|
+
additionalDetails?: T;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
162
|
/**
|
package/src/packageVersion.ts
CHANGED
package/src/utils.ts
CHANGED
|
@@ -3,25 +3,25 @@
|
|
|
3
3
|
* Licensed under the MIT License.
|
|
4
4
|
*/
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
AzureConnectionConfig,
|
|
7
|
+
AzureLocalConnectionConfig,
|
|
8
|
+
AzureRemoteConnectionConfig,
|
|
9
9
|
} from "./interfaces";
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Type guard for validating a given AzureConnectionConfig is a remote connection type (AzureRemoteConnectionConfig)
|
|
13
13
|
*/
|
|
14
14
|
export function isAzureRemoteConnectionConfig(
|
|
15
|
-
|
|
15
|
+
connectionConfig: AzureConnectionConfig,
|
|
16
16
|
): connectionConfig is AzureRemoteConnectionConfig {
|
|
17
|
-
|
|
17
|
+
return connectionConfig.type === "remote";
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* Type guard for validating a given AzureConnectionConfig is a local connection type (AzureLocalConnectionConfig)
|
|
22
22
|
*/
|
|
23
23
|
export function isAzureLocalConnectionConfig(
|
|
24
|
-
|
|
24
|
+
connectionConfig: AzureConnectionConfig,
|
|
25
25
|
): connectionConfig is AzureLocalConnectionConfig {
|
|
26
|
-
|
|
26
|
+
return connectionConfig.type === "local";
|
|
27
27
|
}
|
package/tsconfig.esnext.json
CHANGED
package/tsconfig.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
"extends": "@fluidframework/build-common/ts-common-config.json",
|
|
3
|
+
"compilerOptions": {
|
|
4
|
+
"rootDir": "./src",
|
|
5
|
+
"outDir": "./dist",
|
|
6
|
+
"composite": true,
|
|
7
|
+
"types": ["node"],
|
|
8
|
+
},
|
|
9
|
+
"include": ["src/**/*"],
|
|
10
|
+
"exclude": ["src/test/**/*"],
|
|
11
11
|
}
|