@foxy.io/sdk 1.11.3 → 1.13.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.
Files changed (29) hide show
  1. package/dist/cdn/FoxySDKCustomer.js +3 -3
  2. package/dist/cjs/customer/API.js +23 -0
  3. package/dist/cjs/customer/PaymentCardEmbed.js +170 -0
  4. package/dist/cjs/customer/index.js +3 -1
  5. package/dist/esm/customer/API.js +23 -0
  6. package/dist/esm/customer/PaymentCardEmbed.js +166 -0
  7. package/dist/esm/customer/index.js +1 -0
  8. package/dist/types/backend/Graph/cart.d.ts +2 -2
  9. package/dist/types/backend/Graph/customer.d.ts +2 -2
  10. package/dist/types/backend/Graph/default_payment_method.d.ts +2 -0
  11. package/dist/types/backend/Graph/email_template.d.ts +2 -0
  12. package/dist/types/backend/Graph/passkey.d.ts +19 -0
  13. package/dist/types/backend/Graph/passkeys.d.ts +10 -0
  14. package/dist/types/backend/Graph/send_webhooks.d.ts +9 -0
  15. package/dist/types/backend/Graph/store.d.ts +47 -0
  16. package/dist/types/backend/Graph/subscription_settings.d.ts +1 -1
  17. package/dist/types/backend/Graph/transaction.d.ts +3 -0
  18. package/dist/types/backend/Graph/user.d.ts +6 -0
  19. package/dist/types/backend/Graph/user_invitation.d.ts +38 -0
  20. package/dist/types/backend/Graph/user_invitations.d.ts +10 -0
  21. package/dist/types/backend/Rels.d.ts +5 -0
  22. package/dist/types/customer/API.d.ts +10 -0
  23. package/dist/types/customer/Graph/default_payment_method.d.ts +2 -2
  24. package/dist/types/customer/Graph/index.d.ts +2 -2
  25. package/dist/types/customer/Graph/transaction_template.d.ts +2 -2
  26. package/dist/types/customer/PaymentCardEmbed.d.ts +69 -0
  27. package/dist/types/customer/index.d.ts +1 -0
  28. package/dist/types/customer/types.d.ts +85 -0
  29. package/package.json +1 -1
@@ -0,0 +1,38 @@
1
+ import type { Graph } from '../../core';
2
+ import type { Store } from './store';
3
+ import type { User } from './user';
4
+
5
+ export interface UserInvitation extends Graph {
6
+ curie: 'fx:user_invitation';
7
+ links: {
8
+ 'self': UserInvitation;
9
+ 'fx:user': User;
10
+ 'fx:store': Store;
11
+ 'fx:resend': { curie: 'fx:resend' };
12
+ 'fx:accept': { curie: 'fx:accept' };
13
+ 'fx:reject': { curie: 'fx:reject' };
14
+ 'fx:revoke': { curie: 'fx:revoke' };
15
+ };
16
+ props: {
17
+ /* Read-only website URL of the store that the user is invited to. */
18
+ store_url: string;
19
+ /* Read-only name of the store that the user is invited to. */
20
+ store_name: string;
21
+ /* Read-only email of the store that the user is invited to. */
22
+ store_email: string;
23
+ /* Read-only (sub)domain of the store that the user is invited to. */
24
+ store_domain: string;
25
+ /* Read-only first name of the user that is invited. */
26
+ first_name: string | null;
27
+ /* Read-only last name of the user that is invited. */
28
+ last_name: string | null;
29
+ /* Read-only email of the user that is invited. */
30
+ email: string;
31
+ /* Read-only status of the invitation, `sent` on creation. Use POST actions in links to change the status. */
32
+ status: 'sent' | 'accepted' | 'rejected' | 'revoked' | 'expired';
33
+ /* Read-only date the invitation was created. */
34
+ date_created: string;
35
+ /* Read-only date the invitation was last modified. */
36
+ date_modified: string;
37
+ };
38
+ }
@@ -0,0 +1,10 @@
1
+ import type { CollectionGraphLinks, CollectionGraphProps } from '../../core/defaults';
2
+ import type { Graph } from '../../core';
3
+ import type { UserInvitation } from './user_invitation';
4
+
5
+ export interface UserInvitations extends Graph {
6
+ curie: 'fx:user_accesses';
7
+ links: CollectionGraphLinks<UserInvitations>;
8
+ props: CollectionGraphProps;
9
+ child: UserInvitation;
10
+ }
@@ -89,6 +89,8 @@ export * from './Graph/locale_codes';
89
89
  export * from './Graph/native_integration';
