@fusionauth/typescript-client 1.39.0 → 1.41.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.
@@ -187,6 +187,26 @@ class FusionAuthClient {
187
187
  .withMethod("GET")
188
188
  .go();
189
189
  }
190
+ /**
191
+ * Make a Client Credentials grant request to obtain an access token.
192
+ *
193
+ * @param {string} client_id The client identifier. The client Id is the Id of the FusionAuth Entity in which you are attempting to authenticate.
194
+ * @param {string} client_secret The client secret used to authenticate this request.
195
+ * @param {string} scope (Optional) This parameter is used to indicate which target entity you are requesting access. To request access to an entity, use the format target-entity:<target-entity-id>:<roles>. Roles are an optional comma separated list.
196
+ * @returns {Promise<ClientResponse<AccessToken>>}
197
+ */
198
+ clientCredentialsGrant(client_id, client_secret, scope) {
199
+ let body = new url_1.URLSearchParams();
200
+ body.append('client_id', client_id);
201
+ body.append('client_secret', client_secret);
202
+ body.append('grant_type', 'client_credentials');
203
+ body.append('scope', scope);
204
+ return this.startAnonymous()
205
+ .withUri('/oauth2/token')
206
+ .withFormData(body)
207
+ .withMethod("POST")
208
+ .go();
209
+ }
190
210
  /**
191
211
  * Adds a comment to the user's account.
192
212
  *
@@ -200,6 +220,45 @@ class FusionAuthClient {
200
220
  .withMethod("POST")
201
221
  .go();
202
222
  }
223
+ /**
224
+ * Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge without logging the user in
225
+ *
226
+ * @param {WebAuthnLoginRequest} request An object containing data necessary for completing the authentication ceremony
227
+ * @returns {Promise<ClientResponse<WebAuthnAssertResponse>>}
228
+ */
229
+ completeWebAuthnAssertion(request) {
230
+ return this.startAnonymous()
231
+ .withUri('/api/webauthn/assert')
232
+ .withJSONBody(request)
233
+ .withMethod("POST")
234
+ .go();
235
+ }
236
+ /**
237
+ * Complete a WebAuthn authentication ceremony by validating the signature against the previously generated challenge and then login the user in
238
+ *
239
+ * @param {WebAuthnLoginRequest} request An object containing data necessary for completing the authentication ceremony
240
+ * @returns {Promise<ClientResponse<LoginResponse>>}
241
+ */
242
+ completeWebAuthnLogin(request) {
243
+ return this.startAnonymous()
244
+ .withUri('/api/webauthn/login')
245
+ .withJSONBody(request)
246
+ .withMethod("POST")
247
+ .go();
248
+ }
249
+ /**
250
+ * Complete a WebAuthn registration ceremony by validating the client request and saving the new credential
251
+ *
252
+ * @param {WebAuthnRegisterCompleteRequest} request An object containing data necessary for completing the registration ceremony
253
+ * @returns {Promise<ClientResponse<WebAuthnRegisterCompleteResponse>>}
254
+ */
255
+ completeWebAuthnRegistration(request) {
256
+ return this.start()
257
+ .withUri('/api/webauthn/register/complete')
258
+ .withJSONBody(request)
259
+ .withMethod("POST")
260
+ .go();
261
+ }
203
262
  /**
204
263
  * Creates an API key. You can optionally specify a unique Id for the key, if not provided one will be generated.
205
264
  * an API key can only be created with equal or lesser authority. An API key cannot create another API key unless it is granted
@@ -1192,6 +1251,19 @@ class FusionAuthClient {
1192
1251
  .withMethod("DELETE")
1193
1252
  .go();
1194
1253
  }
1254
+ /**
1255
+ * Deletes the WebAuthn credential for the given Id.
1256
+ *
1257
+ * @param {UUID} id The Id of the WebAuthn credential to delete.
1258
+ * @returns {Promise<ClientResponse<void>>}
1259
+ */
1260
+ deleteWebAuthnCredential(id) {
1261
+ return this.start()
1262
+ .withUri('/api/webauthn')
1263
+ .withUriSegment(id)
1264
+ .withMethod("DELETE")
1265
+ .go();
1266
+ }
1195
1267
  /**
1196
1268
  * Deletes the webhook for the given Id.
1197
1269
  *
@@ -1537,6 +1609,19 @@ class FusionAuthClient {
1537
1609
  .withMethod("POST")
1538
1610
  .go();
1539
1611
  }
1612
+ /**
1613
+ * Import a WebAuthn credential
1614
+ *
1615
+ * @param {WebAuthnCredentialImportRequest} request An object containing data necessary for importing the credential
1616
+ * @returns {Promise<ClientResponse<void>>}
1617
+ */
1618
+ importWebAuthnCredential(request) {
1619
+ return this.start()
1620
+ .withUri('/api/webauthn/import')
1621
+ .withJSONBody(request)
1622
+ .withMethod("POST")
1623
+ .go();
1624
+ }
1540
1625
  /**
1541
1626
  * Inspect an access token issued by FusionAuth.
1542
1627
  *
@@ -3468,6 +3553,32 @@ class FusionAuthClient {
3468
3553
  .withMethod("GET")
3469
3554
  .go();
3470
3555
  }
3556
+ /**
3557
+ * Retrieves the WebAuthn credential for the given Id.
3558
+ *
3559
+ * @param {UUID} id The Id of the WebAuthn credential.
3560
+ * @returns {Promise<ClientResponse<WebAuthnCredentialResponse>>}
3561
+ */
3562
+ retrieveWebAuthnCredential(id) {
3563
+ return this.start()
3564
+ .withUri('/api/webauthn')
3565
+ .withUriSegment(id)
3566
+ .withMethod("GET")
3567
+ .go();
3568
+ }
3569
+ /**
3570
+ * Retrieves all WebAuthn credentials for the given user.
3571
+ *
3572
+ * @param {UUID} userId The user's ID.
3573
+ * @returns {Promise<ClientResponse<WebAuthnCredentialResponse>>}
3574
+ */
3575
+ retrieveWebAuthnCredentialsForUser(userId) {
3576
+ return this.start()
3577
+ .withUri('/api/webauthn')
3578
+ .withParameter('userId', userId)
3579
+ .withMethod("GET")
3580
+ .go();
3581
+ }
3471
3582
  /**
3472
3583
  * Retrieves the webhook for the given Id. If you pass in null for the id, this will return all the webhooks.
3473
3584
  *
@@ -3961,6 +4072,32 @@ class FusionAuthClient {
3961
4072
  .withMethod("POST")
3962
4073
  .go();
3963
4074
  }
4075
+ /**
4076
+ * Start a WebAuthn authentication ceremony by generating a new challenge for the user
4077
+ *
4078
+ * @param {WebAuthnStartRequest} request An object containing data necessary for starting the authentication ceremony
4079
+ * @returns {Promise<ClientResponse<WebAuthnStartResponse>>}
4080
+ */
4081
+ startWebAuthnLogin(request) {
4082
+ return this.start()
4083
+ .withUri('/api/webauthn/start')
4084
+ .withJSONBody(request)
4085
+ .withMethod("POST")
4086
+ .go();
4087
+ }
4088
+ /**
4089
+ * Start a WebAuthn registration ceremony by generating a new challenge for the user
4090
+ *
4091
+ * @param {WebAuthnRegisterStartRequest} request An object containing data necessary for starting the registration ceremony
4092
+ * @returns {Promise<ClientResponse<WebAuthnRegisterStartResponse>>}
4093
+ */
4094
+ startWebAuthnRegistration(request) {
4095
+ return this.start()
4096
+ .withUri('/api/webauthn/register/start')
4097
+ .withJSONBody(request)
4098
+ .withMethod("POST")
4099
+ .go();
4100
+ }
3964
4101
  /**
3965
4102
  * Complete login using a 2FA challenge
3966
4103
  *
@@ -4617,6 +4754,31 @@ var ApplicationMultiFactorTrustPolicy;
4617
4754
  ApplicationMultiFactorTrustPolicy["This"] = "This";
4618
4755
  ApplicationMultiFactorTrustPolicy["None"] = "None";
4619
4756
  })(ApplicationMultiFactorTrustPolicy = exports.ApplicationMultiFactorTrustPolicy || (exports.ApplicationMultiFactorTrustPolicy = {}));
4757
+ /**
4758
+ * Used to communicate whether and how authenticator attestation should be delivered to the Relying Party
4759
+ *
4760
+ * @author Spencer Witt
4761
+ */
4762
+ var AttestationConveyancePreference;
4763
+ (function (AttestationConveyancePreference) {
4764
+ AttestationConveyancePreference["none"] = "none";
4765
+ AttestationConveyancePreference["indirect"] = "indirect";
4766
+ AttestationConveyancePreference["direct"] = "direct";
4767
+ AttestationConveyancePreference["enterprise"] = "enterprise";
4768
+ })(AttestationConveyancePreference = exports.AttestationConveyancePreference || (exports.AttestationConveyancePreference = {}));
4769
+ /**
4770
+ * Used to indicate what type of attestation was included in the authenticator response for a given WebAuthn credential at the time it was created
4771
+ *
4772
+ * @author Spencer Witt
4773
+ */
4774
+ var AttestationType;
4775
+ (function (AttestationType) {
4776
+ AttestationType["basic"] = "basic";
4777
+ AttestationType["self"] = "self";
4778
+ AttestationType["attestationCa"] = "attestationCa";
4779
+ AttestationType["anonymizationCa"] = "anonymizationCa";
4780
+ AttestationType["none"] = "none";
4781
+ })(AttestationType = exports.AttestationType || (exports.AttestationType = {}));
4620
4782
  /**
4621
4783
  * @author Brett Pontarelli
4622
4784
  */
