app-store-server-api
Advanced tools
Comparing version 0.9.0 to 0.10.0
@@ -172,3 +172,3 @@ "use strict"; | ||
/** | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_notification_history | ||
*/ | ||
@@ -175,0 +175,0 @@ AppStoreServerAPI.prototype.getNotificationHistory = function (request, query) { |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.CertificateValidationError = exports.AppStoreError = exports.APPLE_ROOT_CA_G3_FINGERPRINT = exports.decodeNotificationPayload = exports.decodeRenewalInfo = exports.decodeTransaction = exports.decodeTransactions = exports.SendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = exports.TransactionReason = exports.TransactionType = exports.OwnershipType = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.ProductTypeParameter = exports.SortParameter = exports.Environment = exports.AppStoreServerAPI = void 0; | ||
exports.CertificateValidationError = exports.AppStoreError = exports.APPLE_ROOT_CA_G3_FINGERPRINT = exports.decodeNotificationPayload = exports.decodeRenewalInfo = exports.decodeTransaction = exports.decodeTransactions = exports.SendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.isDecodedNotificationSummaryPayload = exports.isDecodedNotificationDataPayload = exports.OrderLookupStatus = exports.TransactionReason = exports.TransactionType = exports.OwnershipType = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.ProductTypeParameter = exports.SortParameter = exports.Environment = exports.AppStoreServerAPI = void 0; | ||
var AppStoreServerAPI_1 = require("./AppStoreServerAPI"); | ||
@@ -19,2 +19,4 @@ Object.defineProperty(exports, "AppStoreServerAPI", { enumerable: true, get: function () { return AppStoreServerAPI_1.AppStoreServerAPI; } }); | ||
Object.defineProperty(exports, "OrderLookupStatus", { enumerable: true, get: function () { return Models_1.OrderLookupStatus; } }); | ||
Object.defineProperty(exports, "isDecodedNotificationDataPayload", { enumerable: true, get: function () { return Models_1.isDecodedNotificationDataPayload; } }); | ||
Object.defineProperty(exports, "isDecodedNotificationSummaryPayload", { enumerable: true, get: function () { return Models_1.isDecodedNotificationSummaryPayload; } }); | ||
Object.defineProperty(exports, "NotificationType", { enumerable: true, get: function () { return Models_1.NotificationType; } }); | ||
@@ -21,0 +23,0 @@ Object.defineProperty(exports, "NotificationSubtype", { enumerable: true, get: function () { return Models_1.NotificationSubtype; } }); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.SendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.TransactionReason = exports.TransactionType = exports.OwnershipType = exports.ProductTypeParameter = exports.SortParameter = exports.Environment = void 0; | ||
exports.SendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.isDecodedNotificationSummaryPayload = exports.isDecodedNotificationDataPayload = exports.OrderLookupStatus = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.TransactionReason = exports.TransactionType = exports.OwnershipType = exports.ProductTypeParameter = exports.SortParameter = exports.Environment = void 0; | ||
var Environment; | ||
@@ -83,2 +83,10 @@ (function (Environment) { | ||
})(OrderLookupStatus = exports.OrderLookupStatus || (exports.OrderLookupStatus = {})); | ||
function isDecodedNotificationDataPayload(decodedNotificationPayload) { | ||
return "data" in decodedNotificationPayload; | ||
} | ||
exports.isDecodedNotificationDataPayload = isDecodedNotificationDataPayload; | ||
function isDecodedNotificationSummaryPayload(decodedNotificationPayload) { | ||
return "summary" in decodedNotificationPayload; | ||
} | ||
exports.isDecodedNotificationSummaryPayload = isDecodedNotificationSummaryPayload; | ||
// https://developer.apple.com/documentation/appstoreservernotifications/notificationtype | ||
@@ -85,0 +93,0 @@ var NotificationType; |
@@ -143,3 +143,3 @@ var __assign = (this && this.__assign) || function () { | ||
/** | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_notification_history | ||
*/ | ||
@@ -146,0 +146,0 @@ AppStoreServerAPI.prototype.getNotificationHistory = function (request, query) { |
export { AppStoreServerAPI } from "./AppStoreServerAPI"; | ||
export { Environment, SortParameter, ProductTypeParameter, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, OwnershipType, TransactionType, TransactionReason, OrderLookupStatus, NotificationType, NotificationSubtype, SendAttemptResult } from "./Models"; | ||
export { Environment, SortParameter, ProductTypeParameter, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, OwnershipType, TransactionType, TransactionReason, OrderLookupStatus, isDecodedNotificationDataPayload, isDecodedNotificationSummaryPayload, NotificationType, NotificationSubtype, SendAttemptResult } from "./Models"; | ||
export { decodeTransactions, decodeTransaction, decodeRenewalInfo, decodeNotificationPayload } from "./Decoding"; | ||
export { APPLE_ROOT_CA_G3_FINGERPRINT } from "./AppleRootCertificate"; | ||
export { AppStoreError, CertificateValidationError } from "./Errors"; |
@@ -80,2 +80,8 @@ export var Environment; | ||
})(OrderLookupStatus || (OrderLookupStatus = {})); | ||
export function isDecodedNotificationDataPayload(decodedNotificationPayload) { | ||
return "data" in decodedNotificationPayload; | ||
} | ||
export function isDecodedNotificationSummaryPayload(decodedNotificationPayload) { | ||
return "summary" in decodedNotificationPayload; | ||
} | ||
// https://developer.apple.com/documentation/appstoreservernotifications/notificationtype | ||
@@ -82,0 +88,0 @@ export var NotificationType; |
@@ -44,3 +44,3 @@ import { CheckTestNotificationResponse, Environment, HistoryResponse, NotificationHistoryQuery, NotificationHistoryRequest, NotificationHistoryResponse, OrderLookupResponse, SendTestNotificationResponse, StatusResponse, SubscriptionStatusesQuery, TransactionHistoryQuery, TransactionInfoResponse } from "./Models"; | ||
/** | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status | ||
* https://developer.apple.com/documentation/appstoreserverapi/get_notification_history | ||
*/ | ||
@@ -47,0 +47,0 @@ getNotificationHistory(request: NotificationHistoryRequest, query?: NotificationHistoryQuery): Promise<NotificationHistoryResponse>; |
export { AppStoreServerAPI } from "./AppStoreServerAPI"; | ||
export { Environment, Timestamp, StorefrontCountryCode, SortParameter, ProductTypeParameter, TransactionHistoryQuery, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, JWSTransactionDecodedPayload, OwnershipType, TransactionType, TransactionReason, StatusResponse, SubscriptionStatusesQuery, LastTransactionsItem, JWSRenewalInfoDecodedPayload, HistoryResponse, TransactionInfoResponse, SubscriptionGroupIdentifierItem, OrderLookupResponse, OrderLookupStatus, DecodedNotificationPayload, NotificationData, NotificationSummary, NotificationType, NotificationSubtype, SendTestNotificationResponse, CheckTestNotificationResponse, SendAttemptResult, NotificationHistoryQuery, NotificationHistoryRequest, NotificationHistoryResponse, NotificationHistoryResponseItem } from "./Models"; | ||
export { Environment, Timestamp, StorefrontCountryCode, SortParameter, ProductTypeParameter, TransactionHistoryQuery, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, JWSTransactionDecodedPayload, OwnershipType, TransactionType, TransactionReason, StatusResponse, SubscriptionStatusesQuery, LastTransactionsItem, JWSRenewalInfoDecodedPayload, HistoryResponse, TransactionInfoResponse, SubscriptionGroupIdentifierItem, OrderLookupResponse, OrderLookupStatus, DecodedNotificationPayload, isDecodedNotificationDataPayload, isDecodedNotificationSummaryPayload, NotificationData, NotificationSummary, NotificationType, NotificationSubtype, SendTestNotificationResponse, CheckTestNotificationResponse, SendAttemptResult, NotificationHistoryQuery, NotificationHistoryRequest, NotificationHistoryResponse, NotificationHistoryResponseItem } from "./Models"; | ||
export { decodeTransactions, decodeTransaction, decodeRenewalInfo, decodeNotificationPayload } from "./Decoding"; | ||
export { APPLE_ROOT_CA_G3_FINGERPRINT } from "./AppleRootCertificate"; | ||
export { AppStoreError, CertificateValidationError } from "./Errors"; |
@@ -166,3 +166,3 @@ export declare enum Environment { | ||
} | ||
export interface DecodedNotificationPayload { | ||
interface DecodedNotificationBasePayload { | ||
notificationType: NotificationType; | ||
@@ -173,5 +173,14 @@ subtype?: NotificationSubtype; | ||
signedDate: Timestamp; | ||
} | ||
interface DecodedNotificationDataPayload extends DecodedNotificationBasePayload { | ||
data: NotificationData; | ||
summary?: never; | ||
} | ||
interface DecodedNotificationSummaryPayload extends DecodedNotificationBasePayload { | ||
data?: never; | ||
summary: NotificationSummary; | ||
} | ||
export type DecodedNotificationPayload = DecodedNotificationDataPayload | DecodedNotificationSummaryPayload; | ||
export declare function isDecodedNotificationDataPayload(decodedNotificationPayload: DecodedNotificationPayload): decodedNotificationPayload is DecodedNotificationDataPayload; | ||
export declare function isDecodedNotificationSummaryPayload(decodedNotificationPayload: DecodedNotificationPayload): decodedNotificationPayload is DecodedNotificationSummaryPayload; | ||
export interface NotificationData { | ||
@@ -274,1 +283,2 @@ appAppleId: string; | ||
} | ||
export {}; |
{ | ||
"name": "app-store-server-api", | ||
"version": "0.9.0", | ||
"version": "0.10.0", | ||
"description": "A client for the App Store Server API", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
@@ -139,3 +139,3 @@ # app-store-server-api | ||
```javascript | ||
import { decodeNotificationPayload } from "app-store-server-api" | ||
import { decodeNotificationPayload, isDecodedNotificationDataPayload, isDecodedNotificationSummaryPayload } from "app-store-server-api" | ||
@@ -149,2 +149,12 @@ // signedPayload is the body sent by Apple | ||
} | ||
// Notifications can contain either a data field or a summary field but never both. | ||
// Use the provided type guards to determine which is present. | ||
if (isDecodedNotificationDataPayload(payload)) { | ||
// payload is of type DecodedNotificationDataPayload | ||
} | ||
if (isdecodedNotificationSummaryPayload(payload)) { | ||
// payload is of type DecodedNotificationSummaryPayload | ||
} | ||
``` | ||
@@ -168,2 +178,3 @@ | ||
- [Apple App Store Server Node.js Library](https://github.com/apple/app-store-server-library-node) | ||
WWDC videos: | ||
@@ -170,0 +181,0 @@ - [Manage in-app purchases on your server](https://developer.apple.com/videos/play/wwdc2021/10174/) |
94550
1693
186