90
90
  export * from './Graph/native_integrations';
91
91
  export * from './Graph/original_transaction';
92
+ export * from './Graph/passkey';
93
+ export * from './Graph/passkeys';
92
94
  export * from './Graph/payment';
93
95
  export * from './Graph/payment_gateway';
94
96
  export * from './Graph/payment_gateways';
@@ -116,6 +118,7 @@ export * from './Graph/reporting_email_exists';
116
118
  export * from './Graph/reporting_store_domain_exists';
117
119
  export * from './Graph/reports';
118
120
  export * from './Graph/send_emails';
121
+ export * from './Graph/send_webhooks';
119
122
  export * from './Graph/shipment';
120
123
  export * from './Graph/shipments';
121
124
  export * from './Graph/shipping_address_types';
@@ -159,6 +162,8 @@ export * from './Graph/transactions';
159
162
  export * from './Graph/user';
160
163
  export * from './Graph/user_access';
161
164
  export * from './Graph/user_accesses';
165
+ export * from './Graph/user_invitation';
166
+ export * from './Graph/user_invitations';
162
167
  export * from './Graph/users';
163
168
  export * from './Graph/void';
164
169
  export * from './Graph/webhook_log';
@@ -17,6 +17,7 @@ export declare class API extends Core.API<Graph> {
17
17
  } & {
18
18
  signUpParams: any;
19
19
  credentials: any;
20
+ boolean: any;
20
21
  email: any;
21
22
  };
22
23
  constructor(params: ConstructorParameters<typeof Core.API>[0]);
@@ -48,5 +49,14 @@ export declare class API extends Core.API<Graph> {
48
49
  }): Promise<void>;
49
50
  /** Destroys current session and clears local session data. */
50
51
  signOut(): Promise<void>;
52
+ /**
53
+ * When logged in with a temporary password, this property getter will return `true`.
54
+ * Will return `false` if password reset is not required or if the session has not been
55
+ * initiated, or if the session was initiated before the introduction of this feature.
56
+ *
57
+ * @returns {boolean} Password reset requirement.
58
+ */
59
+ get usesTemporaryPassword(): boolean;
60
+ set usesTemporaryPassword(value: boolean);
51
61
  private __fetch;
52
62
  }
@@ -15,8 +15,8 @@ export interface DefaultPaymentMethod extends Graph {
15
15
  save_cc: boolean;
16
16
  /** The credit card or debit card type. This will be determined automatically once the payment card is saved. */
17
17
  cc_type: string | null;
18
- /** The payment card number. This property will not be displayed as part of this resource, but can be used to modify this payment method. */
19
- cc_number?: number;
18
+ /** Token returned by our Tokenization Embed. Send this field with PATCH to update customer's payment method. */
19
+ cc_token?: string;
20
20
  /** A masked version of this payment card showing only the last 4 digits. */
21
21
  cc_number_masked: string | null;
22
22
  /** The payment card expiration month in the MM format. */
@@ -41,9 +41,9 @@ interface Customer extends Graph {
41
41
  /** The date of the last time this customer authenticated with the FoxyCart checkout. */
42
42
  last_login_date: string;
43
43
  /** The customer's given name. */
44
- first_name: string;
44
+ first_name: string | null;
45
45
  /** The customer's surname. */
46
- last_name: string;
46
+ last_name: string | null;
47
47
  /** The customer's email address. This is used as the login to the FoxyCart checkout for this customer. */
48
48
  email: string;
49
49
  /** A tax identification number for this customer. */
@@ -32,7 +32,7 @@ export interface TransactionTemplate extends Graph {
32
32
  /** The city of this address. */
33
33
  billing_city: string;
34
34
  /** The two character code for states in the United States. Other countries may call this a province. When a two character code isn't available, use the full region name. */
35
- billing_region: string;
35
+ billing_state: string;
36
36
  /** The postal code of the billing address. */
37
37
  billing_postal_code: string;
38
38
  /** The country code of the billing address. */
@@ -54,7 +54,7 @@ export interface TransactionTemplate extends Graph {
54
54
  /** The city of this address. */
55
55
  shipping_city: string;
56
56
  /** The two character code for states in the United States. Other countries may call this a province. When a two character code isn't available, use the full region name. */
57
- shipping_region: string;
57
+ shipping_state: string;
58
58
  /** The postal code of the shipping address. */
59
59
  shipping_postal_code: string;
60
60
  /** The country code of the shipping address. */
@@ -0,0 +1,69 @@
1
+ import type { PaymentCardEmbedConfig } from './types';
2
+ /**
3
+ * A convenience wrapper for the payment card embed iframe. You don't have to use
4
+ * this class to embed the payment card iframe, but it provides a more convenient
5
+ * way to interact with the iframe and listen to its events.
6
+ *
7
+ * @example
8
+ * const embed = new PaymentCardEmbed({
9
+ * url: 'https://embed.foxy.io/v1.html?template_set_id=123'
10
+ * });
11
+ *
12
+ * await embed.mount(document.body);
13
+ * console.log('Token:', await embed.tokenize());
14
+ */
15
+ export declare class PaymentCardEmbed {
16
+ /**
17
+ * An event handler that is triggered when Enter is pressed in the card form.
18
+ * This feature is not available for template sets configured with the `stripe_connect`
19
+ * hosted payment gateway due to the limitations of Stripe.js.
20
+ */
21
+ onsubmit: (() => void) | null;
22
+ private __tokenizationRequests;
23
+ private __iframeMessageHandler;
24
+ private __iframeLoadHandler;
25
+ private __mountingTask;
26
+ private __channel;
27
+ private __iframe;
28
+ private __config;
29
+ private __url;
30
+ constructor({ url, ...config }: {
31
+ url: string;
32
+ } & PaymentCardEmbedConfig);
33
+ /**
34
+ * Updates the configuration of the payment card embed.
35
+ * You can change style, translations, language and interactivity settings.
36
+ * To change the URL of the payment card embed, you need to create a new instance.
37
+ * You are not required to provide the full configuration object, only the properties you want to change.
38
+ *
39
+ * @param config - The new configuration.
40
+ */
41
+ configure(config: PaymentCardEmbedConfig): void;
42
+ /**
43
+ * Requests the tokenization of the card data.
44
+ *
45
+ * @returns A promise that resolves with the tokenized card data.
46
+ */
47
+ tokenize(): Promise<string>;
48
+ /**
49
+ * Safely removes the embed iframe from the parent node,
50
+ * closing the message channel and cleaning up event listeners.
51
+ */
52
+ unmount(): void;
53
+ /**
54
+ * Mounts the payment card embed in the given root element. If the embed is already mounted,
55
+ * it will be unmounted first.
56
+ *
57
+ * @param root - The root element to mount the embed in.
58
+ * @returns A promise that resolves when the embed is mounted.
59
+ */
60
+ mount(root: Element): Promise<void>;
61
+ /**
62
+ * Clears the card data from the embed.
63
+ * No-op if the embed is not mounted.
64
+ */
65
+ clear(): void;
66
+ protected _createMessageChannel(): MessageChannel;
67
+ protected _createIframe(root: Element): HTMLIFrameElement;
68
+ protected _createId(): string;
69
+ }
@@ -3,6 +3,7 @@ export { getAllowedFrequencies } from './getAllowedFrequencies.js';
3
3
  export { getNextTransactionDateConstraints } from './getNextTransactionDateConstraints.js';
4
4
  export { getTimeFromFrequency } from '../backend/getTimeFromFrequency.js';
5
5
  export { isNextTransactionDate } from './isNextTransactionDate.js';
6
+ export { PaymentCardEmbed } from './PaymentCardEmbed.js';
6
7
  import type * as Rels from './Rels';
7
8
  export type { Graph } from './Graph';
8
9
  export type { Rels };
@@ -1,3 +1,87 @@
1
+ /** Tokenization embed configuration that can be updated any time after mount. */
2
+ export type PaymentCardEmbedConfig = Partial<{
3
+ /** Translations. Note that Stripe and Square provide their own translations that can't be customized. */
4
+ translations: {
5
+ stripe?: {
6
+ label?: string;
7
+ status?: {
8
+ idle?: string;
9
+ busy?: string;
10
+ fail?: string;
11
+ };
12
+ };
13
+ square?: {
14
+ label?: string;
15
+ status?: {
16
+ idle?: string;
17
+ busy?: string;
18
+ fail?: string;
19
+ };
20
+ };
21
+ default?: {
22
+ 'cc-number'?: {
23
+ label?: string;
24
+ placeholder?: string;
25
+ v8n_required?: string;
26
+ v8n_invalid?: string;
27
+ v8n_unsupported?: string;
28
+ };
29
+ 'cc-exp'?: {
30
+ label?: string;
31
+ placeholder?: string;
32
+ v8n_required?: string;
33
+ v8n_invalid?: string;
34
+ v8n_expired?: string;
35
+ };
36
+ 'cc-csc'?: {
37
+ label?: string;
38
+ placeholder?: string;
39
+ v8n_required?: string;
40
+ v8n_invalid?: string;
41
+ };
42
+ 'status'?: {
43
+ idle?: string;
44
+ busy?: string;
45
+ fail?: string;
46
+ misconfigured?: string;
47
+ };
48
+ };
49
+ };
50
+ /** If true, all fields inside the embed will be disabled. */
51
+ disabled: boolean;
52
+ /** If true, all fields inside the embed will be set to be read-only. For Stripe and Square the fields will be disabled and styled as readonly. */
53
+ readonly: boolean;
54
+ /** Appearance settings. */
55
+ style: Partial<{
56
+ '--lumo-space-m': string;
57
+ '--lumo-space-s': string;
58
+ '--lumo-contrast-5pct': string;
59
+ '--lumo-contrast-10pct': string;
60
+ '--lumo-contrast-50pct': string;
61
+ '--lumo-size-m': string;
62
+ '--lumo-size-xs': string;
63
+ '--lumo-border-radius-m': string;
64
+ '--lumo-border-radius-s': string;
65
+ '--lumo-font-family': string;
66
+ '--lumo-font-size-m': string;
67
+ '--lumo-font-size-s': string;
68
+ '--lumo-font-size-xs': string;
69
+ '--lumo-primary-color': string;
70
+ '--lumo-primary-text-color': string;
71
+ '--lumo-primary-color-50pct': string;
72
+ '--lumo-secondary-text-color': string;
73
+ '--lumo-disabled-text-color': string;
74
+ '--lumo-body-text-color': string;
75
+ '--lumo-error-text-color': string;
76
+ '--lumo-error-color-10pct': string;
77
+ '--lumo-error-color-50pct': string;
78
+ '--lumo-line-height-xs': string;
79
+ '--lumo-base-color': string;
80
+ }>;
81
+ /** Locale to use with Stripe or Square. Has no effect on the default UI. */
82
+ lang: string;
83
+ }>;
84
+
1
85
  /** User credentials for authentication. */
2
86
  export interface Credentials {
3
87
  /** Email address associated with an account. */
@@ -26,6 +110,7 @@ export interface SignUpParams {
26
110
  }
27
111
 
28
112
  export interface Session {
113
+ force_password_reset?: boolean;
29
114
  session_token: string;
30
115
  expires_in: number;
31
116
  jwt: string;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@foxy.io/sdk",
3
3
  "type": "commonjs",
4
- "version": "1.11.3",
4
+ "version": "1.13.0",
5
5
  "description": "Universal SDK for a full server-side and a limited in-browser access to Foxy hAPI.",
6
6
  "main": "dist/cjs/index.js",
7
7
  "module": "dist/esm/index.js",