@@ -4624,6 +4786,27 @@ var AuthenticationThreats;
4624
4786
  (function (AuthenticationThreats) {
4625
4787
  AuthenticationThreats["ImpossibleTravel"] = "ImpossibleTravel";
4626
4788
  })(AuthenticationThreats = exports.AuthenticationThreats || (exports.AuthenticationThreats = {}));
4789
+ /**
4790
+ * Describes the <a href="https://www.w3.org/TR/webauthn-2/#authenticator-attachment-modality">authenticator attachment modality</a>.
4791
+ *
4792
+ * @author Spencer Witt
4793
+ */
4794
+ var AuthenticatorAttachment;
4795
+ (function (AuthenticatorAttachment) {
4796
+ AuthenticatorAttachment["platform"] = "platform";
4797
+ AuthenticatorAttachment["crossPlatform"] = "crossPlatform";
4798
+ })(AuthenticatorAttachment = exports.AuthenticatorAttachment || (exports.AuthenticatorAttachment = {}));
4799
+ /**
4800
+ * Describes the authenticator attachment modality preference for a WebAuthn workflow. See {@link AuthenticatorAttachment}
4801
+ *
4802
+ * @author Spencer Witt
4803
+ */
4804
+ var AuthenticatorAttachmentPreference;
4805
+ (function (AuthenticatorAttachmentPreference) {
4806
+ AuthenticatorAttachmentPreference["any"] = "any";
4807
+ AuthenticatorAttachmentPreference["platform"] = "platform";
4808
+ AuthenticatorAttachmentPreference["crossPlatform"] = "crossPlatform";
4809
+ })(AuthenticatorAttachmentPreference = exports.AuthenticatorAttachmentPreference || (exports.AuthenticatorAttachmentPreference = {}));
4627
4810
  var BreachAction;
