@dfns/sdk 0.6.0-rc.0 → 0.6.0-rc.1

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.
@@ -5,6 +5,7 @@ import { NetworksClient } from './generated/networks';
5
5
  import { PermissionsClient } from './generated/permissions';
6
6
  import { PoliciesClient } from './generated/policies';
7
7
  import { SignersClient } from './generated/signers';
8
+ import { StakingClient } from './generated/staking';
8
9
  import { WalletsClient } from './generated/wallets';
9
10
  import { WebhooksClient } from './generated/webhooks';
10
11
  import { CredentialSigner } from './signer';
@@ -20,7 +21,8 @@ export declare class DfnsApiClient {
20
21
  get networks(): NetworksClient;
21
22
  get permissions(): PermissionsClient;
22
23
  get policies(): PoliciesClient;
24
+ get staking(): StakingClient;
25
+ get signers(): SignersClient;
23
26
  get wallets(): WalletsClient;
24
27
  get webhooks(): WebhooksClient;
25
- get signers(): SignersClient;
26
28
  }
package/dfnsApiClient.js CHANGED
@@ -7,6 +7,7 @@ const networks_1 = require("./generated/networks");
7
7
  const permissions_1 = require("./generated/permissions");
8
8
  const policies_1 = require("./generated/policies");
9
9
  const signers_1 = require("./generated/signers");
10
+ const staking_1 = require("./generated/staking");
10
11
  const wallets_1 = require("./generated/wallets");
11
12
  const webhooks_1 = require("./generated/webhooks");
