@permission-protocol/sdk 0.1.0-alpha.3 → 0.1.0
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/LICENSE +21 -0
- package/README.md +61 -28
- package/dist/index.cjs +274 -0
- package/dist/index.d.cts +81 -0
- package/dist/index.d.ts +70 -286
- package/dist/index.js +208 -325
- package/package.json +30 -35
- package/dist/index.d.mts +0 -297
- package/dist/index.mjs +0 -325
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Permission Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,45 +1,78 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @permissionprotocol/sdk
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
> **No receipt = unauthorized autonomy**
|
|
3
|
+
Official JavaScript/TypeScript SDK for Permission Protocol.
|
|
6
4
|
|
|
7
5
|
## Install
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
npm
|
|
8
|
+
npm install @permissionprotocol/sdk
|
|
11
9
|
```
|
|
12
10
|
|
|
13
|
-
##
|
|
11
|
+
## Quickstart
|
|
14
12
|
|
|
15
|
-
```
|
|
16
|
-
import {
|
|
13
|
+
```ts
|
|
14
|
+
import { configure, authorize } from "@permissionprotocol/sdk";
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
configure("pp_live_xxx", "https://app.permissionprotocol.com");
|
|
17
|
+
|
|
18
|
+
const receipt = await authorize(
|
|
19
|
+
"deploy",
|
|
20
|
+
"billing-service",
|
|
21
|
+
"deploy-bot",
|
|
22
|
+
{ pr: 42 },
|
|
23
|
+
true,
|
|
24
|
+
300
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
console.log(receipt.id);
|
|
28
|
+
console.log(receipt.status);
|
|
29
|
+
console.log(receipt.valid);
|
|
30
|
+
console.log(receipt.json());
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
You can skip `configure()` by setting:
|
|
34
|
+
|
|
35
|
+
- `PP_API_KEY` (required)
|
|
36
|
+
- `PP_BASE_URL` (optional, defaults to `https://app.permissionprotocol.com`)
|
|
37
|
+
|
|
38
|
+
## API
|
|
39
|
+
|
|
40
|
+
### `configure(apiKey, baseUrl?)`
|
|
41
|
+
|
|
42
|
+
Set SDK credentials and API base URL.
|
|
43
|
+
|
|
44
|
+
### `authorize(action, resource, actor?, metadata?, wait?, timeout?)`
|
|
45
|
+
|
|
46
|
+
Create an approval request and return a `Receipt`.
|
|
47
|
+
When `wait` is `true` (default), the SDK polls until approved, denied, expired, or timeout.
|
|
48
|
+
|
|
49
|
+
### `verify(receiptId)`
|
|
50
|
+
|
|
51
|
+
Verify a receipt and return a `Receipt` with `.valid`.
|
|
52
|
+
|
|
53
|
+
### `requireApproval(options)`
|
|
54
|
+
|
|
55
|
+
Higher-order wrapper for function execution:
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import { requireApproval } from "@permissionprotocol/sdk";
|
|
22
59
|
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
input: { id: 123, value: 'hello' },
|
|
60
|
+
const deploy = requireApproval({
|
|
61
|
+
resource: "billing-service",
|
|
62
|
+
action: "deploy"
|
|
63
|
+
})(async () => {
|
|
64
|
+
return "deploy complete";
|
|
29
65
|
});
|
|
30
66
|
|
|
31
|
-
|
|
32
|
-
throw new Error(`Blocked: ${decision.status}`);
|
|
33
|
-
}
|
|
67
|
+
await deploy();
|
|
34
68
|
```
|
|
35
69
|
|
|
36
|
-
##
|
|
70
|
+
## Exceptions
|
|
37
71
|
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
72
|
+
- `PermissionProtocolError`
|
|
73
|
+
- `PermissionDenied`
|
|
74
|
+
- `ApprovalTimeout`
|
|
41
75
|
|
|
42
|
-
|
|
76
|
+
## License
|
|
43
77
|
|
|
44
|
-
|
|
45
|
-
Policy evaluation and enforcement live in the hosted Permission Protocol.
|
|
78
|
+
MIT
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
ApprovalTimeout: () => ApprovalTimeout,
|
|
24
|
+
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
25
|
+
PermissionDenied: () => PermissionDenied,
|
|
26
|
+
PermissionProtocolError: () => PermissionProtocolError,
|
|
27
|
+
Receipt: () => Receipt,
|
|
28
|
+
authorize: () => authorize,
|
|
29
|
+
configure: () => configure,
|
|
30
|
+
requireApproval: () => requireApproval,
|
|
31
|
+
verify: () => verify
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(index_exports);
|
|
34
|
+
|
|
35
|
+
// src/exceptions.ts
|
|
36
|
+
var PermissionProtocolError = class extends Error {
|
|
37
|
+
constructor(message) {
|
|
38
|
+
super(message);
|
|
39
|
+
this.name = "PermissionProtocolError";
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
var PermissionDenied = class extends PermissionProtocolError {
|
|
43
|
+
constructor(message = "Permission was denied.") {
|
|
44
|
+
super(message);
|
|
45
|
+
this.name = "PermissionDenied";
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
var ApprovalTimeout = class extends PermissionProtocolError {
|
|
49
|
+
constructor(message = "Approval request timed out.") {
|
|
50
|
+
super(message);
|
|
51
|
+
this.name = "ApprovalTimeout";
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/config.ts
|
|
56
|
+
var DEFAULT_BASE_URL = "https://app.permissionprotocol.com";
|
|
57
|
+
var configuredApiKey;
|
|
58
|
+
var configuredBaseUrl;
|
|
59
|
+
function normalizeBaseUrl(value) {
|
|
60
|
+
return value.replace(/\/+$/, "");
|
|
61
|
+
}
|
|
62
|
+
function configure(apiKey, baseUrl) {
|
|
63
|
+
const resolvedApiKey = apiKey ?? process.env.PP_API_KEY;
|
|
64
|
+
const resolvedBaseUrl = baseUrl ?? process.env.PP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
65
|
+
if (!resolvedApiKey) {
|
|
66
|
+
throw new PermissionProtocolError("Permission Protocol API key is required.");
|
|
67
|
+
}
|
|
68
|
+
configuredApiKey = resolvedApiKey;
|
|
69
|
+
configuredBaseUrl = normalizeBaseUrl(resolvedBaseUrl);
|
|
70
|
+
return {
|
|
71
|
+
apiKey: configuredApiKey,
|
|
72
|
+
baseUrl: configuredBaseUrl
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function getConfig() {
|
|
76
|
+
const apiKey = configuredApiKey ?? process.env.PP_API_KEY;
|
|
77
|
+
const baseUrl = configuredBaseUrl ?? process.env.PP_BASE_URL ?? DEFAULT_BASE_URL;
|
|
78
|
+
if (!apiKey) {
|
|
79
|
+
throw new PermissionProtocolError(
|
|
80
|
+
"Permission Protocol API key is not configured. Call configure(apiKey) or set PP_API_KEY."
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
apiKey,
|
|
85
|
+
baseUrl: normalizeBaseUrl(baseUrl)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/receipt.ts
|
|
90
|
+
var Receipt = class {
|
|
91
|
+
constructor(payload) {
|
|
92
|
+
this.payload = { ...payload };
|
|
93
|
+
this.id = payload.id;
|
|
94
|
+
this.status = payload.status;
|
|
95
|
+
this.action = payload.action;
|
|
96
|
+
this.resource = payload.resource;
|
|
97
|
+
this.actor = payload.actor;
|
|
98
|
+
this.approvedBy = payload.approved_by;
|
|
99
|
+
this.policy = payload.policy;
|
|
100
|
+
this.signature = payload.signature;
|
|
101
|
+
this.issuer = payload.issuer;
|
|
102
|
+
this.timestamp = payload.timestamp;
|
|
103
|
+
this.expiresAt = payload.expires_at;
|
|
104
|
+
this.url = payload.url;
|
|
105
|
+
this.isValid = Boolean(payload.valid);
|
|
106
|
+
}
|
|
107
|
+
get valid() {
|
|
108
|
+
return this.isValid;
|
|
109
|
+
}
|
|
110
|
+
json() {
|
|
111
|
+
return { ...this.payload, valid: this.isValid };
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
// src/sdk.ts
|
|
116
|
+
var import_node_os = require("os");
|
|
117
|
+
|
|
118
|
+
// src/client.ts
|
|
119
|
+
function createHeaders(apiKey) {
|
|
120
|
+
return {
|
|
121
|
+
"Content-Type": "application/json",
|
|
122
|
+
"X-PP-API-Key": apiKey
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function getErrorMessage(status, fallback, body) {
|
|
126
|
+
if (body && typeof body === "object") {
|
|
127
|
+
const maybeErr = body;
|
|
128
|
+
if (maybeErr.error && typeof maybeErr.error === "string") {
|
|
129
|
+
return maybeErr.error;
|
|
130
|
+
}
|
|
131
|
+
if (maybeErr.message && typeof maybeErr.message === "string") {
|
|
132
|
+
return maybeErr.message;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return `${fallback} (HTTP ${status})`;
|
|
136
|
+
}
|
|
137
|
+
async function postAuthorize(payload) {
|
|
138
|
+
const { apiKey, baseUrl } = getConfig();
|
|
139
|
+
const response = await fetch(`${baseUrl}/api/v1/receipts/verify`, {
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: createHeaders(apiKey),
|
|
142
|
+
body: JSON.stringify({
|
|
143
|
+
scope: payload,
|
|
144
|
+
failOnMissing: true
|
|
145
|
+
})
|
|
146
|
+
});
|
|
147
|
+
const body = await response.json().catch(() => ({}));
|
|
148
|
+
if (!response.ok) {
|
|
149
|
+
throw new PermissionProtocolError(getErrorMessage(response.status, "Authorization failed", body));
|
|
150
|
+
}
|
|
151
|
+
return body;
|
|
152
|
+
}
|
|
153
|
+
async function getReceipt(receiptId) {
|
|
154
|
+
const { apiKey, baseUrl } = getConfig();
|
|
155
|
+
const response = await fetch(`${baseUrl}/api/v1/receipts/${encodeURIComponent(receiptId)}`, {
|
|
156
|
+
method: "GET",
|
|
157
|
+
headers: createHeaders(apiKey)
|
|
158
|
+
});
|
|
159
|
+
const body = await response.json().catch(() => ({}));
|
|
160
|
+
if (!response.ok) {
|
|
161
|
+
throw new PermissionProtocolError(
|
|
162
|
+
getErrorMessage(response.status, `Failed to fetch receipt ${receiptId}`, body)
|
|
163
|
+
);
|
|
164
|
+
}
|
|
165
|
+
if (body && typeof body === "object" && "receipt" in body) {
|
|
166
|
+
return body.receipt;
|
|
167
|
+
}
|
|
168
|
+
return body;
|
|
169
|
+
}
|
|
170
|
+
async function postVerify(receiptId) {
|
|
171
|
+
const { apiKey, baseUrl } = getConfig();
|
|
172
|
+
const response = await fetch(`${baseUrl}/api/v1/receipts/verify`, {
|
|
173
|
+
method: "POST",
|
|
174
|
+
headers: createHeaders(apiKey),
|
|
175
|
+
body: JSON.stringify({
|
|
176
|
+
receiptId
|
|
177
|
+
})
|
|
178
|
+
});
|
|
179
|
+
const body = await response.json().catch(() => ({}));
|
|
180
|
+
if (!response.ok) {
|
|
181
|
+
throw new PermissionProtocolError(getErrorMessage(response.status, "Verification failed", body));
|
|
182
|
+
}
|
|
183
|
+
return body;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// src/sdk.ts
|
|
187
|
+
var DEFAULT_TIMEOUT_SECONDS = 300;
|
|
188
|
+
var DEFAULT_POLL_INTERVAL_MS = 2e3;
|
|
189
|
+
var MAX_POLL_INTERVAL_MS = 1e4;
|
|
190
|
+
function sleep(ms) {
|
|
191
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
192
|
+
}
|
|
193
|
+
function asReceipt(data, fallbackId) {
|
|
194
|
+
if (!data?.id && !fallbackId) {
|
|
195
|
+
throw new PermissionProtocolError("Missing receipt data in API response.");
|
|
196
|
+
}
|
|
197
|
+
return new Receipt({
|
|
198
|
+
id: data?.id ?? fallbackId ?? "",
|
|
199
|
+
status: data?.status ?? "PENDING",
|
|
200
|
+
...data
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
async function authorize(action, resource, actor, metadata, wait = true, timeout = DEFAULT_TIMEOUT_SECONDS) {
|
|
204
|
+
const params = { action, resource, actor, metadata, wait, timeout };
|
|
205
|
+
const resolvedActor = params.actor ?? (0, import_node_os.hostname)();
|
|
206
|
+
const response = await postAuthorize({
|
|
207
|
+
action: params.action,
|
|
208
|
+
resource: params.resource,
|
|
209
|
+
actor: resolvedActor,
|
|
210
|
+
metadata: params.metadata
|
|
211
|
+
});
|
|
212
|
+
const receipt = asReceipt(response.receipt, response.requestId);
|
|
213
|
+
if (response.approvalUrl) {
|
|
214
|
+
console.log(`Approval URL: ${response.approvalUrl}`);
|
|
215
|
+
}
|
|
216
|
+
if (!params.wait) {
|
|
217
|
+
return receipt;
|
|
218
|
+
}
|
|
219
|
+
const timeoutMs = Math.max(1, params.timeout ?? DEFAULT_TIMEOUT_SECONDS) * 1e3;
|
|
220
|
+
const deadline = Date.now() + timeoutMs;
|
|
221
|
+
let pollInterval = DEFAULT_POLL_INTERVAL_MS;
|
|
222
|
+
while (Date.now() < deadline) {
|
|
223
|
+
const current = await getReceipt(receipt.id);
|
|
224
|
+
const currentReceipt = asReceipt(current, receipt.id);
|
|
225
|
+
if (currentReceipt.status === "APPROVED") {
|
|
226
|
+
return currentReceipt;
|
|
227
|
+
}
|
|
228
|
+
if (currentReceipt.status === "DENIED" || currentReceipt.status === "EXPIRED") {
|
|
229
|
+
throw new PermissionDenied(`Approval request ${receipt.id} ended with status ${currentReceipt.status}.`);
|
|
230
|
+
}
|
|
231
|
+
await sleep(pollInterval);
|
|
232
|
+
pollInterval = Math.min(MAX_POLL_INTERVAL_MS, Math.floor(pollInterval * 1.5));
|
|
233
|
+
}
|
|
234
|
+
throw new ApprovalTimeout(
|
|
235
|
+
`Approval request ${receipt.id} was not approved within ${Math.floor(timeoutMs / 1e3)} seconds.`
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
async function verify(receiptId) {
|
|
239
|
+
const result = await postVerify(receiptId);
|
|
240
|
+
const payload = result.receipt ?? { id: receiptId, status: "PENDING" };
|
|
241
|
+
return new Receipt({
|
|
242
|
+
...payload,
|
|
243
|
+
id: payload.id ?? receiptId,
|
|
244
|
+
valid: Boolean(result.valid)
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
function requireApproval(options) {
|
|
248
|
+
return function withApproval(fn) {
|
|
249
|
+
return async (...args) => {
|
|
250
|
+
const action = options.action ?? fn.name ?? "action";
|
|
251
|
+
await authorize(
|
|
252
|
+
action,
|
|
253
|
+
options.resource,
|
|
254
|
+
options.actor,
|
|
255
|
+
options.metadata,
|
|
256
|
+
options.wait ?? true,
|
|
257
|
+
options.timeout ?? DEFAULT_TIMEOUT_SECONDS
|
|
258
|
+
);
|
|
259
|
+
return fn(...args);
|
|
260
|
+
};
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
264
|
+
0 && (module.exports = {
|
|
265
|
+
ApprovalTimeout,
|
|
266
|
+
DEFAULT_BASE_URL,
|
|
267
|
+
PermissionDenied,
|
|
268
|
+
PermissionProtocolError,
|
|
269
|
+
Receipt,
|
|
270
|
+
authorize,
|
|
271
|
+
configure,
|
|
272
|
+
requireApproval,
|
|
273
|
+
verify
|
|
274
|
+
});
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
declare const DEFAULT_BASE_URL = "https://app.permissionprotocol.com";
|
|
2
|
+
interface SDKConfig {
|
|
3
|
+
apiKey: string;
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
}
|
|
6
|
+
declare function configure(apiKey?: string, baseUrl?: string): SDKConfig;
|
|
7
|
+
|
|
8
|
+
declare class PermissionProtocolError extends Error {
|
|
9
|
+
constructor(message: string);
|
|
10
|
+
}
|
|
11
|
+
declare class PermissionDenied extends PermissionProtocolError {
|
|
12
|
+
constructor(message?: string);
|
|
13
|
+
}
|
|
14
|
+
declare class ApprovalTimeout extends PermissionProtocolError {
|
|
15
|
+
constructor(message?: string);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ReceiptStatus = "APPROVED" | "DENIED" | "PENDING" | "EXPIRED" | string;
|
|
19
|
+
interface ReceiptData {
|
|
20
|
+
id: string;
|
|
21
|
+
status: ReceiptStatus;
|
|
22
|
+
action?: string;
|
|
23
|
+
resource?: string;
|
|
24
|
+
actor?: string;
|
|
25
|
+
approved_by?: string | null;
|
|
26
|
+
policy?: string | null;
|
|
27
|
+
signature?: string | null;
|
|
28
|
+
issuer?: string;
|
|
29
|
+
timestamp?: string;
|
|
30
|
+
expires_at?: string | null;
|
|
31
|
+
url?: string;
|
|
32
|
+
valid?: boolean;
|
|
33
|
+
[key: string]: unknown;
|
|
34
|
+
}
|
|
35
|
+
interface AuthorizeParams {
|
|
36
|
+
action: string;
|
|
37
|
+
resource: string;
|
|
38
|
+
actor?: string;
|
|
39
|
+
metadata?: Record<string, unknown>;
|
|
40
|
+
wait?: boolean;
|
|
41
|
+
timeout?: number;
|
|
42
|
+
}
|
|
43
|
+
interface VerifyResponse {
|
|
44
|
+
valid: boolean;
|
|
45
|
+
receipt?: ReceiptData;
|
|
46
|
+
[key: string]: unknown;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
declare class Receipt {
|
|
50
|
+
readonly id: string;
|
|
51
|
+
readonly status: ReceiptStatus;
|
|
52
|
+
readonly action?: string;
|
|
53
|
+
readonly resource?: string;
|
|
54
|
+
readonly actor?: string;
|
|
55
|
+
readonly approvedBy?: string | null;
|
|
56
|
+
readonly policy?: string | null;
|
|
57
|
+
readonly signature?: string | null;
|
|
58
|
+
readonly issuer?: string;
|
|
59
|
+
readonly timestamp?: string;
|
|
60
|
+
readonly expiresAt?: string | null;
|
|
61
|
+
readonly url?: string;
|
|
62
|
+
private readonly payload;
|
|
63
|
+
private readonly isValid;
|
|
64
|
+
constructor(payload: ReceiptData);
|
|
65
|
+
get valid(): boolean;
|
|
66
|
+
json(): ReceiptData;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
declare function authorize(action: string, resource: string, actor?: string, metadata?: Record<string, unknown>, wait?: boolean, timeout?: number): Promise<Receipt>;
|
|
70
|
+
declare function verify(receiptId: string): Promise<Receipt>;
|
|
71
|
+
interface RequireApprovalOptions {
|
|
72
|
+
action?: string;
|
|
73
|
+
resource: string;
|
|
74
|
+
actor?: string;
|
|
75
|
+
metadata?: Record<string, unknown>;
|
|
76
|
+
wait?: boolean;
|
|
77
|
+
timeout?: number;
|
|
78
|
+
}
|
|
79
|
+
declare function requireApproval(options: RequireApprovalOptions): <TArgs extends unknown[], TResult>(fn: (...args: TArgs) => TResult | Promise<TResult>) => (...args: TArgs) => Promise<TResult>;
|
|
80
|
+
|
|
81
|
+
export { ApprovalTimeout, type AuthorizeParams, DEFAULT_BASE_URL, PermissionDenied, PermissionProtocolError, Receipt, type ReceiptData, type ReceiptStatus, type RequireApprovalOptions, type SDKConfig, type VerifyResponse, authorize, configure, requireApproval, verify };
|