@spritz-finance/api-client 0.4.7 → 0.4.9
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/README.md +35 -0
- package/dist/spritz-api-client.cjs +2 -2
- package/dist/spritz-api-client.d.ts +8 -5
- package/dist/spritz-api-client.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -974,6 +974,10 @@ Spritz currently supports the following webhook events:
|
|
|
974
974
|
- `payment.completed`: Triggered when a payment is successfully completed.
|
|
975
975
|
- `payment.refunded`: Triggered when a payment is refunded.
|
|
976
976
|
|
|
977
|
+
#### Verification Events
|
|
978
|
+
|
|
979
|
+
- `verification.status.updated`: Triggered when a user's verification status changes.
|
|
980
|
+
|
|
977
981
|
These events allow you to respond to changes in the account and payments for a user.
|
|
978
982
|
|
|
979
983
|
### Setting up webhooks
|
|
@@ -999,3 +1003,34 @@ Upon receiving a webhook, your server will get a payload with the following stru
|
|
|
999
1003
|
"eventName": "name-of-the-event-here"
|
|
1000
1004
|
}
|
|
1001
1005
|
```
|
|
1006
|
+
|
|
1007
|
+
### Webhook security and signing
|
|
1008
|
+
|
|
1009
|
+
Each webhook request is signed using an HMAC SHA256 signature, based on the exact JSON payload sent in the body. This signature is included in the Signature HTTP header of the request.
|
|
1010
|
+
|
|
1011
|
+
The secret key used to compute the signature is the webhook secret you set when configuring your webhook integration. If you have not set a webhook secret, there will be no Signature header in the webhook request.
|
|
1012
|
+
|
|
1013
|
+
You can verify webhook authenticity by computing the HMAC signature and comparing it to the Signature header included in the webhook request.
|
|
1014
|
+
|
|
1015
|
+
#### Example: Verifying a webhook signature (Node.js)
|
|
1016
|
+
|
|
1017
|
+
```typescript
|
|
1018
|
+
import { createHmac } from "crypto";
|
|
1019
|
+
|
|
1020
|
+
const signature = createHmac("sha256", <YOUR_WEBHOOK_SECRET>)
|
|
1021
|
+
.update(<REQUEST_BODY_AS_JSON_STRING>) // JSON.stringify(payload)
|
|
1022
|
+
.digest("hex");
|
|
1023
|
+
```
|
|
1024
|
+
|
|
1025
|
+
Ensure that the computed signature matches the Signature header received in the webhook request before processing the payload.
|
|
1026
|
+
|
|
1027
|
+
### Setting webhook secret
|
|
1028
|
+
|
|
1029
|
+
To add or update a webhook secret for signing webhook requests:
|
|
1030
|
+
|
|
1031
|
+
```typescript
|
|
1032
|
+
const result = await client.webhook.updateWebhookSecret('your-webhook-secret-here')
|
|
1033
|
+
// Returns: { success: true }
|
|
1034
|
+
```
|
|
1035
|
+
|
|
1036
|
+
This secret will be used to sign all subsequent webhook requests sent to your endpoint. Always store your webhook secret securely and never expose it in client-side code.
|
|
@@ -513,7 +513,7 @@ query CurrentUser {
|
|
|
513
513
|
...VerificationFragment
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var pv={};function hv(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return pv[t]?!1:(pv[t]=!0,!0)})}En.definitions=En.definitions.concat(hv(sr.definitions)),En.definitions=En.definitions.concat(hv(su.definitions));function lr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){lr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){lr(i,n)}),e.definitions&&e.definitions.forEach(function(i){lr(i,n)})}var $s={};(function(){En.definitions.forEach(function(n){if(n.name){var t=new Set;lr(n,t),$s[n.name.value]=t}})})();function gv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Ub(e,n){var t={kind:e.kind,definitions:[gv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=$s[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=$s[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=gv(e,o);s&&t.definitions.push(s)}),t}Ub(En,"CurrentUser");var Pb=(e=>(e.NotStarted="
|
|
516
|
+
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var pv={};function hv(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return pv[t]?!1:(pv[t]=!0,!0)})}En.definitions=En.definitions.concat(hv(sr.definitions)),En.definitions=En.definitions.concat(hv(su.definitions));function lr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){lr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){lr(i,n)}),e.definitions&&e.definitions.forEach(function(i){lr(i,n)})}var $s={};(function(){En.definitions.forEach(function(n){if(n.name){var t=new Set;lr(n,t),$s[n.name.value]=t}})})();function gv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Ub(e,n){var t={kind:e.kind,definitions:[gv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=$s[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=$s[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=gv(e,o);s&&t.definitions.push(s)}),t}Ub(En,"CurrentUser");var Pb=(e=>(e.NotStarted="not_started",e.Verified="verified",e.Failed="failed",e.Disabled="disabled",e))(Pb||{});function jb(e=nt.INITIALIZED){switch(e){case nt.FAILED:return"failed";case nt.ACTIVE:return"verified";case nt.DISABLED:return"disabled";case nt.RETRY:return"failed";default:return"not_started"}}function Rb(e){const n=e?.me??null;if(!n)return null;const t=e?.verification??null;return{...n,verificationStatus:jb(t?.identity?.status),verificationUrl:t?.identity?.verificationUrl??null,verifiedCountry:t?.identity?.country??null,canRetryVerification:t?.identity?.canRetry??!1}}class Lb{client;constructor(n){this.client=n}async createUser(n){return this.client.request({method:"post",path:"/users/integration",body:n})}async create(n){return this.createUser(n)}async requestApiKey(n){return this.client.request({method:"post",path:"/users/request-key",body:{email:n}})}async authorizeApiKeyWithOTP(n){return this.client.request({method:"post",path:"/users/validate-key",body:n})}async getCurrentUser(){const n=await this.client.query({query:En});return Rb(n)}async retryFailedVerification(){return await this.client.query({query:Bt}),this.getCurrentUser()}}var cu={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"VirtualDebitCardFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"VirtualCard"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"userId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"country"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"currency"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"type"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"mask"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"balance"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"renderSecret"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"virtualCardType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"billingInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"holder"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"phone"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"email"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"address"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"street"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"street2"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"city"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"subdivision"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"postalCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"countryCode"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"paymentAddresses"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"network"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"address"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:469}};cu.loc.source={body:`fragment VirtualDebitCardFragment on VirtualCard {
|
|
517
517
|
id
|
|
518
518
|
name
|
|
519
519
|
userId
|
|
@@ -557,7 +557,7 @@ query UserVirtualDebitCard {
|
|
|
557
557
|
...VirtualDebitCardFragment
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var kv={};function Mb(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return kv[t]?!1:(kv[t]=!0,!0)})}_t.definitions=_t.definitions.concat(Mb(cu.definitions));function mr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){mr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){mr(i,n)}),e.definitions&&e.definitions.forEach(function(i){mr(i,n)})}var Fs={};(function(){_t.definitions.forEach(function(n){if(n.name){var t=new Set;mr(n,t),Fs[n.name.value]=t}})})();function Dv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Gb(e,n){var t={kind:e.kind,definitions:[Dv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=Fs[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=Fs[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=Dv(e,o);s&&t.definitions.push(s)}),t}Gb(_t,"UserVirtualDebitCard");const Jb={[Co.USVirtualDebitCard]:e=>({query:St,variables:void 0,response:"createUSVirtualDebitCard"})},Hb=(e,n)=>Jb[e]?.(n)??null;class Qb{client;constructor(n){this.client=n}async fetch(){return(await this.client.query({query:_t}))?.virtualDebitCard??null}async create(n,t){const i=Hb(n,t);if(!i)throw new Error("Invalid virtual card type");return(await this.client.query({query:i.query,variables:i.variables}))?.[i.response]??null}}class Kb{client;constructor(n){this.client=n}async create(n){return this.client.request({method:"post",path:"/users/integrators/webhooks",body:n})}}class Os{environment;apiKey;integrationKey;client;user;bankAccount;debitCard;paymentRequest;payment;onrampPayment;virtualCard;bill;institution;webhook;constructor(n,t,i,u){if(t===void 0&&i===void 0)throw new Error("The integrationKey or apiKey variable appears to be missing or empty. Please ensure you provide it, or when initializing the SpritzApiClient, opt for the integratorKey option.");if(this.environment=n,this.apiKey=t,this.integrationKey=i,!u&&Kp())throw new Error(`It seems you're operating within a browser environment.
|
|
560
|
+
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var kv={};function Mb(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return kv[t]?!1:(kv[t]=!0,!0)})}_t.definitions=_t.definitions.concat(Mb(cu.definitions));function mr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){mr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){mr(i,n)}),e.definitions&&e.definitions.forEach(function(i){mr(i,n)})}var Fs={};(function(){_t.definitions.forEach(function(n){if(n.name){var t=new Set;mr(n,t),Fs[n.name.value]=t}})})();function Dv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Gb(e,n){var t={kind:e.kind,definitions:[Dv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=Fs[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=Fs[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=Dv(e,o);s&&t.definitions.push(s)}),t}Gb(_t,"UserVirtualDebitCard");const Jb={[Co.USVirtualDebitCard]:e=>({query:St,variables:void 0,response:"createUSVirtualDebitCard"})},Hb=(e,n)=>Jb[e]?.(n)??null;class Qb{client;constructor(n){this.client=n}async fetch(){return(await this.client.query({query:_t}))?.virtualDebitCard??null}async create(n,t){const i=Hb(n,t);if(!i)throw new Error("Invalid virtual card type");return(await this.client.query({query:i.query,variables:i.variables}))?.[i.response]??null}}class Kb{client;constructor(n){this.client=n}async create(n){return this.client.request({method:"post",path:"/users/integrators/webhooks",body:n})}async updateWebhookSecret(n){return this.client.request({method:"post",path:"/users/integrators/webhook-secret",body:{secret:n}})}}class Os{environment;apiKey;integrationKey;client;user;bankAccount;debitCard;paymentRequest;payment;onrampPayment;virtualCard;bill;institution;webhook;constructor(n,t,i,u){if(t===void 0&&i===void 0)throw new Error("The integrationKey or apiKey variable appears to be missing or empty. Please ensure you provide it, or when initializing the SpritzApiClient, opt for the integratorKey option.");if(this.environment=n,this.apiKey=t,this.integrationKey=i,!u&&Kp())throw new Error(`It seems you're operating within a browser environment.
|
|
561
561
|
|
|
562
562
|
By default, this is deactivated due to the potential risk of exposing your confidential integrator credentials.
|
|
563
563
|
If you're aware of these risks and have taken necessary security measures, you can enable the \`dangerouslyAllowBrowser\` option, e.g.,
|
|
@@ -1592,10 +1592,10 @@ declare class PaymentRequestService {
|
|
|
1592
1592
|
}
|
|
1593
1593
|
|
|
1594
1594
|
declare enum VerificationStatus {
|
|
1595
|
-
NotStarted = "
|
|
1596
|
-
Verified = "
|
|
1597
|
-
Failed = "
|
|
1598
|
-
Disabled = "
|
|
1595
|
+
NotStarted = "not_started",
|
|
1596
|
+
Verified = "verified",
|
|
1597
|
+
Failed = "failed",
|
|
1598
|
+
Disabled = "disabled"
|
|
1599
1599
|
}
|
|
1600
1600
|
|
|
1601
1601
|
interface CreateUserResponse {
|
|
@@ -1698,7 +1698,7 @@ declare class VirtualCardService {
|
|
|
1698
1698
|
create<T extends VirtualCardType>(type: T, input?: CreateInputMapping[T]): Promise<NonNullable<CreateMutationMapping[T]["query"][keyof CreateMutationMapping[T]["query"]]> | null>;
|
|
1699
1699
|
}
|
|
1700
1700
|
|
|
1701
|
-
type WebhookEvent = 'account.created' | 'account.updated' | 'account.deleted' | 'payment.created' | 'payment.updated' | 'payment.completed' | 'payment.refunded';
|
|
1701
|
+
type WebhookEvent = 'account.created' | 'account.updated' | 'account.deleted' | 'payment.created' | 'payment.updated' | 'payment.completed' | 'payment.refunded' | 'verification.status.updated';
|
|
1702
1702
|
type IntegratorWebhook = {
|
|
1703
1703
|
id: string;
|
|
1704
1704
|
integratorId: string;
|
|
@@ -1715,6 +1715,9 @@ declare class WebhookService {
|
|
|
1715
1715
|
private client;
|
|
1716
1716
|
constructor(client: SpritzClient);
|
|
1717
1717
|
create(args: CreateWebhookParams): Promise<IntegratorWebhook>;
|
|
1718
|
+
updateWebhookSecret(secret: string): Promise<{
|
|
1719
|
+
success: boolean;
|
|
1720
|
+
}>;
|
|
1718
1721
|
}
|
|
1719
1722
|
|
|
1720
1723
|
type ClientOptions = {
|
|
@@ -513,7 +513,7 @@ query CurrentUser {
|
|
|
513
513
|
...VerificationFragment
|
|
514
514
|
}
|
|
515
515
|
}
|
|
516
|
-
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var vv={};function pv(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return vv[t]?!1:(vv[t]=!0,!0)})}En.definitions=En.definitions.concat(pv(sr.definitions)),En.definitions=En.definitions.concat(pv(su.definitions));function lr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){lr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){lr(i,n)}),e.definitions&&e.definitions.forEach(function(i){lr(i,n)})}var $s={};(function(){En.definitions.forEach(function(n){if(n.name){var t=new Set;lr(n,t),$s[n.name.value]=t}})})();function hv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Pb(e,n){var t={kind:e.kind,definitions:[hv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=$s[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=$s[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=hv(e,o);s&&t.definitions.push(s)}),t}Pb(En,"CurrentUser");var jb=(e=>(e.NotStarted="
|
|
516
|
+
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var vv={};function pv(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return vv[t]?!1:(vv[t]=!0,!0)})}En.definitions=En.definitions.concat(pv(sr.definitions)),En.definitions=En.definitions.concat(pv(su.definitions));function lr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){lr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){lr(i,n)}),e.definitions&&e.definitions.forEach(function(i){lr(i,n)})}var $s={};(function(){En.definitions.forEach(function(n){if(n.name){var t=new Set;lr(n,t),$s[n.name.value]=t}})})();function hv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Pb(e,n){var t={kind:e.kind,definitions:[hv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=$s[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=$s[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=hv(e,o);s&&t.definitions.push(s)}),t}Pb(En,"CurrentUser");var jb=(e=>(e.NotStarted="not_started",e.Verified="verified",e.Failed="failed",e.Disabled="disabled",e))(jb||{});function Rb(e=nt.INITIALIZED){switch(e){case nt.FAILED:return"failed";case nt.ACTIVE:return"verified";case nt.DISABLED:return"disabled";case nt.RETRY:return"failed";default:return"not_started"}}function Lb(e){const n=e?.me??null;if(!n)return null;const t=e?.verification??null;return{...n,verificationStatus:Rb(t?.identity?.status),verificationUrl:t?.identity?.verificationUrl??null,verifiedCountry:t?.identity?.country??null,canRetryVerification:t?.identity?.canRetry??!1}}class Zb{client;constructor(n){this.client=n}async createUser(n){return this.client.request({method:"post",path:"/users/integration",body:n})}async create(n){return this.createUser(n)}async requestApiKey(n){return this.client.request({method:"post",path:"/users/request-key",body:{email:n}})}async authorizeApiKeyWithOTP(n){return this.client.request({method:"post",path:"/users/validate-key",body:n})}async getCurrentUser(){const n=await this.client.query({query:En});return Lb(n)}async retryFailedVerification(){return await this.client.query({query:Bt}),this.getCurrentUser()}}var cu={kind:"Document",definitions:[{kind:"FragmentDefinition",name:{kind:"Name",value:"VirtualDebitCardFragment"},typeCondition:{kind:"NamedType",name:{kind:"Name",value:"VirtualCard"}},directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"id"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"name"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"userId"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"country"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"currency"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"createdAt"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"type"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"mask"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"balance"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"renderSecret"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"virtualCardType"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"billingInfo"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"holder"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"phone"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"email"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"address"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"street"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"street2"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"city"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"subdivision"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"postalCode"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"countryCode"},arguments:[],directives:[]}]}}]}},{kind:"Field",name:{kind:"Name",value:"paymentAddresses"},arguments:[],directives:[],selectionSet:{kind:"SelectionSet",selections:[{kind:"Field",name:{kind:"Name",value:"network"},arguments:[],directives:[]},{kind:"Field",name:{kind:"Name",value:"address"},arguments:[],directives:[]}]}}]}}],loc:{start:0,end:469}};cu.loc.source={body:`fragment VirtualDebitCardFragment on VirtualCard {
|
|
517
517
|
id
|
|
518
518
|
name
|
|
519
519
|
userId
|
|
@@ -557,7 +557,7 @@ query UserVirtualDebitCard {
|
|
|
557
557
|
...VirtualDebitCardFragment
|
|
558
558
|
}
|
|
559
559
|
}
|
|
560
|
-
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var bv={};function Gb(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return bv[t]?!1:(bv[t]=!0,!0)})}_t.definitions=_t.definitions.concat(Gb(cu.definitions));function mr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){mr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){mr(i,n)}),e.definitions&&e.definitions.forEach(function(i){mr(i,n)})}var Fs={};(function(){_t.definitions.forEach(function(n){if(n.name){var t=new Set;mr(n,t),Fs[n.name.value]=t}})})();function kv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Jb(e,n){var t={kind:e.kind,definitions:[kv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=Fs[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=Fs[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=kv(e,o);s&&t.definitions.push(s)}),t}Jb(_t,"UserVirtualDebitCard");const Hb={[Co.USVirtualDebitCard]:e=>({query:St,variables:void 0,response:"createUSVirtualDebitCard"})},Qb=(e,n)=>Hb[e]?.(n)??null;class Kb{client;constructor(n){this.client=n}async fetch(){return(await this.client.query({query:_t}))?.virtualDebitCard??null}async create(n,t){const i=Qb(n,t);if(!i)throw new Error("Invalid virtual card type");return(await this.client.query({query:i.query,variables:i.variables}))?.[i.response]??null}}class Wb{client;constructor(n){this.client=n}async create(n){return this.client.request({method:"post",path:"/users/integrators/webhooks",body:n})}}class Os{environment;apiKey;integrationKey;client;user;bankAccount;debitCard;paymentRequest;payment;onrampPayment;virtualCard;bill;institution;webhook;constructor(n,t,i,u){if(t===void 0&&i===void 0)throw new Error("The integrationKey or apiKey variable appears to be missing or empty. Please ensure you provide it, or when initializing the SpritzApiClient, opt for the integratorKey option.");if(this.environment=n,this.apiKey=t,this.integrationKey=i,!u&&Wp())throw new Error(`It seems you're operating within a browser environment.
|
|
560
|
+
`,name:"GraphQL request",locationOffset:{line:1,column:1}};var bv={};function Gb(e){return e.filter(function(n){if(n.kind!=="FragmentDefinition")return!0;var t=n.name.value;return bv[t]?!1:(bv[t]=!0,!0)})}_t.definitions=_t.definitions.concat(Gb(cu.definitions));function mr(e,n){if(e.kind==="FragmentSpread")n.add(e.name.value);else if(e.kind==="VariableDefinition"){var t=e.type;t.kind==="NamedType"&&n.add(t.name.value)}e.selectionSet&&e.selectionSet.selections.forEach(function(i){mr(i,n)}),e.variableDefinitions&&e.variableDefinitions.forEach(function(i){mr(i,n)}),e.definitions&&e.definitions.forEach(function(i){mr(i,n)})}var Fs={};(function(){_t.definitions.forEach(function(n){if(n.name){var t=new Set;mr(n,t),Fs[n.name.value]=t}})})();function kv(e,n){for(var t=0;t<e.definitions.length;t++){var i=e.definitions[t];if(i.name&&i.name.value==n)return i}}function Jb(e,n){var t={kind:e.kind,definitions:[kv(e,n)]};e.hasOwnProperty("loc")&&(t.loc=e.loc);var i=Fs[n]||new Set,u=new Set,r=new Set;for(i.forEach(function(o){r.add(o)});r.size>0;){var a=r;r=new Set,a.forEach(function(o){if(!u.has(o)){u.add(o);var s=Fs[o]||new Set;s.forEach(function(c){r.add(c)})}})}return u.forEach(function(o){var s=kv(e,o);s&&t.definitions.push(s)}),t}Jb(_t,"UserVirtualDebitCard");const Hb={[Co.USVirtualDebitCard]:e=>({query:St,variables:void 0,response:"createUSVirtualDebitCard"})},Qb=(e,n)=>Hb[e]?.(n)??null;class Kb{client;constructor(n){this.client=n}async fetch(){return(await this.client.query({query:_t}))?.virtualDebitCard??null}async create(n,t){const i=Qb(n,t);if(!i)throw new Error("Invalid virtual card type");return(await this.client.query({query:i.query,variables:i.variables}))?.[i.response]??null}}class Wb{client;constructor(n){this.client=n}async create(n){return this.client.request({method:"post",path:"/users/integrators/webhooks",body:n})}async updateWebhookSecret(n){return this.client.request({method:"post",path:"/users/integrators/webhook-secret",body:{secret:n}})}}class Os{environment;apiKey;integrationKey;client;user;bankAccount;debitCard;paymentRequest;payment;onrampPayment;virtualCard;bill;institution;webhook;constructor(n,t,i,u){if(t===void 0&&i===void 0)throw new Error("The integrationKey or apiKey variable appears to be missing or empty. Please ensure you provide it, or when initializing the SpritzApiClient, opt for the integratorKey option.");if(this.environment=n,this.apiKey=t,this.integrationKey=i,!u&&Wp())throw new Error(`It seems you're operating within a browser environment.
|
|
561
561
|
|
|
562
562
|
By default, this is deactivated due to the potential risk of exposing your confidential integrator credentials.
|
|
563
563
|
If you're aware of these risks and have taken necessary security measures, you can enable the \`dangerouslyAllowBrowser\` option, e.g.,
|