4628
4811
  (function (BreachAction) {
4629
4812
  BreachAction["Off"] = "Off";
@@ -4727,6 +4910,54 @@ var ContentStatus;
4727
4910
  ContentStatus["PENDING"] = "PENDING";
4728
4911
  ContentStatus["REJECTED"] = "REJECTED";
4729
4912
  })(ContentStatus = exports.ContentStatus || (exports.ContentStatus = {}));
4913
+ /**
4914
+ * A number identifying a cryptographic algorithm. Values should be registered with the <a
4915
+ * href="https://www.iana.org/assignments/cose/cose.xhtml#algorithms">IANA COSE Algorithms registry</a>
4916
+ *
4917
+ * @author Spencer Witt
4918
+ */
4919
+ var CoseAlgorithmIdentifier;
4920
+ (function (CoseAlgorithmIdentifier) {
4921
+ CoseAlgorithmIdentifier["ES256"] = "SHA256withECDSA";
4922
+ CoseAlgorithmIdentifier["ES384"] = "SHA384withECDSA";
4923
+ CoseAlgorithmIdentifier["ES512"] = "SHA512withECDSA";
4924
+ CoseAlgorithmIdentifier["RS256"] = "SHA256withRSA";
4925
+ CoseAlgorithmIdentifier["RS384"] = "SHA384withRSA";
4926
+ CoseAlgorithmIdentifier["RS512"] = "SHA512withRSA";
4927
+ CoseAlgorithmIdentifier["PS256"] = "SHA-256";
4928
+ CoseAlgorithmIdentifier["PS384"] = "SHA-384";
4929
+ CoseAlgorithmIdentifier["PS512"] = "SHA-512";
4930
+ })(CoseAlgorithmIdentifier = exports.CoseAlgorithmIdentifier || (exports.CoseAlgorithmIdentifier = {}));
4931
+ /**
4932
+ * COSE Elliptic Curve identifier to determine which elliptic curve to use with a given key
4933
+ *
4934
+ * @author Spencer Witt
4935
+ */
4936
+ var CoseEllipticCurve;
4937
+ (function (CoseEllipticCurve) {
4938
+ CoseEllipticCurve["Reserved"] = "Reserved";
4939
+ CoseEllipticCurve["P256"] = "P256";
4940
+ CoseEllipticCurve["P384"] = "P384";
4941
+ CoseEllipticCurve["P521"] = "P521";
4942
+ CoseEllipticCurve["X25519"] = "X25519";
4943
+ CoseEllipticCurve["X448"] = "X448";
4944
+ CoseEllipticCurve["Ed25519"] = "Ed25519";
4945
+ CoseEllipticCurve["Ed448"] = "Ed448";
4946
+ CoseEllipticCurve["Secp256k1"] = "Secp256k1";
4947
+ })(CoseEllipticCurve = exports.CoseEllipticCurve || (exports.CoseEllipticCurve = {}));
4948
+ /**
4949
+ * COSE key type
4950
+ *
4951
+ * @author Spencer Witt
4952
+ */
4953
+ var CoseKeyType;
4954
+ (function (CoseKeyType) {
4955
+ CoseKeyType["Reserved"] = "0";
4956
+ CoseKeyType["OKP"] = "1";
4957
+ CoseKeyType["EC2"] = "2";
4958
+ CoseKeyType["RSA"] = "3";
4959
+ CoseKeyType["Symmetric"] = "4";
4960
+ })(CoseKeyType = exports.CoseKeyType || (exports.CoseKeyType = {}));
4730
4961
  var DeviceType;
