New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

app-store-server-api

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

app-store-server-api - npm Package Compare versions

Comparing version 0.4.1 to 0.5.0

97

dist/cjs/AppStoreServerAPI.js
"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -93,8 +108,9 @@ if (k2 === undefined) k2 = k;

*/
AppStoreServerAPI.prototype.getTransactionHistory = function (originalTransactionId, revision) {
AppStoreServerAPI.prototype.getTransactionHistory = function (originalTransactionId, query) {
if (query === void 0) { query = {}; }
return __awaiter(this, void 0, void 0, function () {
var query;
var path;
return __generator(this, function (_a) {
query = revision ? "?revision=".concat(revision) : "";
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/history/").concat(originalTransactionId).concat(query))];
path = this.addQuery("/inApps/v1/history/".concat(originalTransactionId), __assign({}, query));
return [2 /*return*/, this.makeRequest("GET", path)];
});

@@ -109,3 +125,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/subscriptions/").concat(originalTransactionId))];
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/subscriptions/".concat(originalTransactionId))];
});

@@ -120,3 +136,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/lookup/").concat(orderId))];
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/lookup/".concat(orderId))];
});

@@ -126,7 +142,40 @@ });

/**
* https://developer.apple.com/documentation/appstoreserverapi/request_a_test_notification
*/
AppStoreServerAPI.prototype.requestTestNotification = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("POST", "/inApps/v1/notifications/test")];
});
});
};
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
AppStoreServerAPI.prototype.getTestNotificationStatus = function (id) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/notifications/test/".concat(id))];
});
});
};
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
AppStoreServerAPI.prototype.getNotificationHistory = function (request, query) {
if (query === void 0) { query = {}; }
return __awaiter(this, void 0, void 0, function () {
var path;
return __generator(this, function (_a) {
path = this.addQuery("/inApps/v1/notifications/history", __assign({}, query));
return [2 /*return*/, this.makeRequest("POST", path, request)];
});
});
};
/**
* Performs a network request against the API and handles the result.
*/
AppStoreServerAPI.prototype.makeRequest = function (url) {
AppStoreServerAPI.prototype.makeRequest = function (method, path, body) {
return __awaiter(this, void 0, void 0, function () {
var token, result, _a, body;
var token, url, serializedBody, result, _a, body_1;
return __generator(this, function (_b) {

@@ -137,6 +186,10 @@ switch (_b.label) {

token = _b.sent();
url = this.baseUrl + path;
serializedBody = body ? JSON.stringify(body) : undefined;
return [4 /*yield*/, (0, node_fetch_1.default)(url, {
method: "GET",
method: method,
body: serializedBody,
headers: {
Authorization: "Bearer ".concat(token)
Authorization: "Bearer ".concat(token),
"Content-Type": "application/json"
}

@@ -159,4 +212,4 @@ })];

case 4:
body = _b.sent();
throw new Errors_1.AppStoreError(body.errorCode, body.errorMessage);
body_1 = _b.sent();
throw new Errors_1.AppStoreError(body_1.errorCode, body_1.errorMessage);
case 5:

@@ -224,2 +277,20 @@ this.token = undefined;

});
/**
* Serializes a query object into a query string and appends it
* the provided path.
*/
AppStoreServerAPI.prototype.addQuery = function (path, query) {
var params = new URLSearchParams();
for (var _i = 0, _a = Object.entries(query); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
params.set(key, value.toString());
}
var queryString = params.toString();
if (queryString === "") {
return path;
}
else {
return "".concat(path, "?").concat(queryString);
}
};
// The maximum age that an authentication token is allowed to have, as decided by Apple.

@@ -226,0 +297,0 @@ AppStoreServerAPI.maxTokenAge = 3600; // seconds, = 1 hour

"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {

@@ -6,0 +10,0 @@ if (k2 === undefined) k2 = k;

5

dist/cjs/index.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CertificateValidationError = exports.AppStoreError = exports.decodeNotificationPayload = exports.decodeRenewalInfo = exports.decodeTransaction = exports.decodeTransactions = exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = exports.TransactionType = exports.OwnershipType = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.Environment = exports.AppStoreServerAPI = void 0;
exports.CertificateValidationError = exports.AppStoreError = exports.decodeNotificationPayload = exports.decodeRenewalInfo = exports.decodeTransaction = exports.decodeTransactions = exports.FirstSendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = 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");

@@ -8,2 +8,4 @@ Object.defineProperty(exports, "AppStoreServerAPI", { enumerable: true, get: function () { return AppStoreServerAPI_1.AppStoreServerAPI; } });

Object.defineProperty(exports, "Environment", { enumerable: true, get: function () { return Models_1.Environment; } });
Object.defineProperty(exports, "SortParameter", { enumerable: true, get: function () { return Models_1.SortParameter; } });
Object.defineProperty(exports, "ProductTypeParameter", { enumerable: true, get: function () { return Models_1.ProductTypeParameter; } });
Object.defineProperty(exports, "SubscriptionStatus", { enumerable: true, get: function () { return Models_1.SubscriptionStatus; } });

@@ -19,2 +21,3 @@ Object.defineProperty(exports, "AutoRenewStatus", { enumerable: true, get: function () { return Models_1.AutoRenewStatus; } });

Object.defineProperty(exports, "NotificationSubtype", { enumerable: true, get: function () { return Models_1.NotificationSubtype; } });
Object.defineProperty(exports, "FirstSendAttemptResult", { enumerable: true, get: function () { return Models_1.FirstSendAttemptResult; } });
var Decoding_1 = require("./Decoding");

@@ -21,0 +24,0 @@ Object.defineProperty(exports, "decodeTransactions", { enumerable: true, get: function () { return Decoding_1.decodeTransactions; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.TransactionType = exports.OwnershipType = exports.Environment = void 0;
exports.FirstSendAttemptResult = exports.NotificationSubtype = exports.NotificationType = exports.OrderLookupStatus = exports.PriceIncreaseStatus = exports.OfferType = exports.ExpirationIntent = exports.AutoRenewStatus = exports.SubscriptionStatus = exports.TransactionType = exports.OwnershipType = exports.ProductTypeParameter = exports.SortParameter = exports.Environment = void 0;
var Environment;

@@ -9,2 +9,14 @@ (function (Environment) {

})(Environment = exports.Environment || (exports.Environment = {}));
var SortParameter;
(function (SortParameter) {
SortParameter["Ascending"] = "ASCENDING";
SortParameter["Descending"] = "DESCENDING";
})(SortParameter = exports.SortParameter || (exports.SortParameter = {}));
var ProductTypeParameter;
(function (ProductTypeParameter) {
ProductTypeParameter["AutoRenewable"] = "AUTO_RENEWABLE";
ProductTypeParameter["NonRenewable"] = "NON_RENEWABLE";
ProductTypeParameter["Consumable"] = "CONSUMABLE";
ProductTypeParameter["NonConsumable"] = "NON_CONSUMABLE";
})(ProductTypeParameter = exports.ProductTypeParameter || (exports.ProductTypeParameter = {}));
// https://developer.apple.com/documentation/appstoreserverapi/inappownershiptype

@@ -101,1 +113,15 @@ var OwnershipType;

})(NotificationSubtype = exports.NotificationSubtype || (exports.NotificationSubtype = {}));
// https://developer.apple.com/documentation/appstoreserverapi/firstsendattemptresult
var FirstSendAttemptResult;
(function (FirstSendAttemptResult) {
FirstSendAttemptResult["Success"] = "SUCCESS";
FirstSendAttemptResult["TimedOut"] = "TIMED_OUT";
FirstSendAttemptResult["SslIssue"] = "SSL_ISSUE";
FirstSendAttemptResult["CircularRedirect"] = "CIRCULAR_REDIRECT";
FirstSendAttemptResult["NoResponse"] = "NO_RESPONSE";
FirstSendAttemptResult["SocketIssue"] = "SOCKET_ISSUE";
FirstSendAttemptResult["UnsupportedCharset"] = "UNSUPPORTED_CHARSET";
FirstSendAttemptResult["InvalidResponse"] = "INVALID_RESPONSE";
FirstSendAttemptResult["PrematureClose"] = "PREMATURE_CLOSE";
FirstSendAttemptResult["Other"] = "OTHER";
})(FirstSendAttemptResult = exports.FirstSendAttemptResult || (exports.FirstSendAttemptResult = {}));

@@ -0,1 +1,12 @@

var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -68,8 +79,9 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

*/
AppStoreServerAPI.prototype.getTransactionHistory = function (originalTransactionId, revision) {
AppStoreServerAPI.prototype.getTransactionHistory = function (originalTransactionId, query) {
if (query === void 0) { query = {}; }
return __awaiter(this, void 0, void 0, function () {
var query;
var path;
return __generator(this, function (_a) {
query = revision ? "?revision=".concat(revision) : "";
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/history/").concat(originalTransactionId).concat(query))];
path = this.addQuery("/inApps/v1/history/".concat(originalTransactionId), __assign({}, query));
return [2 /*return*/, this.makeRequest("GET", path)];
});

@@ -84,3 +96,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/subscriptions/").concat(originalTransactionId))];
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/subscriptions/".concat(originalTransactionId))];
});

@@ -95,3 +107,3 @@ });

return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("".concat(this.baseUrl, "/inApps/v1/lookup/").concat(orderId))];
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/lookup/".concat(orderId))];
});

@@ -101,7 +113,40 @@ });

/**
* https://developer.apple.com/documentation/appstoreserverapi/request_a_test_notification
*/
AppStoreServerAPI.prototype.requestTestNotification = function () {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("POST", "/inApps/v1/notifications/test")];
});
});
};
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
AppStoreServerAPI.prototype.getTestNotificationStatus = function (id) {
return __awaiter(this, void 0, void 0, function () {
return __generator(this, function (_a) {
return [2 /*return*/, this.makeRequest("GET", "/inApps/v1/notifications/test/".concat(id))];
});
});
};
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
AppStoreServerAPI.prototype.getNotificationHistory = function (request, query) {
if (query === void 0) { query = {}; }
return __awaiter(this, void 0, void 0, function () {
var path;
return __generator(this, function (_a) {
path = this.addQuery("/inApps/v1/notifications/history", __assign({}, query));
return [2 /*return*/, this.makeRequest("POST", path, request)];
});
});
};
/**
* Performs a network request against the API and handles the result.
*/
AppStoreServerAPI.prototype.makeRequest = function (url) {
AppStoreServerAPI.prototype.makeRequest = function (method, path, body) {
return __awaiter(this, void 0, void 0, function () {
var token, result, _a, body;
var token, url, serializedBody, result, _a, body_1;
return __generator(this, function (_b) {

@@ -112,6 +157,10 @@ switch (_b.label) {

token = _b.sent();
url = this.baseUrl + path;
serializedBody = body ? JSON.stringify(body) : undefined;
return [4 /*yield*/, fetch(url, {
method: "GET",
method: method,
body: serializedBody,
headers: {
Authorization: "Bearer ".concat(token)
Authorization: "Bearer ".concat(token),
"Content-Type": "application/json"
}

@@ -134,4 +183,4 @@ })];

case 4:
body = _b.sent();
throw new AppStoreError(body.errorCode, body.errorMessage);
body_1 = _b.sent();
throw new AppStoreError(body_1.errorCode, body_1.errorMessage);
case 5:

@@ -199,2 +248,20 @@ this.token = undefined;

});
/**
* Serializes a query object into a query string and appends it
* the provided path.
*/
AppStoreServerAPI.prototype.addQuery = function (path, query) {
var params = new URLSearchParams();
for (var _i = 0, _a = Object.entries(query); _i < _a.length; _i++) {
var _b = _a[_i], key = _b[0], value = _b[1];
params.set(key, value.toString());
}
var queryString = params.toString();
if (queryString === "") {
return path;
}
else {
return "".concat(path, "?").concat(queryString);
}
};
// The maximum age that an authentication token is allowed to have, as decided by Apple.

@@ -201,0 +268,0 @@ AppStoreServerAPI.maxTokenAge = 3600; // seconds, = 1 hour

export { AppStoreServerAPI } from "./AppStoreServerAPI";
export { Environment, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, OwnershipType, TransactionType, OrderLookupStatus, NotificationType, NotificationSubtype } from "./Models";
export { Environment, SortParameter, ProductTypeParameter, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, OwnershipType, TransactionType, OrderLookupStatus, NotificationType, NotificationSubtype, FirstSendAttemptResult } from "./Models";
export { decodeTransactions, decodeTransaction, decodeRenewalInfo, decodeNotificationPayload } from "./Decoding";
export { AppStoreError, CertificateValidationError } from "./Errors";

@@ -6,2 +6,14 @@ export var Environment;

})(Environment || (Environment = {}));
export var SortParameter;
(function (SortParameter) {
SortParameter["Ascending"] = "ASCENDING";
SortParameter["Descending"] = "DESCENDING";
})(SortParameter || (SortParameter = {}));
export var ProductTypeParameter;
(function (ProductTypeParameter) {
ProductTypeParameter["AutoRenewable"] = "AUTO_RENEWABLE";
ProductTypeParameter["NonRenewable"] = "NON_RENEWABLE";
ProductTypeParameter["Consumable"] = "CONSUMABLE";
ProductTypeParameter["NonConsumable"] = "NON_CONSUMABLE";
})(ProductTypeParameter || (ProductTypeParameter = {}));
// https://developer.apple.com/documentation/appstoreserverapi/inappownershiptype

@@ -98,1 +110,15 @@ export var OwnershipType;

})(NotificationSubtype || (NotificationSubtype = {}));
// https://developer.apple.com/documentation/appstoreserverapi/firstsendattemptresult
export var FirstSendAttemptResult;
(function (FirstSendAttemptResult) {
FirstSendAttemptResult["Success"] = "SUCCESS";
FirstSendAttemptResult["TimedOut"] = "TIMED_OUT";
FirstSendAttemptResult["SslIssue"] = "SSL_ISSUE";
FirstSendAttemptResult["CircularRedirect"] = "CIRCULAR_REDIRECT";
FirstSendAttemptResult["NoResponse"] = "NO_RESPONSE";
FirstSendAttemptResult["SocketIssue"] = "SOCKET_ISSUE";
FirstSendAttemptResult["UnsupportedCharset"] = "UNSUPPORTED_CHARSET";
FirstSendAttemptResult["InvalidResponse"] = "INVALID_RESPONSE";
FirstSendAttemptResult["PrematureClose"] = "PREMATURE_CLOSE";
FirstSendAttemptResult["Other"] = "OTHER";
})(FirstSendAttemptResult || (FirstSendAttemptResult = {}));

@@ -1,2 +0,2 @@

import { Environment, HistoryResponse, OrderLookupResponse, StatusResponse } from "./Models";
import { CheckTestNotificationResponse, Environment, HistoryResponse, NotificationHistoryQuery, NotificationHistoryRequest, NotificationHistoryResponse, OrderLookupResponse, SendTestNotificationResponse, StatusResponse, TransactionHistoryQuery } from "./Models";
export declare class AppStoreServerAPI {

@@ -22,3 +22,3 @@ static readonly maxTokenAge: number;

*/
getTransactionHistory(originalTransactionId: string, revision?: string): Promise<HistoryResponse>;
getTransactionHistory(originalTransactionId: string, query?: TransactionHistoryQuery): Promise<HistoryResponse>;
/**

@@ -33,2 +33,14 @@ * https://developer.apple.com/documentation/appstoreserverapi/get_all_subscription_statuses

/**
* https://developer.apple.com/documentation/appstoreserverapi/request_a_test_notification
*/
requestTestNotification(): Promise<SendTestNotificationResponse>;
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
getTestNotificationStatus(id: string): Promise<CheckTestNotificationResponse>;
/**
* https://developer.apple.com/documentation/appstoreserverapi/get_test_notification_status
*/
getNotificationHistory(request: NotificationHistoryRequest, query?: NotificationHistoryQuery): Promise<NotificationHistoryResponse>;
/**
* Performs a network request against the API and handles the result.

@@ -45,2 +57,7 @@ */

private get tokenExpired();
/**
* Serializes a query object into a query string and appends it
* the provided path.
*/
private addQuery;
}
export { AppStoreServerAPI } from "./AppStoreServerAPI";
export { Environment, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, JWSTransactionDecodedPayload, OwnershipType, TransactionType, StatusResponse, LastTransactionsItem, JWSRenewalInfoDecodedPayload, HistoryResponse, SubscriptionGroupIdentifierItem, OrderLookupResponse, OrderLookupStatus, DecodedNotificationPayload, NotificationData, NotificationType, NotificationSubtype } from "./Models";
export { Environment, Timestamp, SortParameter, ProductTypeParameter, TransactionHistoryQuery, SubscriptionStatus, AutoRenewStatus, ExpirationIntent, OfferType, PriceIncreaseStatus, JWSTransactionDecodedPayload, OwnershipType, TransactionType, StatusResponse, LastTransactionsItem, JWSRenewalInfoDecodedPayload, HistoryResponse, SubscriptionGroupIdentifierItem, OrderLookupResponse, OrderLookupStatus, DecodedNotificationPayload, NotificationData, NotificationType, NotificationSubtype, SendTestNotificationResponse, CheckTestNotificationResponse, FirstSendAttemptResult, NotificationHistoryQuery, NotificationHistoryRequest, NotificationHistoryResponse, NotificationHistoryResponseItem } from "./Models";
export { decodeTransactions, decodeTransaction, decodeRenewalInfo, decodeNotificationPayload } from "./Decoding";
export { AppStoreError, CertificateValidationError } from "./Errors";

@@ -5,2 +5,31 @@ export declare enum Environment {

}
/**
* UNIX timestamp in milliseconds
*/
export declare type Timestamp = number;
export declare enum SortParameter {
Ascending = "ASCENDING",
Descending = "DESCENDING"
}
export declare enum ProductTypeParameter {
AutoRenewable = "AUTO_RENEWABLE",
NonRenewable = "NON_RENEWABLE",
Consumable = "CONSUMABLE",
NonConsumable = "NON_CONSUMABLE"
}
/**
* The query parameters that can be passed to the history endpoint
* to filter results and change sort order.
*/
export interface TransactionHistoryQuery {
revision?: string;
sort?: SortParameter;
startDate?: Timestamp;
endDate?: Timestamp;
productType?: ProductTypeParameter;
productId?: string;
subscriptionGroupIdentifier?: string;
inAppOwnershipType?: OwnershipType;
excludeRevoked?: boolean;
}
export interface HistoryResponse {

@@ -23,3 +52,4 @@ appAppleId: string;

bundleId: string;
expiresDate?: number;
environment: Environment;
expiresDate?: Timestamp;
inAppOwnershipType: OwnershipType;

@@ -29,10 +59,10 @@ isUpgraded?: boolean;

offerType?: OfferType;
originalPurchaseDate: number;
originalPurchaseDate: Timestamp;
originalTransactionId: string;
productId: string;
purchaseDate: number;
purchaseDate: Timestamp;
quantity: number;
revocationDate?: number;
revocationDate?: Timestamp;
revocationReason?: number;
signedDate: number;
signedDate: Timestamp;
subscriptionGroupIdentifier?: string;

@@ -80,4 +110,5 @@ transactionId: string;

autoRenewStatus: AutoRenewStatus;
environment: Environment;
expirationIntent?: ExpirationIntent;
gracePeriodExpiresDate?: number;
gracePeriodExpiresDate?: Timestamp;
isInBillingRetryPeriod?: boolean;

@@ -89,3 +120,4 @@ offerIdentifier?: string;

productId: string;
signedDate: number;
recentSubscriptionStartDate: Timestamp;
signedDate: Timestamp;
}

@@ -124,3 +156,3 @@ export declare enum AutoRenewStatus {

version: string;
signedDate: number;
signedDate: Timestamp;
data: NotificationData;

@@ -167,1 +199,39 @@ }

}
export interface SendTestNotificationResponse {
testNotificationToken: string;
}
export interface CheckTestNotificationResponse {
firstSendAttemptResult: FirstSendAttemptResult;
signedPayload: string;
}
export declare enum FirstSendAttemptResult {
Success = "SUCCESS",
TimedOut = "TIMED_OUT",
SslIssue = "SSL_ISSUE",
CircularRedirect = "CIRCULAR_REDIRECT",
NoResponse = "NO_RESPONSE",
SocketIssue = "SOCKET_ISSUE",
UnsupportedCharset = "UNSUPPORTED_CHARSET",
InvalidResponse = "INVALID_RESPONSE",
PrematureClose = "PREMATURE_CLOSE",
Other = "OTHER"
}
export interface NotificationHistoryQuery {
paginationToken?: string;
}
export interface NotificationHistoryRequest {
startDate: Timestamp;
endDate: Timestamp;
originalTransactionId?: string;
notificationType?: NotificationType;
notificationSubtype?: NotificationSubtype;
}
export interface NotificationHistoryResponse {
notificationHistory: NotificationHistoryResponseItem[];
hasMore: boolean;
paginationToken: string;
}
export interface NotificationHistoryResponseItem {
firstSendAttemptResult: FirstSendAttemptResult;
signedPayload: string;
}
{
"name": "app-store-server-api",
"version": "0.4.1",
"version": "0.5.0",
"description": "A client for the App Store Server API",

@@ -45,3 +45,3 @@ "main": "dist/cjs/index.js",

"dependencies": {
"jose": "^4.3.7",
"jose": "^4.8.1",
"node-fetch": "^2.6.6",

@@ -51,7 +51,7 @@ "uuid": "^8.3.2"

"devDependencies": {
"@types/node-fetch": "^2.5",
"@types/uuid": "^8.3.3",
"prettier": "^2.4.0",
"ts-loader": "^9.2.5",
"typescript": "^4.4.3"
"@types/node-fetch": "^2.6.2",
"@types/uuid": "^8.3.4",
"prettier": "^2.7.1",
"ts-loader": "^9.3.1",
"typescript": "^4.7.4"
},

@@ -58,0 +58,0 @@ "prettier": {

@@ -5,3 +5,4 @@ # app-store-server-api

## Features
- History, subscription status and order lookup endpoints
- Transaction history, subscription status and order lookup endpoints
- Notification test and history endpoints
- Typed responses (i.e. you get auto-complete for the fields in the response)

@@ -67,3 +68,3 @@ - Manages authentication tokens for you

if (response.hasMore) {
const nextResponse = await api.getTransactionHistory(originalTransactionId, response.revision)
const nextResponse = await api.getTransactionHistory(originalTransactionId, { revision: response.revision })
// ...

@@ -73,3 +74,12 @@ }

The library supports the filter and sort options introduced at WWDC 2022.
See [Get Transaction History](https://developer.apple.com/documentation/appstoreserverapi/get_transaction_history) for a list of available options.
```javascript
const response = await api.getTransactionHistory(originalTransactionId, {
productType: ProductTypeParameter.AutoRenewable,
sort: SortParameter.Descending,
})
```
### Subscription status

@@ -99,6 +109,32 @@ ```javascript

### Server notifications
While not exactly part of the App Store Server API, App Store Server Notifications (version 2) is closely related and uses some of the same types and encoding format as the API. For that reason this package includes a function to help you decode notifications (which will also verify their signature).
### Request test notification
```javascript
const response = await api.requestTestNotification()
// response.testNotificationToken identifies the notification that will be sent.
```
### Get test notification status
```javascript
const response = await api.getTestNotificationStatus("ae0e2185-a3c6-47e4-b41a-6ef4bc86314e_1656062546521")
```
### Notification history
```javascript
// Start and end date are required.
// The earliest supported start date is June 6th (the start of WWDC 2022).
const response = await api.getNotificationHistory({
startDate: 1654466400000, // June 6th 2022
endDate: new Date().getTime()
})
// Check if there are more items.
if (response.hasMore) {
// Use history.paginationToken to fetch additional items.
}
```
### Decoding server notifications
The App Store Server API and App Store Server Notifications (version 2) are closely related and use some of the same types and encoding formats. This library includes a function to help you decode notifications (which will also verify their signature).
```javascript
import { decodeNotificationPayload } from "app-store-server-api"

@@ -120,4 +156,5 @@

- [Support customers and handle refunds](https://developer.apple.com/videos/play/wwdc2021/10175/)
- [What's new with in-app purchase](https://developer.apple.com/videos/play/wwdc2022/10007/)
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc