@authing/guard-shim-react 4.5.51-eak.27 → 4.5.51-eak.29

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.
@@ -1,8 +1,9 @@
1
1
  import React, { ReactElement, CSSProperties, ReactNode, ForwardRefRenderFunction } from 'react';
2
+ import { createPortal } from 'react-dom';
2
3
  export interface IRenderer {
3
4
  container: Element;
4
5
  element: ReactElement;
5
6
  }
6
7
  declare function render(renderer: IRenderer): void | Element | React.Component<any, any, any>;
7
8
  declare function unmount(container: Element): void;
8
- export { React, CSSProperties, ReactNode, render, unmount, ReactElement, ForwardRefRenderFunction };
9
+ export { React, createPortal, CSSProperties, ReactNode, render, unmount, ReactElement, ForwardRefRenderFunction };
@@ -1,8 +1,9 @@
1
1
  import React, { ReactNode, CSSProperties, ReactElement, ForwardRefRenderFunction } from 'react';
2
+ import { createPortal } from 'react-dom';
2
3
  export interface IRenderer {
3
4
  container: Element;
4
5
  element: ReactNode;
5
6
  }
6
7
  declare function render(renderer: IRenderer): void;
7
8
  declare function unmount(container: Element): void;
8
- export { React, ReactNode, CSSProperties, render, unmount, ReactElement, ForwardRefRenderFunction };
9
+ export { React, createPortal, ReactNode, CSSProperties, render, unmount, ReactElement, ForwardRefRenderFunction };
@@ -0,0 +1,40 @@
1
+ export declare const TURNSTILE_SCRIPT_URL = "https://challenges.cloudflare.com/turnstile/v0/api.js?render=explicit";
2
+ export interface TurnstileConfig {
3
+ enabled: boolean;
4
+ siteKey: string;
5
+ action: 'send_code';
6
+ scriptUrl: string;
7
+ }
8
+ export interface TurnstileApi {
9
+ render: (container: HTMLElement, options: {
10
+ sitekey: string;
11
+ action: string;
12
+ theme: 'auto';
13
+ size: 'flexible' | 'compact';
14
+ appearance: 'always' | 'interaction-only';
15
+ language: string;
16
+ retry: 'never';
17
+ 'refresh-expired': 'manual';
18
+ 'refresh-timeout': 'manual';
19
+ 'response-field': false;
20
+ callback: (token: string) => void;
21
+ 'error-callback': (code?: string) => void;
22
+ 'expired-callback': () => void;
23
+ 'timeout-callback': () => void;
24
+ }) => string | undefined;
25
+ remove: (widgetId: string) => void;
26
+ }
27
+ export declare class TurnstileLoadError extends Error {
28
+ code: 'SCRIPT_LOAD_FAILED' | 'SCRIPT_LOAD_TIMEOUT' | 'API_UNAVAILABLE';
29
+ constructor(code: 'SCRIPT_LOAD_FAILED' | 'SCRIPT_LOAD_TIMEOUT' | 'API_UNAVAILABLE');
30
+ }
31
+ /** Share the script across widgets and Guard instances in the same document. */
32
+ export declare const loadTurnstile: (document: Document) => Promise<TurnstileApi>;
33
+ /** Never interpret a failed or malformed configuration request as disabled. */
34
+ export declare const readTurnstileConfig: (response: {
35
+ code?: number;
36
+ data?: TurnstileConfig;
37
+ }) => TurnstileConfig;
38
+ export declare class TurnstileChallengeError extends Error {
39
+ constructor(message: string);
40
+ }
@@ -0,0 +1,27 @@
1
+ import { React } from 'shim-react';
2
+ import './style.less';
3
+ /** Authentication forms share one widget until its raw token is submitted. */
4
+ export declare const useTurnstile: (options?: {
5
+ mode?: 'inline' | 'modal';
6
+ placement?: 'inline' | 'send-code' | 'page';
7
+ }) => {
8
+ turnstileView: null;
9
+ shared: boolean;
10
+ getTurnstileParams: () => Promise<Record<string, string>>;
11
+ sendDisabled: boolean;
12
+ submissionProtected: boolean;
13
+ mountVerification: (slot: HTMLElement) => () => void;
14
+ } | {
15
+ shared: boolean;
16
+ getTurnstileParams: () => Promise<Record<string, string>>;
17
+ turnstileView: JSX.Element | null;
18
+ sendDisabled: boolean;
19
+ retryAfterFailure: (token: string) => void;
20
+ };
21
+ /** One native widget across normal login/register forms; other modules do not gate submission. */
22
+ export declare const TurnstileProvider: React.FC<{
23
+ protectSubmission?: boolean;
24
+ }>;
25
+ /** Reserve the native widget's place above the active form's primary action. */
26
+ export declare const TurnstileField: React.FC;
27
+ export declare const useTurnstileSubmitDisabled: () => boolean;
@@ -6,12 +6,14 @@ import { BackFillMultipleState, StoreInstance } from '../Guard/core/hooks/useMul
6
6
  import { ModuleState } from '../Guard/GuardModule/stateMachine';
7
7
  import { ApplicationConfig } from '../Type/application';
8
8
  import { GuardHttp } from './guardHttp';
9
+ import { AuthenticationClient } from 'authing-js-sdk';
9
10
  import { MultipleTenant } from './tenant';
10
11
  export interface IGuardContext {
11
12
  finallyConfig: GuardLocalConfig;
12
13
  defaultMergedConfig: GuardLocalConfig;
13
14
  publicConfig: ApplicationConfig;
14
15
  httpClient: GuardHttp;
16
+ authClient?: AuthenticationClient;
15
17
  appId: string;
16
18
  tenantId?: string;
17
19
  initData: any;
@@ -78,6 +80,7 @@ export declare const useGuardButtonContext: () => {
78
80
  export declare const useGuardButtonState: () => IGuardContextProvider;
79
81
  export declare const useGuardPublicConfig: () => ApplicationConfig;
80
82
  export declare const useGuardHttpClient: () => GuardHttp;
83
+ export declare const useGuardAuthenticationClient: () => AuthenticationClient | undefined;
81
84
  export declare const useIsSpecialBrowser: () => boolean;
82
85
  export declare const useGuardDefaultMergedConfig: () => GuardLocalConfig;
83
86
  export declare const useGuardAppId: () => string;
@@ -1,6 +1,9 @@
1
1
  import { AuthingGuardResponse, AuthingResponse } from './http';
2
2
  import { CodeAction } from './responseManagement/interface';
3
3
  export declare class GuardHttp {
4
+ private turnstileProofReader?;
5
+ private turnstileFailureHandler?;
6
+ setTurnstileProofReader: (reader: () => Promise<Record<string, string>>, onFailure?: (token: string) => void) => () => void;
4
7
  private requestClient;
5
8
  private headers;
6
9
  private responseInterceptorMap;
@@ -0,0 +1,6 @@
1
+ /** Preserve a token already supplied by the caller or another transport. */
2
+ export declare const hasTurnstileToken: (url: string, data?: any) => boolean;
3
+ /** Business errors consume a raw token; MFA/next-step responses do not retry. */
4
+ export declare const turnstileSubmissionFailed: (data: any) => boolean;
5
+ /** Only normal registration/login submissions carry the raw human token. */
6
+ export declare const needsTurnstileProof: (url: string, data?: any) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@authing/guard-shim-react",
3
- "version": "4.5.51-eak.27",
3
+ "version": "4.5.51-eak.29",
4
4
  "description": "Guard shim for react 16 / 17, only be used to internal",
5
5
  "types": "dist/typings/src/index.d.ts",
6
6
  "module": "dist/guard.min.js",