4731
4962
  (function (DeviceType) {
4732
4963
  DeviceType["BROWSER"] = "BROWSER";
@@ -5168,6 +5399,15 @@ var ProofKeyForCodeExchangePolicy;
5168
5399
  ProofKeyForCodeExchangePolicy["NotRequired"] = "NotRequired";
5169
5400
  ProofKeyForCodeExchangePolicy["NotRequiredWhenUsingClientAuthentication"] = "NotRequiredWhenUsingClientAuthentication";
5170
5401
  })(ProofKeyForCodeExchangePolicy = exports.ProofKeyForCodeExchangePolicy || (exports.ProofKeyForCodeExchangePolicy = {}));
5402
+ /**
5403
+ * Defines valid credential types. This is an extension point in the WebAuthn spec. The only defined value at this time is "public-key"
5404
+ *
5405
+ * @author Spencer Witt
5406
+ */
5407
+ var PublicKeyCredentialType;
5408
+ (function (PublicKeyCredentialType) {
5409
+ PublicKeyCredentialType["publicKey"] = "public-key";
5410
+ })(PublicKeyCredentialType = exports.PublicKeyCredentialType || (exports.PublicKeyCredentialType = {}));
5171
5411
  /**
5172
5412
  * @author Daniel DeGroff
5173
5413
  */
