-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(auth): WIP - add tests for Apple IAP modules
* add AppleIAP module test
- Loading branch information
1 parent
bb52af3
commit e0a25f0
Showing
6 changed files
with
359 additions
and
5 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
packages/fxa-auth-server/lib/payments/iap/apple-app-store/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
export { AppleIAP } from './apple-iap'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
187 changes: 187 additions & 0 deletions
187
packages/fxa-auth-server/lib/payments/iap/apple-app-store/types/api-client.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,187 @@ | ||
/** | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 August Heegaard | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
|
||
// TODO: Below is copied over from app-store-server-api/dist/types/Models | ||
// as an module load error occurs if imported from that path e.g. in | ||
// subscription-purchase.ts and running a local test: | ||
// yarn test test/local/payments/iap/apple-iap.js. | ||
export declare enum Environment { | ||
Production = 'Production', | ||
Sandbox = 'Sandbox', | ||
} | ||
export interface HistoryResponse { | ||
appAppleId: string; | ||
bundleId: string; | ||
environment: Environment; | ||
hasMore: boolean; | ||
revision: string; | ||
signedTransactions: JWSTransaction[]; | ||
} | ||
export declare type JWSTransaction = string; | ||
export interface JWSDecodedHeader { | ||
alg: string; | ||
kid: string; | ||
x5c: string[]; | ||
} | ||
export interface JWSTransactionDecodedPayload { | ||
appAccountToken?: string; | ||
bundleId: string; | ||
expiresDate?: number; | ||
inAppOwnershipType: OwnershipType; | ||
isUpgraded?: boolean; | ||
offerIdentifier?: string; | ||
offerType?: OfferType; | ||
originalPurchaseDate: number; | ||
originalTransactionId: string; | ||
productId: string; | ||
purchaseDate: number; | ||
quantity: number; | ||
revocationDate?: number; | ||
revocationReason?: number; | ||
signedDate: number; | ||
subscriptionGroupIdentifier?: string; | ||
transactionId: string; | ||
type: TransactionType; | ||
webOrderLineItemId: string; | ||
} | ||
export declare enum OwnershipType { | ||
Purchased = 'PURCHASED', | ||
FamilyShared = 'FAMILY_SHARED', | ||
} | ||
export declare enum TransactionType { | ||
AutoRenewableSubscription = 'Auto-Renewable Subscription', | ||
NonConsumable = 'Non-Consumable', | ||
Consumable = 'Consumable', | ||
NonRenewingSubscription = 'Non-Renewing Subscription', | ||
} | ||
export interface StatusResponse { | ||
data: SubscriptionGroupIdentifierItem[]; | ||
environment: Environment; | ||
appAppleId: string; | ||
bundleId: string; | ||
} | ||
export interface SubscriptionGroupIdentifierItem { | ||
subscriptionGroupIdentifier: string; | ||
lastTransactions: LastTransactionsItem[]; | ||
} | ||
export interface LastTransactionsItem { | ||
originalTransactionId: string; | ||
status: SubscriptionStatus; | ||
signedRenewalInfo: JWSRenewalInfo; | ||
signedTransactionInfo: JWSTransaction; | ||
} | ||
export declare type JWSRenewalInfo = string; | ||
export declare enum SubscriptionStatus { | ||
Active = 1, | ||
Expired = 2, | ||
InBillingRetry = 3, | ||
InBillingGracePeriod = 4, | ||
Revoked = 5, | ||
} | ||
export interface JWSRenewalInfoDecodedPayload { | ||
autoRenewProductId: string; | ||
autoRenewStatus: AutoRenewStatus; | ||
expirationIntent?: ExpirationIntent; | ||
gracePeriodExpiresDate?: number; | ||
isInBillingRetryPeriod?: boolean; | ||
offerIdentifier?: string; | ||
offerType?: OfferType; | ||
originalTransactionId: string; | ||
priceIncreaseStatus?: PriceIncreaseStatus; | ||
productId: string; | ||
signedDate: number; | ||
} | ||
export declare enum AutoRenewStatus { | ||
Off = 0, | ||
On = 1, | ||
} | ||
export declare enum ExpirationIntent { | ||
Canceled = 1, | ||
BillingError = 2, | ||
RejectedPriceIncrease = 3, | ||
ProductUnavailable = 4, | ||
} | ||
export declare enum OfferType { | ||
Introductory = 1, | ||
Promotional = 2, | ||
SubscriptionOfferCode = 3, | ||
} | ||
export declare enum PriceIncreaseStatus { | ||
NoResponse = 0, | ||
Consented = 1, | ||
} | ||
export interface OrderLookupResponse { | ||
orderLookupStatus: OrderLookupStatus; | ||
signedTransactions: JWSTransaction[]; | ||
} | ||
export declare enum OrderLookupStatus { | ||
Valid = 0, | ||
Invalid = 1, | ||
} | ||
export interface DecodedNotificationPayload { | ||
notificationType: NotificationType; | ||
subtype?: NotificationSubtype; | ||
notificationUUID: string; | ||
version: string; | ||
data: NotificationData; | ||
} | ||
export interface NotificationData { | ||
appAppleId: string; | ||
bundleId: string; | ||
bundleVersion: number; | ||
environment: Environment; | ||
signedRenewalInfo: JWSRenewalInfo; | ||
signedTransactionInfo: JWSTransaction; | ||
} | ||
export declare enum NotificationType { | ||
ConsumptionRequest = 'CONSUMPTION_REQUEST', | ||
DidChangeRenewalPref = 'DID_CHANGE_RENEWAL_PREF', | ||
DidChangeRenewalStatus = 'DID_CHANGE_RENEWAL_STATUS', | ||
DidFailToRenew = 'DID_FAIL_TO_RENEW', | ||
DidRenew = 'DID_RENEW', | ||
Expired = 'EXPIRED', | ||
GracePeriodExpired = 'GRACE_PERIOD_EXPIRED', | ||
OfferRedeemed = 'OFFER_REDEEMED', | ||
PriceIncrease = 'PRICE_INCREASE', | ||
Refund = 'REFUND', | ||
RefundDeclined = 'REFUND_DECLINED', | ||
RenewalExtended = 'RENEWAL_EXTENDED', | ||
Revoke = 'REVOKE', | ||
Subscribed = 'SUBSCRIBED', | ||
} | ||
export declare enum NotificationSubtype { | ||
InitialBuy = 'INITIAL_BUY', | ||
Resubscribe = 'RESUBSCRIBE', | ||
Downgrade = 'DOWNGRADE', | ||
Upgrade = 'UPGRADE', | ||
AutoRenewEnabled = 'AUTO_RENEW_ENABLED', | ||
AutoRenewDisabled = 'AUTO_RENEW_DISABLED', | ||
Voluntary = 'VOLUNTARY', | ||
BillingRetry = 'BILLING_RETRY', | ||
PriceIncrease = 'PRICE_INCREASE', | ||
GracePeriod = 'GRACE_PERIOD', | ||
BillingRecovery = 'BILLING_RECOVERY', | ||
Pending = 'PENDING', | ||
Accepted = 'ACCEPTED', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.