@dfns/sdk 0.2.0 → 0.2.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.
@@ -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 DelegatedPoliciesClient {
5
+ private apiOptions;
6
+ constructor(apiOptions: DfnsDelegatedApiClientOptions);
7
+ archivePolicyInit(request: T.ArchivePolicyRequest): Promise<UserActionChallengeResponse>;
8
+ archivePolicyComplete(request: T.ArchivePolicyRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.ArchivePolicyResponse>;
9
+ createApprovalDecisionInit(request: T.CreateApprovalDecisionRequest): Promise<UserActionChallengeResponse>;
10
+ createApprovalDecisionComplete(request: T.CreateApprovalDecisionRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreateApprovalDecisionResponse>;
11
+ createPolicyInit(request: T.CreatePolicyRequest): Promise<UserActionChallengeResponse>;
12
+ createPolicyComplete(request: T.CreatePolicyRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.CreatePolicyResponse>;
13
+ getPolicy(request: T.GetPolicyRequest): Promise<T.GetPolicyResponse>;
14
+ listApprovals(request?: T.ListApprovalsRequest): Promise<T.ListApprovalsResponse>;
15
+ listPolicies(request?: T.ListPoliciesRequest): Promise<T.ListPoliciesResponse>;
16
+ updatePolicyInit(request: T.UpdatePolicyRequest): Promise<UserActionChallengeResponse>;
17
+ updatePolicyComplete(request: T.UpdatePolicyRequest, signedChallenge: SignUserActionChallengeRequest): Promise<T.UpdatePolicyResponse>;
18
+ }
@@ -0,0 +1,153 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DelegatedPoliciesClient = void 0;
4
+ const baseAuthApi_1 = require("../../baseAuthApi");
5
+ const fetch_1 = require("../../utils/fetch");
6
+ const url_1 = require("../../utils/url");
7
+ class DelegatedPoliciesClient {
8
+ constructor(apiOptions) {
9
+ this.apiOptions = apiOptions;
10
+ }
11
+ async archivePolicyInit(request) {
12
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies/:policyId', {
13
+ path: request ?? {},
14
+ query: {},
15
+ });
16
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
17
+ userActionHttpMethod: 'DELETE',
18
+ userActionHttpPath: path,
19
+ userActionPayload: JSON.stringify({}),
20
+ userActionServerKind: 'Api',
21
+ }, this.apiOptions);
22
+ return challenge;
23
+ }
24
+ async archivePolicyComplete(request, signedChallenge) {
25
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies/:policyId', {
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: 'DELETE',
32
+ body: {},
33
+ headers: { 'x-dfns-useraction': userAction },
34
+ apiOptions: this.apiOptions,
35
+ });
36
+ return response.json();
37
+ }
38
+ async createApprovalDecisionInit(request) {
39
+ const path = (0, url_1.buildPathAndQuery)('/v2/policy-approvals/:approvalId/decisions', {
40
+ path: request ?? {},
41
+ query: {},
42
+ });
43
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
44
+ userActionHttpMethod: 'POST',
45
+ userActionHttpPath: path,
46
+ userActionPayload: JSON.stringify(request.body),
47
+ userActionServerKind: 'Api',
48
+ }, this.apiOptions);
49
+ return challenge;
50
+ }
51
+ async createApprovalDecisionComplete(request, signedChallenge) {
52
+ const path = (0, url_1.buildPathAndQuery)('/v2/policy-approvals/:approvalId/decisions', {
53
+ path: request ?? {},
54
+ query: {},
55
+ });
56
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
57
+ const response = await (0, fetch_1.simpleFetch)(path, {
58
+ method: 'POST',
59
+ body: request.body,
60
+ headers: { 'x-dfns-useraction': userAction },
61
+ apiOptions: this.apiOptions,
62
+ });
63
+ return response.json();
64
+ }
65
+ async createPolicyInit(request) {
66
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies', {
67
+ path: request ?? {},
68
+ query: {},
69
+ });
70
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
71
+ userActionHttpMethod: 'POST',
72
+ userActionHttpPath: path,
73
+ userActionPayload: JSON.stringify(request.body),
74
+ userActionServerKind: 'Api',
75
+ }, this.apiOptions);
76
+ return challenge;
77
+ }
78
+ async createPolicyComplete(request, signedChallenge) {
79
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies', {
80
+ path: request ?? {},
81
+ query: {},
82
+ });
83
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
84
+ const response = await (0, fetch_1.simpleFetch)(path, {
85
+ method: 'POST',
86
+ body: request.body,
87
+ headers: { 'x-dfns-useraction': userAction },
88
+ apiOptions: this.apiOptions,
89
+ });
90
+ return response.json();
91
+ }
92
+ async getPolicy(request) {
93
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies/:policyId', {
94
+ path: request ?? {},
95
+ query: {},
96
+ });
97
+ const response = await (0, fetch_1.simpleFetch)(path, {
98
+ method: 'GET',
99
+ apiOptions: this.apiOptions,
100
+ });
101
+ return response.json();
102
+ }
103
+ async listApprovals(request) {
104
+ const path = (0, url_1.buildPathAndQuery)('/v2/policy-approvals', {
105
+ path: request ?? {},
106
+ query: request?.query ?? {},
107
+ });
108
+ const response = await (0, fetch_1.simpleFetch)(path, {
109
+ method: 'GET',
110
+ apiOptions: this.apiOptions,
111
+ });
112
+ return response.json();
113
+ }
114
+ async listPolicies(request) {
115
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies', {
116
+ path: request ?? {},
117
+ query: request?.query ?? {},
118
+ });
119
+ const response = await (0, fetch_1.simpleFetch)(path, {
120
+ method: 'GET',
121
+ apiOptions: this.apiOptions,
122
+ });
123
+ return response.json();
124
+ }
125
+ async updatePolicyInit(request) {
126
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies/:policyId', {
127
+ path: request ?? {},
128
+ query: {},
129
+ });
130
+ const challenge = await baseAuthApi_1.BaseAuthApi.createUserActionChallenge({
131
+ userActionHttpMethod: 'PUT',
132
+ userActionHttpPath: path,
133
+ userActionPayload: JSON.stringify(request.body),
134
+ userActionServerKind: 'Api',
135
+ }, this.apiOptions);
136
+ return challenge;
137
+ }
138
+ async updatePolicyComplete(request, signedChallenge) {
139
+ const path = (0, url_1.buildPathAndQuery)('/v2/policies/:policyId', {
140
+ path: request ?? {},
141
+ query: {},
142
+ });
143
+ const { userAction } = await baseAuthApi_1.BaseAuthApi.signUserActionChallenge(signedChallenge, this.apiOptions);
144
+ const response = await (0, fetch_1.simpleFetch)(path, {
145
+ method: 'PUT',
146
+ body: request.body,
147
+ headers: { 'x-dfns-useraction': userAction },
148
+ apiOptions: this.apiOptions,
149
+ });
150
+ return response.json();
151
+ }
152
+ }
153
+ exports.DelegatedPoliciesClient = DelegatedPoliciesClient;
@@ -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);