@mission_sciences/provider-sdk 0.3.0-dev.31ea3d4 → 0.3.0
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/dist/adapters/vue/useMarketplaceSession.d.ts +0 -2
- package/dist/adapters/vue/useMarketplaceSession.d.ts.map +1 -1
- package/dist/core/MarketplaceSDK.d.ts +0 -6
- package/dist/core/MarketplaceSDK.d.ts.map +1 -1
- package/dist/marketplace-sdk.es.js +0 -64
- package/dist/marketplace-sdk.es.js.map +1 -1
- package/dist/marketplace-sdk.umd.js +1 -1
- package/dist/marketplace-sdk.umd.js.map +1 -1
- package/dist/types/index.d.ts +0 -32
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/core/PurchaseStateManager.d.ts +0 -28
- package/dist/core/PurchaseStateManager.d.ts.map +0 -1
|
@@ -22,7 +22,6 @@ export declare function useMarketplaceSession(options?: UseMarketplaceSessionOpt
|
|
|
22
22
|
getFormattedTime: () => string;
|
|
23
23
|
getFormattedTimeWithHours: () => string;
|
|
24
24
|
isTimerRunning: () => boolean;
|
|
25
|
-
getPurchaseStateManager: () => import('../../core/PurchaseStateManager').PurchaseStateManager;
|
|
26
25
|
destroy: () => void;
|
|
27
26
|
} | null, MarketplaceSDK | {
|
|
28
27
|
on: <K extends keyof import('../../types').SDKEvents>(event: K, handler: import('../../types').SDKEvents[K]) => void;
|
|
@@ -38,7 +37,6 @@ export declare function useMarketplaceSession(options?: UseMarketplaceSessionOpt
|
|
|
38
37
|
getFormattedTime: () => string;
|
|
39
38
|
getFormattedTimeWithHours: () => string;
|
|
40
39
|
isTimerRunning: () => boolean;
|
|
41
|
-
getPurchaseStateManager: () => import('../../core/PurchaseStateManager').PurchaseStateManager;
|
|
42
40
|
destroy: () => void;
|
|
43
41
|
} | null>;
|
|
44
42
|
session: import('vue').Ref<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useMarketplaceSession.d.ts","sourceRoot":"","sources":["../../../src/adapters/vue/useMarketplaceSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElG,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5E,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiE
|
|
1
|
+
{"version":3,"file":"useMarketplaceSession.d.ts","sourceRoot":"","sources":["../../../src/adapters/vue/useMarketplaceSession.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAElG,MAAM,WAAW,4BAA6B,SAAQ,IAAI,CAAC,SAAS,EAAE,OAAO,CAAC;IAC5E,cAAc,CAAC,EAAE,CAAC,OAAO,EAAE,mBAAmB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACxE,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,iBAAiB,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACpE,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAC5B;AAED,wBAAgB,qBAAqB,CAAC,OAAO,GAAE,4BAAiE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4F/G"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PurchaseStateManager } from './PurchaseStateManager';
|
|
2
1
|
import { SDKConfig, SDKEvents, SessionData } from '../types';
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -21,7 +20,6 @@ export declare class MarketplaceSDK {
|
|
|
21
20
|
private sessionData;
|
|
22
21
|
private jwtToken;
|
|
23
22
|
private endReason;
|
|
24
|
-
private purchaseStateManager;
|
|
25
23
|
constructor(config: SDKConfig);
|
|
26
24
|
/**
|
|
27
25
|
* Register event handlers
|
|
@@ -99,10 +97,6 @@ export declare class MarketplaceSDK {
|
|
|
99
97
|
* Check if timer is running
|
|
100
98
|
*/
|
|
101
99
|
isTimerRunning(): boolean;
|
|
102
|
-
/**
|
|
103
|
-
* Get purchase state manager for item purchase state checking
|
|
104
|
-
*/
|
|
105
|
-
getPurchaseStateManager(): PurchaseStateManager;
|
|
106
100
|
/**
|
|
107
101
|
* Cleanup and destroy SDK instance
|
|
108
102
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarketplaceSDK.d.ts","sourceRoot":"","sources":["../../src/core/MarketplaceSDK.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MarketplaceSDK.d.ts","sourceRoot":"","sources":["../../src/core/MarketplaceSDK.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAiG,MAAM,UAAU,CAAC;AAE5J;;;;;;;GAOG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAAgB;IACjC,OAAO,CAAC,KAAK,CAA6B;IAC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IzB;;OAEG;IACH,OAAO,IAAI,IAAI;CAgBhB"}
|
|
@@ -20,12 +20,6 @@ class SDKError extends Error {
|
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
var PurchaseState = /* @__PURE__ */ ((PurchaseState2) => {
|
|
24
|
-
PurchaseState2["AVAILABLE"] = "AVAILABLE";
|
|
25
|
-
PurchaseState2["PRIVY_REQUIRED"] = "PRIVY_REQUIRED";
|
|
26
|
-
PurchaseState2["INSUFFICIENT_FUNDS"] = "INSUFFICIENT_FUNDS";
|
|
27
|
-
return PurchaseState2;
|
|
28
|
-
})(PurchaseState || {});
|
|
29
23
|
class JWTParser {
|
|
30
24
|
/**
|
|
31
25
|
* Decode JWT payload without verification
|
|
@@ -2023,55 +2017,6 @@ class TabSyncManager {
|
|
|
2023
2017
|
this.logger.log("Tab sync destroyed");
|
|
2024
2018
|
}
|
|
2025
2019
|
}
|
|
2026
|
-
class PurchaseStateManager {
|
|
2027
|
-
constructor(config) {
|
|
2028
|
-
this.config = {
|
|
2029
|
-
timeout: 5e3,
|
|
2030
|
-
...config
|
|
2031
|
-
};
|
|
2032
|
-
}
|
|
2033
|
-
/**
|
|
2034
|
-
* Check purchase state for a specific item
|
|
2035
|
-
* Filters raw API response to expose only safe data to publisher apps
|
|
2036
|
-
*/
|
|
2037
|
-
async checkItemPurchaseState(itemId) {
|
|
2038
|
-
try {
|
|
2039
|
-
const response = await fetch(`${this.config.apiEndpoint}/items/${itemId}/purchase-state`, {
|
|
2040
|
-
method: "GET",
|
|
2041
|
-
headers: {
|
|
2042
|
-
"Content-Type": "application/json"
|
|
2043
|
-
},
|
|
2044
|
-
signal: AbortSignal.timeout(this.config.timeout)
|
|
2045
|
-
});
|
|
2046
|
-
if (!response.ok) {
|
|
2047
|
-
throw new Error(`API request failed: ${response.status} ${response.statusText}`);
|
|
2048
|
-
}
|
|
2049
|
-
const rawData = await response.json();
|
|
2050
|
-
return this.filterPurchaseStateResponse(rawData);
|
|
2051
|
-
} catch (error) {
|
|
2052
|
-
if (error instanceof Error) {
|
|
2053
|
-
throw error;
|
|
2054
|
-
}
|
|
2055
|
-
throw new Error("Unknown error occurred while checking purchase state");
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
/**
|
|
2059
|
-
* Filters raw API response to expose only safe data to publisher apps
|
|
2060
|
-
* CRITICAL: Raw privyEligibility map must NEVER be exposed to apps
|
|
2061
|
-
*/
|
|
2062
|
-
filterPurchaseStateResponse(rawResponse) {
|
|
2063
|
-
const filteredResponse = {
|
|
2064
|
-
state: rawResponse.state
|
|
2065
|
-
};
|
|
2066
|
-
if (rawResponse.state === PurchaseState.PRIVY_REQUIRED && rawResponse.privyEligibility) {
|
|
2067
|
-
const requiredLevels = Object.values(rawResponse.privyEligibility).filter((details) => details.requiresUpgrade).map((details) => details.requiredLevel);
|
|
2068
|
-
if (requiredLevels.length > 0) {
|
|
2069
|
-
filteredResponse.requiredLevel = Math.max(...requiredLevels);
|
|
2070
|
-
}
|
|
2071
|
-
}
|
|
2072
|
-
return filteredResponse;
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
2020
|
const lightTheme = {
|
|
2076
2021
|
colors: {
|
|
2077
2022
|
// Background
|
|
@@ -2592,9 +2537,6 @@ class MarketplaceSDK {
|
|
|
2592
2537
|
};
|
|
2593
2538
|
this.validator = new JWKSValidator(this.config.jwksUri, this.config.debug);
|
|
2594
2539
|
this.logger = new Logger(this.config.debug, "[MarketplaceSDK]");
|
|
2595
|
-
this.purchaseStateManager = new PurchaseStateManager({
|
|
2596
|
-
apiEndpoint: this.config.apiEndpoint
|
|
2597
|
-
});
|
|
2598
2540
|
this.logger.info("SDK initialized with config:", {
|
|
2599
2541
|
jwksUri: this.config.jwksUri,
|
|
2600
2542
|
jwtParamName: this.config.jwtParamName,
|
|
@@ -3104,12 +3046,6 @@ class MarketplaceSDK {
|
|
|
3104
3046
|
isTimerRunning() {
|
|
3105
3047
|
return this.timer?.isRunning() ?? false;
|
|
3106
3048
|
}
|
|
3107
|
-
/**
|
|
3108
|
-
* Get purchase state manager for item purchase state checking
|
|
3109
|
-
*/
|
|
3110
|
-
getPurchaseStateManager() {
|
|
3111
|
-
return this.purchaseStateManager;
|
|
3112
|
-
}
|
|
3113
3049
|
/**
|
|
3114
3050
|
* Cleanup and destroy SDK instance
|
|
3115
3051
|
*/
|