@getvolume/volume-shared
Advanced tools
Comparing version 0.0.18-canary.dfa2749 to 0.0.18
@@ -0,34 +1,8 @@ | ||
import { z } from 'zod'; | ||
interface IVolumeContext { | ||
/** | ||
* Your Application Id as provided in your Merchant Portal. (For BETA merchants please contact us directly for your ID.) | ||
*/ | ||
applicationId: string; | ||
/** | ||
* Volume Environment to target | ||
* Accepted values: 'live'|'sandbox'| String | ||
* Use 'live' or 'sandbox' for the respective api URLs | ||
* | ||
* DEFAULT = 'live' | ||
* | ||
* Any other String will be used as the API Base URL | ||
* ie: http://betmate-dev-getvolume.eu-central-1.elasticbeanstalk.com/api/ | ||
*/ | ||
volumeEnvironment?: VolumeEnvironment; | ||
/** | ||
* Function to subscribe to component events | ||
*/ | ||
onEvent?: (event: VolumeEvent) => void; | ||
/** | ||
* Enabling this flag will extend the device installed banks with sandbox bank selections that will open in the device web browser. | ||
* | ||
* Currently configured for this are: | ||
* | ||
* modelo-sandbox, natwest-sandbox | ||
* | ||
* DEFAULT = true | ||
*/ | ||
showSandboxBanks?: boolean; | ||
/** | ||
* Enable experimental features | ||
*/ | ||
featureFlags?: FeatureFlags; | ||
@@ -44,47 +18,13 @@ } | ||
type VolumeEnvironment = "live" | "sandbox" | "integration" | (string & {}); | ||
/** | ||
* Passed as the only parameter to the `onEvent` function given to the `VolumeProvider` | ||
*/ | ||
interface VolumeEvent { | ||
/** | ||
* Enum of unique event types | ||
*/ | ||
type: VolumeEventType; | ||
/** | ||
* Unix timestamp | ||
*/ | ||
time: number; | ||
/** | ||
* Event specific meta | ||
*/ | ||
meta?: object; | ||
} | ||
/** | ||
* Unique Enum values for the `type` property of VolumeEvents | ||
*/ | ||
declare enum VolumeEventType { | ||
/** | ||
* Called when Volume button is clicked initiating the create payment request to the Volume API | ||
*/ | ||
PaymentInitiated = "PAYMENT_INITIATED", | ||
/** | ||
* Called when AUTHORIZE_SINGLE_DOMESTIC_PAYMENT is returned by the volume api, this occurs when a single domestic payment is successfully authorized | ||
*/ | ||
PaymentAuthorizedSDP = "PAYMENT_AUTHORIZED_SDP", | ||
/** | ||
* Called when payment response was not a successful authorization | ||
*/ | ||
PaymentError = "PAYMENT_ERROR", | ||
/** | ||
* Something went wrong! | ||
*/ | ||
GenericError = "GENERIC_ERROR", | ||
/** | ||
* When the first device payment is made no shopperId exists on the device local storage, | ||
* this event is called when the shopperId is set from the value returned from the API in the first successful payment request | ||
*/ | ||
SetShoppedId = "SET_SHOPPER_ID", | ||
/** | ||
* If the device used for the request is not supported. | ||
*/ | ||
SupportedDevice = "SUPPORTED_DEVICE", | ||
@@ -97,10 +37,4 @@ InstitutionsFetched = "INSTITUTIONS_FETCHED", | ||
BankLaunchedLoaded = "BANK_LAUNCHED_LOADED", | ||
/** | ||
* Called when Volume component rendered in a desktop mode and payment id is generated | ||
*/ | ||
PaymentIdGenerated = "PAYMENT_ID_GENERATED" | ||
} | ||
/** | ||
* Object of keys with boolean values to determine feature flag status | ||
*/ | ||
type FeatureFlags = object; | ||
@@ -120,2 +54,7 @@ interface Institution { | ||
sortingIndex: number; | ||
primaryColorHex: string; | ||
secondaryColorHex: string; | ||
secondaryContrastColorHex: string; | ||
andoidPackageName: string; | ||
iosPackageName: string; | ||
} | ||
@@ -185,3 +124,3 @@ interface Country { | ||
response?: T; | ||
error?: any; | ||
error?: unknown; | ||
} | ||
@@ -192,4 +131,4 @@ declare class VolumeError extends Error { | ||
value: string; | ||
}; | ||
httpErrorMessage?: ErrorMessage; | ||
} | undefined; | ||
httpErrorMessage?: ErrorMessage | undefined; | ||
type: string; | ||
@@ -199,3 +138,3 @@ constructor(msg: string, context?: { | ||
value: string; | ||
}, httpErrorMessage?: ErrorMessage); | ||
} | undefined, httpErrorMessage?: ErrorMessage | undefined); | ||
} | ||
@@ -220,4 +159,17 @@ declare enum VolumeErrorContextType { | ||
type Storage = z.RecordType<string, z.ZodTypeAny>; | ||
declare class LocalStorageHandler<TStorage extends Storage> { | ||
private schema; | ||
constructor(schema: TStorage); | ||
private hasWindow; | ||
private hasLocalStorage; | ||
hasLocalStorageAvailable(): boolean; | ||
private getItem; | ||
private setItem; | ||
getItemSafely<TKey extends keyof TStorage>(key: TKey): TStorage[TKey]["_output"] | null; | ||
setItemSafely<TKey extends keyof TStorage>(key: TKey, value: TStorage[TKey]["_output"]): boolean; | ||
} | ||
declare const numberToCurrency: (number: number) => string; | ||
export { AgentType, Endpoints, type ErrorMessage, type FeatureFlags, INTEGRATION_API_URL, type IVolumeContext, type Institution, type InstitutionMetadata, LIVE_API_URL, LOCAL_API_URL, type Payment, type PaymentRequest, PaymentStatus, type PaymentStatusMetadata, type PaymentStatusResponse, type ResponseWrapper, SANDBOX_API_URL, type UseVolume, type VolumeEnvironment, VolumeError, VolumeErrorContextType, type VolumeEvent, VolumeEventType, apiUrlFromVolumeEnvironment, numberToCurrency }; | ||
export { AgentType, Endpoints, type ErrorMessage, type FeatureFlags, INTEGRATION_API_URL, type IVolumeContext, type Institution, type InstitutionMetadata, LIVE_API_URL, LOCAL_API_URL, LocalStorageHandler, type Payment, type PaymentRequest, PaymentStatus, type PaymentStatusMetadata, type PaymentStatusResponse, type ResponseWrapper, SANDBOX_API_URL, type UseVolume, type VolumeEnvironment, VolumeError, VolumeErrorContextType, type VolumeEvent, VolumeEventType, apiUrlFromVolumeEnvironment, numberToCurrency }; |
@@ -1,1 +0,1 @@ | ||
var s=Object.defineProperty;var N=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var L=(t,r)=>{for(var n in r)s(t,n,{get:r[n],enumerable:!0})},l=(t,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of T(r))!_.call(t,o)&&o!==n&&s(t,o,{get:()=>r[o],enumerable:!(i=N(r,o))||i.enumerable});return t};var P=t=>l(s({},"__esModule",{value:!0}),t);var O={};L(O,{AgentType:()=>A,Endpoints:()=>R,INTEGRATION_API_URL:()=>m,LIVE_API_URL:()=>I,LOCAL_API_URL:()=>p,PaymentStatus:()=>d,SANDBOX_API_URL:()=>E,VolumeError:()=>c,VolumeErrorContextType:()=>g,VolumeEventType:()=>u,apiUrlFromVolumeEnvironment:()=>D,numberToCurrency:()=>x});module.exports=P(O);var u=(e=>(e.PaymentInitiated="PAYMENT_INITIATED",e.PaymentAuthorizedSDP="PAYMENT_AUTHORIZED_SDP",e.PaymentError="PAYMENT_ERROR",e.GenericError="GENERIC_ERROR",e.SetShoppedId="SET_SHOPPER_ID",e.SupportedDevice="SUPPORTED_DEVICE",e.InstitutionsFetched="INSTITUTIONS_FETCHED",e.CancelUrlFetched="CANCEL_URL_FETCHED",e.ConfirmPageLoaded="CONFIRM_PAGE_LOADED",e.BankSelectionLoaded="BANK_SELECTION_LOADED",e.AwaitingAuthorisation="AWAITING_AUTHORISATION",e.BankLaunchedLoaded="BANK_LAUNCHED_LOADED",e.PaymentIdGenerated="PAYMENT_ID_GENERATED",e))(u||{}),A=(n=>(n.WEB_BROWSER="WEB_BROWSER",n.MOBILE_APPLICATION="MOBILE_APPLICATION",n))(A||{}),d=(a=>(a.NEW="NEW",a.AWAITING_AUTHORIZATION="AWAITING_AUTHORIZATION",a.AUTHORIZED="AUTHORIZED",a.PENDING="PENDING",a.COMPLETED="COMPLETED",a.SETTLED="SETTLED",a.FAILED="FAILED",a.UNDEFINED="UNDEFINED",a))(d||{}),c=class t extends Error{constructor(n,i,o){super(n);this.context=i;this.httpErrorMessage=o;Object.setPrototypeOf(this,t.prototype)}type="VolumeError"},g=(r=>(r.HTTP_CALL="HTTP_CALL",r))(g||{});var p="http://localhost:8080",I="https://api.volumepay.io",E="https://api.sandbox.volumepay.io",m="https://api.integration.volumepay.io",R={AUTHENTICATE:"/api/authenticate",INSTITUTIONS:"/api/institutions",CREATE_PAYMENT:"/api/payments",PAYMENT_STATUS:"/api/payments/{0}/status",CANCEL_URL:"/api/merchants/applications/{0}/cancel-url"};var D=t=>{switch(t){case"integration":return m;case"live":return I;case"sandbox":return E;case"local":return p;default:return t}};var x=t=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",minimumFractionDigits:2}).format(t);0&&(module.exports={AgentType,Endpoints,INTEGRATION_API_URL,LIVE_API_URL,LOCAL_API_URL,PaymentStatus,SANDBOX_API_URL,VolumeError,VolumeErrorContextType,VolumeEventType,apiUrlFromVolumeEnvironment,numberToCurrency}); | ||
"use strict";var i=Object.defineProperty;var f=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var T=Object.prototype.hasOwnProperty;var N=(r,e)=>{for(var t in e)i(r,t,{get:e[t],enumerable:!0})},_=(r,e,t,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of A(e))!T.call(r,o)&&o!==t&&i(r,o,{get:()=>e[o],enumerable:!(a=f(e,o))||a.enumerable});return r};var S=r=>_(i({},"__esModule",{value:!0}),r);var x={};N(x,{AgentType:()=>I,Endpoints:()=>L,INTEGRATION_API_URL:()=>d,LIVE_API_URL:()=>u,LOCAL_API_URL:()=>p,LocalStorageHandler:()=>l,PaymentStatus:()=>E,SANDBOX_API_URL:()=>m,VolumeError:()=>c,VolumeErrorContextType:()=>h,VolumeEventType:()=>g,apiUrlFromVolumeEnvironment:()=>y,numberToCurrency:()=>P});module.exports=S(x);var g=(n=>(n.PaymentInitiated="PAYMENT_INITIATED",n.PaymentAuthorizedSDP="PAYMENT_AUTHORIZED_SDP",n.PaymentError="PAYMENT_ERROR",n.GenericError="GENERIC_ERROR",n.SetShoppedId="SET_SHOPPER_ID",n.SupportedDevice="SUPPORTED_DEVICE",n.InstitutionsFetched="INSTITUTIONS_FETCHED",n.CancelUrlFetched="CANCEL_URL_FETCHED",n.ConfirmPageLoaded="CONFIRM_PAGE_LOADED",n.BankSelectionLoaded="BANK_SELECTION_LOADED",n.AwaitingAuthorisation="AWAITING_AUTHORISATION",n.BankLaunchedLoaded="BANK_LAUNCHED_LOADED",n.PaymentIdGenerated="PAYMENT_ID_GENERATED",n))(g||{}),I=(t=>(t.WEB_BROWSER="WEB_BROWSER",t.MOBILE_APPLICATION="MOBILE_APPLICATION",t))(I||{}),E=(s=>(s.NEW="NEW",s.AWAITING_AUTHORIZATION="AWAITING_AUTHORIZATION",s.AUTHORIZED="AUTHORIZED",s.PENDING="PENDING",s.COMPLETED="COMPLETED",s.SETTLED="SETTLED",s.FAILED="FAILED",s.UNDEFINED="UNDEFINED",s))(E||{}),c=class r extends Error{constructor(t,a,o){super(t);this.context=a;this.httpErrorMessage=o;this.type="VolumeError";Object.setPrototypeOf(this,r.prototype)}},h=(e=>(e.HTTP_CALL="HTTP_CALL",e))(h||{});var p="http://localhost:8080",u="https://api.volumepay.io",m="https://api.sandbox.volumepay.io",d="https://api.integration.volumepay.io",L={AUTHENTICATE:"/api/authenticate",INSTITUTIONS:"/api/institutions",CREATE_PAYMENT:"/api/payments",PAYMENT_STATUS:"/api/payments/{0}/status",CANCEL_URL:"/api/merchants/applications/{0}/cancel-url"};var y=r=>{switch(r){case"integration":return d;case"live":return u;case"sandbox":return m;case"local":return p;default:return r}};var l=class{constructor(e){this.schema=e}hasWindow(){return typeof window!="undefined"}hasLocalStorage(){return this.hasWindow()?typeof window.localStorage!="undefined":!1}hasLocalStorageAvailable(){if(!this.hasWindow()||!this.hasLocalStorage())return!1;try{return window.localStorage.getItem("test"),!0}catch(e){return console.log("[@getvolume/volume-shared] Local storage is not available"),!1}}getItem(e){return this.hasLocalStorageAvailable()?window.localStorage.getItem(e):null}setItem(e,t){return this.hasLocalStorageAvailable()?window.localStorage.setItem(e,t):null}getItemSafely(e){if(!this.schema[e])return null;let t=this.getItem(e);if(!t)return null;if(this.schema[e]._def.typeName==="ZodString"){let a=this.schema[e].safeParse(t);return a.success?a.data:null}if(this.schema[e]._def.typeName==="ZodObject"){try{let a=this.schema[e].safeParse(JSON.parse(t));if(a.success)return a.data}catch(a){return null}return null}throw new Error(`Invalid schema type value ${this.schema[e]._def.typeName}, supported types are ZodString and ZodObject`)}setItemSafely(e,t){if(!this.schema[e])return!1;let a=this.schema[e].safeParse(t);if(a.success){if(this.schema[e]._def.typeName==="ZodString")this.setItem(e,a.data);else if(this.schema[e]._def.typeName==="ZodObject")this.setItem(e,JSON.stringify(a.data));else throw new Error(`Invalid schema type value ${this.schema[e]._def.typeName}, supported types are ZodString and ZodObject`);return!0}return!1}};var P=r=>new Intl.NumberFormat("en-GB",{style:"currency",currency:"GBP",minimumFractionDigits:2}).format(r);0&&(module.exports={AgentType,Endpoints,INTEGRATION_API_URL,LIVE_API_URL,LOCAL_API_URL,LocalStorageHandler,PaymentStatus,SANDBOX_API_URL,VolumeError,VolumeErrorContextType,VolumeEventType,apiUrlFromVolumeEnvironment,numberToCurrency}); |
{ | ||
"name": "@getvolume/volume-shared", | ||
"version": "0.0.18-canary.dfa2749", | ||
"version": "0.0.18", | ||
"license": "MIT", | ||
@@ -19,9 +19,14 @@ "files": [ | ||
"devDependencies": { | ||
"tsup": "^8.0.2" | ||
"tsup": "^8.0.2", | ||
"vitest": "^2.0.4" | ||
}, | ||
"dependencies": { | ||
"zod": "^3.23.8" | ||
}, | ||
"scripts": { | ||
"build": "tsup", | ||
"dev": "pnpm build --watch", | ||
"test": "vitest run", | ||
"clean": "rm -rf dist .turbo" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
18872
1
2
192
+ Addedzod@^3.23.8
+ Addedzod@3.24.1(transitive)