@smart-cloud/gatey-core 2.2.7 → 2.2.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/dist/auth.d.ts ADDED
@@ -0,0 +1,27 @@
1
+ import { type ResourcesConfig } from "aws-amplify";
2
+ import { type AuthSession, type FetchAuthSessionOptions, type FetchMFAPreferenceOutput, type FetchUserAttributesOutput } from "aws-amplify/auth";
3
+ import { type ApiConfiguration } from "./store";
4
+ export interface Account {
5
+ username?: string;
6
+ loaded?: boolean;
7
+ userAttributes?: FetchUserAttributesOutput;
8
+ mfaPreferences?: FetchMFAPreferenceOutput;
9
+ }
10
+ export declare const getAmplifyConfig: () => ResourcesConfig;
11
+ export declare const configureAmplify: (resourcesConfig: ResourcesConfig, libraryOptions?: Record<string, unknown>) => void;
12
+ export declare const loadAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
13
+ export declare const loadUserAttributes: () => Promise<FetchUserAttributesOutput>;
14
+ export declare const loadMFAPreferences: () => Promise<FetchMFAPreferenceOutput>;
15
+ export declare const loadUser: (checkStorage?: boolean) => Promise<Account>;
16
+ export declare const clearMfaPreferences: () => Promise<void>;
17
+ export declare const getUsername: () => Promise<string | undefined>;
18
+ export declare const getUserAttributes: () => Promise<FetchUserAttributesOutput | undefined>;
19
+ export declare const getMfaPreferences: () => Promise<FetchMFAPreferenceOutput | undefined>;
20
+ export declare const isAuthenticated: () => Promise<boolean>;
21
+ export declare const isInGroup: (group: string) => Promise<boolean>;
22
+ export declare const getGroups: () => Promise<string[] | undefined>;
23
+ export declare const getRoles: () => Promise<string[] | undefined>;
24
+ export declare const getPreferredRole: () => Promise<string | undefined>;
25
+ export declare const getScopes: () => Promise<string[] | undefined>;
26
+ export declare const login: (signInHook: ApiConfiguration["signInHook"]) => Promise<string | undefined>;
27
+ export declare const logout: (signOutHook: ApiConfiguration["signOutHook"]) => Promise<string | undefined>;
@@ -0,0 +1,2 @@
1
+ export declare const ACCOUNT = "gatey_account";
2
+ export declare const TEXT_DOMAIN = "gatey";
package/dist/index.d.ts CHANGED
@@ -1,167 +1,14 @@
1
- import { FormFieldOptionValue, LoginMechanism, SignUpAttribute, SocialProvider, PasswordlessSettings } from '@aws-amplify/ui';
2
- import { ResourcesConfig } from 'aws-amplify';
3
- import { get, post, put, del, head, patch } from 'aws-amplify/api';
4
- import { CustomProvider } from '@aws-amplify/ui-react';
5
- import { StoreDescriptor } from '@wordpress/data';
6
- import { SubscriptionType, WpSuitePluginBase } from '@smart-cloud/wpsuite-core';
7
- import { FetchUserAttributesOutput, FetchMFAPreferenceOutput, FetchAuthSessionOptions, AuthSession } from 'aws-amplify/auth';
8
-
9
- interface Account {
10
- username?: string;
11
- loaded?: boolean;
12
- userAttributes?: FetchUserAttributesOutput;
13
- mfaPreferences?: FetchMFAPreferenceOutput;
14
- }
15
- declare const getAmplifyConfig: () => ResourcesConfig;
16
- declare const configureAmplify: (resourcesConfig: ResourcesConfig, libraryOptions?: Record<string, unknown>) => void;
17
- declare const loadAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
18
- declare const loadUserAttributes: () => Promise<FetchUserAttributesOutput>;
19
- declare const loadMFAPreferences: () => Promise<FetchMFAPreferenceOutput>;
20
- declare const clearMfaPreferences: () => Promise<void>;
21
- declare const getUsername: () => Promise<string | undefined>;
22
- declare const getUserAttributes: () => Promise<FetchUserAttributesOutput | undefined>;
23
- declare const getMfaPreferences: () => Promise<FetchMFAPreferenceOutput | undefined>;
24
- declare const isAuthenticated: () => Promise<boolean>;
25
- declare const isInGroup: (group: string) => Promise<boolean>;
26
- declare const getGroups: () => Promise<string[] | undefined>;
27
- declare const getRoles: () => Promise<string[] | undefined>;
28
- declare const getPreferredRole: () => Promise<string | undefined>;
29
- declare const getScopes: () => Promise<string[] | undefined>;
30
- declare const login: (signInHook: ApiConfiguration["signInHook"]) => Promise<string | undefined>;
31
- declare const logout: (signOutHook: ApiConfiguration["signOutHook"]) => Promise<string | undefined>;
32
-
33
- /**
34
- * Ensures we only keep runtime keys that are part of AuthenticatorConfig.
35
- *
36
- * Defensive: upstream getConfig("gatey") or persisted site.settings may include
37
- * additional keys, but the admin UI and core should only operate on AuthenticatorConfig.
38
- */
39
- declare const sanitizeAuthenticatorConfig: (input: unknown) => AuthenticatorConfig;
40
- declare const actions: {
41
- setAmplifyConfig(amplifyConfig: ResourcesConfig): {
42
- type: string;
43
- amplifyConfig: ResourcesConfig;
44
- };
45
- setAccount(account: Account): {
46
- type: string;
47
- account: Account;
48
- };
49
- clearAccount(): {
50
- type: string;
51
- };
52
- setSignedIn(signedIn: boolean): {
53
- type: string;
54
- signedIn: boolean;
55
- };
56
- setNextUrl(nextUrl: string | undefined | null): {
57
- type: string;
58
- nextUrl: string | null | undefined;
59
- };
60
- setLanguage(language: string | undefined | null): {
61
- type: string;
62
- language: string | null | undefined;
63
- };
64
- setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
65
- type: string;
66
- direction: "ltr" | "rtl" | "auto" | null | undefined;
67
- };
68
- reloadAuthSession(): {
69
- type: string;
70
- };
71
- reloadUserAttributes(): {
72
- type: string;
73
- };
74
- reloadMFAPreferences(): {
75
- type: string;
76
- };
77
- };
78
- interface FormField {
79
- name: string;
80
- type: string;
81
- values?: Array<FormFieldOptionValue>;
82
- }
83
- interface ApiOptions {
84
- headers?: Record<string, string>;
85
- queryParams?: Record<string, string>;
86
- body?: never;
87
- withCredentials?: boolean;
88
- }
89
- interface API {
90
- name: string;
91
- endpoint: string;
92
- region?: string;
93
- authorization: "IAM" | "ID_TOKEN" | "ACCESS_TOKEN";
94
- }
95
- interface ApiConfiguration {
96
- domains?: string;
97
- apis: API[];
98
- signInHook?: {
99
- apiName: string;
100
- path: string;
101
- options?: ApiOptions;
102
- };
103
- signOutHook?: {
104
- apiName: string;
105
- path: string;
106
- options?: ApiOptions;
107
- };
108
- }
109
- interface AuthenticatorConfig {
110
- customProviders: CustomProvider[];
111
- formFields: FormField[];
112
- apiConfigurations: {
113
- default: ApiConfiguration;
114
- secondary?: ApiConfiguration;
115
- };
116
- subscriptionType?: SubscriptionType;
117
- }
118
- interface CustomTranslations {
119
- [key: string]: Record<string, string>;
120
- }
121
- interface State {
122
- amplifyConfig: ResourcesConfig;
123
- account: Account;
124
- signedIn: boolean;
125
- nextUrl: string | undefined | null;
126
- config: AuthenticatorConfig | null;
127
- language: string | undefined | null;
128
- direction: "ltr" | "rtl" | "auto" | undefined | null;
129
- customTranslations: CustomTranslations | null;
130
- reloadAuthSession: number;
131
- reloadUserAttributes: number;
132
- reloadMFAPreferences: number;
133
- }
134
- type Store = StoreDescriptor;
135
- type StoreSelectors = {
136
- getAmplifyConfig(): ResourcesConfig;
137
- getAccount(): Account;
138
- getNextUrl(): string | null | undefined;
139
- isSignedIn(): boolean;
140
- getConfig(): AuthenticatorConfig | null;
141
- getCustomTranslations(): CustomTranslations | null;
142
- getLanguage(): string | undefined | null;
143
- getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
144
- getState(): State;
145
- };
146
- type StoreActions = typeof actions;
147
- declare const getStoreDispatch: (store: Store) => StoreActions;
148
- declare const getStoreSelect: (store: Store) => StoreSelectors;
149
- declare const observeStore: (observableStore: Store, selector: (state: State) => ResourcesConfig | Account | boolean | number | string | null | undefined, onChange: (nextValue: ResourcesConfig | Account | boolean | number | string | null | undefined, previousValue: ResourcesConfig | Account | boolean | number | string | null | undefined) => void) => () => void;
150
-
151
- type GateyReadyEvent = "wpsuite:gatey:ready";
152
- type GateyErrorEvent = "wpsuite:gatey:error";
153
- type GateyPlugin = WpSuitePluginBase & Gatey;
154
- declare function getGateyPlugin(): GateyPlugin;
155
- declare function waitForGateyReady(timeoutMs?: number): Promise<void>;
156
- declare function getStore(timeoutMs?: number): Promise<Store>;
157
-
158
- declare const TEXT_DOMAIN = "gatey";
159
-
160
- interface RoleMapping {
1
+ import { PasswordlessSettings, type LoginMechanism, type SignUpAttribute, type SocialProvider } from "@aws-amplify/ui";
2
+ import { type ResourcesConfig } from "aws-amplify";
3
+ import { del, get, head, patch, post, put } from "aws-amplify/api";
4
+ import { getGateyPlugin, getStore, waitForGateyReady, type GateyErrorEvent, type GateyPlugin, type GateyReadyEvent } from "./runtime";
5
+ import { clearMfaPreferences, getAmplifyConfig, getGroups, getMfaPreferences, getPreferredRole, getRoles, getScopes, getUserAttributes, getUsername, isAuthenticated, isInGroup } from "./auth";
6
+ import { observeStore, type Store } from "./store";
7
+ export interface RoleMapping {
161
8
  cognitoGroup?: string;
162
9
  wordpressRole?: string;
163
10
  }
164
- interface Settings {
11
+ export interface Settings {
165
12
  userPoolConfigurations: {
166
13
  default: ResourcesConfig;
167
14
  secondary?: ResourcesConfig;
@@ -185,7 +32,7 @@ interface Settings {
185
32
  declare const signOut: () => void;
186
33
  declare const setLanguage: (language?: string) => void;
187
34
  declare const setDirection: (direction?: "ltr" | "rtl" | "auto") => void;
188
- interface Cognito {
35
+ export interface Cognito {
189
36
  readonly store: Promise<Store>;
190
37
  readonly observeStore: typeof observeStore;
191
38
  readonly setLanguage: typeof setLanguage;
@@ -212,18 +59,19 @@ interface Cognito {
212
59
  toSignUp?: () => void;
213
60
  toForgotPassword?: () => void;
214
61
  }
215
- interface Gatey {
62
+ export interface Gatey {
216
63
  cognito: Cognito;
217
64
  settings: Settings;
218
65
  nonce: string;
219
66
  restUrl: string;
220
67
  }
221
-
68
+ export { getGateyPlugin, getStore, waitForGateyReady, type GateyErrorEvent, type GateyPlugin, type GateyReadyEvent, };
69
+ export { clearMfaPreferences, getGroups, getMfaPreferences, getPreferredRole, getRoles, getScopes, getUserAttributes, isAuthenticated, isInGroup, };
70
+ export { configureAmplify, getAmplifyConfig, loadAuthSession, loadMFAPreferences, loadUserAttributes, login, logout, type Account, } from "./auth";
71
+ export { getStoreDispatch, getStoreSelect, observeStore, sanitizeAuthenticatorConfig, type AuthenticatorConfig, type CustomTranslations, type FormField, type State, type Store, } from "./store";
222
72
  /**
223
73
  * @deprecated Use `getStore()` instead. Import with `import { getStore } from '@smart-cloud/gatey-core';`
224
74
  */
225
- declare const store: () => Promise<Store>;
226
-
227
- declare const initializeGatey: () => GateyPlugin;
228
-
229
- export { type Account, type AuthenticatorConfig, type Cognito, type CustomTranslations, type FormField, type Gatey, type GateyErrorEvent, type GateyPlugin, type GateyReadyEvent, type RoleMapping, type Settings, type State, type Store, TEXT_DOMAIN, clearMfaPreferences, configureAmplify, getAmplifyConfig, getGateyPlugin, getGroups, getMfaPreferences, getPreferredRole, getRoles, getScopes, getStore, getStoreDispatch, getStoreSelect, getUserAttributes, initializeGatey, isAuthenticated, isInGroup, loadAuthSession, loadMFAPreferences, loadUserAttributes, login, logout, observeStore, sanitizeAuthenticatorConfig, store, waitForGateyReady };
75
+ export declare const store: () => Promise<Store>;
76
+ export { TEXT_DOMAIN } from "./constants";
77
+ export declare const initializeGatey: () => GateyPlugin;
@@ -0,0 +1,8 @@
1
+ import { WpSuitePluginBase } from "@smart-cloud/wpsuite-core";
2
+ import { Gatey } from "./index";
3
+ export type GateyReadyEvent = "wpsuite:gatey:ready";
4
+ export type GateyErrorEvent = "wpsuite:gatey:error";
5
+ export type GateyPlugin = WpSuitePluginBase & Gatey;
6
+ export declare function getGateyPlugin(): GateyPlugin;
7
+ export declare function waitForGateyReady(timeoutMs?: number): Promise<void>;
8
+ export declare function getStore(timeoutMs?: number): Promise<import("./store").Store>;
@@ -0,0 +1,126 @@
1
+ import { type FormFieldOptionValue } from "@aws-amplify/ui";
2
+ import { type CustomProvider } from "@aws-amplify/ui-react";
3
+ import { type ResourcesConfig } from "aws-amplify";
4
+ import { StoreDescriptor } from "@wordpress/data";
5
+ import { type SubscriptionType } from "@smart-cloud/wpsuite-core";
6
+ import { type Account } from "./auth";
7
+ export declare const getAccountFromStorage: (apiConfiguration?: ApiConfiguration) => Promise<Account>;
8
+ /**
9
+ * Ensures we only keep runtime keys that are part of AuthenticatorConfig.
10
+ *
11
+ * Defensive: upstream getConfig("gatey") or persisted site.settings may include
12
+ * additional keys, but the admin UI and core should only operate on AuthenticatorConfig.
13
+ */
14
+ export declare const sanitizeAuthenticatorConfig: (input: unknown) => AuthenticatorConfig;
15
+ declare const actions: {
16
+ setAmplifyConfig(amplifyConfig: ResourcesConfig): {
17
+ type: string;
18
+ amplifyConfig: ResourcesConfig;
19
+ };
20
+ setAccount(account: Account): {
21
+ type: string;
22
+ account: Account;
23
+ };
24
+ clearAccount(): {
25
+ type: string;
26
+ };
27
+ setSignedIn(signedIn: boolean): {
28
+ type: string;
29
+ signedIn: boolean;
30
+ };
31
+ setNextUrl(nextUrl: string | undefined | null): {
32
+ type: string;
33
+ nextUrl: string | null | undefined;
34
+ };
35
+ setLanguage(language: string | undefined | null): {
36
+ type: string;
37
+ language: string | null | undefined;
38
+ };
39
+ setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
40
+ type: string;
41
+ direction: "ltr" | "rtl" | "auto" | null | undefined;
42
+ };
43
+ reloadAuthSession(): {
44
+ type: string;
45
+ };
46
+ reloadUserAttributes(): {
47
+ type: string;
48
+ };
49
+ reloadMFAPreferences(): {
50
+ type: string;
51
+ };
52
+ };
53
+ export interface FormField {
54
+ name: string;
55
+ type: string;
56
+ values?: Array<FormFieldOptionValue>;
57
+ }
58
+ export interface ApiOptions {
59
+ headers?: Record<string, string>;
60
+ queryParams?: Record<string, string>;
61
+ body?: never;
62
+ withCredentials?: boolean;
63
+ }
64
+ export interface API {
65
+ name: string;
66
+ endpoint: string;
67
+ region?: string;
68
+ authorization: "IAM" | "ID_TOKEN" | "ACCESS_TOKEN";
69
+ }
70
+ export interface ApiConfiguration {
71
+ domains?: string;
72
+ apis: API[];
73
+ signInHook?: {
74
+ apiName: string;
75
+ path: string;
76
+ options?: ApiOptions;
77
+ };
78
+ signOutHook?: {
79
+ apiName: string;
80
+ path: string;
81
+ options?: ApiOptions;
82
+ };
83
+ }
84
+ export interface AuthenticatorConfig {
85
+ customProviders: CustomProvider[];
86
+ formFields: FormField[];
87
+ apiConfigurations: {
88
+ default: ApiConfiguration;
89
+ secondary?: ApiConfiguration;
90
+ };
91
+ subscriptionType?: SubscriptionType;
92
+ }
93
+ export interface CustomTranslations {
94
+ [key: string]: Record<string, string>;
95
+ }
96
+ export interface State {
97
+ amplifyConfig: ResourcesConfig;
98
+ account: Account;
99
+ signedIn: boolean;
100
+ nextUrl: string | undefined | null;
101
+ config: AuthenticatorConfig | null;
102
+ language: string | undefined | null;
103
+ direction: "ltr" | "rtl" | "auto" | undefined | null;
104
+ customTranslations: CustomTranslations | null;
105
+ reloadAuthSession: number;
106
+ reloadUserAttributes: number;
107
+ reloadMFAPreferences: number;
108
+ }
109
+ export type Store = StoreDescriptor;
110
+ export type StoreSelectors = {
111
+ getAmplifyConfig(): ResourcesConfig;
112
+ getAccount(): Account;
113
+ getNextUrl(): string | null | undefined;
114
+ isSignedIn(): boolean;
115
+ getConfig(): AuthenticatorConfig | null;
116
+ getCustomTranslations(): CustomTranslations | null;
117
+ getLanguage(): string | undefined | null;
118
+ getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
119
+ getState(): State;
120
+ };
121
+ export type StoreActions = typeof actions;
122
+ export declare const getStoreDispatch: (store: Store) => StoreActions;
123
+ export declare const getStoreSelect: (store: Store) => StoreSelectors;
124
+ export declare const createStore: () => Promise<Store>;
125
+ export declare const observeStore: (observableStore: Store, selector: (state: State) => ResourcesConfig | Account | boolean | number | string | null | undefined, onChange: (nextValue: ResourcesConfig | Account | boolean | number | string | null | undefined, previousValue: ResourcesConfig | Account | boolean | number | string | null | undefined) => void) => () => void;
126
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@smart-cloud/gatey-core",
3
- "version": "2.2.7",
3
+ "version": "2.2.9",
4
4
  "description": "Login & SSO with Amazon Cognito",
5
5
  "author": "Smart Cloud Solutions Inc.",
6
6
  "license": "MIT",
@@ -19,35 +19,37 @@
19
19
  "dist"
20
20
  ],
21
21
  "scripts": {
22
- "build": "tsup --minify",
22
+ "build": "yarn build:js && yarn build:types",
23
+ "build:js": "tsup --minify",
24
+ "build:types": "tsc -p tsconfig.types.json",
23
25
  "lint": "eslint 'src/**/*.ts' --report-unused-disable-directives --max-warnings 0",
24
26
  "test": "echo \"Error: no test specified\" && exit 1",
25
- "publish": "WPSUITE_PREMIUM=true tsup --minify && npm publish --access=public"
27
+ "publish": "WPSUITE_PREMIUM=true yarn build && npm publish --access=public"
26
28
  },
27
29
  "publishConfig": {
28
30
  "registry": "https://registry.npmjs.org/",
29
31
  "scope": "@smart-cloud/gatey-core"
30
32
  },
31
33
  "dependencies": {
32
- "@smart-cloud/wpsuite-core": "^2.2.10"
34
+ "@smart-cloud/wpsuite-core": "^2.2.11"
33
35
  },
34
36
  "peerDependencies": {
35
37
  "@aws-amplify/ui-react": "^6.15.0",
36
- "@wordpress/data": "^10.41.0",
37
- "aws-amplify": "^6.16.3"
38
+ "@wordpress/data": "^10.44.0",
39
+ "aws-amplify": "^6.16.4"
38
40
  },
39
41
  "devDependencies": {
40
42
  "@aws-amplify/ui-react": "^6.15.0",
41
43
  "@eslint/js": "^10.0.1",
42
- "@types/node": "^25.5.0",
43
- "@typescript-eslint/eslint-plugin": "^8.57.0",
44
- "@typescript-eslint/parser": "^8.57.0",
45
- "@wordpress/data": "^10.41.0",
46
- "aws-amplify": "^6.16.3",
47
- "eslint": "^10.0.3",
48
- "globals": "^17.4.0",
44
+ "@types/node": "^25.6.0",
45
+ "@typescript-eslint/eslint-plugin": "^8.58.2",
46
+ "@typescript-eslint/parser": "^8.58.2",
47
+ "@wordpress/data": "^10.44.0",
48
+ "aws-amplify": "^6.16.4",
49
+ "eslint": "^10.2.1",
50
+ "globals": "^17.5.0",
49
51
  "tsup": "^8.5.1",
50
- "typescript": "^5.9.3",
51
- "typescript-eslint": "^8.57.0"
52
+ "typescript": "^6.0.3",
53
+ "typescript-eslint": "^8.58.2"
52
54
  }
53
55
  }
package/dist/index.d.cts DELETED
@@ -1,229 +0,0 @@
1
- import { FormFieldOptionValue, LoginMechanism, SignUpAttribute, SocialProvider, PasswordlessSettings } from '@aws-amplify/ui';
2
- import { ResourcesConfig } from 'aws-amplify';
3
- import { get, post, put, del, head, patch } from 'aws-amplify/api';
4
- import { CustomProvider } from '@aws-amplify/ui-react';
5
- import { StoreDescriptor } from '@wordpress/data';
6
- import { SubscriptionType, WpSuitePluginBase } from '@smart-cloud/wpsuite-core';
7
- import { FetchUserAttributesOutput, FetchMFAPreferenceOutput, FetchAuthSessionOptions, AuthSession } from 'aws-amplify/auth';
8
-
9
- interface Account {
10
- username?: string;
11
- loaded?: boolean;
12
- userAttributes?: FetchUserAttributesOutput;
13
- mfaPreferences?: FetchMFAPreferenceOutput;
14
- }
15
- declare const getAmplifyConfig: () => ResourcesConfig;
16
- declare const configureAmplify: (resourcesConfig: ResourcesConfig, libraryOptions?: Record<string, unknown>) => void;
17
- declare const loadAuthSession: (options?: FetchAuthSessionOptions) => Promise<AuthSession>;
18
- declare const loadUserAttributes: () => Promise<FetchUserAttributesOutput>;
19
- declare const loadMFAPreferences: () => Promise<FetchMFAPreferenceOutput>;
20
- declare const clearMfaPreferences: () => Promise<void>;
21
- declare const getUsername: () => Promise<string | undefined>;
22
- declare const getUserAttributes: () => Promise<FetchUserAttributesOutput | undefined>;
23
- declare const getMfaPreferences: () => Promise<FetchMFAPreferenceOutput | undefined>;
24
- declare const isAuthenticated: () => Promise<boolean>;
25
- declare const isInGroup: (group: string) => Promise<boolean>;
26
- declare const getGroups: () => Promise<string[] | undefined>;
27
- declare const getRoles: () => Promise<string[] | undefined>;
28
- declare const getPreferredRole: () => Promise<string | undefined>;
29
- declare const getScopes: () => Promise<string[] | undefined>;
30
- declare const login: (signInHook: ApiConfiguration["signInHook"]) => Promise<string | undefined>;
31
- declare const logout: (signOutHook: ApiConfiguration["signOutHook"]) => Promise<string | undefined>;
32
-
33
- /**
34
- * Ensures we only keep runtime keys that are part of AuthenticatorConfig.
35
- *
36
- * Defensive: upstream getConfig("gatey") or persisted site.settings may include
37
- * additional keys, but the admin UI and core should only operate on AuthenticatorConfig.
38
- */
39
- declare const sanitizeAuthenticatorConfig: (input: unknown) => AuthenticatorConfig;
40
- declare const actions: {
41
- setAmplifyConfig(amplifyConfig: ResourcesConfig): {
42
- type: string;
43
- amplifyConfig: ResourcesConfig;
44
- };
45
- setAccount(account: Account): {
46
- type: string;
47
- account: Account;
48
- };
49
- clearAccount(): {
50
- type: string;
51
- };
52
- setSignedIn(signedIn: boolean): {
53
- type: string;
54
- signedIn: boolean;
55
- };
56
- setNextUrl(nextUrl: string | undefined | null): {
57
- type: string;
58
- nextUrl: string | null | undefined;
59
- };
60
- setLanguage(language: string | undefined | null): {
61
- type: string;
62
- language: string | null | undefined;
63
- };
64
- setDirection(direction: "ltr" | "rtl" | "auto" | undefined | null): {
65
- type: string;
66
- direction: "ltr" | "rtl" | "auto" | null | undefined;
67
- };
68
- reloadAuthSession(): {
69
- type: string;
70
- };
71
- reloadUserAttributes(): {
72
- type: string;
73
- };
74
- reloadMFAPreferences(): {
75
- type: string;
76
- };
77
- };
78
- interface FormField {
79
- name: string;
80
- type: string;
81
- values?: Array<FormFieldOptionValue>;
82
- }
83
- interface ApiOptions {
84
- headers?: Record<string, string>;
85
- queryParams?: Record<string, string>;
86
- body?: never;
87
- withCredentials?: boolean;
88
- }
89
- interface API {
90
- name: string;
91
- endpoint: string;
92
- region?: string;
93
- authorization: "IAM" | "ID_TOKEN" | "ACCESS_TOKEN";
94
- }
95
- interface ApiConfiguration {
96
- domains?: string;
97
- apis: API[];
98
- signInHook?: {
99
- apiName: string;
100
- path: string;
101
- options?: ApiOptions;
102
- };
103
- signOutHook?: {
104
- apiName: string;
105
- path: string;
106
- options?: ApiOptions;
107
- };
108
- }
109
- interface AuthenticatorConfig {
110
- customProviders: CustomProvider[];
111
- formFields: FormField[];
112
- apiConfigurations: {
113
- default: ApiConfiguration;
114
- secondary?: ApiConfiguration;
115
- };
116
- subscriptionType?: SubscriptionType;
117
- }
118
- interface CustomTranslations {
119
- [key: string]: Record<string, string>;
120
- }
121
- interface State {
122
- amplifyConfig: ResourcesConfig;
123
- account: Account;
124
- signedIn: boolean;
125
- nextUrl: string | undefined | null;
126
- config: AuthenticatorConfig | null;
127
- language: string | undefined | null;
128
- direction: "ltr" | "rtl" | "auto" | undefined | null;
129
- customTranslations: CustomTranslations | null;
130
- reloadAuthSession: number;
131
- reloadUserAttributes: number;
132
- reloadMFAPreferences: number;
133
- }
134
- type Store = StoreDescriptor;
135
- type StoreSelectors = {
136
- getAmplifyConfig(): ResourcesConfig;
137
- getAccount(): Account;
138
- getNextUrl(): string | null | undefined;
139
- isSignedIn(): boolean;
140
- getConfig(): AuthenticatorConfig | null;
141
- getCustomTranslations(): CustomTranslations | null;
142
- getLanguage(): string | undefined | null;
143
- getDirection(): "ltr" | "rtl" | "auto" | undefined | null;
144
- getState(): State;
145
- };
146
- type StoreActions = typeof actions;
147
- declare const getStoreDispatch: (store: Store) => StoreActions;
148
- declare const getStoreSelect: (store: Store) => StoreSelectors;
149
- declare const observeStore: (observableStore: Store, selector: (state: State) => ResourcesConfig | Account | boolean | number | string | null | undefined, onChange: (nextValue: ResourcesConfig | Account | boolean | number | string | null | undefined, previousValue: ResourcesConfig | Account | boolean | number | string | null | undefined) => void) => () => void;
150
-
151
- type GateyReadyEvent = "wpsuite:gatey:ready";
152
- type GateyErrorEvent = "wpsuite:gatey:error";
153
- type GateyPlugin = WpSuitePluginBase & Gatey;
154
- declare function getGateyPlugin(): GateyPlugin;
155
- declare function waitForGateyReady(timeoutMs?: number): Promise<void>;
156
- declare function getStore(timeoutMs?: number): Promise<Store>;
157
-
158
- declare const TEXT_DOMAIN = "gatey";
159
-
160
- interface RoleMapping {
161
- cognitoGroup?: string;
162
- wordpressRole?: string;
163
- }
164
- interface Settings {
165
- userPoolConfigurations: {
166
- default: ResourcesConfig;
167
- secondary?: ResourcesConfig;
168
- };
169
- secondaryUserPoolDomains?: string;
170
- mappings: RoleMapping[];
171
- loginMechanisms: LoginMechanism[];
172
- signUpAttributes: SignUpAttribute[];
173
- socialProviders?: SocialProvider[];
174
- integrateWpLogin: boolean;
175
- cookieExpiration?: number;
176
- signInPage?: string;
177
- redirectSignIn?: string;
178
- redirectSignOut?: string;
179
- customTranslationsUrl?: string;
180
- enablePoweredBy?: boolean;
181
- debugLoggingEnabled?: boolean;
182
- hideSignUp?: boolean;
183
- passwordlessSettings?: PasswordlessSettings;
184
- }
185
- declare const signOut: () => void;
186
- declare const setLanguage: (language?: string) => void;
187
- declare const setDirection: (direction?: "ltr" | "rtl" | "auto") => void;
188
- interface Cognito {
189
- readonly store: Promise<Store>;
190
- readonly observeStore: typeof observeStore;
191
- readonly setLanguage: typeof setLanguage;
192
- readonly setDirection: typeof setDirection;
193
- readonly getUsername: typeof getUsername;
194
- readonly getUserAttributes: typeof getUserAttributes;
195
- readonly getMfaPreferences: typeof getMfaPreferences;
196
- readonly clearMfaPreferences: typeof clearMfaPreferences;
197
- readonly isAuthenticated: typeof isAuthenticated;
198
- readonly isInGroup: typeof isInGroup;
199
- readonly getGroups: typeof getGroups;
200
- readonly getRoles: typeof getRoles;
201
- readonly getScopes: typeof getScopes;
202
- readonly getPreferredRole: typeof getPreferredRole;
203
- readonly signOut: typeof signOut;
204
- readonly getAmplifyConfig: typeof getAmplifyConfig;
205
- readonly get: typeof get;
206
- readonly post: typeof post;
207
- readonly put: typeof put;
208
- readonly del: typeof del;
209
- readonly head: typeof head;
210
- readonly patch: typeof patch;
211
- toSignIn?: () => void;
212
- toSignUp?: () => void;
213
- toForgotPassword?: () => void;
214
- }
215
- interface Gatey {
216
- cognito: Cognito;
217
- settings: Settings;
218
- nonce: string;
219
- restUrl: string;
220
- }
221
-
222
- /**
223
- * @deprecated Use `getStore()` instead. Import with `import { getStore } from '@smart-cloud/gatey-core';`
224
- */
225
- declare const store: () => Promise<Store>;
226
-
227
- declare const initializeGatey: () => GateyPlugin;
228
-
229
- export { type Account, type AuthenticatorConfig, type Cognito, type CustomTranslations, type FormField, type Gatey, type GateyErrorEvent, type GateyPlugin, type GateyReadyEvent, type RoleMapping, type Settings, type State, type Store, TEXT_DOMAIN, clearMfaPreferences, configureAmplify, getAmplifyConfig, getGateyPlugin, getGroups, getMfaPreferences, getPreferredRole, getRoles, getScopes, getStore, getStoreDispatch, getStoreSelect, getUserAttributes, initializeGatey, isAuthenticated, isInGroup, loadAuthSession, loadMFAPreferences, loadUserAttributes, login, logout, observeStore, sanitizeAuthenticatorConfig, store, waitForGateyReady };