Skip to content

Commit 25d8e04

Browse files
committed
* Updating clients with new domain and APIs
* Removing "Servlet" references * Removing Prime Mock (not needed now) * Java client now uses the client and domain from fusionauth-app with some removal of internal junk
1 parent 4106f56 commit 25d8e04

File tree

1 file changed

+108
-16
lines changed

1 file changed

+108
-16
lines changed

src/FusionAuthClient.ts

Lines changed: 108 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2019, FusionAuth, All Rights Reserved
2+
* Copyright (c) 2019-2022, FusionAuth, All Rights Reserved
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -154,9 +154,9 @@ export class FusionAuthClient {
154154
/**
155155
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
156156
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
157-
* your password, you must obtain a Truest Token by completing a Two-Factor Step-Up authentication.
157+
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
158158
*
159-
* An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API.
159+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
160160
*
161161
* @param {string} changePasswordId The change password Id used to find the user. This value is generated by FusionAuth once the change password workflow has been initiated.
162162
* @returns {Promise<ClientResponse<void>>}
@@ -172,9 +172,9 @@ export class FusionAuthClient {
172172
/**
173173
* Check to see if the user must obtain a Trust Token Id in order to complete a change password request.
174174
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
175-
* your password, you must obtain a Truest Token by completing a Two-Factor Step-Up authentication.
175+
* your password, you must obtain a Trust Token by completing a Two-Factor Step-Up authentication.
176176
*
177-
* An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API.
177+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
178178
*
179179
* @param {string} encodedJWT The encoded JWT (access token).
180180
* @returns {Promise<ClientResponse<void>>}
@@ -190,9 +190,9 @@ export class FusionAuthClient {
190190
/**
191191
* Check to see if the user must obtain a Trust Request Id in order to complete a change password request.
192192
* When a user has enabled Two-Factor authentication, before you are allowed to use the Change Password API to change
193-
* your password, you must obtain a Truest Request Id by completing a Two-Factor Step-Up authentication.
193+
* your password, you must obtain a Trust Request Id by completing a Two-Factor Step-Up authentication.
194194
*
195-
* An HTTP status code of 412 indicates that a Trust Token is required to make a POST request to this API.
195+
* An HTTP status code of 400 with a general error code of [TrustTokenRequired] indicates that a Trust Token is required to make a POST request to this API.
196196
*
197197
* @param {string} loginId The loginId of the User that you intend to change the password for.
198198
* @returns {Promise<ClientResponse<void>>}
@@ -1728,6 +1728,23 @@ export class FusionAuthClient {
17281728
.go();
17291729
}
17301730

1731+
/**
1732+
* Sends a ping to FusionAuth indicating that the user was automatically logged into an application. When using
1733+
* FusionAuth's SSO or your own, you should call this if the user is already logged in centrally, but accesses an
1734+
* application where they no longer have a session. This helps correctly track login counts, times and helps with
1735+
* reporting.
1736+
*
1737+
* @param {LoginPingRequest} request The login request that contains the user credentials used to log them in.
1738+
* @returns {Promise<ClientResponse<LoginResponse>>}
1739+
*/
1740+
loginPingWithRequest(request: LoginPingRequest): Promise<ClientResponse<LoginResponse>> {
1741+
return this.start<LoginResponse, Errors>()
1742+
.withUri('/api/login')
1743+
.withJSONBody(request)
1744+
.withMethod("PUT")
1745+
.go();
1746+
}
1747+
17311748
/**
17321749
* The Logout API is intended to be used to remove the refresh token and access token cookies if they exist on the
17331750
* client and revoke the refresh token stored. This API does nothing if the request does not contain an access
@@ -3364,6 +3381,27 @@ export class FusionAuthClient {
33643381
.go();
33653382
}
33663383

3384+
/**
3385+
* Retrieve a user's two-factor status.
3386+
*
3387+
* This can be used to see if a user will need to complete a two-factor challenge to complete a login,
3388+
* and optionally identify the state of the two-factor trust across various applications.
3389+
*
3390+
* @param {UUID} userId The user Id to retrieve the Two-Factor status.
3391+
* @param {UUID} applicationId The optional applicationId to verify.
3392+
* @param {string} twoFactorTrustId The optional two-factor trust Id to verify.
3393+
* @returns {Promise<ClientResponse<TwoFactorStatusResponse>>}
3394+
*/
3395+
retrieveTwoFactorStatus(userId: UUID, applicationId: UUID, twoFactorTrustId: string): Promise<ClientResponse<TwoFactorStatusResponse>> {
3396+
return this.start<TwoFactorStatusResponse, Errors>()
3397+
.withUri('/api/two-factor/status')
3398+
.withParameter('userId', userId)
3399+
.withParameter('applicationId', applicationId)
3400+
.withUriSegment(twoFactorTrustId)
3401+
.withMethod("GET")
3402+
.go();
3403+
}
3404+
33673405
/**
33683406
* Retrieves the user for the given Id.
33693407
*
@@ -4879,6 +4917,7 @@ export interface AccessToken {
48794917
expires_in?: number;
48804918
id_token?: string;
48814919
refresh_token?: string;
4920+
refresh_token_id?: UUID;
48824921
scope?: string;
48834922
token_type?: TokenType;
48844923
userId?: UUID;
@@ -4929,6 +4968,9 @@ export enum Algorithm {
49294968
HS256 = "HS256",
49304969
HS384 = "HS384",
49314970
HS512 = "HS512",
4971+
PS256 = "PS256",
4972+
PS384 = "PS384",
4973+
PS512 = "PS512",
49324974
RS256 = "RS256",
49334975
RS384 = "RS384",
49344976
RS512 = "RS512",
@@ -5011,6 +5053,7 @@ export interface Application {
50115053
cleanSpeakConfiguration?: CleanSpeakConfiguration;
50125054
data?: Record<string, any>;
50135055
emailConfiguration?: ApplicationEmailConfiguration;
5056+
externalIdentifierConfiguration?: ApplicationExternalIdentifierConfiguration;
50145057
formConfiguration?: ApplicationFormConfiguration;
50155058
id?: UUID;
50165059
insertInstant?: number;
@@ -5060,11 +5103,10 @@ export interface ApplicationEmailConfiguration {
50605103
}
50615104

50625105
/**
5063-
* Events that are bound to applications.
5064-
*
5065-
* @author Brian Pontarelli
5106+
* @author Daniel DeGroff
50665107
*/
5067-
export interface ApplicationEvent {
5108+
export interface ApplicationExternalIdentifierConfiguration {
5109+
twoFactorTrustIdTimeToLiveInSeconds?: number;
50685110
}
50695111

50705112
/**
@@ -5080,7 +5122,18 @@ export interface ApplicationFormConfiguration {
50805122
*/
50815123
export interface ApplicationMultiFactorConfiguration {
50825124
email?: MultiFactorEmailTemplate;
5125+
loginPolicy?: MultiFactorLoginPolicy;
50835126
sms?: MultiFactorSMSTemplate;
5127+
trustPolicy?: ApplicationMultiFactorTrustPolicy;
5128+
}
5129+
5130+
/**
5131+
* @author Daniel DeGroff
5132+
*/
5133+
export enum ApplicationMultiFactorTrustPolicy {
5134+
Any = "Any",
5135+
This = "This",
5136+
None = "None"
50845137
}
50855138

50865139
/**
@@ -5100,7 +5153,6 @@ export interface ApplicationRegistrationDeletePolicy {
51005153
export interface ApplicationRequest extends BaseEventRequest {
51015154
application?: Application;
51025155
role?: ApplicationRole;
5103-
webhookIds?: Array<UUID>;
51045156
}
51055157

51065158
/**
@@ -5278,6 +5330,7 @@ export interface BaseElasticSearchCriteria extends BaseSearchCriteria {
52785330
* @author Brian Pontarelli
52795331
*/
52805332
export interface BaseEvent {
5333+
applicationIds?: Array<UUID>;
52815334
createInstant?: number;
52825335
id?: UUID;
52835336
info?: EventInfo;
@@ -5706,6 +5759,7 @@ export interface EmailAddress {
57065759
*/
57075760
export interface EmailConfiguration {
57085761
additionalHeaders?: Array<EmailHeader>;
5762+
debug?: boolean;
57095763
defaultFromEmail?: string;
57105764
defaultFromName?: string;
57115765
emailUpdateEmailTemplateId?: UUID;
@@ -6800,6 +6854,7 @@ export interface IdentityProviderLink {
68006854
*/
68016855
export enum IdentityProviderLinkingStrategy {
68026856
CreatePendingLink = "CreatePendingLink",
6857+
Disabled = "Disabled",
68036858
LinkAnonymously = "LinkAnonymously",
68046859
LinkByEmail = "LinkByEmail",
68056860
LinkByEmailForExistingUser = "LinkByEmailForExistingUser",
@@ -7141,7 +7196,6 @@ export interface JWTConfiguration extends Enableable {
71417196
* @author Brian Pontarelli
71427197
*/
71437198
export interface JWTPublicKeyUpdateEvent extends BaseEvent {
7144-
applicationIds?: Array<UUID>;
71457199
}
71467200

71477201
/**
@@ -7160,12 +7214,14 @@ export interface JWTRefreshEvent extends BaseEvent {
71607214
/**
71617215
* API response for refreshing a JWT with a Refresh Token.
71627216
* <p>
7163-
* Using a different response object from RefreshTokenResponse because the retrieve response will return an object for refreshToken, and this is a string.
7217+
* Using a different response object from RefreshTokenResponse because the retrieve response will return an object for refreshToken, and this is a
7218+
* string.
71647219
*
71657220
* @author Daniel DeGroff
71667221
*/
71677222
export interface JWTRefreshResponse {
71687223
refreshToken?: string;
7224+
refreshTokenId?: UUID;
71697225
token?: string;
71707226
}
71717227

@@ -7178,6 +7234,7 @@ export interface JWTRefreshResponse {
71787234
export interface JWTRefreshTokenRevokeEvent extends BaseEvent {
71797235
applicationId?: UUID;
71807236
applicationTimeToLiveInSeconds?: Record<UUID, number>;
7237+
refreshToken?: RefreshToken;
71817238
user?: User;
71827239
userId?: UUID;
71837240
}
@@ -7479,6 +7536,15 @@ export enum LoginIdType {
74797536
username = "username"
74807537
}
74817538

7539+
/**
7540+
* Login Ping API request object.
7541+
*
7542+
* @author Daniel DeGroff
7543+
*/
7544+
export interface LoginPingRequest extends BaseLoginRequest {
7545+
userId?: UUID;
7546+
}
7547+
74827548
/**
74837549
* The summary of the action that is preventing login to be returned on the login response.
74847550
*
@@ -7569,6 +7635,7 @@ export interface LoginResponse {
75697635
methods?: Array<TwoFactorMethod>;
75707636
pendingIdPLinkId?: string;
75717637
refreshToken?: string;
7638+
refreshTokenId?: UUID;
75727639
registrationVerificationId?: string;
75737640
state?: Record<string, any>;
75747641
threatsDetected?: Array<AuthenticationThreats>;
@@ -7761,6 +7828,14 @@ export interface MultiFactorEmailTemplate {
77617828
templateId?: UUID;
77627829
}
77637830

7831+
/**
7832+
* @author Daniel DeGroff
7833+
*/
7834+
export enum MultiFactorLoginPolicy {
7835+
Disabled = "Disabled",
7836+
Enabled = "Enabled"
7837+
}
7838+
77647839
export interface MultiFactorSMSMethod extends Enableable {
77657840
messengerId?: UUID;
77667841
templateId?: UUID;
@@ -8225,11 +8300,13 @@ export interface ReactorStatus {
82258300
advancedLambdas?: ReactorFeatureStatus;
82268301
advancedMultiFactorAuthentication?: ReactorFeatureStatus;
82278302
advancedRegistration?: ReactorFeatureStatus;
8303+
applicationMultiFactorAuthentication?: ReactorFeatureStatus;
82288304
applicationThemes?: ReactorFeatureStatus;
82298305
breachedPasswordDetection?: ReactorFeatureStatus;
82308306
connectors?: ReactorFeatureStatus;
82318307
entityManagement?: ReactorFeatureStatus;
82328308
expiration?: string;
8309+
licenseAttributes?: Record<string, string>;
82338310
licensed?: boolean;
82348311
scimServer?: ReactorFeatureStatus;
82358312
threatDetection?: ReactorFeatureStatus;
@@ -8899,6 +8976,7 @@ export interface TenantLoginConfiguration {
88998976
export interface TenantMultiFactorConfiguration {
89008977
authenticator?: MultiFactorAuthenticatorMethod;
89018978
email?: MultiFactorEmailMethod;
8979+
loginPolicy?: MultiFactorLoginPolicy;
89028980
sms?: MultiFactorSMSMethod;
89038981
}
89048982

@@ -8931,6 +9009,7 @@ export interface TenantRegistrationConfiguration {
89319009
export interface TenantRequest extends BaseEventRequest {
89329010
sourceTenantId?: UUID;
89339011
tenant?: Tenant;
9012+
webhookIds?: Array<UUID>;
89349013
}
89359014

89369015
/**
@@ -9239,6 +9318,20 @@ export interface TwoFactorStartResponse {
92399318
twoFactorId?: string;
92409319
}
92419320

9321+
/**
9322+
* @author Daniel DeGroff
9323+
*/
9324+
export interface TwoFactorStatusResponse {
9325+
trusts?: Array<TwoFactorTrust>;
9326+
twoFactorTrustId?: string;
9327+
}
9328+
9329+
export interface TwoFactorTrust {
9330+
applicationId?: UUID;
9331+
expiration?: number;
9332+
startInstant?: number;
9333+
}
9334+
92429335
export interface UIConfiguration {
92439336
headerColor?: string;
92449337
logoURL?: string;
@@ -9330,7 +9423,6 @@ export interface UserActionEvent extends BaseEvent {
93309423
actioneeUserId?: UUID;
93319424
actionerUserId?: UUID;
93329425
actionId?: UUID;
9333-
applicationIds?: Array<UUID>;
93349426
comment?: string;
93359427
email?: Email;
93369428
emailedUser?: boolean;
@@ -10036,7 +10128,6 @@ export interface VersionResponse {
1003610128
* @author Brian Pontarelli
1003710129
*/
1003810130
export interface Webhook {
10039-
applicationIds?: Array<UUID>;
1004010131
connectTimeout?: number;
1004110132
data?: Record<string, any>;
1004210133
description?: string;
@@ -10050,6 +10141,7 @@ export interface Webhook {
1005010141
lastUpdateInstant?: number;
1005110142
readTimeout?: number;
1005210143
sslCertificate?: string;
10144+
tenantIds?: Array<UUID>;
1005310145
url?: string;
1005410146
}
1005510147

0 commit comments

Comments
 (0)