@stytch/vanilla-js 4.8.0 → 4.9.1

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/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessTOTPClient, IHeadlessUserClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/core/public";
1
+ import { StateChangeRegisterFunction } from "@stytch/core";
2
+ import { ConsumerState, IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessTOTPClient, IHeadlessUserClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/core/public";
2
3
  import { PromptMomentNotification } from "google-one-tap";
3
4
  type OneTapNotShownReason = ReturnType<PromptMomentNotification["getNotDisplayedReason"]> | ReturnType<PromptMomentNotification["getSkippedReason"]>;
4
5
  type OneTapRenderResult = {
@@ -73,6 +74,7 @@ declare class StytchHeadlessClient {
73
74
  private readonly _sessionManager;
74
75
  private readonly _networkClient;
75
76
  private readonly _dataLayer;
77
+ private readonly _stateChangeClient;
76
78
  // External API Clients
77
79
  user: IHeadlessUserClient;
78
80
  magicLinks: IHeadlessMagicLinksClient;
@@ -83,6 +85,19 @@ declare class StytchHeadlessClient {
83
85
  totps: IHeadlessTOTPClient;
84
86
  webauthn: IHeadlessWebAuthnClient;
85
87
  passwords: IHeadlessPasswordClient;
88
+ // External methods
89
+ /**
90
+ * Register a callback function to be invoked whenever certain state changes
91
+ * occur, like a user or session object being updated.
92
+ *
93
+ * This is an alternative to more specific methods like `user.onChange` and
94
+ * `session.onChange`. It can be helpful if you want to be notified of related
95
+ * changes to different parts of state at once.
96
+ *
97
+ * If you are only interested in specific state changes, consider using more
98
+ * specific methods like `user.onChange` and `session.onChange` instead.
99
+ */
100
+ onStateChange: StateChangeRegisterFunction<ConsumerState>;
86
101
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
87
102
  }
88
103
  /**
@@ -1,4 +1,5 @@
1
- import { IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessTOTPClient, IHeadlessUserClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/core/public";
1
+ import { StateChangeRegisterFunction } from "@stytch/core";
2
+ import { ConsumerState, IHeadlessCryptoWalletClient, IHeadlessMagicLinksClient, IHeadlessOTPsClient, IHeadlessPasswordClient, IHeadlessSessionClient, IHeadlessTOTPClient, IHeadlessUserClient, IHeadlessWebAuthnClient, StytchClientOptions, IHeadlessOAuthClient, Callbacks, StytchLoginConfig, StyleConfig } from "@stytch/core/public";
2
3
  import { PromptMomentNotification } from "google-one-tap";
3
4
  type OneTapNotShownReason = ReturnType<PromptMomentNotification["getNotDisplayedReason"]> | ReturnType<PromptMomentNotification["getSkippedReason"]>;
4
5
  type OneTapRenderResult = {
@@ -73,6 +74,7 @@ declare class StytchHeadlessClient {
73
74
  private readonly _sessionManager;
74
75
  private readonly _networkClient;
75
76
  private readonly _dataLayer;
77
+ private readonly _stateChangeClient;
76
78
  // External API Clients
77
79
  user: IHeadlessUserClient;
78
80
  magicLinks: IHeadlessMagicLinksClient;
@@ -83,6 +85,19 @@ declare class StytchHeadlessClient {
83
85
  totps: IHeadlessTOTPClient;
84
86
  webauthn: IHeadlessWebAuthnClient;
85
87
  passwords: IHeadlessPasswordClient;
88
+ // External methods
89
+ /**
90
+ * Register a callback function to be invoked whenever certain state changes
91
+ * occur, like a user or session object being updated.
92
+ *
93
+ * This is an alternative to more specific methods like `user.onChange` and
94
+ * `session.onChange`. It can be helpful if you want to be notified of related
95
+ * changes to different parts of state at once.
96
+ *
97
+ * If you are only interested in specific state changes, consider using more
98
+ * specific methods like `user.onChange` and `session.onChange` instead.
99
+ */
100
+ onStateChange: StateChangeRegisterFunction<ConsumerState>;
86
101
  constructor(_PUBLIC_TOKEN: string, options?: StytchClientOptions);
87
102
  }
88
103
  /**