@@ -5212,6 +5452,18 @@ var RegistrationType;
5212
5452
  RegistrationType["basic"] = "basic";
5213
5453
  RegistrationType["advanced"] = "advanced";
5214
5454
  })(RegistrationType = exports.RegistrationType || (exports.RegistrationType = {}));
5455
+ /**
5456
+ * Describes the Relying Party's requirements for <a href="https://www.w3.org/TR/webauthn-2/#client-side-discoverable-credential">client-side
5457
+ * discoverable credentials</a> (formerly known as "resident keys")
5458
+ *
5459
+ * @author Spencer Witt
5460
+ */
5461
+ var ResidentKeyRequirement;
5462
+ (function (ResidentKeyRequirement) {
5463
+ ResidentKeyRequirement["discouraged"] = "discouraged";
5464
+ ResidentKeyRequirement["preferred"] = "preferred";
5465
+ ResidentKeyRequirement["required"] = "required";
5466
+ })(ResidentKeyRequirement = exports.ResidentKeyRequirement || (exports.ResidentKeyRequirement = {}));
5215
5467
  var SAMLLogoutBehavior;
5216
5468
  (function (SAMLLogoutBehavior) {
5217
5469
  SAMLLogoutBehavior["AllParticipants"] = "AllParticipants";
@@ -5305,6 +5557,18 @@ var UserState;
5305
5557
  UserState["AuthenticatedNotVerified"] = "AuthenticatedNotVerified";
5306
5558
  UserState["AuthenticatedRegistrationNotVerified"] = "AuthenticatedRegistrationNotVerified";
5307
5559
  })(UserState = exports.UserState || (exports.UserState = {}));
5560
+ /**
5561
+ * Used to express whether the Relying Party requires <a href="https://www.w3.org/TR/webauthn-2/#user-verification">user verification</a> for the
5562
+ * current operation.
5563
+ *
5564
+ * @author Spencer Witt
5565
+ */
5566
+ var UserVerificationRequirement;
5567
+ (function (UserVerificationRequirement) {
5568
+ UserVerificationRequirement["required"] = "required";
5569
+ UserVerificationRequirement["preferred"] = "preferred";
5570
+ UserVerificationRequirement["discouraged"] = "discouraged";
5571
+ })(UserVerificationRequirement = exports.UserVerificationRequirement || (exports.UserVerificationRequirement = {}));
5308
5572
  /**
5309
5573
  * @author Daniel DeGroff
5310
5574
  */
@@ -5313,6 +5577,18 @@ var VerificationStrategy;
5313
5577
  VerificationStrategy["ClickableLink"] = "ClickableLink";
5314
5578
  VerificationStrategy["FormField"] = "FormField";
5315
5579
  })(VerificationStrategy = exports.VerificationStrategy || (exports.VerificationStrategy = {}));
5580
+ /**
5581
+ * Identifies the WebAuthn workflow. This will affect the parameters used for credential creation
5582
+ * and request based on the Tenant configuration.
5583
+ *
5584
+ * @author Spencer Witt
5585
+ */
5586
+ var WebAuthnWorkflow;
5587
+ (function (WebAuthnWorkflow) {
5588
+ WebAuthnWorkflow["bootstrap"] = "bootstrap";
5589
+ WebAuthnWorkflow["general"] = "general";
5590
+ WebAuthnWorkflow["reauthentication"] = "reauthentication";
5591
+ })(WebAuthnWorkflow = exports.WebAuthnWorkflow || (exports.WebAuthnWorkflow = {}));
5316
5592
  var XMLSignatureLocation;
5317
5593
  (function (XMLSignatureLocation) {
5318
5594
  XMLSignatureLocation["Assertion"] = "Assertion";