From 5febec8d598d8484201774223139b2254b7d01cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Flora?= Date: Wed, 26 Nov 2025 10:48:48 +0000 Subject: [PATCH] Add support for signingKey as KeyObject --- index.ts | 5 +++-- tests/unit-tests/api_client.test.ts | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/index.ts b/index.ts index 4fd6594..95a1641 100644 --- a/index.ts +++ b/index.ts @@ -1,6 +1,7 @@ // Copyright (c) 2023 Apple Inc. Licensed under MIT License. import fetch from 'node-fetch'; +import type { KeyObject } from 'crypto'; import { CheckTestNotificationResponse, CheckTestNotificationResponseValidator } from './models/CheckTestNotificationResponse'; import { ConsumptionRequest } from './models/ConsumptionRequest'; import { UpdateAppAccountTokenRequest } from './models/UpdateAppAccountTokenRequest' @@ -114,7 +115,7 @@ export class AppStoreServerAPIClient { private issuerId: string private keyId: string - private signingKey: string + private signingKey: string | KeyObject private bundleId: string private urlBase: string @@ -126,7 +127,7 @@ export class AppStoreServerAPIClient { * @param bundleId Your app’s bundle ID * @param environment The environment to target */ - public constructor(signingKey: string, keyId: string, issuerId: string, bundleId: string, environment: Environment) { + public constructor(signingKey: string | KeyObject, keyId: string, issuerId: string, bundleId: string, environment: Environment) { this.issuerId = issuerId this.keyId = keyId this.bundleId = bundleId diff --git a/tests/unit-tests/api_client.test.ts b/tests/unit-tests/api_client.test.ts index 6199dc3..6357366 100644 --- a/tests/unit-tests/api_client.test.ts +++ b/tests/unit-tests/api_client.test.ts @@ -19,6 +19,7 @@ import { InAppOwnershipType } from "../../models/InAppOwnershipType"; import { RefundPreference } from "../../models/RefundPreference"; import { APIError, APIException, AppStoreServerAPIClient, ExtendReasonCode, ExtendRenewalDateRequest, GetTransactionHistoryVersion, MassExtendRenewalDateRequest, NotificationHistoryRequest, NotificationHistoryResponseItem, Order, OrderLookupStatus, ProductType, SendAttemptResult, TransactionHistoryRequest } from "../../index"; import { Response } from "node-fetch"; +import type { KeyObject } from "crypto"; import jsonwebtoken = require('jsonwebtoken'); @@ -30,7 +31,7 @@ class AppStoreServerAPIClientForTest extends AppStoreServerAPIClient { private body: string private statusCode: number - public constructor(signingKey: string, keyId: string, issuerId: string, bundleId: string, environment: Environment, callback: callbackType, body: string, statusCode: number) { + public constructor(signingKey: string | KeyObject, keyId: string, issuerId: string, bundleId: string, environment: Environment, callback: callbackType, body: string, statusCode: number) { super(signingKey, keyId, issuerId, bundleId, environment) this.callback = callback this.body = body @@ -872,4 +873,4 @@ describe('The api client ', () => { expect(error.errorMessage).toBe("Transaction id not found.") } }) -}) \ No newline at end of file +})