12
13
  class DfnsApiClient {
@@ -28,14 +29,17 @@ class DfnsApiClient {
28
29
  get policies() {
29
30
  return new policies_1.PoliciesClient(this.apiOptions);
30
31
  }
32
+ get staking() {
33
+ return new staking_1.StakingClient(this.apiOptions);
34
+ }
35
+ get signers() {
36
+ return new signers_1.SignersClient(this.apiOptions);
37
+ }
31
38
  get wallets() {
32
39
  return new wallets_1.WalletsClient(this.apiOptions);
33
40
  }
34
41
  get webhooks() {
35
42
  return new webhooks_1.WebhooksClient(this.apiOptions);
36
43
  }
37
- get signers() {
38
- return new signers_1.SignersClient(this.apiOptions);
39
- }
40
44
  }
41
45
  exports.DfnsApiClient = DfnsApiClient;
@@ -36,7 +36,7 @@ export type CreateAssignmentRequest = CreateAssignmentParams & {
36
36
  };
37
37
  export type CreatePermissionBody = {
38
38
  name: string;
39
- operations: ("Auth:Action:Sign" | "Auth:Apps:Create" | "Auth:Apps:Read" | "Auth:Apps:Update" | "Auth:Creds:Create" | "Auth:Creds:Read" | "Auth:Creds:Update" | "Auth:Creds:Code:Create" | "Auth:Types:Application" | "Auth:Types:Employee" | "Auth:Types:EndUser" | "Auth:Types:Pat" | "Auth:Types:ServiceAccount" | "Auth:Users:Create" | "Auth:Users:Delegate" | "Auth:Users:Read" | "Auth:Users:Update" | "Exchanges:Create" | "Exchanges:Read" | "Exchanges:Delete" | "Exchanges:Deposits:Create" | "Exchanges:Withdrawals:Create" | "Orgs:Read" | "Orgs:Update" | "Orgs:Settings:Read" | "Orgs:Settings:Update" | "PermissionAssignments:Create" | "PermissionAssignments:Read" | "PermissionAssignments:Revoke" | "PermissionPredicates:Archive" | "PermissionPredicates:Create" | "PermissionPredicates:Read" | "PermissionPredicates:Update" | "Permissions:Archive" | "Permissions:Create" | "Permissions:Read" | "Permissions:Update" | "Policies:Archive" | "Policies:Create" | "Policies:Read" | "Policies:Update" | "Policies:Approvals:Read" | "Policies:Approvals:Approve" | "Signers:ListSigners" | "Wallets:BroadcastTransaction" | "Wallets:Create" | "Wallets:Delegate" | "Wallets:Export" | "Wallets:GenerateSignature" | "Wallets:Import" | "Wallets:Read" | "Wallets:ReadSignature" | "Wallets:ReadTransaction" | "Wallets:ReadTransfer" | "Wallets:TransferAsset" | "Wallets:Update" | "Wallets:Tags:Add" | "Wallets:Tags:Delete" | "Webhooks:Create" | "Webhooks:Read" | "Webhooks:Update" | "Webhooks:Delete" | "Webhooks:Ping" | "Webhooks:Events:Read")[];
39
+ operations: ("Auth:Action:Sign" | "Auth:Apps:Create" | "Auth:Apps:Read" | "Auth:Apps:Update" | "Auth:Creds:Create" | "Auth:Creds:Read" | "Auth:Creds:Update" | "Auth:Creds:Code:Create" | "Auth:Types:Application" | "Auth:Types:Employee" | "Auth:Types:EndUser" | "Auth:Types:Pat" | "Auth:Types:ServiceAccount" | "Auth:Users:Create" | "Auth:Users:Delegate" | "Auth:Users:Read" | "Auth:Users:Update" | "Exchanges:Create" | "Exchanges:Read" | "Exchanges:Delete" | "Exchanges:Deposits:Create" | "Exchanges:Withdrawals:Create" | "Orgs:Read" | "Orgs:Update" | "Orgs:Settings:Read" | "Orgs:Settings:Update" | "PermissionAssignments:Create" | "PermissionAssignments:Read" | "PermissionAssignments:Revoke" | "PermissionPredicates:Archive" | "PermissionPredicates:Create" | "PermissionPredicates:Read" | "PermissionPredicates:Update" | "Permissions:Archive" | "Permissions:Create" | "Permissions:Read" | "Permissions:Update" | "Policies:Archive" | "Policies:Create" | "Policies:Read" | "Policies:Update" | "Policies:Approvals:Read" | "Policies:Approvals:Approve" | "Signers:ListSigners" | "Stakes:Create" | "Stakes:Read" | "Wallets:BroadcastTransaction" | "Wallets:Create" | "Wallets:Delegate" | "Wallets:Export" | "Wallets:GenerateSignature" | "Wallets:Import" | "Wallets:Read" | "Wallets:ReadSignature" | "Wallets:ReadTransaction" | "Wallets:ReadTransfer" | "Wallets:TransferAsset" | "Wallets:Update" | "Wallets:Tags:Add" | "Wallets:Tags:Delete" | "Webhooks:Create" | "Webhooks:Read" | "Webhooks:Update" | "Webhooks:Delete" | "Webhooks:Ping" | "Webhooks:Events:Read")[];
40
40
  };
41
41
  export type CreatePermissionResponse = {
42
42
  id: string;
@@ -178,7 +178,7 @@ export type ListPermissionsRequest = {
178
178
  };
179
179
  export type UpdatePermissionBody = {
180
180
  name?: string | undefined;
181
- operations?: ("Auth:Action:Sign" | "Auth:Apps:Create" | "Auth:Apps:Read" | "Auth:Apps:Update" | "Auth:Creds:Create" | "Auth:Creds:Read" | "Auth:Creds:Update" | "Auth:Creds:Code:Create" | "Auth:Types:Application" | "Auth:Types:Employee" | "Auth:Types:EndUser" | "Auth:Types:Pat" | "Auth:Types:ServiceAccount" | "Auth:Users:Create" | "Auth:Users:Delegate" | "Auth:Users:Read" | "Auth:Users:Update" | "Exchanges:Create" | "Exchanges:Read" | "Exchanges:Delete" | "Exchanges:Deposits:Create" | "Exchanges:Withdrawals:Create" | "Orgs:Read" | "Orgs:Update" | "Orgs:Settings:Read" | "Orgs:Settings:Update" | "PermissionAssignments:Create" | "PermissionAssignments:Read" | "PermissionAssignments:Revoke" | "PermissionPredicates:Archive" | "PermissionPredicates:Create" | "PermissionPredicates:Read" | "PermissionPredicates:Update" | "Permissions:Archive" | "Permissions:Create" | "Permissions:Read" | "Permissions:Update" | "Policies:Archive" | "Policies:Create" | "Policies:Read" | "Policies:Update" | "Policies:Approvals:Read" | "Policies:Approvals:Approve" | "Signers:ListSigners" | "Wallets:BroadcastTransaction" | "Wallets:Create" | "Wallets:Delegate" | "Wallets:Export" | "Wallets:GenerateSignature" | "Wallets:Import" | "Wallets:Read" | "Wallets:ReadSignature" | "Wallets:ReadTransaction" | "Wallets:ReadTransfer" | "Wallets:TransferAsset" | "Wallets:Update" | "Wallets:Tags:Add" | "Wallets:Tags:Delete" | "Webhooks:Create" | "Webhooks:Read" | "Webhooks:Update" | "Webhooks:Delete" | "Webhooks:Ping" | "Webhooks:Events:Read")[] | undefined;
181
+ operations?: ("Auth:Action:Sign" | "Auth:Apps:Create" | "Auth:Apps:Read" | "Auth:Apps:Update" | "Auth:Creds:Create" | "Auth:Creds:Read" | "Auth:Creds:Update" | "Auth:Creds:Code:Create" | "Auth:Types:Application" | "Auth:Types:Employee" | "Auth:Types:EndUser" | "Auth:Types:Pat" | "Auth:Types:ServiceAccount" | "Auth:Users:Create" | "Auth:Users:Delegate" | "Auth:Users:Read" | "Auth:Users:Update" | "Exchanges:Create" | "Exchanges:Read" | "Exchanges:Delete" | "Exchanges:Deposits:Create" | "Exchanges:Withdrawals:Create" | "Orgs:Read" | "Orgs:Update" | "Orgs:Settings:Read" | "Orgs:Settings:Update" | "PermissionAssignments:Create" | "PermissionAssignments:Read" | "PermissionAssignments:Revoke" | "PermissionPredicates:Archive" | "PermissionPredicates:Create" | "PermissionPredicates:Read" | "PermissionPredicates:Update" | "Permissions:Archive" | "Permissions:Create" | "Permissions:Read" | "Permissions:Update" | "Policies:Archive" | "Policies:Create" | "Policies:Read" | "Policies:Update" | "Policies:Approvals:Read" | "Policies:Approvals:Approve" | "Signers:ListSigners" | "Stakes:Create" | "Stakes:Read" | "Wallets:BroadcastTransaction" | "Wallets:Create" | "Wallets:Delegate" | "Wallets:Export" | "Wallets:GenerateSignature" | "Wallets:Import" | "Wallets:Read" | "Wallets:ReadSignature" | "Wallets:ReadTransaction" | "Wallets:ReadTransfer" | "Wallets:TransferAsset" | "Wallets:Update" | "Wallets:Tags:Add" | "Wallets:Tags:Delete" | "Webhooks:Create" | "Webhooks:Read" | "Webhooks:Update" | "Webhooks:Delete" | "Webhooks:Ping" | "Webhooks:Events:Read")[] | undefined;
182
182
  };
183
183
  export type UpdatePermissionParams = {
184
184
  permissionId: string;
@@ -0,0 +1,8 @@
1
+ import { DfnsApiClientOptions } from '../../types/generic';
2
+ import * as T from './types';
3
+ export declare class StakingClient {
4
+ private apiOptions;
5
+ constructor(apiOptions: DfnsApiClientOptions);
6
+ createStake(request: T.CreateStakeRequest): Promise<T.CreateStakeResponse>;
7
+ listStakes(request?: T.ListStakesRequest): Promise<T.ListStakesResponse>;
8
+ }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.StakingClient = void 0;
4
+ const fetch_1 = require("../../utils/fetch");
5
+ const userActionFetch_1 = require("../../utils/userActionFetch");
6
+ const url_1 = require("../../utils/url");
7
+ class StakingClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createStake(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const response = await (0, userActionFetch_1.userActionFetch)(path, {
17
+ method: 'POST',
18
+ body: request.body,
19
+ apiOptions: this.apiOptions,
20
+ });
21
+ return response.json();
22
+ }
23
+ async listStakes(request) {
24
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
25
+ path: request ?? {},
26
+ query: request?.query ?? {},
27
+ });
28
+ const response = await (0, fetch_1.simpleFetch)(path, {
29
+ method: 'GET',
30
+ apiOptions: this.apiOptions,
31
+ });
32
+ return response.json();
33
+ }
34
+ }
35
+ exports.StakingClient = StakingClient;
@@ -0,0 +1,10 @@
1
+ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
2
+ import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
3
+ import * as T from './types';
4
+ export declare class DelegatedStakingClient {
5
+ private apiOptions;
6
+ constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ createStakeInit(request: T.CreateStakeRequest): Promise<UserActionChallengeResponse>;
8
+ createStakeComplete(request: T.CreateStakeRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateStakeResponse>;
9
+ listStakes(request?: T.ListStakesRequest): Promise<T.ListStakesResponse>;
10
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedStakingClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedStakingClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createStakeInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
17
+ userActionHttpMethod: 'POST',
18
+ userActionHttpPath: path,
19
+ userActionPayload: JSON.stringify(request.body),
20
+ userActionServerKind: 'Api',
21
+ }, this.apiOptions);
22
+ return challenge;
23
+ }
24
+ async createStakeComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
26
+ path: request ?? {},
27
+ query: {},
28
+ });
29
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
30
+ const response = await (0, fetch_1.simpleFetch)(path, {
31
+ method: 'POST',
32
+ body: request.body,
33
+ headers: { 'x-dfns-useraction': userAction },
34
+ apiOptions: this.apiOptions,
35
+ });
36
+ return response.json();
37
+ }
38
+ async listStakes(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/staking/stakes', {
40
+ path: request ?? {},
41
+ query: request?.query ?? {},
42
+ });
43
+ const response = await (0, fetch_1.simpleFetch)(path, {
44
+ method: 'GET',
45
+ apiOptions: this.apiOptions,
46
+ });
47
+ return response.json();
48
+ }
49
+ }
50
+ exports.DelegatedStakingClient = DelegatedStakingClient;
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './client';
3
+ export * from './delegatedClient';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./client"), exports);
19
+ __exportStar(require("./delegatedClient"), exports);
@@ -0,0 +1,99 @@
1
+ export type CreateStakeBody = {
2
+ kind: "Native";
3
+ amount: string;
4
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
5
+ createDestinationAccount?: boolean | undefined;
6
+ externalId?: string | undefined;
7
+ walletId: string;
8
+ provider: "Figment";
9
+ protocol: "Babylon";
10
+ duration: number;
11
+ };
12
+ export type CreateStakeResponse = {
13
+ stake: {
14
+ id: string;
15
+ provider: "Figment";
16
+ providerStakeId: string;
17
+ walletId: string;
18
+ protocol: "Babylon";
19
+ status: "Active";
20
+ requester: {
21
+ userId: string;
22
+ tokenId?: string | undefined;
23
+ appId?: string | undefined;
24
+ };
25
+ requestBody: {
26
+ kind: "Native";
27
+ amount: string;
28
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
29
+ createDestinationAccount?: boolean | undefined;
30
+ externalId?: string | undefined;
31
+ walletId: string;
32
+ provider: "Figment";
33
+ protocol: "Babylon";
34
+ duration: number;
35
+ };
36
+ dateCreated: string;
37
+ };
38
+ stakeTransaction: {
39
+ id: string;
40
+ stakeId: string;
41
+ transactionId?: string | undefined;
42
+ kind: "Stake" | "Unbond" | "UnbondWithdrawal" | "Withdraw";
43
+ requester: {
44
+ userId: string;
45
+ tokenId?: string | undefined;
46
+ appId?: string | undefined;
47
+ };
48
+ requestBody: {
49
+ kind: "Native";
50
+ amount: string;
51
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
52
+ createDestinationAccount?: boolean | undefined;
53
+ externalId?: string | undefined;
54
+ walletId: string;
55
+ provider: "Figment";
56
+ protocol: "Babylon";
57
+ duration: number;
58
+ };
59
+ dateCreated: string;
60
+ };
61
+ };
62
+ export type CreateStakeRequest = {
63
+ body: CreateStakeBody;
64
+ };
65
+ export type ListStakesQuery = {
66
+ limit?: number | undefined;
67
+ paginationToken?: string | undefined;
68
+ };
69
+ export type ListStakesResponse = {
70
+ items: {
71
+ id: string;
72
+ provider: "Figment";
73
+ providerStakeId: string;
74
+ walletId: string;
75
+ protocol: "Babylon";
76
+ status: "Active";
77
+ requester: {
78
+ userId: string;
79
+ tokenId?: string | undefined;
80
+ appId?: string | undefined;
81
+ };
82
+ requestBody: {
83
+ kind: "Native";
84
+ amount: string;
85
+ priority?: ("Slow" | "Standard" | "Fast") | undefined;
86
+ createDestinationAccount?: boolean | undefined;
87
+ externalId?: string | undefined;
88
+ walletId: string;
89
+ provider: "Figment";
90
+ protocol: "Babylon";
91
+ duration: number;
92
+ };
93
+ dateCreated: string;
94
+ }[];
95
+ nextPageToken?: string | undefined;
96
+ };
97
+ export type ListStakesRequest = {
98
+ query?: ListStakesQuery;
99
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dfns/sdk",
3
- "version": "0.6.0-rc.0",
3
+ "version": "0.6.0-rc.1",
4
4
  "dependencies": {
5
5
  "buffer": "6.0.3",
6
6
  "cross-fetch": "3.1.6",