@cometh/checkout-sdk
Advanced tools
Comparing version 0.1.0-dev.3 to 0.1.0-dev.4
@@ -10,2 +10,3 @@ import { EventEmitter } from 'eventemitter3'; | ||
checkoutAppURI?: string; | ||
checkoutApiURI?: string; | ||
display?: DisplayMode; | ||
@@ -31,2 +32,7 @@ } | ||
declare enum CheckoutEvents { | ||
START = "checkoutStart", | ||
SUCCESS = "checkoutSuccess", | ||
FAILURE = "checkoutFailure" | ||
} | ||
interface CheckoutSuccess { | ||
@@ -57,13 +63,2 @@ transactionId: string; | ||
declare class UnauthorizedMethodError extends Error { | ||
constructor(methodName: string); | ||
} | ||
declare class RelayedTransactionPendingError extends Error { | ||
relayId: string; | ||
constructor(relayId: string); | ||
} | ||
declare class UnknownChainIdError extends Error { | ||
constructor(); | ||
} | ||
export { type CheckoutConfiguration, type CheckoutParameters, DisplayMode, RelayedTransactionPendingError, UnauthorizedMethodError, UnknownChainIdError, CheckoutSDK as default }; | ||
export { type CheckoutConfiguration, type CheckoutError, CheckoutEvents, type CheckoutParameters, type CheckoutSuccess, DisplayMode, CheckoutSDK as default }; |
@@ -60,5 +60,5 @@ var __defProp = Object.defineProperty; | ||
super(...arguments); | ||
__publicField(this, "_modalID", "modal-cometh-web-auth"); | ||
__publicField(this, "_modalID", "modal-cometh-web-checkout"); | ||
__publicField(this, "_modal", null); | ||
__publicField(this, "_iframeID", "cometh-web-auth"); | ||
__publicField(this, "_iframeID", "cometh-web-checkout"); | ||
__publicField(this, "_iframe", null); | ||
@@ -97,5 +97,9 @@ } | ||
} | ||
console.log("Creating iframe", this._modal); | ||
const iframe = document.createElement("iframe"); | ||
iframe.id = this._iframeID; | ||
iframe.allow = ""; | ||
iframe.sandbox.add("allow-forms"); | ||
iframe.sandbox.add("allow-scripts"); | ||
iframe.sandbox.add("allow-same-origin"); | ||
iframe.style.width = "100%"; | ||
@@ -139,4 +143,4 @@ iframe.style.height = "100%"; | ||
// src/core/app/popup.ts | ||
var POPUP_WIDTH = 420; | ||
var POPUP_HEIGHT = 540; | ||
var POPUP_WIDTH = 620; | ||
var POPUP_HEIGHT = 740; | ||
var Popup = class extends Embedded { | ||
@@ -155,3 +159,3 @@ constructor() { | ||
url, | ||
"Smart Wallet", | ||
"Smart Checkout", | ||
`width=${POPUP_WIDTH}, height=${POPUP_HEIGHT}, left=${left}, top=${top}` | ||
@@ -246,6 +250,2 @@ ); | ||
// src/constants.ts | ||
var CHECKOUT_APP_URI = "https://checkout-portal.cometh.io"; | ||
var CHECKOUT_API_URI = "https://checkout.cometh.io/v1"; | ||
// src/core/app/DisplayableFlow.ts | ||
@@ -262,4 +262,3 @@ var DisplayableFlow = class { | ||
user_wallet: parameters.user.walletAddress, | ||
user_email: parameters.user.email, | ||
checkout_api_url: CHECKOUT_API_URI | ||
user_email: parameters.user.email | ||
}); | ||
@@ -284,4 +283,14 @@ } | ||
// src/constants.ts | ||
var CHECKOUT_APP_URI = "https://checkout-portal.cometh.io"; | ||
var CHECKOUT_API_URI = "https://checkout.cometh.io/v1"; | ||
// src/core/events/types.ts | ||
import { EventEmitter } from "eventemitter3"; | ||
var CheckoutEvents = /* @__PURE__ */ ((CheckoutEvents2) => { | ||
CheckoutEvents2["START"] = "checkoutStart"; | ||
CheckoutEvents2["SUCCESS"] = "checkoutSuccess"; | ||
CheckoutEvents2["FAILURE"] = "checkoutFailure"; | ||
return CheckoutEvents2; | ||
})(CheckoutEvents || {}); | ||
var CheckoutEventEmitter = class extends EventEmitter { | ||
@@ -296,7 +305,11 @@ }; | ||
const checkoutAppURI = configuration?.checkoutAppURI || CHECKOUT_APP_URI; | ||
this.flow = new DisplayableFlow(configuration?.display || "iframe" /* IFRAME */, { | ||
const checkoutApiURI = configuration?.checkoutApiURI || CHECKOUT_API_URI; | ||
this.flow = new DisplayableFlow(configuration?.display || "popup" /* POPUP */, { | ||
authorizedOrigin: checkoutAppURI, | ||
defaultURL: buildURL( | ||
checkoutAppURI, | ||
{ checkout_api_key: encodeURIComponent(apiKey) } | ||
{ | ||
checkout_api_key: encodeURIComponent(apiKey), | ||
checkout_api_url: checkoutApiURI | ||
} | ||
) | ||
@@ -329,30 +342,8 @@ }); | ||
// src/core/errors/index.ts | ||
var UnauthorizedMethodError = class extends Error { | ||
constructor(methodName) { | ||
super(`Not authorized method: ${methodName}`); | ||
} | ||
}; | ||
var RelayedTransactionPendingError = class extends Error { | ||
constructor(relayId) { | ||
super( | ||
`The transaction has not been confirmed yet on the network, you can track its progress using its relayId:${relayId}` | ||
); | ||
this.relayId = relayId; | ||
} | ||
}; | ||
var UnknownChainIdError = class extends Error { | ||
constructor() { | ||
super("ChainID is null"); | ||
} | ||
}; | ||
// src/index.ts | ||
var src_default = CheckoutSDK; | ||
export { | ||
CheckoutEvents, | ||
DisplayMode, | ||
RelayedTransactionPendingError, | ||
UnauthorizedMethodError, | ||
UnknownChainIdError, | ||
src_default as default | ||
}; |
{ | ||
"name": "@cometh/checkout-sdk", | ||
"version": "0.1.0-dev.3", | ||
"version": "0.1.0-dev.4", | ||
"author": "Cometh", | ||
@@ -5,0 +5,0 @@ "description": "SDK Cometh Checkout", |
@@ -36,14 +36,14 @@ # Connect Checkout SDK | ||
```ts | ||
import {CheckoutSDK, CheckoutError, CheckoutSuccess} from '@cometh/checkout-sdk' | ||
import {CheckoutSDK, CheckoutError, CheckoutSuccess, CheckoutEvents} from '@cometh/checkout-sdk' | ||
const sdk = new CheckoutSDK(apiKey) | ||
sdk.on('start', () => { | ||
sdk.on(CheckoutEvents.START, () => { | ||
console.log('display is ON and flow has started'); | ||
}); | ||
sdk.on('success', (result: CheckoutSuccess) => { | ||
sdk.on(CheckoutEvents.SUCCESS, (result: CheckoutSuccess) => { | ||
}); | ||
sdk.on('failure', (error: CheckoutError) => { | ||
sdk.on(CheckoutEvents.FAILURE, (error: CheckoutError) => { | ||
}); | ||
``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
24048
709