@dfns/sdk 0.1.0-alpha.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.
Files changed (161) hide show
  1. package/baseAuthApi.d.ts +53 -0
  2. package/baseAuthApi.js +39 -0
  3. package/codegen/ApiKeys/ApiKeysClient.d.ts +10 -0
  4. package/codegen/ApiKeys/ApiKeysClient.js +56 -0
  5. package/codegen/ApiKeys/DelegatedApiKeysClient.d.ts +13 -0
  6. package/codegen/ApiKeys/DelegatedApiKeysClient.js +88 -0
  7. package/codegen/ApiKeys/index.d.ts +3 -0
  8. package/codegen/ApiKeys/index.js +19 -0
  9. package/codegen/ApiKeys/types.d.ts +16 -0
  10. package/codegen/ApiKeys/types.js +2 -0
  11. package/codegen/Assets/AssetsClient.d.ts +14 -0
  12. package/codegen/Assets/AssetsClient.js +105 -0
  13. package/codegen/Assets/DelegatedAssetsClient.d.ts +18 -0
  14. package/codegen/Assets/DelegatedAssetsClient.js +152 -0
  15. package/codegen/Assets/index.d.ts +3 -0
  16. package/codegen/Assets/index.js +19 -0
  17. package/codegen/Assets/types.d.ts +39 -0
  18. package/codegen/Assets/types.js +2 -0
  19. package/codegen/Auth/AuthClient.d.ts +62 -0
  20. package/codegen/Auth/AuthClient.js +667 -0
  21. package/codegen/Auth/DelegatedAuthClient.d.ts +98 -0
  22. package/codegen/Auth/DelegatedAuthClient.js +1223 -0
  23. package/codegen/Auth/index.d.ts +3 -0
  24. package/codegen/Auth/index.js +19 -0
  25. package/codegen/Auth/types.d.ts +243 -0
  26. package/codegen/Auth/types.js +2 -0
  27. package/codegen/Callbacks/CallbacksClient.d.ts +12 -0
  28. package/codegen/Callbacks/CallbacksClient.js +78 -0
  29. package/codegen/Callbacks/DelegatedCallbacksClient.d.ts +15 -0
  30. package/codegen/Callbacks/DelegatedCallbacksClient.js +110 -0
  31. package/codegen/Callbacks/index.d.ts +3 -0
  32. package/codegen/Callbacks/index.js +19 -0
  33. package/codegen/Callbacks/types.d.ts +23 -0
  34. package/codegen/Callbacks/types.js +2 -0
  35. package/codegen/Permissions/DelegatedPermissionsClient.d.ts +28 -0
  36. package/codegen/Permissions/DelegatedPermissionsClient.js +297 -0
  37. package/codegen/Permissions/PermissionsClient.d.ts +19 -0
  38. package/codegen/Permissions/PermissionsClient.js +169 -0
  39. package/codegen/Permissions/index.d.ts +3 -0
  40. package/codegen/Permissions/index.js +19 -0
  41. package/codegen/Permissions/types.d.ts +71 -0
  42. package/codegen/Permissions/types.js +2 -0
  43. package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.d.ts +11 -0
  44. package/codegen/PolicyExecution/DelegatedPolicyExecutionClient.js +62 -0
  45. package/codegen/PolicyExecution/PolicyExecutionClient.d.ts +9 -0
  46. package/codegen/PolicyExecution/PolicyExecutionClient.js +46 -0
  47. package/codegen/PolicyExecution/index.d.ts +3 -0
  48. package/codegen/PolicyExecution/index.js +19 -0
  49. package/codegen/PolicyExecution/types.d.ts +16 -0
  50. package/codegen/PolicyExecution/types.js +2 -0
  51. package/codegen/PolicyManagement/DelegatedPolicyManagementClient.d.ts +31 -0
  52. package/codegen/PolicyManagement/DelegatedPolicyManagementClient.js +324 -0
  53. package/codegen/PolicyManagement/PolicyManagementClient.d.ts +21 -0
  54. package/codegen/PolicyManagement/PolicyManagementClient.js +185 -0
  55. package/codegen/PolicyManagement/index.d.ts +3 -0
  56. package/codegen/PolicyManagement/index.js +19 -0
  57. package/codegen/PolicyManagement/types.d.ts +91 -0
  58. package/codegen/PolicyManagement/types.js +2 -0
  59. package/codegen/PublicKeys/DelegatedPublicKeysClient.d.ts +21 -0
  60. package/codegen/PublicKeys/DelegatedPublicKeysClient.js +191 -0
  61. package/codegen/PublicKeys/PublicKeysClient.d.ts +16 -0
  62. package/codegen/PublicKeys/PublicKeysClient.js +130 -0
  63. package/codegen/PublicKeys/index.d.ts +3 -0
  64. package/codegen/PublicKeys/index.js +19 -0
  65. package/codegen/PublicKeys/types.d.ts +51 -0
  66. package/codegen/PublicKeys/types.js +2 -0
  67. package/codegen/Wallets/DelegatedWalletsClient.d.ts +26 -0
  68. package/codegen/Wallets/DelegatedWalletsClient.js +249 -0
  69. package/codegen/Wallets/WalletsClient.d.ts +21 -0
  70. package/codegen/Wallets/WalletsClient.js +188 -0
  71. package/codegen/Wallets/index.d.ts +3 -0
  72. package/codegen/Wallets/index.js +19 -0
  73. package/codegen/Wallets/types.d.ts +87 -0
  74. package/codegen/Wallets/types.js +2 -0
  75. package/codegen/datamodel/ApiKeys/errors.d.ts +6 -0
  76. package/codegen/datamodel/ApiKeys/errors.js +15 -0
  77. package/codegen/datamodel/ApiKeys/index.d.ts +3 -0
  78. package/codegen/datamodel/ApiKeys/index.js +19 -0
  79. package/codegen/datamodel/ApiKeys/responses.d.ts +25 -0
  80. package/codegen/datamodel/ApiKeys/responses.js +2 -0
  81. package/codegen/datamodel/ApiKeys/types.d.ts +32 -0
  82. package/codegen/datamodel/ApiKeys/types.js +11 -0
  83. package/codegen/datamodel/Assets/errors.d.ts +11 -0
  84. package/codegen/datamodel/Assets/errors.js +17 -0
  85. package/codegen/datamodel/Assets/index.d.ts +3 -0
  86. package/codegen/datamodel/Assets/index.js +19 -0
  87. package/codegen/datamodel/Assets/responses.d.ts +45 -0
  88. package/codegen/datamodel/Assets/responses.js +2 -0
  89. package/codegen/datamodel/Assets/types.d.ts +225 -0
  90. package/codegen/datamodel/Assets/types.js +75 -0
  91. package/codegen/datamodel/Auth/index.d.ts +2 -0
  92. package/codegen/datamodel/Auth/index.js +18 -0
  93. package/codegen/datamodel/Auth/responses.d.ts +348 -0
  94. package/codegen/datamodel/Auth/responses.js +2 -0
  95. package/codegen/datamodel/Auth/types.d.ts +610 -0
  96. package/codegen/datamodel/Auth/types.js +127 -0
  97. package/codegen/datamodel/Callbacks/index.d.ts +2 -0
  98. package/codegen/datamodel/Callbacks/index.js +18 -0
  99. package/codegen/datamodel/Callbacks/responses.d.ts +36 -0
  100. package/codegen/datamodel/Callbacks/responses.js +2 -0
  101. package/codegen/datamodel/Callbacks/types.d.ts +43 -0
  102. package/codegen/datamodel/Callbacks/types.js +39 -0
  103. package/codegen/datamodel/Foundations/errors.d.ts +121 -0
  104. package/codegen/datamodel/Foundations/errors.js +169 -0
  105. package/codegen/datamodel/Foundations/index.d.ts +2 -0
  106. package/codegen/datamodel/Foundations/index.js +18 -0
  107. package/codegen/datamodel/Foundations/types.d.ts +9754 -0
  108. package/codegen/datamodel/Foundations/types.js +57741 -0
  109. package/codegen/datamodel/Permissions/index.d.ts +2 -0
  110. package/codegen/datamodel/Permissions/index.js +18 -0
  111. package/codegen/datamodel/Permissions/responses.d.ts +75 -0
  112. package/codegen/datamodel/Permissions/responses.js +2 -0
  113. package/codegen/datamodel/Permissions/types.d.ts +106 -0
  114. package/codegen/datamodel/Permissions/types.js +65 -0
  115. package/codegen/datamodel/PolicyExecution/errors.d.ts +11 -0
  116. package/codegen/datamodel/PolicyExecution/errors.js +17 -0
  117. package/codegen/datamodel/PolicyExecution/index.d.ts +3 -0
  118. package/codegen/datamodel/PolicyExecution/index.js +19 -0
  119. package/codegen/datamodel/PolicyExecution/responses.d.ts +17 -0
  120. package/codegen/datamodel/PolicyExecution/responses.js +2 -0
  121. package/codegen/datamodel/PolicyExecution/types.d.ts +45 -0
  122. package/codegen/datamodel/PolicyExecution/types.js +15 -0
  123. package/codegen/datamodel/PolicyManagement/index.d.ts +2 -0
  124. package/codegen/datamodel/PolicyManagement/index.js +18 -0
  125. package/codegen/datamodel/PolicyManagement/responses.d.ts +83 -0
  126. package/codegen/datamodel/PolicyManagement/responses.js +2 -0
  127. package/codegen/datamodel/PolicyManagement/types.d.ts +252 -0
  128. package/codegen/datamodel/PolicyManagement/types.js +81 -0
  129. package/codegen/datamodel/PublicKeys/index.d.ts +2 -0
  130. package/codegen/datamodel/PublicKeys/index.js +18 -0
  131. package/codegen/datamodel/PublicKeys/responses.d.ts +56 -0
  132. package/codegen/datamodel/PublicKeys/responses.js +2 -0
  133. package/codegen/datamodel/PublicKeys/types.d.ts +222 -0
  134. package/codegen/datamodel/PublicKeys/types.js +59 -0
  135. package/codegen/datamodel/Wallets/index.d.ts +2 -0
  136. package/codegen/datamodel/Wallets/index.js +18 -0
  137. package/codegen/datamodel/Wallets/responses.d.ts +77 -0
  138. package/codegen/datamodel/Wallets/responses.js +2 -0
  139. package/codegen/datamodel/Wallets/types.d.ts +261 -0
  140. package/codegen/datamodel/Wallets/types.js +89 -0
  141. package/dfnsApiClient.d.ts +27 -0
  142. package/dfnsApiClient.js +45 -0
  143. package/dfnsAuthenticator.d.ts +11 -0
  144. package/dfnsAuthenticator.js +18 -0
  145. package/dfnsDelegatedApiClient.d.ts +24 -0
  146. package/dfnsDelegatedApiClient.js +41 -0
  147. package/dfnsError.d.ts +5 -0
  148. package/dfnsError.js +11 -0
  149. package/index.d.ts +3 -0
  150. package/index.js +19 -0
  151. package/package.json +11 -0
  152. package/signer.d.ts +47 -0
  153. package/signer.js +2 -0
  154. package/utils/base64.d.ts +3 -0
  155. package/utils/base64.js +20 -0
  156. package/utils/fetch.d.ts +12 -0
  157. package/utils/fetch.js +89 -0
  158. package/utils/nonce.d.ts +1 -0
  159. package/utils/nonce.js +12 -0
  160. package/utils/url.d.ts +4 -0
  161. package/utils/url.js +15 -0
