@fluidframework/local-driver 2.0.0-internal.3.0.2 → 2.0.0-internal.3.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 +19 -22
- package/.mocharc.js +2 -2
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +2 -2
- package/dist/auth.js.map +1 -1
- package/dist/localDeltaStorageService.d.ts.map +1 -1
- package/dist/localDeltaStorageService.js.map +1 -1
- package/dist/localDocumentDeltaConnection.d.ts.map +1 -1
- package/dist/localDocumentDeltaConnection.js.map +1 -1
- package/dist/localDocumentService.d.ts.map +1 -1
- package/dist/localDocumentService.js.map +1 -1
- package/dist/localDocumentServiceFactory.d.ts.map +1 -1
- package/dist/localDocumentServiceFactory.js +3 -2
- package/dist/localDocumentServiceFactory.js.map +1 -1
- package/dist/localDocumentStorageService.d.ts.map +1 -1
- package/dist/localDocumentStorageService.js +4 -3
- package/dist/localDocumentStorageService.js.map +1 -1
- package/dist/localResolver.d.ts.map +1 -1
- package/dist/localResolver.js.map +1 -1
- package/dist/localSessionStorageDb.d.ts.map +1 -1
- package/dist/localSessionStorageDb.js.map +1 -1
- package/dist/packageVersion.d.ts +1 -1
- package/dist/packageVersion.js +1 -1
- package/dist/packageVersion.js.map +1 -1
- package/package.json +37 -36
- package/prettier.config.cjs +1 -1
- package/src/auth.ts +35 -29
- package/src/localDeltaStorageService.ts +26 -29
- package/src/localDocumentDeltaConnection.ts +89 -85
- package/src/localDocumentService.ts +106 -98
- package/src/localDocumentServiceFactory.ts +126 -117
- package/src/localDocumentStorageService.ts +17 -10
- package/src/localResolver.ts +55 -55
- package/src/localSessionStorageDb.ts +267 -261
- package/src/packageVersion.ts +1 -1
- package/tsconfig.json +9 -13
package/src/localResolver.ts
CHANGED
|
@@ -7,22 +7,22 @@ import { parse } from "url";
|
|
|
7
7
|
import { assert } from "@fluidframework/common-utils";
|
|
8
8
|
import { IRequest } from "@fluidframework/core-interfaces";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
IFluidResolvedUrl,
|
|
11
|
+
IResolvedUrl,
|
|
12
|
+
IUrlResolver,
|
|
13
|
+
DriverHeader,
|
|
14
14
|
} from "@fluidframework/driver-definitions";
|
|
15
15
|
import { ScopeType } from "@fluidframework/protocol-definitions";
|
|
16
16
|
import { generateToken } from "./auth";
|
|
17
17
|
|
|
18
18
|
export function createLocalResolverCreateNewRequest(documentId: string): IRequest {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
const createNewRequest: IRequest = {
|
|
20
|
+
url: `http://localhost:3000/${documentId}`,
|
|
21
|
+
headers: {
|
|
22
|
+
[DriverHeader.createNew]: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
return createNewRequest;
|
|
26
26
|
}
|
|
27
27
|
|
|
28
28
|
/**
|
|
@@ -30,55 +30,55 @@ export function createLocalResolverCreateNewRequest(documentId: string): IReques
|
|
|
30
30
|
* related local classes.
|
|
31
31
|
*/
|
|
32
32
|
export class LocalResolver implements IUrlResolver {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
private readonly tenantId = "tenantId";
|
|
34
|
+
private readonly tokenKey = "tokenKey";
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
constructor() {}
|
|
37
37
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
38
|
+
/**
|
|
39
|
+
* Resolves URL requests by providing fake URLs with an actually generated
|
|
40
|
+
* token from constant test strings. The root of the URL is fake, but the
|
|
41
|
+
* remaining relative URL can still be parsed.
|
|
42
|
+
* @param request - request to handle
|
|
43
|
+
*/
|
|
44
|
+
public async resolve(request: IRequest): Promise<IResolvedUrl> {
|
|
45
|
+
const parsedUrl = new URL(request.url);
|
|
46
|
+
const fullPath = `${parsedUrl.pathname.substr(1)}${parsedUrl.search}`;
|
|
47
|
+
const documentId = fullPath.split("/")[0];
|
|
48
|
+
const scopes = [ScopeType.DocRead, ScopeType.DocWrite, ScopeType.SummaryWrite];
|
|
49
|
+
const resolved: IFluidResolvedUrl = {
|
|
50
|
+
endpoints: {
|
|
51
|
+
deltaStorageUrl: `http://localhost:3000/deltas/${this.tenantId}/${documentId}`,
|
|
52
|
+
ordererUrl: "http://localhost:3000",
|
|
53
|
+
storageUrl: `http://localhost:3000/repos/${this.tenantId}`,
|
|
54
|
+
},
|
|
55
|
+
id: documentId,
|
|
56
|
+
tokens: { jwt: generateToken(this.tenantId, documentId, this.tokenKey, scopes) },
|
|
57
|
+
type: "fluid",
|
|
58
|
+
url: `fluid-test://localhost:3000/${this.tenantId}/${fullPath}`,
|
|
59
|
+
};
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
return resolved;
|
|
62
|
+
}
|
|
63
63
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
64
|
+
public async getAbsoluteUrl(resolvedUrl: IResolvedUrl, relativeUrl: string): Promise<string> {
|
|
65
|
+
let url = relativeUrl;
|
|
66
|
+
if (url.startsWith("/")) {
|
|
67
|
+
url = url.substr(1);
|
|
68
|
+
}
|
|
69
|
+
const fluidResolvedUrl = resolvedUrl as IFluidResolvedUrl;
|
|
70
70
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
71
|
+
const parsedUrl = parse(fluidResolvedUrl.url);
|
|
72
|
+
if (parsedUrl.pathname === null) {
|
|
73
|
+
throw new Error("Url should contain tenant and docId!!");
|
|
74
|
+
}
|
|
75
|
+
const [, , documentId] = parsedUrl.pathname.split("/");
|
|
76
|
+
assert(!!documentId, 0x09a /* "'documentId' must be a defined, non-zero length string." */);
|
|
77
77
|
|
|
78
|
-
|
|
79
|
-
|
|
78
|
+
return `http://localhost:3000/${documentId}/${url}`;
|
|
79
|
+
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
public createCreateNewRequest(documentId: string): IRequest {
|
|
82
|
+
return createLocalResolverCreateNewRequest(documentId);
|
|
83
|
+
}
|
|
84
84
|
}
|