@leisuresaas/react-native 0.6.12-dev.1 → 0.6.12-dev.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/errors.ts +16 -0
- package/src/index.ts +3 -0
- package/src/types.ts +87 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leisuresaas/react-native",
|
|
3
|
-
"version": "0.6.12-dev.
|
|
3
|
+
"version": "0.6.12-dev.3",
|
|
4
4
|
"description": "React Native SDK for LeisureSaas: OAuth, Public Ads/App Config, Drive User Plane (publishable keys). Frontend-only — no Integration Key.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
package/src/errors.ts
CHANGED
|
@@ -52,6 +52,22 @@ export const ErrorReason = {
|
|
|
52
52
|
OfferLimitReached: "OFFER_LIMIT_REACHED",
|
|
53
53
|
OfferNotFound: "OFFER_NOT_FOUND",
|
|
54
54
|
OfferRedemptionNotHeld: "OFFER_REDEMPTION_NOT_HELD",
|
|
55
|
+
// Targeted offers (R-1125-1 P3): for current or former subscribers only (on ios an Apple
|
|
56
|
+
// promotional offer also needs an App Store subscription before) / for the campaign's audience list
|
|
57
|
+
// only / web offers are new purchases and the workspace has an active paid subscription.
|
|
58
|
+
OfferNotASubscriber: "OFFER_NOT_A_SUBSCRIBER",
|
|
59
|
+
OfferNotInList: "OFFER_NOT_IN_LIST",
|
|
60
|
+
OfferAlreadySubscribed: "OFFER_ALREADY_SUBSCRIBED",
|
|
61
|
+
// Promo codes (R-1125-1 P4), from the BFF's ClaimOffer (and a code redeem in an Android app): the
|
|
62
|
+
// code is unknown, disabled or its campaign is not live / already used / too many invalid codes
|
|
63
|
+
// (429) / a code campaign claimed without redeeming a code (internal) / the iOS Apple code pool is
|
|
64
|
+
// empty / the code pool is for new iOS users only.
|
|
65
|
+
OfferCodeInvalid: "OFFER_CODE_INVALID",
|
|
66
|
+
OfferCodeAlreadyRedeemed: "OFFER_CODE_ALREADY_REDEEMED",
|
|
67
|
+
OfferCodeRateLimited: "OFFER_CODE_RATE_LIMITED",
|
|
68
|
+
OfferCodeRequired: "OFFER_CODE_REQUIRED",
|
|
69
|
+
OfferPoolExhausted: "OFFER_POOL_EXHAUSTED",
|
|
70
|
+
OfferAppleCodePoolNewUsersOnly: "OFFER_APPLE_CODE_POOL_NEW_USERS_ONLY",
|
|
55
71
|
// apple_intro claim: the product has no App Store In-App Purchase key.
|
|
56
72
|
StoreNotConfigured: "STORE_NOT_CONFIGURED",
|
|
57
73
|
// The token's workspace is no longer the user's active one: refresh the token, then retry.
|
package/src/index.ts
CHANGED
|
@@ -218,6 +218,7 @@ export type {
|
|
|
218
218
|
AdFeedRotation,
|
|
219
219
|
AdFeedSource,
|
|
220
220
|
AdsFeedResponse,
|
|
221
|
+
ApplePromotionalSignature,
|
|
221
222
|
AuthConfig,
|
|
222
223
|
ClaimOfferResult,
|
|
223
224
|
EnablePushOptions,
|
|
@@ -228,6 +229,8 @@ export type {
|
|
|
228
229
|
OfferBenefit,
|
|
229
230
|
OfferCampaign,
|
|
230
231
|
OfferList,
|
|
232
|
+
OfferCodeResult,
|
|
233
|
+
OfferCodeValidation,
|
|
231
234
|
OfferMethod,
|
|
232
235
|
OfferRedemption,
|
|
233
236
|
Plan,
|
package/src/types.ts
CHANGED
|
@@ -42,7 +42,8 @@ export type SubscriptionOffer = {
|
|
|
42
42
|
| "offer"
|
|
43
43
|
| "promo_code"
|
|
44
44
|
| "platform_offer"
|
|
45
|
-
| "stripe_trial"
|
|
45
|
+
| "stripe_trial"
|
|
46
|
+
| "stripe_coupon";
|
|
46
47
|
id?: string;
|
|
47
48
|
phase?: "" | "trial" | "intro";
|
|
48
49
|
phase_ends_at_unix?: number;
|
|
@@ -52,10 +53,33 @@ export type SubscriptionOffer = {
|
|
|
52
53
|
};
|
|
53
54
|
|
|
54
55
|
/**
|
|
55
|
-
* How an offer is used: `platform_grant` / `stripe_trial` (web), `google_offer`
|
|
56
|
-
* the Play offer), `apple_intro` (ios: buy with `ios.intro_eligibility_jws`)
|
|
56
|
+
* How an offer is used: `platform_grant` / `stripe_trial` / `stripe_coupon` (web), `google_offer`
|
|
57
|
+
* (android: buy with the Play offer), `apple_intro` (ios: buy with `ios.intro_eligibility_jws`),
|
|
58
|
+
* `apple_promotional` (ios: buy with `ios.promotional_offer_id` + signature or JWS and
|
|
59
|
+
* `appAccountToken = account_token`), `apple_offer_code_pool` (ios promo code for new users: redeemed
|
|
60
|
+
* on the product's website through `ios.redeem_url`, never in the app).
|
|
57
61
|
*/
|
|
58
|
-
export type OfferMethod =
|
|
62
|
+
export type OfferMethod =
|
|
63
|
+
| "platform_grant"
|
|
64
|
+
| "stripe_trial"
|
|
65
|
+
| "stripe_coupon"
|
|
66
|
+
| "google_offer"
|
|
67
|
+
| "apple_intro"
|
|
68
|
+
| "apple_promotional"
|
|
69
|
+
| "apple_offer_code_pool";
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Classic Apple promotional offer signature (`ios.promotional_signature`), for
|
|
73
|
+
* `promotionalOffer(offerID:keyID:nonce:signature:timestamp:)`. Valid 24 hours, single use.
|
|
74
|
+
*/
|
|
75
|
+
export type ApplePromotionalSignature = {
|
|
76
|
+
key_id: string;
|
|
77
|
+
/** Lowercase UUID. */
|
|
78
|
+
nonce: string;
|
|
79
|
+
timestamp_ms: number;
|
|
80
|
+
/** Base64. */
|
|
81
|
+
signature: string;
|
|
82
|
+
};
|
|
59
83
|
|
|
60
84
|
export type OfferBenefit = {
|
|
61
85
|
type: "free_days" | "percent_off" | "amount_off";
|
|
@@ -90,8 +114,32 @@ export type Offer = {
|
|
|
90
114
|
held_until_unix?: number;
|
|
91
115
|
price_id?: string;
|
|
92
116
|
android?: { package_name?: string; store_product_id: string; base_plan_id: string; offer_id: string };
|
|
93
|
-
/** `intro_eligibility_jws`
|
|
94
|
-
ios?: {
|
|
117
|
+
/** `intro_eligibility_jws`, `promotional_signature` and `promotional_offer_jws` are set on claims only. */
|
|
118
|
+
ios?: {
|
|
119
|
+
bundle_id?: string;
|
|
120
|
+
store_product_id: string;
|
|
121
|
+
intro_eligibility_jws?: string;
|
|
122
|
+
/** apple_promotional: the promotional offer identifier in App Store Connect. */
|
|
123
|
+
promotional_offer_id?: string;
|
|
124
|
+
promotional_signature?: ApplePromotionalSignature;
|
|
125
|
+
/** apple_promotional: for `promotionalOffer(_:compactJWS:)`. */
|
|
126
|
+
promotional_offer_jws?: string;
|
|
127
|
+
/** apple_offer_code_pool code redeem only (on the website): App Store link for `apple_code`. */
|
|
128
|
+
redeem_url?: string;
|
|
129
|
+
apple_code?: string;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* Claims on ios / android: the user's fixed account token for the product (lowercase UUID). Pass it
|
|
133
|
+
* as Apple `appAccountToken` / Google `obfuscatedAccountId` on every purchase.
|
|
134
|
+
*/
|
|
135
|
+
account_token?: string;
|
|
136
|
+
/**
|
|
137
|
+
* `code` = a promo code campaign. It is listed only while the user holds a redemption from a code
|
|
138
|
+
* redeemed on the website; claim it as usual.
|
|
139
|
+
*/
|
|
140
|
+
entry?: "automatic" | "code";
|
|
141
|
+
/** Promo code campaigns: the code the user redeemed, masked ("SPRING-••••-••••-PT"). Show as a hint. */
|
|
142
|
+
code?: { display: string };
|
|
95
143
|
};
|
|
96
144
|
|
|
97
145
|
/** `GET /v1/billing/offers` response. */
|
|
@@ -118,6 +166,39 @@ export type OfferRedemption = {
|
|
|
118
166
|
created_at_unix?: number;
|
|
119
167
|
used_at_unix?: number;
|
|
120
168
|
released_at_unix?: number;
|
|
169
|
+
/** Promo code campaigns: the code redeemed and its masked display. */
|
|
170
|
+
code_id?: string;
|
|
171
|
+
code_display?: string;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* One platform's answer for a promo code (`POST /v1/billing/offers/codes/validate`, for an Android
|
|
176
|
+
* app that lets users enter codes). `redeem_on` is ios only: `web` (Apple code pool link on the
|
|
177
|
+
* website) or `app` (redeem on the website, then claim in the app).
|
|
178
|
+
*/
|
|
179
|
+
export type OfferCodeResult = {
|
|
180
|
+
eligible: boolean;
|
|
181
|
+
reason?: string | null;
|
|
182
|
+
method?: OfferMethod | null;
|
|
183
|
+
redeem_on?: "web" | "app";
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Validate response as the BFF passes it through from sdk/go `ValidateOfferCode`. Always 200: an
|
|
188
|
+
* unusable code is `eligible: false` with a `reason`. With `platform` the top-level fields are that
|
|
189
|
+
* platform's; `code`, `campaign`, `plan_ids`, `platforms` are absent for `OFFER_CODE_INVALID`. Do not
|
|
190
|
+
* add a code field to an iOS app (App Store 3.1.1); iOS users enter codes on the website.
|
|
191
|
+
*/
|
|
192
|
+
export type OfferCodeValidation = {
|
|
193
|
+
eligible?: boolean;
|
|
194
|
+
reason?: string | null;
|
|
195
|
+
platform?: "web" | "ios" | "android";
|
|
196
|
+
method?: OfferMethod | null;
|
|
197
|
+
redeem_on?: "web" | "app";
|
|
198
|
+
code?: { display: string; kind: "single_use" | "shared"; expires_at_unix?: number };
|
|
199
|
+
campaign?: OfferCampaign;
|
|
200
|
+
plan_ids?: string[];
|
|
201
|
+
platforms?: { web?: OfferCodeResult; ios?: OfferCodeResult; android?: OfferCodeResult };
|
|
121
202
|
};
|
|
122
203
|
|
|
123
204
|
/** `POST /v1/billing/offers/claim` response; `subscription` is set for `platform_grant`. */
|