@dfns/sdk
Advanced tools
Comparing version 0.1.1 to 0.1.2-rc.1
@@ -71,6 +71,5 @@ "use strict"; | ||
async listAssetAccounts(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -77,0 +76,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -102,6 +102,5 @@ "use strict"; | ||
async listAssetAccounts(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -108,0 +107,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -273,6 +273,5 @@ "use strict"; | ||
async listPermissionAssignments(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/permissions/assignments', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -279,0 +278,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -145,6 +145,5 @@ "use strict"; | ||
async listPermissionAssignments(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/permissions/assignments', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -151,0 +150,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -12,6 +12,5 @@ "use strict"; | ||
async listPolicyControlExecutions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/policies/policy-control-executions', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -18,0 +17,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -11,6 +11,5 @@ "use strict"; | ||
async listPolicyControlExecutions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/policies/policy-control-executions', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -17,0 +16,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -202,6 +202,5 @@ "use strict"; | ||
async listPolicyRules(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/policies/policy-rules', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -208,0 +207,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -124,6 +124,5 @@ "use strict"; | ||
async listPolicyRules(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/policies/policy-rules', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -130,0 +129,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -61,6 +61,5 @@ "use strict"; | ||
async getAddressForNetwork(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/address', { | ||
path: { publicKeyId: request.publicKeyId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -142,6 +141,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransactions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/transactions', { | ||
path: { publicKeyId: request.publicKeyId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -148,0 +146,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -45,6 +45,5 @@ "use strict"; | ||
async getAddressForNetwork(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/address', { | ||
path: { publicKeyId: request.publicKeyId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -96,6 +95,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransactions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/public-keys/:publicKeyId/transactions', { | ||
path: { publicKeyId: request.publicKeyId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -102,0 +100,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -72,6 +72,5 @@ "use strict"; | ||
async listWallets(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -85,6 +84,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async getWalletHistory(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/history', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -136,6 +134,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransfers(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transfers', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -190,6 +187,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransactions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transactions', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -241,6 +237,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listSignatures(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/signatures', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -247,0 +242,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -56,6 +56,5 @@ "use strict"; | ||
async listWallets(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets', { | ||
path: {}, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -69,6 +68,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async getWalletHistory(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/history', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -105,6 +103,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransfers(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transfers', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -144,6 +141,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listTransactions(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/transactions', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -180,6 +176,5 @@ const response = await (0, fetch_1.simpleFetch)(path, { | ||
async listSignatures(request) { | ||
var _a; | ||
const path = (0, url_1.buildPathAndQuery)('/wallets/:walletId/signatures', { | ||
path: { walletId: request.walletId }, | ||
query: (_a = request.query) !== null && _a !== void 0 ? _a : {}, | ||
query: request.query ?? {}, | ||
}); | ||
@@ -186,0 +181,0 @@ const response = await (0, fetch_1.simpleFetch)(path, { |
@@ -12,2 +12,3 @@ import { DfnsBaseApiOptions } from './baseAuthApi'; | ||
import { SignersClient } from './codegen/Signers'; | ||
import { WebhooksClient } from './generated/webhooks'; | ||
import { CredentialSigner } from './signer'; | ||
@@ -29,3 +30,4 @@ export type DfnsApiClientOptions = DfnsBaseApiOptions & { | ||
get wallets(): WalletsClient; | ||
get webhooks(): WebhooksClient; | ||
get signers(): SignersClient; | ||
} |
@@ -14,2 +14,3 @@ "use strict"; | ||
const Signers_1 = require("./codegen/Signers"); | ||
const webhooks_1 = require("./generated/webhooks"); | ||
class DfnsApiClient { | ||
@@ -46,2 +47,5 @@ constructor(apiOptions) { | ||
} | ||
get webhooks() { | ||
return new webhooks_1.WebhooksClient(this.apiOptions); | ||
} | ||
get signers() { | ||
@@ -48,0 +52,0 @@ return new Signers_1.SignersClient(this.apiOptions); |
@@ -11,2 +11,3 @@ import { DfnsBaseApiOptions } from './baseAuthApi'; | ||
import { DelegatedSignersClient } from './codegen/Signers'; | ||
import { DelegatedWebhooksClient } from './generated/webhooks'; | ||
import { DelegatedWalletsClient } from './codegen/Wallets'; | ||
@@ -28,3 +29,4 @@ export type DfnsDelegatedApiClientOptions = DfnsBaseApiOptions & { | ||
get wallets(): DelegatedWalletsClient; | ||
get webhooks(): DelegatedWebhooksClient; | ||
get signers(): DelegatedSignersClient; | ||
} |
@@ -13,2 +13,3 @@ "use strict"; | ||
const Signers_1 = require("./codegen/Signers"); | ||
const webhooks_1 = require("./generated/webhooks"); | ||
const Wallets_1 = require("./codegen/Wallets"); | ||
@@ -46,2 +47,5 @@ class DfnsDelegatedApiClient { | ||
} | ||
get webhooks() { | ||
return new webhooks_1.DelegatedWebhooksClient(this.apiOptions); | ||
} | ||
get signers() { | ||
@@ -48,0 +52,0 @@ return new Signers_1.DelegatedSignersClient(this.apiOptions); |
{ | ||
"name": "@dfns/sdk", | ||
"version": "0.1.1", | ||
"dependencies": { | ||
"buffer": "6.0.3", | ||
"cross-fetch": "3.1.6", | ||
"uuid": "9.0.0" | ||
}, | ||
"version": "0.1.2-rc.1", | ||
"main": "./index.js", | ||
"types": "./index.d.ts" | ||
"type": "commonjs" | ||
} |
@@ -17,3 +17,2 @@ "use strict"; | ||
return async (resource, options) => { | ||
var _a; | ||
if (options.body) { | ||
@@ -23,3 +22,3 @@ options.body = JSON.stringify(options.body); | ||
'content-type': 'application/json', | ||
...((_a = options.headers) !== null && _a !== void 0 ? _a : {}), | ||
...(options.headers ?? {}), | ||
}; | ||
@@ -32,3 +31,2 @@ } | ||
return async (resource, options) => { | ||
var _a; | ||
const response = await fetch(resource, options); | ||
@@ -40,3 +38,3 @@ if (response.ok) { | ||
const body = await response.json(); | ||
const errorMessage = ((_a = body === null || body === void 0 ? void 0 : body.error) === null || _a === void 0 ? void 0 : _a.message) || (body === null || body === void 0 ? void 0 : body.message) || JSON.stringify(body); | ||
const errorMessage = body?.error?.message || body?.message || JSON.stringify(body); | ||
throw new dfnsError_1.DfnsError(response.status, errorMessage, body.error); | ||
@@ -48,3 +46,2 @@ } | ||
return async (resource, options) => { | ||
var _a; | ||
const { appId, appSecret, authToken } = options.apiOptions; | ||
@@ -66,3 +63,3 @@ const authorization = authToken | ||
...authorization, | ||
...((_a = options.headers) !== null && _a !== void 0 ? _a : {}), | ||
...(options.headers ?? {}), | ||
}; | ||
@@ -74,3 +71,2 @@ return fetch(resource, options); | ||
return async (resource, options) => { | ||
var _a, _b; | ||
if (options.method !== 'GET') { | ||
@@ -82,6 +78,6 @@ const apiOptions = { | ||
const { challenge, challengeIdentifier, allowCredentials } = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({ | ||
userActionPayload: (_a = options.body) !== null && _a !== void 0 ? _a : '', | ||
userActionPayload: options.body ?? '', | ||
userActionHttpMethod: options.method, | ||
userActionHttpPath: resource.pathname, | ||
userActionServerKind: (apiOptions === null || apiOptions === void 0 ? void 0 : apiOptions.userActionServerKind) || 'Api', | ||
userActionServerKind: apiOptions?.userActionServerKind || 'Api', | ||
}, apiOptions); | ||
@@ -95,3 +91,3 @@ const assertion = await apiOptions.signer.sign(challenge, allowCredentials); | ||
'x-dfns-useraction': userAction, | ||
...((_b = options.headers) !== null && _b !== void 0 ? _b : {}), | ||
...(options.headers ?? {}), | ||
}; | ||
@@ -98,0 +94,0 @@ } |
export declare const buildPathAndQuery: (pattern: string, params: { | ||
path: Record<string, string>; | ||
path: Record<string, any>; | ||
query: Record<string, string | number | boolean | undefined>; | ||
}) => string; |
@@ -6,3 +6,4 @@ "use strict"; | ||
let path = pattern; | ||
for (const key in params.path) { | ||
const paramsToReplace = path.match(new RegExp(`:[a-zA-Z]+`, 'g')) || []; | ||
for (const key of paramsToReplace) { | ||
path = path.replace(new RegExp(`:${key}`, 'g'), encodeURIComponent(params.path[key])); | ||
@@ -9,0 +10,0 @@ } |
2279348
0
225
78585
- Removedbuffer@6.0.3
- Removedcross-fetch@3.1.6
- Removeduuid@9.0.0
- Removedbase64-js@1.5.1(transitive)
- Removedbuffer@6.0.3(transitive)
- Removedcross-fetch@3.1.6(transitive)
- Removedieee754@1.2.1(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removeduuid@9.0.0(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)