From 3bee3eca7c28419dbe74ac3a6d19c0bcfa64d208 Mon Sep 17 00:00:00 2001 From: "dfnsco-dfns-sdk-sync[bot]" <275545256+dfnsco-dfns-sdk-sync[bot]@users.noreply.github.com> Date: Wed, 8 Jul 2026 11:20:35 +0000 Subject: [PATCH 1/3] chore: sync generated SDK from monorepo v1.908.2 --- .../co/dfns/sdk/DfnsDelegatedAsyncClient.java | 66 +++ .../java/co/dfns/sdk/DfnsDelegatedClient.java | 66 +++ .../DelegatedAgreementsAsyncClient.java | 32 ++ .../agreements/DelegatedAgreementsClient.java | 31 ++ .../DelegatedAllocationsAsyncClient.java | 54 +++ .../DelegatedAllocationsClient.java | 53 +++ .../sdk/auth/DelegatedAuthAsyncClient.java | 446 ++++++++++++++++++ .../co/dfns/sdk/auth/DelegatedAuthClient.java | 445 +++++++++++++++++ .../auth/model/InitiateSsoLoginRequest.java | 4 + .../java/co/dfns/sdk/auth/model/Network.java | 4 + .../DelegatedExchangesAsyncClient.java | 87 ++++ .../exchanges/DelegatedExchangesClient.java | 86 ++++ .../DelegatedFeeSponsorsAsyncClient.java | 77 +++ .../DelegatedFeeSponsorsClient.java | 76 +++ .../dfns/sdk/feesponsors/model/Network.java | 4 + .../co/dfns/sdk/internal/DfnsHttpClient.java | 93 ++++ .../sdk/keys/DelegatedKeysAsyncClient.java | 126 +++++ .../co/dfns/sdk/keys/DelegatedKeysClient.java | 125 +++++ .../java/co/dfns/sdk/keys/model/Network.java | 4 + .../DelegatedNetworksAsyncClient.java | 72 +++ .../sdk/networks/DelegatedNetworksClient.java | 71 +++ .../payouts/DelegatedPayoutsAsyncClient.java | 54 +++ .../sdk/payouts/DelegatedPayoutsClient.java | 53 +++ .../sdk/payouts/model/ListPayoutsQuery.java | 7 + .../DelegatedPermissionsAsyncClient.java | 86 ++++ .../DelegatedPermissionsClient.java | 85 ++++ .../DelegatedPoliciesAsyncClient.java | 82 ++++ .../sdk/policies/DelegatedPoliciesClient.java | 81 ++++ .../signers/DelegatedSignersAsyncClient.java | 106 +++++ .../sdk/signers/DelegatedSignersClient.java | 105 +++++ .../staking/DelegatedStakingAsyncClient.java | 60 +++ .../sdk/staking/DelegatedStakingClient.java | 59 +++ .../sdk/swaps/DelegatedSwapsAsyncClient.java | 48 ++ .../dfns/sdk/swaps/DelegatedSwapsClient.java | 47 ++ .../wallets/DelegatedWalletsAsyncClient.java | 262 ++++++++++ .../sdk/wallets/DelegatedWalletsClient.java | 261 ++++++++++ .../co/dfns/sdk/wallets/model/Network.java | 4 + .../DelegatedWebhooksAsyncClient.java | 82 ++++ .../sdk/webhooks/DelegatedWebhooksClient.java | 81 ++++ 39 files changed, 3585 insertions(+) create mode 100644 src/main/java/co/dfns/sdk/DfnsDelegatedAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/DfnsDelegatedClient.java create mode 100644 src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsClient.java create mode 100644 src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsClient.java create mode 100644 src/main/java/co/dfns/sdk/auth/DelegatedAuthAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/auth/DelegatedAuthClient.java create mode 100644 src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesClient.java create mode 100644 src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsClient.java create mode 100644 src/main/java/co/dfns/sdk/keys/DelegatedKeysAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/keys/DelegatedKeysClient.java create mode 100644 src/main/java/co/dfns/sdk/networks/DelegatedNetworksAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/networks/DelegatedNetworksClient.java create mode 100644 src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsClient.java create mode 100644 src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsClient.java create mode 100644 src/main/java/co/dfns/sdk/policies/DelegatedPoliciesAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/policies/DelegatedPoliciesClient.java create mode 100644 src/main/java/co/dfns/sdk/signers/DelegatedSignersAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/signers/DelegatedSignersClient.java create mode 100644 src/main/java/co/dfns/sdk/staking/DelegatedStakingAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/staking/DelegatedStakingClient.java create mode 100644 src/main/java/co/dfns/sdk/swaps/DelegatedSwapsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/swaps/DelegatedSwapsClient.java create mode 100644 src/main/java/co/dfns/sdk/wallets/DelegatedWalletsAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/wallets/DelegatedWalletsClient.java create mode 100644 src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksAsyncClient.java create mode 100644 src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksClient.java diff --git a/src/main/java/co/dfns/sdk/DfnsDelegatedAsyncClient.java b/src/main/java/co/dfns/sdk/DfnsDelegatedAsyncClient.java new file mode 100644 index 0000000..e0d20f5 --- /dev/null +++ b/src/main/java/co/dfns/sdk/DfnsDelegatedAsyncClient.java @@ -0,0 +1,66 @@ +package co.dfns.sdk; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.agreements.DelegatedAgreementsAsyncClient; +import co.dfns.sdk.allocations.DelegatedAllocationsAsyncClient; +import co.dfns.sdk.auth.DelegatedAuthAsyncClient; +import co.dfns.sdk.exchanges.DelegatedExchangesAsyncClient; +import co.dfns.sdk.feesponsors.DelegatedFeeSponsorsAsyncClient; +import co.dfns.sdk.keys.DelegatedKeysAsyncClient; +import co.dfns.sdk.networks.DelegatedNetworksAsyncClient; +import co.dfns.sdk.payouts.DelegatedPayoutsAsyncClient; +import co.dfns.sdk.permissions.DelegatedPermissionsAsyncClient; +import co.dfns.sdk.policies.DelegatedPoliciesAsyncClient; +import co.dfns.sdk.signers.DelegatedSignersAsyncClient; +import co.dfns.sdk.staking.DelegatedStakingAsyncClient; +import co.dfns.sdk.swaps.DelegatedSwapsAsyncClient; +import co.dfns.sdk.wallets.DelegatedWalletsAsyncClient; +import co.dfns.sdk.webhooks.DelegatedWebhooksAsyncClient; + +/** + * Dfns async SDK client for delegated user action signing. Its domain clients split signed + * operations into Init/Complete calls so challenges can be signed out-of-band (e.g. by an + * end user) rather than by a Signer held in this process. + */ +public class DfnsDelegatedAsyncClient implements AutoCloseable { + private final DfnsHttpClient httpClient; + public final DelegatedAgreementsAsyncClient agreements; + public final DelegatedAllocationsAsyncClient allocations; + public final DelegatedAuthAsyncClient auth; + public final DelegatedExchangesAsyncClient exchanges; + public final DelegatedFeeSponsorsAsyncClient feeSponsors; + public final DelegatedKeysAsyncClient keys; + public final DelegatedNetworksAsyncClient networks; + public final DelegatedPayoutsAsyncClient payouts; + public final DelegatedPermissionsAsyncClient permissions; + public final DelegatedPoliciesAsyncClient policies; + public final DelegatedSignersAsyncClient signers; + public final DelegatedStakingAsyncClient staking; + public final DelegatedSwapsAsyncClient swaps; + public final DelegatedWalletsAsyncClient wallets; + public final DelegatedWebhooksAsyncClient webhooks; + + public DfnsDelegatedAsyncClient(DfnsClientConfig config) { + this.httpClient = new DfnsHttpClient(config); + this.agreements = new DelegatedAgreementsAsyncClient(httpClient); + this.allocations = new DelegatedAllocationsAsyncClient(httpClient); + this.auth = new DelegatedAuthAsyncClient(httpClient); + this.exchanges = new DelegatedExchangesAsyncClient(httpClient); + this.feeSponsors = new DelegatedFeeSponsorsAsyncClient(httpClient); + this.keys = new DelegatedKeysAsyncClient(httpClient); + this.networks = new DelegatedNetworksAsyncClient(httpClient); + this.payouts = new DelegatedPayoutsAsyncClient(httpClient); + this.permissions = new DelegatedPermissionsAsyncClient(httpClient); + this.policies = new DelegatedPoliciesAsyncClient(httpClient); + this.signers = new DelegatedSignersAsyncClient(httpClient); + this.staking = new DelegatedStakingAsyncClient(httpClient); + this.swaps = new DelegatedSwapsAsyncClient(httpClient); + this.wallets = new DelegatedWalletsAsyncClient(httpClient); + this.webhooks = new DelegatedWebhooksAsyncClient(httpClient); + } + + @Override + public void close() { + httpClient.close(); + } +} diff --git a/src/main/java/co/dfns/sdk/DfnsDelegatedClient.java b/src/main/java/co/dfns/sdk/DfnsDelegatedClient.java new file mode 100644 index 0000000..1316114 --- /dev/null +++ b/src/main/java/co/dfns/sdk/DfnsDelegatedClient.java @@ -0,0 +1,66 @@ +package co.dfns.sdk; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.agreements.DelegatedAgreementsClient; +import co.dfns.sdk.allocations.DelegatedAllocationsClient; +import co.dfns.sdk.auth.DelegatedAuthClient; +import co.dfns.sdk.exchanges.DelegatedExchangesClient; +import co.dfns.sdk.feesponsors.DelegatedFeeSponsorsClient; +import co.dfns.sdk.keys.DelegatedKeysClient; +import co.dfns.sdk.networks.DelegatedNetworksClient; +import co.dfns.sdk.payouts.DelegatedPayoutsClient; +import co.dfns.sdk.permissions.DelegatedPermissionsClient; +import co.dfns.sdk.policies.DelegatedPoliciesClient; +import co.dfns.sdk.signers.DelegatedSignersClient; +import co.dfns.sdk.staking.DelegatedStakingClient; +import co.dfns.sdk.swaps.DelegatedSwapsClient; +import co.dfns.sdk.wallets.DelegatedWalletsClient; +import co.dfns.sdk.webhooks.DelegatedWebhooksClient; + +/** + * Dfns SDK client for delegated user action signing. Its domain clients split signed + * operations into Init/Complete calls so challenges can be signed out-of-band (e.g. by an + * end user) rather than by a Signer held in this process. + */ +public class DfnsDelegatedClient implements AutoCloseable { + private final DfnsHttpClient httpClient; + public final DelegatedAgreementsClient agreements; + public final DelegatedAllocationsClient allocations; + public final DelegatedAuthClient auth; + public final DelegatedExchangesClient exchanges; + public final DelegatedFeeSponsorsClient feeSponsors; + public final DelegatedKeysClient keys; + public final DelegatedNetworksClient networks; + public final DelegatedPayoutsClient payouts; + public final DelegatedPermissionsClient permissions; + public final DelegatedPoliciesClient policies; + public final DelegatedSignersClient signers; + public final DelegatedStakingClient staking; + public final DelegatedSwapsClient swaps; + public final DelegatedWalletsClient wallets; + public final DelegatedWebhooksClient webhooks; + + public DfnsDelegatedClient(DfnsClientConfig config) { + this.httpClient = new DfnsHttpClient(config); + this.agreements = new DelegatedAgreementsClient(httpClient); + this.allocations = new DelegatedAllocationsClient(httpClient); + this.auth = new DelegatedAuthClient(httpClient); + this.exchanges = new DelegatedExchangesClient(httpClient); + this.feeSponsors = new DelegatedFeeSponsorsClient(httpClient); + this.keys = new DelegatedKeysClient(httpClient); + this.networks = new DelegatedNetworksClient(httpClient); + this.payouts = new DelegatedPayoutsClient(httpClient); + this.permissions = new DelegatedPermissionsClient(httpClient); + this.policies = new DelegatedPoliciesClient(httpClient); + this.signers = new DelegatedSignersClient(httpClient); + this.staking = new DelegatedStakingClient(httpClient); + this.swaps = new DelegatedSwapsClient(httpClient); + this.wallets = new DelegatedWalletsClient(httpClient); + this.webhooks = new DelegatedWebhooksClient(httpClient); + } + + @Override + public void close() { + httpClient.close(); + } +} diff --git a/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsAsyncClient.java b/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsAsyncClient.java new file mode 100644 index 0000000..b6a05b2 --- /dev/null +++ b/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsAsyncClient.java @@ -0,0 +1,32 @@ +package co.dfns.sdk.agreements; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.agreements.model.*; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAgreementsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedAgreementsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Latest Unaccepted Agreement */ + public CompletableFuture getLatestUnacceptedAgreement(GetLatestUnacceptedAgreementQuery query) { + return httpClient.getAsync("/agreements/latest-unaccepted", query.toMap(), GetLatestUnacceptedAgreementResponse.class); + } + + /** Delegated signing step 1 for Record Agreement Acceptance: returns the challenge to sign out-of-band. */ + public CompletableFuture recordAgreementAcceptanceInit(String agreementId) { + return httpClient.createUserActionChallengeAsync("POST", "/agreements/" + agreementId + "/accept", null); + } + + /** Delegated signing step 2 for Record Agreement Acceptance: submits the signed challenge and issues the request. */ + public CompletableFuture recordAgreementAcceptanceComplete(String agreementId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/agreements/" + agreementId + "/accept", java.util.Map.of(), null, RecordAgreementAcceptanceResponse.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsClient.java b/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsClient.java new file mode 100644 index 0000000..c67b273 --- /dev/null +++ b/src/main/java/co/dfns/sdk/agreements/DelegatedAgreementsClient.java @@ -0,0 +1,31 @@ +package co.dfns.sdk.agreements; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.agreements.model.*; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAgreementsClient { + private final DfnsHttpClient httpClient; + + public DelegatedAgreementsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Latest Unaccepted Agreement */ + public GetLatestUnacceptedAgreementResponse getLatestUnacceptedAgreement(GetLatestUnacceptedAgreementQuery query) { + return httpClient.get("/agreements/latest-unaccepted", query.toMap(), GetLatestUnacceptedAgreementResponse.class); + } + + /** Delegated signing step 1 for Record Agreement Acceptance: returns the challenge to sign out-of-band. */ + public UserActionChallenge recordAgreementAcceptanceInit(String agreementId) { + return httpClient.createUserActionChallenge("POST", "/agreements/" + agreementId + "/accept", null); + } + + /** Delegated signing step 2 for Record Agreement Acceptance: submits the signed challenge and issues the request. */ + public RecordAgreementAcceptanceResponse recordAgreementAcceptanceComplete(String agreementId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/agreements/" + agreementId + "/accept", java.util.Map.of(), null, RecordAgreementAcceptanceResponse.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsAsyncClient.java b/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsAsyncClient.java new file mode 100644 index 0000000..065cc37 --- /dev/null +++ b/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsAsyncClient.java @@ -0,0 +1,54 @@ +package co.dfns.sdk.allocations; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.allocations.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAllocationsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedAllocationsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Allocations */ + public CompletableFuture> listAllocations(ListAllocationsQuery query) { + return httpClient.getAsync("/allocations", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Allocation: returns the challenge to sign out-of-band. */ + public CompletableFuture createAllocationInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/allocations", body); + } + + /** Delegated signing step 2 for Create Allocation: submits the signed challenge and issues the request. */ + public CompletableFuture createAllocationComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/allocations", java.util.Map.of(), body, Allocation.class, userAction)); + } + + /** List Allocation Actions */ + public CompletableFuture> listAllocationActions(String allocationId, ListAllocationActionsQuery query) { + return httpClient.getAsync("/allocations/" + allocationId + "/actions", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Allocation Action: returns the challenge to sign out-of-band. */ + public CompletableFuture createAllocationActionInit(String allocationId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/allocations/" + allocationId + "/actions", body); + } + + /** Delegated signing step 2 for Create Allocation Action: submits the signed challenge and issues the request. */ + public CompletableFuture createAllocationActionComplete(String allocationId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/allocations/" + allocationId + "/actions", java.util.Map.of(), body, Allocation.class, userAction)); + } + + /** Get Allocation */ + public CompletableFuture getAllocation(String allocationId) { + return httpClient.getAsync("/allocations/" + allocationId, java.util.Map.of(), Allocation.class); + } +} diff --git a/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsClient.java b/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsClient.java new file mode 100644 index 0000000..27111c0 --- /dev/null +++ b/src/main/java/co/dfns/sdk/allocations/DelegatedAllocationsClient.java @@ -0,0 +1,53 @@ +package co.dfns.sdk.allocations; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.allocations.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAllocationsClient { + private final DfnsHttpClient httpClient; + + public DelegatedAllocationsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Allocations */ + public PaginatedList listAllocations(ListAllocationsQuery query) { + return httpClient.get("/allocations", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Allocation: returns the challenge to sign out-of-band. */ + public UserActionChallenge createAllocationInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/allocations", body); + } + + /** Delegated signing step 2 for Create Allocation: submits the signed challenge and issues the request. */ + public Allocation createAllocationComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/allocations", java.util.Map.of(), body, Allocation.class, userAction); + } + + /** List Allocation Actions */ + public PaginatedList listAllocationActions(String allocationId, ListAllocationActionsQuery query) { + return httpClient.get("/allocations/" + allocationId + "/actions", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Allocation Action: returns the challenge to sign out-of-band. */ + public UserActionChallenge createAllocationActionInit(String allocationId, Object body) { + return httpClient.createUserActionChallenge("POST", "/allocations/" + allocationId + "/actions", body); + } + + /** Delegated signing step 2 for Create Allocation Action: submits the signed challenge and issues the request. */ + public Allocation createAllocationActionComplete(String allocationId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/allocations/" + allocationId + "/actions", java.util.Map.of(), body, Allocation.class, userAction); + } + + /** Get Allocation */ + public Allocation getAllocation(String allocationId) { + return httpClient.get("/allocations/" + allocationId, java.util.Map.of(), Allocation.class); + } +} diff --git a/src/main/java/co/dfns/sdk/auth/DelegatedAuthAsyncClient.java b/src/main/java/co/dfns/sdk/auth/DelegatedAuthAsyncClient.java new file mode 100644 index 0000000..057905e --- /dev/null +++ b/src/main/java/co/dfns/sdk/auth/DelegatedAuthAsyncClient.java @@ -0,0 +1,446 @@ +package co.dfns.sdk.auth; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.auth.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAuthAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedAuthAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Create User Action Signature */ + public CompletableFuture createUserActionSignature(CreateUserActionSignatureRequest body) { + return httpClient.postAsync("/auth/action", java.util.Map.of(), body, CreateUserActionSignatureResponse.class, false); + } + + /** Create User Action Challenge */ + public CompletableFuture createUserActionChallenge(CreateUserActionChallengeRequest body) { + return httpClient.postAsync("/auth/action/init", java.util.Map.of(), body, CreateUserActionChallengeResponse.class, false); + } + + /** List Audit Logs */ + public CompletableFuture listAuditLogs(ListAuditLogsQuery query) { + return httpClient.getAsync("/auth/action/logs", query.toMap(), Object.class); + } + + /** Get Audit Log */ + public CompletableFuture getAuditLog(Object id) { + return httpClient.getAsync("/auth/action/logs/" + id, java.util.Map.of(), AuditLog.class); + } + + /** List Applications */ + @Deprecated + public CompletableFuture listApplications() { + return httpClient.getAsync("/auth/apps", java.util.Map.of(), ListApplicationsResponse.class); + } + + /** Get Application */ + @Deprecated + public CompletableFuture getApplication(String appId) { + return httpClient.getAsync("/auth/apps/" + appId, java.util.Map.of(), GetApplicationResponse.class); + } + + /** List Credentials */ + public CompletableFuture listCredentials() { + return httpClient.getAsync("/auth/credentials", java.util.Map.of(), ListCredentialsResponse.class); + } + + /** Delegated signing step 1 for Create Credential: returns the challenge to sign out-of-band. */ + public CompletableFuture createCredentialInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/credentials", body); + } + + /** Delegated signing step 2 for Create Credential: submits the signed challenge and issues the request. */ + public CompletableFuture createCredentialComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/credentials", java.util.Map.of(), body, Credential.class, userAction)); + } + + /** Create Credential Challenge */ + public CompletableFuture createCredentialChallenge(CreateCredentialChallengeRequest body) { + return httpClient.postAsync("/auth/credentials/init", java.util.Map.of(), body, Object.class, false); + } + + /** Delegated signing step 1 for Activate Credential: returns the challenge to sign out-of-band. */ + public CompletableFuture activateCredentialInit(ActivateCredentialRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/credentials/activate", body); + } + + /** Delegated signing step 2 for Activate Credential: submits the signed challenge and issues the request. */ + public CompletableFuture activateCredentialComplete(ActivateCredentialRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/credentials/activate", java.util.Map.of(), body, ActivateCredentialResponse.class, userAction)); + } + + /** Delegated signing step 1 for Delete Credential: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteCredentialInit(String credentialUuid) { + return httpClient.createUserActionChallengeAsync("DELETE", "/auth/credentials/" + credentialUuid, null); + } + + /** Delegated signing step 2 for Delete Credential: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public CompletableFuture> deleteCredentialComplete(String credentialUuid, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/auth/credentials/" + credentialUuid, java.util.Map.of(), null, (Class>) (Class) Map.class, userAction)); + } + + /** Delegated signing step 1 for Deactivate Credential: returns the challenge to sign out-of-band. */ + public CompletableFuture deactivateCredentialInit(DeactivateCredentialRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/credentials/deactivate", body); + } + + /** Delegated signing step 2 for Deactivate Credential: submits the signed challenge and issues the request. */ + public CompletableFuture deactivateCredentialComplete(DeactivateCredentialRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/credentials/deactivate", java.util.Map.of(), body, DeactivateCredentialResponse.class, userAction)); + } + + /** Delegated signing step 1 for Create Credential Code: returns the challenge to sign out-of-band. */ + public CompletableFuture createCredentialCodeInit(CreateCredentialCodeRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/credentials/code", body); + } + + /** Delegated signing step 2 for Create Credential Code: submits the signed challenge and issues the request. */ + public CompletableFuture createCredentialCodeComplete(CreateCredentialCodeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/credentials/code", java.util.Map.of(), body, CreateCredentialCodeResponse.class, userAction)); + } + + /** Create Credential Challenge With Code */ + public CompletableFuture createCredentialChallengeWithCode(CreateCredentialChallengeWithCodeRequest body) { + return httpClient.postAsync("/auth/credentials/code/init", java.util.Map.of(), body, Object.class, false); + } + + /** Create Credential With Code */ + public CompletableFuture createCredentialWithCode(Object body) { + return httpClient.postAsync("/auth/credentials/code/verify", java.util.Map.of(), body, Credential.class, false); + } + + /** Create Login Challenge */ + public CompletableFuture createLoginChallenge(CreateLoginChallengeRequest body) { + return httpClient.postAsync("/auth/login/init", java.util.Map.of(), body, CreateLoginChallengeResponse.class, false); + } + + /** Delegated signing step 1 for Delegated Login: returns the challenge to sign out-of-band. */ + public CompletableFuture delegatedLoginInit(DelegatedLoginRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/login/delegated", body); + } + + /** Delegated signing step 2 for Delegated Login: submits the signed challenge and issues the request. */ + public CompletableFuture delegatedLoginComplete(DelegatedLoginRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/login/delegated", java.util.Map.of(), body, DelegatedLoginResponse.class, userAction)); + } + + /** Complete User Login */ + public CompletableFuture completeUserLogin(CompleteUserLoginRequest body) { + return httpClient.postAsync("/auth/login", java.util.Map.of(), body, Object.class, false); + } + + /** Logout */ + public CompletableFuture logout(LogoutRequest body) { + return httpClient.putAsync("/auth/logout", java.util.Map.of(), body, LogoutResponse.class, false); + } + + /** Send Login Code */ + public CompletableFuture sendLoginCode(SendLoginCodeRequest body) { + return httpClient.postAsync("/auth/login/code", java.util.Map.of(), body, SendLoginCodeResponse.class, false); + } + + /** Social Login */ + public CompletableFuture socialLogin(SocialLoginRequest body) { + return httpClient.postAsync("/auth/login/social", java.util.Map.of(), body, SocialLoginResponse.class, false); + } + + /** Complete SSO Login */ + public CompletableFuture completeSsoLogin(CompleteSsoLoginRequest body) { + return httpClient.postAsync("/auth/login/sso", java.util.Map.of(), body, CompleteSsoLoginResponse.class, false); + } + + /** Initiate SSO Login */ + public CompletableFuture initiateSsoLogin(InitiateSsoLoginRequest body) { + return httpClient.postAsync("/auth/login/sso/init", java.util.Map.of(), body, InitiateSsoLoginResponse.class, false); + } + + /** Exchange Access Token */ + public CompletableFuture exchangeAccessToken(ExchangeAccessTokenRequest body) { + return httpClient.postAsync("/auth/tokens", java.util.Map.of(), body, ExchangeAccessTokenResponse.class, false); + } + + /** List Personal Access Tokens */ + public CompletableFuture listPersonalAccessTokens() { + return httpClient.getAsync("/auth/pats", java.util.Map.of(), ListPersonalAccessTokensResponse.class); + } + + /** Delegated signing step 1 for Create Personal Access Token: returns the challenge to sign out-of-band. */ + public CompletableFuture createPersonalAccessTokenInit(CreatePersonalAccessTokenRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/pats", body); + } + + /** Delegated signing step 2 for Create Personal Access Token: submits the signed challenge and issues the request. */ + public CompletableFuture createPersonalAccessTokenComplete(CreatePersonalAccessTokenRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/pats", java.util.Map.of(), body, CreatePersonalAccessTokenResponse.class, userAction)); + } + + /** Get Personal Access Token */ + public CompletableFuture getPersonalAccessToken(String tokenId) { + return httpClient.getAsync("/auth/pats/" + tokenId, java.util.Map.of(), PersonalAccessToken.class); + } + + /** Delegated signing step 1 for Update Personal Access Token: returns the challenge to sign out-of-band. */ + public CompletableFuture updatePersonalAccessTokenInit(String tokenId, UpdatePersonalAccessTokenRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/pats/" + tokenId, body); + } + + /** Delegated signing step 2 for Update Personal Access Token: submits the signed challenge and issues the request. */ + public CompletableFuture updatePersonalAccessTokenComplete(String tokenId, UpdatePersonalAccessTokenRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/pats/" + tokenId, java.util.Map.of(), body, PersonalAccessToken.class, userAction)); + } + + /** Delegated signing step 1 for Delete Personal Access Token: returns the challenge to sign out-of-band. */ + public CompletableFuture deletePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/auth/pats/" + tokenId, null); + } + + /** Delegated signing step 2 for Delete Personal Access Token: submits the signed challenge and issues the request. */ + public CompletableFuture deletePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/auth/pats/" + tokenId, java.util.Map.of(), null, PersonalAccessToken.class, userAction)); + } + + /** Delegated signing step 1 for Activate Personal Access Token: returns the challenge to sign out-of-band. */ + public CompletableFuture activatePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/pats/" + tokenId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Personal Access Token: submits the signed challenge and issues the request. */ + public CompletableFuture activatePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/pats/" + tokenId + "/activate", java.util.Map.of(), null, PersonalAccessToken.class, userAction)); + } + + /** Delegated signing step 1 for Deactivate Personal Access Token: returns the challenge to sign out-of-band. */ + public CompletableFuture deactivatePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/pats/" + tokenId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate Personal Access Token: submits the signed challenge and issues the request. */ + public CompletableFuture deactivatePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/pats/" + tokenId + "/deactivate", java.util.Map.of(), null, PersonalAccessToken.class, userAction)); + } + + /** Delegated signing step 1 for Create Delegated Recovery Challenge: returns the challenge to sign out-of-band. */ + public CompletableFuture createDelegatedRecoveryChallengeInit(CreateDelegatedRecoveryChallengeRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/recover/user/delegated", body); + } + + /** Delegated signing step 2 for Create Delegated Recovery Challenge: submits the signed challenge and issues the request. */ + public CompletableFuture createDelegatedRecoveryChallengeComplete(CreateDelegatedRecoveryChallengeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/recover/user/delegated", java.util.Map.of(), body, CreateDelegatedRecoveryChallengeResponse.class, userAction)); + } + + /** Recover User */ + public CompletableFuture recoverUser(RecoverUserRequest body) { + return httpClient.postAsync("/auth/recover/user", java.util.Map.of(), body, RecoverUserResponse.class, false); + } + + /** Create Recovery Challenge */ + public CompletableFuture createRecoveryChallenge(CreateRecoveryChallengeRequest body) { + return httpClient.postAsync("/auth/recover/user/init", java.util.Map.of(), body, CreateRecoveryChallengeResponse.class, false); + } + + /** Send Recovery Code Email */ + public CompletableFuture sendRecoveryCodeEmail(SendRecoveryCodeEmailRequest body) { + return httpClient.postAsync("/auth/recover/user/code", java.util.Map.of(), body, SendRecoveryCodeEmailResponse.class, false); + } + + /** Delegated signing step 1 for Create Delegated Registration Challenge: returns the challenge to sign out-of-band. */ + public CompletableFuture createDelegatedRegistrationChallengeInit(CreateDelegatedRegistrationChallengeRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/registration/delegated", body); + } + + /** Delegated signing step 2 for Create Delegated Registration Challenge: submits the signed challenge and issues the request. */ + public CompletableFuture createDelegatedRegistrationChallengeComplete(CreateDelegatedRegistrationChallengeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/registration/delegated", java.util.Map.of(), body, CreateDelegatedRegistrationChallengeResponse.class, userAction)); + } + + /** Create Registration Challenge */ + public CompletableFuture createRegistrationChallenge(CreateRegistrationChallengeRequest body) { + return httpClient.postAsync("/auth/registration/init", java.util.Map.of(), body, CreateRegistrationChallengeResponse.class, false); + } + + /** Create Social Registration Challenge */ + public CompletableFuture createSocialRegistrationChallenge(CreateSocialRegistrationChallengeRequest body) { + return httpClient.postAsync("/auth/registration/social", java.util.Map.of(), body, CreateSocialRegistrationChallengeResponse.class, false); + } + + /** Complete User Registration */ + public CompletableFuture completeUserRegistration(CompleteUserRegistrationRequest body) { + return httpClient.postAsync("/auth/registration", java.util.Map.of(), body, CompleteUserRegistrationResponse.class, false); + } + + /** Complete End User Registration with Wallets */ + public CompletableFuture completeEndUserRegistrationWithWallets(CompleteEndUserRegistrationWithWalletsRequest body) { + return httpClient.postAsync("/auth/registration/enduser", java.util.Map.of(), body, CompleteEndUserRegistrationWithWalletsResponse.class, false); + } + + /** Resend Registration Code */ + public CompletableFuture resendRegistrationCode(ResendRegistrationCodeRequest body) { + return httpClient.putAsync("/auth/registration/code", java.util.Map.of(), body, ResendRegistrationCodeResponse.class, false); + } + + /** List Service Accounts */ + public CompletableFuture listServiceAccounts() { + return httpClient.getAsync("/auth/service-accounts", java.util.Map.of(), ListServiceAccountsResponse.class); + } + + /** Delegated signing step 1 for Create Service Account: returns the challenge to sign out-of-band. */ + public CompletableFuture createServiceAccountInit(CreateServiceAccountRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/service-accounts", body); + } + + /** Delegated signing step 2 for Create Service Account: submits the signed challenge and issues the request. */ + public CompletableFuture createServiceAccountComplete(CreateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/service-accounts", java.util.Map.of(), body, CreateServiceAccountResponse.class, userAction)); + } + + /** Get Service Account */ + public CompletableFuture getServiceAccount(String serviceAccountId) { + return httpClient.getAsync("/auth/service-accounts/" + serviceAccountId, java.util.Map.of(), GetServiceAccountResponse.class); + } + + /** Delegated signing step 1 for Update Service Account: returns the challenge to sign out-of-band. */ + public CompletableFuture updateServiceAccountInit(String serviceAccountId, UpdateServiceAccountRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/service-accounts/" + serviceAccountId, body); + } + + /** Delegated signing step 2 for Update Service Account: submits the signed challenge and issues the request. */ + public CompletableFuture updateServiceAccountComplete(String serviceAccountId, UpdateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/service-accounts/" + serviceAccountId, java.util.Map.of(), body, UpdateServiceAccountResponse.class, userAction)); + } + + /** Delegated signing step 1 for Delete Service Account: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteServiceAccountInit(String serviceAccountId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/auth/service-accounts/" + serviceAccountId, null); + } + + /** Delegated signing step 2 for Delete Service Account: submits the signed challenge and issues the request. */ + public CompletableFuture deleteServiceAccountComplete(String serviceAccountId, DeleteServiceAccountQuery query, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/auth/service-accounts/" + serviceAccountId, query.toMap(), null, DeleteServiceAccountResponse.class, userAction)); + } + + /** Delegated signing step 1 for Activate Service Account: returns the challenge to sign out-of-band. */ + public CompletableFuture activateServiceAccountInit(String serviceAccountId) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/service-accounts/" + serviceAccountId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Service Account: submits the signed challenge and issues the request. */ + public CompletableFuture activateServiceAccountComplete(String serviceAccountId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/service-accounts/" + serviceAccountId + "/activate", java.util.Map.of(), null, ActivateServiceAccountResponse.class, userAction)); + } + + /** Delegated signing step 1 for Deactivate Service Account: returns the challenge to sign out-of-band. */ + public CompletableFuture deactivateServiceAccountInit(String serviceAccountId, DeactivateServiceAccountRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/service-accounts/" + serviceAccountId + "/deactivate", body); + } + + /** Delegated signing step 2 for Deactivate Service Account: submits the signed challenge and issues the request. */ + public CompletableFuture deactivateServiceAccountComplete(String serviceAccountId, DeactivateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/service-accounts/" + serviceAccountId + "/deactivate", java.util.Map.of(), body, DeactivateServiceAccountResponse.class, userAction)); + } + + /** Delegated signing step 1 for Activate User: returns the challenge to sign out-of-band. */ + public CompletableFuture activateUserInit(String userId) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/users/" + userId + "/activate", null); + } + + /** Delegated signing step 2 for Activate User: submits the signed challenge and issues the request. */ + public CompletableFuture activateUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/users/" + userId + "/activate", java.util.Map.of(), null, User.class, userAction)); + } + + /** Delegated signing step 1 for Deactivate User: returns the challenge to sign out-of-band. */ + public CompletableFuture deactivateUserInit(String userId) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/users/" + userId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate User: submits the signed challenge and issues the request. */ + public CompletableFuture deactivateUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/users/" + userId + "/deactivate", java.util.Map.of(), null, User.class, userAction)); + } + + /** Get User */ + public CompletableFuture getUser(String userId) { + return httpClient.getAsync("/auth/users/" + userId, java.util.Map.of(), User.class); + } + + /** Delegated signing step 1 for Update User: returns the challenge to sign out-of-band. */ + public CompletableFuture updateUserInit(String userId, UpdateUserRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/auth/users/" + userId, body); + } + + /** Delegated signing step 2 for Update User: submits the signed challenge and issues the request. */ + public CompletableFuture updateUserComplete(String userId, UpdateUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/auth/users/" + userId, java.util.Map.of(), body, User.class, userAction)); + } + + /** Delegated signing step 1 for Delete User: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteUserInit(String userId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/auth/users/" + userId, null); + } + + /** Delegated signing step 2 for Delete User: submits the signed challenge and issues the request. */ + public CompletableFuture deleteUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/auth/users/" + userId, java.util.Map.of(), null, User.class, userAction)); + } + + /** List Users */ + public CompletableFuture> listUsers(ListUsersQuery query) { + return httpClient.getAsync("/auth/users", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create User: returns the challenge to sign out-of-band. */ + public CompletableFuture createUserInit(CreateUserRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/users", body); + } + + /** Delegated signing step 2 for Create User: submits the signed challenge and issues the request. */ + public CompletableFuture createUserComplete(CreateUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/users", java.util.Map.of(), body, User.class, userAction)); + } + + /** Delegated signing step 1 for Invite Tenant User: returns the challenge to sign out-of-band. */ + public CompletableFuture inviteTenantUserInit(InviteTenantUserRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/auth/users/invite", body); + } + + /** Delegated signing step 2 for Invite Tenant User: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public CompletableFuture> inviteTenantUserComplete(InviteTenantUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/auth/users/invite", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/auth/DelegatedAuthClient.java b/src/main/java/co/dfns/sdk/auth/DelegatedAuthClient.java new file mode 100644 index 0000000..fe7f992 --- /dev/null +++ b/src/main/java/co/dfns/sdk/auth/DelegatedAuthClient.java @@ -0,0 +1,445 @@ +package co.dfns.sdk.auth; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.auth.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedAuthClient { + private final DfnsHttpClient httpClient; + + public DelegatedAuthClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Create User Action Signature */ + public CreateUserActionSignatureResponse createUserActionSignature(CreateUserActionSignatureRequest body) { + return httpClient.post("/auth/action", java.util.Map.of(), body, CreateUserActionSignatureResponse.class, false); + } + + /** Create User Action Challenge */ + public CreateUserActionChallengeResponse createUserActionChallenge(CreateUserActionChallengeRequest body) { + return httpClient.post("/auth/action/init", java.util.Map.of(), body, CreateUserActionChallengeResponse.class, false); + } + + /** List Audit Logs */ + public Object listAuditLogs(ListAuditLogsQuery query) { + return httpClient.get("/auth/action/logs", query.toMap(), Object.class); + } + + /** Get Audit Log */ + public AuditLog getAuditLog(Object id) { + return httpClient.get("/auth/action/logs/" + id, java.util.Map.of(), AuditLog.class); + } + + /** List Applications */ + @Deprecated + public ListApplicationsResponse listApplications() { + return httpClient.get("/auth/apps", java.util.Map.of(), ListApplicationsResponse.class); + } + + /** Get Application */ + @Deprecated + public GetApplicationResponse getApplication(String appId) { + return httpClient.get("/auth/apps/" + appId, java.util.Map.of(), GetApplicationResponse.class); + } + + /** List Credentials */ + public ListCredentialsResponse listCredentials() { + return httpClient.get("/auth/credentials", java.util.Map.of(), ListCredentialsResponse.class); + } + + /** Delegated signing step 1 for Create Credential: returns the challenge to sign out-of-band. */ + public UserActionChallenge createCredentialInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/auth/credentials", body); + } + + /** Delegated signing step 2 for Create Credential: submits the signed challenge and issues the request. */ + public Credential createCredentialComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/credentials", java.util.Map.of(), body, Credential.class, userAction); + } + + /** Create Credential Challenge */ + public Object createCredentialChallenge(CreateCredentialChallengeRequest body) { + return httpClient.post("/auth/credentials/init", java.util.Map.of(), body, Object.class, false); + } + + /** Delegated signing step 1 for Activate Credential: returns the challenge to sign out-of-band. */ + public UserActionChallenge activateCredentialInit(ActivateCredentialRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/credentials/activate", body); + } + + /** Delegated signing step 2 for Activate Credential: submits the signed challenge and issues the request. */ + public ActivateCredentialResponse activateCredentialComplete(ActivateCredentialRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/credentials/activate", java.util.Map.of(), body, ActivateCredentialResponse.class, userAction); + } + + /** Delegated signing step 1 for Delete Credential: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteCredentialInit(String credentialUuid) { + return httpClient.createUserActionChallenge("DELETE", "/auth/credentials/" + credentialUuid, null); + } + + /** Delegated signing step 2 for Delete Credential: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public Map deleteCredentialComplete(String credentialUuid, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/auth/credentials/" + credentialUuid, java.util.Map.of(), null, (Class>) (Class) Map.class, userAction); + } + + /** Delegated signing step 1 for Deactivate Credential: returns the challenge to sign out-of-band. */ + public UserActionChallenge deactivateCredentialInit(DeactivateCredentialRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/credentials/deactivate", body); + } + + /** Delegated signing step 2 for Deactivate Credential: submits the signed challenge and issues the request. */ + public DeactivateCredentialResponse deactivateCredentialComplete(DeactivateCredentialRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/credentials/deactivate", java.util.Map.of(), body, DeactivateCredentialResponse.class, userAction); + } + + /** Delegated signing step 1 for Create Credential Code: returns the challenge to sign out-of-band. */ + public UserActionChallenge createCredentialCodeInit(CreateCredentialCodeRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/credentials/code", body); + } + + /** Delegated signing step 2 for Create Credential Code: submits the signed challenge and issues the request. */ + public CreateCredentialCodeResponse createCredentialCodeComplete(CreateCredentialCodeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/credentials/code", java.util.Map.of(), body, CreateCredentialCodeResponse.class, userAction); + } + + /** Create Credential Challenge With Code */ + public Object createCredentialChallengeWithCode(CreateCredentialChallengeWithCodeRequest body) { + return httpClient.post("/auth/credentials/code/init", java.util.Map.of(), body, Object.class, false); + } + + /** Create Credential With Code */ + public Credential createCredentialWithCode(Object body) { + return httpClient.post("/auth/credentials/code/verify", java.util.Map.of(), body, Credential.class, false); + } + + /** Create Login Challenge */ + public CreateLoginChallengeResponse createLoginChallenge(CreateLoginChallengeRequest body) { + return httpClient.post("/auth/login/init", java.util.Map.of(), body, CreateLoginChallengeResponse.class, false); + } + + /** Delegated signing step 1 for Delegated Login: returns the challenge to sign out-of-band. */ + public UserActionChallenge delegatedLoginInit(DelegatedLoginRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/login/delegated", body); + } + + /** Delegated signing step 2 for Delegated Login: submits the signed challenge and issues the request. */ + public DelegatedLoginResponse delegatedLoginComplete(DelegatedLoginRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/login/delegated", java.util.Map.of(), body, DelegatedLoginResponse.class, userAction); + } + + /** Complete User Login */ + public Object completeUserLogin(CompleteUserLoginRequest body) { + return httpClient.post("/auth/login", java.util.Map.of(), body, Object.class, false); + } + + /** Logout */ + public LogoutResponse logout(LogoutRequest body) { + return httpClient.put("/auth/logout", java.util.Map.of(), body, LogoutResponse.class, false); + } + + /** Send Login Code */ + public SendLoginCodeResponse sendLoginCode(SendLoginCodeRequest body) { + return httpClient.post("/auth/login/code", java.util.Map.of(), body, SendLoginCodeResponse.class, false); + } + + /** Social Login */ + public SocialLoginResponse socialLogin(SocialLoginRequest body) { + return httpClient.post("/auth/login/social", java.util.Map.of(), body, SocialLoginResponse.class, false); + } + + /** Complete SSO Login */ + public CompleteSsoLoginResponse completeSsoLogin(CompleteSsoLoginRequest body) { + return httpClient.post("/auth/login/sso", java.util.Map.of(), body, CompleteSsoLoginResponse.class, false); + } + + /** Initiate SSO Login */ + public InitiateSsoLoginResponse initiateSsoLogin(InitiateSsoLoginRequest body) { + return httpClient.post("/auth/login/sso/init", java.util.Map.of(), body, InitiateSsoLoginResponse.class, false); + } + + /** Exchange Access Token */ + public ExchangeAccessTokenResponse exchangeAccessToken(ExchangeAccessTokenRequest body) { + return httpClient.post("/auth/tokens", java.util.Map.of(), body, ExchangeAccessTokenResponse.class, false); + } + + /** List Personal Access Tokens */ + public ListPersonalAccessTokensResponse listPersonalAccessTokens() { + return httpClient.get("/auth/pats", java.util.Map.of(), ListPersonalAccessTokensResponse.class); + } + + /** Delegated signing step 1 for Create Personal Access Token: returns the challenge to sign out-of-band. */ + public UserActionChallenge createPersonalAccessTokenInit(CreatePersonalAccessTokenRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/pats", body); + } + + /** Delegated signing step 2 for Create Personal Access Token: submits the signed challenge and issues the request. */ + public CreatePersonalAccessTokenResponse createPersonalAccessTokenComplete(CreatePersonalAccessTokenRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/pats", java.util.Map.of(), body, CreatePersonalAccessTokenResponse.class, userAction); + } + + /** Get Personal Access Token */ + public PersonalAccessToken getPersonalAccessToken(String tokenId) { + return httpClient.get("/auth/pats/" + tokenId, java.util.Map.of(), PersonalAccessToken.class); + } + + /** Delegated signing step 1 for Update Personal Access Token: returns the challenge to sign out-of-band. */ + public UserActionChallenge updatePersonalAccessTokenInit(String tokenId, UpdatePersonalAccessTokenRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/pats/" + tokenId, body); + } + + /** Delegated signing step 2 for Update Personal Access Token: submits the signed challenge and issues the request. */ + public PersonalAccessToken updatePersonalAccessTokenComplete(String tokenId, UpdatePersonalAccessTokenRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/pats/" + tokenId, java.util.Map.of(), body, PersonalAccessToken.class, userAction); + } + + /** Delegated signing step 1 for Delete Personal Access Token: returns the challenge to sign out-of-band. */ + public UserActionChallenge deletePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallenge("DELETE", "/auth/pats/" + tokenId, null); + } + + /** Delegated signing step 2 for Delete Personal Access Token: submits the signed challenge and issues the request. */ + public PersonalAccessToken deletePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/auth/pats/" + tokenId, java.util.Map.of(), null, PersonalAccessToken.class, userAction); + } + + /** Delegated signing step 1 for Activate Personal Access Token: returns the challenge to sign out-of-band. */ + public UserActionChallenge activatePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallenge("PUT", "/auth/pats/" + tokenId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Personal Access Token: submits the signed challenge and issues the request. */ + public PersonalAccessToken activatePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/pats/" + tokenId + "/activate", java.util.Map.of(), null, PersonalAccessToken.class, userAction); + } + + /** Delegated signing step 1 for Deactivate Personal Access Token: returns the challenge to sign out-of-band. */ + public UserActionChallenge deactivatePersonalAccessTokenInit(String tokenId) { + return httpClient.createUserActionChallenge("PUT", "/auth/pats/" + tokenId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate Personal Access Token: submits the signed challenge and issues the request. */ + public PersonalAccessToken deactivatePersonalAccessTokenComplete(String tokenId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/pats/" + tokenId + "/deactivate", java.util.Map.of(), null, PersonalAccessToken.class, userAction); + } + + /** Delegated signing step 1 for Create Delegated Recovery Challenge: returns the challenge to sign out-of-band. */ + public UserActionChallenge createDelegatedRecoveryChallengeInit(CreateDelegatedRecoveryChallengeRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/recover/user/delegated", body); + } + + /** Delegated signing step 2 for Create Delegated Recovery Challenge: submits the signed challenge and issues the request. */ + public CreateDelegatedRecoveryChallengeResponse createDelegatedRecoveryChallengeComplete(CreateDelegatedRecoveryChallengeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/recover/user/delegated", java.util.Map.of(), body, CreateDelegatedRecoveryChallengeResponse.class, userAction); + } + + /** Recover User */ + public RecoverUserResponse recoverUser(RecoverUserRequest body) { + return httpClient.post("/auth/recover/user", java.util.Map.of(), body, RecoverUserResponse.class, false); + } + + /** Create Recovery Challenge */ + public CreateRecoveryChallengeResponse createRecoveryChallenge(CreateRecoveryChallengeRequest body) { + return httpClient.post("/auth/recover/user/init", java.util.Map.of(), body, CreateRecoveryChallengeResponse.class, false); + } + + /** Send Recovery Code Email */ + public SendRecoveryCodeEmailResponse sendRecoveryCodeEmail(SendRecoveryCodeEmailRequest body) { + return httpClient.post("/auth/recover/user/code", java.util.Map.of(), body, SendRecoveryCodeEmailResponse.class, false); + } + + /** Delegated signing step 1 for Create Delegated Registration Challenge: returns the challenge to sign out-of-band. */ + public UserActionChallenge createDelegatedRegistrationChallengeInit(CreateDelegatedRegistrationChallengeRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/registration/delegated", body); + } + + /** Delegated signing step 2 for Create Delegated Registration Challenge: submits the signed challenge and issues the request. */ + public CreateDelegatedRegistrationChallengeResponse createDelegatedRegistrationChallengeComplete(CreateDelegatedRegistrationChallengeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/registration/delegated", java.util.Map.of(), body, CreateDelegatedRegistrationChallengeResponse.class, userAction); + } + + /** Create Registration Challenge */ + public CreateRegistrationChallengeResponse createRegistrationChallenge(CreateRegistrationChallengeRequest body) { + return httpClient.post("/auth/registration/init", java.util.Map.of(), body, CreateRegistrationChallengeResponse.class, false); + } + + /** Create Social Registration Challenge */ + public CreateSocialRegistrationChallengeResponse createSocialRegistrationChallenge(CreateSocialRegistrationChallengeRequest body) { + return httpClient.post("/auth/registration/social", java.util.Map.of(), body, CreateSocialRegistrationChallengeResponse.class, false); + } + + /** Complete User Registration */ + public CompleteUserRegistrationResponse completeUserRegistration(CompleteUserRegistrationRequest body) { + return httpClient.post("/auth/registration", java.util.Map.of(), body, CompleteUserRegistrationResponse.class, false); + } + + /** Complete End User Registration with Wallets */ + public CompleteEndUserRegistrationWithWalletsResponse completeEndUserRegistrationWithWallets(CompleteEndUserRegistrationWithWalletsRequest body) { + return httpClient.post("/auth/registration/enduser", java.util.Map.of(), body, CompleteEndUserRegistrationWithWalletsResponse.class, false); + } + + /** Resend Registration Code */ + public ResendRegistrationCodeResponse resendRegistrationCode(ResendRegistrationCodeRequest body) { + return httpClient.put("/auth/registration/code", java.util.Map.of(), body, ResendRegistrationCodeResponse.class, false); + } + + /** List Service Accounts */ + public ListServiceAccountsResponse listServiceAccounts() { + return httpClient.get("/auth/service-accounts", java.util.Map.of(), ListServiceAccountsResponse.class); + } + + /** Delegated signing step 1 for Create Service Account: returns the challenge to sign out-of-band. */ + public UserActionChallenge createServiceAccountInit(CreateServiceAccountRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/service-accounts", body); + } + + /** Delegated signing step 2 for Create Service Account: submits the signed challenge and issues the request. */ + public CreateServiceAccountResponse createServiceAccountComplete(CreateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/service-accounts", java.util.Map.of(), body, CreateServiceAccountResponse.class, userAction); + } + + /** Get Service Account */ + public GetServiceAccountResponse getServiceAccount(String serviceAccountId) { + return httpClient.get("/auth/service-accounts/" + serviceAccountId, java.util.Map.of(), GetServiceAccountResponse.class); + } + + /** Delegated signing step 1 for Update Service Account: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateServiceAccountInit(String serviceAccountId, UpdateServiceAccountRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/service-accounts/" + serviceAccountId, body); + } + + /** Delegated signing step 2 for Update Service Account: submits the signed challenge and issues the request. */ + public UpdateServiceAccountResponse updateServiceAccountComplete(String serviceAccountId, UpdateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/service-accounts/" + serviceAccountId, java.util.Map.of(), body, UpdateServiceAccountResponse.class, userAction); + } + + /** Delegated signing step 1 for Delete Service Account: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteServiceAccountInit(String serviceAccountId) { + return httpClient.createUserActionChallenge("DELETE", "/auth/service-accounts/" + serviceAccountId, null); + } + + /** Delegated signing step 2 for Delete Service Account: submits the signed challenge and issues the request. */ + public DeleteServiceAccountResponse deleteServiceAccountComplete(String serviceAccountId, DeleteServiceAccountQuery query, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/auth/service-accounts/" + serviceAccountId, query.toMap(), null, DeleteServiceAccountResponse.class, userAction); + } + + /** Delegated signing step 1 for Activate Service Account: returns the challenge to sign out-of-band. */ + public UserActionChallenge activateServiceAccountInit(String serviceAccountId) { + return httpClient.createUserActionChallenge("PUT", "/auth/service-accounts/" + serviceAccountId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Service Account: submits the signed challenge and issues the request. */ + public ActivateServiceAccountResponse activateServiceAccountComplete(String serviceAccountId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/service-accounts/" + serviceAccountId + "/activate", java.util.Map.of(), null, ActivateServiceAccountResponse.class, userAction); + } + + /** Delegated signing step 1 for Deactivate Service Account: returns the challenge to sign out-of-band. */ + public UserActionChallenge deactivateServiceAccountInit(String serviceAccountId, DeactivateServiceAccountRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/service-accounts/" + serviceAccountId + "/deactivate", body); + } + + /** Delegated signing step 2 for Deactivate Service Account: submits the signed challenge and issues the request. */ + public DeactivateServiceAccountResponse deactivateServiceAccountComplete(String serviceAccountId, DeactivateServiceAccountRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/service-accounts/" + serviceAccountId + "/deactivate", java.util.Map.of(), body, DeactivateServiceAccountResponse.class, userAction); + } + + /** Delegated signing step 1 for Activate User: returns the challenge to sign out-of-band. */ + public UserActionChallenge activateUserInit(String userId) { + return httpClient.createUserActionChallenge("PUT", "/auth/users/" + userId + "/activate", null); + } + + /** Delegated signing step 2 for Activate User: submits the signed challenge and issues the request. */ + public User activateUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/users/" + userId + "/activate", java.util.Map.of(), null, User.class, userAction); + } + + /** Delegated signing step 1 for Deactivate User: returns the challenge to sign out-of-band. */ + public UserActionChallenge deactivateUserInit(String userId) { + return httpClient.createUserActionChallenge("PUT", "/auth/users/" + userId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate User: submits the signed challenge and issues the request. */ + public User deactivateUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/users/" + userId + "/deactivate", java.util.Map.of(), null, User.class, userAction); + } + + /** Get User */ + public User getUser(String userId) { + return httpClient.get("/auth/users/" + userId, java.util.Map.of(), User.class); + } + + /** Delegated signing step 1 for Update User: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateUserInit(String userId, UpdateUserRequest body) { + return httpClient.createUserActionChallenge("PUT", "/auth/users/" + userId, body); + } + + /** Delegated signing step 2 for Update User: submits the signed challenge and issues the request. */ + public User updateUserComplete(String userId, UpdateUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/auth/users/" + userId, java.util.Map.of(), body, User.class, userAction); + } + + /** Delegated signing step 1 for Delete User: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteUserInit(String userId) { + return httpClient.createUserActionChallenge("DELETE", "/auth/users/" + userId, null); + } + + /** Delegated signing step 2 for Delete User: submits the signed challenge and issues the request. */ + public User deleteUserComplete(String userId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/auth/users/" + userId, java.util.Map.of(), null, User.class, userAction); + } + + /** List Users */ + public PaginatedList listUsers(ListUsersQuery query) { + return httpClient.get("/auth/users", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create User: returns the challenge to sign out-of-band. */ + public UserActionChallenge createUserInit(CreateUserRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/users", body); + } + + /** Delegated signing step 2 for Create User: submits the signed challenge and issues the request. */ + public User createUserComplete(CreateUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/users", java.util.Map.of(), body, User.class, userAction); + } + + /** Delegated signing step 1 for Invite Tenant User: returns the challenge to sign out-of-band. */ + public UserActionChallenge inviteTenantUserInit(InviteTenantUserRequest body) { + return httpClient.createUserActionChallenge("POST", "/auth/users/invite", body); + } + + /** Delegated signing step 2 for Invite Tenant User: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public Map inviteTenantUserComplete(InviteTenantUserRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/auth/users/invite", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/auth/model/InitiateSsoLoginRequest.java b/src/main/java/co/dfns/sdk/auth/model/InitiateSsoLoginRequest.java index 7d17afd..09a4d55 100644 --- a/src/main/java/co/dfns/sdk/auth/model/InitiateSsoLoginRequest.java +++ b/src/main/java/co/dfns/sdk/auth/model/InitiateSsoLoginRequest.java @@ -2,10 +2,14 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonInclude; @JsonIgnoreProperties(ignoreUnknown = true) public record InitiateSsoLoginRequest( + @JsonInclude(JsonInclude.Include.NON_NULL) @JsonProperty("orgId") String orgId, + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonProperty("tenantId") String tenantId, @JsonProperty("clientId") String clientId, @JsonProperty("redirectUri") String redirectUri ) {} diff --git a/src/main/java/co/dfns/sdk/auth/model/Network.java b/src/main/java/co/dfns/sdk/auth/model/Network.java index 313f316..1eae02d 100644 --- a/src/main/java/co/dfns/sdk/auth/model/Network.java +++ b/src/main/java/co/dfns/sdk/auth/model/Network.java @@ -84,6 +84,10 @@ public enum Network { PolymeshTestnet("PolymeshTestnet"), Race("Race"), RaceSepolia("RaceSepolia"), + Rayls("Rayls"), + RaylsTestnet("RaylsTestnet"), + Robinhood("Robinhood"), + RobinhoodSepolia("RobinhoodSepolia"), SeiAtlantic2("SeiAtlantic2"), SeiPacific1("SeiPacific1"), Solana("Solana"), diff --git a/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesAsyncClient.java b/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesAsyncClient.java new file mode 100644 index 0000000..a40cc72 --- /dev/null +++ b/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesAsyncClient.java @@ -0,0 +1,87 @@ +package co.dfns.sdk.exchanges; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.exchanges.model.*; +import java.util.Map; +import java.util.List; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedExchangesAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedExchangesAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Exchange */ + public CompletableFuture getExchange(String exchangeId) { + return httpClient.getAsync("/exchanges/" + exchangeId, java.util.Map.of(), GetExchangeResponse.class); + } + + /** Delegated signing step 1 for Delete Exchange: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteExchangeInit(String exchangeId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/exchanges/" + exchangeId, null); + } + + /** Delegated signing step 2 for Delete Exchange: submits the signed challenge and issues the request. */ + public CompletableFuture deleteExchangeComplete(String exchangeId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/exchanges/" + exchangeId, java.util.Map.of(), null, DeleteExchangeResponse.class, userAction)); + } + + /** List Exchanges */ + public CompletableFuture listExchanges(ListExchangesQuery query) { + return httpClient.getAsync("/exchanges", query.toMap(), ListExchangesResponse.class); + } + + /** Delegated signing step 1 for Create Exchange: returns the challenge to sign out-of-band. */ + public CompletableFuture createExchangeInit(CreateExchangeRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/exchanges", body); + } + + /** Delegated signing step 2 for Create Exchange: submits the signed challenge and issues the request. */ + public CompletableFuture createExchangeComplete(CreateExchangeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/exchanges", java.util.Map.of(), body, CreateExchangeResponse.class, userAction)); + } + + /** List Accounts */ + public CompletableFuture listAccounts(String exchangeId, ListAccountsQuery query) { + return httpClient.getAsync("/exchanges/" + exchangeId + "/accounts", query.toMap(), ListAccountsResponse.class); + } + + /** List Account Assets */ + public CompletableFuture listAccountAssets(String exchangeId, String accountId, ListAccountAssetsQuery query) { + return httpClient.getAsync("/exchanges/" + exchangeId + "/accounts/" + accountId + "/assets", query.toMap(), ListAccountAssetsResponse.class); + } + + /** List Asset Withdrawal Networks */ + @SuppressWarnings("unchecked") + public CompletableFuture> listAssetWithdrawalNetworks(String exchangeId, String accountId, String asset) { + return httpClient.getAsync("/exchanges/" + exchangeId + "/accounts/" + accountId + "/assets/" + asset + "/withdrawal-networks", java.util.Map.of(), (Class>) (Class) List.class); + } + + /** Delegated signing step 1 for Create Exchange Deposit: returns the challenge to sign out-of-band. */ + public CompletableFuture createExchangeDepositInit(String exchangeId, String accountId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/deposits", body); + } + + /** Delegated signing step 2 for Create Exchange Deposit: submits the signed challenge and issues the request. */ + public CompletableFuture createExchangeDepositComplete(String exchangeId, String accountId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/deposits", java.util.Map.of(), body, CreateExchangeDepositResponse.class, userAction)); + } + + /** Delegated signing step 1 for Create Exchange Withdrawal: returns the challenge to sign out-of-band. */ + public CompletableFuture createExchangeWithdrawalInit(String exchangeId, String accountId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/withdrawals", body); + } + + /** Delegated signing step 2 for Create Exchange Withdrawal: submits the signed challenge and issues the request. */ + public CompletableFuture createExchangeWithdrawalComplete(String exchangeId, String accountId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/withdrawals", java.util.Map.of(), body, CreateExchangeWithdrawalResponse.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesClient.java b/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesClient.java new file mode 100644 index 0000000..7ccb59b --- /dev/null +++ b/src/main/java/co/dfns/sdk/exchanges/DelegatedExchangesClient.java @@ -0,0 +1,86 @@ +package co.dfns.sdk.exchanges; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.exchanges.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedExchangesClient { + private final DfnsHttpClient httpClient; + + public DelegatedExchangesClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Exchange */ + public GetExchangeResponse getExchange(String exchangeId) { + return httpClient.get("/exchanges/" + exchangeId, java.util.Map.of(), GetExchangeResponse.class); + } + + /** Delegated signing step 1 for Delete Exchange: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteExchangeInit(String exchangeId) { + return httpClient.createUserActionChallenge("DELETE", "/exchanges/" + exchangeId, null); + } + + /** Delegated signing step 2 for Delete Exchange: submits the signed challenge and issues the request. */ + public DeleteExchangeResponse deleteExchangeComplete(String exchangeId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/exchanges/" + exchangeId, java.util.Map.of(), null, DeleteExchangeResponse.class, userAction); + } + + /** List Exchanges */ + public ListExchangesResponse listExchanges(ListExchangesQuery query) { + return httpClient.get("/exchanges", query.toMap(), ListExchangesResponse.class); + } + + /** Delegated signing step 1 for Create Exchange: returns the challenge to sign out-of-band. */ + public UserActionChallenge createExchangeInit(CreateExchangeRequest body) { + return httpClient.createUserActionChallenge("POST", "/exchanges", body); + } + + /** Delegated signing step 2 for Create Exchange: submits the signed challenge and issues the request. */ + public CreateExchangeResponse createExchangeComplete(CreateExchangeRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/exchanges", java.util.Map.of(), body, CreateExchangeResponse.class, userAction); + } + + /** List Accounts */ + public ListAccountsResponse listAccounts(String exchangeId, ListAccountsQuery query) { + return httpClient.get("/exchanges/" + exchangeId + "/accounts", query.toMap(), ListAccountsResponse.class); + } + + /** List Account Assets */ + public ListAccountAssetsResponse listAccountAssets(String exchangeId, String accountId, ListAccountAssetsQuery query) { + return httpClient.get("/exchanges/" + exchangeId + "/accounts/" + accountId + "/assets", query.toMap(), ListAccountAssetsResponse.class); + } + + /** List Asset Withdrawal Networks */ + @SuppressWarnings("unchecked") + public List listAssetWithdrawalNetworks(String exchangeId, String accountId, String asset) { + return httpClient.get("/exchanges/" + exchangeId + "/accounts/" + accountId + "/assets/" + asset + "/withdrawal-networks", java.util.Map.of(), (Class>) (Class) List.class); + } + + /** Delegated signing step 1 for Create Exchange Deposit: returns the challenge to sign out-of-band. */ + public UserActionChallenge createExchangeDepositInit(String exchangeId, String accountId, Object body) { + return httpClient.createUserActionChallenge("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/deposits", body); + } + + /** Delegated signing step 2 for Create Exchange Deposit: submits the signed challenge and issues the request. */ + public CreateExchangeDepositResponse createExchangeDepositComplete(String exchangeId, String accountId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/deposits", java.util.Map.of(), body, CreateExchangeDepositResponse.class, userAction); + } + + /** Delegated signing step 1 for Create Exchange Withdrawal: returns the challenge to sign out-of-band. */ + public UserActionChallenge createExchangeWithdrawalInit(String exchangeId, String accountId, Object body) { + return httpClient.createUserActionChallenge("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/withdrawals", body); + } + + /** Delegated signing step 2 for Create Exchange Withdrawal: submits the signed challenge and issues the request. */ + public CreateExchangeWithdrawalResponse createExchangeWithdrawalComplete(String exchangeId, String accountId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/exchanges/" + exchangeId + "/accounts/" + accountId + "/withdrawals", java.util.Map.of(), body, CreateExchangeWithdrawalResponse.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsAsyncClient.java b/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsAsyncClient.java new file mode 100644 index 0000000..ca7be2f --- /dev/null +++ b/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsAsyncClient.java @@ -0,0 +1,77 @@ +package co.dfns.sdk.feesponsors; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.feesponsors.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedFeeSponsorsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedFeeSponsorsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Fee Sponsors */ + public CompletableFuture> listFeeSponsors(ListFeeSponsorsQuery query) { + return httpClient.getAsync("/fee-sponsors", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Fee Sponsor: returns the challenge to sign out-of-band. */ + public CompletableFuture createFeeSponsorInit(CreateFeeSponsorRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/fee-sponsors", body); + } + + /** Delegated signing step 2 for Create Fee Sponsor: submits the signed challenge and issues the request. */ + public CompletableFuture createFeeSponsorComplete(CreateFeeSponsorRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/fee-sponsors", java.util.Map.of(), body, FeeSponsor.class, userAction)); + } + + /** Get Fee Sponsor */ + public CompletableFuture getFeeSponsor(String feeSponsorId) { + return httpClient.getAsync("/fee-sponsors/" + feeSponsorId, java.util.Map.of(), FeeSponsor.class); + } + + /** Delegated signing step 1 for Delete Fee Sponsor: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/fee-sponsors/" + feeSponsorId, null); + } + + /** Delegated signing step 2 for Delete Fee Sponsor: submits the signed challenge and issues the request. */ + public CompletableFuture deleteFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/fee-sponsors/" + feeSponsorId, java.util.Map.of(), null, FeeSponsor.class, userAction)); + } + + /** Delegated signing step 1 for Deactivate Fee Sponsor: returns the challenge to sign out-of-band. */ + public CompletableFuture deactivateFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallengeAsync("PUT", "/fee-sponsors/" + feeSponsorId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate Fee Sponsor: submits the signed challenge and issues the request. */ + public CompletableFuture deactivateFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/fee-sponsors/" + feeSponsorId + "/deactivate", java.util.Map.of(), null, FeeSponsor.class, userAction)); + } + + /** Delegated signing step 1 for Activate Fee Sponsor: returns the challenge to sign out-of-band. */ + public CompletableFuture activateFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallengeAsync("PUT", "/fee-sponsors/" + feeSponsorId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Fee Sponsor: submits the signed challenge and issues the request. */ + public CompletableFuture activateFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/fee-sponsors/" + feeSponsorId + "/activate", java.util.Map.of(), null, FeeSponsor.class, userAction)); + } + + /** List Sponsored Fees */ + public CompletableFuture listSponsoredFees(String feeSponsorId, ListSponsoredFeesQuery query) { + return httpClient.getAsync("/fee-sponsors/" + feeSponsorId + "/fees", query.toMap(), ListSponsoredFeesResponse.class); + } +} diff --git a/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsClient.java b/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsClient.java new file mode 100644 index 0000000..5595406 --- /dev/null +++ b/src/main/java/co/dfns/sdk/feesponsors/DelegatedFeeSponsorsClient.java @@ -0,0 +1,76 @@ +package co.dfns.sdk.feesponsors; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.feesponsors.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedFeeSponsorsClient { + private final DfnsHttpClient httpClient; + + public DelegatedFeeSponsorsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Fee Sponsors */ + public PaginatedList listFeeSponsors(ListFeeSponsorsQuery query) { + return httpClient.get("/fee-sponsors", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Fee Sponsor: returns the challenge to sign out-of-band. */ + public UserActionChallenge createFeeSponsorInit(CreateFeeSponsorRequest body) { + return httpClient.createUserActionChallenge("POST", "/fee-sponsors", body); + } + + /** Delegated signing step 2 for Create Fee Sponsor: submits the signed challenge and issues the request. */ + public FeeSponsor createFeeSponsorComplete(CreateFeeSponsorRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/fee-sponsors", java.util.Map.of(), body, FeeSponsor.class, userAction); + } + + /** Get Fee Sponsor */ + public FeeSponsor getFeeSponsor(String feeSponsorId) { + return httpClient.get("/fee-sponsors/" + feeSponsorId, java.util.Map.of(), FeeSponsor.class); + } + + /** Delegated signing step 1 for Delete Fee Sponsor: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallenge("DELETE", "/fee-sponsors/" + feeSponsorId, null); + } + + /** Delegated signing step 2 for Delete Fee Sponsor: submits the signed challenge and issues the request. */ + public FeeSponsor deleteFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/fee-sponsors/" + feeSponsorId, java.util.Map.of(), null, FeeSponsor.class, userAction); + } + + /** Delegated signing step 1 for Deactivate Fee Sponsor: returns the challenge to sign out-of-band. */ + public UserActionChallenge deactivateFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallenge("PUT", "/fee-sponsors/" + feeSponsorId + "/deactivate", null); + } + + /** Delegated signing step 2 for Deactivate Fee Sponsor: submits the signed challenge and issues the request. */ + public FeeSponsor deactivateFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/fee-sponsors/" + feeSponsorId + "/deactivate", java.util.Map.of(), null, FeeSponsor.class, userAction); + } + + /** Delegated signing step 1 for Activate Fee Sponsor: returns the challenge to sign out-of-band. */ + public UserActionChallenge activateFeeSponsorInit(String feeSponsorId) { + return httpClient.createUserActionChallenge("PUT", "/fee-sponsors/" + feeSponsorId + "/activate", null); + } + + /** Delegated signing step 2 for Activate Fee Sponsor: submits the signed challenge and issues the request. */ + public FeeSponsor activateFeeSponsorComplete(String feeSponsorId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/fee-sponsors/" + feeSponsorId + "/activate", java.util.Map.of(), null, FeeSponsor.class, userAction); + } + + /** List Sponsored Fees */ + public ListSponsoredFeesResponse listSponsoredFees(String feeSponsorId, ListSponsoredFeesQuery query) { + return httpClient.get("/fee-sponsors/" + feeSponsorId + "/fees", query.toMap(), ListSponsoredFeesResponse.class); + } +} diff --git a/src/main/java/co/dfns/sdk/feesponsors/model/Network.java b/src/main/java/co/dfns/sdk/feesponsors/model/Network.java index 0f40429..bc4a6f1 100644 --- a/src/main/java/co/dfns/sdk/feesponsors/model/Network.java +++ b/src/main/java/co/dfns/sdk/feesponsors/model/Network.java @@ -84,6 +84,10 @@ public enum Network { PolymeshTestnet("PolymeshTestnet"), Race("Race"), RaceSepolia("RaceSepolia"), + Rayls("Rayls"), + RaylsTestnet("RaylsTestnet"), + Robinhood("Robinhood"), + RobinhoodSepolia("RobinhoodSepolia"), SeiAtlantic2("SeiAtlantic2"), SeiPacific1("SeiPacific1"), Solana("Solana"), diff --git a/src/main/java/co/dfns/sdk/internal/DfnsHttpClient.java b/src/main/java/co/dfns/sdk/internal/DfnsHttpClient.java index 166c856..250e038 100644 --- a/src/main/java/co/dfns/sdk/internal/DfnsHttpClient.java +++ b/src/main/java/co/dfns/sdk/internal/DfnsHttpClient.java @@ -214,6 +214,99 @@ private CompletableFuture obtainUserActionTokenAsync(String method, Stri } } + // ───────────────────────────────────────────────────────────────────────── + // Delegated user action signing (init/complete split) + // + // These expose the two halves of user action signing so a challenge can be + // signed out-of-band (e.g. by an end user's device) instead of by a Signer + // held in this process. createUserActionChallenge returns the challenge to + // sign; completeUserActionSigning exchanges the signed assertion for a token; + // executeWithUserAction issues the request with that token. + + public UserActionChallenge createUserActionChallenge(String method, String path, Object body) { + try { + String bodyJson = body != null ? mapper.writeValueAsString(body) : "{}"; + String initBody = mapper.writeValueAsString(Map.of( + "userActionHttpMethod", method, + "userActionHttpPath", path, + "userActionPayload", bodyJson, + "userActionServerKind", "Api" + )); + HttpRequest initReq = buildRequest("POST", "/auth/action/init", Map.of(), initBody, null); + return execute(initReq, UserActionChallenge.class); + } catch (DfnsException e) { + throw e; + } catch (Exception e) { + throw new DfnsException("Failed to create user action challenge: " + e.getMessage(), e); + } + } + + public CompletableFuture createUserActionChallengeAsync(String method, String path, Object body) { + try { + String bodyJson = body != null ? mapper.writeValueAsString(body) : "{}"; + String initBody = mapper.writeValueAsString(Map.of( + "userActionHttpMethod", method, + "userActionHttpPath", path, + "userActionPayload", bodyJson, + "userActionServerKind", "Api" + )); + HttpRequest initReq = buildRequest("POST", "/auth/action/init", Map.of(), initBody, null); + return executeAsync(initReq, UserActionChallenge.class); + } catch (Exception e) { + return CompletableFuture.failedFuture( + new DfnsException("Failed to create user action challenge: " + e.getMessage(), e)); + } + } + + public String completeUserActionSigning(String challengeIdentifier, co.dfns.sdk.auth.CredentialAssertion assertion) { + try { + String signBody = mapper.writeValueAsString(Map.of( + "challengeIdentifier", challengeIdentifier, + "firstFactor", assertion + )); + HttpRequest signReq = buildRequest("POST", "/auth/action", Map.of(), signBody, null); + @SuppressWarnings("unchecked") + Map signResp = execute(signReq, Map.class); + return (String) signResp.get("userAction"); + } catch (DfnsException e) { + throw e; + } catch (Exception e) { + throw new DfnsException("Failed to complete user action signing: " + e.getMessage(), e); + } + } + + public CompletableFuture completeUserActionSigningAsync(String challengeIdentifier, co.dfns.sdk.auth.CredentialAssertion assertion) { + try { + String signBody = mapper.writeValueAsString(Map.of( + "challengeIdentifier", challengeIdentifier, + "firstFactor", assertion + )); + HttpRequest signReq = buildRequest("POST", "/auth/action", Map.of(), signBody, null); + @SuppressWarnings("unchecked") + Class> mapClass = (Class>) (Class) Map.class; + return executeAsync(signReq, mapClass).thenApply(signResp -> (String) signResp.get("userAction")); + } catch (Exception e) { + return CompletableFuture.failedFuture( + new DfnsException("Failed to complete user action signing: " + e.getMessage(), e)); + } + } + + public T executeWithUserAction(String method, String path, Map query, Object body, Class responseType, String userAction) { + return execute(buildRequest(method, path, query, body, userAction), responseType); + } + + public T executeWithUserAction(String method, String path, Map query, Object body, TypeReference responseType, String userAction) { + return executeWithTypeRef(buildRequest(method, path, query, body, userAction), responseType); + } + + public CompletableFuture executeWithUserActionAsync(String method, String path, Map query, Object body, Class responseType, String userAction) { + return executeAsync(buildRequest(method, path, query, body, userAction), responseType); + } + + public CompletableFuture executeWithUserActionAsync(String method, String path, Map query, Object body, TypeReference responseType, String userAction) { + return executeAsyncWithTypeRef(buildRequest(method, path, query, body, userAction), responseType); + } + private HttpRequest buildRequest(String method, String path, Map query, Object body, String userAction) { try { String url = config.getBaseUrl() + path; diff --git a/src/main/java/co/dfns/sdk/keys/DelegatedKeysAsyncClient.java b/src/main/java/co/dfns/sdk/keys/DelegatedKeysAsyncClient.java new file mode 100644 index 0000000..101a2fb --- /dev/null +++ b/src/main/java/co/dfns/sdk/keys/DelegatedKeysAsyncClient.java @@ -0,0 +1,126 @@ +package co.dfns.sdk.keys; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.keys.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedKeysAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedKeysAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Keys */ + public CompletableFuture> listKeys(ListKeysQuery query) { + return httpClient.getAsync("/keys", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Key: returns the challenge to sign out-of-band. */ + public CompletableFuture createKeyInit(CreateKeyRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys", body); + } + + /** Delegated signing step 2 for Create Key: submits the signed challenge and issues the request. */ + public CompletableFuture createKeyComplete(CreateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys", java.util.Map.of(), body, Key.class, userAction)); + } + + /** Delegated signing step 1 for Delegate Key: returns the challenge to sign out-of-band. */ + public CompletableFuture delegateKeyInit(String keyId, DelegateKeyRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys/" + keyId + "/delegate", body); + } + + /** Delegated signing step 2 for Delegate Key: submits the signed challenge and issues the request. */ + public CompletableFuture delegateKeyComplete(String keyId, DelegateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys/" + keyId + "/delegate", java.util.Map.of(), body, DelegateKeyResponse.class, userAction)); + } + + /** Get Key */ + public CompletableFuture getKey(String keyId) { + return httpClient.getAsync("/keys/" + keyId, java.util.Map.of(), Key.class); + } + + /** Delegated signing step 1 for Update Key: returns the challenge to sign out-of-band. */ + public CompletableFuture updateKeyInit(String keyId, UpdateKeyRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/keys/" + keyId, body); + } + + /** Delegated signing step 2 for Update Key: submits the signed challenge and issues the request. */ + public CompletableFuture updateKeyComplete(String keyId, UpdateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/keys/" + keyId, java.util.Map.of(), body, Key.class, userAction)); + } + + /** Delegated signing step 1 for Delete Key: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteKeyInit(String keyId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/keys/" + keyId, null); + } + + /** Delegated signing step 2 for Delete Key: submits the signed challenge and issues the request. */ + public CompletableFuture deleteKeyComplete(String keyId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/keys/" + keyId, java.util.Map.of(), null, Key.class, userAction)); + } + + /** Delegated signing step 1 for Derive Key: returns the challenge to sign out-of-band. */ + public CompletableFuture deriveKeyInit(String keyId, DeriveKeyRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys/" + keyId + "/derive", body); + } + + /** Delegated signing step 2 for Derive Key: submits the signed challenge and issues the request. */ + public CompletableFuture deriveKeyComplete(String keyId, DeriveKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys/" + keyId + "/derive", java.util.Map.of(), body, DeriveKeyResponse.class, userAction)); + } + + /** Delegated signing step 1 for Export Key: returns the challenge to sign out-of-band. */ + public CompletableFuture exportKeyInit(String keyId, ExportKeyRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys/" + keyId + "/export", body); + } + + /** Delegated signing step 2 for Export Key: submits the signed challenge and issues the request. */ + public CompletableFuture exportKeyComplete(String keyId, ExportKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys/" + keyId + "/export", java.util.Map.of(), body, ExportKeyResponse.class, userAction)); + } + + /** List Signatures */ + public CompletableFuture listSignatures(String keyId, ListSignaturesQuery query) { + return httpClient.getAsync("/keys/" + keyId + "/signatures", query.toMap(), ListSignaturesResponse.class); + } + + /** Delegated signing step 1 for Generate Signature: returns the challenge to sign out-of-band. */ + public CompletableFuture generateSignatureInit(String keyId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys/" + keyId + "/signatures", body); + } + + /** Delegated signing step 2 for Generate Signature: submits the signed challenge and issues the request. */ + public CompletableFuture generateSignatureComplete(String keyId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys/" + keyId + "/signatures", java.util.Map.of(), body, SignatureRequest.class, userAction)); + } + + /** Get Signature */ + public CompletableFuture getSignature(String keyId, String signatureId) { + return httpClient.getAsync("/keys/" + keyId + "/signatures/" + signatureId, java.util.Map.of(), SignatureRequest.class); + } + + /** Delegated signing step 1 for Import Key: returns the challenge to sign out-of-band. */ + public CompletableFuture importKeyInit(ImportKeyRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/keys/import", body); + } + + /** Delegated signing step 2 for Import Key: submits the signed challenge and issues the request. */ + public CompletableFuture importKeyComplete(ImportKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/keys/import", java.util.Map.of(), body, Key.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/keys/DelegatedKeysClient.java b/src/main/java/co/dfns/sdk/keys/DelegatedKeysClient.java new file mode 100644 index 0000000..593e9f7 --- /dev/null +++ b/src/main/java/co/dfns/sdk/keys/DelegatedKeysClient.java @@ -0,0 +1,125 @@ +package co.dfns.sdk.keys; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.keys.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedKeysClient { + private final DfnsHttpClient httpClient; + + public DelegatedKeysClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Keys */ + public PaginatedList listKeys(ListKeysQuery query) { + return httpClient.get("/keys", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge createKeyInit(CreateKeyRequest body) { + return httpClient.createUserActionChallenge("POST", "/keys", body); + } + + /** Delegated signing step 2 for Create Key: submits the signed challenge and issues the request. */ + public Key createKeyComplete(CreateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys", java.util.Map.of(), body, Key.class, userAction); + } + + /** Delegated signing step 1 for Delegate Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge delegateKeyInit(String keyId, DelegateKeyRequest body) { + return httpClient.createUserActionChallenge("POST", "/keys/" + keyId + "/delegate", body); + } + + /** Delegated signing step 2 for Delegate Key: submits the signed challenge and issues the request. */ + public DelegateKeyResponse delegateKeyComplete(String keyId, DelegateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys/" + keyId + "/delegate", java.util.Map.of(), body, DelegateKeyResponse.class, userAction); + } + + /** Get Key */ + public Key getKey(String keyId) { + return httpClient.get("/keys/" + keyId, java.util.Map.of(), Key.class); + } + + /** Delegated signing step 1 for Update Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateKeyInit(String keyId, UpdateKeyRequest body) { + return httpClient.createUserActionChallenge("PUT", "/keys/" + keyId, body); + } + + /** Delegated signing step 2 for Update Key: submits the signed challenge and issues the request. */ + public Key updateKeyComplete(String keyId, UpdateKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/keys/" + keyId, java.util.Map.of(), body, Key.class, userAction); + } + + /** Delegated signing step 1 for Delete Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteKeyInit(String keyId) { + return httpClient.createUserActionChallenge("DELETE", "/keys/" + keyId, null); + } + + /** Delegated signing step 2 for Delete Key: submits the signed challenge and issues the request. */ + public Key deleteKeyComplete(String keyId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/keys/" + keyId, java.util.Map.of(), null, Key.class, userAction); + } + + /** Delegated signing step 1 for Derive Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge deriveKeyInit(String keyId, DeriveKeyRequest body) { + return httpClient.createUserActionChallenge("POST", "/keys/" + keyId + "/derive", body); + } + + /** Delegated signing step 2 for Derive Key: submits the signed challenge and issues the request. */ + public DeriveKeyResponse deriveKeyComplete(String keyId, DeriveKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys/" + keyId + "/derive", java.util.Map.of(), body, DeriveKeyResponse.class, userAction); + } + + /** Delegated signing step 1 for Export Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge exportKeyInit(String keyId, ExportKeyRequest body) { + return httpClient.createUserActionChallenge("POST", "/keys/" + keyId + "/export", body); + } + + /** Delegated signing step 2 for Export Key: submits the signed challenge and issues the request. */ + public ExportKeyResponse exportKeyComplete(String keyId, ExportKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys/" + keyId + "/export", java.util.Map.of(), body, ExportKeyResponse.class, userAction); + } + + /** List Signatures */ + public ListSignaturesResponse listSignatures(String keyId, ListSignaturesQuery query) { + return httpClient.get("/keys/" + keyId + "/signatures", query.toMap(), ListSignaturesResponse.class); + } + + /** Delegated signing step 1 for Generate Signature: returns the challenge to sign out-of-band. */ + public UserActionChallenge generateSignatureInit(String keyId, Object body) { + return httpClient.createUserActionChallenge("POST", "/keys/" + keyId + "/signatures", body); + } + + /** Delegated signing step 2 for Generate Signature: submits the signed challenge and issues the request. */ + public SignatureRequest generateSignatureComplete(String keyId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys/" + keyId + "/signatures", java.util.Map.of(), body, SignatureRequest.class, userAction); + } + + /** Get Signature */ + public SignatureRequest getSignature(String keyId, String signatureId) { + return httpClient.get("/keys/" + keyId + "/signatures/" + signatureId, java.util.Map.of(), SignatureRequest.class); + } + + /** Delegated signing step 1 for Import Key: returns the challenge to sign out-of-band. */ + public UserActionChallenge importKeyInit(ImportKeyRequest body) { + return httpClient.createUserActionChallenge("POST", "/keys/import", body); + } + + /** Delegated signing step 2 for Import Key: submits the signed challenge and issues the request. */ + public Key importKeyComplete(ImportKeyRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/keys/import", java.util.Map.of(), body, Key.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/keys/model/Network.java b/src/main/java/co/dfns/sdk/keys/model/Network.java index c66ea8e..4254769 100644 --- a/src/main/java/co/dfns/sdk/keys/model/Network.java +++ b/src/main/java/co/dfns/sdk/keys/model/Network.java @@ -84,6 +84,10 @@ public enum Network { PolymeshTestnet("PolymeshTestnet"), Race("Race"), RaceSepolia("RaceSepolia"), + Rayls("Rayls"), + RaylsTestnet("RaylsTestnet"), + Robinhood("Robinhood"), + RobinhoodSepolia("RobinhoodSepolia"), SeiAtlantic2("SeiAtlantic2"), SeiPacific1("SeiPacific1"), Solana("Solana"), diff --git a/src/main/java/co/dfns/sdk/networks/DelegatedNetworksAsyncClient.java b/src/main/java/co/dfns/sdk/networks/DelegatedNetworksAsyncClient.java new file mode 100644 index 0000000..97315fc --- /dev/null +++ b/src/main/java/co/dfns/sdk/networks/DelegatedNetworksAsyncClient.java @@ -0,0 +1,72 @@ +package co.dfns.sdk.networks; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.networks.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedNetworksAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedNetworksAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Estimate Fees */ + public CompletableFuture estimateFees(EstimateFeesQuery query) { + return httpClient.getAsync("/networks/fees", query.toMap(), Object.class); + } + + /** Call Function */ + @SuppressWarnings("unchecked") + public CompletableFuture> callFunction(String network, CallFunctionRequest body) { + return httpClient.postAsync("/networks/" + network + "/call-function", java.util.Map.of(), body, (Class>) (Class) Map.class, false); + } + + /** Get Canton Validator */ + public CompletableFuture getCantonValidator(String network, String validatorId) { + return httpClient.getAsync("/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), CantonValidator.class); + } + + /** Delegated signing step 1 for Update Canton Validator: returns the challenge to sign out-of-band. */ + public CompletableFuture updateCantonValidatorInit(String network, String validatorId, UpdateCantonValidatorRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/networks/" + network + "/validators/" + validatorId, body); + } + + /** Delegated signing step 2 for Update Canton Validator: submits the signed challenge and issues the request. */ + public CompletableFuture updateCantonValidatorComplete(String network, String validatorId, UpdateCantonValidatorRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), body, CantonValidator.class, userAction)); + } + + /** Delegated signing step 1 for Delete Canton Validator: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteCantonValidatorInit(String network, String validatorId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/networks/" + network + "/validators/" + validatorId, null); + } + + /** Delegated signing step 2 for Delete Canton Validator: submits the signed challenge and issues the request. */ + public CompletableFuture deleteCantonValidatorComplete(String network, String validatorId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), null, CantonValidator.class, userAction)); + } + + /** List Canton Validators */ + public CompletableFuture> listCantonValidators(String network, ListCantonValidatorsQuery query) { + return httpClient.getAsync("/networks/" + network + "/validators", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Canton Validator: returns the challenge to sign out-of-band. */ + public CompletableFuture createCantonValidatorInit(String network, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/networks/" + network + "/validators", body); + } + + /** Delegated signing step 2 for Create Canton Validator: submits the signed challenge and issues the request. */ + public CompletableFuture createCantonValidatorComplete(String network, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/networks/" + network + "/validators", java.util.Map.of(), body, CantonValidator.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/networks/DelegatedNetworksClient.java b/src/main/java/co/dfns/sdk/networks/DelegatedNetworksClient.java new file mode 100644 index 0000000..45158ce --- /dev/null +++ b/src/main/java/co/dfns/sdk/networks/DelegatedNetworksClient.java @@ -0,0 +1,71 @@ +package co.dfns.sdk.networks; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.networks.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedNetworksClient { + private final DfnsHttpClient httpClient; + + public DelegatedNetworksClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Estimate Fees */ + public Object estimateFees(EstimateFeesQuery query) { + return httpClient.get("/networks/fees", query.toMap(), Object.class); + } + + /** Call Function */ + @SuppressWarnings("unchecked") + public Map callFunction(String network, CallFunctionRequest body) { + return httpClient.post("/networks/" + network + "/call-function", java.util.Map.of(), body, (Class>) (Class) Map.class, false); + } + + /** Get Canton Validator */ + public CantonValidator getCantonValidator(String network, String validatorId) { + return httpClient.get("/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), CantonValidator.class); + } + + /** Delegated signing step 1 for Update Canton Validator: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateCantonValidatorInit(String network, String validatorId, UpdateCantonValidatorRequest body) { + return httpClient.createUserActionChallenge("PUT", "/networks/" + network + "/validators/" + validatorId, body); + } + + /** Delegated signing step 2 for Update Canton Validator: submits the signed challenge and issues the request. */ + public CantonValidator updateCantonValidatorComplete(String network, String validatorId, UpdateCantonValidatorRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), body, CantonValidator.class, userAction); + } + + /** Delegated signing step 1 for Delete Canton Validator: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteCantonValidatorInit(String network, String validatorId) { + return httpClient.createUserActionChallenge("DELETE", "/networks/" + network + "/validators/" + validatorId, null); + } + + /** Delegated signing step 2 for Delete Canton Validator: submits the signed challenge and issues the request. */ + public CantonValidator deleteCantonValidatorComplete(String network, String validatorId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/networks/" + network + "/validators/" + validatorId, java.util.Map.of(), null, CantonValidator.class, userAction); + } + + /** List Canton Validators */ + public PaginatedList listCantonValidators(String network, ListCantonValidatorsQuery query) { + return httpClient.get("/networks/" + network + "/validators", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Canton Validator: returns the challenge to sign out-of-band. */ + public UserActionChallenge createCantonValidatorInit(String network, Object body) { + return httpClient.createUserActionChallenge("POST", "/networks/" + network + "/validators", body); + } + + /** Delegated signing step 2 for Create Canton Validator: submits the signed challenge and issues the request. */ + public CantonValidator createCantonValidatorComplete(String network, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/networks/" + network + "/validators", java.util.Map.of(), body, CantonValidator.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsAsyncClient.java b/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsAsyncClient.java new file mode 100644 index 0000000..be8a9dd --- /dev/null +++ b/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsAsyncClient.java @@ -0,0 +1,54 @@ +package co.dfns.sdk.payouts; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.payouts.model.*; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPayoutsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedPayoutsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Payouts */ + public CompletableFuture listPayouts(ListPayoutsQuery query) { + return httpClient.getAsync("/payouts", query.toMap(), ListPayoutsResponse.class); + } + + /** Delegated signing step 1 for Create Payout: returns the challenge to sign out-of-band. */ + public CompletableFuture createPayoutInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/payouts", body); + } + + /** Delegated signing step 2 for Create Payout: submits the signed challenge and issues the request. */ + public CompletableFuture createPayoutComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/payouts", java.util.Map.of(), body, Object.class, userAction)); + } + + /** Request Payout Quote */ + public CompletableFuture requestPayoutQuote(Object body) { + return httpClient.postAsync("/payouts/quote", java.util.Map.of(), body, RequestPayoutQuoteResponse.class, false); + } + + /** Get Payout Status */ + public CompletableFuture getPayoutStatus(String payoutId) { + return httpClient.getAsync("/payouts/" + payoutId, java.util.Map.of(), Object.class); + } + + /** Delegated signing step 1 for Create Payout Action: returns the challenge to sign out-of-band. */ + public CompletableFuture createPayoutActionInit(String payoutId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/payouts/" + payoutId + "/action", body); + } + + /** Delegated signing step 2 for Create Payout Action: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public CompletableFuture> createPayoutActionComplete(String payoutId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/payouts/" + payoutId + "/action", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsClient.java b/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsClient.java new file mode 100644 index 0000000..d5821fd --- /dev/null +++ b/src/main/java/co/dfns/sdk/payouts/DelegatedPayoutsClient.java @@ -0,0 +1,53 @@ +package co.dfns.sdk.payouts; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.payouts.model.*; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPayoutsClient { + private final DfnsHttpClient httpClient; + + public DelegatedPayoutsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Payouts */ + public ListPayoutsResponse listPayouts(ListPayoutsQuery query) { + return httpClient.get("/payouts", query.toMap(), ListPayoutsResponse.class); + } + + /** Delegated signing step 1 for Create Payout: returns the challenge to sign out-of-band. */ + public UserActionChallenge createPayoutInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/payouts", body); + } + + /** Delegated signing step 2 for Create Payout: submits the signed challenge and issues the request. */ + public Object createPayoutComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/payouts", java.util.Map.of(), body, Object.class, userAction); + } + + /** Request Payout Quote */ + public RequestPayoutQuoteResponse requestPayoutQuote(Object body) { + return httpClient.post("/payouts/quote", java.util.Map.of(), body, RequestPayoutQuoteResponse.class, false); + } + + /** Get Payout Status */ + public Object getPayoutStatus(String payoutId) { + return httpClient.get("/payouts/" + payoutId, java.util.Map.of(), Object.class); + } + + /** Delegated signing step 1 for Create Payout Action: returns the challenge to sign out-of-band. */ + public UserActionChallenge createPayoutActionInit(String payoutId, Object body) { + return httpClient.createUserActionChallenge("POST", "/payouts/" + payoutId + "/action", body); + } + + /** Delegated signing step 2 for Create Payout Action: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public Map createPayoutActionComplete(String payoutId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/payouts/" + payoutId + "/action", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/payouts/model/ListPayoutsQuery.java b/src/main/java/co/dfns/sdk/payouts/model/ListPayoutsQuery.java index c4ea4c6..b988723 100644 --- a/src/main/java/co/dfns/sdk/payouts/model/ListPayoutsQuery.java +++ b/src/main/java/co/dfns/sdk/payouts/model/ListPayoutsQuery.java @@ -9,6 +9,7 @@ public class ListPayoutsQuery { private String paginationToken; private String walletId; private List status; + private List provider; public ListPayoutsQuery limit(Long limit) { this.limit = limit; @@ -30,12 +31,18 @@ public ListPayoutsQuery status(List status) { return this; } + public ListPayoutsQuery provider(List provider) { + this.provider = provider; + return this; + } + public Map toMap() { Map map = new HashMap<>(); if (limit != null) map.put("limit", String.valueOf(limit)); if (paginationToken != null) map.put("paginationToken", String.valueOf(paginationToken)); if (walletId != null) map.put("walletId", String.valueOf(walletId)); if (status != null) map.put("status", String.valueOf(status)); + if (provider != null) map.put("provider", String.valueOf(provider)); return map; } } diff --git a/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsAsyncClient.java b/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsAsyncClient.java new file mode 100644 index 0000000..8f564d4 --- /dev/null +++ b/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsAsyncClient.java @@ -0,0 +1,86 @@ +package co.dfns.sdk.permissions; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.permissions.model.*; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPermissionsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedPermissionsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Archive Permission: returns the challenge to sign out-of-band. */ + public CompletableFuture archivePermissionInit(String permissionId, ArchivePermissionRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/permissions/" + permissionId + "/archive", body); + } + + /** Delegated signing step 2 for Archive Permission: submits the signed challenge and issues the request. */ + public CompletableFuture archivePermissionComplete(String permissionId, ArchivePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/permissions/" + permissionId + "/archive", java.util.Map.of(), body, Permission.class, userAction)); + } + + /** List Permission Assignments */ + public CompletableFuture listPermissionAssignments(String permissionId, ListPermissionAssignmentsQuery query) { + return httpClient.getAsync("/permissions/" + permissionId + "/assignments", query.toMap(), ListPermissionAssignmentsResponse.class); + } + + /** Delegated signing step 1 for Assign Permission: returns the challenge to sign out-of-band. */ + public CompletableFuture assignPermissionInit(String permissionId, AssignPermissionRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/permissions/" + permissionId + "/assignments", body); + } + + /** Delegated signing step 2 for Assign Permission: submits the signed challenge and issues the request. */ + public CompletableFuture assignPermissionComplete(String permissionId, AssignPermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/permissions/" + permissionId + "/assignments", java.util.Map.of(), body, AssignPermissionResponse.class, userAction)); + } + + /** List Permissions */ + public CompletableFuture listPermissions(ListPermissionsQuery query) { + return httpClient.getAsync("/permissions", query.toMap(), ListPermissionsResponse.class); + } + + /** Delegated signing step 1 for Create Permission: returns the challenge to sign out-of-band. */ + public CompletableFuture createPermissionInit(CreatePermissionRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/permissions", body); + } + + /** Delegated signing step 2 for Create Permission: submits the signed challenge and issues the request. */ + public CompletableFuture createPermissionComplete(CreatePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/permissions", java.util.Map.of(), body, Permission.class, userAction)); + } + + /** Delegated signing step 1 for Revoke Permission: returns the challenge to sign out-of-band. */ + public CompletableFuture revokePermissionInit(String permissionId, String assignmentId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/permissions/" + permissionId + "/assignments/" + assignmentId, null); + } + + /** Delegated signing step 2 for Revoke Permission: submits the signed challenge and issues the request. */ + public CompletableFuture revokePermissionComplete(String permissionId, String assignmentId, RevokePermissionQuery query, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/permissions/" + permissionId + "/assignments/" + assignmentId, query.toMap(), null, Void.class, userAction)); + } + + /** Get Permission */ + public CompletableFuture getPermission(String permissionId) { + return httpClient.getAsync("/permissions/" + permissionId, java.util.Map.of(), Permission.class); + } + + /** Delegated signing step 1 for Update Permission: returns the challenge to sign out-of-band. */ + public CompletableFuture updatePermissionInit(String permissionId, UpdatePermissionRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/permissions/" + permissionId, body); + } + + /** Delegated signing step 2 for Update Permission: submits the signed challenge and issues the request. */ + public CompletableFuture updatePermissionComplete(String permissionId, UpdatePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/permissions/" + permissionId, java.util.Map.of(), body, Permission.class, userAction)); + } +} diff --git a/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsClient.java b/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsClient.java new file mode 100644 index 0000000..a36d4e8 --- /dev/null +++ b/src/main/java/co/dfns/sdk/permissions/DelegatedPermissionsClient.java @@ -0,0 +1,85 @@ +package co.dfns.sdk.permissions; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.permissions.model.*; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPermissionsClient { + private final DfnsHttpClient httpClient; + + public DelegatedPermissionsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Archive Permission: returns the challenge to sign out-of-band. */ + public UserActionChallenge archivePermissionInit(String permissionId, ArchivePermissionRequest body) { + return httpClient.createUserActionChallenge("PUT", "/permissions/" + permissionId + "/archive", body); + } + + /** Delegated signing step 2 for Archive Permission: submits the signed challenge and issues the request. */ + public Permission archivePermissionComplete(String permissionId, ArchivePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/permissions/" + permissionId + "/archive", java.util.Map.of(), body, Permission.class, userAction); + } + + /** List Permission Assignments */ + public ListPermissionAssignmentsResponse listPermissionAssignments(String permissionId, ListPermissionAssignmentsQuery query) { + return httpClient.get("/permissions/" + permissionId + "/assignments", query.toMap(), ListPermissionAssignmentsResponse.class); + } + + /** Delegated signing step 1 for Assign Permission: returns the challenge to sign out-of-band. */ + public UserActionChallenge assignPermissionInit(String permissionId, AssignPermissionRequest body) { + return httpClient.createUserActionChallenge("POST", "/permissions/" + permissionId + "/assignments", body); + } + + /** Delegated signing step 2 for Assign Permission: submits the signed challenge and issues the request. */ + public AssignPermissionResponse assignPermissionComplete(String permissionId, AssignPermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/permissions/" + permissionId + "/assignments", java.util.Map.of(), body, AssignPermissionResponse.class, userAction); + } + + /** List Permissions */ + public ListPermissionsResponse listPermissions(ListPermissionsQuery query) { + return httpClient.get("/permissions", query.toMap(), ListPermissionsResponse.class); + } + + /** Delegated signing step 1 for Create Permission: returns the challenge to sign out-of-band. */ + public UserActionChallenge createPermissionInit(CreatePermissionRequest body) { + return httpClient.createUserActionChallenge("POST", "/permissions", body); + } + + /** Delegated signing step 2 for Create Permission: submits the signed challenge and issues the request. */ + public Permission createPermissionComplete(CreatePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/permissions", java.util.Map.of(), body, Permission.class, userAction); + } + + /** Delegated signing step 1 for Revoke Permission: returns the challenge to sign out-of-band. */ + public UserActionChallenge revokePermissionInit(String permissionId, String assignmentId) { + return httpClient.createUserActionChallenge("DELETE", "/permissions/" + permissionId + "/assignments/" + assignmentId, null); + } + + /** Delegated signing step 2 for Revoke Permission: submits the signed challenge and issues the request. */ + public Void revokePermissionComplete(String permissionId, String assignmentId, RevokePermissionQuery query, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/permissions/" + permissionId + "/assignments/" + assignmentId, query.toMap(), null, Void.class, userAction); + } + + /** Get Permission */ + public Permission getPermission(String permissionId) { + return httpClient.get("/permissions/" + permissionId, java.util.Map.of(), Permission.class); + } + + /** Delegated signing step 1 for Update Permission: returns the challenge to sign out-of-band. */ + public UserActionChallenge updatePermissionInit(String permissionId, UpdatePermissionRequest body) { + return httpClient.createUserActionChallenge("PUT", "/permissions/" + permissionId, body); + } + + /** Delegated signing step 2 for Update Permission: submits the signed challenge and issues the request. */ + public Permission updatePermissionComplete(String permissionId, UpdatePermissionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/permissions/" + permissionId, java.util.Map.of(), body, Permission.class, userAction); + } +} diff --git a/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesAsyncClient.java b/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesAsyncClient.java new file mode 100644 index 0000000..b7e4274 --- /dev/null +++ b/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesAsyncClient.java @@ -0,0 +1,82 @@ +package co.dfns.sdk.policies; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.policies.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPoliciesAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedPoliciesAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Policy */ + public CompletableFuture getPolicy(String policyId) { + return httpClient.getAsync("/v2/policies/" + policyId, java.util.Map.of(), Policy.class); + } + + /** Delegated signing step 1 for Update Policy: returns the challenge to sign out-of-band. */ + public CompletableFuture updatePolicyInit(String policyId, Object body) { + return httpClient.createUserActionChallengeAsync("PUT", "/v2/policies/" + policyId, body); + } + + /** Delegated signing step 2 for Update Policy: submits the signed challenge and issues the request. */ + public CompletableFuture updatePolicyComplete(String policyId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/v2/policies/" + policyId, java.util.Map.of(), body, Policy.class, userAction)); + } + + /** Delegated signing step 1 for Delete Policy: returns the challenge to sign out-of-band. */ + public CompletableFuture deletePolicyInit(String policyId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/v2/policies/" + policyId, null); + } + + /** Delegated signing step 2 for Delete Policy: submits the signed challenge and issues the request. */ + public CompletableFuture deletePolicyComplete(String policyId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/v2/policies/" + policyId, java.util.Map.of(), null, Policy.class, userAction)); + } + + /** Delegated signing step 1 for Create Approval Decision: returns the challenge to sign out-of-band. */ + public CompletableFuture createApprovalDecisionInit(String approvalId, CreateApprovalDecisionRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/v2/policy-approvals/" + approvalId + "/decisions", body); + } + + /** Delegated signing step 2 for Create Approval Decision: submits the signed challenge and issues the request. */ + public CompletableFuture createApprovalDecisionComplete(String approvalId, CreateApprovalDecisionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/v2/policy-approvals/" + approvalId + "/decisions", java.util.Map.of(), body, PolicyApproval.class, userAction)); + } + + /** List Policies */ + public CompletableFuture listPolicies(ListPoliciesQuery query) { + return httpClient.getAsync("/v2/policies", query.toMap(), ListPoliciesResponse.class); + } + + /** Delegated signing step 1 for Create Policy: returns the challenge to sign out-of-band. */ + public CompletableFuture createPolicyInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/v2/policies", body); + } + + /** Delegated signing step 2 for Create Policy: submits the signed challenge and issues the request. */ + public CompletableFuture createPolicyComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/v2/policies", java.util.Map.of(), body, Policy.class, userAction)); + } + + /** Get Approval */ + public CompletableFuture getApproval(String approvalId) { + return httpClient.getAsync("/v2/policy-approvals/" + approvalId, java.util.Map.of(), PolicyApproval.class); + } + + /** List Approvals */ + public CompletableFuture> listApprovals(ListApprovalsQuery query) { + return httpClient.getAsync("/v2/policy-approvals", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } +} diff --git a/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesClient.java b/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesClient.java new file mode 100644 index 0000000..343686a --- /dev/null +++ b/src/main/java/co/dfns/sdk/policies/DelegatedPoliciesClient.java @@ -0,0 +1,81 @@ +package co.dfns.sdk.policies; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.policies.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedPoliciesClient { + private final DfnsHttpClient httpClient; + + public DelegatedPoliciesClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Get Policy */ + public Policy getPolicy(String policyId) { + return httpClient.get("/v2/policies/" + policyId, java.util.Map.of(), Policy.class); + } + + /** Delegated signing step 1 for Update Policy: returns the challenge to sign out-of-band. */ + public UserActionChallenge updatePolicyInit(String policyId, Object body) { + return httpClient.createUserActionChallenge("PUT", "/v2/policies/" + policyId, body); + } + + /** Delegated signing step 2 for Update Policy: submits the signed challenge and issues the request. */ + public Policy updatePolicyComplete(String policyId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/v2/policies/" + policyId, java.util.Map.of(), body, Policy.class, userAction); + } + + /** Delegated signing step 1 for Delete Policy: returns the challenge to sign out-of-band. */ + public UserActionChallenge deletePolicyInit(String policyId) { + return httpClient.createUserActionChallenge("DELETE", "/v2/policies/" + policyId, null); + } + + /** Delegated signing step 2 for Delete Policy: submits the signed challenge and issues the request. */ + public Policy deletePolicyComplete(String policyId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/v2/policies/" + policyId, java.util.Map.of(), null, Policy.class, userAction); + } + + /** Delegated signing step 1 for Create Approval Decision: returns the challenge to sign out-of-band. */ + public UserActionChallenge createApprovalDecisionInit(String approvalId, CreateApprovalDecisionRequest body) { + return httpClient.createUserActionChallenge("POST", "/v2/policy-approvals/" + approvalId + "/decisions", body); + } + + /** Delegated signing step 2 for Create Approval Decision: submits the signed challenge and issues the request. */ + public PolicyApproval createApprovalDecisionComplete(String approvalId, CreateApprovalDecisionRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/v2/policy-approvals/" + approvalId + "/decisions", java.util.Map.of(), body, PolicyApproval.class, userAction); + } + + /** List Policies */ + public ListPoliciesResponse listPolicies(ListPoliciesQuery query) { + return httpClient.get("/v2/policies", query.toMap(), ListPoliciesResponse.class); + } + + /** Delegated signing step 1 for Create Policy: returns the challenge to sign out-of-band. */ + public UserActionChallenge createPolicyInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/v2/policies", body); + } + + /** Delegated signing step 2 for Create Policy: submits the signed challenge and issues the request. */ + public Policy createPolicyComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/v2/policies", java.util.Map.of(), body, Policy.class, userAction); + } + + /** Get Approval */ + public PolicyApproval getApproval(String approvalId) { + return httpClient.get("/v2/policy-approvals/" + approvalId, java.util.Map.of(), PolicyApproval.class); + } + + /** List Approvals */ + public PaginatedList listApprovals(ListApprovalsQuery query) { + return httpClient.get("/v2/policy-approvals", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } +} diff --git a/src/main/java/co/dfns/sdk/signers/DelegatedSignersAsyncClient.java b/src/main/java/co/dfns/sdk/signers/DelegatedSignersAsyncClient.java new file mode 100644 index 0000000..cc26d33 --- /dev/null +++ b/src/main/java/co/dfns/sdk/signers/DelegatedSignersAsyncClient.java @@ -0,0 +1,106 @@ +package co.dfns.sdk.signers; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.signers.model.*; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedSignersAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedSignersAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Create Add Mac User Input: returns the challenge to sign out-of-band. */ + public CompletableFuture createAddMacUserInputInit(String storeId, CreateAddMacUserInputRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/key-stores/" + storeId + "/add-mac-user/input", body); + } + + /** Delegated signing step 2 for Create Add Mac User Input: submits the signed challenge and issues the request. */ + public CompletableFuture createAddMacUserInputComplete(String storeId, CreateAddMacUserInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/key-stores/" + storeId + "/add-mac-user/input", java.util.Map.of(), body, Object.class, userAction)); + } + + /** Delegated signing step 1 for Create Clone Input: returns the challenge to sign out-of-band. */ + public CompletableFuture createCloneInputInit(String storeId, CreateCloneInputRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/key-stores/" + storeId + "/clone/input", body); + } + + /** Delegated signing step 2 for Create Clone Input: submits the signed challenge and issues the request. */ + public CompletableFuture createCloneInputComplete(String storeId, CreateCloneInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/key-stores/" + storeId + "/clone/input", java.util.Map.of(), body, Object.class, userAction)); + } + + /** Delegated signing step 1 for Create Genesis Input: returns the challenge to sign out-of-band. */ + public CompletableFuture createGenesisInputInit(String storeId, CreateGenesisInputRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/key-stores/" + storeId + "/genesis/input", body); + } + + /** Delegated signing step 2 for Create Genesis Input: submits the signed challenge and issues the request. */ + public CompletableFuture createGenesisInputComplete(String storeId, CreateGenesisInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/key-stores/" + storeId + "/genesis/input", java.util.Map.of(), body, Object.class, userAction)); + } + + /** Delegated signing step 1 for Create Onchain Sign Input: returns the challenge to sign out-of-band. */ + public CompletableFuture createOnchainSignInputInit(String storeId, Map body) { + return httpClient.createUserActionChallengeAsync("POST", "/key-stores/" + storeId + "/onchain-sign/input", body); + } + + /** Delegated signing step 2 for Create Onchain Sign Input: submits the signed challenge and issues the request. */ + public CompletableFuture createOnchainSignInputComplete(String storeId, Map body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/key-stores/" + storeId + "/onchain-sign/input", java.util.Map.of(), body, Object.class, userAction)); + } + + /** Delegated signing step 1 for Create Proof Of Control Input: returns the challenge to sign out-of-band. */ + public CompletableFuture createProofOfControlInputInit(String storeId, CreateProofOfControlInputRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/key-stores/" + storeId + "/proof-of-control/input", body); + } + + /** Delegated signing step 2 for Create Proof Of Control Input: submits the signed challenge and issues the request. */ + public CompletableFuture createProofOfControlInputComplete(String storeId, CreateProofOfControlInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/key-stores/" + storeId + "/proof-of-control/input", java.util.Map.of(), body, Object.class, userAction)); + } + + /** List Key Stores */ + public CompletableFuture listKeyStores() { + return httpClient.getAsync("/key-stores", java.util.Map.of(), ListKeyStoresResponse.class); + } + + /** List Signers */ + public CompletableFuture listSigners() { + return httpClient.getAsync("/signers", java.util.Map.of(), ListSignersResponse.class); + } + + /** Submit Add Mac User Output */ + public CompletableFuture submitAddMacUserOutput(String storeId, SubmitAddMacUserOutputRequest body, byte[] file) { + return httpClient.postMultipartAsync("/key-stores/" + storeId + "/add-mac-user/output", java.util.Map.of(), body, file, SubmitAddMacUserOutputResponse.class, true); + } + + /** Submit Clone Output */ + public CompletableFuture submitCloneOutput(String storeId, SubmitCloneOutputRequest body, byte[] file) { + return httpClient.postMultipartAsync("/key-stores/" + storeId + "/clone/output", java.util.Map.of(), body, file, SubmitCloneOutputResponse.class, true); + } + + /** Submit Genesis Output */ + public CompletableFuture submitGenesisOutput(String storeId, SubmitGenesisOutputRequest body, byte[] file) { + return httpClient.postMultipartAsync("/key-stores/" + storeId + "/genesis/output", java.util.Map.of(), body, file, SubmitGenesisOutputResponse.class, true); + } + + /** Submit Onchain Sign Output */ + public CompletableFuture submitOnchainSignOutput(String storeId, SubmitOnchainSignOutputRequest body, byte[] file) { + return httpClient.postMultipartAsync("/key-stores/" + storeId + "/onchain-sign/output", java.util.Map.of(), body, file, SubmitOnchainSignOutputResponse.class, true); + } + + /** Submit Proof Of Control Output */ + public CompletableFuture submitProofOfControlOutput(String storeId, SubmitProofOfControlOutputRequest body, byte[] file) { + return httpClient.postMultipartAsync("/key-stores/" + storeId + "/proof-of-control/output", java.util.Map.of(), body, file, SubmitProofOfControlOutputResponse.class, true); + } +} diff --git a/src/main/java/co/dfns/sdk/signers/DelegatedSignersClient.java b/src/main/java/co/dfns/sdk/signers/DelegatedSignersClient.java new file mode 100644 index 0000000..f2d5026 --- /dev/null +++ b/src/main/java/co/dfns/sdk/signers/DelegatedSignersClient.java @@ -0,0 +1,105 @@ +package co.dfns.sdk.signers; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.signers.model.*; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedSignersClient { + private final DfnsHttpClient httpClient; + + public DelegatedSignersClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Create Add Mac User Input: returns the challenge to sign out-of-band. */ + public UserActionChallenge createAddMacUserInputInit(String storeId, CreateAddMacUserInputRequest body) { + return httpClient.createUserActionChallenge("POST", "/key-stores/" + storeId + "/add-mac-user/input", body); + } + + /** Delegated signing step 2 for Create Add Mac User Input: submits the signed challenge and issues the request. */ + public Object createAddMacUserInputComplete(String storeId, CreateAddMacUserInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/key-stores/" + storeId + "/add-mac-user/input", java.util.Map.of(), body, Object.class, userAction); + } + + /** Delegated signing step 1 for Create Clone Input: returns the challenge to sign out-of-band. */ + public UserActionChallenge createCloneInputInit(String storeId, CreateCloneInputRequest body) { + return httpClient.createUserActionChallenge("POST", "/key-stores/" + storeId + "/clone/input", body); + } + + /** Delegated signing step 2 for Create Clone Input: submits the signed challenge and issues the request. */ + public Object createCloneInputComplete(String storeId, CreateCloneInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/key-stores/" + storeId + "/clone/input", java.util.Map.of(), body, Object.class, userAction); + } + + /** Delegated signing step 1 for Create Genesis Input: returns the challenge to sign out-of-band. */ + public UserActionChallenge createGenesisInputInit(String storeId, CreateGenesisInputRequest body) { + return httpClient.createUserActionChallenge("POST", "/key-stores/" + storeId + "/genesis/input", body); + } + + /** Delegated signing step 2 for Create Genesis Input: submits the signed challenge and issues the request. */ + public Object createGenesisInputComplete(String storeId, CreateGenesisInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/key-stores/" + storeId + "/genesis/input", java.util.Map.of(), body, Object.class, userAction); + } + + /** Delegated signing step 1 for Create Onchain Sign Input: returns the challenge to sign out-of-band. */ + public UserActionChallenge createOnchainSignInputInit(String storeId, Map body) { + return httpClient.createUserActionChallenge("POST", "/key-stores/" + storeId + "/onchain-sign/input", body); + } + + /** Delegated signing step 2 for Create Onchain Sign Input: submits the signed challenge and issues the request. */ + public Object createOnchainSignInputComplete(String storeId, Map body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/key-stores/" + storeId + "/onchain-sign/input", java.util.Map.of(), body, Object.class, userAction); + } + + /** Delegated signing step 1 for Create Proof Of Control Input: returns the challenge to sign out-of-band. */ + public UserActionChallenge createProofOfControlInputInit(String storeId, CreateProofOfControlInputRequest body) { + return httpClient.createUserActionChallenge("POST", "/key-stores/" + storeId + "/proof-of-control/input", body); + } + + /** Delegated signing step 2 for Create Proof Of Control Input: submits the signed challenge and issues the request. */ + public Object createProofOfControlInputComplete(String storeId, CreateProofOfControlInputRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/key-stores/" + storeId + "/proof-of-control/input", java.util.Map.of(), body, Object.class, userAction); + } + + /** List Key Stores */ + public ListKeyStoresResponse listKeyStores() { + return httpClient.get("/key-stores", java.util.Map.of(), ListKeyStoresResponse.class); + } + + /** List Signers */ + public ListSignersResponse listSigners() { + return httpClient.get("/signers", java.util.Map.of(), ListSignersResponse.class); + } + + /** Submit Add Mac User Output */ + public SubmitAddMacUserOutputResponse submitAddMacUserOutput(String storeId, SubmitAddMacUserOutputRequest body, byte[] file) { + return httpClient.postMultipart("/key-stores/" + storeId + "/add-mac-user/output", java.util.Map.of(), body, file, SubmitAddMacUserOutputResponse.class, true); + } + + /** Submit Clone Output */ + public SubmitCloneOutputResponse submitCloneOutput(String storeId, SubmitCloneOutputRequest body, byte[] file) { + return httpClient.postMultipart("/key-stores/" + storeId + "/clone/output", java.util.Map.of(), body, file, SubmitCloneOutputResponse.class, true); + } + + /** Submit Genesis Output */ + public SubmitGenesisOutputResponse submitGenesisOutput(String storeId, SubmitGenesisOutputRequest body, byte[] file) { + return httpClient.postMultipart("/key-stores/" + storeId + "/genesis/output", java.util.Map.of(), body, file, SubmitGenesisOutputResponse.class, true); + } + + /** Submit Onchain Sign Output */ + public SubmitOnchainSignOutputResponse submitOnchainSignOutput(String storeId, SubmitOnchainSignOutputRequest body, byte[] file) { + return httpClient.postMultipart("/key-stores/" + storeId + "/onchain-sign/output", java.util.Map.of(), body, file, SubmitOnchainSignOutputResponse.class, true); + } + + /** Submit Proof Of Control Output */ + public SubmitProofOfControlOutputResponse submitProofOfControlOutput(String storeId, SubmitProofOfControlOutputRequest body, byte[] file) { + return httpClient.postMultipart("/key-stores/" + storeId + "/proof-of-control/output", java.util.Map.of(), body, file, SubmitProofOfControlOutputResponse.class, true); + } +} diff --git a/src/main/java/co/dfns/sdk/staking/DelegatedStakingAsyncClient.java b/src/main/java/co/dfns/sdk/staking/DelegatedStakingAsyncClient.java new file mode 100644 index 0000000..6a24d0b --- /dev/null +++ b/src/main/java/co/dfns/sdk/staking/DelegatedStakingAsyncClient.java @@ -0,0 +1,60 @@ +package co.dfns.sdk.staking; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.staking.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedStakingAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedStakingAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Stakes */ + public CompletableFuture> listStakes(ListStakesQuery query) { + return httpClient.getAsync("/staking/stakes", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Stake: returns the challenge to sign out-of-band. */ + public CompletableFuture createStakeInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/staking/stakes", body); + } + + /** Delegated signing step 2 for Create Stake: submits the signed challenge and issues the request. */ + public CompletableFuture createStakeComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/staking/stakes", java.util.Map.of(), body, Stake.class, userAction)); + } + + /** List Stake Actions */ + public CompletableFuture> listStakeActions(String stakeId, ListStakeActionsQuery query) { + return httpClient.getAsync("/staking/stakes/" + stakeId + "/actions", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Stake Action: returns the challenge to sign out-of-band. */ + public CompletableFuture createStakeActionInit(String stakeId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/staking/stakes/" + stakeId + "/actions", body); + } + + /** Delegated signing step 2 for Create Stake Action: submits the signed challenge and issues the request. */ + public CompletableFuture createStakeActionComplete(String stakeId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/staking/stakes/" + stakeId + "/actions", java.util.Map.of(), body, Stake.class, userAction)); + } + + /** Get Stakes */ + public CompletableFuture getStakes(String stakeId, GetStakesQuery query) { + return httpClient.getAsync("/staking/stakes/" + stakeId, query.toMap(), Stake.class); + } + + /** Get Stake Rewards */ + public CompletableFuture getStakeRewards(String stakeId) { + return httpClient.getAsync("/staking/stakes/" + stakeId + "/rewards", java.util.Map.of(), GetStakeRewardsResponse.class); + } +} diff --git a/src/main/java/co/dfns/sdk/staking/DelegatedStakingClient.java b/src/main/java/co/dfns/sdk/staking/DelegatedStakingClient.java new file mode 100644 index 0000000..2c76568 --- /dev/null +++ b/src/main/java/co/dfns/sdk/staking/DelegatedStakingClient.java @@ -0,0 +1,59 @@ +package co.dfns.sdk.staking; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.staking.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedStakingClient { + private final DfnsHttpClient httpClient; + + public DelegatedStakingClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Stakes */ + public PaginatedList listStakes(ListStakesQuery query) { + return httpClient.get("/staking/stakes", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Stake: returns the challenge to sign out-of-band. */ + public UserActionChallenge createStakeInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/staking/stakes", body); + } + + /** Delegated signing step 2 for Create Stake: submits the signed challenge and issues the request. */ + public Stake createStakeComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/staking/stakes", java.util.Map.of(), body, Stake.class, userAction); + } + + /** List Stake Actions */ + public PaginatedList listStakeActions(String stakeId, ListStakeActionsQuery query) { + return httpClient.get("/staking/stakes/" + stakeId + "/actions", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Stake Action: returns the challenge to sign out-of-band. */ + public UserActionChallenge createStakeActionInit(String stakeId, Object body) { + return httpClient.createUserActionChallenge("POST", "/staking/stakes/" + stakeId + "/actions", body); + } + + /** Delegated signing step 2 for Create Stake Action: submits the signed challenge and issues the request. */ + public Stake createStakeActionComplete(String stakeId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/staking/stakes/" + stakeId + "/actions", java.util.Map.of(), body, Stake.class, userAction); + } + + /** Get Stakes */ + public Stake getStakes(String stakeId, GetStakesQuery query) { + return httpClient.get("/staking/stakes/" + stakeId, query.toMap(), Stake.class); + } + + /** Get Stake Rewards */ + public GetStakeRewardsResponse getStakeRewards(String stakeId) { + return httpClient.get("/staking/stakes/" + stakeId + "/rewards", java.util.Map.of(), GetStakeRewardsResponse.class); + } +} diff --git a/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsAsyncClient.java b/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsAsyncClient.java new file mode 100644 index 0000000..7a6107a --- /dev/null +++ b/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsAsyncClient.java @@ -0,0 +1,48 @@ +package co.dfns.sdk.swaps; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.swaps.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedSwapsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedSwapsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Swaps */ + public CompletableFuture> listSwaps(ListSwapsQuery query) { + return httpClient.getAsync("/swaps", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Swap: returns the challenge to sign out-of-band. */ + public CompletableFuture createSwapInit(Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/swaps", body); + } + + /** Delegated signing step 2 for Create Swap: submits the signed challenge and issues the request. */ + public CompletableFuture createSwapComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/swaps", java.util.Map.of(), body, Swap.class, userAction)); + } + + /** Request Swap Quote */ + public CompletableFuture requestSwapQuote(Object body) { + return httpClient.postAsync("/swaps/quotes", java.util.Map.of(), body, SwapQuote.class, false); + } + + /** Get Swap */ + public CompletableFuture getSwap(String swapId) { + return httpClient.getAsync("/swaps/" + swapId, java.util.Map.of(), Swap.class); + } + + /** Get Swap Quote */ + public CompletableFuture getSwapQuote(String quoteId) { + return httpClient.getAsync("/swaps/quotes/" + quoteId, java.util.Map.of(), SwapQuote.class); + } +} diff --git a/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsClient.java b/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsClient.java new file mode 100644 index 0000000..f38525c --- /dev/null +++ b/src/main/java/co/dfns/sdk/swaps/DelegatedSwapsClient.java @@ -0,0 +1,47 @@ +package co.dfns.sdk.swaps; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.swaps.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedSwapsClient { + private final DfnsHttpClient httpClient; + + public DelegatedSwapsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Swaps */ + public PaginatedList listSwaps(ListSwapsQuery query) { + return httpClient.get("/swaps", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Swap: returns the challenge to sign out-of-band. */ + public UserActionChallenge createSwapInit(Object body) { + return httpClient.createUserActionChallenge("POST", "/swaps", body); + } + + /** Delegated signing step 2 for Create Swap: submits the signed challenge and issues the request. */ + public Swap createSwapComplete(Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/swaps", java.util.Map.of(), body, Swap.class, userAction); + } + + /** Request Swap Quote */ + public SwapQuote requestSwapQuote(Object body) { + return httpClient.post("/swaps/quotes", java.util.Map.of(), body, SwapQuote.class, false); + } + + /** Get Swap */ + public Swap getSwap(String swapId) { + return httpClient.get("/swaps/" + swapId, java.util.Map.of(), Swap.class); + } + + /** Get Swap Quote */ + public SwapQuote getSwapQuote(String quoteId) { + return httpClient.get("/swaps/quotes/" + quoteId, java.util.Map.of(), SwapQuote.class); + } +} diff --git a/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsAsyncClient.java b/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsAsyncClient.java new file mode 100644 index 0000000..c385067 --- /dev/null +++ b/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsAsyncClient.java @@ -0,0 +1,262 @@ +package co.dfns.sdk.wallets; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.wallets.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedWalletsAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedWalletsAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Abort Transaction: returns the challenge to sign out-of-band. */ + public CompletableFuture abortTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId + "/transactions/" + transactionId + "/abort", null); + } + + /** Delegated signing step 2 for Abort Transaction: submits the signed challenge and issues the request. */ + public CompletableFuture abortTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId + "/transactions/" + transactionId + "/abort", java.util.Map.of(), null, TransactionRequest.class, userAction)); + } + + /** Delegated signing step 1 for Abort Transfer: returns the challenge to sign out-of-band. */ + public CompletableFuture abortTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId + "/transfers/" + transferId + "/abort", null); + } + + /** Delegated signing step 2 for Abort Transfer: submits the signed challenge and issues the request. */ + public CompletableFuture abortTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId + "/transfers/" + transferId + "/abort", java.util.Map.of(), null, TransferRequest.class, userAction)); + } + + /** Delegated signing step 1 for Activate Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture activateWalletInit(String walletId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/activate", body); + } + + /** Delegated signing step 2 for Activate Wallet: submits the signed challenge and issues the request. */ + public CompletableFuture activateWalletComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/activate", java.util.Map.of(), body, TransactionRequest.class, userAction)); + } + + /** List Transactions */ + public CompletableFuture listTransactions(String walletId, ListTransactionsQuery query) { + return httpClient.getAsync("/wallets/" + walletId + "/transactions", query.toMap(), ListTransactionsResponse.class); + } + + /** Delegated signing step 1 for Sign and Broadcast Transaction: returns the challenge to sign out-of-band. */ + public CompletableFuture signAndBroadcastTransactionInit(String walletId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transactions", body); + } + + /** Delegated signing step 2 for Sign and Broadcast Transaction: submits the signed challenge and issues the request. */ + public CompletableFuture signAndBroadcastTransactionComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transactions", java.util.Map.of(), body, TransactionRequest.class, userAction)); + } + + /** Delegated signing step 1 for Cancel Transaction: returns the challenge to sign out-of-band. */ + public CompletableFuture cancelTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/cancel", null); + } + + /** Delegated signing step 2 for Cancel Transaction: submits the signed challenge and issues the request. */ + public CompletableFuture cancelTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/cancel", java.util.Map.of(), null, TransactionRequest.class, userAction)); + } + + /** Delegated signing step 1 for Cancel Transfer: returns the challenge to sign out-of-band. */ + public CompletableFuture cancelTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/cancel", null); + } + + /** Delegated signing step 2 for Cancel Transfer: submits the signed challenge and issues the request. */ + public CompletableFuture cancelTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/cancel", java.util.Map.of(), null, TransactionRequest.class, userAction)); + } + + /** Proxy a request to the Canton Ledger API */ + @SuppressWarnings("unchecked") + public CompletableFuture> proxyARequestToTheCantonLedgerApi(String walletId, ProxyARequestToTheCantonLedgerApiRequest body) { + return httpClient.postAsync("/wallets/" + walletId + "/canton/ledger-api", java.util.Map.of(), body, (Class>) (Class) Map.class, false); + } + + /** Delegated signing step 1 for Speed Up Transaction: returns the challenge to sign out-of-band. */ + public CompletableFuture speedUpTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/speed-up", null); + } + + /** Delegated signing step 2 for Speed Up Transaction: submits the signed challenge and issues the request. */ + public CompletableFuture speedUpTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/speed-up", java.util.Map.of(), null, TransactionRequest.class, userAction)); + } + + /** Delegated signing step 1 for Speed Up Transfer: returns the challenge to sign out-of-band. */ + public CompletableFuture speedUpTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/speed-up", null); + } + + /** Delegated signing step 2 for Speed Up Transfer: submits the signed challenge and issues the request. */ + public CompletableFuture speedUpTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/speed-up", java.util.Map.of(), null, TransactionRequest.class, userAction)); + } + + /** List Wallets */ + public CompletableFuture> listWallets(ListWalletsQuery query) { + return httpClient.getAsync("/wallets", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture createWalletInit(CreateWalletRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets", body); + } + + /** Delegated signing step 2 for Create Wallet: submits the signed challenge and issues the request. */ + public CompletableFuture createWalletComplete(CreateWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets", java.util.Map.of(), body, Wallet.class, userAction)); + } + + /** Get Transaction */ + public CompletableFuture getTransaction(String walletId, String transactionId) { + return httpClient.getAsync("/wallets/" + walletId + "/transactions/" + transactionId, java.util.Map.of(), TransactionRequest.class); + } + + /** Get Transfer */ + public CompletableFuture getTransfer(String walletId, String transferId) { + return httpClient.getAsync("/wallets/" + walletId + "/transfers/" + transferId, java.util.Map.of(), TransferRequest.class); + } + + /** Get Wallet */ + public CompletableFuture getWallet(String walletId) { + return httpClient.getAsync("/wallets/" + walletId, java.util.Map.of(), Wallet.class); + } + + /** Delegated signing step 1 for Update Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture updateWalletInit(String walletId, UpdateWalletRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId, body); + } + + /** Delegated signing step 2 for Update Wallet: submits the signed challenge and issues the request. */ + public CompletableFuture updateWalletComplete(String walletId, UpdateWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId, java.util.Map.of(), body, Wallet.class, userAction)); + } + + /** Get Wallet Assets */ + public CompletableFuture getWalletAssets(String walletId, GetWalletAssetsQuery query) { + return httpClient.getAsync("/wallets/" + walletId + "/assets", query.toMap(), GetWalletAssetsResponse.class); + } + + /** Get Wallet History */ + public CompletableFuture getWalletHistory(String walletId, GetWalletHistoryQuery query) { + return httpClient.getAsync("/wallets/" + walletId + "/history", query.toMap(), GetWalletHistoryResponse.class); + } + + /** Get Wallet Nfts */ + public CompletableFuture getWalletNfts(String walletId) { + return httpClient.getAsync("/wallets/" + walletId + "/nfts", java.util.Map.of(), GetWalletNftsResponse.class); + } + + /** Delegated signing step 1 for Import Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture importWalletInit(ImportWalletRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/import", body); + } + + /** Delegated signing step 2 for Import Wallet: submits the signed challenge and issues the request. */ + public CompletableFuture importWalletComplete(ImportWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/import", java.util.Map.of(), body, Wallet.class, userAction)); + } + + /** List Transfers */ + public CompletableFuture listTransfers(String walletId, ListTransfersQuery query) { + return httpClient.getAsync("/wallets/" + walletId + "/transfers", query.toMap(), ListTransfersResponse.class); + } + + /** Delegated signing step 1 for Transfer Asset: returns the challenge to sign out-of-band. */ + public CompletableFuture transferAssetInit(String walletId, Object body) { + return httpClient.createUserActionChallengeAsync("POST", "/wallets/" + walletId + "/transfers", body); + } + + /** Delegated signing step 2 for Transfer Asset: submits the signed challenge and issues the request. */ + public CompletableFuture transferAssetComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/wallets/" + walletId + "/transfers", java.util.Map.of(), body, TransferRequest.class, userAction)); + } + + /** Delegated signing step 1 for Tag Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture tagWalletInit(String walletId, TagWalletRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId + "/tags", body); + } + + /** Delegated signing step 2 for Tag Wallet: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public CompletableFuture> tagWalletComplete(String walletId, TagWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId + "/tags", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction)); + } + + /** Delegated signing step 1 for Untag Wallet: returns the challenge to sign out-of-band. */ + public CompletableFuture untagWalletInit(String walletId, UntagWalletRequest body) { + return httpClient.createUserActionChallengeAsync("DELETE", "/wallets/" + walletId + "/tags", body); + } + + /** Delegated signing step 2 for Untag Wallet: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public CompletableFuture> untagWalletComplete(String walletId, UntagWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/wallets/" + walletId + "/tags", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction)); + } + + /** Get Offer */ + public CompletableFuture getOffer(String walletId, String offerId) { + return httpClient.getAsync("/wallets/" + walletId + "/offers/" + offerId, java.util.Map.of(), Offer.class); + } + + /** List Offers */ + public CompletableFuture> listOffers(String walletId, ListOffersQuery query) { + return httpClient.getAsync("/wallets/" + walletId + "/offers", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Accept Offer: returns the challenge to sign out-of-band. */ + public CompletableFuture acceptOfferInit(String walletId, String offerId) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/accept", null); + } + + /** Delegated signing step 2 for Accept Offer: submits the signed challenge and issues the request. */ + public CompletableFuture acceptOfferComplete(String walletId, String offerId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/accept", java.util.Map.of(), null, Offer.class, userAction)); + } + + /** Delegated signing step 1 for Reject Offer: returns the challenge to sign out-of-band. */ + public CompletableFuture rejectOfferInit(String walletId, String offerId) { + return httpClient.createUserActionChallengeAsync("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/reject", null); + } + + /** Delegated signing step 2 for Reject Offer: submits the signed challenge and issues the request. */ + public CompletableFuture rejectOfferComplete(String walletId, String offerId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/reject", java.util.Map.of(), null, Offer.class, userAction)); + } + + /** List Org Wallet History */ + public CompletableFuture listOrgWalletHistory(ListOrgWalletHistoryQuery query) { + return httpClient.getAsync("/wallets/all/history", query.toMap(), Object.class); + } +} diff --git a/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsClient.java b/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsClient.java new file mode 100644 index 0000000..2f7de6b --- /dev/null +++ b/src/main/java/co/dfns/sdk/wallets/DelegatedWalletsClient.java @@ -0,0 +1,261 @@ +package co.dfns.sdk.wallets; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.wallets.model.*; +import java.util.Map; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedWalletsClient { + private final DfnsHttpClient httpClient; + + public DelegatedWalletsClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** Delegated signing step 1 for Abort Transaction: returns the challenge to sign out-of-band. */ + public UserActionChallenge abortTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId + "/transactions/" + transactionId + "/abort", null); + } + + /** Delegated signing step 2 for Abort Transaction: submits the signed challenge and issues the request. */ + public TransactionRequest abortTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId + "/transactions/" + transactionId + "/abort", java.util.Map.of(), null, TransactionRequest.class, userAction); + } + + /** Delegated signing step 1 for Abort Transfer: returns the challenge to sign out-of-band. */ + public UserActionChallenge abortTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId + "/transfers/" + transferId + "/abort", null); + } + + /** Delegated signing step 2 for Abort Transfer: submits the signed challenge and issues the request. */ + public TransferRequest abortTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId + "/transfers/" + transferId + "/abort", java.util.Map.of(), null, TransferRequest.class, userAction); + } + + /** Delegated signing step 1 for Activate Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge activateWalletInit(String walletId, Object body) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/activate", body); + } + + /** Delegated signing step 2 for Activate Wallet: submits the signed challenge and issues the request. */ + public TransactionRequest activateWalletComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/activate", java.util.Map.of(), body, TransactionRequest.class, userAction); + } + + /** List Transactions */ + public ListTransactionsResponse listTransactions(String walletId, ListTransactionsQuery query) { + return httpClient.get("/wallets/" + walletId + "/transactions", query.toMap(), ListTransactionsResponse.class); + } + + /** Delegated signing step 1 for Sign and Broadcast Transaction: returns the challenge to sign out-of-band. */ + public UserActionChallenge signAndBroadcastTransactionInit(String walletId, Object body) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transactions", body); + } + + /** Delegated signing step 2 for Sign and Broadcast Transaction: submits the signed challenge and issues the request. */ + public TransactionRequest signAndBroadcastTransactionComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transactions", java.util.Map.of(), body, TransactionRequest.class, userAction); + } + + /** Delegated signing step 1 for Cancel Transaction: returns the challenge to sign out-of-band. */ + public UserActionChallenge cancelTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/cancel", null); + } + + /** Delegated signing step 2 for Cancel Transaction: submits the signed challenge and issues the request. */ + public TransactionRequest cancelTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/cancel", java.util.Map.of(), null, TransactionRequest.class, userAction); + } + + /** Delegated signing step 1 for Cancel Transfer: returns the challenge to sign out-of-band. */ + public UserActionChallenge cancelTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/cancel", null); + } + + /** Delegated signing step 2 for Cancel Transfer: submits the signed challenge and issues the request. */ + public TransactionRequest cancelTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/cancel", java.util.Map.of(), null, TransactionRequest.class, userAction); + } + + /** Proxy a request to the Canton Ledger API */ + @SuppressWarnings("unchecked") + public Map proxyARequestToTheCantonLedgerApi(String walletId, ProxyARequestToTheCantonLedgerApiRequest body) { + return httpClient.post("/wallets/" + walletId + "/canton/ledger-api", java.util.Map.of(), body, (Class>) (Class) Map.class, false); + } + + /** Delegated signing step 1 for Speed Up Transaction: returns the challenge to sign out-of-band. */ + public UserActionChallenge speedUpTransactionInit(String walletId, String transactionId) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/speed-up", null); + } + + /** Delegated signing step 2 for Speed Up Transaction: submits the signed challenge and issues the request. */ + public TransactionRequest speedUpTransactionComplete(String walletId, String transactionId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transactions/" + transactionId + "/speed-up", java.util.Map.of(), null, TransactionRequest.class, userAction); + } + + /** Delegated signing step 1 for Speed Up Transfer: returns the challenge to sign out-of-band. */ + public UserActionChallenge speedUpTransferInit(String walletId, String transferId) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/speed-up", null); + } + + /** Delegated signing step 2 for Speed Up Transfer: submits the signed challenge and issues the request. */ + public TransactionRequest speedUpTransferComplete(String walletId, String transferId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transfers/" + transferId + "/speed-up", java.util.Map.of(), null, TransactionRequest.class, userAction); + } + + /** List Wallets */ + public PaginatedList listWallets(ListWalletsQuery query) { + return httpClient.get("/wallets", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge createWalletInit(CreateWalletRequest body) { + return httpClient.createUserActionChallenge("POST", "/wallets", body); + } + + /** Delegated signing step 2 for Create Wallet: submits the signed challenge and issues the request. */ + public Wallet createWalletComplete(CreateWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets", java.util.Map.of(), body, Wallet.class, userAction); + } + + /** Get Transaction */ + public TransactionRequest getTransaction(String walletId, String transactionId) { + return httpClient.get("/wallets/" + walletId + "/transactions/" + transactionId, java.util.Map.of(), TransactionRequest.class); + } + + /** Get Transfer */ + public TransferRequest getTransfer(String walletId, String transferId) { + return httpClient.get("/wallets/" + walletId + "/transfers/" + transferId, java.util.Map.of(), TransferRequest.class); + } + + /** Get Wallet */ + public Wallet getWallet(String walletId) { + return httpClient.get("/wallets/" + walletId, java.util.Map.of(), Wallet.class); + } + + /** Delegated signing step 1 for Update Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateWalletInit(String walletId, UpdateWalletRequest body) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId, body); + } + + /** Delegated signing step 2 for Update Wallet: submits the signed challenge and issues the request. */ + public Wallet updateWalletComplete(String walletId, UpdateWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId, java.util.Map.of(), body, Wallet.class, userAction); + } + + /** Get Wallet Assets */ + public GetWalletAssetsResponse getWalletAssets(String walletId, GetWalletAssetsQuery query) { + return httpClient.get("/wallets/" + walletId + "/assets", query.toMap(), GetWalletAssetsResponse.class); + } + + /** Get Wallet History */ + public GetWalletHistoryResponse getWalletHistory(String walletId, GetWalletHistoryQuery query) { + return httpClient.get("/wallets/" + walletId + "/history", query.toMap(), GetWalletHistoryResponse.class); + } + + /** Get Wallet Nfts */ + public GetWalletNftsResponse getWalletNfts(String walletId) { + return httpClient.get("/wallets/" + walletId + "/nfts", java.util.Map.of(), GetWalletNftsResponse.class); + } + + /** Delegated signing step 1 for Import Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge importWalletInit(ImportWalletRequest body) { + return httpClient.createUserActionChallenge("POST", "/wallets/import", body); + } + + /** Delegated signing step 2 for Import Wallet: submits the signed challenge and issues the request. */ + public Wallet importWalletComplete(ImportWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/import", java.util.Map.of(), body, Wallet.class, userAction); + } + + /** List Transfers */ + public ListTransfersResponse listTransfers(String walletId, ListTransfersQuery query) { + return httpClient.get("/wallets/" + walletId + "/transfers", query.toMap(), ListTransfersResponse.class); + } + + /** Delegated signing step 1 for Transfer Asset: returns the challenge to sign out-of-band. */ + public UserActionChallenge transferAssetInit(String walletId, Object body) { + return httpClient.createUserActionChallenge("POST", "/wallets/" + walletId + "/transfers", body); + } + + /** Delegated signing step 2 for Transfer Asset: submits the signed challenge and issues the request. */ + public TransferRequest transferAssetComplete(String walletId, Object body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/wallets/" + walletId + "/transfers", java.util.Map.of(), body, TransferRequest.class, userAction); + } + + /** Delegated signing step 1 for Tag Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge tagWalletInit(String walletId, TagWalletRequest body) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId + "/tags", body); + } + + /** Delegated signing step 2 for Tag Wallet: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public Map tagWalletComplete(String walletId, TagWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId + "/tags", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction); + } + + /** Delegated signing step 1 for Untag Wallet: returns the challenge to sign out-of-band. */ + public UserActionChallenge untagWalletInit(String walletId, UntagWalletRequest body) { + return httpClient.createUserActionChallenge("DELETE", "/wallets/" + walletId + "/tags", body); + } + + /** Delegated signing step 2 for Untag Wallet: submits the signed challenge and issues the request. */ + @SuppressWarnings("unchecked") + public Map untagWalletComplete(String walletId, UntagWalletRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/wallets/" + walletId + "/tags", java.util.Map.of(), body, (Class>) (Class) Map.class, userAction); + } + + /** Get Offer */ + public Offer getOffer(String walletId, String offerId) { + return httpClient.get("/wallets/" + walletId + "/offers/" + offerId, java.util.Map.of(), Offer.class); + } + + /** List Offers */ + public PaginatedList listOffers(String walletId, ListOffersQuery query) { + return httpClient.get("/wallets/" + walletId + "/offers", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Accept Offer: returns the challenge to sign out-of-band. */ + public UserActionChallenge acceptOfferInit(String walletId, String offerId) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/accept", null); + } + + /** Delegated signing step 2 for Accept Offer: submits the signed challenge and issues the request. */ + public Offer acceptOfferComplete(String walletId, String offerId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/accept", java.util.Map.of(), null, Offer.class, userAction); + } + + /** Delegated signing step 1 for Reject Offer: returns the challenge to sign out-of-band. */ + public UserActionChallenge rejectOfferInit(String walletId, String offerId) { + return httpClient.createUserActionChallenge("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/reject", null); + } + + /** Delegated signing step 2 for Reject Offer: submits the signed challenge and issues the request. */ + public Offer rejectOfferComplete(String walletId, String offerId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/wallets/" + walletId + "/offers/" + offerId + "/reject", java.util.Map.of(), null, Offer.class, userAction); + } + + /** List Org Wallet History */ + public Object listOrgWalletHistory(ListOrgWalletHistoryQuery query) { + return httpClient.get("/wallets/all/history", query.toMap(), Object.class); + } +} diff --git a/src/main/java/co/dfns/sdk/wallets/model/Network.java b/src/main/java/co/dfns/sdk/wallets/model/Network.java index 62b4148..e33299f 100644 --- a/src/main/java/co/dfns/sdk/wallets/model/Network.java +++ b/src/main/java/co/dfns/sdk/wallets/model/Network.java @@ -84,6 +84,10 @@ public enum Network { PolymeshTestnet("PolymeshTestnet"), Race("Race"), RaceSepolia("RaceSepolia"), + Rayls("Rayls"), + RaylsTestnet("RaylsTestnet"), + Robinhood("Robinhood"), + RobinhoodSepolia("RobinhoodSepolia"), SeiAtlantic2("SeiAtlantic2"), SeiPacific1("SeiPacific1"), Solana("Solana"), diff --git a/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksAsyncClient.java b/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksAsyncClient.java new file mode 100644 index 0000000..7912f4b --- /dev/null +++ b/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksAsyncClient.java @@ -0,0 +1,82 @@ +package co.dfns.sdk.webhooks; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.webhooks.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import java.util.concurrent.CompletableFuture; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedWebhooksAsyncClient { + private final DfnsHttpClient httpClient; + + public DelegatedWebhooksAsyncClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Webhooks */ + public CompletableFuture> listWebhooks(ListWebhooksQuery query) { + return httpClient.getAsync("/webhooks", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Webhook: returns the challenge to sign out-of-band. */ + public CompletableFuture createWebhookInit(CreateWebhookRequest body) { + return httpClient.createUserActionChallengeAsync("POST", "/webhooks", body); + } + + /** Delegated signing step 2 for Create Webhook: submits the signed challenge and issues the request. */ + public CompletableFuture createWebhookComplete(CreateWebhookRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/webhooks", java.util.Map.of(), body, WebhookWithSecret.class, userAction)); + } + + /** Get Webhook */ + public CompletableFuture getWebhook(String webhookId) { + return httpClient.getAsync("/webhooks/" + webhookId, java.util.Map.of(), Webhook.class); + } + + /** Delegated signing step 1 for Update Webhook: returns the challenge to sign out-of-band. */ + public CompletableFuture updateWebhookInit(String webhookId, UpdateWebhookRequest body) { + return httpClient.createUserActionChallengeAsync("PUT", "/webhooks/" + webhookId, body); + } + + /** Delegated signing step 2 for Update Webhook: submits the signed challenge and issues the request. */ + public CompletableFuture updateWebhookComplete(String webhookId, UpdateWebhookRequest body, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("PUT", "/webhooks/" + webhookId, java.util.Map.of(), body, Webhook.class, userAction)); + } + + /** Delegated signing step 1 for Delete Webhook: returns the challenge to sign out-of-band. */ + public CompletableFuture deleteWebhookInit(String webhookId) { + return httpClient.createUserActionChallengeAsync("DELETE", "/webhooks/" + webhookId, null); + } + + /** Delegated signing step 2 for Delete Webhook: submits the signed challenge and issues the request. */ + public CompletableFuture deleteWebhookComplete(String webhookId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("DELETE", "/webhooks/" + webhookId, java.util.Map.of(), null, DeleteWebhookResponse.class, userAction)); + } + + /** Delegated signing step 1 for Ping Webhook: returns the challenge to sign out-of-band. */ + public CompletableFuture pingWebhookInit(String webhookId) { + return httpClient.createUserActionChallengeAsync("POST", "/webhooks/" + webhookId + "/ping", null); + } + + /** Delegated signing step 2 for Ping Webhook: submits the signed challenge and issues the request. */ + public CompletableFuture pingWebhookComplete(String webhookId, String challengeIdentifier, CredentialAssertion assertion) { + return httpClient.completeUserActionSigningAsync(challengeIdentifier, assertion) + .thenCompose(userAction -> httpClient.executeWithUserActionAsync("POST", "/webhooks/" + webhookId + "/ping", java.util.Map.of(), null, PingWebhookResponse.class, userAction)); + } + + /** Get Webhook Event */ + public CompletableFuture getWebhookEvent(String webhookId, String webhookEventId) { + return httpClient.getAsync("/webhooks/" + webhookId + "/events/" + webhookEventId, java.util.Map.of(), WebhookEvent.class); + } + + /** List Webhook Events */ + public CompletableFuture> listWebhookEvents(String webhookId, ListWebhookEventsQuery query) { + return httpClient.getAsync("/webhooks/" + webhookId + "/events", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } +} diff --git a/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksClient.java b/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksClient.java new file mode 100644 index 0000000..7655e02 --- /dev/null +++ b/src/main/java/co/dfns/sdk/webhooks/DelegatedWebhooksClient.java @@ -0,0 +1,81 @@ +package co.dfns.sdk.webhooks; + +import co.dfns.sdk.internal.DfnsHttpClient; +import co.dfns.sdk.webhooks.model.*; +import java.util.List; +import co.dfns.sdk.PaginatedList; +import java.util.Map; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.auth.CredentialAssertion; + +public class DelegatedWebhooksClient { + private final DfnsHttpClient httpClient; + + public DelegatedWebhooksClient(DfnsHttpClient httpClient) { + this.httpClient = httpClient; + } + + /** List Webhooks */ + public PaginatedList listWebhooks(ListWebhooksQuery query) { + return httpClient.get("/webhooks", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } + + /** Delegated signing step 1 for Create Webhook: returns the challenge to sign out-of-band. */ + public UserActionChallenge createWebhookInit(CreateWebhookRequest body) { + return httpClient.createUserActionChallenge("POST", "/webhooks", body); + } + + /** Delegated signing step 2 for Create Webhook: submits the signed challenge and issues the request. */ + public WebhookWithSecret createWebhookComplete(CreateWebhookRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/webhooks", java.util.Map.of(), body, WebhookWithSecret.class, userAction); + } + + /** Get Webhook */ + public Webhook getWebhook(String webhookId) { + return httpClient.get("/webhooks/" + webhookId, java.util.Map.of(), Webhook.class); + } + + /** Delegated signing step 1 for Update Webhook: returns the challenge to sign out-of-band. */ + public UserActionChallenge updateWebhookInit(String webhookId, UpdateWebhookRequest body) { + return httpClient.createUserActionChallenge("PUT", "/webhooks/" + webhookId, body); + } + + /** Delegated signing step 2 for Update Webhook: submits the signed challenge and issues the request. */ + public Webhook updateWebhookComplete(String webhookId, UpdateWebhookRequest body, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("PUT", "/webhooks/" + webhookId, java.util.Map.of(), body, Webhook.class, userAction); + } + + /** Delegated signing step 1 for Delete Webhook: returns the challenge to sign out-of-band. */ + public UserActionChallenge deleteWebhookInit(String webhookId) { + return httpClient.createUserActionChallenge("DELETE", "/webhooks/" + webhookId, null); + } + + /** Delegated signing step 2 for Delete Webhook: submits the signed challenge and issues the request. */ + public DeleteWebhookResponse deleteWebhookComplete(String webhookId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("DELETE", "/webhooks/" + webhookId, java.util.Map.of(), null, DeleteWebhookResponse.class, userAction); + } + + /** Delegated signing step 1 for Ping Webhook: returns the challenge to sign out-of-band. */ + public UserActionChallenge pingWebhookInit(String webhookId) { + return httpClient.createUserActionChallenge("POST", "/webhooks/" + webhookId + "/ping", null); + } + + /** Delegated signing step 2 for Ping Webhook: submits the signed challenge and issues the request. */ + public PingWebhookResponse pingWebhookComplete(String webhookId, String challengeIdentifier, CredentialAssertion assertion) { + String userAction = httpClient.completeUserActionSigning(challengeIdentifier, assertion); + return httpClient.executeWithUserAction("POST", "/webhooks/" + webhookId + "/ping", java.util.Map.of(), null, PingWebhookResponse.class, userAction); + } + + /** Get Webhook Event */ + public WebhookEvent getWebhookEvent(String webhookId, String webhookEventId) { + return httpClient.get("/webhooks/" + webhookId + "/events/" + webhookEventId, java.util.Map.of(), WebhookEvent.class); + } + + /** List Webhook Events */ + public PaginatedList listWebhookEvents(String webhookId, ListWebhookEventsQuery query) { + return httpClient.get("/webhooks/" + webhookId + "/events", query.toMap(), new com.fasterxml.jackson.core.type.TypeReference>() {}); + } +} From d9bc86591456d53d6087cfe567ad050154fae540 Mon Sep 17 00:00:00 2001 From: Jonas Lerebours Date: Wed, 8 Jul 2026 13:29:24 +0200 Subject: [PATCH 2/3] test(internal): cover DfnsHttpClient core request path + delegated signing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add repo-owned JUnit5 tests for the DfnsHttpClient runtime (JDK HttpServer stub, no new deps): - DfnsHttpClientCoreTest: GET/POST client calls (response deserialization, request body, DfnsException on API error) and multipart upload packing (data part with injected fileChecksum + file part). - DfnsHttpClientDelegatedTest: the delegated init/complete signing runtime the Java SDK generator now emits — createUserActionChallenge, completeUserActionSigning, executeWithUserAction — sync and async, incl. full round-trips. Both files are repo-owned (src/test, preserved across syncs); the delegated runtime in DfnsHttpClient.java arrived via this sync from monorepo v1.908.2 (generator PR #3668). gradle test: 9 new tests green (4 core + 5 delegated). Co-Authored-By: Claude Opus 4.8 (1M context) --- .../sdk/internal/DfnsHttpClientCoreTest.java | 124 +++++++++++++ .../internal/DfnsHttpClientDelegatedTest.java | 164 ++++++++++++++++++ 2 files changed, 288 insertions(+) create mode 100644 src/test/java/co/dfns/sdk/internal/DfnsHttpClientCoreTest.java create mode 100644 src/test/java/co/dfns/sdk/internal/DfnsHttpClientDelegatedTest.java diff --git a/src/test/java/co/dfns/sdk/internal/DfnsHttpClientCoreTest.java b/src/test/java/co/dfns/sdk/internal/DfnsHttpClientCoreTest.java new file mode 100644 index 0000000..f479d75 --- /dev/null +++ b/src/test/java/co/dfns/sdk/internal/DfnsHttpClientCoreTest.java @@ -0,0 +1,124 @@ +package co.dfns.sdk.internal; + +import co.dfns.sdk.DfnsClientConfig; +import co.dfns.sdk.DfnsException; +import com.sun.net.httpserver.HttpServer; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Repo-owned tests for the core DfnsHttpClient request path — GET/POST (client call) and + * multipart upload — independent of user-action signing. Uses the JDK's built-in HttpServer + * as a stub API, so there are no external test dependencies. + */ +class DfnsHttpClientCoreTest { + + /** A stub API that records the last request (body, content-type) per path and replies. */ + private static final class StubServer implements AutoCloseable { + final HttpServer server; + final Map lastBody = new ConcurrentHashMap<>(); + final Map lastContentType = new ConcurrentHashMap<>(); + private final int status; + + StubServer(int status, Map responses) throws IOException { + this.status = status; + server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0); + responses.forEach((path, body) -> server.createContext(path, exchange -> { + byte[] req = exchange.getRequestBody().readAllBytes(); + lastBody.put(path, new String(req, StandardCharsets.UTF_8)); + String ct = exchange.getRequestHeaders().getFirst("Content-Type"); + if (ct != null) { + lastContentType.put(path, ct); + } + byte[] resp = body.getBytes(StandardCharsets.UTF_8); + exchange.getResponseHeaders().add("Content-Type", "application/json"); + exchange.sendResponseHeaders(this.status, resp.length); + exchange.getResponseBody().write(resp); + exchange.close(); + })); + server.start(); + } + + String baseUrl() { + return "http://127.0.0.1:" + server.getAddress().getPort(); + } + + @Override + public void close() { + server.stop(0); + } + } + + private DfnsHttpClient clientFor(StubServer s) { + DfnsClientConfig config = DfnsClientConfig.builder() + .baseUrl(s.baseUrl()) + .authToken("test-token") + .build(); + return new DfnsHttpClient(config); + } + + @Test + void getDeserializesResponse() throws Exception { + try (StubServer s = new StubServer(200, Map.of("/wallets/wa-1", "{\"id\":\"wa-1\"}"))) { + @SuppressWarnings("unchecked") + Map result = clientFor(s).get("/wallets/wa-1", Map.of(), Map.class); + assertEquals("wa-1", result.get("id")); + } + } + + @Test + void postSendsBodyAndDeserializesResponse() throws Exception { + try (StubServer s = new StubServer(200, Map.of("/wallets", "{\"id\":\"wa-1\"}"))) { + @SuppressWarnings("unchecked") + Map result = clientFor(s).post( + "/wallets", Map.of(), Map.of("network", "Eth"), Map.class, false); + + assertEquals("wa-1", result.get("id")); + String body = s.lastBody.get("/wallets"); + assertTrue(body.contains("\"network\":\"Eth\""), body); + } + } + + @Test + void apiErrorRaisesDfnsException() throws Exception { + try (StubServer s = new StubServer(400, Map.of("/wallets", "{\"error\":{\"message\":\"bad\"}}"))) { + DfnsHttpClient http = clientFor(s); + assertThrows(DfnsException.class, + () -> http.post("/wallets", Map.of(), Map.of(), Map.class, false)); + } + } + + @Test + void postMultipartPacksDataAndFileParts() throws Exception { + try (StubServer s = new StubServer(200, Map.of("/documents", "{\"id\":\"doc-1\"}"))) { + byte[] file = "hello-file-contents".getBytes(StandardCharsets.UTF_8); + + @SuppressWarnings("unchecked") + Map result = clientFor(s).postMultipart( + "/documents", Map.of(), Map.of("kind", "kyc"), file, Map.class, false); + + assertEquals("doc-1", result.get("id")); + + // The request is multipart/form-data carrying the JSON "data" part (with the + // injected fileChecksum) and the raw file bytes as the "file" part. + assertTrue(s.lastContentType.get("/documents").startsWith("multipart/form-data"), + s.lastContentType.get("/documents")); + String body = s.lastBody.get("/documents"); + assertTrue(body.contains("name=\"data\""), body); + assertTrue(body.contains("name=\"file\""), body); + assertTrue(body.contains("fileChecksum"), body); + assertTrue(body.contains("hello-file-contents"), body); + assertNotNull(body); + } + } +} diff --git a/src/test/java/co/dfns/sdk/internal/DfnsHttpClientDelegatedTest.java b/src/test/java/co/dfns/sdk/internal/DfnsHttpClientDelegatedTest.java new file mode 100644 index 0000000..0c1debd --- /dev/null +++ b/src/test/java/co/dfns/sdk/internal/DfnsHttpClientDelegatedTest.java @@ -0,0 +1,164 @@ +package co.dfns.sdk.internal; + +import co.dfns.sdk.DfnsClientConfig; +import co.dfns.sdk.auth.CredentialAssertion; +import co.dfns.sdk.auth.UserActionChallenge; +import com.sun.net.httpserver.HttpServer; +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.nio.charset.StandardCharsets; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +/** + * Repo-owned tests for the delegated user-action-signing runtime on {@link DfnsHttpClient}: + * createUserActionChallenge, completeUserActionSigning and executeWithUserAction (sync + async). + * These back the generated Delegated*Client classes, letting a challenge be signed out-of-band + * instead of by an in-process Signer. Uses the JDK's built-in HttpServer as a stub API, so there + * are no external test dependencies. + */ +class DfnsHttpClientDelegatedTest { + + /** A stub API that records the last request body / user-action header per path. */ + private static final class StubServer implements AutoCloseable { + final HttpServer server; + final Map lastBody = new ConcurrentHashMap<>(); + final Map lastUserAction = new ConcurrentHashMap<>(); + + StubServer(Map responses) throws IOException { + server = HttpServer.create(new InetSocketAddress("127.0.0.1", 0), 0); + responses.forEach((path, body) -> server.createContext(path, exchange -> { + byte[] req = exchange.getRequestBody().readAllBytes(); + lastBody.put(path, new String(req, StandardCharsets.UTF_8)); + String ua = exchange.getRequestHeaders().getFirst("X-DFNS-USERACTION"); + if (ua != null) { + lastUserAction.put(path, ua); + } + byte[] resp = body.getBytes(StandardCharsets.UTF_8); + exchange.getResponseHeaders().add("Content-Type", "application/json"); + exchange.sendResponseHeaders(200, resp.length); + exchange.getResponseBody().write(resp); + exchange.close(); + })); + server.start(); + } + + String baseUrl() { + return "http://127.0.0.1:" + server.getAddress().getPort(); + } + + @Override + public void close() { + server.stop(0); + } + } + + private DfnsHttpClient clientFor(StubServer s) { + // No Signer configured: the delegated flow signs challenges out-of-band. + DfnsClientConfig config = DfnsClientConfig.builder() + .baseUrl(s.baseUrl()) + .authToken("test-token") + .build(); + return new DfnsHttpClient(config); + } + + private static CredentialAssertion testAssertion() { + return new CredentialAssertion("Key", + new CredentialAssertion.CredentialAssertionData("cred-1", "Y2xpZW50", "c2ln")); + } + + @Test + void createUserActionChallengeReturnsChallengeAndEncodesPayload() throws Exception { + try (StubServer s = new StubServer(Map.of( + "/auth/action/init", "{\"challengeIdentifier\":\"ch-1\",\"challenge\":\"c2ln\"}"))) { + DfnsHttpClient http = clientFor(s); + + UserActionChallenge challenge = http.createUserActionChallenge( + "POST", "/wallets", Map.of("network", "Eth")); + + assertEquals("ch-1", challenge.challengeIdentifier()); + assertEquals("c2ln", challenge.challenge()); + + // The init request carries the method, path and JSON-serialized body to be signed. + String init = s.lastBody.get("/auth/action/init"); + assertTrue(init.contains("\"userActionHttpMethod\":\"POST\""), init); + assertTrue(init.contains("\"userActionHttpPath\":\"/wallets\""), init); + assertTrue(init.contains("\"userActionServerKind\":\"Api\""), init); + assertTrue(init.contains("network"), init); + } + } + + @Test + void completeUserActionSigningReturnsTokenAndSendsAssertion() throws Exception { + try (StubServer s = new StubServer(Map.of( + "/auth/action", "{\"userAction\":\"ua-token\"}"))) { + DfnsHttpClient http = clientFor(s); + + String token = http.completeUserActionSigning("ch-1", testAssertion()); + + assertEquals("ua-token", token); + String body = s.lastBody.get("/auth/action"); + assertTrue(body.contains("\"challengeIdentifier\":\"ch-1\""), body); + assertTrue(body.contains("firstFactor"), body); + } + } + + @Test + void executeWithUserActionAttachesHeaderAndReturnsResponse() throws Exception { + try (StubServer s = new StubServer(Map.of("/wallets", "{\"id\":\"wa-1\"}"))) { + DfnsHttpClient http = clientFor(s); + + @SuppressWarnings("unchecked") + Map result = http.executeWithUserAction( + "POST", "/wallets", Map.of(), Map.of("network", "Eth"), Map.class, "ua-token"); + + assertEquals("wa-1", result.get("id")); + assertEquals("ua-token", s.lastUserAction.get("/wallets")); + } + } + + @Test + void delegatedRoundTripSync() throws Exception { + try (StubServer s = new StubServer(Map.of( + "/auth/action/init", "{\"challengeIdentifier\":\"ch-1\",\"challenge\":\"c2ln\"}", + "/auth/action", "{\"userAction\":\"ua-token\"}", + "/wallets", "{\"id\":\"wa-1\"}"))) { + DfnsHttpClient http = clientFor(s); + + UserActionChallenge ch = http.createUserActionChallenge("POST", "/wallets", Map.of()); + String token = http.completeUserActionSigning(ch.challengeIdentifier(), testAssertion()); + @SuppressWarnings("unchecked") + Map result = http.executeWithUserAction( + "POST", "/wallets", Map.of(), Map.of(), Map.class, token); + + assertEquals("wa-1", result.get("id")); + assertEquals("ua-token", s.lastUserAction.get("/wallets")); + } + } + + @Test + void delegatedRoundTripAsync() throws Exception { + try (StubServer s = new StubServer(Map.of( + "/auth/action/init", "{\"challengeIdentifier\":\"ch-1\",\"challenge\":\"c2ln\"}", + "/auth/action", "{\"userAction\":\"ua-token\"}", + "/wallets", "{\"id\":\"wa-1\"}"))) { + DfnsHttpClient http = clientFor(s); + + UserActionChallenge ch = http.createUserActionChallengeAsync("POST", "/wallets", Map.of()).get(); + String token = http.completeUserActionSigningAsync(ch.challengeIdentifier(), testAssertion()).get(); + assertEquals("ua-token", token); + + @SuppressWarnings("unchecked") + Map result = http.executeWithUserActionAsync( + "POST", "/wallets", Map.of(), Map.of(), Map.class, token).get(); + + assertEquals("wa-1", result.get("id")); + assertEquals("ua-token", s.lastUserAction.get("/wallets")); + } + } +} From 9cf252dde9361f6bd1bdb30ac665faf020157f94 Mon Sep 17 00:00:00 2001 From: Jonas Lerebours Date: Wed, 8 Jul 2026 13:46:18 +0200 Subject: [PATCH 3/3] docs: expand README to document signing, delegated client, and install Rewrite the Java README onto the shared SDK outline (Install, Quick Start, User Action Signing, Delegated Signing, Available Domains, Error Handling, Supported Key Types), matching the Go/Python/TS SDKs. Adds the previously-missing Installation, User Action Signing, Delegated Signing, and Supported Key Types sections; documents DfnsDelegatedClient and the ...Init/...Complete pairs. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 137 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 6fa0915..5e1b32a 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,74 @@ # Dfns Java SDK -Java 17 SDK for the Dfns API. +Welcome, builders. This repo holds the Dfns Java SDK. Useful links: + +- [Dfns Website](https://www.dfns.co) +- [Dfns API Docs](https://docs.dfns.co) + +## Installation + +Requires **Java 17+**. The SDK is built with Gradle and will be published to Maven Central +under group `co.dfns`, artifact `dfns-sdk-java`: + +**Gradle** + +```groovy +implementation("co.dfns:dfns-sdk-java:$version") +``` + +**Maven** + +```xml + + co.dfns + dfns-sdk-java + ${version} + +``` + +> Maven Central publishing is being finalized; until it lands, build the SDK from source. ## Quick Start ```java -import co.dfns.sdk.*; -import co.dfns.sdk.auth.*; +import co.dfns.sdk.DfnsClient; +import co.dfns.sdk.DfnsClientConfig; + +// Create the client (read-only operations) +DfnsClientConfig config = DfnsClientConfig.builder() + .authToken("your-auth-token") + // .baseUrl("https://api.dfns.io") // Optional, this is the default + .build(); -// Create a signer with your credential ID and private key +DfnsClient client = new DfnsClient(config); + +// List wallets +var wallets = client.wallets.listWallets(null); +System.out.println(wallets); +``` + +An async client with the same API but `CompletableFuture` return types is also available: + +```java +import co.dfns.sdk.DfnsAsyncClient; + +DfnsAsyncClient asyncClient = new DfnsAsyncClient(config); +``` + +## User Action Signing + +Some operations (like creating wallets or signing transactions) require user action signing. +Configure a signer to enable these operations: + +```java +import co.dfns.sdk.DfnsClient; +import co.dfns.sdk.DfnsClientConfig; +import co.dfns.sdk.auth.KeySigner; +import co.dfns.sdk.auth.Signer; +import co.dfns.sdk.wallets.model.CreateWalletRequest; +import co.dfns.sdk.wallets.model.Network; + +// Create a signer from your credential ID and private key bytes Signer signer = KeySigner.fromEd25519PrivateKey("cr-xxx-xxx", privateKeyBytes); DfnsClientConfig config = DfnsClientConfig.builder() @@ -17,9 +77,57 @@ DfnsClientConfig config = DfnsClientConfig.builder() .build(); DfnsClient client = new DfnsClient(config); -DfnsAsyncClient asyncClient = new DfnsAsyncClient(config); + +// Operations requiring signatures are signed automatically +var wallet = client.wallets.createWallet(new CreateWalletRequest(Network.EthereumSepolia)); +System.out.println(wallet); +``` + +## Delegated Signing + +In some setups you want your **server** to talk to Dfns on behalf of a user, while the user +keeps signing every request themselves (e.g. with a WebAuthn credential in a web app). The +`DfnsDelegatedClient` supports this: it needs **no `Signer`**, and every operation that needs +a user action signature is split into an `...Init` / `...Complete` pair. + +- `...Init` takes the request payload and returns a `UserActionChallenge` to be signed + out-of-band (typically by the end user in the browser). +- `...Complete` takes the same payload, the challenge identifier, and the signed + `CredentialAssertion`, and performs the request. + +A typical flow: the server calls `...Init` and sends the challenge to the user; the user +signs it with their credential and returns the assertion; the server calls `...Complete`. + +```java +import co.dfns.sdk.DfnsClientConfig; +import co.dfns.sdk.DfnsDelegatedClient; +import co.dfns.sdk.auth.CredentialAssertion; +import co.dfns.sdk.auth.UserActionChallenge; +import co.dfns.sdk.wallets.model.CreateWalletRequest; +import co.dfns.sdk.wallets.model.Network; + +// No signer needed — challenges are signed out-of-band (e.g. by the end user). +DfnsClientConfig config = DfnsClientConfig.builder() + .authToken("user-auth-token") + .build(); + +DfnsDelegatedClient client = new DfnsDelegatedClient(config); + +CreateWalletRequest body = new CreateWalletRequest(Network.EthereumSepolia); + +// Step 1 (server): start the action, get a challenge. +UserActionChallenge challenge = client.wallets.createWalletInit(body); + +// Step 2 (client): the user signs `challenge` with their credential and returns the +// signed assertion (a CredentialAssertion) to the server. +CredentialAssertion assertion = signChallengeOutOfBand(challenge); + +// Step 3 (server): complete the action with the signed challenge. +var wallet = client.wallets.createWalletComplete(body, challenge.challengeIdentifier(), assertion); ``` +A `DfnsDelegatedAsyncClient` with `CompletableFuture` return types is also available. + ## Available Domains - `client.agreements` — AgreementsClient @@ -38,12 +146,35 @@ DfnsAsyncClient asyncClient = new DfnsAsyncClient(config); - `client.wallets` — WalletsClient - `client.webhooks` — WebhooksClient +Each domain provides typed methods for all available API endpoints. The same domains are +exposed (as `Delegated*Client`) on `DfnsDelegatedClient`. + ## Error Handling ```java +import co.dfns.sdk.DfnsException; + try { - var result = client.wallets.listWallets(); + var result = client.wallets.listWallets(null); } catch (DfnsException e) { System.err.println("HTTP status: " + e.getHttpStatus()); + System.err.println("Dfns error code: " + e.getDfnsErrorCode()); + System.err.println("Message: " + e.getErrorMessage()); } ``` + +## Supported Key Types + +The `KeySigner` supports the following private key types, each via a factory method that +takes the credential ID and the private key bytes: + +| Factory method | Key type | +|---|---| +| `KeySigner.fromEd25519PrivateKey` | Ed25519 (EdDSA) | +| `KeySigner.fromEcdsaP256PrivateKey` | ECDSA (P-256) | +| `KeySigner.fromSecp256k1PrivateKey` | ECDSA (secp256k1) | +| `KeySigner.fromRsaPrivateKey` | RSA (PKCS#1 v1.5, SHA-256) | + +## License + +MIT License - See LICENSE file for details.