@dfns/sdk 0.2.3-rc.1 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/baseAuthApi.d.ts +113 -0
- package/baseAuthApi.js +97 -0
- package/codegen/Assets/AssetsClient.d.ts +13 -0
- package/codegen/Assets/AssetsClient.js +93 -0
- package/codegen/Assets/DelegatedAssetsClient.d.ts +16 -0
- package/codegen/Assets/DelegatedAssetsClient.js +124 -0
- package/codegen/Assets/index.d.ts +3 -0
- package/codegen/Assets/index.js +19 -0
- package/codegen/Assets/types.d.ts +37 -0
- package/codegen/Assets/types.js +2 -0
- package/codegen/Auth/AuthClient.d.ts +50 -0
- package/codegen/Auth/AuthClient.js +518 -0
- package/codegen/Auth/DelegatedAuthClient.d.ts +78 -0
- package/codegen/Auth/DelegatedAuthClient.js +936 -0
- package/codegen/Auth/index.d.ts +3 -0
- package/codegen/Auth/index.js +19 -0
- package/codegen/Auth/types.d.ts +177 -0
- package/codegen/Auth/types.js +2 -0
- package/codegen/Blockchains/BlockchainsClient.d.ts +7 -0
- package/codegen/Blockchains/BlockchainsClient.js +23 -0
- package/codegen/Blockchains/DelegatedBlockchainsClient.d.ts +7 -0
- package/codegen/Blockchains/DelegatedBlockchainsClient.js +23 -0
- package/codegen/Blockchains/index.d.ts +3 -0
- package/codegen/Blockchains/index.js +19 -0
- package/codegen/Blockchains/types.d.ts +6 -0
- package/codegen/Blockchains/types.js +2 -0
- package/codegen/Callbacks/CallbacksClient.d.ts +12 -0
- package/codegen/Callbacks/CallbacksClient.js +78 -0
- package/codegen/Callbacks/DelegatedCallbacksClient.d.ts +15 -0
- package/codegen/Callbacks/DelegatedCallbacksClient.js +110 -0
- package/codegen/Callbacks/index.d.ts +3 -0
- package/codegen/Callbacks/index.js +19 -0
- package/codegen/Callbacks/{types.ts → types.d.ts} +18 -26
- package/codegen/Callbacks/types.js +2 -0
- package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.d.ts +11 -0
- package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.js +61 -0
- package/codegen/PolicyExecution/PolicyExecutionClient.d.ts +9 -0
- package/codegen/PolicyExecution/PolicyExecutionClient.js +45 -0
- package/codegen/PolicyExecution/index.d.ts +3 -0
- package/codegen/PolicyExecution/index.js +19 -0
- package/codegen/PolicyExecution/types.d.ts +18 -0
- package/codegen/PolicyExecution/types.js +2 -0
- package/codegen/PolicyManagement/DelegatedPolicyManagementClient.d.ts +25 -0
- package/codegen/PolicyManagement/DelegatedPolicyManagementClient.js +240 -0
- package/codegen/PolicyManagement/PolicyManagementClient.d.ts +18 -0
- package/codegen/PolicyManagement/PolicyManagementClient.js +146 -0
- package/codegen/PolicyManagement/index.d.ts +3 -0
- package/codegen/PolicyManagement/index.js +19 -0
- package/codegen/PolicyManagement/{types.ts → types.d.ts} +40 -56
- package/codegen/PolicyManagement/types.js +2 -0
- package/codegen/PublicKeys/DelegatedPublicKeysClient.d.ts +21 -0
- package/codegen/PublicKeys/DelegatedPublicKeysClient.js +189 -0
- package/codegen/PublicKeys/PublicKeysClient.d.ts +16 -0
- package/codegen/PublicKeys/PublicKeysClient.js +128 -0
- package/codegen/PublicKeys/index.d.ts +3 -0
- package/codegen/PublicKeys/index.js +19 -0
- package/codegen/PublicKeys/types.d.ts +51 -0
- package/codegen/PublicKeys/types.js +2 -0
- package/codegen/Signers/DelegatedSignersClient.d.ts +7 -0
- package/codegen/Signers/DelegatedSignersClient.js +22 -0
- package/codegen/Signers/SignersClient.d.ts +7 -0
- package/codegen/Signers/SignersClient.js +22 -0
- package/codegen/Signers/index.d.ts +3 -0
- package/codegen/Signers/index.js +19 -0
- package/codegen/Signers/types.d.ts +2 -0
- package/codegen/Signers/types.js +2 -0
- package/codegen/Wallets/DelegatedWalletsClient.d.ts +32 -0
- package/codegen/Wallets/DelegatedWalletsClient.js +325 -0
- package/codegen/Wallets/WalletsClient.d.ts +24 -0
- package/codegen/Wallets/WalletsClient.js +219 -0
- package/codegen/Wallets/index.d.ts +3 -0
- package/codegen/Wallets/index.js +19 -0
- package/codegen/Wallets/types.d.ts +101 -0
- package/codegen/Wallets/types.js +2 -0
- package/codegen/datamodel/ApiKeys/errors.d.ts +6 -0
- package/codegen/datamodel/ApiKeys/errors.js +15 -0
- package/codegen/datamodel/ApiKeys/index.d.ts +3 -0
- package/codegen/datamodel/ApiKeys/index.js +19 -0
- package/codegen/datamodel/ApiKeys/responses.d.ts +25 -0
- package/codegen/datamodel/ApiKeys/responses.js +2 -0
- package/codegen/datamodel/ApiKeys/types.d.ts +32 -0
- package/codegen/datamodel/ApiKeys/types.js +11 -0
- package/codegen/datamodel/Assets/errors.d.ts +11 -0
- package/codegen/datamodel/Assets/errors.js +17 -0
- package/codegen/datamodel/Assets/index.d.ts +3 -0
- package/codegen/datamodel/Assets/index.js +19 -0
- package/codegen/datamodel/Assets/responses.d.ts +47 -0
- package/codegen/datamodel/Assets/responses.js +2 -0
- package/codegen/datamodel/Assets/types.d.ts +225 -0
- package/codegen/datamodel/Assets/types.js +75 -0
- package/codegen/datamodel/Auth/errors.js +1 -0
- package/codegen/datamodel/Auth/index.d.ts +2 -0
- package/codegen/datamodel/Auth/index.js +18 -0
- package/codegen/datamodel/Auth/responses.d.ts +358 -0
- package/codegen/datamodel/Auth/responses.js +2 -0
- package/codegen/datamodel/Auth/types.d.ts +615 -0
- package/codegen/datamodel/Auth/types.js +127 -0
- package/codegen/datamodel/BlockchainIndexing/errors.js +1 -0
- package/codegen/datamodel/BlockchainIndexing/index.d.ts +1 -0
- package/codegen/datamodel/BlockchainIndexing/index.js +17 -0
- package/codegen/datamodel/BlockchainIndexing/{responses.ts → responses.d.ts} +5 -10
- package/codegen/datamodel/BlockchainIndexing/responses.js +2 -0
- package/codegen/datamodel/BlockchainIndexing/types.js +1 -0
- package/codegen/datamodel/Blockchains/errors.js +1 -0
- package/codegen/datamodel/Blockchains/index.d.ts +2 -0
- package/codegen/datamodel/Blockchains/index.js +18 -0
- package/codegen/datamodel/Blockchains/responses.d.ts +12 -0
- package/codegen/datamodel/Blockchains/responses.js +2 -0
- package/codegen/datamodel/Blockchains/types.d.ts +270 -0
- package/codegen/datamodel/Blockchains/types.js +53 -0
- package/codegen/datamodel/Callbacks/errors.js +1 -0
- package/codegen/datamodel/Callbacks/index.d.ts +2 -0
- package/codegen/datamodel/Callbacks/index.js +18 -0
- package/codegen/datamodel/Callbacks/responses.d.ts +36 -0
- package/codegen/datamodel/Callbacks/responses.js +2 -0
- package/codegen/datamodel/Callbacks/types.d.ts +43 -0
- package/codegen/datamodel/Callbacks/types.js +39 -0
- package/codegen/datamodel/Foundations/errors.d.ts +131 -0
- package/codegen/datamodel/Foundations/errors.js +182 -0
- package/codegen/datamodel/Foundations/index.d.ts +2 -0
- package/codegen/datamodel/Foundations/index.js +18 -0
- package/codegen/datamodel/Foundations/responses.js +1 -0
- package/codegen/datamodel/Foundations/types.d.ts +9759 -0
- package/codegen/datamodel/Foundations/types.js +57755 -0
- package/codegen/datamodel/Orgs/errors.js +1 -0
- package/codegen/datamodel/Orgs/index.d.ts +2 -0
- package/codegen/datamodel/Orgs/index.js +18 -0
- package/codegen/datamodel/Orgs/responses.d.ts +45 -0
- package/codegen/datamodel/Orgs/responses.js +2 -0
- package/codegen/datamodel/Orgs/types.d.ts +240 -0
- package/codegen/datamodel/Orgs/types.js +39 -0
- package/codegen/datamodel/Permissions/errors.js +1 -0
- package/codegen/datamodel/Permissions/index.d.ts +2 -0
- package/codegen/datamodel/Permissions/index.js +18 -0
- package/codegen/datamodel/Permissions/responses.d.ts +75 -0
- package/codegen/datamodel/Permissions/responses.js +2 -0
- package/codegen/datamodel/Permissions/types.d.ts +93 -0
- package/codegen/datamodel/Permissions/types.js +43 -0
- package/codegen/datamodel/PolicyExecution/errors.d.ts +11 -0
- package/codegen/datamodel/PolicyExecution/errors.js +17 -0
- package/codegen/datamodel/PolicyExecution/index.d.ts +3 -0
- package/codegen/datamodel/PolicyExecution/index.js +19 -0
- package/codegen/datamodel/PolicyExecution/responses.d.ts +19 -0
- package/codegen/datamodel/PolicyExecution/responses.js +2 -0
- package/codegen/datamodel/PolicyExecution/types.d.ts +60 -0
- package/codegen/datamodel/PolicyExecution/types.js +17 -0
- package/codegen/datamodel/PolicyManagement/errors.js +1 -0
- package/codegen/datamodel/PolicyManagement/index.d.ts +2 -0
- package/codegen/datamodel/PolicyManagement/index.js +18 -0
- package/codegen/datamodel/PolicyManagement/responses.d.ts +83 -0
- package/codegen/datamodel/PolicyManagement/responses.js +2 -0
- package/codegen/datamodel/PolicyManagement/types.d.ts +391 -0
- package/codegen/datamodel/PolicyManagement/types.js +95 -0
- package/codegen/datamodel/PublicKeys/errors.js +1 -0
- package/codegen/datamodel/PublicKeys/index.d.ts +2 -0
- package/codegen/datamodel/PublicKeys/index.js +18 -0
- package/codegen/datamodel/PublicKeys/responses.d.ts +56 -0
- package/codegen/datamodel/PublicKeys/responses.js +2 -0
- package/codegen/datamodel/PublicKeys/types.d.ts +223 -0
- package/codegen/datamodel/PublicKeys/types.js +59 -0
- package/codegen/datamodel/Signers/errors.js +1 -0
- package/codegen/datamodel/Signers/index.d.ts +2 -0
- package/codegen/datamodel/Signers/index.js +18 -0
- package/codegen/datamodel/Signers/responses.d.ts +27 -0
- package/codegen/datamodel/Signers/responses.js +2 -0
- package/codegen/datamodel/Signers/types.d.ts +21 -0
- package/codegen/datamodel/Signers/types.js +2 -0
- package/codegen/datamodel/Wallets/errors.js +1 -0
- package/codegen/datamodel/Wallets/index.d.ts +2 -0
- package/codegen/datamodel/Wallets/index.js +18 -0
- package/codegen/datamodel/Wallets/responses.d.ts +92 -0
- package/codegen/datamodel/Wallets/responses.js +2 -0
- package/codegen/datamodel/Wallets/types.d.ts +677 -0
- package/codegen/datamodel/Wallets/types.js +251 -0
- package/dfnsApiClient.d.ts +39 -0
- package/dfnsApiClient.js +63 -0
- package/dfnsAuthenticator.d.ts +17 -0
- package/dfnsAuthenticator.js +29 -0
- package/dfnsDelegatedApiClient.d.ts +38 -0
- package/dfnsDelegatedApiClient.js +63 -0
- package/dfnsError.d.ts +5 -0
- package/dfnsError.js +11 -0
- package/generated/permissions/client.d.ts +14 -0
- package/generated/permissions/client.js +104 -0
- package/generated/permissions/delegatedClient.d.ts +20 -0
- package/generated/permissions/delegatedClient.js +180 -0
- package/generated/permissions/index.d.ts +3 -0
- package/generated/permissions/index.js +19 -0
- package/generated/permissions/types.d.ts +225 -0
- package/generated/permissions/types.js +2 -0
- package/generated/policies/client.d.ts +13 -0
- package/generated/policies/client.js +92 -0
- package/generated/policies/delegatedClient.d.ts +18 -0
- package/generated/policies/delegatedClient.js +153 -0
- package/generated/policies/index.d.ts +3 -0
- package/generated/policies/index.js +19 -0
- package/generated/policies/{types.ts → types.d.ts} +409 -39
- package/generated/policies/types.js +2 -0
- package/generated/signers/client.d.ts +7 -0
- package/generated/signers/client.js +22 -0
- package/generated/signers/delegatedClient.d.ts +7 -0
- package/generated/signers/delegatedClient.js +22 -0
- package/generated/signers/index.d.ts +3 -0
- package/generated/signers/index.js +19 -0
- package/generated/signers/{types.ts → types.d.ts} +0 -1
- package/generated/signers/types.js +2 -0
- package/generated/wallets/client.d.ts +25 -0
- package/generated/wallets/client.js +228 -0
- package/generated/wallets/delegatedClient.d.ts +34 -0
- package/generated/wallets/delegatedClient.js +349 -0
- package/generated/wallets/index.d.ts +3 -0
- package/generated/wallets/index.js +19 -0
- package/generated/wallets/{types.ts → types.d.ts} +68 -109
- package/generated/wallets/types.js +2 -0
- package/generated/webhooks/client.d.ts +14 -0
- package/generated/webhooks/client.js +103 -0
- package/generated/webhooks/delegatedClient.d.ts +19 -0
- package/generated/webhooks/delegatedClient.js +164 -0
- package/generated/webhooks/index.d.ts +3 -0
- package/generated/webhooks/index.js +19 -0
- package/generated/webhooks/{types.ts → types.d.ts} +16 -34
- package/generated/webhooks/types.js +2 -0
- package/index.d.ts +7 -0
- package/index.js +23 -0
- package/package.json +8 -1
- package/signer.d.ts +52 -0
- package/signer.js +2 -0
- package/store.d.ts +79 -0
- package/store.js +2 -0
- package/types/policies.d.ts +1 -0
- package/types/policies.js +17 -0
- package/types/signers.d.ts +1 -0
- package/types/signers.js +17 -0
- package/types/wallets.d.ts +1 -0
- package/types/wallets.js +17 -0
- package/types/webhooks.d.ts +1 -0
- package/types/webhooks.js +17 -0
- package/utils/base64.d.ts +3 -0
- package/utils/base64.js +20 -0
- package/utils/fetch.d.ts +12 -0
- package/utils/fetch.js +94 -0
- package/utils/index.d.ts +4 -0
- package/utils/index.js +20 -0
- package/utils/nonce.d.ts +1 -0
- package/utils/nonce.js +12 -0
- package/utils/url.d.ts +4 -0
- package/utils/url.js +16 -0
- package/baseAuthApi.ts +0 -236
- package/codegen/Assets/AssetsClient.ts +0 -137
- package/codegen/Assets/DelegatedAssetsClient.ts +0 -201
- package/codegen/Assets/index.ts +0 -3
- package/codegen/Assets/types.ts +0 -45
- package/codegen/Auth/AuthClient.ts +0 -729
- package/codegen/Auth/DelegatedAuthClient.ts +0 -1508
- package/codegen/Auth/index.ts +0 -3
- package/codegen/Auth/types.ts +0 -262
- package/codegen/Blockchains/BlockchainsClient.ts +0 -25
- package/codegen/Blockchains/DelegatedBlockchainsClient.ts +0 -25
- package/codegen/Blockchains/index.ts +0 -3
- package/codegen/Blockchains/types.ts +0 -8
- package/codegen/Callbacks/CallbacksClient.ts +0 -107
- package/codegen/Callbacks/DelegatedCallbacksClient.ts +0 -172
- package/codegen/Callbacks/index.ts +0 -3
- package/codegen/Permissions/DelegatedPermissionsClient.ts +0 -468
- package/codegen/Permissions/PermissionsClient.ts +0 -223
- package/codegen/Permissions/index.ts +0 -3
- package/codegen/Permissions/types.ts +0 -82
- package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.ts +0 -99
- package/codegen/PolicyExecution/PolicyExecutionClient.ts +0 -63
- package/codegen/PolicyExecution/index.ts +0 -3
- package/codegen/PolicyExecution/types.ts +0 -24
- package/codegen/PolicyManagement/DelegatedPolicyManagementClient.ts +0 -384
- package/codegen/PolicyManagement/PolicyManagementClient.ts +0 -205
- package/codegen/PolicyManagement/index.ts +0 -3
- package/codegen/PublicKeys/DelegatedPublicKeysClient.ts +0 -299
- package/codegen/PublicKeys/PublicKeysClient.ts +0 -179
- package/codegen/PublicKeys/index.ts +0 -3
- package/codegen/PublicKeys/types.ts +0 -68
- package/codegen/Signers/DelegatedSignersClient.ts +0 -22
- package/codegen/Signers/SignersClient.ts +0 -22
- package/codegen/Signers/index.ts +0 -3
- package/codegen/Signers/types.ts +0 -3
- package/codegen/Wallets/DelegatedWalletsClient.ts +0 -511
- package/codegen/Wallets/WalletsClient.ts +0 -310
- package/codegen/Wallets/index.ts +0 -3
- package/codegen/Wallets/types.ts +0 -137
- package/codegen/datamodel/ApiKeys/errors.ts +0 -9
- package/codegen/datamodel/ApiKeys/index.ts +0 -3
- package/codegen/datamodel/ApiKeys/responses.ts +0 -68
- package/codegen/datamodel/ApiKeys/types.ts +0 -81
- package/codegen/datamodel/Assets/errors.ts +0 -24
- package/codegen/datamodel/Assets/index.ts +0 -3
- package/codegen/datamodel/Assets/responses.ts +0 -146
- package/codegen/datamodel/Assets/types.ts +0 -417
- package/codegen/datamodel/Auth/index.ts +0 -2
- package/codegen/datamodel/Auth/responses.ts +0 -1110
- package/codegen/datamodel/Auth/types.ts +0 -1404
- package/codegen/datamodel/BlockchainIndexing/index.ts +0 -1
- package/codegen/datamodel/Blockchains/index.ts +0 -2
- package/codegen/datamodel/Blockchains/responses.ts +0 -41
- package/codegen/datamodel/Blockchains/types.ts +0 -695
- package/codegen/datamodel/Callbacks/index.ts +0 -2
- package/codegen/datamodel/Callbacks/responses.ts +0 -110
- package/codegen/datamodel/Callbacks/types.ts +0 -100
- package/codegen/datamodel/Foundations/errors.ts +0 -299
- package/codegen/datamodel/Foundations/index.ts +0 -2
- package/codegen/datamodel/Foundations/types.ts +0 -57921
- package/codegen/datamodel/Orgs/index.ts +0 -2
- package/codegen/datamodel/Orgs/responses.ts +0 -104
- package/codegen/datamodel/Orgs/types.ts +0 -322
- package/codegen/datamodel/Permissions/index.ts +0 -2
- package/codegen/datamodel/Permissions/responses.ts +0 -258
- package/codegen/datamodel/Permissions/types.ts +0 -221
- package/codegen/datamodel/PolicyExecution/errors.ts +0 -24
- package/codegen/datamodel/PolicyExecution/index.ts +0 -3
- package/codegen/datamodel/PolicyExecution/responses.ts +0 -59
- package/codegen/datamodel/PolicyExecution/types.ts +0 -122
- package/codegen/datamodel/PolicyManagement/index.ts +0 -2
- package/codegen/datamodel/PolicyManagement/responses.ts +0 -255
- package/codegen/datamodel/PolicyManagement/types.ts +0 -711
- package/codegen/datamodel/PublicKeys/index.ts +0 -2
- package/codegen/datamodel/PublicKeys/responses.ts +0 -190
- package/codegen/datamodel/PublicKeys/types.ts +0 -558
- package/codegen/datamodel/Signers/index.ts +0 -2
- package/codegen/datamodel/Signers/responses.ts +0 -64
- package/codegen/datamodel/Signers/types.ts +0 -31
- package/codegen/datamodel/Wallets/errors.ts +0 -0
- package/codegen/datamodel/Wallets/index.ts +0 -2
- package/codegen/datamodel/Wallets/responses.ts +0 -318
- package/codegen/datamodel/Wallets/types.ts +0 -1268
- package/dfnsApiClient.ts +0 -76
- package/dfnsAuthenticator.ts +0 -59
- package/dfnsDelegatedApiClient.ts +0 -75
- package/dfnsError.ts +0 -5
- package/generated/permissions/client.ts +0 -125
- package/generated/permissions/delegatedClient.ts +0 -266
- package/generated/permissions/index.ts +0 -3
- package/generated/permissions/types.ts +0 -202
- package/generated/policies/client.ts +0 -110
- package/generated/policies/delegatedClient.ts +0 -223
- package/generated/policies/index.ts +0 -3
- package/generated/signers/client.ts +0 -22
- package/generated/signers/delegatedClient.ts +0 -23
- package/generated/signers/index.ts +0 -3
- package/generated/wallets/client.ts +0 -282
- package/generated/wallets/delegatedClient.ts +0 -507
- package/generated/wallets/index.ts +0 -3
- package/generated/webhooks/client.ts +0 -124
- package/generated/webhooks/delegatedClient.ts +0 -237
- package/generated/webhooks/index.ts +0 -3
- package/index.ts +0 -7
- package/project.json +0 -14
- package/signer.ts +0 -60
- package/store.ts +0 -99
- package/tsconfig.json +0 -7
- package/typedoc.json +0 -21
- package/types/policies.ts +0 -1
- package/types/signers.ts +0 -1
- package/types/wallets.ts +0 -1
- package/types/webhooks.ts +0 -1
- package/utils/base64.ts +0 -19
- package/utils/fetch.ts +0 -130
- package/utils/index.ts +0 -4
- package/utils/nonce.ts +0 -12
- package/utils/url.ts +0 -19
- /package/{README.md → codegen/datamodel/Auth/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Auth/errors.ts → BlockchainIndexing/errors.d.ts} +0 -0
- /package/codegen/datamodel/BlockchainIndexing/{errors.ts → types.d.ts} +0 -0
- /package/codegen/datamodel/{BlockchainIndexing/types.ts → Blockchains/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Blockchains/errors.ts → Callbacks/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Callbacks/errors.ts → Foundations/responses.d.ts} +0 -0
- /package/codegen/datamodel/{Foundations/responses.ts → Orgs/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Orgs/errors.ts → Permissions/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Permissions/errors.ts → PolicyManagement/errors.d.ts} +0 -0
- /package/codegen/datamodel/{PolicyManagement/errors.ts → PublicKeys/errors.d.ts} +0 -0
- /package/codegen/datamodel/{PublicKeys/errors.ts → Signers/errors.d.ts} +0 -0
- /package/codegen/datamodel/{Signers/errors.ts → Wallets/errors.d.ts} +0 -0
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { BaseAuthApi, SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi'
|
|
2
|
-
import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient'
|
|
3
|
-
import { simpleFetch } from '../../utils/fetch'
|
|
4
|
-
import { buildPathAndQuery } from '../../utils/url'
|
|
5
|
-
import * as T from './types'
|
|
6
|
-
|
|
7
|
-
export class DelegatedWebhooksClient {
|
|
8
|
-
constructor(private apiOptions: DfnsDelegatedApiClientOptions) {}
|
|
9
|
-
|
|
10
|
-
async createWebhookInit(request: T.CreateWebhookRequest): Promise<UserActionChallengeResponse> {
|
|
11
|
-
const path = buildPathAndQuery('/webhooks', {
|
|
12
|
-
path: request ?? {},
|
|
13
|
-
query: {},
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
const challenge = await BaseAuthApi.createUserActionChallenge(
|
|
17
|
-
{
|
|
18
|
-
userActionHttpMethod: 'POST',
|
|
19
|
-
userActionHttpPath: path,
|
|
20
|
-
userActionPayload: JSON.stringify(request.body),
|
|
21
|
-
userActionServerKind: 'Api',
|
|
22
|
-
},
|
|
23
|
-
this.apiOptions
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
return challenge
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
async createWebhookComplete(
|
|
30
|
-
request: T.CreateWebhookRequest,
|
|
31
|
-
signedChallenge: SignUserActionChallengeRequest
|
|
32
|
-
): Promise<T.CreateWebhookResponse> {
|
|
33
|
-
const path = buildPathAndQuery('/webhooks', {
|
|
34
|
-
path: request ?? {},
|
|
35
|
-
query: {},
|
|
36
|
-
})
|
|
37
|
-
|
|
38
|
-
const { userAction } = await BaseAuthApi.signUserActionChallenge(
|
|
39
|
-
signedChallenge,
|
|
40
|
-
this.apiOptions
|
|
41
|
-
)
|
|
42
|
-
|
|
43
|
-
const response = await simpleFetch(path, {
|
|
44
|
-
method: 'POST',
|
|
45
|
-
body: request.body,
|
|
46
|
-
headers: { 'x-dfns-useraction': userAction },
|
|
47
|
-
apiOptions: this.apiOptions,
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
return response.json()
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
async deleteWebhookInit(request: T.DeleteWebhookRequest): Promise<UserActionChallengeResponse> {
|
|
54
|
-
const path = buildPathAndQuery('/webhooks/:webhookId', {
|
|
55
|
-
path: request ?? {},
|
|
56
|
-
query: {},
|
|
57
|
-
})
|
|
58
|
-
|
|
59
|
-
const challenge = await BaseAuthApi.createUserActionChallenge(
|
|
60
|
-
{
|
|
61
|
-
userActionHttpMethod: 'DELETE',
|
|
62
|
-
userActionHttpPath: path,
|
|
63
|
-
userActionPayload: JSON.stringify({}),
|
|
64
|
-
userActionServerKind: 'Api',
|
|
65
|
-
},
|
|
66
|
-
this.apiOptions
|
|
67
|
-
)
|
|
68
|
-
|
|
69
|
-
return challenge
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async deleteWebhookComplete(
|
|
73
|
-
request: T.DeleteWebhookRequest,
|
|
74
|
-
signedChallenge: SignUserActionChallengeRequest
|
|
75
|
-
): Promise<T.DeleteWebhookResponse> {
|
|
76
|
-
const path = buildPathAndQuery('/webhooks/:webhookId', {
|
|
77
|
-
path: request ?? {},
|
|
78
|
-
query: {},
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
const { userAction } = await BaseAuthApi.signUserActionChallenge(
|
|
82
|
-
signedChallenge,
|
|
83
|
-
this.apiOptions
|
|
84
|
-
)
|
|
85
|
-
|
|
86
|
-
const response = await simpleFetch(path, {
|
|
87
|
-
method: 'DELETE',
|
|
88
|
-
body: {},
|
|
89
|
-
headers: { 'x-dfns-useraction': userAction },
|
|
90
|
-
apiOptions: this.apiOptions,
|
|
91
|
-
})
|
|
92
|
-
|
|
93
|
-
return response.json()
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
async getWebhook(request: T.GetWebhookRequest): Promise<T.GetWebhookResponse> {
|
|
97
|
-
const path = buildPathAndQuery('/webhooks/:webhookId', {
|
|
98
|
-
path: request ?? {},
|
|
99
|
-
query: {},
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
const response = await simpleFetch(path, {
|
|
103
|
-
method: 'GET',
|
|
104
|
-
apiOptions: this.apiOptions,
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
return response.json()
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
async getWebhookEvent(request: T.GetWebhookEventRequest): Promise<T.GetWebhookEventResponse> {
|
|
111
|
-
const path = buildPathAndQuery('/webhooks/:webhookId/events/:webhookEventId', {
|
|
112
|
-
path: request ?? {},
|
|
113
|
-
query: {},
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
const response = await simpleFetch(path, {
|
|
117
|
-
method: 'GET',
|
|
118
|
-
apiOptions: this.apiOptions,
|
|
119
|
-
})
|
|
120
|
-
|
|
121
|
-
return response.json()
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
async listWebhookEvents(request: T.ListWebhookEventsRequest): Promise<T.ListWebhookEventsResponse> {
|
|
125
|
-
const path = buildPathAndQuery('/webhooks/:webhookId/events', {
|
|
126
|
-
path: request ?? {},
|
|
127
|
-
query: request.query ?? {},
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
const response = await simpleFetch(path, {
|
|
131
|
-
method: 'GET',
|
|
132
|
-
apiOptions: this.apiOptions,
|
|
133
|
-
})
|
|
134
|
-
|
|
135
|
-
return response.json()
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
async listWebhooks(request?: T.ListWebhooksRequest): Promise<T.ListWebhooksResponse> {
|
|
139
|
-
const path = buildPathAndQuery('/webhooks', {
|
|
140
|
-
path: request ?? {},
|
|
141
|
-
query: request?.query ?? {},
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
const response = await simpleFetch(path, {
|
|
145
|
-
method: 'GET',
|
|
146
|
-
apiOptions: this.apiOptions,
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
return response.json()
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
async pingWebhookInit(request: T.PingWebhookRequest): Promise<UserActionChallengeResponse> {
|
|
153
|
-
const path = buildPathAndQuery('/webhooks/:webhookId/ping', {
|
|
154
|
-
path: request ?? {},
|
|
155
|
-
query: {},
|
|
156
|
-
})
|
|
157
|
-
|
|
158
|
-
const challenge = await BaseAuthApi.createUserActionChallenge(
|
|
159
|
-
{
|
|
160
|
-
userActionHttpMethod: 'POST',
|
|
161
|
-
userActionHttpPath: path,
|
|
162
|
-
userActionPayload: JSON.stringify({}),
|
|
163
|
-
userActionServerKind: 'Api',
|
|
164
|
-
},
|
|
165
|
-
this.apiOptions
|
|
166
|
-
)
|
|
167
|
-
|
|
168
|
-
return challenge
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
async pingWebhookComplete(
|
|
172
|
-
request: T.PingWebhookRequest,
|
|
173
|
-
signedChallenge: SignUserActionChallengeRequest
|
|
174
|
-
): Promise<T.PingWebhookResponse> {
|
|
175
|
-
const path = buildPathAndQuery('/webhooks/:webhookId/ping', {
|
|
176
|
-
path: request ?? {},
|
|
177
|
-
query: {},
|
|
178
|
-
})
|
|
179
|
-
|
|
180
|
-
const { userAction } = await BaseAuthApi.signUserActionChallenge(
|
|
181
|
-
signedChallenge,
|
|
182
|
-
this.apiOptions
|
|
183
|
-
)
|
|
184
|
-
|
|
185
|
-
const response = await simpleFetch(path, {
|
|
186
|
-
method: 'POST',
|
|
187
|
-
body: {},
|
|
188
|
-
headers: { 'x-dfns-useraction': userAction },
|
|
189
|
-
apiOptions: this.apiOptions,
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
return response.json()
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
async updateWebhookInit(request: T.UpdateWebhookRequest): Promise<UserActionChallengeResponse> {
|
|
196
|
-
const path = buildPathAndQuery('/webhooks/:webhookId', {
|
|
197
|
-
path: request ?? {},
|
|
198
|
-
query: {},
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
const challenge = await BaseAuthApi.createUserActionChallenge(
|
|
202
|
-
{
|
|
203
|
-
userActionHttpMethod: 'PUT',
|
|
204
|
-
userActionHttpPath: path,
|
|
205
|
-
userActionPayload: JSON.stringify(request.body),
|
|
206
|
-
userActionServerKind: 'Api',
|
|
207
|
-
},
|
|
208
|
-
this.apiOptions
|
|
209
|
-
)
|
|
210
|
-
|
|
211
|
-
return challenge
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
async updateWebhookComplete(
|
|
215
|
-
request: T.UpdateWebhookRequest,
|
|
216
|
-
signedChallenge: SignUserActionChallengeRequest
|
|
217
|
-
): Promise<T.UpdateWebhookResponse> {
|
|
218
|
-
const path = buildPathAndQuery('/webhooks/:webhookId', {
|
|
219
|
-
path: request ?? {},
|
|
220
|
-
query: {},
|
|
221
|
-
})
|
|
222
|
-
|
|
223
|
-
const { userAction } = await BaseAuthApi.signUserActionChallenge(
|
|
224
|
-
signedChallenge,
|
|
225
|
-
this.apiOptions
|
|
226
|
-
)
|
|
227
|
-
|
|
228
|
-
const response = await simpleFetch(path, {
|
|
229
|
-
method: 'PUT',
|
|
230
|
-
body: request.body,
|
|
231
|
-
headers: { 'x-dfns-useraction': userAction },
|
|
232
|
-
apiOptions: this.apiOptions,
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
return response.json()
|
|
236
|
-
}
|
|
237
|
-
}
|
package/index.ts
DELETED
package/project.json
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"targets": {
|
|
3
|
-
"cb": {
|
|
4
|
-
"executor": "@nx/js:tsc",
|
|
5
|
-
"options": {
|
|
6
|
-
"outputPath": "dist/@dfns/sdk",
|
|
7
|
-
"clean": true,
|
|
8
|
-
"main": "packages/sdk/index.ts",
|
|
9
|
-
"tsConfig": "packages/sdk/tsconfig.json",
|
|
10
|
-
"updateBuildableProjectDepsInPackageJson": true
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
package/signer.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
export type CredentialKind = 'Key' | 'Fido2' | 'Password' | 'Totp' | 'RecoveryKey'
|
|
2
|
-
|
|
3
|
-
export type CredentialTransport = 'usb' | 'nfc' | 'ble' | 'internal'
|
|
4
|
-
|
|
5
|
-
export type AllowCredential = {
|
|
6
|
-
type: 'public-key'
|
|
7
|
-
id: string
|
|
8
|
-
transports: CredentialTransport[]
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export type KeyAssertion = {
|
|
12
|
-
kind: 'Key'
|
|
13
|
-
credentialAssertion: {
|
|
14
|
-
credId: string
|
|
15
|
-
clientData: string
|
|
16
|
-
signature: string
|
|
17
|
-
algorithm?: string
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export type Fido2Assertion = {
|
|
22
|
-
kind: 'Fido2'
|
|
23
|
-
credentialAssertion: {
|
|
24
|
-
credId: string
|
|
25
|
-
clientData: string
|
|
26
|
-
authenticatorData: string
|
|
27
|
-
signature: string
|
|
28
|
-
userHandle: string
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type PasswordAssertion = {
|
|
33
|
-
kind: 'Password'
|
|
34
|
-
password: string
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export type TotpAssertion = {
|
|
38
|
-
kind: 'Totp'
|
|
39
|
-
otpCode: string
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type RecoveryKeyAssertion = {
|
|
43
|
-
kind: 'RecoveryKey'
|
|
44
|
-
credentialAssertion: {
|
|
45
|
-
credId: string
|
|
46
|
-
clientData: string
|
|
47
|
-
signature: string
|
|
48
|
-
algorithm?: string
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export type FirstFactorAssertion = KeyAssertion | Fido2Assertion | PasswordAssertion
|
|
53
|
-
|
|
54
|
-
export type SecondFactorAssertion = KeyAssertion | Fido2Assertion | TotpAssertion
|
|
55
|
-
|
|
56
|
-
export type CredentialAssertion = KeyAssertion | Fido2Assertion | PasswordAssertion | TotpAssertion
|
|
57
|
-
|
|
58
|
-
export interface CredentialSigner<T extends CredentialAssertion = FirstFactorAssertion> {
|
|
59
|
-
sign(challenge: string, allowCredentials: { key: AllowCredential[]; webauthn: AllowCredential[] }): Promise<T>
|
|
60
|
-
}
|
package/store.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { AllowCredential, CredentialKind } from './signer'
|
|
2
|
-
|
|
3
|
-
export type AuthenticatorAttachment = 'platform' | 'cross-platform'
|
|
4
|
-
|
|
5
|
-
export type ResidentKeyRequirement = 'required' | 'preferred' | 'discouraged'
|
|
6
|
-
|
|
7
|
-
export type UserVerificationRequirement = 'required' | 'preferred' | 'discouraged'
|
|
8
|
-
|
|
9
|
-
export type AttestationConveyancePreference = 'none' | 'indirect' | 'direct' | 'enterprise'
|
|
10
|
-
|
|
11
|
-
export type UserRegistrationChallenge = {
|
|
12
|
-
temporaryAuthenticationToken: string
|
|
13
|
-
rp: {
|
|
14
|
-
id: string
|
|
15
|
-
name: string
|
|
16
|
-
}
|
|
17
|
-
user: {
|
|
18
|
-
id: string
|
|
19
|
-
name: string
|
|
20
|
-
displayName: string
|
|
21
|
-
}
|
|
22
|
-
supportedCredentialKinds: {
|
|
23
|
-
firstFactor: CredentialKind[]
|
|
24
|
-
secondFactor: CredentialKind[]
|
|
25
|
-
}
|
|
26
|
-
otpUrl: string
|
|
27
|
-
challenge: string
|
|
28
|
-
authenticatorSelection: {
|
|
29
|
-
authenticatorAttachment?: AuthenticatorAttachment
|
|
30
|
-
requireResidentKey: boolean
|
|
31
|
-
residentKey: ResidentKeyRequirement
|
|
32
|
-
userVerification: UserVerificationRequirement
|
|
33
|
-
}
|
|
34
|
-
attestation: AttestationConveyancePreference
|
|
35
|
-
pubKeyCredParams: {
|
|
36
|
-
type: 'public-key'
|
|
37
|
-
alg: number
|
|
38
|
-
}[]
|
|
39
|
-
excludeCredentials: AllowCredential[]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
export type KeyAttestation = {
|
|
43
|
-
credentialKind: 'Key'
|
|
44
|
-
credentialInfo: {
|
|
45
|
-
credId: string
|
|
46
|
-
clientData: string
|
|
47
|
-
attestationData: string
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export type Fido2Attestation = {
|
|
52
|
-
credentialKind: 'Fido2'
|
|
53
|
-
credentialInfo: {
|
|
54
|
-
credId: string
|
|
55
|
-
clientData: string
|
|
56
|
-
attestationData: string
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type PasswordAttestation = {
|
|
61
|
-
credentialKind: 'Password'
|
|
62
|
-
credentialInfo: {
|
|
63
|
-
password: string
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export type TotpAttestation = {
|
|
68
|
-
credentialKind: 'Totp'
|
|
69
|
-
credentialInfo: {
|
|
70
|
-
otpCode: string
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
export type FirstFactorAttestation = KeyAttestation | Fido2Attestation | PasswordAttestation
|
|
75
|
-
|
|
76
|
-
export type SecondFactorAttestation = KeyAttestation | Fido2Attestation | TotpAttestation
|
|
77
|
-
|
|
78
|
-
export type RecoveryKeyAttestation = {
|
|
79
|
-
credentialKind: 'RecoveryKey'
|
|
80
|
-
credentialInfo: {
|
|
81
|
-
credId: string
|
|
82
|
-
clientData: string
|
|
83
|
-
attestationData: string
|
|
84
|
-
}
|
|
85
|
-
encryptedPrivateKey?: string
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export type RecoveryFactorAttestation = RecoveryKeyAttestation
|
|
89
|
-
|
|
90
|
-
export type CredentialAttestation =
|
|
91
|
-
| KeyAttestation
|
|
92
|
-
| Fido2Attestation
|
|
93
|
-
| PasswordAttestation
|
|
94
|
-
| TotpAttestation
|
|
95
|
-
| RecoveryKeyAttestation
|
|
96
|
-
|
|
97
|
-
export interface CredentialStore<T extends CredentialAttestation = FirstFactorAttestation> {
|
|
98
|
-
create(challenge: UserRegistrationChallenge): Promise<T>
|
|
99
|
-
}
|
package/tsconfig.json
DELETED
package/typedoc.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://typedoc.org/schema.json",
|
|
3
|
-
"includeVersion": true,
|
|
4
|
-
"readme": "./README.md",
|
|
5
|
-
"entryPoints": [
|
|
6
|
-
"./index.ts",
|
|
7
|
-
"./generated/signers/index.ts",
|
|
8
|
-
"./generated/wallets/index.ts",
|
|
9
|
-
"./generated/webhooks/index.ts",
|
|
10
|
-
"./types/signers.ts",
|
|
11
|
-
"./types/wallets.ts",
|
|
12
|
-
"./types/webhooks.ts",
|
|
13
|
-
"./utils/index.ts",
|
|
14
|
-
"./codegen/Auth/index.ts",
|
|
15
|
-
"./codegen/Permissions/index.ts",
|
|
16
|
-
"./codegen/datamodel/Auth/index.ts",
|
|
17
|
-
"./codegen/datamodel/Foundations/index.ts",
|
|
18
|
-
"./codegen/datamodel/Orgs/index.ts",
|
|
19
|
-
"./codegen/datamodel/Permissions/index.ts"
|
|
20
|
-
]
|
|
21
|
-
}
|
package/types/policies.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../generated/policies/types'
|
package/types/signers.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../generated/signers/types'
|
package/types/wallets.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../generated/wallets/types'
|
package/types/webhooks.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from '../generated/webhooks/types'
|
package/utils/base64.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { Buffer } from 'buffer'
|
|
2
|
-
|
|
3
|
-
export const toBase64Url = (buffer: string | Buffer): string => {
|
|
4
|
-
if (typeof buffer === 'string') {
|
|
5
|
-
buffer = Buffer.from(buffer)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return buffer.toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const fromBase64Url = (encoded: string): Buffer => {
|
|
12
|
-
const padLength = 4 - (encoded.length % 4)
|
|
13
|
-
if (padLength < 4) {
|
|
14
|
-
encoded += '='.repeat(padLength)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
encoded = encoded.replace(/\-/g, '+').replace(/_/g, '/')
|
|
18
|
-
return Buffer.from(encoded, 'base64')
|
|
19
|
-
}
|
package/utils/fetch.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { Response, fetch as _fetch } from 'cross-fetch'
|
|
2
|
-
|
|
3
|
-
import { DfnsError } from '../dfnsError'
|
|
4
|
-
import { BaseAuthApi, DfnsBaseApiOptions } from '../baseAuthApi'
|
|
5
|
-
import { generateNonce } from './nonce'
|
|
6
|
-
import { DfnsApiClientOptions } from '../dfnsApiClient'
|
|
7
|
-
|
|
8
|
-
export type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE'
|
|
9
|
-
|
|
10
|
-
export type FetchOptions<T> = {
|
|
11
|
-
method: HttpMethod
|
|
12
|
-
headers?: Record<string, string>
|
|
13
|
-
body?: string | unknown
|
|
14
|
-
apiOptions: T
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type Fetch<T> = (resource: string | URL, options: FetchOptions<T>) => Promise<Response>
|
|
18
|
-
|
|
19
|
-
const fullUrl = <T extends DfnsBaseApiOptions>(fetch: Fetch<T>): Fetch<T> => {
|
|
20
|
-
return async (resource, options) => {
|
|
21
|
-
const { baseUrl } = options.apiOptions
|
|
22
|
-
resource = new URL(resource, baseUrl)
|
|
23
|
-
return fetch(resource, options)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const jsonSerializer = <T>(fetch: Fetch<T>): Fetch<T> => {
|
|
28
|
-
return async (resource, options) => {
|
|
29
|
-
if (options.body) {
|
|
30
|
-
options.body = JSON.stringify(options.body)
|
|
31
|
-
|
|
32
|
-
options.headers = {
|
|
33
|
-
'content-type': 'application/json',
|
|
34
|
-
...(options.headers ?? {}),
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return fetch(resource, options)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const errorHandler = <T>(fetch: Fetch<T>): Fetch<T> => {
|
|
43
|
-
return async (resource, options) => {
|
|
44
|
-
const response = await fetch(resource, options)
|
|
45
|
-
|
|
46
|
-
if (response.ok) {
|
|
47
|
-
return response
|
|
48
|
-
} else {
|
|
49
|
-
const body = await response.json()
|
|
50
|
-
const message = body?.error?.message ?? body?.message
|
|
51
|
-
throw new DfnsError(response.status, message, {
|
|
52
|
-
url: response.url,
|
|
53
|
-
headers: response.headers,
|
|
54
|
-
body,
|
|
55
|
-
})
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const dfnsAuth = <T extends DfnsBaseApiOptions>(fetch: Fetch<T>): Fetch<T> => {
|
|
61
|
-
return async (resource, options) => {
|
|
62
|
-
const { appId, appSecret, authToken } = options.apiOptions
|
|
63
|
-
|
|
64
|
-
const authorization: Record<string, string> = authToken
|
|
65
|
-
? {
|
|
66
|
-
authorization: `Bearer ${authToken}`,
|
|
67
|
-
}
|
|
68
|
-
: {}
|
|
69
|
-
|
|
70
|
-
const dfnsAppSecret: Record<string, string> = appSecret
|
|
71
|
-
? {
|
|
72
|
-
'x-dfns-appsecret': appSecret,
|
|
73
|
-
}
|
|
74
|
-
: {}
|
|
75
|
-
|
|
76
|
-
options.headers = {
|
|
77
|
-
'x-dfns-appid': appId,
|
|
78
|
-
'x-dfns-nonce': generateNonce(),
|
|
79
|
-
...dfnsAppSecret,
|
|
80
|
-
...authorization,
|
|
81
|
-
...(options.headers ?? {}),
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return fetch(resource, options)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const userAction = <T extends DfnsApiClientOptions>(fetch: Fetch<T>): Fetch<T> => {
|
|
89
|
-
return async (resource, options) => {
|
|
90
|
-
if (options.method !== 'GET') {
|
|
91
|
-
const apiOptions = {
|
|
92
|
-
...options.apiOptions,
|
|
93
|
-
baseUrl: (<any>options.apiOptions).baseAuthUrl || options.apiOptions.baseUrl,
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const { challenge, challengeIdentifier, allowCredentials } = await BaseAuthApi.createUserActionChallenge(
|
|
97
|
-
{
|
|
98
|
-
userActionPayload: <string>options.body ?? '',
|
|
99
|
-
userActionHttpMethod: options.method,
|
|
100
|
-
userActionHttpPath: (<URL>resource).pathname,
|
|
101
|
-
userActionServerKind: (<any>apiOptions)?.userActionServerKind || 'Api',
|
|
102
|
-
},
|
|
103
|
-
apiOptions
|
|
104
|
-
)
|
|
105
|
-
|
|
106
|
-
const assertion = await apiOptions.signer.sign(challenge, allowCredentials)
|
|
107
|
-
|
|
108
|
-
const { userAction } = await BaseAuthApi.signUserActionChallenge(
|
|
109
|
-
{
|
|
110
|
-
challengeIdentifier,
|
|
111
|
-
firstFactor: assertion,
|
|
112
|
-
},
|
|
113
|
-
apiOptions
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
options.headers = {
|
|
117
|
-
'x-dfns-useraction': userAction,
|
|
118
|
-
...(options.headers ?? {}),
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
return fetch(resource, options)
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export const simpleFetch = fullUrl(jsonSerializer(dfnsAuth(errorHandler(<Fetch<DfnsBaseApiOptions>>_fetch))))
|
|
127
|
-
|
|
128
|
-
export const userActionFetch = fullUrl(
|
|
129
|
-
jsonSerializer(dfnsAuth(userAction(errorHandler(<Fetch<DfnsApiClientOptions>>_fetch))))
|
|
130
|
-
)
|
package/utils/index.ts
DELETED
package/utils/nonce.ts
DELETED
package/utils/url.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const buildPathAndQuery = (
|
|
2
|
-
pattern: string,
|
|
3
|
-
params: { path: Record<string, any>; query: Record<string, string | number | boolean | undefined> }
|
|
4
|
-
): string => {
|
|
5
|
-
let path = pattern
|
|
6
|
-
|
|
7
|
-
const paramsToReplace = (path.match(new RegExp(`:[a-zA-Z]+`, 'g')) || []).map((v) => v.replace(/^:/, ''))
|
|
8
|
-
|
|
9
|
-
for (const key of paramsToReplace) {
|
|
10
|
-
path = path.replace(new RegExp(`:${key}`, 'g'), encodeURIComponent(params.path[key]))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const query = Object.entries(params.query)
|
|
14
|
-
.filter(([_, value]) => !!value)
|
|
15
|
-
.map(([key, value]) => `${key}=${encodeURIComponent(value!.toString())}`)
|
|
16
|
-
.join('&')
|
|
17
|
-
|
|
18
|
-
return query === '' ? path : `${path}?${query}`
|
|
19
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|