@azure/notification-hubs 1.0.0-beta.1 → 1.0.0-beta.4

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.
Files changed (165) hide show
  1. package/README.md +15 -20
  2. package/dist/{index.js → index.cjs} +245 -146
  3. package/dist/index.cjs.map +1 -0
  4. package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
  5. package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
  6. package/dist-esm/src/auth/hmacSha256.browser.js +12 -0
  7. package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
  8. package/dist-esm/src/auth/hmacSha256.js +8 -0
  9. package/dist-esm/src/auth/hmacSha256.js.map +1 -0
  10. package/dist-esm/src/auth/sasTokenProvider.js +58 -0
  11. package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
  12. package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
  13. package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
  14. package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
  15. package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
  16. package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
  17. package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
  18. package/dist-esm/src/client/createRegistration.js +2 -1
  19. package/dist-esm/src/client/createRegistration.js.map +1 -1
  20. package/dist-esm/src/client/createRegistrationId.js +3 -2
  21. package/dist-esm/src/client/createRegistrationId.js.map +1 -1
  22. package/dist-esm/src/client/deleteInstallation.js +3 -2
  23. package/dist-esm/src/client/deleteInstallation.js.map +1 -1
  24. package/dist-esm/src/client/deleteRegistration.js +3 -2
  25. package/dist-esm/src/client/deleteRegistration.js.map +1 -1
  26. package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
  27. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
  28. package/dist-esm/src/client/getInstallation.js +3 -2
  29. package/dist-esm/src/client/getInstallation.js.map +1 -1
  30. package/dist-esm/src/client/getNotificationHubJob.js +3 -2
  31. package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
  32. package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
  33. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
  34. package/dist-esm/src/client/getRegistration.js +3 -2
  35. package/dist-esm/src/client/getRegistration.js.map +1 -1
  36. package/dist-esm/src/client/index.js +7 -3
  37. package/dist-esm/src/client/index.js.map +1 -1
  38. package/dist-esm/src/client/internal/_client.js +23 -7
  39. package/dist-esm/src/client/internal/_client.js.map +1 -1
  40. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
  41. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
  42. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
  43. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
  44. package/dist-esm/src/client/internal/_sendNotificationPayload.js +2 -2
  45. package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
  46. package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
  47. package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
  48. package/dist-esm/src/client/listRegistrations.js +3 -2
  49. package/dist-esm/src/client/listRegistrations.js.map +1 -1
  50. package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
  51. package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
  52. package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -1
  53. package/dist-esm/src/client/scheduleNotification.js.map +1 -1
  54. package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -1
  55. package/dist-esm/src/client/sendDirectNotification.js +1 -2
  56. package/dist-esm/src/client/sendDirectNotification.js.map +1 -1
  57. package/dist-esm/src/client/sendNotification.js.map +1 -1
  58. package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
  59. package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
  60. package/dist-esm/src/client/updateInstallation.js +3 -2
  61. package/dist-esm/src/client/updateInstallation.js.map +1 -1
  62. package/dist-esm/src/client/updateRegistration.js +2 -1
  63. package/dist-esm/src/client/updateRegistration.js.map +1 -1
  64. package/dist-esm/src/models/installation.js +1 -1
  65. package/dist-esm/src/models/installation.js.map +1 -1
  66. package/dist-esm/src/models/notification.js +1 -1
  67. package/dist-esm/src/models/notification.js.map +1 -1
  68. package/dist-esm/src/models/notificationBuilder.js +6 -6
  69. package/dist-esm/src/models/notificationBuilder.js.map +1 -1
  70. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  71. package/dist-esm/src/models/registration.js +3 -39
  72. package/dist-esm/src/models/registration.js.map +1 -1
  73. package/dist-esm/src/models/response.js.map +1 -1
  74. package/dist-esm/src/notificationHubsClient.js +1 -2
  75. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  76. package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -0
  77. package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
  78. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +31 -0
  79. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -0
  80. package/dist-esm/src/serializers/registrationSerializer.js +3 -28
  81. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  82. package/dist-esm/src/utils/constants.js +1 -0
  83. package/dist-esm/src/utils/constants.js.map +1 -1
  84. package/dist-esm/src/utils/retryPolicy.js +2 -2
  85. package/dist-esm/src/utils/retryPolicy.js.map +1 -1
  86. package/dist-esm/src/utils/tracing.js +2 -1
  87. package/dist-esm/src/utils/tracing.js.map +1 -1
  88. package/package.json +18 -13
  89. package/types/3.1/notification-hubs.d.ts +60 -77
  90. package/types/latest/notification-hubs.d.ts +61 -83
  91. package/types/latest/tsdoc-metadata.json +1 -1
  92. package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
  93. package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
  94. package/types/src/auth/hmacSha256.browser.d.ts +3 -0
  95. package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
  96. package/types/src/auth/hmacSha256.d.ts +2 -0
  97. package/types/src/auth/hmacSha256.d.ts.map +1 -0
  98. package/types/src/auth/sasTokenProvider.d.ts +77 -0
  99. package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
  100. package/types/src/client/cancelScheduledNotification.d.ts +1 -1
  101. package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
  102. package/types/src/client/createOrUpdateInstallation.d.ts +1 -1
  103. package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
  104. package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
  105. package/types/src/client/createRegistration.d.ts.map +1 -1
  106. package/types/src/client/createRegistrationId.d.ts.map +1 -1
  107. package/types/src/client/deleteInstallation.d.ts +1 -1
  108. package/types/src/client/deleteInstallation.d.ts.map +1 -1
  109. package/types/src/client/deleteRegistration.d.ts +1 -1
  110. package/types/src/client/deleteRegistration.d.ts.map +1 -1
  111. package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
  112. package/types/src/client/getInstallation.d.ts.map +1 -1
  113. package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
  114. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
  115. package/types/src/client/getRegistration.d.ts.map +1 -1
  116. package/types/src/client/index.d.ts +2 -3
  117. package/types/src/client/index.d.ts.map +1 -1
  118. package/types/src/client/internal/_client.d.ts +8 -8
  119. package/types/src/client/internal/_client.d.ts.map +1 -1
  120. package/types/src/client/internal/_scheduleNotificationPayload.d.ts +1 -1
  121. package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
  122. package/types/src/client/internal/_sendNotificationPayload.d.ts +1 -1
  123. package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -1
  124. package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
  125. package/types/src/client/listRegistrations.d.ts.map +1 -1
  126. package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
  127. package/types/src/client/scheduleBroadcastNotification.d.ts +1 -1
  128. package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -1
  129. package/types/src/client/scheduleNotification.d.ts +1 -1
  130. package/types/src/client/scheduleNotification.d.ts.map +1 -1
  131. package/types/src/client/sendBroadcastNotification.d.ts +1 -1
  132. package/types/src/client/sendBroadcastNotification.d.ts.map +1 -1
  133. package/types/src/client/sendDirectNotification.d.ts +4 -5
  134. package/types/src/client/sendDirectNotification.d.ts.map +1 -1
  135. package/types/src/client/sendNotification.d.ts +1 -1
  136. package/types/src/client/sendNotification.d.ts.map +1 -1
  137. package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
  138. package/types/src/client/updateInstallation.d.ts +1 -1
  139. package/types/src/client/updateInstallation.d.ts.map +1 -1
  140. package/types/src/client/updateRegistration.d.ts.map +1 -1
  141. package/types/src/models/installation.d.ts +3 -3
  142. package/types/src/models/installation.d.ts.map +1 -1
  143. package/types/src/models/notification.d.ts +3 -3
  144. package/types/src/models/notification.d.ts.map +1 -1
  145. package/types/src/models/notificationBuilder.d.ts +4 -4
  146. package/types/src/models/notificationBuilder.d.ts.map +1 -1
  147. package/types/src/models/notificationDetails.d.ts +63 -0
  148. package/types/src/models/notificationDetails.d.ts.map +1 -1
  149. package/types/src/models/registration.d.ts +6 -59
  150. package/types/src/models/registration.d.ts.map +1 -1
  151. package/types/src/models/response.d.ts +0 -26
  152. package/types/src/models/response.d.ts.map +1 -1
  153. package/types/src/notificationHubsClient.d.ts +3 -5
  154. package/types/src/notificationHubsClient.d.ts.map +1 -1
  155. package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
  156. package/types/src/serializers/notificationOutcomeSerializer.d.ts +3 -0
  157. package/types/src/serializers/notificationOutcomeSerializer.d.ts.map +1 -0
  158. package/types/src/serializers/registrationSerializer.d.ts +1 -21
  159. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  160. package/types/src/utils/constants.d.ts +1 -0
  161. package/types/src/utils/constants.d.ts.map +1 -1
  162. package/types/src/utils/tracing.d.ts.map +1 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
  165. package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
