@eluvio/elv-client-js 4.0.34 → 4.0.36
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
CHANGED
|
@@ -400,7 +400,27 @@ exports.ExchangeRate = async function({currency}) {
|
|
|
400
400
|
);
|
|
401
401
|
};
|
|
402
402
|
|
|
403
|
+
/**
|
|
404
|
+
* Retrieve custom CSS for the specified tenant
|
|
405
|
+
*
|
|
406
|
+
* @methodGroup Tenants
|
|
407
|
+
* @namedParams
|
|
408
|
+
* @param {Object} tenantSlug
|
|
409
|
+
*
|
|
410
|
+
* @returns {Promise<string>} - The CSS of the tenant
|
|
411
|
+
*/
|
|
412
|
+
exports.TenantCSS = async function ({tenantSlug}) {
|
|
413
|
+
if(!this.cachedCSS[tenantSlug]) {
|
|
414
|
+
this.cachedCSS[tenantSlug] = await this.client.ContentObjectMetadata({
|
|
415
|
+
libraryId: this.mainSiteLibraryId,
|
|
416
|
+
objectId: this.mainSiteId,
|
|
417
|
+
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", tenantSlug, "info", "branding", "wallet_css"),
|
|
418
|
+
authorizationToken: this.publicStaticToken
|
|
419
|
+
});
|
|
420
|
+
}
|
|
403
421
|
|
|
422
|
+
return this.cachedCSS[tenantSlug] || "";
|
|
423
|
+
};
|
|
404
424
|
|
|
405
425
|
/* MARKETPLACE */
|
|
406
426
|
|
|
@@ -1106,6 +1126,71 @@ exports.ClaimItem = async function({marketplaceParams, sku, email}) {
|
|
|
1106
1126
|
});
|
|
1107
1127
|
};
|
|
1108
1128
|
|
|
1129
|
+
/**
|
|
1130
|
+
* Redirect to the wallet app to purchase the specified item from the specified marketplace
|
|
1131
|
+
*
|
|
1132
|
+
* Use the <a href="#.PurchaseStatus">PurchaseStatus</a> method to check minting status after purchasing
|
|
1133
|
+
*
|
|
1134
|
+
* @methodGroup Purchase
|
|
1135
|
+
* @namedParams
|
|
1136
|
+
* @param {Object} marketplaceParams - Parameters of the marketplace
|
|
1137
|
+
* @param {string} sku - The SKU of the item to claim
|
|
1138
|
+
* @param {string=} confirmationId - Confirmation ID with which to reference this purchase. If not specified, a confirmation ID will be automatically generated. On success, the user will be returned to `successUrl` with the `confirmationId` as a URL parameter.
|
|
1139
|
+
* @param {string} successUrl - The URL to redirect back to upon successful purchase
|
|
1140
|
+
* @param {string} cancelUrl - The URL to redirect back to upon cancellation of purchase
|
|
1141
|
+
*/
|
|
1142
|
+
exports.PurchaseItem = async function({marketplaceParams, sku, confirmationId, successUrl, cancelUrl}) {
|
|
1143
|
+
const marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
1144
|
+
|
|
1145
|
+
window.location.href = this.FlowURL({
|
|
1146
|
+
type: "action",
|
|
1147
|
+
flow: "purchase",
|
|
1148
|
+
marketplaceId: marketplaceInfo.marketplaceId,
|
|
1149
|
+
parameters: {
|
|
1150
|
+
sku,
|
|
1151
|
+
confirmationId,
|
|
1152
|
+
successUrl,
|
|
1153
|
+
cancelUrl,
|
|
1154
|
+
login: true,
|
|
1155
|
+
auth: this.ClientAuthToken(),
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
};
|
|
1159
|
+
|
|
1160
|
+
/**
|
|
1161
|
+
* Redirect to the wallet app to purchase the specified listing
|
|
1162
|
+
*
|
|
1163
|
+
* Use the <a href="#.PurchaseStatus">ListingPurchaseStatus</a> method to check minting status after purchasing
|
|
1164
|
+
*
|
|
1165
|
+
* @methodGroup Purchase
|
|
1166
|
+
* @namedParams
|
|
1167
|
+
* @param {Object=} marketplaceParams - Parameters of the marketplace
|
|
1168
|
+
* @param {string} listingId - The SKU of the item to claim
|
|
1169
|
+
* @param {string=} confirmationId - Confirmation ID with which to reference this purchase. If not specified, a confirmation ID will be automatically generated. On success, the user will be returned to `successUrl` with the `confirmationId` as a URL parameter.
|
|
1170
|
+
* @param {string} successUrl - The URL to redirect back to upon successful purchase
|
|
1171
|
+
* @param {string} cancelUrl - The URL to redirect back to upon cancellation of purchase
|
|
1172
|
+
*/
|
|
1173
|
+
exports.PurchaseListing = async function({marketplaceParams, listingId, confirmationId, successUrl, cancelUrl}) {
|
|
1174
|
+
let marketplaceInfo;
|
|
1175
|
+
if(marketplaceParams) {
|
|
1176
|
+
marketplaceInfo = await this.MarketplaceInfo({marketplaceParams});
|
|
1177
|
+
}
|
|
1178
|
+
|
|
1179
|
+
window.location.href = this.FlowURL({
|
|
1180
|
+
type: "action",
|
|
1181
|
+
flow: "purchase",
|
|
1182
|
+
marketplaceId: marketplaceInfo && marketplaceInfo.marketplaceId,
|
|
1183
|
+
parameters: {
|
|
1184
|
+
listingId,
|
|
1185
|
+
confirmationId,
|
|
1186
|
+
successUrl,
|
|
1187
|
+
cancelUrl,
|
|
1188
|
+
login: true,
|
|
1189
|
+
auth: this.ClientAuthToken(),
|
|
1190
|
+
}
|
|
1191
|
+
});
|
|
1192
|
+
};
|
|
1193
|
+
|
|
1109
1194
|
/* MINTING STATUS */
|
|
1110
1195
|
|
|
1111
1196
|
/**
|
|
@@ -619,6 +619,19 @@ class ElvWalletClient {
|
|
|
619
619
|
});
|
|
620
620
|
}
|
|
621
621
|
|
|
622
|
+
FlowURL({type="flow", flow, marketplaceId, parameters={}}) {
|
|
623
|
+
const url = new URL(this.appUrl);
|
|
624
|
+
if(marketplaceId) {
|
|
625
|
+
url.hash = UrlJoin("/", type, flow, "marketplace", marketplaceId, Utils.B58(JSON.stringify(parameters)));
|
|
626
|
+
} else {
|
|
627
|
+
url.hash = UrlJoin("/", type, flow, Utils.B58(JSON.stringify(parameters)));
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
url.searchParams.set("origin", window.location.origin);
|
|
631
|
+
|
|
632
|
+
return url.toString();
|
|
633
|
+
}
|
|
634
|
+
|
|
622
635
|
|
|
623
636
|
// Internal loading methods
|
|
624
637
|
|
|
@@ -642,6 +655,7 @@ class ElvWalletClient {
|
|
|
642
655
|
noAuth: true,
|
|
643
656
|
select: [
|
|
644
657
|
"*/.",
|
|
658
|
+
"*/info/branding",
|
|
645
659
|
"*/marketplaces/*/.",
|
|
646
660
|
"*/marketplaces/*/info/tenant_id",
|
|
647
661
|
"*/marketplaces/*/info/tenant_name",
|
|
@@ -650,6 +664,7 @@ class ElvWalletClient {
|
|
|
650
664
|
"*/marketplaces/*/info/storefront/background_mobile"
|
|
651
665
|
],
|
|
652
666
|
remove: [
|
|
667
|
+
"*/info/branding/wallet_css",
|
|
653
668
|
"*/marketplaces/*/info/branding/custom_css"
|
|
654
669
|
]
|
|
655
670
|
});
|
|
@@ -736,6 +751,7 @@ class ElvWalletClient {
|
|
|
736
751
|
marketplaceSlug,
|
|
737
752
|
marketplaceId: objectId,
|
|
738
753
|
marketplaceHash: versionHash,
|
|
754
|
+
tenantBranding: (metadata[tenantSlug].info || {}).branding || {},
|
|
739
755
|
order: Configuration.__MARKETPLACE_ORDER.findIndex(slug => slug === marketplaceSlug)
|
|
740
756
|
};
|
|
741
757
|
|
|
@@ -805,6 +821,16 @@ class ElvWalletClient {
|
|
|
805
821
|
authorizationToken: this.publicStaticToken
|
|
806
822
|
});
|
|
807
823
|
|
|
824
|
+
if(marketplace.branding.use_tenant_styling) {
|
|
825
|
+
marketplace.tenantBranding = (await this.client.ContentObjectMetadata({
|
|
826
|
+
libraryId: this.mainSiteLibraryId,
|
|
827
|
+
objectId: this.mainSiteId,
|
|
828
|
+
metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "info", "branding"),
|
|
829
|
+
authorizationToken: this.publicStaticToken,
|
|
830
|
+
produceLinkUrls: true
|
|
831
|
+
})) || {};
|
|
832
|
+
}
|
|
833
|
+
|
|
808
834
|
marketplace.items = await Promise.all(
|
|
809
835
|
marketplace.items.map(async (item, index) => {
|
|
810
836
|
if(item.requires_permissions) {
|