apns2
Version:
Node client for connecting to Apple's Push Notification Service using the new HTTP/2 protocol with JSON web tokens.
45 lines (44 loc) • 1.46 kB
TypeScript
import { EventEmitter } from "node:events";
import { type PrivateKey } from "fast-jwt";
import { Pool } from "undici";
import { ApnsError } from "./errors.js";
import { type Notification } from "./notifications/notification.js";
export declare const Host: {
readonly production: "api.push.apple.com";
readonly development: "api.sandbox.push.apple.com";
};
export type Host = (typeof Host)[keyof typeof Host];
export interface SigningToken {
value: string;
timestamp: number;
}
export interface ApnsOptions {
team: string;
signingKey: string | Buffer | PrivateKey;
keyId: string;
defaultTopic?: string;
host?: Host | string;
requestTimeout?: number;
keepAlive?: boolean;
}
export declare class ApnsClient extends EventEmitter {
readonly team: string;
readonly keyId: string;
readonly host: Host | string;
readonly signingKey: string | Buffer | PrivateKey;
readonly defaultTopic?: string;
readonly keepAlive: boolean;
readonly client: Pool;
private _token;
private _pingInterval;
constructor(options: ApnsOptions);
sendMany(notifications: Notification[]): Promise<(Notification | {
error: ApnsError;
})[]>;
send(notification: Notification): Promise<Notification>;
ping(): Promise<PromiseSettledResult<void>[]>;
close(): Promise<void>;
destroy(err?: Error | null): Promise<void>;
private _handleServerResponse;
private _getSigningToken;
}