@unkey/api 0.17.0 → 0.19.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 +68 -81
- package/dist/index.d.mts +75 -504
- package/dist/index.d.ts +75 -504
- package/dist/index.js +8 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +9 -5
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { PermissionQuery } from '@unkey/rbac';
|
|
2
|
+
export { Flatten, and, or } from '@unkey/rbac';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* This file was auto-generated by openapi-typescript.
|
|
3
6
|
* Do not make direct changes to the file.
|
|
@@ -249,7 +252,7 @@ interface paths {
|
|
|
249
252
|
[key: string]: unknown;
|
|
250
253
|
};
|
|
251
254
|
/**
|
|
252
|
-
* @description A list of roles that this key should have.
|
|
255
|
+
* @description A list of roles that this key should have. If the role does not exist, an error is thrown
|
|
253
256
|
* @example [
|
|
254
257
|
* "admin",
|
|
255
258
|
* "finance"
|
|
@@ -311,6 +314,17 @@ interface paths {
|
|
|
311
314
|
* @example false
|
|
312
315
|
*/
|
|
313
316
|
enabled?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* @description Environments allow you to divide your keyspace.
|
|
319
|
+
*
|
|
320
|
+
* Some applications like Stripe, Clerk, WorkOS and others have a concept of "live" and "test" keys to
|
|
321
|
+
* give the developer a way to develop their own application without the risk of modifying real world
|
|
322
|
+
* resources.
|
|
323
|
+
*
|
|
324
|
+
* When you set an environment, we will return it back to you when validating the key, so you can
|
|
325
|
+
* handle it correctly.
|
|
326
|
+
*/
|
|
327
|
+
environment?: string;
|
|
314
328
|
};
|
|
315
329
|
};
|
|
316
330
|
};
|
|
@@ -670,7 +684,7 @@ interface paths {
|
|
|
670
684
|
};
|
|
671
685
|
};
|
|
672
686
|
responses: {
|
|
673
|
-
/** @description
|
|
687
|
+
/** @description Usage numbers over time */
|
|
674
688
|
200: {
|
|
675
689
|
content: {
|
|
676
690
|
"application/json": {
|
|
@@ -1026,232 +1040,6 @@ interface paths {
|
|
|
1026
1040
|
};
|
|
1027
1041
|
};
|
|
1028
1042
|
};
|
|
1029
|
-
"/v1/keys/{keyId}": {
|
|
1030
|
-
put: {
|
|
1031
|
-
parameters: {
|
|
1032
|
-
path: {
|
|
1033
|
-
keyId: string;
|
|
1034
|
-
};
|
|
1035
|
-
};
|
|
1036
|
-
requestBody: {
|
|
1037
|
-
content: {
|
|
1038
|
-
"application/json": {
|
|
1039
|
-
/**
|
|
1040
|
-
* @description The name of the key
|
|
1041
|
-
* @example Customer X
|
|
1042
|
-
*/
|
|
1043
|
-
name?: string | null;
|
|
1044
|
-
/**
|
|
1045
|
-
* @description The id of the tenant associated with this key. Use whatever reference you have in your system to identify the tenant. When verifying the key, we will send this field back to you, so you know who is accessing your API.
|
|
1046
|
-
* @example user_123
|
|
1047
|
-
*/
|
|
1048
|
-
ownerId?: string | null;
|
|
1049
|
-
/**
|
|
1050
|
-
* @description Any additional metadata you want to store with the key
|
|
1051
|
-
* @example {
|
|
1052
|
-
* "roles": [
|
|
1053
|
-
* "admin",
|
|
1054
|
-
* "user"
|
|
1055
|
-
* ],
|
|
1056
|
-
* "stripeCustomerId": "cus_1234"
|
|
1057
|
-
* }
|
|
1058
|
-
*/
|
|
1059
|
-
meta?: {
|
|
1060
|
-
[key: string]: unknown;
|
|
1061
|
-
} | null;
|
|
1062
|
-
/**
|
|
1063
|
-
* @description The unix timestamp in milliseconds when the key will expire. If this field is null or undefined, the key is not expiring.
|
|
1064
|
-
* @example 0
|
|
1065
|
-
*/
|
|
1066
|
-
expires?: number | null;
|
|
1067
|
-
/**
|
|
1068
|
-
* @description Unkey comes with per-key ratelimiting out of the box. Set `null` to disable.
|
|
1069
|
-
* @example {
|
|
1070
|
-
* "type": "fast",
|
|
1071
|
-
* "limit": 10,
|
|
1072
|
-
* "refillRate": 1,
|
|
1073
|
-
* "refillInterval": 60
|
|
1074
|
-
* }
|
|
1075
|
-
*/
|
|
1076
|
-
ratelimit?: ({
|
|
1077
|
-
/**
|
|
1078
|
-
* @description Fast ratelimiting doesn't add latency, while consistent ratelimiting is more accurate.
|
|
1079
|
-
* @enum {string}
|
|
1080
|
-
*/
|
|
1081
|
-
type: "fast" | "consistent";
|
|
1082
|
-
/** @description The total amount of burstable requests. */
|
|
1083
|
-
limit: number;
|
|
1084
|
-
/** @description How many tokens to refill during each refillInterval. */
|
|
1085
|
-
refillRate: number;
|
|
1086
|
-
/** @description Determines the speed at which tokens are refilled, in milliseconds. */
|
|
1087
|
-
refillInterval: number;
|
|
1088
|
-
}) | null;
|
|
1089
|
-
/**
|
|
1090
|
-
* @description The number of requests that can be made with this key before it becomes invalid. Set `null` to disable.
|
|
1091
|
-
* @example 1000
|
|
1092
|
-
*/
|
|
1093
|
-
remaining?: number | null;
|
|
1094
|
-
};
|
|
1095
|
-
};
|
|
1096
|
-
};
|
|
1097
|
-
responses: {
|
|
1098
|
-
/** @description The key was successfully updated, it may take up to 30s for this to take effect in all regions */
|
|
1099
|
-
200: {
|
|
1100
|
-
content: {
|
|
1101
|
-
"application/json": Record<string, never>;
|
|
1102
|
-
};
|
|
1103
|
-
};
|
|
1104
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1105
|
-
400: {
|
|
1106
|
-
content: {
|
|
1107
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1108
|
-
};
|
|
1109
|
-
};
|
|
1110
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1111
|
-
401: {
|
|
1112
|
-
content: {
|
|
1113
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1114
|
-
};
|
|
1115
|
-
};
|
|
1116
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1117
|
-
403: {
|
|
1118
|
-
content: {
|
|
1119
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1120
|
-
};
|
|
1121
|
-
};
|
|
1122
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1123
|
-
404: {
|
|
1124
|
-
content: {
|
|
1125
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1126
|
-
};
|
|
1127
|
-
};
|
|
1128
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1129
|
-
409: {
|
|
1130
|
-
content: {
|
|
1131
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1132
|
-
};
|
|
1133
|
-
};
|
|
1134
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1135
|
-
429: {
|
|
1136
|
-
content: {
|
|
1137
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1138
|
-
};
|
|
1139
|
-
};
|
|
1140
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1141
|
-
500: {
|
|
1142
|
-
content: {
|
|
1143
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1144
|
-
};
|
|
1145
|
-
};
|
|
1146
|
-
};
|
|
1147
|
-
};
|
|
1148
|
-
};
|
|
1149
|
-
"/v1/keys/:keyId": {
|
|
1150
|
-
get: {
|
|
1151
|
-
responses: {
|
|
1152
|
-
/** @description The configuration for a single key */
|
|
1153
|
-
200: {
|
|
1154
|
-
content: {
|
|
1155
|
-
"application/json": components["schemas"]["Key"];
|
|
1156
|
-
};
|
|
1157
|
-
};
|
|
1158
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1159
|
-
400: {
|
|
1160
|
-
content: {
|
|
1161
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1162
|
-
};
|
|
1163
|
-
};
|
|
1164
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1165
|
-
401: {
|
|
1166
|
-
content: {
|
|
1167
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1168
|
-
};
|
|
1169
|
-
};
|
|
1170
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1171
|
-
403: {
|
|
1172
|
-
content: {
|
|
1173
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1174
|
-
};
|
|
1175
|
-
};
|
|
1176
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1177
|
-
404: {
|
|
1178
|
-
content: {
|
|
1179
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1180
|
-
};
|
|
1181
|
-
};
|
|
1182
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1183
|
-
409: {
|
|
1184
|
-
content: {
|
|
1185
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1186
|
-
};
|
|
1187
|
-
};
|
|
1188
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1189
|
-
429: {
|
|
1190
|
-
content: {
|
|
1191
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1192
|
-
};
|
|
1193
|
-
};
|
|
1194
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1195
|
-
500: {
|
|
1196
|
-
content: {
|
|
1197
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1198
|
-
};
|
|
1199
|
-
};
|
|
1200
|
-
};
|
|
1201
|
-
};
|
|
1202
|
-
delete: {
|
|
1203
|
-
responses: {
|
|
1204
|
-
/** @description The key was successfully revoked, it may take up to 30s for this to take effect in all regions */
|
|
1205
|
-
200: {
|
|
1206
|
-
content: {
|
|
1207
|
-
"application/json": Record<string, never>;
|
|
1208
|
-
};
|
|
1209
|
-
};
|
|
1210
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1211
|
-
400: {
|
|
1212
|
-
content: {
|
|
1213
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1214
|
-
};
|
|
1215
|
-
};
|
|
1216
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1217
|
-
401: {
|
|
1218
|
-
content: {
|
|
1219
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1220
|
-
};
|
|
1221
|
-
};
|
|
1222
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1223
|
-
403: {
|
|
1224
|
-
content: {
|
|
1225
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1226
|
-
};
|
|
1227
|
-
};
|
|
1228
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1229
|
-
404: {
|
|
1230
|
-
content: {
|
|
1231
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1232
|
-
};
|
|
1233
|
-
};
|
|
1234
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1235
|
-
409: {
|
|
1236
|
-
content: {
|
|
1237
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1238
|
-
};
|
|
1239
|
-
};
|
|
1240
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1241
|
-
429: {
|
|
1242
|
-
content: {
|
|
1243
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1244
|
-
};
|
|
1245
|
-
};
|
|
1246
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1247
|
-
500: {
|
|
1248
|
-
content: {
|
|
1249
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1250
|
-
};
|
|
1251
|
-
};
|
|
1252
|
-
};
|
|
1253
|
-
};
|
|
1254
|
-
};
|
|
1255
1043
|
"/v1/keys": {
|
|
1256
1044
|
post: {
|
|
1257
1045
|
requestBody: {
|
|
@@ -1505,282 +1293,12 @@ interface paths {
|
|
|
1505
1293
|
* - FORBIDDEN: the key is not allowed to access the api
|
|
1506
1294
|
* - USAGE_EXCEEDED: the key has exceeded its request limit
|
|
1507
1295
|
* - RATE_LIMITED: the key has been ratelimited,
|
|
1296
|
+
* - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
|
|
1508
1297
|
*
|
|
1509
1298
|
* @example NOT_FOUND
|
|
1510
1299
|
* @enum {string}
|
|
1511
1300
|
*/
|
|
1512
|
-
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED";
|
|
1513
|
-
};
|
|
1514
|
-
};
|
|
1515
|
-
};
|
|
1516
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1517
|
-
400: {
|
|
1518
|
-
content: {
|
|
1519
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1520
|
-
};
|
|
1521
|
-
};
|
|
1522
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1523
|
-
401: {
|
|
1524
|
-
content: {
|
|
1525
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1526
|
-
};
|
|
1527
|
-
};
|
|
1528
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1529
|
-
403: {
|
|
1530
|
-
content: {
|
|
1531
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1532
|
-
};
|
|
1533
|
-
};
|
|
1534
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1535
|
-
404: {
|
|
1536
|
-
content: {
|
|
1537
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1538
|
-
};
|
|
1539
|
-
};
|
|
1540
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1541
|
-
409: {
|
|
1542
|
-
content: {
|
|
1543
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1544
|
-
};
|
|
1545
|
-
};
|
|
1546
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1547
|
-
429: {
|
|
1548
|
-
content: {
|
|
1549
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1550
|
-
};
|
|
1551
|
-
};
|
|
1552
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1553
|
-
500: {
|
|
1554
|
-
content: {
|
|
1555
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1556
|
-
};
|
|
1557
|
-
};
|
|
1558
|
-
};
|
|
1559
|
-
};
|
|
1560
|
-
};
|
|
1561
|
-
"/v1/apis": {
|
|
1562
|
-
post: {
|
|
1563
|
-
requestBody: {
|
|
1564
|
-
content: {
|
|
1565
|
-
"application/json": {
|
|
1566
|
-
/**
|
|
1567
|
-
* @description The name for your API. This is not customer facing.
|
|
1568
|
-
* @example my-api
|
|
1569
|
-
*/
|
|
1570
|
-
name: string;
|
|
1571
|
-
};
|
|
1572
|
-
};
|
|
1573
|
-
};
|
|
1574
|
-
responses: {
|
|
1575
|
-
/** @description The configuration for an api */
|
|
1576
|
-
200: {
|
|
1577
|
-
content: {
|
|
1578
|
-
"application/json": {
|
|
1579
|
-
/**
|
|
1580
|
-
* @description The id of the api
|
|
1581
|
-
* @example api_134
|
|
1582
|
-
*/
|
|
1583
|
-
apiId: string;
|
|
1584
|
-
};
|
|
1585
|
-
};
|
|
1586
|
-
};
|
|
1587
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1588
|
-
400: {
|
|
1589
|
-
content: {
|
|
1590
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1591
|
-
};
|
|
1592
|
-
};
|
|
1593
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1594
|
-
401: {
|
|
1595
|
-
content: {
|
|
1596
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1597
|
-
};
|
|
1598
|
-
};
|
|
1599
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1600
|
-
403: {
|
|
1601
|
-
content: {
|
|
1602
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1603
|
-
};
|
|
1604
|
-
};
|
|
1605
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1606
|
-
404: {
|
|
1607
|
-
content: {
|
|
1608
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1609
|
-
};
|
|
1610
|
-
};
|
|
1611
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1612
|
-
409: {
|
|
1613
|
-
content: {
|
|
1614
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1615
|
-
};
|
|
1616
|
-
};
|
|
1617
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1618
|
-
429: {
|
|
1619
|
-
content: {
|
|
1620
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1621
|
-
};
|
|
1622
|
-
};
|
|
1623
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1624
|
-
500: {
|
|
1625
|
-
content: {
|
|
1626
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1627
|
-
};
|
|
1628
|
-
};
|
|
1629
|
-
};
|
|
1630
|
-
};
|
|
1631
|
-
};
|
|
1632
|
-
"/v1/apis/{apiId}": {
|
|
1633
|
-
get: {
|
|
1634
|
-
parameters: {
|
|
1635
|
-
path: {
|
|
1636
|
-
apiId: string;
|
|
1637
|
-
};
|
|
1638
|
-
};
|
|
1639
|
-
responses: {
|
|
1640
|
-
/** @description The configuration for an api */
|
|
1641
|
-
200: {
|
|
1642
|
-
content: {
|
|
1643
|
-
"application/json": {
|
|
1644
|
-
/**
|
|
1645
|
-
* @description The id of the key
|
|
1646
|
-
* @example key_1234
|
|
1647
|
-
*/
|
|
1648
|
-
id: string;
|
|
1649
|
-
/**
|
|
1650
|
-
* @description The id of the workspace that owns the api
|
|
1651
|
-
* @example ws_1234
|
|
1652
|
-
*/
|
|
1653
|
-
workspaceId: string;
|
|
1654
|
-
/**
|
|
1655
|
-
* @description The name of the api. This is internal and your users will not see this.
|
|
1656
|
-
* @example Unkey - Production
|
|
1657
|
-
*/
|
|
1658
|
-
name?: string;
|
|
1659
|
-
};
|
|
1660
|
-
};
|
|
1661
|
-
};
|
|
1662
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1663
|
-
400: {
|
|
1664
|
-
content: {
|
|
1665
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1666
|
-
};
|
|
1667
|
-
};
|
|
1668
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1669
|
-
401: {
|
|
1670
|
-
content: {
|
|
1671
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1672
|
-
};
|
|
1673
|
-
};
|
|
1674
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1675
|
-
403: {
|
|
1676
|
-
content: {
|
|
1677
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1678
|
-
};
|
|
1679
|
-
};
|
|
1680
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1681
|
-
404: {
|
|
1682
|
-
content: {
|
|
1683
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1684
|
-
};
|
|
1685
|
-
};
|
|
1686
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1687
|
-
409: {
|
|
1688
|
-
content: {
|
|
1689
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1690
|
-
};
|
|
1691
|
-
};
|
|
1692
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1693
|
-
429: {
|
|
1694
|
-
content: {
|
|
1695
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1696
|
-
};
|
|
1697
|
-
};
|
|
1698
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1699
|
-
500: {
|
|
1700
|
-
content: {
|
|
1701
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1702
|
-
};
|
|
1703
|
-
};
|
|
1704
|
-
};
|
|
1705
|
-
};
|
|
1706
|
-
delete: {
|
|
1707
|
-
parameters: {
|
|
1708
|
-
path: {
|
|
1709
|
-
apiId: string;
|
|
1710
|
-
};
|
|
1711
|
-
};
|
|
1712
|
-
responses: {
|
|
1713
|
-
/** @description The api was successfully deleted, it may take up to 30s for this to take effect in all regions */
|
|
1714
|
-
200: {
|
|
1715
|
-
content: {
|
|
1716
|
-
"application/json": Record<string, never>;
|
|
1717
|
-
};
|
|
1718
|
-
};
|
|
1719
|
-
/** @description The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing). */
|
|
1720
|
-
400: {
|
|
1721
|
-
content: {
|
|
1722
|
-
"application/json": components["schemas"]["ErrBadRequest"];
|
|
1723
|
-
};
|
|
1724
|
-
};
|
|
1725
|
-
/** @description Although the HTTP standard specifies "unauthorized", semantically this response means "unauthenticated". That is, the client must authenticate itself to get the requested response. */
|
|
1726
|
-
401: {
|
|
1727
|
-
content: {
|
|
1728
|
-
"application/json": components["schemas"]["ErrUnauthorized"];
|
|
1729
|
-
};
|
|
1730
|
-
};
|
|
1731
|
-
/** @description The client does not have access rights to the content; that is, it is unauthorized, so the server is refusing to give the requested resource. Unlike 401 Unauthorized, the client's identity is known to the server. */
|
|
1732
|
-
403: {
|
|
1733
|
-
content: {
|
|
1734
|
-
"application/json": components["schemas"]["ErrForbidden"];
|
|
1735
|
-
};
|
|
1736
|
-
};
|
|
1737
|
-
/** @description The server cannot find the requested resource. In the browser, this means the URL is not recognized. In an API, this can also mean that the endpoint is valid but the resource itself does not exist. Servers may also send this response instead of 403 Forbidden to hide the existence of a resource from an unauthorized client. This response code is probably the most well known due to its frequent occurrence on the web. */
|
|
1738
|
-
404: {
|
|
1739
|
-
content: {
|
|
1740
|
-
"application/json": components["schemas"]["ErrNotFound"];
|
|
1741
|
-
};
|
|
1742
|
-
};
|
|
1743
|
-
/** @description This response is sent when a request conflicts with the current state of the server. */
|
|
1744
|
-
409: {
|
|
1745
|
-
content: {
|
|
1746
|
-
"application/json": components["schemas"]["ErrConflict"];
|
|
1747
|
-
};
|
|
1748
|
-
};
|
|
1749
|
-
/** @description The user has sent too many requests in a given amount of time ("rate limiting") */
|
|
1750
|
-
429: {
|
|
1751
|
-
content: {
|
|
1752
|
-
"application/json": components["schemas"]["ErrTooManyRequests"];
|
|
1753
|
-
};
|
|
1754
|
-
};
|
|
1755
|
-
/** @description The server has encountered a situation it does not know how to handle. */
|
|
1756
|
-
500: {
|
|
1757
|
-
content: {
|
|
1758
|
-
"application/json": components["schemas"]["ErrInternalServerError"];
|
|
1759
|
-
};
|
|
1760
|
-
};
|
|
1761
|
-
};
|
|
1762
|
-
};
|
|
1763
|
-
};
|
|
1764
|
-
"/v1/apis/{apiId}/keys": {
|
|
1765
|
-
get: {
|
|
1766
|
-
parameters: {
|
|
1767
|
-
query?: {
|
|
1768
|
-
limit?: number;
|
|
1769
|
-
offset?: number | null;
|
|
1770
|
-
ownerId?: string;
|
|
1771
|
-
};
|
|
1772
|
-
path: {
|
|
1773
|
-
apiId: string;
|
|
1774
|
-
};
|
|
1775
|
-
};
|
|
1776
|
-
responses: {
|
|
1777
|
-
/** @description Keys belonging to the api */
|
|
1778
|
-
200: {
|
|
1779
|
-
content: {
|
|
1780
|
-
"application/json": {
|
|
1781
|
-
keys: components["schemas"]["Key"][];
|
|
1782
|
-
/** @description The total number of keys for this api */
|
|
1783
|
-
total: number;
|
|
1301
|
+
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
|
|
1784
1302
|
};
|
|
1785
1303
|
};
|
|
1786
1304
|
};
|
|
@@ -2107,6 +1625,14 @@ interface components {
|
|
|
2107
1625
|
* ]
|
|
2108
1626
|
*/
|
|
2109
1627
|
roles?: string[];
|
|
1628
|
+
/**
|
|
1629
|
+
* @description All permissions this key has
|
|
1630
|
+
* @example [
|
|
1631
|
+
* "domain.dns.create_record",
|
|
1632
|
+
* "finance.read_receipt"
|
|
1633
|
+
* ]
|
|
1634
|
+
*/
|
|
1635
|
+
permissions?: string[];
|
|
2110
1636
|
/**
|
|
2111
1637
|
* @description Sets if key is enabled or disabled. Disabled keys are not valid.
|
|
2112
1638
|
* @example true
|
|
@@ -2192,11 +1718,26 @@ interface components {
|
|
|
2192
1718
|
* - RATE_LIMITED: the key has been ratelimited
|
|
2193
1719
|
* - UNAUTHORIZED: the key is not authorized
|
|
2194
1720
|
* - DISABLED: the key is disabled
|
|
1721
|
+
* - INSUFFICIENT_PERMISSIONS: you do not have the required permissions to perform this action
|
|
1722
|
+
*
|
|
2195
1723
|
* @enum {string}
|
|
2196
1724
|
*/
|
|
2197
|
-
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED";
|
|
1725
|
+
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS";
|
|
2198
1726
|
/** @description Sets the key to be enabled or disabled. Disabled keys will not verify. */
|
|
2199
1727
|
enabled?: boolean;
|
|
1728
|
+
/**
|
|
1729
|
+
* @description A list of all the permissions this key is connected to.
|
|
1730
|
+
* @example [
|
|
1731
|
+
* "dns.record.update",
|
|
1732
|
+
* "dns.record.delete"
|
|
1733
|
+
* ]
|
|
1734
|
+
*/
|
|
1735
|
+
permissions?: string[];
|
|
1736
|
+
/**
|
|
1737
|
+
* @description The environment of the key, this is what what you set when you crated the key
|
|
1738
|
+
* @example test
|
|
1739
|
+
*/
|
|
1740
|
+
environment?: string;
|
|
2200
1741
|
};
|
|
2201
1742
|
V1KeysVerifyKeyRequest: {
|
|
2202
1743
|
/**
|
|
@@ -2210,6 +1751,24 @@ interface components {
|
|
|
2210
1751
|
* @example sk_1234
|
|
2211
1752
|
*/
|
|
2212
1753
|
key: string;
|
|
1754
|
+
/** @description Perform RBAC checks */
|
|
1755
|
+
authorization?: {
|
|
1756
|
+
/**
|
|
1757
|
+
* @description A query for which permissions you require
|
|
1758
|
+
* @example {
|
|
1759
|
+
* "or": [
|
|
1760
|
+
* {
|
|
1761
|
+
* "and": [
|
|
1762
|
+
* "dns.record.read",
|
|
1763
|
+
* "dns.record.update"
|
|
1764
|
+
* ]
|
|
1765
|
+
* },
|
|
1766
|
+
* "admin"
|
|
1767
|
+
* ]
|
|
1768
|
+
* }
|
|
1769
|
+
*/
|
|
1770
|
+
permissions: Record<string, never>;
|
|
1771
|
+
};
|
|
2213
1772
|
};
|
|
2214
1773
|
};
|
|
2215
1774
|
responses: never;
|
|
@@ -2306,7 +1865,17 @@ declare class Unkey {
|
|
|
2306
1865
|
get keys(): {
|
|
2307
1866
|
create: (req: paths["/v1/keys.createKey"]["post"]["requestBody"]["content"]["application/json"]) => Promise<Result<paths["/v1/keys.createKey"]["post"]["responses"]["200"]["content"]["application/json"]>>;
|
|
2308
1867
|
update: (req: paths["/v1/keys.updateKey"]["post"]["requestBody"]["content"]["application/json"]) => Promise<Result<paths["/v1/keys.updateKey"]["post"]["responses"]["200"]["content"]["application/json"]>>;
|
|
2309
|
-
verify: (req:
|
|
1868
|
+
verify: <TPermission extends string = string>(req: Omit<{
|
|
1869
|
+
apiId?: string | undefined;
|
|
1870
|
+
key: string;
|
|
1871
|
+
authorization?: {
|
|
1872
|
+
permissions: Record<string, never>;
|
|
1873
|
+
} | undefined;
|
|
1874
|
+
}, "authorization"> & {
|
|
1875
|
+
authorization?: {
|
|
1876
|
+
permissions: PermissionQuery<TPermission>;
|
|
1877
|
+
} | undefined;
|
|
1878
|
+
}) => Promise<Result<paths["/v1/keys.verifyKey"]["post"]["responses"]["200"]["content"]["application/json"]>>;
|
|
2310
1879
|
delete: (req: paths["/v1/keys.deleteKey"]["post"]["requestBody"]["content"]["application/json"]) => Promise<Result<paths["/v1/keys.deleteKey"]["post"]["responses"]["200"]["content"]["application/json"]>>;
|
|
2311
1880
|
updateRemaining: (req: paths["/v1/keys.updateRemaining"]["post"]["requestBody"]["content"]["application/json"]) => Promise<Result<paths["/v1/keys.updateRemaining"]["post"]["responses"]["200"]["content"]["application/json"]>>;
|
|
2312
1881
|
get: (req: paths["/v1/keys.getKey"]["get"]["parameters"]["query"]) => Promise<Result<paths["/v1/keys.getKey"]["get"]["responses"]["200"]["content"]["application/json"]>>;
|
|
@@ -2368,10 +1937,12 @@ declare function verifyKey(req: string | {
|
|
|
2368
1937
|
reset: number;
|
|
2369
1938
|
} | undefined;
|
|
2370
1939
|
remaining?: number | undefined;
|
|
2371
|
-
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | undefined;
|
|
1940
|
+
code?: "NOT_FOUND" | "FORBIDDEN" | "USAGE_EXCEEDED" | "RATE_LIMITED" | "UNAUTHORIZED" | "DISABLED" | "INSUFFICIENT_PERMISSIONS" | undefined;
|
|
2372
1941
|
enabled?: boolean | undefined;
|
|
1942
|
+
permissions?: string[] | undefined;
|
|
1943
|
+
environment?: string | undefined;
|
|
2373
1944
|
};
|
|
2374
1945
|
error?: undefined;
|
|
2375
1946
|
}>;
|
|
2376
1947
|
|
|
2377
|
-
export { ErrorResponse, Unkey, UnkeyOptions, verifyKey };
|
|
1948
|
+
export { type ErrorResponse, Unkey, type UnkeyOptions, verifyKey };
|