@azure/web-pubsub 1.0.0-beta.2 → 1.0.1-alpha.20211215.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +40 -0
- package/README.md +118 -31
- package/dist/index.js +1315 -567
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/broadcasting.js +16 -16
- package/dist-esm/samples-dev/broadcasting.js.map +1 -1
- package/dist-esm/samples-dev/directMessage.js +9 -9
- package/dist-esm/samples-dev/directMessage.js.map +1 -1
- package/dist-esm/samples-dev/managingGroups.js +11 -12
- package/dist-esm/samples-dev/managingGroups.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +23 -0
- package/dist-esm/src/generated/generatedClient.js.map +1 -0
- package/dist-esm/src/generated/generatedClientContext.js +41 -0
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -0
- package/dist-esm/src/generated/index.js +10 -2
- package/dist-esm/src/generated/index.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +13 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +368 -0
- package/dist-esm/src/generated/models/mappers.js.map +1 -0
- package/dist-esm/src/generated/models/parameters.js +124 -43
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/operations/healthApi.js +16 -11
- package/dist-esm/src/generated/operations/healthApi.js.map +1 -1
- package/dist-esm/src/generated/operations/index.js +7 -0
- package/dist-esm/src/generated/operations/index.js.map +1 -1
- package/dist-esm/src/generated/operations/webPubSub.js +341 -175
- package/dist-esm/src/generated/operations/webPubSub.js.map +1 -1
- package/dist-esm/src/generated/operationsInterfaces/healthApi.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/healthApi.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js +10 -0
- package/dist-esm/src/generated/operationsInterfaces/index.js.map +1 -0
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js +9 -0
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +1 -0
- package/dist-esm/src/groupClient.js +74 -92
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +280 -196
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/logger.js +1 -1
- package/dist-esm/src/logger.js.map +1 -1
- package/dist-esm/src/parseConnectionString.js +3 -1
- package/dist-esm/src/parseConnectionString.js.map +1 -1
- package/dist-esm/src/reverseProxyPolicy.js +21 -0
- package/dist-esm/src/reverseProxyPolicy.js.map +1 -0
- package/dist-esm/src/utils.js +8 -6
- package/dist-esm/src/utils.js.map +1 -1
- package/dist-esm/src/webPubSubCredentialPolicy.js +18 -18
- package/dist-esm/src/webPubSubCredentialPolicy.js.map +1 -1
- package/dist-esm/test/conn.spec.js +7 -8
- package/dist-esm/test/conn.spec.js.map +1 -1
- package/dist-esm/test/groups.spec.js +39 -38
- package/dist-esm/test/groups.spec.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +95 -49
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/dist-esm/test/integration.spec.js +128 -0
- package/dist-esm/test/integration.spec.js.map +1 -0
- package/dist-esm/test/testEnv.js +5 -1
- package/dist-esm/test/testEnv.js.map +1 -1
- package/package.json +37 -36
- package/types/web-pubsub.d.ts +186 -138
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPI.js +0 -15
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPI.js.map +0 -1
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPIContext.js +0 -34
- package/dist-esm/src/generated/azureWebPubSubServiceRestAPIContext.js.map +0 -1
- package/dist-esm/src/normalizeOptions.js +0 -8
- package/dist-esm/src/normalizeOptions.js.map +0 -1
@@ -1,26 +1,23 @@
|
|
1
|
-
import { __awaiter } from "tslib";
|
2
1
|
// Copyright (c) Microsoft Corporation.
|
3
2
|
// Licensed under the MIT license.
|
4
3
|
/* eslint-disable no-invalid-this */
|
5
|
-
import { env, record } from "@azure/test-
|
4
|
+
import { env, record, isLiveMode } from "@azure-tools/test-recorder";
|
6
5
|
import { WebPubSubServiceClient, AzureKeyCredential } from "../src";
|
7
|
-
import
|
6
|
+
import { assert } from "chai";
|
8
7
|
import environmentSetup from "./testEnv";
|
8
|
+
import { DefaultAzureCredential } from "@azure/identity";
|
9
|
+
/* eslint-disable @typescript-eslint/no-invalid-this */
|
9
10
|
describe("HubClient", function () {
|
10
11
|
let recorder;
|
11
12
|
beforeEach(function () {
|
12
13
|
recorder = record(this, environmentSetup);
|
13
14
|
});
|
14
|
-
afterEach(function () {
|
15
|
+
afterEach(async function () {
|
15
16
|
if (recorder) {
|
16
|
-
recorder.stop();
|
17
|
+
await recorder.stop();
|
17
18
|
}
|
18
19
|
});
|
19
20
|
describe("Constructing a HubClient", () => {
|
20
|
-
let cred;
|
21
|
-
beforeEach(function () {
|
22
|
-
cred = new AzureKeyCredential(env.WPS_API_KEY);
|
23
|
-
});
|
24
21
|
it("takes a connection string, hub name, and options", () => {
|
25
22
|
assert.doesNotThrow(() => {
|
26
23
|
new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, "test-hub", {
|
@@ -30,77 +27,126 @@ describe("HubClient", function () {
|
|
30
27
|
});
|
31
28
|
it("takes an endpoint, an API key, a hub name, and options", () => {
|
32
29
|
assert.doesNotThrow(() => {
|
33
|
-
new WebPubSubServiceClient(env.ENDPOINT,
|
30
|
+
new WebPubSubServiceClient(env.ENDPOINT, new AzureKeyCredential(env.WPS_API_KEY), "test-hub", {
|
31
|
+
retryOptions: { maxRetries: 2 }
|
32
|
+
});
|
33
|
+
});
|
34
|
+
});
|
35
|
+
it("takes an endpoint, DefaultAzureCredential, a hub name, and options", () => {
|
36
|
+
assert.doesNotThrow(() => {
|
37
|
+
new WebPubSubServiceClient(env.ENDPOINT, new DefaultAzureCredential(), "test-hub", {
|
34
38
|
retryOptions: { maxRetries: 2 }
|
35
39
|
});
|
36
40
|
});
|
37
41
|
});
|
38
42
|
});
|
39
43
|
describe("Working with a hub", function () {
|
40
|
-
this.timeout(30000);
|
41
44
|
let client;
|
45
|
+
let lastResponse;
|
46
|
+
function onResponse(response) {
|
47
|
+
lastResponse = response;
|
48
|
+
}
|
42
49
|
beforeEach(function () {
|
43
50
|
client = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, "simplechat");
|
44
51
|
});
|
45
|
-
it("can broadcast", () =>
|
46
|
-
|
47
|
-
assert.equal(
|
48
|
-
|
49
|
-
assert.equal(
|
52
|
+
it("can broadcast", async () => {
|
53
|
+
await client.sendToAll("hello", { contentType: "text/plain", onResponse });
|
54
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
55
|
+
await client.sendToAll({ x: 1, y: 2 }, { onResponse });
|
56
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
50
57
|
const binaryMessage = new Uint8Array(10);
|
51
|
-
|
52
|
-
assert.equal(
|
53
|
-
})
|
54
|
-
it("can
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
58
|
+
await client.sendToAll(binaryMessage.buffer, { onResponse });
|
59
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
60
|
+
});
|
61
|
+
it("can broadcast using the DAC", async () => {
|
62
|
+
const dacClient = new WebPubSubServiceClient(env.ENDPOINT, new DefaultAzureCredential(), "simplechat");
|
63
|
+
await dacClient.sendToAll("hello", { contentType: "text/plain", onResponse });
|
64
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
65
|
+
await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });
|
66
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
59
67
|
const binaryMessage = new Uint8Array(10);
|
60
|
-
|
61
|
-
assert.equal(
|
62
|
-
})
|
63
|
-
it("can
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
+
await dacClient.sendToAll(binaryMessage.buffer, { onResponse });
|
69
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
70
|
+
});
|
71
|
+
it("can broadcast using APIM", async () => {
|
72
|
+
const apimClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, "simplechat", {
|
73
|
+
reverseProxyEndpoint: env.REVERSE_PROXY_ENDPOINT
|
74
|
+
});
|
75
|
+
await apimClient.sendToAll("hello", { contentType: "text/plain", onResponse });
|
76
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
77
|
+
await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });
|
78
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
68
79
|
const binaryMessage = new Uint8Array(10);
|
69
|
-
|
70
|
-
assert.equal(
|
71
|
-
})
|
72
|
-
it("can
|
73
|
-
|
80
|
+
await apimClient.sendToAll(binaryMessage.buffer, { onResponse });
|
81
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
82
|
+
});
|
83
|
+
it("can send messages to a user", async () => {
|
84
|
+
await client.sendToUser("brian", "hello", {
|
85
|
+
contentType: "text/plain",
|
86
|
+
onResponse
|
87
|
+
});
|
88
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
89
|
+
await client.sendToUser("brian", { x: 1, y: 2 }, { onResponse });
|
90
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
91
|
+
const binaryMessage = new Uint8Array(10);
|
92
|
+
await client.sendToUser("brian", binaryMessage.buffer, { onResponse });
|
93
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
94
|
+
});
|
95
|
+
it("can send messages to a connection", async () => {
|
96
|
+
await client.sendToConnection("xxxx", "hello", { contentType: "text/plain", onResponse });
|
97
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
98
|
+
await client.sendToConnection("xxxx", { x: 1, y: 2 }, { onResponse });
|
99
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
100
|
+
const binaryMessage = new Uint8Array(10);
|
101
|
+
await client.sendToConnection("xxxx", binaryMessage.buffer, { onResponse });
|
102
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 202);
|
103
|
+
});
|
104
|
+
// `removeUserFromAllGroups` always times out.
|
105
|
+
it.skip("can manage users", async () => {
|
106
|
+
this.timeout(Infinity);
|
107
|
+
const res = await client.userExists("foo");
|
74
108
|
assert.ok(!res);
|
75
|
-
|
76
|
-
assert.equal(
|
77
|
-
})
|
78
|
-
it("can check if a connection exists",
|
79
|
-
|
109
|
+
await client.removeUserFromAllGroups("brian", { onResponse });
|
110
|
+
assert.equal(lastResponse === null || lastResponse === void 0 ? void 0 : lastResponse.status, 200);
|
111
|
+
});
|
112
|
+
it("can check if a connection exists", async function () {
|
113
|
+
// likely bug in recorder for this test - recording not generating properly
|
114
|
+
if (!isLiveMode())
|
115
|
+
this.skip();
|
116
|
+
const res = await client.connectionExists("xxx");
|
80
117
|
assert.ok(!res);
|
81
|
-
})
|
82
|
-
it("can grant permissions to connections", () =>
|
118
|
+
});
|
119
|
+
it("can grant permissions to connections", async () => {
|
83
120
|
let error;
|
84
121
|
try {
|
85
|
-
|
122
|
+
await client.grantPermission("xxx", "joinLeaveGroup", { targetName: "x" });
|
86
123
|
}
|
87
124
|
catch (e) {
|
88
125
|
error = e;
|
89
126
|
}
|
90
127
|
// grantPermission validates connection ids, so we expect an error here.
|
91
128
|
assert.equal(error.statusCode, 404);
|
92
|
-
})
|
93
|
-
it("can revoke permissions from connections",
|
129
|
+
});
|
130
|
+
it("can revoke permissions from connections", async function () {
|
131
|
+
// likely bug in recorder for this test - recording not generating properly
|
132
|
+
if (!isLiveMode())
|
133
|
+
this.skip();
|
94
134
|
let error;
|
95
135
|
try {
|
96
|
-
|
136
|
+
await client.revokePermission("xxx", "joinLeaveGroup", { targetName: "x" });
|
97
137
|
}
|
98
138
|
catch (e) {
|
99
139
|
error = e;
|
100
140
|
}
|
101
141
|
// grantPermission validates connection ids, so we expect an error here.
|
102
142
|
assert.equal(error.statusCode, 404);
|
103
|
-
})
|
143
|
+
});
|
144
|
+
// service API doesn't work yet.
|
145
|
+
it.skip("can generate client tokens", async () => {
|
146
|
+
await client.getClientAccessToken({
|
147
|
+
userId: "brian"
|
148
|
+
});
|
149
|
+
});
|
104
150
|
});
|
105
151
|
});
|
106
152
|
//# sourceMappingURL=hubs.spec.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,GAAG,EAAY,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,gBAAgB,MAAM,WAAW,CAAC;AAEzC,QAAQ,CAAC,WAAW,EAAE;IACpB,IAAI,QAAkB,CAAC;IACvB,UAAU,CAAC;QACT,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC;QACR,IAAI,QAAQ,EAAE;YACZ,QAAQ,CAAC,IAAI,EAAE,CAAC;SACjB;IACH,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,IAAI,IAAwB,CAAC;QAC7B,UAAU,CAAC;YACT,IAAI,GAAG,IAAI,kBAAkB,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACjD,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,kDAAkD,EA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AAC,EAAE;gBACV,KAAK,GAAG,CAAC,CAAC;aACX;YACD,wEAAwE;YACxE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC,CAAA,CAAC,CAAC;QAEH,EAAE,CAAC,yCAAyC,EAAE,GAAS,EAAE;YACvD,IAAI,KAAK,CAAC;YACV,IAAI;gBACF,MAAM,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;aAC7E;YAAC,OAAO,CAAC,EAAE;gBACV,KAAK,GAAG,CAAC,CAAC;aACX;YACD,wEAAwE;YACxE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC,CAAA,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { env, Recorder, record } from \"@azure/test-utils-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport * as assert from \"assert\";\nimport environmentSetup from \"./testEnv\";\n\ndescribe(\"HubClient\", function() {\n let recorder: Recorder;\n beforeEach(function() {\n recorder = record(this, environmentSetup);\n });\n\n afterEach(function() {\n if (recorder) {\n recorder.stop();\n }\n });\n\n describe(\"Constructing a HubClient\", () => {\n let cred: AzureKeyCredential;\n beforeEach(function() {\n cred = new AzureKeyCredential(env.WPS_API_KEY);\n });\n\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"test-hub\", {\n retryOptions: { maxRetries: 2 }\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.ENDPOINT, cred, \"test-hub\", {\n retryOptions: { maxRetries: 2 }\n });\n });\n });\n });\n\n describe(\"Working with a hub\", function() {\n this.timeout(30000);\n let client: WebPubSubServiceClient;\n beforeEach(function() {\n client = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"simplechat\");\n });\n\n it(\"can broadcast\", async () => {\n let res = await client.sendToAll(\"hello\", { contentType: \"text/plain\" });\n assert.equal(res._response.status, 202);\n\n res = await client.sendToAll({ x: 1, y: 2 });\n assert.equal(res._response.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n res = await client.sendToAll(binaryMessage.buffer);\n assert.equal(res._response.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n let res = await client.sendToUser(\"brian\", \"hello\", { contentType: \"text/plain\" });\n assert.equal(res._response.status, 202);\n\n res = await client.sendToUser(\"brian\", { x: 1, y: 2 });\n assert.equal(res._response.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n res = await client.sendToUser(\"brian\", binaryMessage.buffer);\n assert.equal(res._response.status, 202);\n });\n\n it(\"can send messages to a connection\", async () => {\n let res = await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\" });\n assert.equal(res._response.status, 202);\n\n res = await client.sendToConnection(\"xxxx\", { x: 1, y: 2 });\n assert.equal(res._response.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n res = await client.sendToConnection(\"xxxx\", binaryMessage.buffer);\n assert.equal(res._response.status, 202);\n });\n\n it(\"can manage users\", async () => {\n const res = await client.hasUser(\"foo\");\n assert.ok(!res);\n\n const res2 = await client.removeUserFromAllGroups(\"brian\");\n assert.equal(res2._response.status, 200);\n });\n\n it(\"can check if a connection exists\", async () => {\n const res = await client.hasConnection(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async () => {\n let error;\n try {\n await client.revokePermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n });\n});\n"]}
|
1
|
+
{"version":3,"file":"hubs.spec.js","sourceRoot":"","sources":["../../test/hubs.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,GAAG,EAAY,MAAM,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC/E,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,gBAAgB,MAAM,WAAW,CAAC;AAEzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,uDAAuD;AAEvD,QAAQ,CAAC,WAAW,EAAE;IACpB,IAAI,QAAkB,CAAC;IACvB,UAAU,CAAC;QACT,QAAQ,GAAG,MAAM,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAC5C,CAAC,CAAC,CAAC;IAEH,SAAS,CAAC,KAAK;QACb,IAAI,QAAQ,EAAE;YACZ,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;SACvB;IACH,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;QACxC,EAAE,CAAC,kDAAkD,EAAE,GAAG,EAAE;YAC1D,MAAM,CAAC,YAAY,CAAC,GAAG,EAAE;gBACvB,IAAI,sBAAsB,CAAC,GAAG,CAAC,qBAAqB,EAAE,UAAU,EAAE;oBAChE,YAAY,EAAE,EAAE,UAAU,EAAE,CAAC,EAAE;iBAChC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,wDAAwD,EAAE,GAAG,EAAE;YAChE,MAAM,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AU,EAAE;gBAAE,IAAI,CAAC,IAAI,EAAE,CAAC;YAC/B,IAAI,KAAK,CAAC;YACV,IAAI;gBACF,MAAM,MAAM,CAAC,gBAAgB,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;aAC7E;YAAC,OAAO,CAAC,EAAE;gBACV,KAAK,GAAG,CAAC,CAAC;aACX;YACD,wEAAwE;YACxE,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;QAEH,gCAAgC;QAChC,EAAE,CAAC,IAAI,CAAC,4BAA4B,EAAE,KAAK,IAAI,EAAE;YAC/C,MAAM,MAAM,CAAC,oBAAoB,CAAC;gBAChC,MAAM,EAAE,OAAO;aAChB,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { env, Recorder, record, isLiveMode } from \"@azure-tools/test-recorder\";\nimport { WebPubSubServiceClient, AzureKeyCredential } from \"../src\";\nimport { assert } from \"chai\";\nimport environmentSetup from \"./testEnv\";\nimport { FullOperationResponse } from \"@azure/core-client\";\nimport { DefaultAzureCredential } from \"@azure/identity\";\n/* eslint-disable @typescript-eslint/no-invalid-this */\n\ndescribe(\"HubClient\", function() {\n let recorder: Recorder;\n beforeEach(function() {\n recorder = record(this, environmentSetup);\n });\n\n afterEach(async function() {\n if (recorder) {\n await recorder.stop();\n }\n });\n\n describe(\"Constructing a HubClient\", () => {\n it(\"takes a connection string, hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"test-hub\", {\n retryOptions: { maxRetries: 2 }\n });\n });\n });\n\n it(\"takes an endpoint, an API key, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(\n env.ENDPOINT,\n new AzureKeyCredential(env.WPS_API_KEY),\n \"test-hub\",\n {\n retryOptions: { maxRetries: 2 }\n }\n );\n });\n });\n\n it(\"takes an endpoint, DefaultAzureCredential, a hub name, and options\", () => {\n assert.doesNotThrow(() => {\n new WebPubSubServiceClient(env.ENDPOINT, new DefaultAzureCredential(), \"test-hub\", {\n retryOptions: { maxRetries: 2 }\n });\n });\n });\n });\n\n describe(\"Working with a hub\", function() {\n let client: WebPubSubServiceClient;\n let lastResponse: FullOperationResponse | undefined;\n function onResponse(response: FullOperationResponse) {\n lastResponse = response;\n }\n beforeEach(function() {\n client = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"simplechat\");\n });\n\n it(\"can broadcast\", async () => {\n await client.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using the DAC\", async () => {\n const dacClient = new WebPubSubServiceClient(\n env.ENDPOINT,\n new DefaultAzureCredential(),\n \"simplechat\"\n );\n\n await dacClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await dacClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await dacClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can broadcast using APIM\", async () => {\n const apimClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, \"simplechat\", {\n reverseProxyEndpoint: env.REVERSE_PROXY_ENDPOINT\n });\n\n await apimClient.sendToAll(\"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await apimClient.sendToAll({ x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await apimClient.sendToAll(binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a user\", async () => {\n await client.sendToUser(\"brian\", \"hello\", {\n contentType: \"text/plain\",\n onResponse\n });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToUser(\"brian\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n\n const binaryMessage = new Uint8Array(10);\n await client.sendToUser(\"brian\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n it(\"can send messages to a connection\", async () => {\n await client.sendToConnection(\"xxxx\", \"hello\", { contentType: \"text/plain\", onResponse });\n assert.equal(lastResponse?.status, 202);\n\n await client.sendToConnection(\"xxxx\", { x: 1, y: 2 }, { onResponse });\n assert.equal(lastResponse?.status, 202);\n const binaryMessage = new Uint8Array(10);\n\n await client.sendToConnection(\"xxxx\", binaryMessage.buffer, { onResponse });\n assert.equal(lastResponse?.status, 202);\n });\n\n // `removeUserFromAllGroups` always times out.\n it.skip(\"can manage users\", async () => {\n this.timeout(Infinity);\n const res = await client.userExists(\"foo\");\n assert.ok(!res);\n await client.removeUserFromAllGroups(\"brian\", { onResponse });\n assert.equal(lastResponse?.status, 200);\n });\n\n it(\"can check if a connection exists\", async function() {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n const res = await client.connectionExists(\"xxx\");\n assert.ok(!res);\n });\n\n it(\"can grant permissions to connections\", async () => {\n let error;\n try {\n await client.grantPermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n it(\"can revoke permissions from connections\", async function() {\n // likely bug in recorder for this test - recording not generating properly\n if (!isLiveMode()) this.skip();\n let error;\n try {\n await client.revokePermission(\"xxx\", \"joinLeaveGroup\", { targetName: \"x\" });\n } catch (e) {\n error = e;\n }\n // grantPermission validates connection ids, so we expect an error here.\n assert.equal(error.statusCode, 404);\n });\n\n // service API doesn't work yet.\n it.skip(\"can generate client tokens\", async () => {\n await client.getClientAccessToken({\n userId: \"brian\"\n });\n });\n });\n});\n"]}
|
@@ -0,0 +1,128 @@
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
2
|
+
// Licensed under the MIT license.
|
3
|
+
/* eslint-disable no-invalid-this */
|
4
|
+
import { WebPubSubServiceClient } from "../src/index";
|
5
|
+
import { env, isLiveMode } from "@azure-tools/test-recorder";
|
6
|
+
import { assert } from "chai";
|
7
|
+
import ws from "ws";
|
8
|
+
function defer() {
|
9
|
+
let actualResolve;
|
10
|
+
let actualReject;
|
11
|
+
const promise = new Promise((resolve, reject) => {
|
12
|
+
actualResolve = resolve;
|
13
|
+
actualReject = reject;
|
14
|
+
});
|
15
|
+
return {
|
16
|
+
promise,
|
17
|
+
resolve: actualResolve,
|
18
|
+
reject: actualReject
|
19
|
+
};
|
20
|
+
}
|
21
|
+
class SimpleWebSocketFrame {
|
22
|
+
constructor(data, isBinary) {
|
23
|
+
this.data = data;
|
24
|
+
this.isBinary = isBinary;
|
25
|
+
if (!isBinary) {
|
26
|
+
this.dataAsString = data.toString();
|
27
|
+
}
|
28
|
+
}
|
29
|
+
isEndSignal() {
|
30
|
+
return (this.isBinary &&
|
31
|
+
this.data instanceof Buffer &&
|
32
|
+
this.data[0] === 5 &&
|
33
|
+
this.data[1] === 1 &&
|
34
|
+
this.data[2] === 1);
|
35
|
+
}
|
36
|
+
}
|
37
|
+
class PubSubWebSocketFrame {
|
38
|
+
constructor(data, isBinary) {
|
39
|
+
assert.isFalse(isBinary);
|
40
|
+
this.dataAsString = data.toString();
|
41
|
+
this.message = JSON.parse(this.dataAsString);
|
42
|
+
}
|
43
|
+
isEndSignal() {
|
44
|
+
return this.message.dataType === "binary" && this.message.data === "BQEB";
|
45
|
+
}
|
46
|
+
}
|
47
|
+
function getEndSignal() {
|
48
|
+
// magic number 511
|
49
|
+
const payload = new Uint8Array(3);
|
50
|
+
payload[0] = 5;
|
51
|
+
payload[1] = 1;
|
52
|
+
payload[2] = 1;
|
53
|
+
return payload;
|
54
|
+
}
|
55
|
+
describe("ServiceClient to manage the connected WebSocket connections", function () {
|
56
|
+
it("Simple clients can receive expected messages with different content types", async function () {
|
57
|
+
if (!isLiveMode())
|
58
|
+
this.skip();
|
59
|
+
const hub = "SimpleClientCanReceiveMessage";
|
60
|
+
const messages = [];
|
61
|
+
// Get token
|
62
|
+
const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);
|
63
|
+
const token = await serviceClient.getClientAccessToken();
|
64
|
+
const endSignal = defer();
|
65
|
+
// Start simple WebSocket connections
|
66
|
+
const client = new ws.WebSocket(token.url);
|
67
|
+
client.on("message", (data, isBinary) => {
|
68
|
+
const frame = new SimpleWebSocketFrame(data, isBinary);
|
69
|
+
if (frame.isEndSignal()) {
|
70
|
+
endSignal.resolve();
|
71
|
+
client.close();
|
72
|
+
}
|
73
|
+
else {
|
74
|
+
messages.push(frame);
|
75
|
+
}
|
76
|
+
});
|
77
|
+
client.on("open", async () => {
|
78
|
+
// send to all
|
79
|
+
// Send a JSON message
|
80
|
+
await serviceClient.sendToAll({ message: "Hello world!" });
|
81
|
+
// Send a plain text message
|
82
|
+
await serviceClient.sendToAll("Hi there!", { contentType: "text/plain" });
|
83
|
+
// Send the binary end signal message
|
84
|
+
await serviceClient.sendToAll(getEndSignal());
|
85
|
+
});
|
86
|
+
await endSignal.promise;
|
87
|
+
assert.equal(messages.length, 2);
|
88
|
+
assert.equal(messages[0].dataAsString, '{"message":"Hello world!"}');
|
89
|
+
assert.equal(messages[1].dataAsString, "Hi there!");
|
90
|
+
});
|
91
|
+
it("Subprotocol clients can receive expected messages with different content types", async function () {
|
92
|
+
if (!isLiveMode())
|
93
|
+
this.skip();
|
94
|
+
const hub = "PubSubClientCanReceiveMessage";
|
95
|
+
const messages = [];
|
96
|
+
// Get token
|
97
|
+
const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);
|
98
|
+
const token = await serviceClient.getClientAccessToken();
|
99
|
+
const endSignal = defer();
|
100
|
+
// Start simple WebSocket connections
|
101
|
+
const client = new ws.WebSocket(token.url, "json.webpubsub.azure.v1");
|
102
|
+
client.on("message", (data, isBinary) => {
|
103
|
+
const frame = new PubSubWebSocketFrame(data, isBinary);
|
104
|
+
if (frame.isEndSignal()) {
|
105
|
+
endSignal.resolve();
|
106
|
+
client.close();
|
107
|
+
}
|
108
|
+
else {
|
109
|
+
messages.push(frame);
|
110
|
+
}
|
111
|
+
});
|
112
|
+
client.on("open", async () => {
|
113
|
+
// send to all
|
114
|
+
// Send a JSON message
|
115
|
+
await serviceClient.sendToAll({ message: "Hello world!" });
|
116
|
+
// Send a plain text message
|
117
|
+
await serviceClient.sendToAll("Hi there!", { contentType: "text/plain" });
|
118
|
+
// Send the binary end signal message
|
119
|
+
await serviceClient.sendToAll(getEndSignal());
|
120
|
+
});
|
121
|
+
await endSignal.promise;
|
122
|
+
assert.equal(messages.length, 3);
|
123
|
+
assert.equal(messages[0].message.event, "connected");
|
124
|
+
assert.equal(messages[1].dataAsString, '{"type":"message","from":"server","dataType":"json","data":{"message":"Hello world!"}}');
|
125
|
+
assert.equal(messages[2].dataAsString, '{"type":"message","from":"server","dataType":"text","data":"Hi there!"}');
|
126
|
+
});
|
127
|
+
});
|
128
|
+
//# sourceMappingURL=integration.spec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"integration.spec.js","sourceRoot":"","sources":["../../test/integration.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE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,EAAE,CAAC,IAAI,EAAE,QAAQ,EAAE,EAAE;YACtC,MAAM,KAAK,GAAG,IAAI,oBAAoB,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACvD,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE;gBACvB,SAAS,CAAC,OAAO,EAAE,CAAC;gBACpB,MAAM,CAAC,KAAK,EAAE,CAAC;aAChB;iBAAM;gBACL,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;aACtB;QACH,CAAC,CAAC,CAAC;QACH,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,IAAI,EAAE;YAC3B,cAAc;YACd,sBAAsB;YACtB,MAAM,aAAa,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,cAAc,EAAE,CAAC,CAAC;YAE3D,4BAA4B;YAC5B,MAAM,aAAa,CAAC,SAAS,CAAC,WAAW,EAAE,EAAE,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC;YAE1E,qCAAqC;YACrC,MAAM,aAAa,CAAC,SAAS,CAAC,YAAY,EAAE,CAAC,CAAC;QAChD,CAAC,CAAC,CAAC;QAEH,MAAM,SAAS,CAAC,OAAO,CAAC;QAExB,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACjC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QACrD,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,wFAAwF,CACzF,CAAC;QACF,MAAM,CAAC,KAAK,CACV,QAAQ,CAAC,CAAC,CAAC,CAAC,YAAY,EACxB,yEAAyE,CAC1E,CAAC;IACJ,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n/* eslint-disable no-invalid-this */\nimport { WebPubSubServiceClient } from \"../src/index\";\nimport { env, isLiveMode } from \"@azure-tools/test-recorder\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport ws from \"ws\";\n\nfunction defer<T>(): {\n promise: Promise<T>;\n resolve: (t: T) => void;\n reject: (err: Error) => void;\n} {\n let actualResolve: (t: T) => void;\n let actualReject: (err: Error) => void;\n\n const promise = new Promise<T>((resolve, reject) => {\n actualResolve = resolve;\n actualReject = reject;\n });\n\n return {\n promise,\n resolve: actualResolve!,\n reject: actualReject!\n };\n}\n\nclass SimpleWebSocketFrame {\n public dataAsString: string | undefined;\n constructor(public data: Buffer | ArrayBuffer | Buffer[], public isBinary: boolean) {\n if (!isBinary) {\n this.dataAsString = data.toString();\n }\n }\n\n isEndSignal(): boolean {\n return (\n this.isBinary &&\n this.data instanceof Buffer &&\n this.data[0] === 5 &&\n this.data[1] === 1 &&\n this.data[2] === 1\n );\n }\n}\n\nclass PubSubWebSocketFrame {\n public message: any;\n public dataAsString: string;\n constructor(data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) {\n assert.isFalse(isBinary);\n this.dataAsString = data.toString();\n this.message = JSON.parse(this.dataAsString);\n }\n\n isEndSignal(): boolean {\n return this.message.dataType === \"binary\" && this.message.data === \"BQEB\";\n }\n}\n\nfunction getEndSignal(): Uint8Array {\n // magic number 511\n const payload = new Uint8Array(3);\n payload[0] = 5;\n payload[1] = 1;\n payload[2] = 1;\n return payload;\n}\n\ndescribe(\"ServiceClient to manage the connected WebSocket connections\", function() {\n it(\"Simple clients can receive expected messages with different content types\", async function(this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hi there!\");\n });\n\n it(\"Subprotocol clients can receive expected messages with different content types\", async function(this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"PubSubClientCanReceiveMessage\";\n const messages: PubSubWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(env.WPS_CONNECTION_STRING, hub);\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url, \"json.webpubsub.azure.v1\");\n client.on(\"message\", (data, isBinary) => {\n const frame = new PubSubWebSocketFrame(data, isBinary);\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 3);\n assert.equal(messages[0].message.event, \"connected\");\n assert.equal(\n messages[1].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"json\",\"data\":{\"message\":\"Hello world!\"}}'\n );\n assert.equal(\n messages[2].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"text\",\"data\":\"Hi there!\"}'\n );\n });\n});\n"]}
|
package/dist-esm/test/testEnv.js
CHANGED
@@ -2,7 +2,11 @@ const environmentSetup = {
|
|
2
2
|
replaceableVariables: {
|
3
3
|
WPS_CONNECTION_STRING: "Endpoint=endpoint;AccessKey=api_key;Version=1.0;",
|
4
4
|
WPS_API_KEY: "api_key",
|
5
|
-
ENDPOINT: "endpoint"
|
5
|
+
ENDPOINT: "https://endpoint",
|
6
|
+
REVERSE_PROXY_ENDPOINT: "https://rp-endpoint",
|
7
|
+
AZURE_CLIENT_ID: "azure_client_id",
|
8
|
+
AZURE_CLIENT_SECRET: "azure_client_secret",
|
9
|
+
AZURE_TENANT_ID: "azuretenantid"
|
6
10
|
},
|
7
11
|
customizationsOnRecordings: [],
|
8
12
|
queryParametersToSkip: []
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"AAIA,MAAM,gBAAgB,GAA6B;IACjD,oBAAoB,EAAE;QACpB,qBAAqB,EAAE,kDAAkD;QACzE,WAAW,EAAE,SAAS;QACtB,QAAQ,EAAE,
|
1
|
+
{"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"AAIA,MAAM,gBAAgB,GAA6B;IACjD,oBAAoB,EAAE;QACpB,qBAAqB,EAAE,kDAAkD;QACzE,WAAW,EAAE,SAAS;QACtB,QAAQ,EAAE,kBAAkB;QAC5B,sBAAsB,EAAE,qBAAqB;QAC7C,eAAe,EAAE,iBAAiB;QAClC,mBAAmB,EAAE,qBAAqB;QAC1C,eAAe,EAAE,eAAe;KACjC;IACD,0BAA0B,EAAE,EAAE;IAC9B,qBAAqB,EAAE,EAAE;CAC1B,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\nimport { RecorderEnvironmentSetup } from \"@azure-tools/test-recorder\";\n\nconst environmentSetup: RecorderEnvironmentSetup = {\n replaceableVariables: {\n WPS_CONNECTION_STRING: \"Endpoint=endpoint;AccessKey=api_key;Version=1.0;\",\n WPS_API_KEY: \"api_key\",\n ENDPOINT: \"https://endpoint\",\n REVERSE_PROXY_ENDPOINT: \"https://rp-endpoint\",\n AZURE_CLIENT_ID: \"azure_client_id\",\n AZURE_CLIENT_SECRET: \"azure_client_secret\",\n AZURE_TENANT_ID: \"azuretenantid\"\n },\n customizationsOnRecordings: [],\n queryParametersToSkip: []\n};\n\nexport default environmentSetup;\n"]}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@azure/web-pubsub",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.1-alpha.20211215.2",
|
4
4
|
"description": "Azure client library for Azure Web PubSub",
|
5
5
|
"sdk-type": "client",
|
6
6
|
"main": "dist/index.js",
|
@@ -11,8 +11,8 @@
|
|
11
11
|
"build:browser": "echo \"Browser is not supported.\" && exit 0",
|
12
12
|
"build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1",
|
13
13
|
"build:samples": "echo Obsolete.",
|
14
|
-
"build:test": "tsc -p . && rollup -c
|
15
|
-
"build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local",
|
14
|
+
"build:test": "tsc -p . && rollup -c 2>&1",
|
15
|
+
"build": "npm run clean && tsc -p . && rollup -c 2>&1 && api-extractor run --local",
|
16
16
|
"check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
17
17
|
"format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"",
|
18
18
|
"clean": "rimraf dist dist-esm test-dist temp types *.tgz *.log",
|
@@ -22,16 +22,14 @@
|
|
22
22
|
"integration-test:node": "echo skipped",
|
23
23
|
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
|
24
24
|
"lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]",
|
25
|
-
"lint": "eslint package.json api-extractor.json src test --ext .ts
|
25
|
+
"lint": "eslint package.json api-extractor.json src test --ext .ts",
|
26
26
|
"pack": "npm pack 2>&1",
|
27
|
-
"prebuild": "npm run clean",
|
28
27
|
"test:browser": "echo \"Browser is not supported.\" && exit 0",
|
29
28
|
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
|
30
29
|
"test": "npm run build:test && npm run unit-test && npm run integration-test",
|
31
30
|
"unit-test:browser": "echo \"Browser is not supported.\" && exit 0",
|
32
|
-
"unit-test:node": "mocha --reporter ../../../common/tools/mocha-multi-reporter.js
|
33
|
-
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
34
|
-
"docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src"
|
31
|
+
"unit-test:node": "mocha --exit -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --full-trace \"test/{,!(browser)/**/}*.spec.ts\"",
|
32
|
+
"unit-test": "npm run unit-test:node && npm run unit-test:browser"
|
35
33
|
},
|
36
34
|
"files": [
|
37
35
|
"dist/",
|
@@ -41,12 +39,24 @@
|
|
41
39
|
"README.md",
|
42
40
|
"LICENSE"
|
43
41
|
],
|
42
|
+
"//metadata": {
|
43
|
+
"constantPaths": [
|
44
|
+
{
|
45
|
+
"path": "src/generated/generatedClientContext.ts",
|
46
|
+
"prefix": "packageDetails"
|
47
|
+
},
|
48
|
+
{
|
49
|
+
"path": "swagger/README.md",
|
50
|
+
"prefix": "package-version"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
},
|
44
54
|
"browser": {
|
45
55
|
"./dist-esm/src/util/url.js": "./dist-esm/src/util/url.browser.js"
|
46
56
|
},
|
47
57
|
"repository": "github:Azure/azure-sdk-for-js",
|
48
58
|
"keywords": [
|
49
|
-
"
|
59
|
+
"azure",
|
50
60
|
"cloud"
|
51
61
|
],
|
52
62
|
"author": "Microsoft Corporation",
|
@@ -55,35 +65,31 @@
|
|
55
65
|
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
|
56
66
|
},
|
57
67
|
"engines": {
|
58
|
-
"node": ">=
|
68
|
+
"node": ">=12.0.0"
|
59
69
|
},
|
60
|
-
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/
|
70
|
+
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub/README.md",
|
61
71
|
"sideEffects": false,
|
62
72
|
"dependencies": {
|
63
73
|
"@azure/core-auth": "^1.3.0",
|
64
|
-
"@azure/core-
|
65
|
-
"@azure/core-
|
74
|
+
"@azure/core-client": "^1.0.0",
|
75
|
+
"@azure/core-rest-pipeline": "^1.1.0",
|
76
|
+
"@azure/core-tracing": "1.0.0-preview.13",
|
66
77
|
"@azure/logger": "^1.0.0",
|
67
|
-
"tslib": "^2.
|
78
|
+
"tslib": "^2.2.0",
|
68
79
|
"jsonwebtoken": "^8.5.1"
|
69
80
|
},
|
70
81
|
"devDependencies": {
|
71
|
-
"@azure/dev-tool": "
|
72
|
-
"@azure/eslint-plugin-azure-sdk": "
|
73
|
-
"@azure/identity": "^
|
74
|
-
"@azure/test-
|
75
|
-
"@microsoft/api-extractor": "7.
|
76
|
-
"@
|
77
|
-
"@rollup/plugin-json": "^4.0.0",
|
78
|
-
"@rollup/plugin-multi-entry": "^3.0.0",
|
79
|
-
"@rollup/plugin-node-resolve": "^8.0.0",
|
80
|
-
"@rollup/plugin-replace": "^2.2.0",
|
82
|
+
"@azure/dev-tool": ">=1.0.0-alpha <1.0.0-alphb",
|
83
|
+
"@azure/eslint-plugin-azure-sdk": ">=3.0.0-alpha <3.0.0-alphb",
|
84
|
+
"@azure/identity": "^2.0.1",
|
85
|
+
"@azure-tools/test-recorder": "^1.0.0",
|
86
|
+
"@microsoft/api-extractor": "^7.18.11",
|
87
|
+
"@types/chai": "^4.1.6",
|
81
88
|
"@types/jsonwebtoken": "~8.5.0",
|
82
89
|
"@types/mocha": "^7.0.2",
|
83
|
-
"@types/node": "^
|
84
|
-
"@types/query-string": "6.2.0",
|
90
|
+
"@types/node": "^12.0.0",
|
85
91
|
"@types/sinon": "^9.0.4",
|
86
|
-
"
|
92
|
+
"@types/ws": "^8.2.0",
|
87
93
|
"chai": "^4.2.0",
|
88
94
|
"cross-env": "^7.0.2",
|
89
95
|
"dotenv": "^8.2.0",
|
@@ -103,21 +109,16 @@
|
|
103
109
|
"karma-mocha-reporter": "^2.2.5",
|
104
110
|
"karma-sourcemap-loader": "^0.3.8",
|
105
111
|
"mocha": "^7.1.1",
|
106
|
-
"mocha-junit-reporter": "^
|
107
|
-
"nyc": "^
|
112
|
+
"mocha-junit-reporter": "^2.0.0",
|
113
|
+
"nyc": "^15.0.0",
|
108
114
|
"prettier": "^1.16.4",
|
109
|
-
"puppeteer": "^
|
110
|
-
"query-string": "^5.0.0",
|
115
|
+
"puppeteer": "^10.2.0",
|
111
116
|
"rimraf": "^3.0.0",
|
112
117
|
"rollup": "^1.16.3",
|
113
|
-
"rollup-plugin-shim": "^1.0.0",
|
114
|
-
"rollup-plugin-sourcemaps": "^0.4.2",
|
115
|
-
"rollup-plugin-terser": "^5.1.1",
|
116
|
-
"rollup-plugin-visualizer": "^4.0.4",
|
117
118
|
"sinon": "^9.0.2",
|
118
119
|
"source-map-support": "^0.5.9",
|
119
120
|
"typescript": "~4.2.0",
|
120
|
-
"
|
121
|
+
"ws": "^8.2.0"
|
121
122
|
},
|
122
123
|
"//sampleConfiguration": {
|
123
124
|
"productName": "Azure Web PubSub",
|