package/README.md CHANGED
@@ -9,8 +9,12 @@ Azure Notification Hubs provide a scaled-out push engine that enables you to sen
9
9
  - Notify users of enterprise events such as new messages and work items.
10
10
  - Send codes for multi-factor authentication.
11
11
 
12
- [Source code](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/notificationhubs/notification-hubs/) |
13
- [Product documentation](https://docs.microsoft.com/azure/notification-hubs/)
12
+ Key links:
13
+
14
+ - [Source code](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/notificationhubs/notification-hubs/)
15
+ - [Package (npm)](https://www.npmjs.com/package/@azure/notification-hubs)
16
+ - [Product documentation](https://docs.microsoft.com/azure/notification-hubs/)
17
+ - [Samples](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/notificationhubs/notification-hubs/samples-dev)
14
18
 
15
19
  ## Getting started
16
20
 
@@ -134,7 +138,7 @@ Device management is a core concept to Notification Hubs to be able to store the
134
138
  Installations are a newer and native JSON approach to device management that contains additional properties such as an installation ID and user ID which can be used for sending to audiences. The installations API has a few advantages over the existing Registration APIs in the following ways:
135
139
 
136
140
  - Fully idempotent API so calling create on the installation, so an operation can be retried without worries about duplications.
137
- - Support for `userId` and `installationId` properties which can be then used in tag expressions such as `$InstallationId:myInstallId` and `$UserId:bob@contoso.com`.
141
+ - Support for `userId` and `installationId` properties which can be then used in tag expressions such as `$InstallationId:{myInstallId}` and `$UserId:{bob@contoso.com}`.
138
142
  - Templates are now part of the installation instead of a separate registration and can be reference by name as a tag for sending.
139
143
  - Partial updates are supported through the [JSON Patch Standard](https://tools.ietf.org/html/rfc6902), which allows to add tags and change other data without having to first query the installation.
140
144
 
@@ -355,7 +359,7 @@ for await (const pages of registrations.byPage()) {
355
359
 
356
360
  Notification Hubs supports sending notifications to devices either directly using the unique PNS provided identifier, using tags for audience send, or a general broadcast to all devices. Using the Standard SKU and above, [scheduled send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-send-push-notifications-scheduled) allows the user to schedule notifications up to seven days in advance. All send operations return a Tracking ID and Correlation ID which can be used for Notification Hubs support cases. With the Standard SKU and above, a Notification ID is also returned which can be used to get notification telemetry via the `getNotificationOutcomeDetails` method.
357
361
 
358
- For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `send*` methods, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
362
+ For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `sendNotification` or `sendBroadcastNotification` methods, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
359
363
 
360
364
  Raw JSON or XML strings can be sent to the send or scheduled send methods, or the notification builders can be used which helps construct messages per PNS such as APNs, Firebase, Baidu, ADM and WNS. These builders will build the native message format and fill in associated HTTP headers so there is no guessing about which fields are available for each PNS.
361
365
 
@@ -366,6 +370,7 @@ import { buildAppleNativeMessage } from "@azure/notification-hubs";
366
370
  // Using the modular approach
367
371
  import { buildAppleNativeMessage } from "@azure/notification-hubs/models/notificationBuilder";
368
372
 
373
+
369
374
  const apnsMessage = buildAppleNativeMessage({
370
375
  alert: {
371
376
  title: "Notification Title",
@@ -377,6 +382,7 @@ const apnsMessage = buildAppleNativeMessage({
377
382
  });
378
383
 
379
384
  // Send the message using the modular approach
385
+
380
386
  const result = await sendBroadcastNotification(context, apnsMessage);
381
387
  ```
382
388
 
@@ -473,9 +479,7 @@ const message = createAppleNotification({
473
479
  },
474
480
  });
475
481
 
476
- // Not required but can set test send to true for debugging purposes.
477
- const sendOptions: SendOperationOptions = { enableTestSend: false };
478
- const result = await client.sendDirectNotification(devicetoken, message, sendOptions);
482
+ const result = await client.sendDirectNotification(devicetoken, message);
479
483
 
480
484
  console.log(`Tracking ID: ${result.trackingId}`);
481
485
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -507,8 +511,6 @@ const message = createAppleNotification({
507
511
  },
508
512
  });
509
513
 
510
- // Not required but can set test send to true for debugging purposes.
511
- const sendOptions: SendOperationOptions = { enableTestSend: false };
512
514
  const result = await sendDirectNotification(context, devicetoken, message, sendOptions);
513
515
 
514
516
  console.log(`Tracking ID: ${result.trackingId}`);
@@ -620,9 +622,7 @@ const message = createAppleNotification({
620
622
  },
621
623
  });
622
624
 
623
- // Not required but can set test send to true for debugging purposes.
624
- const sendOptions: SendOperationOptions = { enableTestSend: false };
625
- const result = await client.scheduleNotification(scheduledTime, tagExpression, message, sendOptions);
625
+ const result = await client.scheduleNotification(scheduledTime, tagExpression, message);
626
626
 
627
627
  console.log(`Tracking ID: ${result.trackingId}`);
628
628
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -655,9 +655,7 @@ const message = createAppleNotification({
655
655
  },
656
656
  });
657
657
 
658
- // Not required but can set test send to true for debugging purposes.
659
- const sendOptions: SendOperationOptions = { enableTestSend: false };
660
- const result = await scheduleNotification(context, scheduledTime, tagExpression, message, sendOptions);
658
+ const result = await scheduleNotification(context, scheduledTime, tagExpression, message);
661
659
 
662
660
  console.log(`Tracking ID: ${result.trackingId}`);
663
661
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -672,11 +670,11 @@ console.log(`Notification ID: ${result.notificationId}`);
672
670
 
673
671
  Azure Notification Hubs has a complete guide to troubleshooting problems with dropped notifications in the [Diagnose dropped notifications in Azure Notification Hubs Guide](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer).
674
672
 
675
- [Test send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer#enabletestsend-property) is supported supported in the send methods with the `enableTestSend` option:
673
+ [Test send](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-fixer#enabletestsend-property) is supported supported in the `sendNotification` method with the `enableTestSend` option:
676
674
 
677
675
  ```typescript
678
676
  const sendOptions: SendOperationOptions = { enableTestSend: true };
679
- const result = await client.sendDirectNotification(devicetoken, message, sendOptions);
677
+ const result = await client.sendNotification(tags, message, sendOptions);
680
678
  ```
681
679
 
682
680
  ### Logging
@@ -744,6 +742,3 @@ folder for more details.
744
742
  - [Azure Notification Hubs](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-overview)
745
743
 
746
744
  ![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%notificationhubs%2Fnotification-hubs%2FREADME.png)
747
-
748
- [azure_cli]: https://docs.microsoft.com/cli/azure
749
- [azure_sub]: https://azure.microsoft.com/free/