Socket
Socket
Sign inDemoInstall

expo-server-sdk

Package Overview
Dependencies
Maintainers
21
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

expo-server-sdk - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

build/ExpoClientValues.d.ts

2

build/ExpoClient.d.ts

@@ -69,2 +69,4 @@ /// <reference types="node" />

channelId?: string;
categoryId?: string;
mutableContent?: boolean;
};

@@ -71,0 +73,0 @@ export declare type ExpoPushReceiptId = string;

82

build/ExpoClient.js
"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]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -11,2 +30,5 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });

@@ -20,6 +42,8 @@ exports.Expo = void 0;

*/
const assert = require("assert");
const node_fetch_1 = require("node-fetch");
const promiseLimit = require("promise-limit");
const zlib = require("zlib");
const assert_1 = __importDefault(require("assert"));
const node_fetch_1 = __importStar(require("node-fetch"));
const promise_limit_1 = __importDefault(require("promise-limit"));
const promise_retry_1 = __importDefault(require("promise-retry"));
const zlib_1 = __importDefault(require("zlib"));
const ExpoClientValues_1 = require("./ExpoClientValues");
const BASE_URL = 'https://exp.host';

@@ -44,3 +68,3 @@ const BASE_API_URL = `${BASE_URL}/--/api/v2`;

this.httpAgent = options.httpAgent;
this.limitConcurrentRequests = promiseLimit(options.maxConcurrentRequests != null
this.limitConcurrentRequests = promise_limit_1.default(options.maxConcurrentRequests != null
? options.maxConcurrentRequests

@@ -73,9 +97,26 @@ : DEFAULT_CONCURRENT_REQUEST_LIMIT);

const actualMessagesCount = Expo._getActualMessageCount(messages);
const data = yield this.requestAsync(`${BASE_API_URL}/push/send`, {
httpMethod: 'post',
body: messages,
shouldCompress(body) {
return body.length > 1024;
},
});
const data = yield this.limitConcurrentRequests(() => __awaiter(this, void 0, void 0, function* () {
return yield promise_retry_1.default((retry) => __awaiter(this, void 0, void 0, function* () {
try {
return yield this.requestAsync(`${BASE_API_URL}/push/send`, {
httpMethod: 'post',
body: messages,
shouldCompress(body) {
return body.length > 1024;
},
});
}
catch (e) {
// if Expo servers rate limit, retry with exponential backoff
if (e.statusCode === 429) {
return retry(e);
}
throw e;
}
}), {
retries: 2,
factor: 2,
minTimeout: ExpoClientValues_1.requestRetryMinTimeout,
});
}));
if (!Array.isArray(data) || data.length !== actualMessagesCount) {

@@ -181,3 +222,3 @@ const apiError = new Error(`Expected Expo to respond with ${actualMessagesCount} ${actualMessagesCount === 1 ? 'ticket' : 'tickets'} but got ${data.length}`);

const json = JSON.stringify(options.body);
assert(json != null, `JSON request body must not be null`);
assert_1.default(json != null, `JSON request body must not be null`);
if (options.shouldCompress(json)) {

@@ -192,3 +233,3 @@ requestBody = yield gzipAsync(Buffer.from(json));

}
const response = yield this.limitConcurrentRequests(() => node_fetch_1.default(url, {
const response = yield node_fetch_1.default(url, {
method: options.httpMethod,

@@ -198,3 +239,3 @@ body: requestBody,

agent: this.httpAgent,
}));
});
if (response.status !== 200) {

@@ -215,3 +256,3 @@ const apiError = yield this.parseErrorResponseAsync(response);

if (result.errors) {
const apiError = this.getErrorFromResult(result);
const apiError = this.getErrorFromResult(response, result);
throw apiError;

@@ -237,3 +278,3 @@ }

}
return this.getErrorFromResult(result);
return this.getErrorFromResult(response, result);
});

@@ -253,4 +294,4 @@ }

*/
getErrorFromResult(result) {
assert(result.errors && result.errors.length > 0, `Expected at least one error from Expo`);
getErrorFromResult(response, result) {
assert_1.default(result.errors && result.errors.length > 0, `Expected at least one error from Expo`);
const [errorData, ...otherErrorData] = result.errors;

@@ -261,2 +302,3 @@ const error = this.getErrorFromResultError(errorData);

}
error.statusCode = response.status;
return error;

@@ -296,3 +338,3 @@ }

return new Promise((resolve, reject) => {
zlib.gzip(data, (error, result) => {
zlib_1.default.gzip(data, (error, result) => {
if (error) {

@@ -299,0 +341,0 @@ reject(error);

{
"name": "expo-server-sdk",
"version": "3.6.0",
"version": "3.7.0",
"description": "Server-side library for working with Expo using Node.js",

@@ -43,15 +43,17 @@ "main": "build/ExpoClient.js",

"node-fetch": "^2.6.0",
"promise-limit": "^2.7.0"
"promise-limit": "^2.7.0",
"promise-retry": "^2.0.1"
},
"devDependencies": {
"@types/jest": "^26.0.3",
"@types/node-fetch": "^2.5.7",
"eslint": "^7.3.1",
"eslint-config-universe": "^4.0.0",
"fetch-mock": "^9.10.3",
"jest": "^26.1.0",
"prettier": "^2.0.5",
"ts-jest": "~26.4.0",
"typescript": "^4.0.3"
"@types/jest": "^27.0.1",
"@types/node-fetch": "^2.5.12",
"@types/promise-retry": "^1.1.3",
"eslint": "^7.32.0",
"eslint-config-universe": "^7.0.1",
"fetch-mock": "^9.11.0",
"jest": "^27.0.6",
"prettier": "^2.3.2",
"ts-jest": "~27.0.5",
"typescript": "^4.3.5"
}
}

Sorry, the diff of this file is not supported yet

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