Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

capacitor-adapty

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

capacitor-adapty - npm Package Compare versions

Comparing version 3.0.3 to 4.0.1

dist/esm/promise-queue.d.ts

113

dist/esm/index.d.ts

@@ -1,24 +0,105 @@

import type * as Models from './sdk/cdk';
import type { ActivateOptions, AttributionNetwork, MakePurchaseResult } from './definitions';
export declare class Adapty {
import { PluginListenerHandle } from '@capacitor/core';
import * as Models from "./sdk/cdk.js";
import { AdaptySdk } from "./sdk/api";
interface AdaptyPlugin {
activate(options: ActivateOptions): Promise<void>;
updateAttribution(options: AttributionOptions): Promise<void>;
getPaywall(options: GetPaywallOptions): Promise<{
paywall: AdaptySdk["InOutput.AdaptyPaywall"];
}>;
getPaywallProducts(options: {
paywall: AdaptySdk["InOutput.AdaptyPaywall"];
}): Promise<{
products: AdaptySdk["Output.AdaptyPaywallProduct"][];
}>;
getProductsIntroductoryOfferEligibility(options: {
vendorProductIds: string[];
}): Promise<{
eligibilities: Record<string, Models.OfferEligibility>;
}>;
logShowOnboarding(options: ShowOnboardingOptions): Promise<void>;
logShowPaywall(options: {
paywall: AdaptySdk["InOutput.AdaptyPaywall"];
}): Promise<void>;
setFallbackPaywalls(options: {
paywalls: any;
}): Promise<void>;
getProfile(): Promise<{
profile: AdaptySdk["Output.AdaptyProfile"];
}>;
identify(options: {
customerUserId: string;
}): Promise<void>;
logout(): Promise<void>;
updateProfile(options: {
params: Partial<AdaptySdk["Input.AdaptyProfileParameters"]>;
}): Promise<void>;
makePurchase(options: {
product: AdaptySdk["Input.AdaptyPaywallProduct"];
}): Promise<{
purchase: AdaptySdk["Output.AdaptyPurchasedInfo"];
}>;
presentCodeRedemptionSheet(): Promise<void>;
restorePurchases(): Promise<{
profile: AdaptySdk["Output.AdaptyProfile"];
}>;
setLogLevel(options: {
logLevel: Models.LogLevel;
}): Promise<void>;
addListener(eventName: "onLatestProfileLoad", listenerFunc: (data: {
profile: AdaptySdk["Output.AdaptyProfile"];
}) => void): Promise<PluginListenerHandle> & PluginListenerHandle;
}
interface ActivateOptions {
apiKey: string;
customerUserId?: string;
logLevel?: Models.LogLevel;
libVersion: string;
observerMode?: boolean;
idfaCollectionDisabled?: boolean;
}
interface AttributionOptions {
attribution: Record<string, any>;
source: Models.AttributionNetwork | string;
networkUserId?: string;
}
interface ShowOnboardingOptions {
name?: string;
screenName?: string;
screenOrder: number;
}
interface GetPaywallOptions {
placementId: string;
locale: string;
fetchPolicy?: Models.PaywallFetchPolicy;
loadTimeout?: number;
}
declare class Adapty {
private adapty;
private resolveActivation;
private activatingPromise;
private awaitActivation;
private mutationalQueue;
activate(apiKey: string, options: Omit<ActivateOptions, 'apiKey' | 'libVersion'>): Promise<void>;
updateAttribution(source: AttributionNetwork | string, attribution: Record<string, any>, networkUserId?: string): Promise<void>;
getPaywall(id: string, locale: string): Promise<Models.AdaptyPaywall>;
getPaywallProducts(paywall: Models.AdaptyPaywall): Promise<Models.AdaptyProduct[]>;
updateAttribution(source: Models.AttributionNetwork | string, attribution: Record<string, any>, networkUserId?: string): Promise<void>;
getPaywall(placementId: string, locale: string, options?: Partial<Omit<GetPaywallOptions, 'placementId' | 'locale'>>): Promise<Models.AdaptyPaywall>;
getPaywallProducts(paywall: Models.AdaptyPaywall): Promise<Models.AdaptyPaywallProduct[]>;
getProductsIntroductoryOfferEligibility(vendorProductIds: string[]): Promise<Record<string, Models.OfferEligibility>>;
logShowOnboarding(screenOrder: number, screenName?: string, name?: string): Promise<void>;
logShowPaywall(paywall: Models.AdaptyPaywall): Promise<void>;
setFallbackPaywalls(paywalls: any): Promise<void>;
getProfile: () => Promise<Models.AdaptyProfile>;
getProfile(): Promise<Models.AdaptyProfile>;
identify(customerUserId: string): Promise<void>;
logout: () => Promise<void>;
logout(): Promise<void>;
updateProfile(params: Partial<Models.AdaptyProfileParameters>): Promise<void>;
makePurchase(product: Models.AdaptyProduct): Promise<MakePurchaseResult>;
presentCodeRedemptionSheet: () => Promise<void>;
restorePurchases: () => Promise<Models.AdaptyProfile>;
setLogLevel(logLevel: string): Promise<void>;
addListener: (eventName: "onLatestProfileLoad", listenerFunc: (profile: Models.AdaptyProfile) => void) => Promise<import("@capacitor/core").PluginListenerHandle> & import("@capacitor/core").PluginListenerHandle;
makePurchase(product: Models.AdaptyPaywallProduct): Promise<Models.AdaptyPurchasedInfo>;
presentCodeRedemptionSheet(): Promise<void>;
restorePurchases(): Promise<Models.AdaptyProfile>;
setLogLevel(logLevel: Models.LogLevel): Promise<void>;
addListener(eventName: 'onLatestProfileLoad', listenerFunc: (data: {
profile: Models.AdaptyProfile;
}) => void): PluginListenerHandle & Promise<PluginListenerHandle>;
}
export * from './definitions';
export * from './sdk/cdk';
export * from './sdk/errors';
export { Adapty, AdaptyPlugin, ActivateOptions, AttributionOptions, ShowOnboardingOptions, GetPaywallOptions };
export * from "./sdk/cdk.js";
export * from "./sdk/errors.js";

138

dist/esm/index.js
import { registerPlugin } from '@capacitor/core';
import { VERSION } from './version';
const libVersion = VERSION;
import { decodePaywall, encodePaywall } from './sdk/coders/paywall.js';
import { decodeProduct, encodeProduct } from './sdk/coders/product.js';
import { decodeProfile } from './sdk/coders/profile.js';
import { encodeProfileParameters } from './sdk/coders/profile-parameters.js';
import { decodeSKTransaction } from './sdk/coders/sk-transaction.js';
import { PromiseQueue } from './promise-queue.js';
export { AppTrackingTransparencyStatus, AttributionNetwork, CancellationReason, Gender, LogLevel, OfferEligibility, OfferType, PaywallFetchPolicy, ProductPeriod, SKPaymentTransactionState, VendorStore } from './sdk/cdk.js';
export { AdaptyErrors, isAdaptyError } from './sdk/errors.js';
const CapacitorAdapty = registerPlugin('Adapty', {});
export class Adapty {
const LIB_VERSION = "4.0.1";
class Adapty {
constructor() {
this.adapty = CapacitorAdapty;
this.getProfile = this.adapty.getProfile;
this.logout = this.adapty.logout;
this.presentCodeRedemptionSheet = this.adapty.presentCodeRedemptionSheet;
this.restorePurchases = this.adapty.restorePurchases;
this.addListener = this.adapty.addListener;
this.resolveActivation = null;
this.activatingPromise = new Promise(resolve => (this.resolveActivation = resolve));
// https://github.com/adaptyteam/AdaptySDK-React-Native/issues/66#issuecomment-1521638581
this.mutationalQueue = new PromiseQueue();
}
activate(apiKey, options) {
return this.adapty.activate(Object.assign({ apiKey,
libVersion }, options));
async awaitActivation() {
if (this.activatingPromise) {
await this.activatingPromise;
this.activatingPromise = null;
}
}
updateAttribution(source, attribution, networkUserId) {
async activate(apiKey, options) {
const promise = this.adapty.activate(Object.assign({ apiKey, libVersion: LIB_VERSION }, options));
if (!this.activatingPromise) {
this.activatingPromise = promise;
}
const result = await promise;
if (this.resolveActivation) {
this.resolveActivation();
this.resolveActivation = null;
}
return result;
}
async updateAttribution(source, attribution, networkUserId) {
await this.awaitActivation();
return this.adapty.updateAttribution({

@@ -25,35 +47,87 @@ source,

}
getPaywall(id, locale) {
return this.adapty.getPaywall({ id, locale });
async getPaywall(placementId, locale, options) {
await this.awaitActivation();
return this.adapty
.getPaywall(Object.assign({ placementId, locale }, options))
.then(res => decodePaywall(res.paywall));
}
getPaywallProducts(paywall) {
async getPaywallProducts(paywall) {
await this.awaitActivation();
return this.adapty
.getPaywallProducts({ paywall })
.then(res => res.products);
.getPaywallProducts({ paywall: encodePaywall(paywall) })
.then(res => res.products.map(decodeProduct));
}
logShowOnboarding(screenOrder, screenName, name) {
async getProductsIntroductoryOfferEligibility(vendorProductIds) {
await this.awaitActivation();
return this.adapty
.getProductsIntroductoryOfferEligibility({
vendorProductIds,
})
.then(res => res.eligibilities);
}
async logShowOnboarding(screenOrder, screenName, name) {
await this.awaitActivation();
return this.adapty.logShowOnboarding({ screenOrder, screenName, name });
}
logShowPaywall(paywall) {
return this.adapty.logShowPaywall({ paywall });
async logShowPaywall(paywall) {
await this.awaitActivation();
return this.adapty.logShowPaywall({ paywall: encodePaywall(paywall) });
}
setFallbackPaywalls(paywalls) {
async setFallbackPaywalls(paywalls) {
await this.awaitActivation();
return this.adapty.setFallbackPaywalls({ paywalls });
}
identify(customerUserId) {
return this.adapty.identify({ customerUserId });
async getProfile() {
await this.awaitActivation();
return this.adapty.getProfile().then(res => decodeProfile(res.profile));
}
updateProfile(params) {
return this.adapty.updateProfile({ params });
async identify(customerUserId) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.identify({ customerUserId }));
}
makePurchase(product) {
return this.adapty.makePurchase({ product });
async logout() {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.logout());
}
setLogLevel(logLevel) {
async updateProfile(params) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.updateProfile({
params: encodeProfileParameters(params),
}));
}
async makePurchase(product) {
await this.awaitActivation();
return this.adapty
.makePurchase({ product: encodeProduct(product) })
.then(res => ({
profile: decodeProfile(res.purchase.profile),
transaction: res.purchase.transaction
? decodeSKTransaction(res.purchase.transaction)
: undefined,
}));
}
async presentCodeRedemptionSheet() {
await this.awaitActivation();
return this.adapty.presentCodeRedemptionSheet();
}
async restorePurchases() {
await this.awaitActivation();
return this.adapty
.restorePurchases()
.then(res => decodeProfile(res.profile));
}
async setLogLevel(logLevel) {
await this.awaitActivation();
return this.adapty.setLogLevel({ logLevel });
}
addListener(eventName, listenerFunc) {
{
switch (eventName) {
case 'onLatestProfileLoad':
return this.adapty.addListener(eventName, data => listenerFunc({ profile: decodeProfile(data.profile) }));
}
}
}
}
export * from './definitions';
export * from './sdk/cdk';
export * from './sdk/errors';
//# sourceMappingURL=index.js.map
export { Adapty };

@@ -1,42 +0,105 @@

export declare enum VendorStore {
AppStore = "app_store",
PlayStore = "play_store",
Adapty = "adapty"
declare const VendorStore: Readonly<{
AppStore: "app_store";
PlayStore: "play_store";
Adapty: "adapty";
}>;
type VendorStore = typeof VendorStore[keyof typeof VendorStore];
declare const OfferType: Readonly<{
FreeTrial: "free_trial";
PayAsYouGo: "pay_as_you_go";
PayUpFront: "pay_up_front";
Unknown: "unknown";
}>;
type OfferType = typeof OfferType[keyof typeof OfferType];
declare const CancellationReason: Readonly<{
VolountarilyCancelled: "voluntarily_cancelled";
BillingError: "billing_error";
Refund: "refund";
PriceIncrease: "price_increase";
ProductWasNotAvailable: "product_was_not_available";
Unknown: "unknown";
}>;
type CancellationReason = typeof CancellationReason[keyof typeof CancellationReason];
declare const Gender: Readonly<{
Female: "f";
Male: "m";
Other: "o";
}>;
type Gender = typeof Gender[keyof typeof Gender];
declare const AppTrackingTransparencyStatus: Readonly<{
NotDetermined: 0;
Restricted: 1;
Denied: 2;
Authorized: 3;
Unknown: 4;
}>;
type AppTrackingTransparencyStatus = typeof AppTrackingTransparencyStatus[keyof typeof AppTrackingTransparencyStatus];
declare const ProductPeriod: Readonly<{
Day: "day";
Week: "week";
Month: "month";
Year: "year";
Unknown: "unknown";
}>;
type ProductPeriod = typeof ProductPeriod[keyof typeof ProductPeriod];
declare const OfferEligibility: Readonly<{
Eligible: "eligible";
Ineligible: "ineligible";
NotApplicable: "not_applicable";
}>;
type OfferEligibility = typeof OfferEligibility[keyof typeof OfferEligibility];
declare const LogLevel: Readonly<{
error: "error";
warn: "warn";
info: "info";
verbose: "verbose";
debug: "debug";
}>;
type LogLevel = typeof LogLevel[keyof typeof LogLevel];
declare const PaywallFetchPolicy: Readonly<{
returnCacheDataElseLoad: "return_cache_data_else_load";
reloadRevalidatingCacheData: "reload_revalidating_cache_data";
default: "default";
}>;
type PaywallFetchPolicy = typeof PaywallFetchPolicy[keyof typeof PaywallFetchPolicy];
declare const AttributionNetwork: Readonly<{
appsflyer: "appsflyer";
adjust: "adjust";
branch: "branch";
custom: "custom";
appleSearchAds: "apple_search_ads";
}>;
type AttributionNetwork = typeof AttributionNetwork[keyof typeof AttributionNetwork];
declare const SKPaymentTransactionState: Readonly<{
purchasing: 0;
purchased: 1;
failed: 2;
restored: 3;
deferred: 4;
}>;
type SKPaymentTransactionState = typeof SKPaymentTransactionState[keyof typeof SKPaymentTransactionState];
interface AdaptyPrice {
/**
* Price as number
*/
amount: number;
/**
* The currency code of the locale
* used to format the price of the product.
* The ISO 4217 (USD, EUR).
*/
currencyCode?: string;
/**
* The currency symbol of the locale
* used to format the price of the product.
* ($, €).
*/
currencySymbol?: string;
/**
* A price’s language is determined
* by the preferred language set on the device.
* On Android, the formatted price from Google Play as is.
*/
localizedString?: string;
}
export declare enum OfferType {
FreeTrial = "free_trial",
PayAsYouGo = "pay_as_you_go",
PayUpFront = "pay_up_front"
}
export declare enum CancellationReason {
VolountarilyCancelled = "voluntarily_cancelled",
BillingError = "billing_error",
Refund = "refund",
PriceIncrease = "price_increase",
ProductWasNotAvailable = "product_was_not_available",
Unknown = "unknown"
}
export declare enum Gender {
Female = "f",
Male = "m",
Other = "o"
}
export declare enum AppTrackingTransparencyStatus {
NotDetermined = "not_determined",
Restricted = "restricted",
Denied = "denied",
Authorized = "authorized",
Unknown = "unknown"
}
export declare enum ProductPeriod {
Day = "day",
Week = "week",
Month = "month",
Year = "year"
}
export declare enum OfferEligibility {
Eligible = "eligible",
Ineligible = "ineligible",
Unknown = "unknown"
}
/**

@@ -47,3 +110,3 @@ * Describes an object that represents a paywall.

*/
export interface AdaptyPaywall {
interface AdaptyPaywall {
/**

@@ -53,8 +116,8 @@ * Parent A/B test name.

*/
readonly ab_test_name: string;
abTestName: string;
/**
* ID of a paywall configured in Adapty Dashboard.
* ID of a placement configured in Adapty Dashboard.
* @readonly
*/
readonly id: string;
placementId: string;
/**

@@ -64,13 +127,13 @@ * Identifier of a paywall locale.

*/
readonly locale: string;
locale: string;
/**
* A paywall name.
* @readonly
* If `true`, it is possible to fetch the view object
* and use it with AdaptyUI library.
*/
readonly name?: string;
hasViewConfiguration: boolean;
/**
* A custom dictionary configured in Adapty Dashboard for this paywall.
* A paywall name.
* @readonly
*/
readonly remote_config?: Record<string, any>;
name: string;
/**

@@ -80,3 +143,3 @@ * A custom JSON string configured in Adapty Dashboard for this paywall.

*/
readonly remote_config_string?: string;
remoteConfig?: string;
/**

@@ -87,3 +150,3 @@ * Current revision (version) of a paywall.

*/
readonly revision: number;
revision: number;
/**

@@ -94,98 +157,95 @@ * An identifier of a variation,

*/
readonly variation_id: string;
variationId: string;
/**
* Array of related products ids.
* Array of initial products info
* @readonly
*/
readonly products: AdaptyPaywallProduct[];
products: ProductReference[];
instanceIdentity: string;
version: number;
}
/**
* Describes an object that represents a user profile,
* including subscriptions and consumables.
* Interface representing a user profile in Adapty,
* including details about the user's subscriptions and consumable products.
* @public
*/
export interface AdaptyProfile {
interface AdaptyProfile {
/**
* The keys are access level identifiers configured by you in Adapty Dashboard.
* The values can be `null` if the customer has no access levels.
* Object that maps access level identifiers (configured by you in Adapty Dashboard)
* to the corresponding access level details. The value can be `null`
* if the user does not have any access levels.
* @readonly
*/
readonly paid_access_levels?: Record<string, AdaptyAccessLevel>;
accessLevels?: Record<string, AdaptyAccessLevel>;
segmentHash: string;
/**
* Previously set user custom attributes with {@link Adapty.updateProfile} method.
* Object representing custom attributes set for the user using
* the {@link Adapty.updateProfile} method.
* @readonly
*/
readonly custom_attributes: Record<string, any>;
customAttributes?: Record<string, any>;
/**
* An identifier of a user in your system.
* The identifier for a user in your system.
* @readonly
*/
readonly customer_user_id?: string;
customerUserId?: string;
/**
* The keys are product ids from the store.
* The values are arrays of information about consumables.
* Can be `null` if the customer has no purchases.
* Object that maps product ids from the store to an array of
* information about the user's non-subscription purchases.
* The value can be `null` if the user does not have any purchases.
* @readonly
*/
readonly non_subscriptions?: Record<string, AdaptyNonSubscription[]>;
nonSubscriptions?: Record<string, AdaptyNonSubscription[]>;
/**
* An identifier of a user in Adapty.
* The identifier for a user in Adapty.
*/
readonly profile_id: string;
profileId: string;
/**
* The keys are product ids from a store.
* The values are information about subscriptions.
* Can be `null` if the customer has no subscriptions.
* Object that maps product ids from a store to
* information about the user's subscriptions.
* The value can be `null` if the user does not have any subscriptions.
* @readonly
*/
readonly subscriptions?: Record<string, AdaptySubscription>;
subscriptions?: Record<string, AdaptySubscription>;
}
/**
* Current user's access level information.
* Interface representing access level details of a user.
* @public
*/
export interface AdaptyAccessLevel {
interface AdaptyAccessLevel {
/**
* Time when this access level was activated.
* The date and time when the access level was activated.
* @readonly
*/
readonly activated_at: Date;
activatedAt: Date;
/**
* A type of an active introductory offer.
* If the value is not `null`,
* it means that the offer was applied during the current subscription period.
* Type of active introductory offer, if any.
* @readonly
*/
readonly active_introductory_offer_type?: OfferType;
activeIntroductoryOfferType?: OfferType;
/**
* An id of active promotional offer.
* Identifier of the active promotional offer, if any.
* @readonly
*/
readonly active_promotional_offer_id?: string;
activePromotionalOfferId?: string;
/**
* A type of an active promotional offer.
* If the value is not `null`,
* it means that the offer was applied
* during the current subscription period.
* Type of the active promotional offer, if any.
* @readonly
*/
readonly active_promotional_offer_type?: OfferType;
activePromotionalOfferType?: OfferType;
/**
* Time when billing issue was detected.
* Subscription can still be active.
* Would be set to `null` if a charge is made.
* The date and time when a billing issue was detected.
* @readonly
*/
readonly billing_issue_detected_at?: Date;
billingIssueDetectedAt?: Date;
/**
* A reason why a subscription was cancelled.
* The reason for the cancellation of the subscription.
* @readonly
*/
readonly cancellation_reason?: CancellationReason;
cancellationReason?: CancellationReason;
/**
* Time when the access level will expire.
* Could be in the past and could be `null` for lifetime access.
* The expiration date of the access level, if applicable.
* @readonly
*/
readonly expires_at?: Date;
expiresAt?: Date;
/**

@@ -196,238 +256,211 @@ * Unique identifier of the access level

*/
readonly id: string;
id: string;
/**
* `true` if this access level is active.
* Generally, you can check this property to determine
* whether a user has an access to premium features.
* Flag indicating whether the access level is currently active.
* @readonly
*/
readonly is_active: boolean;
isActive: boolean;
/**
* `true` if this auto-renewable subscription is in the grace period.
* Flag indicating whether this auto-renewable subscription is in the grace period.
* @readonly
*/
readonly is_in_grace_period: boolean;
isInGracePeriod: boolean;
/**
* `true` if this access level is active for a lifetime (no expiration date).
* Flag indicating whether this access level is active for a lifetime.
* @readonly
*/
readonly is_lifetime: boolean;
isLifetime: boolean;
/**
* `true` if this purchase was refunded
* Flag indicating whether this purchase was refunded.
* @readonly
*/
readonly is_refund: boolean;
isRefund: boolean;
/**
* Time when the access level was renewed.
* It can be null if the purchase was first in chain
* or it is non-renewing subscription / non-consumable (e.g. lifetime)
* The date and time when the access level was renewed.
* @readonly
*/
readonly renewed_at?: Date;
renewedAt?: Date;
/**
* Time when this access level has started.
* Could be in the future.
* The start date of this access level.
* @readonly
*/
readonly starts_at?: Date;
startsAt?: Date;
/**
* A store of the purchase that unlocked this access level.
* The store where the purchase that unlocked this access level was made.
* @readonly
*/
readonly store: VendorStore;
store: VendorStore;
/**
* Time when the auto-renewable subscription was cancelled.
* Subscription can still be active,
* it just means that auto-renewal turned off.
* Will be set to `null` if the user reactivates the subscription.
* The date and time when the auto-renewable subscription was cancelled.
* @readonly
*/
readonly unsubscribed_at?: Date;
unsubscribedAt?: Date;
/**
* An identifier of a product in a store that unlocked this access level.
* The identifier of the product in the store that unlocked this access level.
* @readonly
*/
readonly vendor_product_id: string;
vendorProductId: string;
/**
* `true` if this auto-renewable subscription is set to renew.
* Flag indicating whether this auto-renewable subscription is set to renew.
* @readonly
*/
readonly will_renew: boolean;
willRenew: boolean;
android?: {
offerId?: string;
};
}
/**
* Current user's consumable/non-subscription purchase.
* Interface representing a consumable or non-subscription purchase made by the user.
* @public
*/
export interface AdaptyNonSubscription {
interface AdaptyNonSubscription {
/**
* `true` if the product is consumable.
* Flag indicating whether the product is consumable.
* @readonly
*/
readonly is_consumable: boolean;
isConsumable: boolean;
/**
* true if the purchase was refunded.
* Flag indicating whether the purchase was refunded.
* @readonly
*/
readonly is_refund: boolean;
isRefund: boolean;
/**
* `true` if the product was purchased in sandbox environment
* Flag indicating whether the product was purchased in a sandbox environment.
* @readonly
*/
readonly is_sandbox: boolean;
isSandbox: boolean;
/**
* An identifier of the purchase in Adapty.
* You can use it to ensure that you’ve already processed this purchase
* (for example tracking one time products).
* The date and time when the purchase was made.
* @readonly
*/
readonly purchase_id: string;
purchasedAt: Date;
/**
* Date when the product was purchased.
* The identifier of the product in the store that was purchased.
* @readonly
*/
readonly purchased_at: Date;
vendorProductId: string;
/**
* A store of the purchase
* The identifier of the product in the store that was purchased.
* @readonly
*/
readonly store: VendorStore;
vendorTransactionId?: string;
/**
* An identifier of a product in a store
* that unlocked this subscription.
* The store where the purchase was made.
* @readonly
*/
readonly vendor_product_id: String;
store: VendorStore;
/**
* A transaction id of a purchase in a store
* that unlocked this subscription.
* An identifier of the purchase in Adapty.
* You can use it to ensure that you've already processed this purchase
* (for example tracking one time products).
* @readonly
*/
readonly vendor_transaction_id?: string;
purchaseId: string;
}
/**
* Current user's subscription purchase.
* Interface representing details about a user's subscription.
* @public
*/
export interface AdaptySubscription {
interface AdaptySubscription {
/**
* Time when the subscription was activated.
* The date and time when the subscription was activated.
* @readonly
*/
readonly activated_at: Date;
activatedAt: Date;
/**
* A type of an active introductory offer.
* If the value is not `null`,
* it means that the offer was applied during the current subscription period.
* Type of active introductory offer, if any.
* @readonly
*/
readonly active_introductory_offer_type?: OfferType;
activeIntroductoryOfferType?: OfferType;
/**
* An id of active promotional offer.
* Identifier of the active promotional offer, if any.
* @readonly
*/
readonly active_promotional_offer_id?: string;
activePromotionalOfferId?: string;
/**
* A type of an active promotional offer.
* If the value is not `null`,
* it means that the offer was applied during the current subscription period.
* Type of the active promotional offer, if any.
* @readonly
*/
readonly active_promotional_offer_type?: OfferType;
activePromotionalOfferType?: OfferType;
/**
* Time when a billing issue was detected. Subscription can still be active.
* The date and time when a billing issue was detected.
* @readonly
*/
readonly billing_issue_detected_at?: Date;
billingIssueDetectedAt?: Date;
/**
* A reason why a subscription was cancelled.
* The reason for the cancellation of the subscription.
* @readonly
*/
readonly cancellation_reason?: CancellationReason;
cancellationReason?: CancellationReason;
/**
* Time when the access level will expire.
* Could be in the past and could be `null` for lifetime access.
* The expiration date of the subscription, if applicable.
* @readonly
*/
readonly expires_at?: Date;
expiresAt?: Date;
/**
* `true` if this subscription is active
* Flag indicating whether the subscription is currently active.
* @readonly
*/
readonly is_active: boolean;
isActive: boolean;
/**
* `true` if auto renewable subscription is in grace period
* Flag indicating whether the subscription is in the grace period.
* @readonly
*/
readonly is_in_grace_period: boolean;
isInGracePeriod: boolean;
/**
* `true` if the subscription is active for lifetime
* (no expiration date).
* Flag indicating whether the subscription is set for a lifetime.
* @readonly
*/
readonly is_lifetime: boolean;
isLifetime: boolean;
/**
* `true` if the purchase was refunded
* Flag indicating whether the subscription was refunded.
* @readonly
*/
readonly is_refund: boolean;
isRefund: boolean;
/**
* `true` if the product was purchased in sandbox enviroment
* Flag indicating whether the subscription was purchased in a sandbox environment.
* @readonly
*/
readonly is_sandbox: boolean;
isSandbox: boolean;
/**
* Time when the subscription was renewed.
* It can be `null` if the purchase was first in chain
* or it is non-renewing subscription.
* The date and time when the subscription was renewed.
* @readonly
*/
readonly renewed_at?: Date;
renewedAt?: Date;
/**
* Time when the subscription has started.
* Could be in the future.
* The date and time when the subscription starts.
* @readonly
*/
readonly starts_at?: Date;
startsAt?: Date;
/**
* A store of the purchase.
* The store where the subscription was made.
* @readonly
*/
readonly store: VendorStore;
store: VendorStore;
/**
* Time when the auto-renewable subscription was cancelled.
* Subscription can still be active,
* it means that auto-renewal is turned off.
* Would be `null` if a user reactivates the subscription.
*/
readonly unsubscribed_at?: Date;
/**
* An original transaction id of the purchase
* in a store that unlocked this subscription.
* For auto-renewable subscription,
* this will be an id of the first transaction
* in this subscription.
* The date and time when the subscription was cancelled.
* @readonly
*/
readonly vendor_original_transaction_id: string;
unsubscribedAt?: Date;
/**
* An identifier of a product in a store that unlocked this subscription.
* The identifier of the product in the store that was subscribed to.
* @readonly
*/
readonly vendor_product_id: string;
vendorProductId: string;
/**
* A transaction id of a purchase in a store that unlocked this subscription.
* The identifier of the product in the store that was subscribed to.
* @readonly
*/
readonly vendor_transaction_id: string;
vendorTransactionId: string;
/**
* `true` if the auto-renewable subscription is set to renew
* An original transaction id of the purchase in a store that unlocked this subscription.
* For auto-renewable subscription, this will be an id of the first transaction in this subscription.
* @readonly
*/
readonly will_renew: boolean;
}
export interface AdaptyPaywallProduct {
vendorOriginalTransactionId: string;
/**
* Unique identifier of a product
* from App Store Connect or Google Play Console
* Flag indicating whether the subscription is set to auto-renew.
* @readonly
*/
vendor_product_id: string;
willRenew: boolean;
}

@@ -439,99 +472,65 @@ /**

*/
export interface AdaptyProduct {
interface AdaptyPaywallProduct {
/**
* The currency code of the locale
* used to format the price of the product.
* The ISO 4217 (USD, EUR).
* @readonly
*/
readonly currency_code?: string;
/**
* The currency symbol of the locale
* used to format the price of the product.
* ($, €).
* @readonly
*/
readonly currency_symbol?: string;
/**
* An object containing introductory price information for a product.
* iOS: Will be null for iOS version below 11.2
* and macOS version below 10.14.4.
*/
readonly introductory_discount?: AdaptyProductDiscount;
/**
* User's eligibility for your introductory offer.
* Check this property before displaying info about
* introductory offers (i.e. free trials)
* @readonly
*/
readonly introductory_offer_eligibility: OfferEligibility;
/**
* A description of the product.
* @readonly
*/
readonly localized_description: string;
localizedDescription: string;
/**
* A price’s language is determined
* by the preferred language set on the device.
* On Android, the formatted price from Google Play as is.
* @readonly
* The region code of the locale used to format the price of the product.
* ISO 3166 ALPHA-2 (US, DE)
*/
readonly localized_price?: string;
regionCode?: string;
/**
* The period’s language is determined
* by the preferred language set on the device.
* @readonly
*/
readonly localized_subscription_period?: string;
/**
* The name of the product.
* @readonly
*/
readonly localized_title: string;
localizedTitle: string;
/**
* Same as `abTestName` property of the parent {@link AdaptyPaywall}.
* @readonly
*/
readonly paywall_ab_test_name: string;
paywallAbTestName: string;
/**
* Same as `name` property of the parent {@link AdaptyPaywall}.
* @readonly
*/
readonly paywall_name: string;
paywallName: string;
/**
* The cost of the product in the local currency
* @readonly
*/
readonly price: number;
price?: AdaptyPrice;
/**
* The period details for products that are subscriptions.
* Will be `null` for iOS version below 11.2 and macOS version below 10.14.4.
* @readonly
* A description of the product.
*/
readonly subscription_period?: AdaptySubscriptionPeriod;
adaptyProductId: string;
/**
* Same as `variationId` property of the parent {@link AdaptyPaywall}.
* @readonly
*/
readonly variation_id: string;
paywallVariationId: string;
/**
* Unique identifier of a product
* from App Store Connect or Google Play Console
* @readonly
*/
readonly vendor_product_id: string;
vendorProductId: string;
payloadData?: string;
subscriptionDetails?: AdaptySubscriptionDetails;
ios?: {
/**
* Boolean value that indicates
* whether the product is available for family sharing
* in App Store Connect.
* Will be `false` for iOS version below 14.0 and macOS version below 11.0.
* @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}
*/
isFamilyShareable: boolean;
};
}
interface AdaptySubscriptionDetails {
/**
* An object containing free trial information for the given product.
* android only
* @see {@link https://developer.android.com/google/play/billing/subscriptions#free-trial}
* @readonly
* The period details for products that are subscriptions.
* Will be `null` for iOS version below 11.2 and macOS version below 10.14.4.
*/
readonly free_trial_period?: AdaptySubscriptionPeriod;
subscriptionPeriod: AdaptySubscriptionPeriod;
/**
* The period’s language is determined
* by the preferred language set on the device.
* android only
* @readonly
*/
readonly localized_free_trial_period?: string;
localizedSubscriptionPeriod?: string;
/**

@@ -541,46 +540,28 @@ * An array of subscription offers available for the auto-renewable subscription.

* and macOS version below 10.14.4.
* iOS only
* @readonly
*/
readonly discounts: AdaptyProductDiscount[];
/**
* Boolean value that indicates
* whether the product is available for family sharing
* in App Store Connect.
* Will be `false` for iOS version below 14.0 and macOS version below 11.0.
* iOS only
* @see {@link https://developer.apple.com/documentation/storekit/skproduct/3564805-isfamilyshareable}
* @readonly
*/
readonly is_family_shareable: boolean;
/**
* User's eligibility for the promotional offers.
* Check this property before displaying info
* about promotional offers
* iOS only
* @readonly
*/
readonly promotional_offer_eligibility: OfferEligibility;
/**
* An identifier of a promotional offer,
* provided by Adapty for this specific user.
* iOS only
* @readonly
*/
readonly promotional_offer_id?: string;
/**
* The region code of the locale used to format the price of the product.
* ISO 3166 ALPHA-2 (US, DE)
* iOS only
* @readonly
*/
readonly region_code?: string;
/**
* An identifier of the subscription group
* to which the subscription belongs.
* Will be `null` for iOS version below 12.0 and macOS version below 10.14.
* iOS only
* @readonly
*/
readonly subscription_group_identifier?: string;
introductoryOffers?: AdaptyDiscountPhase[];
ios?: {
promotionalOffer?: AdaptyDiscountPhase;
/**
* An identifier of the subscription group
* to which the subscription belongs.
* Will be `null` for iOS version below 12.0 and macOS version below 10.14.
*/
subscriptionGroupIdentifier?: string;
};
android?: {
/**
* An object containing free trial information for the given product.
* @see {@link https://developer.android.com/google/play/billing/subscriptions#free-trial}
*/
/**
* The period’s language is determined
* by the preferred language set on the device.
*/
offerId?: string;
basePlanId: string;
introductoryOfferEligibility: OfferEligibility;
offerTags?: string[];
renewalType?: 'prepaid' | 'autorenewable';
};
}

@@ -591,3 +572,3 @@ /**

*/
export interface AdaptyProductDiscount {
interface AdaptyDiscountPhase {
/**

@@ -597,13 +578,8 @@ * A formatted number of periods of a discount for a user’s locale.

*/
readonly localized_number_of_periods?: string;
localizedNumberOfPeriods?: string;
/**
* A formatted price of a discount for a user’s locale.
* @readonly
*/
readonly localized_price?: string;
/**
* A formatted subscription period of a discount for a user’s locale.
* @readonly
*/
readonly localized_subscription_period?: string;
localizedSubscriptionPeriod?: string;
/**

@@ -613,3 +589,3 @@ * A number of periods this product discount is available.

*/
readonly number_of_periods: number;
numberOfPeriods: number;
/**

@@ -619,3 +595,3 @@ * Discount price of a product in a local currency.

*/
readonly price: number;
price: AdaptyPrice;
/**

@@ -625,3 +601,8 @@ * An information about period for a product discount.

*/
readonly subscription_period: AdaptySubscriptionPeriod;
subscriptionPeriod: AdaptySubscriptionPeriod;
/**
* A payment mode for this product discount.
* @readonly
*/
paymentMode: OfferType;
ios?: {

@@ -633,8 +614,3 @@ /**

*/
readonly identifier?: string;
/**
* A payment mode for this product discount.
* @readonly
*/
readonly payment_mode: OfferType;
identifier?: string;
};

@@ -646,3 +622,3 @@ }

*/
export interface AdaptySubscriptionPeriod {
interface AdaptySubscriptionPeriod {
/**

@@ -652,3 +628,3 @@ * A number of period units.

*/
readonly number_of_units: number;
numberOfUnits: number;
/**

@@ -658,36 +634,36 @@ * A unit of time that a subscription period is specified in.

*/
readonly unit: ProductPeriod;
unit: ProductPeriod;
}
export interface AdaptyProfileParameters {
analytics_disabled?: boolean;
codable_custom_attributes?: {
interface AdaptyProfileParameters {
analyticsDisabled?: boolean;
customAttributes?: {
[key: string]: any;
};
app_tracking_transparency_status?: AppTrackingTransparencyStatus;
store_country?: string;
first_name?: string;
last_name?: string;
appTrackingTransparencyStatus?: AppTrackingTransparencyStatus;
firstName?: string;
lastName?: string;
gender?: Gender;
birthday?: string;
birthday?: Date;
email?: string;
phone_number?: string;
facebook_anonymous_id?: string;
amplitude_user_id?: string;
amplitude_device_id?: string;
mixpanel_user_id?: string;
appmetrica_profile_id?: string;
appmetrica_device_id?: string;
one_signal_player_id?: string;
pushwoosh_hwid?: string;
firebase_app_instance_id?: string;
airbridge_device_id?: string;
phoneNumber?: string;
facebookAnonymousId?: string;
amplitudeUserId?: string;
amplitudeDeviceId?: string;
mixpanelUserId?: string;
appmetricaProfileId?: string;
appmetricaDeviceId?: string;
oneSignalPlayerId?: string;
oneSignalSubscriptionId?: string;
pushwooshHWID?: string;
firebaseAppInstanceId?: string;
airbridgeDeviceId?: string;
}
export declare enum SKPaymentTransactionState {
purchasing = 0,
purchased = 1,
failed = 2,
restored = 3,
deferred = 4
interface ProductReference {
vendorId: string;
adaptyProductId: string;
ios?: {
promotionalOfferId?: string;
};
}
export interface SKPayment {
interface SKPayment {
productIdentifier: string;

@@ -699,5 +675,5 @@ quantity: number;

}
export interface SKTransaction {
interface SKPaymentTransaction {
errorDescription: string;
original?: Omit<SKTransaction, 'original'>;
original?: Omit<SKPaymentTransaction, 'original'>;
payment: SKPayment;

@@ -708,1 +684,6 @@ transactionDate: string;

}
interface AdaptyPurchasedInfo {
profile: AdaptyProfile;
transaction?: SKPaymentTransaction;
}
export { VendorStore, OfferType, CancellationReason, Gender, AppTrackingTransparencyStatus, ProductPeriod, OfferEligibility, LogLevel, PaywallFetchPolicy, AttributionNetwork, SKPaymentTransactionState, AdaptyPrice, AdaptyPaywall, AdaptyProfile, AdaptyAccessLevel, AdaptyNonSubscription, AdaptySubscription, AdaptyPaywallProduct, AdaptySubscriptionDetails, AdaptyDiscountPhase, AdaptySubscriptionPeriod, AdaptyProfileParameters, ProductReference, SKPayment, SKPaymentTransaction, AdaptyPurchasedInfo };

@@ -1,57 +0,71 @@

export var VendorStore;
(function (VendorStore) {
VendorStore["AppStore"] = "app_store";
VendorStore["PlayStore"] = "play_store";
VendorStore["Adapty"] = "adapty";
})(VendorStore || (VendorStore = {}));
export var OfferType;
(function (OfferType) {
OfferType["FreeTrial"] = "free_trial";
OfferType["PayAsYouGo"] = "pay_as_you_go";
OfferType["PayUpFront"] = "pay_up_front";
})(OfferType || (OfferType = {}));
export var CancellationReason;
(function (CancellationReason) {
CancellationReason["VolountarilyCancelled"] = "voluntarily_cancelled";
CancellationReason["BillingError"] = "billing_error";
CancellationReason["Refund"] = "refund";
CancellationReason["PriceIncrease"] = "price_increase";
CancellationReason["ProductWasNotAvailable"] = "product_was_not_available";
CancellationReason["Unknown"] = "unknown";
})(CancellationReason || (CancellationReason = {}));
export var Gender;
(function (Gender) {
Gender["Female"] = "f";
Gender["Male"] = "m";
Gender["Other"] = "o";
})(Gender || (Gender = {}));
export var AppTrackingTransparencyStatus;
(function (AppTrackingTransparencyStatus) {
AppTrackingTransparencyStatus["NotDetermined"] = "not_determined";
AppTrackingTransparencyStatus["Restricted"] = "restricted";
AppTrackingTransparencyStatus["Denied"] = "denied";
AppTrackingTransparencyStatus["Authorized"] = "authorized";
AppTrackingTransparencyStatus["Unknown"] = "unknown";
})(AppTrackingTransparencyStatus || (AppTrackingTransparencyStatus = {}));
export var ProductPeriod;
(function (ProductPeriod) {
ProductPeriod["Day"] = "day";
ProductPeriod["Week"] = "week";
ProductPeriod["Month"] = "month";
ProductPeriod["Year"] = "year";
})(ProductPeriod || (ProductPeriod = {}));
export var OfferEligibility;
(function (OfferEligibility) {
OfferEligibility["Eligible"] = "eligible";
OfferEligibility["Ineligible"] = "ineligible";
OfferEligibility["Unknown"] = "unknown";
})(OfferEligibility || (OfferEligibility = {}));
export var SKPaymentTransactionState;
(function (SKPaymentTransactionState) {
SKPaymentTransactionState[SKPaymentTransactionState["purchasing"] = 0] = "purchasing";
SKPaymentTransactionState[SKPaymentTransactionState["purchased"] = 1] = "purchased";
SKPaymentTransactionState[SKPaymentTransactionState["failed"] = 2] = "failed";
SKPaymentTransactionState[SKPaymentTransactionState["restored"] = 3] = "restored";
SKPaymentTransactionState[SKPaymentTransactionState["deferred"] = 4] = "deferred";
})(SKPaymentTransactionState || (SKPaymentTransactionState = {}));
//# sourceMappingURL=cdk.js.map
const VendorStore = Object.freeze({
AppStore: 'app_store',
PlayStore: 'play_store',
Adapty: 'adapty',
});
const OfferType = Object.freeze({
FreeTrial: 'free_trial',
PayAsYouGo: 'pay_as_you_go',
PayUpFront: 'pay_up_front',
Unknown: 'unknown',
});
const CancellationReason = Object.freeze({
VolountarilyCancelled: 'voluntarily_cancelled',
BillingError: 'billing_error',
Refund: 'refund',
PriceIncrease: 'price_increase',
ProductWasNotAvailable: 'product_was_not_available',
Unknown: 'unknown',
});
const Gender = Object.freeze({
Female: 'f',
Male: 'm',
Other: 'o',
});
const AppTrackingTransparencyStatus = Object.freeze({
NotDetermined: 0,
Restricted: 1,
Denied: 2,
Authorized: 3,
Unknown: 4,
});
const ProductPeriod = Object.freeze({
Day: 'day',
Week: 'week',
Month: 'month',
Year: 'year',
Unknown: 'unknown',
});
const OfferEligibility = Object.freeze({
Eligible: 'eligible',
Ineligible: 'ineligible',
NotApplicable: 'not_applicable',
});
const LogLevel = Object.freeze({
error: 'error',
warn: 'warn',
info: 'info',
verbose: 'verbose',
debug: 'debug',
});
const PaywallFetchPolicy = Object.freeze({
returnCacheDataElseLoad: 'return_cache_data_else_load',
reloadRevalidatingCacheData: 'reload_revalidating_cache_data',
default: 'default',
});
const AttributionNetwork = Object.freeze({
appsflyer: 'appsflyer',
adjust: 'adjust',
branch: 'branch',
custom: 'custom',
appleSearchAds: 'apple_search_ads',
});
const SKPaymentTransactionState = Object.freeze({
purchasing: 0, // Transaction is being added to the server queue.
purchased: 1, // Transaction is in queue, user has been charged. Client should complete the transaction.
failed: 2, // Transaction was cancelled or failed before being added to the server queue.
restored: 3, // Transaction was restored from user's purchase history. Client should complete the transaction.
deferred: 4, // The transaction is in the queue, but its final status is pending external action.
});
export { AppTrackingTransparencyStatus, AttributionNetwork, CancellationReason, Gender, LogLevel, OfferEligibility, OfferType, PaywallFetchPolicy, ProductPeriod, SKPaymentTransactionState, VendorStore };

@@ -1,42 +0,42 @@

export declare const AdaptyErrors: {
declare const AdaptyErrors: Readonly<{
/**
* System StoreKit codes
*/
unknown: number;
unknown: 0;
/**
* Client is not allowed to make a request, etc.
*/
clientInvalid: number;
clientInvalid: 1;
/**
* User cancelled the request, etc.
*/
paymentCancelled: number;
paymentCancelled: 2;
/**
* Invalid purchase identifier, etc.
*/
paymentInvalid: number;
paymentInvalid: 3;
/**
* This device is not allowed to make the payment.
*/
paymentNotAllowed: number;
paymentNotAllowed: 4;
/**
* Product is not available in the current storefront.
*/
storeProductNotAvailable: number;
storeProductNotAvailable: 5;
/**
* User has not allowed access to cloud service information.
*/
cloudServicePermissionDenied: number;
cloudServicePermissionDenied: 6;
/**
* The device could not connect to the network.
*/
cloudServiceNetworkConnectionFailed: number;
cloudServiceNetworkConnectionFailed: 7;
/**
* User has revoked permission to use this cloud service.
*/
cloudServiceRevoked: number;
cloudServiceRevoked: 8;
/**
* The user needs to acknowledge Apple's privacy policy.
*/
privacyAcknowledgementRequired: number;
privacyAcknowledgementRequired: 9;
/**

@@ -46,59 +46,58 @@ * The app is attempting to use SKPayment's requestData property,

*/
unauthorizedRequestData: number;
unauthorizedRequestData: 10;
/**
* The specified subscription offer identifier is not valid.
*/
invalidOfferIdentifier: number;
invalidOfferIdentifier: 11;
/**
* The cryptographic signature provided is not valid.
*/
invalidSignature: number;
invalidSignature: 12;
/**
* One or more parameters from SKPaymentDiscount is missing.
*/
missingOfferParams: number;
invalidOfferPrice: number;
noProductIDsFound: number;
productRequestFailed: number;
missingOfferParams: 13;
invalidOfferPrice: 14;
noProductIDsFound: 1000;
productRequestFailed: 1002;
/**
* In-App Purchases are not allowed on this device.
*/
cantMakePayments: number;
noPurchasesToRestore: number;
cantReadReceipt: number;
productPurchaseFailed: number;
refreshReceiptFailed: number;
receiveRestoredTransactionsFailed: number;
cantMakePayments: 1003;
noPurchasesToRestore: 1004;
cantReadReceipt: 1005;
productPurchaseFailed: 1006;
refreshReceiptFailed: 1010;
receiveRestoredTransactionsFailed: 1011;
/**
* Adapty SDK is not activated.
*/
notActivated: number;
badRequest: number;
serverError: number;
networkFailed: number;
decodingFailed: number;
encodingFailed: number;
analyticsDisabled: number;
notActivated: 2002;
badRequest: 2003;
serverError: 2004;
networkFailed: 2005;
decodingFailed: 2006;
encodingFailed: 2009;
analyticsDisabled: 3000;
/**
* Wrong parameter was passed.
*/
wrongParam: number;
wrongParam: 3001;
/**
* It is not possible to call `.activate` method more than once.
*/
activateOnceError: number;
activateOnceError: 3005;
/**
* The user profile was changed during the operation.
*/
profileWasChanged: number;
persistingDataError: number;
operationInterrupted: number;
};
declare type ErrorType = typeof AdaptyErrors;
export declare type AdaptyError = {
profileWasChanged: 3006;
persistingDataError: 3100;
operationInterrupted: 9000;
}>;
type AdaptyError = {
message: string;
code: ErrorType[keyof ErrorType];
code: typeof AdaptyErrors[keyof typeof AdaptyErrors];
errorMessage: string;
};
export declare function isAdaptyError(error: unknown): error is AdaptyError;
export {};
declare function isAdaptyError(error: unknown): error is AdaptyError;
export { AdaptyErrors, AdaptyError, isAdaptyError };

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

export const AdaptyErrors = {
const AdaptyErrors = Object.freeze({
/**

@@ -95,4 +95,4 @@ * System StoreKit codes

operationInterrupted: 9000,
};
export function isAdaptyError(error) {
});
function isAdaptyError(error) {
return (typeof error === 'object' &&

@@ -102,2 +102,3 @@ 'code' in error &&

}
//# sourceMappingURL=errors.js.map
export { AdaptyErrors, isAdaptyError };
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var core = require('@capacitor/core');
const VERSION = "3.0.1";
function decodePaywall(paywall) {
return {
abTestName: paywall.ab_test_name,
placementId: paywall.developer_id,
locale: paywall.remote_config.lang,
hasViewConfiguration: paywall.use_paywall_builder || false,
name: paywall.paywall_name,
remoteConfig: paywall.remote_config.data,
revision: paywall.revision,
variationId: paywall.variation_id,
products: paywall.products.map(decodeProductReference),
instanceIdentity: paywall.paywall_id,
version: paywall.paywall_updated_at,
};
}
function encodePaywall(paywall) {
return {
ab_test_name: paywall.abTestName,
developer_id: paywall.placementId,
remote_config: {
lang: paywall.locale,
data: paywall.remoteConfig,
},
use_paywall_builder: paywall.hasViewConfiguration,
paywall_name: paywall.name,
revision: paywall.revision,
variation_id: paywall.variationId,
products: paywall.products.map(encodeProductReference),
paywall_id: paywall.instanceIdentity,
paywall_updated_at: paywall.version,
};
}
function decodeProductReference(product) {
return {
vendorId: product.vendor_product_id,
adaptyProductId: product.adapty_product_id,
ios: {
promotionalOfferId: product.promotional_offer_id,
},
};
}
function encodeProductReference(product) {
var _a;
return {
vendor_product_id: product.vendorId,
adapty_product_id: product.adaptyProductId,
promotional_offer_id: (_a = product.ios) === null || _a === void 0 ? void 0 : _a.promotionalOfferId,
};
}
exports.LogLevel = void 0;
(function (LogLevel) {
LogLevel["error"] = "error";
LogLevel["warn"] = "warn";
LogLevel["info"] = "info";
LogLevel["verbose"] = "verbose";
LogLevel["debug"] = "debug";
})(exports.LogLevel || (exports.LogLevel = {}));
exports.StoreKit2Usage = void 0;
(function (StoreKit2Usage) {
StoreKit2Usage["forIntroEligibilityCheck"] = "for_intro_eligibility_check";
StoreKit2Usage["disabled"] = "disabled";
})(exports.StoreKit2Usage || (exports.StoreKit2Usage = {}));
exports.AttributionNetwork = void 0;
(function (AttributionNetwork) {
AttributionNetwork["appsflyer"] = "appsflyer";
AttributionNetwork["adjust"] = "adjust";
AttributionNetwork["branch"] = "branch";
AttributionNetwork["custom"] = "custom";
AttributionNetwork["appleSearchAds"] = "apple_search_ads";
})(exports.AttributionNetwork || (exports.AttributionNetwork = {}));
/******************************************************************************
Copyright (c) Microsoft Corporation.
exports.VendorStore = void 0;
(function (VendorStore) {
VendorStore["AppStore"] = "app_store";
VendorStore["PlayStore"] = "play_store";
VendorStore["Adapty"] = "adapty";
})(exports.VendorStore || (exports.VendorStore = {}));
exports.OfferType = void 0;
(function (OfferType) {
OfferType["FreeTrial"] = "free_trial";
OfferType["PayAsYouGo"] = "pay_as_you_go";
OfferType["PayUpFront"] = "pay_up_front";
})(exports.OfferType || (exports.OfferType = {}));
exports.CancellationReason = void 0;
(function (CancellationReason) {
CancellationReason["VolountarilyCancelled"] = "voluntarily_cancelled";
CancellationReason["BillingError"] = "billing_error";
CancellationReason["Refund"] = "refund";
CancellationReason["PriceIncrease"] = "price_increase";
CancellationReason["ProductWasNotAvailable"] = "product_was_not_available";
CancellationReason["Unknown"] = "unknown";
})(exports.CancellationReason || (exports.CancellationReason = {}));
exports.Gender = void 0;
(function (Gender) {
Gender["Female"] = "f";
Gender["Male"] = "m";
Gender["Other"] = "o";
})(exports.Gender || (exports.Gender = {}));
exports.AppTrackingTransparencyStatus = void 0;
(function (AppTrackingTransparencyStatus) {
AppTrackingTransparencyStatus["NotDetermined"] = "not_determined";
AppTrackingTransparencyStatus["Restricted"] = "restricted";
AppTrackingTransparencyStatus["Denied"] = "denied";
AppTrackingTransparencyStatus["Authorized"] = "authorized";
AppTrackingTransparencyStatus["Unknown"] = "unknown";
})(exports.AppTrackingTransparencyStatus || (exports.AppTrackingTransparencyStatus = {}));
exports.ProductPeriod = void 0;
(function (ProductPeriod) {
ProductPeriod["Day"] = "day";
ProductPeriod["Week"] = "week";
ProductPeriod["Month"] = "month";
ProductPeriod["Year"] = "year";
})(exports.ProductPeriod || (exports.ProductPeriod = {}));
exports.OfferEligibility = void 0;
(function (OfferEligibility) {
OfferEligibility["Eligible"] = "eligible";
OfferEligibility["Ineligible"] = "ineligible";
OfferEligibility["Unknown"] = "unknown";
})(exports.OfferEligibility || (exports.OfferEligibility = {}));
exports.SKPaymentTransactionState = void 0;
(function (SKPaymentTransactionState) {
SKPaymentTransactionState[SKPaymentTransactionState["purchasing"] = 0] = "purchasing";
SKPaymentTransactionState[SKPaymentTransactionState["purchased"] = 1] = "purchased";
SKPaymentTransactionState[SKPaymentTransactionState["failed"] = 2] = "failed";
SKPaymentTransactionState[SKPaymentTransactionState["restored"] = 3] = "restored";
SKPaymentTransactionState[SKPaymentTransactionState["deferred"] = 4] = "deferred";
})(exports.SKPaymentTransactionState || (exports.SKPaymentTransactionState = {}));
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
const AdaptyErrors = {
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
const CamelToSnake = (str) => str.replace(/([A-Z])/g, g => '_' + g[0].toLowerCase());
const SnakeToCamel = (str) => str.replace(/(\_\w)/g, g => g[1].toUpperCase());
const toSnake = (input) => converter(input, 'CamelToSnake');
const toCamel = (input) => converter(input, 'SnakeToCamel');
function converter(input, type) {
let result;
if (typeof input === 'string')
result = stringParser(input, type);
if (isArray(input))
result = arrayParser(input, type);
if (isObject(input))
result = objectParser(input, type);
return result;
}
function stringParser(input, type) {
return {
CamelToSnake,
SnakeToCamel,
}[type](input);
}
function arrayParser(input, type) {
return input.map(item => {
if (isArray(item))
return arrayParser(item, type);
if (isObject(item))
return objectParser(item, type);
return item;
});
}
function objectParser(input, type) {
const result = {};
for (const property in input) {
const parsedKey = stringParser(property, type);
const value = input[property];
if (isArray(value)) {
result[parsedKey] = arrayParser(value, type);
}
else if (isObject(value)) {
result[parsedKey] = objectParser(value, type);
}
else {
result[parsedKey] = value;
}
}
return result;
}
function isObject(input) {
return typeof input === 'object' && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
}
function isArray(input) {
return Array.isArray(input);
}
function decodeDiscountPhase(discountPhase) {
const { identifier, payment_mode } = discountPhase, rest = __rest(discountPhase, ["identifier", "payment_mode"]);
return Object.assign(Object.assign({}, toCamel(rest)), { paymentMode: payment_mode, ios: {
identifier,
} });
}
function decodeSubscriptionDetails(subscriptionDetails) {
var _a;
if (!subscriptionDetails)
return undefined;
const { introductory_offer_phases, promotional_offer, subscription_group_identifier } = subscriptionDetails, rest = __rest(subscriptionDetails, ["introductory_offer_phases", "promotional_offer", "subscription_group_identifier"]);
return Object.assign(Object.assign({}, toCamel(rest)), { introductoryOffers: (_a = subscriptionDetails.introductory_offer_phases) === null || _a === void 0 ? void 0 : _a.map(decodeDiscountPhase), ios: {
promotionalOffer: promotional_offer
? decodeDiscountPhase(promotional_offer)
: undefined,
subscriptionGroupIdentifier: subscription_group_identifier,
} });
}
function decodeProduct(product) {
const { is_family_shareable } = product, rest = __rest(product, ["is_family_shareable"]);
return Object.assign(Object.assign({}, toCamel(rest)), { subscriptionDetails: decodeSubscriptionDetails(product.subscription_details), ios: {
isFamilyShareable: is_family_shareable || false,
} });
}
function encodeProduct(product) {
var _a, _b, _c, _d;
return {
adapty_product_id: product.adaptyProductId,
paywall_ab_test_name: product.paywallAbTestName,
payload_data: product.payloadData,
paywall_name: product.paywallName,
paywall_variation_id: product.paywallVariationId,
promotional_offer_id: (_d = (_c = (_b = (_a = product.subscriptionDetails) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b.promotionalOffer) === null || _c === void 0 ? void 0 : _c.ios) === null || _d === void 0 ? void 0 : _d.identifier,
vendor_product_id: product.vendorProductId,
};
}
function decodeDate(date) {
if (!date)
return undefined;
return new Date(date);
}
/** Format: YYYY-MM-dd */
function encodeDate(date) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return [year, month, day].map(n => n.toString().padStart(2, '0')).join('-');
}
function decodeAccessLevel(accessLevel) {
const { activated_at, billing_issue_detected_at, expires_at, renewed_at, starts_at, unsubscribed_at, store, active_introductory_offer_type, active_promotional_offer_type, cancellation_reason } = accessLevel, rest = __rest(accessLevel, ["activated_at", "billing_issue_detected_at", "expires_at", "renewed_at", "starts_at", "unsubscribed_at", "store", "active_introductory_offer_type", "active_promotional_offer_type", "cancellation_reason"]);
return Object.assign(Object.assign({}, toCamel(rest)), { activatedAt: decodeDate(activated_at), billingIssueDetectedAt: decodeDate(billing_issue_detected_at), expiresAt: decodeDate(expires_at), renewedAt: decodeDate(renewed_at), startsAt: decodeDate(starts_at), unsubscribedAt: decodeDate(unsubscribed_at), store: store, activeIntroductoryOfferType: active_introductory_offer_type, activePromotionalOfferType: active_promotional_offer_type, cancellationReason: cancellation_reason });
}
function decodeNonSubscription(nonSubscription) {
const { purchased_at, store } = nonSubscription, rest = __rest(nonSubscription, ["purchased_at", "store"]);
return Object.assign(Object.assign({}, toCamel(rest)), { purchasedAt: decodeDate(purchased_at), store: store });
}
function decodeRecords(records, converter) {
return Object.entries(records).reduce((acc, [key, value]) => {
acc[key] = converter(value);
return acc;
}, {});
}
function decodeSubscription(subscription) {
const { activated_at, active_introductory_offer_type, active_promotional_offer_type, billing_issue_detected_at, cancellation_reason, expires_at, renewed_at, store, starts_at, unsubscribed_at } = subscription, rest = __rest(subscription, ["activated_at", "active_introductory_offer_type", "active_promotional_offer_type", "billing_issue_detected_at", "cancellation_reason", "expires_at", "renewed_at", "store", "starts_at", "unsubscribed_at"]);
return Object.assign(Object.assign({}, toCamel(rest)), { activatedAt: decodeDate(activated_at), activeIntroductoryOfferType: active_introductory_offer_type, activePromotionalOfferType: active_promotional_offer_type, billingIssueDetectedAt: decodeDate(billing_issue_detected_at), cancellationReason: cancellation_reason, expiresAt: decodeDate(expires_at), renewedAt: decodeDate(renewed_at), startsAt: decodeDate(starts_at), store: store, unsubscribedAt: decodeDate(unsubscribed_at) });
}
function decodeProfile(profile) {
const { paid_access_levels, custom_attributes, non_subscriptions, subscriptions } = profile, rest = __rest(profile, ["paid_access_levels", "custom_attributes", "non_subscriptions", "subscriptions"]);
return Object.assign(Object.assign({}, toCamel(rest)), { accessLevels: paid_access_levels
? decodeRecords(paid_access_levels, decodeAccessLevel)
: undefined, customAttributes: custom_attributes, nonSubscriptions: non_subscriptions
? decodeRecords(non_subscriptions, value => value.map(decodeNonSubscription))
: non_subscriptions, subscriptions: subscriptions
? decodeRecords(subscriptions, decodeSubscription)
: undefined });
}
function encodeProfileParameters(profile) {
const { birthday, customAttributes, pushwooshHWID, appTrackingTransparencyStatus, gender } = profile, rest = __rest(profile, ["birthday", "customAttributes", "pushwooshHWID", "appTrackingTransparencyStatus", "gender"]);
let _params = toSnake(rest);
let params = _params;
function hasProp(key) {
return Object.prototype.hasOwnProperty.call(profile, key);
}
if (hasProp('birthday')) {
params.birthday = birthday ? encodeDate(birthday) : undefined;
}
if (hasProp('gender')) {
params.gender = gender;
}
if (hasProp('customAttributes')) {
params.custom_attributes = customAttributes;
}
if (hasProp('appTrackingTransparencyStatus')) {
params.att_status = appTrackingTransparencyStatus;
}
if (hasProp('pushwooshHWID')) {
params.pushwoosh_hwid = pushwooshHWID;
}
console.log('updateProfile', profile, params);
return params;
}
function decodeSKPayment(payment) {
return toCamel(payment);
}
function decodeSKTransaction(transaction) {
const { payment, original } = transaction, rest = __rest(transaction, ["payment", "original"]);
return Object.assign(Object.assign({}, toCamel(rest)), { payment: decodeSKPayment(payment), original: original ? decodeSKTransaction(original) : undefined });
}
class PromiseQueue {
constructor() {
this.queue = [];
this.running = false;
}
async enqueue(task) {
const completionPromise = new Promise(resolve => {
const wrapped = async () => {
await task();
resolve();
};
this.queue.push(wrapped);
});
this.runQueue();
return completionPromise;
}
async runQueue() {
if (this.running)
return;
this.running = true;
while (this.queue.length > 0) {
const task = this.queue.shift();
if (task) {
await task();
}
await Promise.resolve();
}
this.running = false;
}
}
const VendorStore = Object.freeze({
AppStore: 'app_store',
PlayStore: 'play_store',
Adapty: 'adapty',
});
const OfferType = Object.freeze({
FreeTrial: 'free_trial',
PayAsYouGo: 'pay_as_you_go',
PayUpFront: 'pay_up_front',
Unknown: 'unknown',
});
const CancellationReason = Object.freeze({
VolountarilyCancelled: 'voluntarily_cancelled',
BillingError: 'billing_error',
Refund: 'refund',
PriceIncrease: 'price_increase',
ProductWasNotAvailable: 'product_was_not_available',
Unknown: 'unknown',
});
const Gender = Object.freeze({
Female: 'f',
Male: 'm',
Other: 'o',
});
const AppTrackingTransparencyStatus = Object.freeze({
NotDetermined: 0,
Restricted: 1,
Denied: 2,
Authorized: 3,
Unknown: 4,
});
const ProductPeriod = Object.freeze({
Day: 'day',
Week: 'week',
Month: 'month',
Year: 'year',
Unknown: 'unknown',
});
const OfferEligibility = Object.freeze({
Eligible: 'eligible',
Ineligible: 'ineligible',
NotApplicable: 'not_applicable',
});
const LogLevel = Object.freeze({
error: 'error',
warn: 'warn',
info: 'info',
verbose: 'verbose',
debug: 'debug',
});
const PaywallFetchPolicy = Object.freeze({
returnCacheDataElseLoad: 'return_cache_data_else_load',
reloadRevalidatingCacheData: 'reload_revalidating_cache_data',
default: 'default',
});
const AttributionNetwork = Object.freeze({
appsflyer: 'appsflyer',
adjust: 'adjust',
branch: 'branch',
custom: 'custom',
appleSearchAds: 'apple_search_ads',
});
const SKPaymentTransactionState = Object.freeze({
purchasing: 0, // Transaction is being added to the server queue.
purchased: 1, // Transaction is in queue, user has been charged. Client should complete the transaction.
failed: 2, // Transaction was cancelled or failed before being added to the server queue.
restored: 3, // Transaction was restored from user's purchase history. Client should complete the transaction.
deferred: 4, // The transaction is in the queue, but its final status is pending external action.
});
const AdaptyErrors = Object.freeze({
/**

@@ -182,3 +457,3 @@ * System StoreKit codes

operationInterrupted: 9000,
};
});
function isAdaptyError(error) {

@@ -190,18 +465,32 @@ return (typeof error === 'object' &&

const libVersion = VERSION;
const CapacitorAdapty = core.registerPlugin('Adapty', {});
const LIB_VERSION = "4.0.1";
class Adapty {
constructor() {
this.adapty = CapacitorAdapty;
this.getProfile = this.adapty.getProfile;
this.logout = this.adapty.logout;
this.presentCodeRedemptionSheet = this.adapty.presentCodeRedemptionSheet;
this.restorePurchases = this.adapty.restorePurchases;
this.addListener = this.adapty.addListener;
this.resolveActivation = null;
this.activatingPromise = new Promise(resolve => (this.resolveActivation = resolve));
// https://github.com/adaptyteam/AdaptySDK-React-Native/issues/66#issuecomment-1521638581
this.mutationalQueue = new PromiseQueue();
}
activate(apiKey, options) {
return this.adapty.activate(Object.assign({ apiKey,
libVersion }, options));
async awaitActivation() {
if (this.activatingPromise) {
await this.activatingPromise;
this.activatingPromise = null;
}
}
updateAttribution(source, attribution, networkUserId) {
async activate(apiKey, options) {
const promise = this.adapty.activate(Object.assign({ apiKey, libVersion: LIB_VERSION }, options));
if (!this.activatingPromise) {
this.activatingPromise = promise;
}
const result = await promise;
if (this.resolveActivation) {
this.resolveActivation();
this.resolveActivation = null;
}
return result;
}
async updateAttribution(source, attribution, networkUserId) {
await this.awaitActivation();
return this.adapty.updateAttribution({

@@ -213,31 +502,85 @@ source,

}
getPaywall(id, locale) {
return this.adapty.getPaywall({ id, locale });
async getPaywall(placementId, locale, options) {
await this.awaitActivation();
return this.adapty
.getPaywall(Object.assign({ placementId, locale }, options))
.then(res => decodePaywall(res.paywall));
}
getPaywallProducts(paywall) {
async getPaywallProducts(paywall) {
await this.awaitActivation();
return this.adapty
.getPaywallProducts({ paywall })
.then(res => res.products);
.getPaywallProducts({ paywall: encodePaywall(paywall) })
.then(res => res.products.map(decodeProduct));
}
logShowOnboarding(screenOrder, screenName, name) {
async getProductsIntroductoryOfferEligibility(vendorProductIds) {
await this.awaitActivation();
return this.adapty
.getProductsIntroductoryOfferEligibility({
vendorProductIds,
})
.then(res => res.eligibilities);
}
async logShowOnboarding(screenOrder, screenName, name) {
await this.awaitActivation();
return this.adapty.logShowOnboarding({ screenOrder, screenName, name });
}
logShowPaywall(paywall) {
return this.adapty.logShowPaywall({ paywall });
async logShowPaywall(paywall) {
await this.awaitActivation();
return this.adapty.logShowPaywall({ paywall: encodePaywall(paywall) });
}
setFallbackPaywalls(paywalls) {
async setFallbackPaywalls(paywalls) {
await this.awaitActivation();
return this.adapty.setFallbackPaywalls({ paywalls });
}
identify(customerUserId) {
return this.adapty.identify({ customerUserId });
async getProfile() {
await this.awaitActivation();
return this.adapty.getProfile().then(res => decodeProfile(res.profile));
}
updateProfile(params) {
return this.adapty.updateProfile({ params });
async identify(customerUserId) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.identify({ customerUserId }));
}
makePurchase(product) {
return this.adapty.makePurchase({ product });
async logout() {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.logout());
}
setLogLevel(logLevel) {
async updateProfile(params) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.updateProfile({
params: encodeProfileParameters(params),
}));
}
async makePurchase(product) {
await this.awaitActivation();
return this.adapty
.makePurchase({ product: encodeProduct(product) })
.then(res => ({
profile: decodeProfile(res.purchase.profile),
transaction: res.purchase.transaction
? decodeSKTransaction(res.purchase.transaction)
: undefined,
}));
}
async presentCodeRedemptionSheet() {
await this.awaitActivation();
return this.adapty.presentCodeRedemptionSheet();
}
async restorePurchases() {
await this.awaitActivation();
return this.adapty
.restorePurchases()
.then(res => decodeProfile(res.profile));
}
async setLogLevel(logLevel) {
await this.awaitActivation();
return this.adapty.setLogLevel({ logLevel });
}
addListener(eventName, listenerFunc) {
{
switch (eventName) {
case 'onLatestProfileLoad':
return this.adapty.addListener(eventName, data => listenerFunc({ profile: decodeProfile(data.profile) }));
}
}
}
}

@@ -247,3 +590,14 @@

exports.AdaptyErrors = AdaptyErrors;
exports.AppTrackingTransparencyStatus = AppTrackingTransparencyStatus;
exports.AttributionNetwork = AttributionNetwork;
exports.CancellationReason = CancellationReason;
exports.Gender = Gender;
exports.LogLevel = LogLevel;
exports.OfferEligibility = OfferEligibility;
exports.OfferType = OfferType;
exports.PaywallFetchPolicy = PaywallFetchPolicy;
exports.ProductPeriod = ProductPeriod;
exports.SKPaymentTransactionState = SKPaymentTransactionState;
exports.VendorStore = VendorStore;
exports.isAdaptyError = isAdaptyError;
//# sourceMappingURL=plugin.cjs.js.map
var capacitorAdapty = (function (exports, core) {
'use strict';
'use strict';
const VERSION = "3.0.1";
function decodePaywall(paywall) {
return {
abTestName: paywall.ab_test_name,
placementId: paywall.developer_id,
locale: paywall.remote_config.lang,
hasViewConfiguration: paywall.use_paywall_builder || false,
name: paywall.paywall_name,
remoteConfig: paywall.remote_config.data,
revision: paywall.revision,
variationId: paywall.variation_id,
products: paywall.products.map(decodeProductReference),
instanceIdentity: paywall.paywall_id,
version: paywall.paywall_updated_at,
};
}
function encodePaywall(paywall) {
return {
ab_test_name: paywall.abTestName,
developer_id: paywall.placementId,
remote_config: {
lang: paywall.locale,
data: paywall.remoteConfig,
},
use_paywall_builder: paywall.hasViewConfiguration,
paywall_name: paywall.name,
revision: paywall.revision,
variation_id: paywall.variationId,
products: paywall.products.map(encodeProductReference),
paywall_id: paywall.instanceIdentity,
paywall_updated_at: paywall.version,
};
}
function decodeProductReference(product) {
return {
vendorId: product.vendor_product_id,
adaptyProductId: product.adapty_product_id,
ios: {
promotionalOfferId: product.promotional_offer_id,
},
};
}
function encodeProductReference(product) {
var _a;
return {
vendor_product_id: product.vendorId,
adapty_product_id: product.adaptyProductId,
promotional_offer_id: (_a = product.ios) === null || _a === void 0 ? void 0 : _a.promotionalOfferId,
};
}
exports.LogLevel = void 0;
(function (LogLevel) {
LogLevel["error"] = "error";
LogLevel["warn"] = "warn";
LogLevel["info"] = "info";
LogLevel["verbose"] = "verbose";
LogLevel["debug"] = "debug";
})(exports.LogLevel || (exports.LogLevel = {}));
exports.StoreKit2Usage = void 0;
(function (StoreKit2Usage) {
StoreKit2Usage["forIntroEligibilityCheck"] = "for_intro_eligibility_check";
StoreKit2Usage["disabled"] = "disabled";
})(exports.StoreKit2Usage || (exports.StoreKit2Usage = {}));
exports.AttributionNetwork = void 0;
(function (AttributionNetwork) {
AttributionNetwork["appsflyer"] = "appsflyer";
AttributionNetwork["adjust"] = "adjust";
AttributionNetwork["branch"] = "branch";
AttributionNetwork["custom"] = "custom";
AttributionNetwork["appleSearchAds"] = "apple_search_ads";
})(exports.AttributionNetwork || (exports.AttributionNetwork = {}));
/******************************************************************************
Copyright (c) Microsoft Corporation.
exports.VendorStore = void 0;
(function (VendorStore) {
VendorStore["AppStore"] = "app_store";
VendorStore["PlayStore"] = "play_store";
VendorStore["Adapty"] = "adapty";
})(exports.VendorStore || (exports.VendorStore = {}));
exports.OfferType = void 0;
(function (OfferType) {
OfferType["FreeTrial"] = "free_trial";
OfferType["PayAsYouGo"] = "pay_as_you_go";
OfferType["PayUpFront"] = "pay_up_front";
})(exports.OfferType || (exports.OfferType = {}));
exports.CancellationReason = void 0;
(function (CancellationReason) {
CancellationReason["VolountarilyCancelled"] = "voluntarily_cancelled";
CancellationReason["BillingError"] = "billing_error";
CancellationReason["Refund"] = "refund";
CancellationReason["PriceIncrease"] = "price_increase";
CancellationReason["ProductWasNotAvailable"] = "product_was_not_available";
CancellationReason["Unknown"] = "unknown";
})(exports.CancellationReason || (exports.CancellationReason = {}));
exports.Gender = void 0;
(function (Gender) {
Gender["Female"] = "f";
Gender["Male"] = "m";
Gender["Other"] = "o";
})(exports.Gender || (exports.Gender = {}));
exports.AppTrackingTransparencyStatus = void 0;
(function (AppTrackingTransparencyStatus) {
AppTrackingTransparencyStatus["NotDetermined"] = "not_determined";
AppTrackingTransparencyStatus["Restricted"] = "restricted";
AppTrackingTransparencyStatus["Denied"] = "denied";
AppTrackingTransparencyStatus["Authorized"] = "authorized";
AppTrackingTransparencyStatus["Unknown"] = "unknown";
})(exports.AppTrackingTransparencyStatus || (exports.AppTrackingTransparencyStatus = {}));
exports.ProductPeriod = void 0;
(function (ProductPeriod) {
ProductPeriod["Day"] = "day";
ProductPeriod["Week"] = "week";
ProductPeriod["Month"] = "month";
ProductPeriod["Year"] = "year";
})(exports.ProductPeriod || (exports.ProductPeriod = {}));
exports.OfferEligibility = void 0;
(function (OfferEligibility) {
OfferEligibility["Eligible"] = "eligible";
OfferEligibility["Ineligible"] = "ineligible";
OfferEligibility["Unknown"] = "unknown";
})(exports.OfferEligibility || (exports.OfferEligibility = {}));
exports.SKPaymentTransactionState = void 0;
(function (SKPaymentTransactionState) {
SKPaymentTransactionState[SKPaymentTransactionState["purchasing"] = 0] = "purchasing";
SKPaymentTransactionState[SKPaymentTransactionState["purchased"] = 1] = "purchased";
SKPaymentTransactionState[SKPaymentTransactionState["failed"] = 2] = "failed";
SKPaymentTransactionState[SKPaymentTransactionState["restored"] = 3] = "restored";
SKPaymentTransactionState[SKPaymentTransactionState["deferred"] = 4] = "deferred";
})(exports.SKPaymentTransactionState || (exports.SKPaymentTransactionState = {}));
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
const AdaptyErrors = {
/**
* System StoreKit codes
*/
unknown: 0,
/**
* Client is not allowed to make a request, etc.
*/
clientInvalid: 1,
/**
* User cancelled the request, etc.
*/
paymentCancelled: 2,
/**
* Invalid purchase identifier, etc.
*/
paymentInvalid: 3,
/**
* This device is not allowed to make the payment.
*/
paymentNotAllowed: 4,
/**
* Product is not available in the current storefront.
*/
storeProductNotAvailable: 5,
/**
* User has not allowed access to cloud service information.
*/
cloudServicePermissionDenied: 6,
/**
* The device could not connect to the network.
*/
cloudServiceNetworkConnectionFailed: 7,
/**
* User has revoked permission to use this cloud service.
*/
cloudServiceRevoked: 8,
/**
* The user needs to acknowledge Apple's privacy policy.
*/
privacyAcknowledgementRequired: 9,
/**
* The app is attempting to use SKPayment's requestData property,
* but does not have the appropriate entitlement.
*/
unauthorizedRequestData: 10,
/**
* The specified subscription offer identifier is not valid.
*/
invalidOfferIdentifier: 11,
/**
* The cryptographic signature provided is not valid.
*/
invalidSignature: 12,
/**
* One or more parameters from SKPaymentDiscount is missing.
*/
missingOfferParams: 13,
invalidOfferPrice: 14,
noProductIDsFound: 1000,
productRequestFailed: 1002,
/**
* In-App Purchases are not allowed on this device.
*/
cantMakePayments: 1003,
noPurchasesToRestore: 1004,
cantReadReceipt: 1005,
productPurchaseFailed: 1006,
refreshReceiptFailed: 1010,
receiveRestoredTransactionsFailed: 1011,
/**
* Adapty SDK is not activated.
*/
notActivated: 2002,
badRequest: 2003,
serverError: 2004,
networkFailed: 2005,
decodingFailed: 2006,
encodingFailed: 2009,
analyticsDisabled: 3000,
/**
* Wrong parameter was passed.
*/
wrongParam: 3001,
/**
* It is not possible to call `.activate` method more than once.
*/
activateOnceError: 3005,
/**
* The user profile was changed during the operation.
*/
profileWasChanged: 3006,
persistingDataError: 3100,
operationInterrupted: 9000,
};
function isAdaptyError(error) {
return (typeof error === 'object' &&
'code' in error &&
'message' in error);
}
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
/* global Reflect, Promise, SuppressedError, Symbol */
const libVersion = VERSION;
const CapacitorAdapty = core.registerPlugin('Adapty', {});
class Adapty {
constructor() {
this.adapty = CapacitorAdapty;
this.getProfile = this.adapty.getProfile;
this.logout = this.adapty.logout;
this.presentCodeRedemptionSheet = this.adapty.presentCodeRedemptionSheet;
this.restorePurchases = this.adapty.restorePurchases;
this.addListener = this.adapty.addListener;
}
activate(apiKey, options) {
return this.adapty.activate(Object.assign({ apiKey,
libVersion }, options));
}
updateAttribution(source, attribution, networkUserId) {
return this.adapty.updateAttribution({
source,
attribution,
networkUserId,
});
}
getPaywall(id, locale) {
return this.adapty.getPaywall({ id, locale });
}
getPaywallProducts(paywall) {
return this.adapty
.getPaywallProducts({ paywall })
.then(res => res.products);
}
logShowOnboarding(screenOrder, screenName, name) {
return this.adapty.logShowOnboarding({ screenOrder, screenName, name });
}
logShowPaywall(paywall) {
return this.adapty.logShowPaywall({ paywall });
}
setFallbackPaywalls(paywalls) {
return this.adapty.setFallbackPaywalls({ paywalls });
}
identify(customerUserId) {
return this.adapty.identify({ customerUserId });
}
updateProfile(params) {
return this.adapty.updateProfile({ params });
}
makePurchase(product) {
return this.adapty.makePurchase({ product });
}
setLogLevel(logLevel) {
return this.adapty.setLogLevel({ logLevel });
}
}
exports.Adapty = Adapty;
exports.AdaptyErrors = AdaptyErrors;
exports.isAdaptyError = isAdaptyError;
function __rest(s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
Object.defineProperty(exports, '__esModule', { value: true });
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
var e = new Error(message);
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
};
return exports;
const CamelToSnake = (str) => str.replace(/([A-Z])/g, g => '_' + g[0].toLowerCase());
const SnakeToCamel = (str) => str.replace(/(\_\w)/g, g => g[1].toUpperCase());
const toSnake = (input) => converter(input, 'CamelToSnake');
const toCamel = (input) => converter(input, 'SnakeToCamel');
function converter(input, type) {
let result;
if (typeof input === 'string')
result = stringParser(input, type);
if (isArray(input))
result = arrayParser(input, type);
if (isObject(input))
result = objectParser(input, type);
return result;
}
function stringParser(input, type) {
return {
CamelToSnake,
SnakeToCamel,
}[type](input);
}
function arrayParser(input, type) {
return input.map(item => {
if (isArray(item))
return arrayParser(item, type);
if (isObject(item))
return objectParser(item, type);
return item;
});
}
function objectParser(input, type) {
const result = {};
for (const property in input) {
const parsedKey = stringParser(property, type);
const value = input[property];
if (isArray(value)) {
result[parsedKey] = arrayParser(value, type);
}
else if (isObject(value)) {
result[parsedKey] = objectParser(value, type);
}
else {
result[parsedKey] = value;
}
}
return result;
}
function isObject(input) {
return typeof input === 'object' && (input === null || input === void 0 ? void 0 : input.constructor) === Object;
}
function isArray(input) {
return Array.isArray(input);
}
function decodeDiscountPhase(discountPhase) {
const { identifier, payment_mode } = discountPhase, rest = __rest(discountPhase, ["identifier", "payment_mode"]);
return Object.assign(Object.assign({}, toCamel(rest)), { paymentMode: payment_mode, ios: {
identifier,
} });
}
function decodeSubscriptionDetails(subscriptionDetails) {
var _a;
if (!subscriptionDetails)
return undefined;
const { introductory_offer_phases, promotional_offer, subscription_group_identifier } = subscriptionDetails, rest = __rest(subscriptionDetails, ["introductory_offer_phases", "promotional_offer", "subscription_group_identifier"]);
return Object.assign(Object.assign({}, toCamel(rest)), { introductoryOffers: (_a = subscriptionDetails.introductory_offer_phases) === null || _a === void 0 ? void 0 : _a.map(decodeDiscountPhase), ios: {
promotionalOffer: promotional_offer
? decodeDiscountPhase(promotional_offer)
: undefined,
subscriptionGroupIdentifier: subscription_group_identifier,
} });
}
function decodeProduct(product) {
const { is_family_shareable } = product, rest = __rest(product, ["is_family_shareable"]);
return Object.assign(Object.assign({}, toCamel(rest)), { subscriptionDetails: decodeSubscriptionDetails(product.subscription_details), ios: {
isFamilyShareable: is_family_shareable || false,
} });
}
function encodeProduct(product) {
var _a, _b, _c, _d;
return {
adapty_product_id: product.adaptyProductId,
paywall_ab_test_name: product.paywallAbTestName,
payload_data: product.payloadData,
paywall_name: product.paywallName,
paywall_variation_id: product.paywallVariationId,
promotional_offer_id: (_d = (_c = (_b = (_a = product.subscriptionDetails) === null || _a === void 0 ? void 0 : _a.ios) === null || _b === void 0 ? void 0 : _b.promotionalOffer) === null || _c === void 0 ? void 0 : _c.ios) === null || _d === void 0 ? void 0 : _d.identifier,
vendor_product_id: product.vendorProductId,
};
}
function decodeDate(date) {
if (!date)
return undefined;
return new Date(date);
}
/** Format: YYYY-MM-dd */
function encodeDate(date) {
const year = date.getFullYear();
const month = date.getMonth() + 1;
const day = date.getDate();
return [year, month, day].map(n => n.toString().padStart(2, '0')).join('-');
}
function decodeAccessLevel(accessLevel) {
const { activated_at, billing_issue_detected_at, expires_at, renewed_at, starts_at, unsubscribed_at, store, active_introductory_offer_type, active_promotional_offer_type, cancellation_reason } = accessLevel, rest = __rest(accessLevel, ["activated_at", "billing_issue_detected_at", "expires_at", "renewed_at", "starts_at", "unsubscribed_at", "store", "active_introductory_offer_type", "active_promotional_offer_type", "cancellation_reason"]);
return Object.assign(Object.assign({}, toCamel(rest)), { activatedAt: decodeDate(activated_at), billingIssueDetectedAt: decodeDate(billing_issue_detected_at), expiresAt: decodeDate(expires_at), renewedAt: decodeDate(renewed_at), startsAt: decodeDate(starts_at), unsubscribedAt: decodeDate(unsubscribed_at), store: store, activeIntroductoryOfferType: active_introductory_offer_type, activePromotionalOfferType: active_promotional_offer_type, cancellationReason: cancellation_reason });
}
function decodeNonSubscription(nonSubscription) {
const { purchased_at, store } = nonSubscription, rest = __rest(nonSubscription, ["purchased_at", "store"]);
return Object.assign(Object.assign({}, toCamel(rest)), { purchasedAt: decodeDate(purchased_at), store: store });
}
function decodeRecords(records, converter) {
return Object.entries(records).reduce((acc, [key, value]) => {
acc[key] = converter(value);
return acc;
}, {});
}
function decodeSubscription(subscription) {
const { activated_at, active_introductory_offer_type, active_promotional_offer_type, billing_issue_detected_at, cancellation_reason, expires_at, renewed_at, store, starts_at, unsubscribed_at } = subscription, rest = __rest(subscription, ["activated_at", "active_introductory_offer_type", "active_promotional_offer_type", "billing_issue_detected_at", "cancellation_reason", "expires_at", "renewed_at", "store", "starts_at", "unsubscribed_at"]);
return Object.assign(Object.assign({}, toCamel(rest)), { activatedAt: decodeDate(activated_at), activeIntroductoryOfferType: active_introductory_offer_type, activePromotionalOfferType: active_promotional_offer_type, billingIssueDetectedAt: decodeDate(billing_issue_detected_at), cancellationReason: cancellation_reason, expiresAt: decodeDate(expires_at), renewedAt: decodeDate(renewed_at), startsAt: decodeDate(starts_at), store: store, unsubscribedAt: decodeDate(unsubscribed_at) });
}
function decodeProfile(profile) {
const { paid_access_levels, custom_attributes, non_subscriptions, subscriptions } = profile, rest = __rest(profile, ["paid_access_levels", "custom_attributes", "non_subscriptions", "subscriptions"]);
return Object.assign(Object.assign({}, toCamel(rest)), { accessLevels: paid_access_levels
? decodeRecords(paid_access_levels, decodeAccessLevel)
: undefined, customAttributes: custom_attributes, nonSubscriptions: non_subscriptions
? decodeRecords(non_subscriptions, value => value.map(decodeNonSubscription))
: non_subscriptions, subscriptions: subscriptions
? decodeRecords(subscriptions, decodeSubscription)
: undefined });
}
function encodeProfileParameters(profile) {
const { birthday, customAttributes, pushwooshHWID, appTrackingTransparencyStatus, gender } = profile, rest = __rest(profile, ["birthday", "customAttributes", "pushwooshHWID", "appTrackingTransparencyStatus", "gender"]);
let _params = toSnake(rest);
let params = _params;
function hasProp(key) {
return Object.prototype.hasOwnProperty.call(profile, key);
}
if (hasProp('birthday')) {
params.birthday = birthday ? encodeDate(birthday) : undefined;
}
if (hasProp('gender')) {
params.gender = gender;
}
if (hasProp('customAttributes')) {
params.custom_attributes = customAttributes;
}
if (hasProp('appTrackingTransparencyStatus')) {
params.att_status = appTrackingTransparencyStatus;
}
if (hasProp('pushwooshHWID')) {
params.pushwoosh_hwid = pushwooshHWID;
}
console.log('updateProfile', profile, params);
return params;
}
function decodeSKPayment(payment) {
return toCamel(payment);
}
function decodeSKTransaction(transaction) {
const { payment, original } = transaction, rest = __rest(transaction, ["payment", "original"]);
return Object.assign(Object.assign({}, toCamel(rest)), { payment: decodeSKPayment(payment), original: original ? decodeSKTransaction(original) : undefined });
}
class PromiseQueue {
constructor() {
this.queue = [];
this.running = false;
}
async enqueue(task) {
const completionPromise = new Promise(resolve => {
const wrapped = async () => {
await task();
resolve();
};
this.queue.push(wrapped);
});
this.runQueue();
return completionPromise;
}
async runQueue() {
if (this.running)
return;
this.running = true;
while (this.queue.length > 0) {
const task = this.queue.shift();
if (task) {
await task();
}
await Promise.resolve();
}
this.running = false;
}
}
const VendorStore = Object.freeze({
AppStore: 'app_store',
PlayStore: 'play_store',
Adapty: 'adapty',
});
const OfferType = Object.freeze({
FreeTrial: 'free_trial',
PayAsYouGo: 'pay_as_you_go',
PayUpFront: 'pay_up_front',
Unknown: 'unknown',
});
const CancellationReason = Object.freeze({
VolountarilyCancelled: 'voluntarily_cancelled',
BillingError: 'billing_error',
Refund: 'refund',
PriceIncrease: 'price_increase',
ProductWasNotAvailable: 'product_was_not_available',
Unknown: 'unknown',
});
const Gender = Object.freeze({
Female: 'f',
Male: 'm',
Other: 'o',
});
const AppTrackingTransparencyStatus = Object.freeze({
NotDetermined: 0,
Restricted: 1,
Denied: 2,
Authorized: 3,
Unknown: 4,
});
const ProductPeriod = Object.freeze({
Day: 'day',
Week: 'week',
Month: 'month',
Year: 'year',
Unknown: 'unknown',
});
const OfferEligibility = Object.freeze({
Eligible: 'eligible',
Ineligible: 'ineligible',
NotApplicable: 'not_applicable',
});
const LogLevel = Object.freeze({
error: 'error',
warn: 'warn',
info: 'info',
verbose: 'verbose',
debug: 'debug',
});
const PaywallFetchPolicy = Object.freeze({
returnCacheDataElseLoad: 'return_cache_data_else_load',
reloadRevalidatingCacheData: 'reload_revalidating_cache_data',
default: 'default',
});
const AttributionNetwork = Object.freeze({
appsflyer: 'appsflyer',
adjust: 'adjust',
branch: 'branch',
custom: 'custom',
appleSearchAds: 'apple_search_ads',
});
const SKPaymentTransactionState = Object.freeze({
purchasing: 0, // Transaction is being added to the server queue.
purchased: 1, // Transaction is in queue, user has been charged. Client should complete the transaction.
failed: 2, // Transaction was cancelled or failed before being added to the server queue.
restored: 3, // Transaction was restored from user's purchase history. Client should complete the transaction.
deferred: 4, // The transaction is in the queue, but its final status is pending external action.
});
const AdaptyErrors = Object.freeze({
/**
* System StoreKit codes
*/
unknown: 0,
/**
* Client is not allowed to make a request, etc.
*/
clientInvalid: 1,
/**
* User cancelled the request, etc.
*/
paymentCancelled: 2,
/**
* Invalid purchase identifier, etc.
*/
paymentInvalid: 3,
/**
* This device is not allowed to make the payment.
*/
paymentNotAllowed: 4,
/**
* Product is not available in the current storefront.
*/
storeProductNotAvailable: 5,
/**
* User has not allowed access to cloud service information.
*/
cloudServicePermissionDenied: 6,
/**
* The device could not connect to the network.
*/
cloudServiceNetworkConnectionFailed: 7,
/**
* User has revoked permission to use this cloud service.
*/
cloudServiceRevoked: 8,
/**
* The user needs to acknowledge Apple's privacy policy.
*/
privacyAcknowledgementRequired: 9,
/**
* The app is attempting to use SKPayment's requestData property,
* but does not have the appropriate entitlement.
*/
unauthorizedRequestData: 10,
/**
* The specified subscription offer identifier is not valid.
*/
invalidOfferIdentifier: 11,
/**
* The cryptographic signature provided is not valid.
*/
invalidSignature: 12,
/**
* One or more parameters from SKPaymentDiscount is missing.
*/
missingOfferParams: 13,
invalidOfferPrice: 14,
noProductIDsFound: 1000,
productRequestFailed: 1002,
/**
* In-App Purchases are not allowed on this device.
*/
cantMakePayments: 1003,
noPurchasesToRestore: 1004,
cantReadReceipt: 1005,
productPurchaseFailed: 1006,
refreshReceiptFailed: 1010,
receiveRestoredTransactionsFailed: 1011,
/**
* Adapty SDK is not activated.
*/
notActivated: 2002,
badRequest: 2003,
serverError: 2004,
networkFailed: 2005,
decodingFailed: 2006,
encodingFailed: 2009,
analyticsDisabled: 3000,
/**
* Wrong parameter was passed.
*/
wrongParam: 3001,
/**
* It is not possible to call `.activate` method more than once.
*/
activateOnceError: 3005,
/**
* The user profile was changed during the operation.
*/
profileWasChanged: 3006,
persistingDataError: 3100,
operationInterrupted: 9000,
});
function isAdaptyError(error) {
return (typeof error === 'object' &&
'code' in error &&
'message' in error);
}
const CapacitorAdapty = core.registerPlugin('Adapty', {});
const LIB_VERSION = "4.0.1";
class Adapty {
constructor() {
this.adapty = CapacitorAdapty;
this.resolveActivation = null;
this.activatingPromise = new Promise(resolve => (this.resolveActivation = resolve));
// https://github.com/adaptyteam/AdaptySDK-React-Native/issues/66#issuecomment-1521638581
this.mutationalQueue = new PromiseQueue();
}
async awaitActivation() {
if (this.activatingPromise) {
await this.activatingPromise;
this.activatingPromise = null;
}
}
async activate(apiKey, options) {
const promise = this.adapty.activate(Object.assign({ apiKey, libVersion: LIB_VERSION }, options));
if (!this.activatingPromise) {
this.activatingPromise = promise;
}
const result = await promise;
if (this.resolveActivation) {
this.resolveActivation();
this.resolveActivation = null;
}
return result;
}
async updateAttribution(source, attribution, networkUserId) {
await this.awaitActivation();
return this.adapty.updateAttribution({
source,
attribution,
networkUserId,
});
}
async getPaywall(placementId, locale, options) {
await this.awaitActivation();
return this.adapty
.getPaywall(Object.assign({ placementId, locale }, options))
.then(res => decodePaywall(res.paywall));
}
async getPaywallProducts(paywall) {
await this.awaitActivation();
return this.adapty
.getPaywallProducts({ paywall: encodePaywall(paywall) })
.then(res => res.products.map(decodeProduct));
}
async getProductsIntroductoryOfferEligibility(vendorProductIds) {
await this.awaitActivation();
return this.adapty
.getProductsIntroductoryOfferEligibility({
vendorProductIds,
})
.then(res => res.eligibilities);
}
async logShowOnboarding(screenOrder, screenName, name) {
await this.awaitActivation();
return this.adapty.logShowOnboarding({ screenOrder, screenName, name });
}
async logShowPaywall(paywall) {
await this.awaitActivation();
return this.adapty.logShowPaywall({ paywall: encodePaywall(paywall) });
}
async setFallbackPaywalls(paywalls) {
await this.awaitActivation();
return this.adapty.setFallbackPaywalls({ paywalls });
}
async getProfile() {
await this.awaitActivation();
return this.adapty.getProfile().then(res => decodeProfile(res.profile));
}
async identify(customerUserId) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.identify({ customerUserId }));
}
async logout() {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.logout());
}
async updateProfile(params) {
await this.awaitActivation();
return this.mutationalQueue.enqueue(() => this.adapty.updateProfile({
params: encodeProfileParameters(params),
}));
}
async makePurchase(product) {
await this.awaitActivation();
return this.adapty
.makePurchase({ product: encodeProduct(product) })
.then(res => ({
profile: decodeProfile(res.purchase.profile),
transaction: res.purchase.transaction
? decodeSKTransaction(res.purchase.transaction)
: undefined,
}));
}
async presentCodeRedemptionSheet() {
await this.awaitActivation();
return this.adapty.presentCodeRedemptionSheet();
}
async restorePurchases() {
await this.awaitActivation();
return this.adapty
.restorePurchases()
.then(res => decodeProfile(res.profile));
}
async setLogLevel(logLevel) {
await this.awaitActivation();
return this.adapty.setLogLevel({ logLevel });
}
addListener(eventName, listenerFunc) {
{
switch (eventName) {
case 'onLatestProfileLoad':
return this.adapty.addListener(eventName, data => listenerFunc({ profile: decodeProfile(data.profile) }));
}
}
}
}
exports.Adapty = Adapty;
exports.AdaptyErrors = AdaptyErrors;
exports.AppTrackingTransparencyStatus = AppTrackingTransparencyStatus;
exports.AttributionNetwork = AttributionNetwork;
exports.CancellationReason = CancellationReason;
exports.Gender = Gender;
exports.LogLevel = LogLevel;
exports.OfferEligibility = OfferEligibility;
exports.OfferType = OfferType;
exports.PaywallFetchPolicy = PaywallFetchPolicy;
exports.ProductPeriod = ProductPeriod;
exports.SKPaymentTransactionState = SKPaymentTransactionState;
exports.VendorStore = VendorStore;
exports.isAdaptyError = isAdaptyError;
return exports;
})({}, capacitorExports);
//# sourceMappingURL=plugin.js.map
{
"name": "capacitor-adapty",
"version": "3.0.3",
"version": "4.0.1",
"description": "Adapty plugin for capacitor",

@@ -19,3 +19,3 @@ "main": "dist/plugin.cjs.js",

"swiftlint": "node-swiftlint",
"build": "npm run clean && tsc && rollup -c rollup.config.js",
"build": "npm run clean && rollup -c rollup.config.mjs",
"clean": "rimraf ./dist",

@@ -32,5 +32,7 @@ "watch": "tsc --watch",

"@capacitor/ios": "^5.0.0",
"@dotenv-run/rollup": "^1.3.4",
"@ionic/eslint-config": "^0.3.0",
"@ionic/prettier-config": "^1.0.1",
"@ionic/swiftlint-config": "^1.1.2",
"@rollup/plugin-node-resolve": "^15.2.3",
"eslint": "^7.11.0",

@@ -40,12 +42,12 @@ "prettier": "~2.3.0",

"rimraf": "^3.0.2",
"rollup": "^2.32.0",
"rollup": "^3.29.4",
"rollup-plugin-ts": "^3.4.5",
"swiftlint": "^1.0.1",
"typescript": "~4.1.5"
"typescript": "^5.4.2"
},
"peerDependencies": {
"@capacitor/core": "^5.0.0"
"@capacitor/core": ">=5",
"tslib": ">=2"
},
"files": [
"android/src/main/",
"android/build.gradle",
"dist/",

@@ -52,0 +54,0 @@ "ios/Plugin/",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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