@@ -0,0 +1,53 @@
1
+ import { AllowCredential, FirstFactorAssertion, SecondFactorAssertion } from './signer';
2
+ import { HttpMethod } from './utils/fetch';
3
+ export type DfnsBaseApiOptions = {
4
+ appId: string;
5
+ appSecret?: string;
6
+ accessToken?: string;
7
+ baseUrl: string;
8
+ };
9
+ export type CreateUserActionChallengeRequest = {
10
+ userActionPayload: string;
11
+ userActionHttpMethod: HttpMethod;
12
+ userActionHttpPath: string;
13
+ userActionServerKind: 'Api';
14
+ };
15
+ export type CredentialKind = 'Key' | 'Fido2' | 'Password' | 'Totp';
16
+ export type CredentialFactor = 'first' | 'second' | 'either';
17
+ export type UserActionChallengeResponse = {
18
+ supportedCredentialKinds: {
19
+ kind: CredentialKind;
20
+ factor: CredentialFactor;
21
+ requiresSecondFactor: boolean;
22
+ }[];
23
+ challenge: string;
24
+ challengeIdentifier: string;
25
+ externalAuthenticationUrl: string;
26
+ allowCredentials: {
27
+ key: AllowCredential[];
28
+ webauthn: AllowCredential[];
29
+ };
30
+ };
31
+ export type SignUserActionChallengeRequest = {
32
+ challengeIdentifier: string;
33
+ firstFactor: FirstFactorAssertion;
34
+ secondFactor?: SecondFactorAssertion;
35
+ };
36
+ export type UserActionResponse = {
37
+ userAction: string;
38
+ };
39
+ export type CreateUserLoginChallengeRequest = {
40
+ username: string;
41
+ orgId: string;
42
+ };
43
+ export type UserLoginChallengeResponse = UserActionChallengeResponse;
44
+ export type SignUserLoginChallengeRequest = SignUserActionChallengeRequest;
45
+ export type UserLoginResponse = {
46
+ token: string;
47
+ };
48
+ export declare class BaseAuthApi {
49
+ static createUserActionChallenge(request: CreateUserActionChallengeRequest, options: DfnsBaseApiOptions): Promise<UserActionChallengeResponse>;
50
+ static signUserActionChallenge(request: SignUserActionChallengeRequest, options: DfnsBaseApiOptions): Promise<UserActionResponse>;
51
+ static createUserLoginChallenge(request: CreateUserLoginChallengeRequest, options: DfnsBaseApiOptions): Promise<UserLoginChallengeResponse>;
52
+ static signUserLoginChallenge(request: SignUserLoginChallengeRequest, options: DfnsBaseApiOptions): Promise<UserLoginResponse>;
53
+ }
package/baseAuthApi.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.BaseAuthApi = void 0;
4
+ const fetch_1 = require("./utils/fetch");
5
+ class BaseAuthApi {
6
+ static async createUserActionChallenge(request, options) {
7
+ const response = await (0, fetch_1.simpleFetch)('/auth/action/init', {
8
+ method: 'POST',
9
+ body: request,
10
+ apiOptions: options,
11
+ });
12
+ return response.json();
13
+ }
14
+ static async signUserActionChallenge(request, options) {
15
+ const response = await (0, fetch_1.simpleFetch)('/auth/action', {
16
+ method: 'POST',
17
+ body: request,
18
+ apiOptions: options,
19
+ });
20
+ return response.json();
21
+ }
22
+ static async createUserLoginChallenge(request, options) {
23
+ const response = await (0, fetch_1.simpleFetch)('/auth/login/init', {
24
+ method: 'POST',
25
+ body: request,
26
+ apiOptions: options,
27
+ });
28
+ return response.json();
29
+ }
30
+ static async signUserLoginChallenge(request, options) {
31
+ const response = await (0, fetch_1.simpleFetch)('/auth/login', {
32
+ method: 'POST',
33
+ body: request,
34
+ apiOptions: options,
35
+ });
36
+ return response.json();
37
+ }
38
+ }
39
+ exports.BaseAuthApi = BaseAuthApi;
@@ -0,0 +1,10 @@
1
+ import { DfnsApiClientOptions } from '../../dfnsApiClient';
2
+ import * as T from './types';
3
+ export declare class ApiKeysClient {
4
+ private apiOptions;
5
+ constructor(apiOptions: DfnsApiClientOptions);
6
+ createApiKey(request: T.CreateApiKeyRequest): Promise<T.CreateApiKeyResponse>;
7
+ listApiKeys(): Promise<T.ListApiKeysResponse>;
8
+ revokeApiKey(request: T.RevokeApiKeyRequest): Promise<T.RevokeApiKeyResponse>;
9
+ getApiKeyById(request: T.GetApiKeyByIdRequest): Promise<T.GetApiKeyByIdResponse>;
10
+ }
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApiKeysClient = void 0;
4
+ const fetch_1 = require("../../utils/fetch");
5
+ const url_1 = require("../../utils/url");
6
+ class ApiKeysClient {
7
+ constructor(apiOptions) {
8
+ this.apiOptions = apiOptions;
9
+ }
10
+ async createApiKey(request) {
11
+ const path = (0, url_1.buildPathAndQuery)('/api-keys', {
12
+ path: {},
13
+ query: {},
14
+ });
15
+ const response = await (0, fetch_1.userActionFetch)(path, {
16
+ method: 'POST',
17
+ body: request.body,
18
+ apiOptions: this.apiOptions,
19
+ });
20
+ return response.json();
21
+ }
22
+ async listApiKeys() {
23
+ const path = (0, url_1.buildPathAndQuery)('/api-keys', {
24
+ path: {},
25
+ query: {},
26
+ });
27
+ const response = await (0, fetch_1.simpleFetch)(path, {
28
+ method: 'GET',
29
+ apiOptions: this.apiOptions,
30
+ });
31
+ return response.json();
32
+ }
33
+ async revokeApiKey(request) {
34
+ const path = (0, url_1.buildPathAndQuery)('/api-keys/:apiKeyId', {
35
+ path: { apiKeyId: request.apiKeyId },
36
+ query: {},
37
+ });
38
+ const response = await (0, fetch_1.userActionFetch)(path, {
39
+ method: 'DELETE',
40
+ apiOptions: this.apiOptions,
41
+ });
42
+ return response.json();
43
+ }
44
+ async getApiKeyById(request) {
45
+ const path = (0, url_1.buildPathAndQuery)('/api-keys/:apiKeyId', {
46
+ path: { apiKeyId: request.apiKeyId },
47
+ query: {},
48
+ });
49
+ const response = await (0, fetch_1.simpleFetch)(path, {
50
+ method: 'GET',
51
+ apiOptions: this.apiOptions,
52
+ });
53
+ return response.json();
54
+ }
55
+ }
56
+ exports.ApiKeysClient = ApiKeysClient;
@@ -0,0 +1,13 @@
1
+ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
2
+ import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
3
+ import * as T from './types';
4
+ export declare class DelegatedApiKeysClient {
5
+ private apiOptions;
6
+ constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ createApiKeyInit(request: T.CreateApiKeyRequest): Promise<UserActionChallengeResponse>;
8
+ createApiKeyComplete(request: T.CreateApiKeyRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateApiKeyResponse>;
9
+ listApiKeys(): Promise<T.ListApiKeysResponse>;
10
+ revokeApiKeyInit(request: T.RevokeApiKeyRequest): Promise<UserActionChallengeResponse>;
11
+ revokeApiKeyComplete(request: T.RevokeApiKeyRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.RevokeApiKeyResponse>;
12
+ getApiKeyById(request: T.GetApiKeyByIdRequest): Promise<T.GetApiKeyByIdResponse>;
13
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedApiKeysClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedApiKeysClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async createApiKeyInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/api-keys', {
13
+ path: {},
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 createApiKeyComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/api-keys', {
26
+ path: {},
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 listApiKeys() {
39
+ const path = (0, url_1.buildPathAndQuery)('/api-keys', {
40
+ path: {},
41
+ 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
+ async revokeApiKeyInit(request) {
50
+ const path = (0, url_1.buildPathAndQuery)('/api-keys/:apiKeyId', {
51
+ path: { apiKeyId: request.apiKeyId },
52
+ query: {},
53
+ });
54
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
55
+ userActionHttpMethod: 'DELETE',
56
+ userActionHttpPath: path,
57
+ userActionPayload: JSON.stringify({}),
58
+ userActionServerKind: 'Api',
59
+ }, this.apiOptions);
60
+ return challenge;
61
+ }
62
+ async revokeApiKeyComplete(request, signedChallenge) {
63
+ const path = (0, url_1.buildPathAndQuery)('/api-keys/:apiKeyId', {
64
+ path: { apiKeyId: request.apiKeyId },
65
+ query: {},
66
+ });
67
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
68
+ const response = await (0, fetch_1.simpleFetch)(path, {
69
+ method: 'DELETE',
70
+ body: {},
71
+ headers: { 'x-dfns-useraction': userAction },
72
+ apiOptions: this.apiOptions,
73
+ });
74
+ return response.json();
75
+ }
76
+ async getApiKeyById(request) {
77
+ const path = (0, url_1.buildPathAndQuery)('/api-keys/:apiKeyId', {
78
+ path: { apiKeyId: request.apiKeyId },
79
+ query: {},
80
+ });
81
+ const response = await (0, fetch_1.simpleFetch)(path, {
82
+ method: 'GET',
83
+ apiOptions: this.apiOptions,
84
+ });
85
+ return response.json();
86
+ }
87
+ }
88
+ exports.DelegatedApiKeysClient = DelegatedApiKeysClient;
@@ -0,0 +1,3 @@
1
+ export * from './ApiKeysClient';
2
+ export * from './DelegatedApiKeysClient';
3
+ export * from './types';
@@ -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("./ApiKeysClient"), exports);
18
+ __exportStar(require("./DelegatedApiKeysClient"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,16 @@
1
+ import * as ApiKeys from '../datamodel/ApiKeys';
2
+ export type CreateApiKeyRequest = {
3
+ body: ApiKeys.CreateApiKeyInput;
4
+ };
5
+ export type CreateApiKeyResponse = ApiKeys.ApiKeyRecordWithToken;
6
+ export type ListApiKeysResponse = {
7
+ items: ApiKeys.ApiKeyRecord[];
8
+ };
9
+ export type RevokeApiKeyRequest = {
10
+ apiKeyId: string;
11
+ };
12
+ export type RevokeApiKeyResponse = ApiKeys.ApiKeyRecord;
13
+ export type GetApiKeyByIdRequest = {
14
+ apiKeyId: string;
15
+ };
16
+ export type GetApiKeyByIdResponse = ApiKeys.ApiKeyRecord;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,14 @@
1
+ import { DfnsApiClientOptions } from '../../dfnsApiClient';
2
+ import * as T from './types';
3
+ export declare class AssetsClient {
4
+ private apiOptions;
5
+ constructor(apiOptions: DfnsApiClientOptions);
6
+ initiatePayment(request: T.InitiatePaymentRequest): Promise<T.InitiatePaymentResponse>;
7
+ getPaymentById(request: T.GetPaymentByIdRequest): Promise<T.GetPaymentByIdResponse>;
8
+ listPayments(request: T.ListPaymentsRequest): Promise<T.ListPaymentsResponse>;
9
+ createAssetAccount(request: T.CreateAssetAccountRequest): Promise<T.CreateAssetAccountResponse>;
10
+ getAssetAccountById(request: T.GetAssetAccountByIdRequest): Promise<T.GetAssetAccountByIdResponse>;
11
+ listAssetAccounts(request: T.ListAssetAccountsRequest): Promise<T.ListAssetAccountsResponse>;
12
+ archiveAssetAccount(request: T.ArchiveAssetAccountRequest): Promise<T.ArchiveAssetAccountResponse>;
13
+ getAssetAccountBalanceById(request: T.GetAssetAccountBalanceByIdRequest): Promise<T.GetAssetAccountBalanceByIdResponse>;
14
+ }
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssetsClient = void 0;
4
+ const fetch_1 = require("../../utils/fetch");
5
+ const url_1 = require("../../utils/url");
6
+ class AssetsClient {
7
+ constructor(apiOptions) {
8
+ this.apiOptions = apiOptions;
9
+ }
10
+ async initiatePayment(request) {
11
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments', {
12
+ path: { assetAccountId: request.assetAccountId },
13
+ query: {},
14
+ });
15
+ const response = await (0, fetch_1.userActionFetch)(path, {
16
+ method: 'POST',
17
+ body: request.body,
18
+ apiOptions: this.apiOptions,
19
+ });
20
+ return response.json();
21
+ }
22
+ async getPaymentById(request) {
23
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments/:paymentId', {
24
+ path: {
25
+ assetAccountId: request.assetAccountId,
26
+ paymentId: request.paymentId,
27
+ },
28
+ query: {},
29
+ });
30
+ const response = await (0, fetch_1.simpleFetch)(path, {
31
+ method: 'GET',
32
+ apiOptions: this.apiOptions,
33
+ });
34
+ return response.json();
35
+ }
36
+ async listPayments(request) {
37
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments', {
38
+ path: { assetAccountId: request.assetAccountId },
39
+ query: {},
40
+ });
41
+ const response = await (0, fetch_1.simpleFetch)(path, {
42
+ method: 'GET',
43
+ apiOptions: this.apiOptions,
44
+ });
45
+ return response.json();
46
+ }
47
+ async createAssetAccount(request) {
48
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
49
+ path: {},
50
+ query: {},
51
+ });
52
+ const response = await (0, fetch_1.userActionFetch)(path, {
53
+ method: 'POST',
54
+ body: request.body,
55
+ apiOptions: this.apiOptions,
56
+ });
57
+ return response.json();
58
+ }
59
+ async getAssetAccountById(request) {
60
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId', {
61
+ path: { assetAccountId: request.assetAccountId },
62
+ query: {},
63
+ });
64
+ const response = await (0, fetch_1.simpleFetch)(path, {
65
+ method: 'GET',
66
+ apiOptions: this.apiOptions,
67
+ });
68
+ return response.json();
69
+ }
70
+ async listAssetAccounts(request) {
71
+ var _a;
72
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
73
+ path: {},
74
+ query: (_a = request.query) !== null && _a !== void 0 ? _a : {},
75
+ });
76
+ const response = await (0, fetch_1.simpleFetch)(path, {
77
+ method: 'GET',
78
+ apiOptions: this.apiOptions,
79
+ });
80
+ return response.json();
81
+ }
82
+ async archiveAssetAccount(request) {
83
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId', {
84
+ path: { assetAccountId: request.assetAccountId },
85
+ query: {},
86
+ });
87
+ const response = await (0, fetch_1.userActionFetch)(path, {
88
+ method: 'DELETE',
89
+ apiOptions: this.apiOptions,
90
+ });
91
+ return response.json();
92
+ }
93
+ async getAssetAccountBalanceById(request) {
94
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/balance', {
95
+ path: { assetAccountId: request.assetAccountId },
96
+ query: {},
97
+ });
98
+ const response = await (0, fetch_1.simpleFetch)(path, {
99
+ method: 'GET',
100
+ apiOptions: this.apiOptions,
101
+ });
102
+ return response.json();
103
+ }
104
+ }
105
+ exports.AssetsClient = AssetsClient;
@@ -0,0 +1,18 @@
1
+ import { SignUserActionChallengeRequest, UserActionChallengeResponse } from '../../baseAuthApi';
2
+ import { DfnsDelegatedApiClientOptions } from '../../dfnsDelegatedApiClient';
3
+ import * as T from './types';
4
+ export declare class DelegatedAssetsClient {
5
+ private apiOptions;
6
+ constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ initiatePaymentInit(request: T.InitiatePaymentRequest): Promise<UserActionChallengeResponse>;
8
+ initiatePaymentComplete(request: T.InitiatePaymentRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.InitiatePaymentResponse>;
9
+ getPaymentById(request: T.GetPaymentByIdRequest): Promise<T.GetPaymentByIdResponse>;
10
+ listPayments(request: T.ListPaymentsRequest): Promise<T.ListPaymentsResponse>;
11
+ createAssetAccountInit(request: T.CreateAssetAccountRequest): Promise<UserActionChallengeResponse>;
12
+ createAssetAccountComplete(request: T.CreateAssetAccountRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateAssetAccountResponse>;
13
+ getAssetAccountById(request: T.GetAssetAccountByIdRequest): Promise<T.GetAssetAccountByIdResponse>;
14
+ listAssetAccounts(request: T.ListAssetAccountsRequest): Promise<T.ListAssetAccountsResponse>;
15
+ archiveAssetAccountInit(request: T.ArchiveAssetAccountRequest): Promise<UserActionChallengeResponse>;
16
+ archiveAssetAccountComplete(request: T.ArchiveAssetAccountRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ArchiveAssetAccountResponse>;
17
+ getAssetAccountBalanceById(request: T.GetAssetAccountBalanceByIdRequest): Promise<T.GetAssetAccountBalanceByIdResponse>;
18
+ }
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedAssetsClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedAssetsClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async initiatePaymentInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments', {
13
+ path: { assetAccountId: request.assetAccountId },
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 initiatePaymentComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments', {
26
+ path: { assetAccountId: request.assetAccountId },
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 getPaymentById(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments/:paymentId', {
40
+ path: {
41
+ assetAccountId: request.assetAccountId,
42
+ paymentId: request.paymentId,
43
+ },
44
+ query: {},
45
+ });
46
+ const response = await (0, fetch_1.simpleFetch)(path, {
47
+ method: 'GET',
48
+ apiOptions: this.apiOptions,
49
+ });
50
+ return response.json();
51
+ }
52
+ async listPayments(request) {
53
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/payments', {
54
+ path: { assetAccountId: request.assetAccountId },
55
+ query: {},
56
+ });
57
+ const response = await (0, fetch_1.simpleFetch)(path, {
58
+ method: 'GET',
59
+ apiOptions: this.apiOptions,
60
+ });
61
+ return response.json();
62
+ }
63
+ async createAssetAccountInit(request) {
64
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
65
+ path: {},
66
+ query: {},
67
+ });
68
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
69
+ userActionHttpMethod: 'POST',
70
+ userActionHttpPath: path,
71
+ userActionPayload: JSON.stringify(request.body),
72
+ userActionServerKind: 'Api',
73
+ }, this.apiOptions);
74
+ return challenge;
75
+ }
76
+ async createAssetAccountComplete(request, signedChallenge) {
77
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
78
+ path: {},
79
+ query: {},
80
+ });
81
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
82
+ const response = await (0, fetch_1.simpleFetch)(path, {
83
+ method: 'POST',
84
+ body: request.body,
85
+ headers: { 'x-dfns-useraction': userAction },
86
+ apiOptions: this.apiOptions,
87
+ });
88
+ return response.json();
89
+ }
90
+ async getAssetAccountById(request) {
91
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId', {
92
+ path: { assetAccountId: request.assetAccountId },
93
+ query: {},
94
+ });
95
+ const response = await (0, fetch_1.simpleFetch)(path, {
96
+ method: 'GET',
97
+ apiOptions: this.apiOptions,
98
+ });
99
+ return response.json();
100
+ }
101
+ async listAssetAccounts(request) {
102
+ var _a;
103
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts', {
104
+ path: {},
105
+ query: (_a = request.query) !== null && _a !== void 0 ? _a : {},
106
+ });
107
+ const response = await (0, fetch_1.simpleFetch)(path, {
108
+ method: 'GET',
109
+ apiOptions: this.apiOptions,
110
+ });
111
+ return response.json();
112
+ }
113
+ async archiveAssetAccountInit(request) {
114
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId', {
115
+ path: { assetAccountId: request.assetAccountId },
116
+ query: {},
117
+ });
118
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
119
+ userActionHttpMethod: 'DELETE',
120
+ userActionHttpPath: path,
121
+ userActionPayload: JSON.stringify({}),
122
+ userActionServerKind: 'Api',
123
+ }, this.apiOptions);
124
+ return challenge;
125
+ }
126
+ async archiveAssetAccountComplete(request, signedChallenge) {
127
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId', {
128
+ path: { assetAccountId: request.assetAccountId },
129
+ query: {},
130
+ });
131
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
132
+ const response = await (0, fetch_1.simpleFetch)(path, {
133
+ method: 'DELETE',
134
+ body: {},
135
+ headers: { 'x-dfns-useraction': userAction },
136
+ apiOptions: this.apiOptions,
137
+ });
138
+ return response.json();
139
+ }
140
+ async getAssetAccountBalanceById(request) {
141
+ const path = (0, url_1.buildPathAndQuery)('/assets/asset-accounts/:assetAccountId/balance', {
142
+ path: { assetAccountId: request.assetAccountId },
143
+ query: {},
144
+ });
145
+ const response = await (0, fetch_1.simpleFetch)(path, {
146
+ method: 'GET',
147
+ apiOptions: this.apiOptions,
148
+ });
149
+ return response.json();
150
+ }
151
+ }
152
+ exports.DelegatedAssetsClient = DelegatedAssetsClient;
@@ -0,0 +1,3 @@
1
+ export * from './AssetsClient';
2
+ export * from './DelegatedAssetsClient';
3
+ export * from './types';
@@ -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("./AssetsClient"), exports);
18
+ __exportStar(require("./DelegatedAssetsClient"), exports);
19
+ __exportStar(require("./types"), exports);
@@ -0,0 +1,39 @@
1
+ import * as Assets from '../datamodel/Assets';
2
+ export type InitiatePaymentRequest = {
3
+ assetAccountId: string;
4
+ body: Assets.CreatePaymentInput;
5
+ };
6
+ export type InitiatePaymentResponse = Assets.Payment;
7
+ export type GetPaymentByIdRequest = {
8
+ assetAccountId: string;
9
+ paymentId: string;
10
+ };
11
+ export type GetPaymentByIdResponse = Assets.Payment;
12
+ export type ListPaymentsRequest = {
13
+ assetAccountId: string;
14
+ };
15
+ export type ListPaymentsResponse = Assets.Payment;
16
+ export type CreateAssetAccountRequest = {
17
+ body: Assets.CreateAssetAccountInput;
18
+ };
19
+ export type CreateAssetAccountResponse = Assets.AssetAccount;
20
+ export type GetAssetAccountByIdRequest = {
21
+ assetAccountId: string;
22
+ };
23
+ export type GetAssetAccountByIdResponse = Assets.AssetAccount;
24
+ export type ListAssetAccountsRequest = {
25
+ query?: {
26
+ status?: Assets.AssetAccountStatus;
27
+ };
28
+ };
29
+ export type ListAssetAccountsResponse = {
30
+ items: Assets.AssetAccount[];
31
+ };
32
+ export type ArchiveAssetAccountRequest = {
33
+ assetAccountId: string;
34
+ };
35
+ export type ArchiveAssetAccountResponse = Assets.AssetAccount;
36
+ export type GetAssetAccountBalanceByIdRequest = {
37
+ assetAccountId: string;
38
+ };
39
+ export type GetAssetAccountBalanceByIdResponse = Assets.AssetAccountBalance;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });