@azure/notification-hubs 1.0.0-beta.1 → 1.0.0-beta.2
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/dist/{index.js → index.cjs} +193 -52
- package/dist/index.cjs.map +1 -0
- package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
- package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.browser.js +11 -0
- package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.js +8 -0
- package/dist-esm/src/auth/hmacSha256.js.map +1 -0
- package/dist-esm/src/auth/sasTokenProvider.js +79 -0
- package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistration.js +2 -1
- package/dist-esm/src/client/createRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistrationId.js +3 -2
- package/dist-esm/src/client/createRegistrationId.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js +3 -2
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.js +3 -2
- package/dist-esm/src/client/deleteRegistration.js.map +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
- package/dist-esm/src/client/getInstallation.js +3 -2
- package/dist-esm/src/client/getInstallation.js.map +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js +3 -2
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
- package/dist-esm/src/client/getRegistration.js +3 -2
- package/dist-esm/src/client/getRegistration.js.map +1 -1
- package/dist-esm/src/client/index.js +7 -3
- package/dist-esm/src/client/index.js.map +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
- package/dist-esm/src/client/listRegistrations.js +3 -2
- package/dist-esm/src/client/listRegistrations.js.map +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/updateInstallation.js +3 -2
- package/dist-esm/src/client/updateInstallation.js.map +1 -1
- package/dist-esm/src/client/updateRegistration.js +2 -1
- package/dist-esm/src/client/updateRegistration.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -0
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/dist-esm/src/utils/retryPolicy.js +2 -2
- package/dist-esm/src/utils/retryPolicy.js.map +1 -1
- package/dist-esm/src/utils/tracing.js +2 -1
- package/dist-esm/src/utils/tracing.js.map +1 -1
- package/package.json +15 -10
- package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
- package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.browser.d.ts +2 -0
- package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.d.ts +2 -0
- package/types/src/auth/hmacSha256.d.ts.map +1 -0
- package/types/src/auth/sasTokenProvider.d.ts +57 -0
- package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
- package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
- package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
- package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistrationId.d.ts.map +1 -1
- package/types/src/client/deleteInstallation.d.ts.map +1 -1
- package/types/src/client/deleteRegistration.d.ts.map +1 -1
- package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
- package/types/src/client/getInstallation.d.ts.map +1 -1
- package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
- package/types/src/client/getRegistration.d.ts.map +1 -1
- package/types/src/client/index.d.ts +2 -2
- package/types/src/client/index.d.ts.map +1 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
- package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
- package/types/src/client/listRegistrations.d.ts.map +1 -1
- package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
- package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/updateInstallation.d.ts.map +1 -1
- package/types/src/client/updateRegistration.d.ts.map +1 -1
- package/types/src/utils/constants.d.ts +1 -0
- package/types/src/utils/constants.d.ts.map +1 -1
- package/types/src/utils/tracing.d.ts.map +1 -1
- package/dist/index.js.map +0 -1
- package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
- package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
|
@@ -3,13 +3,144 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
6
|
-
var
|
|
6
|
+
var coreAuth = require('@azure/core-auth');
|
|
7
|
+
var coreUtil = require('@azure/core-util');
|
|
8
|
+
var crypto = require('crypto');
|
|
7
9
|
var coreXml = require('@azure/core-xml');
|
|
8
10
|
var coreClient = require('@azure/core-client');
|
|
9
11
|
var coreTracing = require('@azure/core-tracing');
|
|
10
12
|
var tslib = require('tslib');
|
|
11
13
|
|
|
12
14
|
// Copyright (c) Microsoft Corporation.
|
|
15
|
+
// Licensed under the MIT license.
|
|
16
|
+
const SDK_VERSION = "1.0.0-beta.2";
|
|
17
|
+
const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
|
|
18
|
+
const XML_CONTENT_TYPE = "application/xml";
|
|
19
|
+
const STREAM_CONTENT_TYPE = "application/octet-stream";
|
|
20
|
+
const WNS_TYPE_NAME = "X-WNS-Type";
|
|
21
|
+
const WNS_RAW = "wns/raw";
|
|
22
|
+
const WNS_BADGE = "wns/badge";
|
|
23
|
+
const WNS_TITLE = "wns/tile";
|
|
24
|
+
const WNS_TOAST = "wns/toast";
|
|
25
|
+
|
|
26
|
+
// Copyright (c) Microsoft Corporation.
|
|
27
|
+
async function signString(key, toSign) {
|
|
28
|
+
const hmac = crypto.createHmac("sha256", key).update(toSign).digest("base64");
|
|
29
|
+
return encodeURIComponent(hmac);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Copyright (c) Microsoft Corporation.
|
|
33
|
+
/**
|
|
34
|
+
* Creates a token provider from the provided shared access data.
|
|
35
|
+
* @param data - The sharedAccessKeyName/sharedAccessKey pair or the sharedAccessSignature.
|
|
36
|
+
* @hidden
|
|
37
|
+
*/
|
|
38
|
+
function createSasTokenProvider(data) {
|
|
39
|
+
if (coreAuth.isNamedKeyCredential(data) || coreAuth.isSASCredential(data)) {
|
|
40
|
+
return new SasTokenProviderImpl(data);
|
|
41
|
+
}
|
|
42
|
+
else if (coreUtil.isObjectWithProperties(data, ["sharedAccessKeyName", "sharedAccessKey"])) {
|
|
43
|
+
return new SasTokenProviderImpl({
|
|
44
|
+
name: data.sharedAccessKeyName,
|
|
45
|
+
key: data.sharedAccessKey,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
return new SasTokenProviderImpl({ signature: data.sharedAccessSignature });
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* A TokenProvider that generates a Sas token:
|
|
54
|
+
* `SharedAccessSignature sr=<resource>&sig=<signature>&se=<expiry>&skn=<keyname>`
|
|
55
|
+
*
|
|
56
|
+
* @internal
|
|
57
|
+
*/
|
|
58
|
+
class SasTokenProviderImpl {
|
|
59
|
+
/**
|
|
60
|
+
* Initializes a new instance of SasTokenProvider
|
|
61
|
+
* @param credential - The source `NamedKeyCredential` or `SASCredential`.
|
|
62
|
+
*/
|
|
63
|
+
constructor(credential) {
|
|
64
|
+
this._credential = credential;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Property used to distinguish TokenProvider from TokenCredential.
|
|
68
|
+
*/
|
|
69
|
+
get isSasTokenProvider() {
|
|
70
|
+
return true;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Gets the sas token for the specified audience
|
|
74
|
+
* @param audience - The audience for which the token is desired.
|
|
75
|
+
*/
|
|
76
|
+
async getToken(audience) {
|
|
77
|
+
if (coreAuth.isNamedKeyCredential(this._credential)) {
|
|
78
|
+
return createToken(this._credential.name, this._credential.key, Math.floor(Date.now() / 1000) + 3600, audience);
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
return {
|
|
82
|
+
token: this._credential.signature,
|
|
83
|
+
expiresOnTimestamp: 0,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Creates the sas token based on the provided information.
|
|
90
|
+
* @param keyName - The shared access key name.
|
|
91
|
+
* @param key - The shared access key.
|
|
92
|
+
* @param expiry - The time period in unix time after which the token will expire.
|
|
93
|
+
* @param audience - The audience for which the token is desired.
|
|
94
|
+
* @internal
|
|
95
|
+
*/
|
|
96
|
+
async function createToken(keyName, key, expiry, audience) {
|
|
97
|
+
audience = encodeURIComponent(audience.toLowerCase());
|
|
98
|
+
keyName = encodeURIComponent(keyName);
|
|
99
|
+
const stringToSign = audience + "\n" + expiry;
|
|
100
|
+
const sig = await signString(key, stringToSign);
|
|
101
|
+
return {
|
|
102
|
+
token: `SharedAccessSignature sr=${audience}&sig=${sig}&se=${expiry}&skn=${keyName}`,
|
|
103
|
+
expiresOnTimestamp: expiry,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Copyright (c) Microsoft Corporation.
|
|
108
|
+
/**
|
|
109
|
+
* Parses the connection string and returns an object of type T.
|
|
110
|
+
*
|
|
111
|
+
* Connection strings have the following syntax:
|
|
112
|
+
*
|
|
113
|
+
* ConnectionString ::= `Part { ";" Part } [ ";" ] [ WhiteSpace ]`
|
|
114
|
+
* Part ::= [ PartLiteral [ "=" PartLiteral ] ]
|
|
115
|
+
* PartLiteral ::= [ WhiteSpace ] Literal [ WhiteSpace ]
|
|
116
|
+
* Literal ::= ? any sequence of characters except ; or = or WhiteSpace ?
|
|
117
|
+
* WhiteSpace ::= ? all whitespace characters including `\r` and `\n` ?
|
|
118
|
+
*
|
|
119
|
+
* @param connectionString - The connection string to be parsed.
|
|
120
|
+
* @returns ParsedOutput<T>.
|
|
121
|
+
*/
|
|
122
|
+
function parseConnectionString(connectionString) {
|
|
123
|
+
const output = {};
|
|
124
|
+
const parts = connectionString.trim().split(";");
|
|
125
|
+
for (let part of parts) {
|
|
126
|
+
part = part.trim();
|
|
127
|
+
if (part === "") {
|
|
128
|
+
// parts can be empty
|
|
129
|
+
continue;
|
|
130
|
+
}
|
|
131
|
+
const splitIndex = part.indexOf("=");
|
|
132
|
+
if (splitIndex === -1) {
|
|
133
|
+
throw new Error("Connection string malformed: each part of the connection string must have an `=` assignment.");
|
|
134
|
+
}
|
|
135
|
+
const key = part.substring(0, splitIndex).trim();
|
|
136
|
+
if (key === "") {
|
|
137
|
+
throw new Error("Connection string malformed: missing key for assignment");
|
|
138
|
+
}
|
|
139
|
+
const value = part.substring(splitIndex + 1).trim();
|
|
140
|
+
output[key] = value;
|
|
141
|
+
}
|
|
142
|
+
return output;
|
|
143
|
+
}
|
|
13
144
|
/**
|
|
14
145
|
* Creates a SasTokenProvider from a shared access key and shared access key name.
|
|
15
146
|
* @param sharedAccessKey - The shared access key value.
|
|
@@ -17,7 +148,7 @@ var tslib = require('tslib');
|
|
|
17
148
|
* @returns A SasTokenProvider with the given shared access token information.
|
|
18
149
|
*/
|
|
19
150
|
function createTokenProviderFromConnection(sharedAccessKey, sharedAccessKeyName) {
|
|
20
|
-
return
|
|
151
|
+
return createSasTokenProvider({ sharedAccessKey, sharedAccessKeyName });
|
|
21
152
|
}
|
|
22
153
|
/**
|
|
23
154
|
* Parses given connection string into the different properties applicable to Azure Service Bus.
|
|
@@ -26,7 +157,7 @@ function createTokenProviderFromConnection(sharedAccessKey, sharedAccessKeyName)
|
|
|
26
157
|
* for the Service Bus namespace, queue or topic.
|
|
27
158
|
*/
|
|
28
159
|
function parseNotificationHubsConnectionString(connectionString) {
|
|
29
|
-
const parsedResult =
|
|
160
|
+
const parsedResult = parseConnectionString(connectionString);
|
|
30
161
|
if (!parsedResult.Endpoint) {
|
|
31
162
|
throw new Error("Connection string should have an Endpoint key.");
|
|
32
163
|
}
|
|
@@ -61,17 +192,20 @@ class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
|
|
|
61
192
|
parseXML: coreXml.parseXML,
|
|
62
193
|
}, serializationOptions: {
|
|
63
194
|
stringifyXML: coreXml.stringifyXML,
|
|
195
|
+
}, userAgentOptions: {
|
|
196
|
+
userAgentPrefix: `azsdk-js-messaging-notificationhubs/${SDK_VERSION}`,
|
|
64
197
|
} }, options));
|
|
65
198
|
this.hubName = hubName;
|
|
66
199
|
const parsedConnection = parseNotificationHubsConnectionString(connectionString);
|
|
67
200
|
this.baseUrl = parsedConnection.endpoint;
|
|
68
201
|
this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
|
|
69
202
|
}
|
|
70
|
-
createHeaders() {
|
|
71
|
-
const authorization = this.sasTokenProvider.getToken(this.baseUrl);
|
|
203
|
+
async createHeaders(operationName) {
|
|
204
|
+
const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
|
|
72
205
|
const headers = coreRestPipeline.createHttpHeaders();
|
|
73
206
|
headers.set("Authorization", authorization.token);
|
|
74
207
|
headers.set("x-ms-version", API_VERSION);
|
|
208
|
+
headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
|
|
75
209
|
return headers;
|
|
76
210
|
}
|
|
77
211
|
requestUrl() {
|
|
@@ -361,10 +495,11 @@ async function sendRequest(context, request, successStatusCode) {
|
|
|
361
495
|
const tracingClient = coreTracing.createTracingClient({
|
|
362
496
|
namespace: "Microsoft.NotificationHubs",
|
|
363
497
|
packageName: "@azure/notification-hubs",
|
|
364
|
-
packageVersion:
|
|
498
|
+
packageVersion: SDK_VERSION,
|
|
365
499
|
});
|
|
366
500
|
|
|
367
501
|
// Copyright (c) Microsoft Corporation.
|
|
502
|
+
const OPERATION_NAME$h = "cancelScheduledNotification";
|
|
368
503
|
/**
|
|
369
504
|
* Cancels the scheduled notification with the given notification ID.
|
|
370
505
|
* NOTE: This is only available in Standard SKU Azure Notification Hubs.
|
|
@@ -374,10 +509,10 @@ const tracingClient = coreTracing.createTracingClient({
|
|
|
374
509
|
* @returns A notification hub response with correlation ID and tracking ID.
|
|
375
510
|
*/
|
|
376
511
|
function cancelScheduledNotification(context, notificationId, options = {}) {
|
|
377
|
-
return tracingClient.withSpan(
|
|
512
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$h}`, options, async (updatedOptions) => {
|
|
378
513
|
const endpoint = context.requestUrl();
|
|
379
514
|
endpoint.pathname += `/schedulednotifications/${notificationId}`;
|
|
380
|
-
const headers = context.createHeaders();
|
|
515
|
+
const headers = await context.createHeaders(OPERATION_NAME$h);
|
|
381
516
|
const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
|
|
382
517
|
const response = await sendRequest(context, request, 200);
|
|
383
518
|
return parseNotificationSendResponse(response);
|
|
@@ -385,6 +520,7 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
|
|
|
385
520
|
}
|
|
386
521
|
|
|
387
522
|
// Copyright (c) Microsoft Corporation.
|
|
523
|
+
const OPERATION_NAME$g = "createOrUpdateInstallation";
|
|
388
524
|
/**
|
|
389
525
|
* Creates or overwrites an installation to a Notification Hub.
|
|
390
526
|
* @param context - The Notification Hubs client.
|
|
@@ -393,10 +529,10 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
|
|
|
393
529
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
394
530
|
*/
|
|
395
531
|
function createOrUpdateInstallation(context, installation, options = {}) {
|
|
396
|
-
return tracingClient.withSpan(
|
|
532
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$g}`, options, async (updatedOptions) => {
|
|
397
533
|
const endpoint = context.requestUrl();
|
|
398
534
|
endpoint.pathname += `/installations/${installation.installationId}`;
|
|
399
|
-
const headers = context.createHeaders();
|
|
535
|
+
const headers = await context.createHeaders(OPERATION_NAME$g);
|
|
400
536
|
headers.set("Content-Type", "application/json");
|
|
401
537
|
const request = createRequest(endpoint, "PUT", headers, updatedOptions);
|
|
402
538
|
request.body = JSON.stringify(installation);
|
|
@@ -791,7 +927,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
|
|
|
791
927
|
// Clear out readonly properties
|
|
792
928
|
registration.registrationId = undefined;
|
|
793
929
|
registration.etag = undefined;
|
|
794
|
-
const headers = context.createHeaders();
|
|
930
|
+
const headers = await context.createHeaders(`${operationName}Registration`);
|
|
795
931
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
796
932
|
if (operationName === "update") {
|
|
797
933
|
headers.set("If-Match", isDefined(etag) ? `"${etag}"` : "*");
|
|
@@ -803,6 +939,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
|
|
|
803
939
|
}
|
|
804
940
|
|
|
805
941
|
// Copyright (c) Microsoft Corporation.
|
|
942
|
+
const OPERATION_NAME$f = "createOrUpdateRegistration";
|
|
806
943
|
/**
|
|
807
944
|
* Creates or updates a registration.
|
|
808
945
|
* @param context - The Notification Hubs client.
|
|
@@ -811,12 +948,13 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
|
|
|
811
948
|
* @returns The created or updated registration description.
|
|
812
949
|
*/
|
|
813
950
|
function createOrUpdateRegistration(context, registration, options = {}) {
|
|
814
|
-
return tracingClient.withSpan(
|
|
951
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$f}`, options, async (updatedOptions) => {
|
|
815
952
|
return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
|
|
816
953
|
});
|
|
817
954
|
}
|
|
818
955
|
|
|
819
956
|
// Copyright (c) Microsoft Corporation.
|
|
957
|
+
const OPERATION_NAME$e = "createRegistrationId";
|
|
820
958
|
/**
|
|
821
959
|
* Creates a new registration ID.
|
|
822
960
|
* @param context - The Notification Hubs client.
|
|
@@ -824,10 +962,10 @@ function createOrUpdateRegistration(context, registration, options = {}) {
|
|
|
824
962
|
* @returns The newly created registration ID.
|
|
825
963
|
*/
|
|
826
964
|
function createRegistrationId(context, options = {}) {
|
|
827
|
-
return tracingClient.withSpan(
|
|
965
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$e}`, options, async (updatedOptions) => {
|
|
828
966
|
const endpoint = context.requestUrl();
|
|
829
967
|
endpoint.pathname += "/registrationIDs";
|
|
830
|
-
const headers = context.createHeaders();
|
|
968
|
+
const headers = await context.createHeaders(OPERATION_NAME$e);
|
|
831
969
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
832
970
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
833
971
|
const response = await sendRequest(context, request, 201);
|
|
@@ -840,6 +978,7 @@ function createRegistrationId(context, options = {}) {
|
|
|
840
978
|
}
|
|
841
979
|
|
|
842
980
|
// Copyright (c) Microsoft Corporation.
|
|
981
|
+
const OPERATION_NAME$d = "createRegistration";
|
|
843
982
|
/**
|
|
844
983
|
* Creates a new registration. This method generates a registration ID,
|
|
845
984
|
* which you can subsequently use to retrieve, update, and delete this registration.
|
|
@@ -849,7 +988,7 @@ function createRegistrationId(context, options = {}) {
|
|
|
849
988
|
* @returns The newly created registration description.
|
|
850
989
|
*/
|
|
851
990
|
function createRegistration(context, registration, options = {}) {
|
|
852
|
-
return tracingClient.withSpan(
|
|
991
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$d}`, options, async (updatedOptions) => {
|
|
853
992
|
if (registration.registrationId) {
|
|
854
993
|
throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
|
|
855
994
|
statusCode: 400,
|
|
@@ -860,6 +999,7 @@ function createRegistration(context, registration, options = {}) {
|
|
|
860
999
|
}
|
|
861
1000
|
|
|
862
1001
|
// Copyright (c) Microsoft Corporation.
|
|
1002
|
+
const OPERATION_NAME$c = "deleteInstallation";
|
|
863
1003
|
/**
|
|
864
1004
|
* Deletes an installation from a Notification Hub.
|
|
865
1005
|
* @param context - The Notification Hubs client.
|
|
@@ -868,10 +1008,10 @@ function createRegistration(context, registration, options = {}) {
|
|
|
868
1008
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
869
1009
|
*/
|
|
870
1010
|
function deleteInstallation(context, installationId, options = {}) {
|
|
871
|
-
return tracingClient.withSpan(
|
|
1011
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$c}`, options, async (updatedOptions) => {
|
|
872
1012
|
const endpoint = context.requestUrl();
|
|
873
1013
|
endpoint.pathname += `/installations/${installationId}`;
|
|
874
|
-
const headers = context.createHeaders();
|
|
1014
|
+
const headers = await context.createHeaders(OPERATION_NAME$c);
|
|
875
1015
|
const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
|
|
876
1016
|
const response = await sendRequest(context, request, 204);
|
|
877
1017
|
return parseNotificationResponse(response);
|
|
@@ -879,6 +1019,7 @@ function deleteInstallation(context, installationId, options = {}) {
|
|
|
879
1019
|
}
|
|
880
1020
|
|
|
881
1021
|
// Copyright (c) Microsoft Corporation.
|
|
1022
|
+
const OPERATION_NAME$b = "getFeedbackContainerUrl";
|
|
882
1023
|
/**
|
|
883
1024
|
* Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
|
|
884
1025
|
* The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
|
|
@@ -887,10 +1028,10 @@ function deleteInstallation(context, installationId, options = {}) {
|
|
|
887
1028
|
* @returns The URL of the Azure Storage Container containing the feedback data.
|
|
888
1029
|
*/
|
|
889
1030
|
function getFeedbackContainerUrl(context, options = {}) {
|
|
890
|
-
return tracingClient.withSpan(
|
|
1031
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$b}`, options, async (updatedOptions) => {
|
|
891
1032
|
const endpoint = context.requestUrl();
|
|
892
1033
|
endpoint.pathname += "/feedbackcontainer";
|
|
893
|
-
const headers = context.createHeaders();
|
|
1034
|
+
const headers = await context.createHeaders(OPERATION_NAME$b);
|
|
894
1035
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
895
1036
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
896
1037
|
const response = await sendRequest(context, request, 200);
|
|
@@ -899,6 +1040,7 @@ function getFeedbackContainerUrl(context, options = {}) {
|
|
|
899
1040
|
}
|
|
900
1041
|
|
|
901
1042
|
// Copyright (c) Microsoft Corporation.
|
|
1043
|
+
const OPERATION_NAME$a = "getInstallation";
|
|
902
1044
|
/**
|
|
903
1045
|
* Gets an Azure Notification Hub installation by the installation ID.
|
|
904
1046
|
* @param context - The Notification Hubs client.
|
|
@@ -907,10 +1049,10 @@ function getFeedbackContainerUrl(context, options = {}) {
|
|
|
907
1049
|
* @returns The installation that matches the installation ID.
|
|
908
1050
|
*/
|
|
909
1051
|
function getInstallation(context, installationId, options = {}) {
|
|
910
|
-
return tracingClient.withSpan(
|
|
1052
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$a}`, options, async (updatedOptions) => {
|
|
911
1053
|
const endpoint = context.requestUrl();
|
|
912
1054
|
endpoint.pathname += `/installations/${installationId}`;
|
|
913
|
-
const headers = context.createHeaders();
|
|
1055
|
+
const headers = await context.createHeaders(OPERATION_NAME$a);
|
|
914
1056
|
headers.set("Content-Type", "application/json");
|
|
915
1057
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
916
1058
|
const response = await sendRequest(context, request, 200);
|
|
@@ -989,6 +1131,7 @@ function createNotificationHubJob(content) {
|
|
|
989
1131
|
}
|
|
990
1132
|
|
|
991
1133
|
// Copyright (c) Microsoft Corporation.
|
|
1134
|
+
const OPERATION_NAME$9 = "getNotificationHubJob";
|
|
992
1135
|
/**
|
|
993
1136
|
* Gets a Notification Hub Job by the ID.
|
|
994
1137
|
* @param context - The Notification Hubs client.
|
|
@@ -997,10 +1140,10 @@ function createNotificationHubJob(content) {
|
|
|
997
1140
|
* @returns The Notification Hub Job with the matching ID.
|
|
998
1141
|
*/
|
|
999
1142
|
function getNotificationHubJob(context, jobId, options = {}) {
|
|
1000
|
-
return tracingClient.withSpan(
|
|
1143
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$9}`, options, async (updatedOptions) => {
|
|
1001
1144
|
const endpoint = context.requestUrl();
|
|
1002
1145
|
endpoint.pathname += `/jobs/${jobId}`;
|
|
1003
|
-
const headers = context.createHeaders();
|
|
1146
|
+
const headers = await context.createHeaders(OPERATION_NAME$9);
|
|
1004
1147
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1005
1148
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1006
1149
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1064,6 +1207,7 @@ function parseOutcomeCounts(counts) {
|
|
|
1064
1207
|
}
|
|
1065
1208
|
|
|
1066
1209
|
// Copyright (c) Microsoft Corporation.
|
|
1210
|
+
const OPERATION_NAME$8 = "getNotificationOutcomeDetails";
|
|
1067
1211
|
/**
|
|
1068
1212
|
* Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
|
|
1069
1213
|
* or final results if the Send* has completed. This API can only be called for Standard SKU and above.
|
|
@@ -1073,10 +1217,10 @@ function parseOutcomeCounts(counts) {
|
|
|
1073
1217
|
* @returns The results of the send operation.
|
|
1074
1218
|
*/
|
|
1075
1219
|
function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
1076
|
-
return tracingClient.withSpan(
|
|
1220
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$8}`, options, async (updatedOptions) => {
|
|
1077
1221
|
const endpoint = context.requestUrl();
|
|
1078
1222
|
endpoint.pathname += `/messages/${notificationId}`;
|
|
1079
|
-
const headers = context.createHeaders();
|
|
1223
|
+
const headers = await context.createHeaders(OPERATION_NAME$8);
|
|
1080
1224
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1081
1225
|
const response = await sendRequest(context, request, 200);
|
|
1082
1226
|
return parseNotificationDetails(response.bodyAsText);
|
|
@@ -1084,6 +1228,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
|
1084
1228
|
}
|
|
1085
1229
|
|
|
1086
1230
|
// Copyright (c) Microsoft Corporation.
|
|
1231
|
+
const OPERATION_NAME$7 = "getRegistration";
|
|
1087
1232
|
/**
|
|
1088
1233
|
* Gets a registration by the given registration ID.
|
|
1089
1234
|
* @param context - The Notification Hubs client.
|
|
@@ -1092,10 +1237,10 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
|
|
|
1092
1237
|
* @returns A RegistrationDescription that has the given registration ID.
|
|
1093
1238
|
*/
|
|
1094
1239
|
function getRegistration(context, registrationId, options = {}) {
|
|
1095
|
-
return tracingClient.withSpan(
|
|
1240
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$7}`, options, async (updatedOptions) => {
|
|
1096
1241
|
const endpoint = context.requestUrl();
|
|
1097
1242
|
endpoint.pathname += `/registrations/${registrationId}`;
|
|
1098
|
-
const headers = context.createHeaders();
|
|
1243
|
+
const headers = await context.createHeaders(OPERATION_NAME$7);
|
|
1099
1244
|
headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
|
|
1100
1245
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1101
1246
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1104,6 +1249,7 @@ function getRegistration(context, registrationId, options = {}) {
|
|
|
1104
1249
|
}
|
|
1105
1250
|
|
|
1106
1251
|
// Copyright (c) Microsoft Corporation.
|
|
1252
|
+
const OPERATION_NAME$6 = "listNotificationHubJobs";
|
|
1107
1253
|
/**
|
|
1108
1254
|
* Gets all Notification Hub Jobs for this Notification Hub.
|
|
1109
1255
|
* @param context - The Notification Hubs client.xs
|
|
@@ -1111,10 +1257,10 @@ function getRegistration(context, registrationId, options = {}) {
|
|
|
1111
1257
|
* @returns An array of all Notification Hub Jobs for this Notification Hub.
|
|
1112
1258
|
*/
|
|
1113
1259
|
function listNotificationHubJobs(context, options = {}) {
|
|
1114
|
-
return tracingClient.withSpan(
|
|
1260
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$6}`, options, async (updatedOptions) => {
|
|
1115
1261
|
const endpoint = context.requestUrl();
|
|
1116
1262
|
endpoint.pathname += "/jobs";
|
|
1117
|
-
const headers = context.createHeaders();
|
|
1263
|
+
const headers = await context.createHeaders(OPERATION_NAME$6);
|
|
1118
1264
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1119
1265
|
const request = createRequest(endpoint, "GET", headers, updatedOptions);
|
|
1120
1266
|
const response = await sendRequest(context, request, 200);
|
|
@@ -1123,6 +1269,7 @@ function listNotificationHubJobs(context, options = {}) {
|
|
|
1123
1269
|
}
|
|
1124
1270
|
|
|
1125
1271
|
// Copyright (c) Microsoft Corporation.
|
|
1272
|
+
const OPERATION_NAME$5 = "listRegistrationsByTag";
|
|
1126
1273
|
/**
|
|
1127
1274
|
* Lists all registrations with the matching tag.
|
|
1128
1275
|
* @param context - The Notification Hubs client.
|
|
@@ -1131,7 +1278,7 @@ function listNotificationHubJobs(context, options = {}) {
|
|
|
1131
1278
|
* @returns A paged async iterable containing the matching registrations for the notification hub.
|
|
1132
1279
|
*/
|
|
1133
1280
|
function listRegistrationsByTag(context, tag, options = {}) {
|
|
1134
|
-
const { span, updatedOptions } = tracingClient.startSpan(
|
|
1281
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME$5}`, options);
|
|
1135
1282
|
try {
|
|
1136
1283
|
const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
|
|
1137
1284
|
return {
|
|
@@ -1193,7 +1340,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1193
1340
|
if (continuationToken !== undefined) {
|
|
1194
1341
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1195
1342
|
}
|
|
1196
|
-
const headers = context.createHeaders();
|
|
1343
|
+
const headers = await context.createHeaders(OPERATION_NAME$5);
|
|
1197
1344
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1198
1345
|
const response = await sendRequest(context, request, 200);
|
|
1199
1346
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1205,6 +1352,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1205
1352
|
}
|
|
1206
1353
|
|
|
1207
1354
|
// Copyright (c) Microsoft Corporation.
|
|
1355
|
+
const OPERATION_NAME$4 = "listRegistrations";
|
|
1208
1356
|
/**
|
|
1209
1357
|
* Gets all registrations for the notification hub with the given query options.
|
|
1210
1358
|
* @param context - The Notification Hubs client.
|
|
@@ -1212,7 +1360,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
|
|
|
1212
1360
|
* @returns A paged async iterable containing all of the registrations for the notification hub.
|
|
1213
1361
|
*/
|
|
1214
1362
|
function listRegistrations(context, options = {}) {
|
|
1215
|
-
const { span, updatedOptions } = tracingClient.startSpan(
|
|
1363
|
+
const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME$4}`, options);
|
|
1216
1364
|
try {
|
|
1217
1365
|
const iter = listRegistrationsAll(context, updatedOptions);
|
|
1218
1366
|
return {
|
|
@@ -1277,7 +1425,7 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1277
1425
|
if (continuationToken !== undefined) {
|
|
1278
1426
|
endpoint.searchParams.set("continuationtoken", continuationToken);
|
|
1279
1427
|
}
|
|
1280
|
-
const headers = context.createHeaders();
|
|
1428
|
+
const headers = await context.createHeaders(OPERATION_NAME$4);
|
|
1281
1429
|
const request = createRequest(endpoint, "GET", headers, options);
|
|
1282
1430
|
const response = await sendRequest(context, request, 200);
|
|
1283
1431
|
const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
|
|
@@ -1289,14 +1437,15 @@ async function _listRegistrations(context, options, continuationToken) {
|
|
|
1289
1437
|
}
|
|
1290
1438
|
|
|
1291
1439
|
// Copyright (c) Microsoft Corporation.
|
|
1440
|
+
const OPERATION_NAME$3 = "scheduleNotificationPayload";
|
|
1292
1441
|
/**
|
|
1293
1442
|
* @internal
|
|
1294
1443
|
*/
|
|
1295
1444
|
function scheduleNotificationPayload(context, scheduledTime, tags, notification, options = {}) {
|
|
1296
|
-
return tracingClient.withSpan(
|
|
1445
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$3}`, options, async (updatedOptions) => {
|
|
1297
1446
|
const endpoint = context.requestUrl();
|
|
1298
1447
|
endpoint.pathname += "/schedulednotifications/";
|
|
1299
|
-
const headers = context.createHeaders();
|
|
1448
|
+
const headers = await context.createHeaders(OPERATION_NAME$3);
|
|
1300
1449
|
if (notification.headers) {
|
|
1301
1450
|
for (const headerName of Object.keys(notification.headers)) {
|
|
1302
1451
|
headers.set(headerName, notification.headers[headerName]);
|
|
@@ -1364,7 +1513,7 @@ function sendNotificationPayload(context, notification, method, pushHandle, tags
|
|
|
1364
1513
|
if (options.enableTestSend) {
|
|
1365
1514
|
endpoint.searchParams.append("debug", "true");
|
|
1366
1515
|
}
|
|
1367
|
-
const headers = context.createHeaders();
|
|
1516
|
+
const headers = await context.createHeaders(method);
|
|
1368
1517
|
if (notification.headers) {
|
|
1369
1518
|
for (const headerName of Object.keys(notification.headers)) {
|
|
1370
1519
|
headers.set(headerName, notification.headers[headerName]);
|
|
@@ -1443,6 +1592,7 @@ function sendNotification(context, tags, notification, options = {}) {
|
|
|
1443
1592
|
}
|
|
1444
1593
|
|
|
1445
1594
|
// Copyright (c) Microsoft Corporation.
|
|
1595
|
+
const OPERATION_NAME$2 = "submitNotificationHubJob";
|
|
1446
1596
|
/**
|
|
1447
1597
|
* Submits a Notification Hub Job.
|
|
1448
1598
|
* Note: this is available to Standard SKU namespace and above.
|
|
@@ -1452,10 +1602,10 @@ function sendNotification(context, tags, notification, options = {}) {
|
|
|
1452
1602
|
* @returns The notification hub job details including job ID and status.
|
|
1453
1603
|
*/
|
|
1454
1604
|
function submitNotificationHubJob(context, job, options = {}) {
|
|
1455
|
-
return tracingClient.withSpan(
|
|
1605
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$2}`, options, async (updatedOptions) => {
|
|
1456
1606
|
const endpoint = context.requestUrl();
|
|
1457
1607
|
endpoint.pathname += "/jobs";
|
|
1458
|
-
const headers = context.createHeaders();
|
|
1608
|
+
const headers = await context.createHeaders(OPERATION_NAME$2);
|
|
1459
1609
|
headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
|
|
1460
1610
|
const request = createRequest(endpoint, "POST", headers, updatedOptions);
|
|
1461
1611
|
request.body = serializeNotificationHubJobEntry(job);
|
|
@@ -1465,6 +1615,7 @@ function submitNotificationHubJob(context, job, options = {}) {
|
|
|
1465
1615
|
}
|
|
1466
1616
|
|
|
1467
1617
|
// Copyright (c) Microsoft Corporation.
|
|
1618
|
+
const OPERATION_NAME$1 = "updateInstallation";
|
|
1468
1619
|
/**
|
|
1469
1620
|
* Updates an installation using the JSON-Patch standard in RFC6902.
|
|
1470
1621
|
* @param context - The Notification Hubs client.
|
|
@@ -1474,10 +1625,10 @@ function submitNotificationHubJob(context, job, options = {}) {
|
|
|
1474
1625
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
1475
1626
|
*/
|
|
1476
1627
|
function updateInstallation(context, installationId, installationPatches, options = {}) {
|
|
1477
|
-
return tracingClient.withSpan(
|
|
1628
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$1}`, options, async (updatedOptions) => {
|
|
1478
1629
|
const endpoint = context.requestUrl();
|
|
1479
1630
|
endpoint.pathname += `/installations/${installationId}`;
|
|
1480
|
-
const headers = context.createHeaders();
|
|
1631
|
+
const headers = await context.createHeaders(OPERATION_NAME$1);
|
|
1481
1632
|
headers.set("Content-Type", "application/json");
|
|
1482
1633
|
const request = createRequest(endpoint, "PATCH", headers, updatedOptions);
|
|
1483
1634
|
request.body = JSON.stringify(installationPatches);
|
|
@@ -1487,6 +1638,7 @@ function updateInstallation(context, installationId, installationPatches, option
|
|
|
1487
1638
|
}
|
|
1488
1639
|
|
|
1489
1640
|
// Copyright (c) Microsoft Corporation.
|
|
1641
|
+
const OPERATION_NAME = "updateRegistration";
|
|
1490
1642
|
/**
|
|
1491
1643
|
* Updates an existing registration.
|
|
1492
1644
|
* @param context - The Notification Hubs client.
|
|
@@ -1495,7 +1647,7 @@ function updateInstallation(context, installationId, installationPatches, option
|
|
|
1495
1647
|
* @returns The updated registration description.
|
|
1496
1648
|
*/
|
|
1497
1649
|
function updateRegistration(context, registration, options = {}) {
|
|
1498
|
-
return tracingClient.withSpan(
|
|
1650
|
+
return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
|
|
1499
1651
|
if (!registration.etag) {
|
|
1500
1652
|
throw new coreRestPipeline.RestError("ETag is required for registration update", { statusCode: 400 });
|
|
1501
1653
|
}
|
|
@@ -1781,17 +1933,6 @@ function createBrowserInstallation(installation) {
|
|
|
1781
1933
|
return Object.assign(Object.assign({}, installation), { platform: "browser" });
|
|
1782
1934
|
}
|
|
1783
1935
|
|
|
1784
|
-
// Copyright (c) Microsoft Corporation.
|
|
1785
|
-
// Licensed under the MIT license.
|
|
1786
|
-
const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
|
|
1787
|
-
const XML_CONTENT_TYPE = "application/xml";
|
|
1788
|
-
const STREAM_CONTENT_TYPE = "application/octet-stream";
|
|
1789
|
-
const WNS_TYPE_NAME = "X-WNS-Type";
|
|
1790
|
-
const WNS_RAW = "wns/raw";
|
|
1791
|
-
const WNS_BADGE = "wns/badge";
|
|
1792
|
-
const WNS_TITLE = "wns/tile";
|
|
1793
|
-
const WNS_TOAST = "wns/toast";
|
|
1794
|
-
|
|
1795
1936
|
// Copyright (c) Microsoft Corporation.
|
|
1796
1937
|
/**
|
|
1797
1938
|
* Creates a notification to send to an Apple device.
|