@unkey/api 2.0.3 → 2.0.4
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/README.md +4 -2
- package/bin/mcp-server.js +348 -141
- package/bin/mcp-server.js.map +21 -16
- package/dist/commonjs/funcs/keysRerollKey.d.ts +49 -0
- package/dist/commonjs/funcs/keysRerollKey.d.ts.map +1 -0
- package/dist/commonjs/funcs/keysRerollKey.js +159 -0
- package/dist/commonjs/funcs/keysRerollKey.js.map +1 -0
- package/dist/commonjs/funcs/permissionsListPermissions.d.ts +2 -1
- package/dist/commonjs/funcs/permissionsListPermissions.d.ts.map +1 -1
- package/dist/commonjs/funcs/permissionsListPermissions.js +2 -1
- package/dist/commonjs/funcs/permissionsListPermissions.js.map +1 -1
- package/dist/commonjs/funcs/permissionsListRoles.d.ts +2 -1
- package/dist/commonjs/funcs/permissionsListRoles.d.ts.map +1 -1
- package/dist/commonjs/funcs/permissionsListRoles.js +2 -1
- package/dist/commonjs/funcs/permissionsListRoles.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/server.js +3 -1
- package/dist/commonjs/mcp-server/server.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/keysRerollKey.d.ts +8 -0
- package/dist/commonjs/mcp-server/tools/keysRerollKey.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/keysRerollKey.js +96 -0
- package/dist/commonjs/mcp-server/tools/keysRerollKey.js.map +1 -0
- package/dist/commonjs/mcp-server/tools/permissionsListPermissions.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/tools/permissionsListPermissions.js +2 -1
- package/dist/commonjs/mcp-server/tools/permissionsListPermissions.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/permissionsListRoles.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/tools/permissionsListRoles.js +2 -1
- package/dist/commonjs/mcp-server/tools/permissionsListRoles.js.map +1 -1
- package/dist/commonjs/models/components/index.d.ts +3 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +3 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/v2keysaddpermissionsresponsebody.d.ts +0 -1
- package/dist/commonjs/models/components/v2keysaddpermissionsresponsebody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keysaddpermissionsresponsebody.js.map +1 -1
- package/dist/commonjs/models/components/v2keysaddrolesresponsebody.d.ts +0 -1
- package/dist/commonjs/models/components/v2keysaddrolesresponsebody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keysaddrolesresponsebody.js.map +1 -1
- package/dist/commonjs/models/components/v2keysremoverolesresponsebody.d.ts +0 -1
- package/dist/commonjs/models/components/v2keysremoverolesresponsebody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keysremoverolesresponsebody.js.map +1 -1
- package/dist/commonjs/models/components/v2keysrerollkeyrequestbody.d.ts +60 -0
- package/dist/commonjs/models/components/v2keysrerollkeyrequestbody.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysrerollkeyrequestbody.js +71 -0
- package/dist/commonjs/models/components/v2keysrerollkeyrequestbody.js.map +1 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsebody.d.ts +36 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsebody.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsebody.js +73 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsebody.js.map +1 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsedata.d.ts +62 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsedata.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsedata.js +71 -0
- package/dist/commonjs/models/components/v2keysrerollkeyresponsedata.js.map +1 -0
- package/dist/commonjs/models/components/v2keyssetpermissionsresponsebody.d.ts +0 -1
- package/dist/commonjs/models/components/v2keyssetpermissionsresponsebody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keyssetpermissionsresponsebody.js.map +1 -1
- package/dist/commonjs/models/components/v2keyssetrolesresponsebody.d.ts +0 -1
- package/dist/commonjs/models/components/v2keyssetrolesresponsebody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keyssetrolesresponsebody.js.map +1 -1
- package/dist/commonjs/sdk/keys.d.ts +38 -0
- package/dist/commonjs/sdk/keys.d.ts.map +1 -1
- package/dist/commonjs/sdk/keys.js +41 -0
- package/dist/commonjs/sdk/keys.js.map +1 -1
- package/dist/commonjs/sdk/permissions.d.ts +4 -2
- package/dist/commonjs/sdk/permissions.d.ts.map +1 -1
- package/dist/commonjs/sdk/permissions.js +4 -2
- package/dist/commonjs/sdk/permissions.js.map +1 -1
- package/dist/esm/funcs/keysRerollKey.d.ts +49 -0
- package/dist/esm/funcs/keysRerollKey.d.ts.map +1 -0
- package/dist/esm/funcs/keysRerollKey.js +123 -0
- package/dist/esm/funcs/keysRerollKey.js.map +1 -0
- package/dist/esm/funcs/permissionsListPermissions.d.ts +2 -1
- package/dist/esm/funcs/permissionsListPermissions.d.ts.map +1 -1
- package/dist/esm/funcs/permissionsListPermissions.js +2 -1
- package/dist/esm/funcs/permissionsListPermissions.js.map +1 -1
- package/dist/esm/funcs/permissionsListRoles.d.ts +2 -1
- package/dist/esm/funcs/permissionsListRoles.d.ts.map +1 -1
- package/dist/esm/funcs/permissionsListRoles.js +2 -1
- package/dist/esm/funcs/permissionsListRoles.js.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/server.d.ts.map +1 -1
- package/dist/esm/mcp-server/server.js +3 -1
- package/dist/esm/mcp-server/server.js.map +1 -1
- package/dist/esm/mcp-server/tools/keysRerollKey.d.ts +8 -0
- package/dist/esm/mcp-server/tools/keysRerollKey.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/keysRerollKey.js +60 -0
- package/dist/esm/mcp-server/tools/keysRerollKey.js.map +1 -0
- package/dist/esm/mcp-server/tools/permissionsListPermissions.d.ts.map +1 -1
- package/dist/esm/mcp-server/tools/permissionsListPermissions.js +2 -1
- package/dist/esm/mcp-server/tools/permissionsListPermissions.js.map +1 -1
- package/dist/esm/mcp-server/tools/permissionsListRoles.d.ts.map +1 -1
- package/dist/esm/mcp-server/tools/permissionsListRoles.js +2 -1
- package/dist/esm/mcp-server/tools/permissionsListRoles.js.map +1 -1
- package/dist/esm/models/components/index.d.ts +3 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +3 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/v2keysaddpermissionsresponsebody.d.ts +0 -1
- package/dist/esm/models/components/v2keysaddpermissionsresponsebody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keysaddpermissionsresponsebody.js.map +1 -1
- package/dist/esm/models/components/v2keysaddrolesresponsebody.d.ts +0 -1
- package/dist/esm/models/components/v2keysaddrolesresponsebody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keysaddrolesresponsebody.js.map +1 -1
- package/dist/esm/models/components/v2keysremoverolesresponsebody.d.ts +0 -1
- package/dist/esm/models/components/v2keysremoverolesresponsebody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keysremoverolesresponsebody.js.map +1 -1
- package/dist/esm/models/components/v2keysrerollkeyrequestbody.d.ts +60 -0
- package/dist/esm/models/components/v2keysrerollkeyrequestbody.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysrerollkeyrequestbody.js +33 -0
- package/dist/esm/models/components/v2keysrerollkeyrequestbody.js.map +1 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsebody.d.ts +36 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsebody.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsebody.js +35 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsebody.js.map +1 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsedata.d.ts +62 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsedata.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsedata.js +33 -0
- package/dist/esm/models/components/v2keysrerollkeyresponsedata.js.map +1 -0
- package/dist/esm/models/components/v2keyssetpermissionsresponsebody.d.ts +0 -1
- package/dist/esm/models/components/v2keyssetpermissionsresponsebody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keyssetpermissionsresponsebody.js.map +1 -1
- package/dist/esm/models/components/v2keyssetrolesresponsebody.d.ts +0 -1
- package/dist/esm/models/components/v2keyssetrolesresponsebody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keyssetrolesresponsebody.js.map +1 -1
- package/dist/esm/sdk/keys.d.ts +38 -0
- package/dist/esm/sdk/keys.d.ts.map +1 -1
- package/dist/esm/sdk/keys.js +41 -0
- package/dist/esm/sdk/keys.js.map +1 -1
- package/dist/esm/sdk/permissions.d.ts +4 -2
- package/dist/esm/sdk/permissions.d.ts.map +1 -1
- package/dist/esm/sdk/permissions.js +4 -2
- package/dist/esm/sdk/permissions.js.map +1 -1
- package/docs/sdks/keys/README.md +113 -0
- package/docs/sdks/permissions/README.md +4 -2
- package/examples/apisCreateApi.example.ts +1 -1
- package/examples/package-lock.json +3 -3
- package/jsr.json +1 -1
- package/package.json +3 -3
- package/src/funcs/keysRerollKey.ts +227 -0
- package/src/funcs/permissionsListPermissions.ts +2 -1
- package/src/funcs/permissionsListRoles.ts +2 -1
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +3 -1
- package/src/mcp-server/tools/keysRerollKey.ts +69 -0
- package/src/mcp-server/tools/permissionsListPermissions.ts +2 -1
- package/src/mcp-server/tools/permissionsListRoles.ts +2 -1
- package/src/models/components/index.ts +3 -0
- package/src/models/components/v2keysaddpermissionsresponsebody.ts +0 -1
- package/src/models/components/v2keysaddrolesresponsebody.ts +0 -1
- package/src/models/components/v2keysremoverolesresponsebody.ts +0 -1
- package/src/models/components/v2keysrerollkeyrequestbody.ts +99 -0
- package/src/models/components/v2keysrerollkeyresponsebody.ts +87 -0
- package/src/models/components/v2keysrerollkeyresponsedata.ts +103 -0
- package/src/models/components/v2keyssetpermissionsresponsebody.ts +0 -1
- package/src/models/components/v2keyssetrolesresponsebody.ts +0 -1
- package/src/sdk/keys.ts +49 -0
- package/src/sdk/permissions.ts +4 -2
package/dist/esm/sdk/keys.js
CHANGED
|
@@ -8,6 +8,7 @@ import { keysDeleteKey } from "../funcs/keysDeleteKey.js";
|
|
|
8
8
|
import { keysGetKey } from "../funcs/keysGetKey.js";
|
|
9
9
|
import { keysRemovePermissions } from "../funcs/keysRemovePermissions.js";
|
|
10
10
|
import { keysRemoveRoles } from "../funcs/keysRemoveRoles.js";
|
|
11
|
+
import { keysRerollKey } from "../funcs/keysRerollKey.js";
|
|
11
12
|
import { keysSetPermissions } from "../funcs/keysSetPermissions.js";
|
|
12
13
|
import { keysSetRoles } from "../funcs/keysSetRoles.js";
|
|
13
14
|
import { keysUpdateCredits } from "../funcs/keysUpdateCredits.js";
|
|
@@ -174,6 +175,46 @@ export class Keys extends ClientSDK {
|
|
|
174
175
|
async removeRoles(request, options) {
|
|
175
176
|
return unwrapAsync(keysRemoveRoles(this, request, options));
|
|
176
177
|
}
|
|
178
|
+
/**
|
|
179
|
+
* Reroll Key
|
|
180
|
+
*
|
|
181
|
+
* @remarks
|
|
182
|
+
* Generate a new API key while preserving the configuration from an existing key.
|
|
183
|
+
*
|
|
184
|
+
* This operation creates a fresh key with a new token while maintaining all settings from the original key:
|
|
185
|
+
* - Permissions and roles
|
|
186
|
+
* - Custom metadata
|
|
187
|
+
* - Rate limit configurations
|
|
188
|
+
* - Identity associations
|
|
189
|
+
* - Remaining credits
|
|
190
|
+
* - Recovery settings
|
|
191
|
+
*
|
|
192
|
+
* **Key Generation:**
|
|
193
|
+
* - The system attempts to extract the prefix from the original key
|
|
194
|
+
* - If prefix extraction fails, the default API prefix is used
|
|
195
|
+
* - Key length follows the API's default byte configuration (or 16 bytes if not specified)
|
|
196
|
+
*
|
|
197
|
+
* **Original Key Handling:**
|
|
198
|
+
* - The original key will be revoked after the duration specified in `expiration`
|
|
199
|
+
* - Set `expiration` to 0 to revoke immediately
|
|
200
|
+
* - This allows for graceful key rotation with an overlap period
|
|
201
|
+
*
|
|
202
|
+
* Common use cases include:
|
|
203
|
+
* - Rotating keys for security compliance
|
|
204
|
+
* - Issuing replacement keys for compromised credentials
|
|
205
|
+
* - Creating backup keys with identical permissions
|
|
206
|
+
*
|
|
207
|
+
* **Important:** Analytics and usage metrics are tracked at both the key level AND identity level. If the original key has an identity, the new key will inherit it, allowing you to track usage across both individual keys and the overall identity.
|
|
208
|
+
*
|
|
209
|
+
* **Required Permissions**
|
|
210
|
+
*
|
|
211
|
+
* Your root key must have:
|
|
212
|
+
* - `api.*.create_key` or `api.<api_id>.create_key`
|
|
213
|
+
* - `api.*.encrypt_key` or `api.<api_id>.encrypt_key` (only when the original key is recoverable)
|
|
214
|
+
*/
|
|
215
|
+
async rerollKey(request, options) {
|
|
216
|
+
return unwrapAsync(keysRerollKey(this, request, options));
|
|
217
|
+
}
|
|
177
218
|
/**
|
|
178
219
|
* Set key permissions
|
|
179
220
|
*
|
package/dist/esm/sdk/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../../../src/sdk/keys.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,aAA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C,aAAa,CAC9B,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,MAAM,CACV,OAA2C,EAC3C,OAAwB;QAExB,OAAO,WAAW,CAAC,UAAU,CAC3B,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF"}
|
|
@@ -87,7 +87,8 @@ export declare class Permissions extends ClientSDK {
|
|
|
87
87
|
* List permissions
|
|
88
88
|
*
|
|
89
89
|
* @remarks
|
|
90
|
-
* Retrieve all permissions in your workspace.
|
|
90
|
+
* Retrieve all permissions in your workspace.
|
|
91
|
+
* Results are paginated and sorted by their id.
|
|
91
92
|
*
|
|
92
93
|
* **Required Permissions**
|
|
93
94
|
*
|
|
@@ -99,7 +100,8 @@ export declare class Permissions extends ClientSDK {
|
|
|
99
100
|
* List roles
|
|
100
101
|
*
|
|
101
102
|
* @remarks
|
|
102
|
-
* Retrieve all roles in your workspace including their assigned permissions.
|
|
103
|
+
* Retrieve all roles in your workspace including their assigned permissions.
|
|
104
|
+
* Results are paginated and sorted by their id.
|
|
103
105
|
*
|
|
104
106
|
* **Required Permissions**
|
|
105
107
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../../../src/sdk/permissions.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,KAAK,UAAU,MAAM,+BAA+B,CAAC;AAG5D,qBAAa,WAAY,SAAQ,SAAS;IACxC;;;;;;;;;;;;;;OAcG;IACG,gBAAgB,CACpB,OAAO,EAAE,UAAU,CAAC,wCAAwC,EAC5D,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,yCAAyC,CAAC;IAQhE;;;;;;;;;;;;OAYG;IACG,UAAU,CACd,OAAO,EAAE,UAAU,CAAC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;;;;;;;;;;;OAYG;IACG,gBAAgB,CACpB,OAAO,EAAE,UAAU,CAAC,wCAAwC,EAC5D,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,yCAAyC,CAAC;IAQhE;;;;;;;;;;;;OAYG;IACG,UAAU,CACd,OAAO,EAAE,UAAU,CAAC,kCAAkC,EACtD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,mCAAmC,CAAC;IAQ1D;;;;;;;;;;OAUG;IACG,aAAa,CACjB,OAAO,EAAE,UAAU,CAAC,qCAAqC,EACzD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,sCAAsC,CAAC;IAQ7D;;;;;;;;;;OAUG;IACG,OAAO,CACX,OAAO,EAAE,UAAU,CAAC,+BAA+B,EACnD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,gCAAgC,CAAC;IAQvD;;;;;;;;;;;OAWG;IACG,eAAe,CACnB,OAAO,EAAE,UAAU,CAAC,uCAAuC,EAC3D,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,wCAAwC,CAAC;IAQ/D;;;;;;;;;;;OAWG;IACG,SAAS,CACb,OAAO,EAAE,UAAU,CAAC,iCAAiC,EACrD,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,UAAU,CAAC,kCAAkC,CAAC;CAO1D"}
|
|
@@ -110,7 +110,8 @@ export class Permissions extends ClientSDK {
|
|
|
110
110
|
* List permissions
|
|
111
111
|
*
|
|
112
112
|
* @remarks
|
|
113
|
-
* Retrieve all permissions in your workspace.
|
|
113
|
+
* Retrieve all permissions in your workspace.
|
|
114
|
+
* Results are paginated and sorted by their id.
|
|
114
115
|
*
|
|
115
116
|
* **Required Permissions**
|
|
116
117
|
*
|
|
@@ -124,7 +125,8 @@ export class Permissions extends ClientSDK {
|
|
|
124
125
|
* List roles
|
|
125
126
|
*
|
|
126
127
|
* @remarks
|
|
127
|
-
* Retrieve all roles in your workspace including their assigned permissions.
|
|
128
|
+
* Retrieve all roles in your workspace including their assigned permissions.
|
|
129
|
+
* Results are paginated and sorted by their id.
|
|
128
130
|
*
|
|
129
131
|
* **Required Permissions**
|
|
130
132
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/sdk/permissions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C,MAAM,OAAO,WAAY,SAAQ,SAAS;IACxC;;;;;;;;;;;;;;OAcG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAA4D,EAC5D,OAAwB;QAExB,OAAO,WAAW,CAAC,2BAA2B,CAC5C,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,UAAU,CACd,OAAsD,EACtD,OAAwB;QAExB,OAAO,WAAW,CAAC,qBAAqB,CACtC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,gBAAgB,CACpB,OAA4D,EAC5D,OAAwB;QAExB,OAAO,WAAW,CAAC,2BAA2B,CAC5C,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,UAAU,CACd,OAAsD,EACtD,OAAwB;QAExB,OAAO,WAAW,CAAC,qBAAqB,CACtC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,aAAa,CACjB,OAAyD,EACzD,OAAwB;QAExB,OAAO,WAAW,CAAC,wBAAwB,CACzC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,OAAO,CACX,OAAmD,EACnD,OAAwB;QAExB,OAAO,WAAW,CAAC,kBAAkB,CACnC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../../../src/sdk/permissions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,wBAAwB,EAAE,MAAM,sCAAsC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACpF,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,SAAS,EAAkB,MAAM,gBAAgB,CAAC;AAE3D,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P,OAAO,CACR,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,SAAS,CACb,OAAqD,EACrD,OAAwB;QAExB,OAAO,WAAW,CAAC,oBAAoB,CACrC,IAAI,EACJ,OAAO,EACP,OAAO,CACR,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/docs/sdks/keys/README.md
CHANGED
|
@@ -14,6 +14,7 @@ API key management operations
|
|
|
14
14
|
* [getKey](#getkey) - Get API key
|
|
15
15
|
* [removePermissions](#removepermissions) - Remove key permissions
|
|
16
16
|
* [removeRoles](#removeroles) - Remove key roles
|
|
17
|
+
* [rerollKey](#rerollkey) - Reroll Key
|
|
17
18
|
* [setPermissions](#setpermissions) - Set key permissions
|
|
18
19
|
* [setRoles](#setroles) - Set key roles
|
|
19
20
|
* [updateCredits](#updatecredits) - Update key credits
|
|
@@ -780,6 +781,118 @@ run();
|
|
|
780
781
|
| errors.InternalServerErrorResponse | 500 | application/json |
|
|
781
782
|
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
782
783
|
|
|
784
|
+
## rerollKey
|
|
785
|
+
|
|
786
|
+
Generate a new API key while preserving the configuration from an existing key.
|
|
787
|
+
|
|
788
|
+
This operation creates a fresh key with a new token while maintaining all settings from the original key:
|
|
789
|
+
- Permissions and roles
|
|
790
|
+
- Custom metadata
|
|
791
|
+
- Rate limit configurations
|
|
792
|
+
- Identity associations
|
|
793
|
+
- Remaining credits
|
|
794
|
+
- Recovery settings
|
|
795
|
+
|
|
796
|
+
**Key Generation:**
|
|
797
|
+
- The system attempts to extract the prefix from the original key
|
|
798
|
+
- If prefix extraction fails, the default API prefix is used
|
|
799
|
+
- Key length follows the API's default byte configuration (or 16 bytes if not specified)
|
|
800
|
+
|
|
801
|
+
**Original Key Handling:**
|
|
802
|
+
- The original key will be revoked after the duration specified in `expiration`
|
|
803
|
+
- Set `expiration` to 0 to revoke immediately
|
|
804
|
+
- This allows for graceful key rotation with an overlap period
|
|
805
|
+
|
|
806
|
+
Common use cases include:
|
|
807
|
+
- Rotating keys for security compliance
|
|
808
|
+
- Issuing replacement keys for compromised credentials
|
|
809
|
+
- Creating backup keys with identical permissions
|
|
810
|
+
|
|
811
|
+
**Important:** Analytics and usage metrics are tracked at both the key level AND identity level. If the original key has an identity, the new key will inherit it, allowing you to track usage across both individual keys and the overall identity.
|
|
812
|
+
|
|
813
|
+
**Required Permissions**
|
|
814
|
+
|
|
815
|
+
Your root key must have:
|
|
816
|
+
- `api.*.create_key` or `api.<api_id>.create_key`
|
|
817
|
+
- `api.*.encrypt_key` or `api.<api_id>.encrypt_key` (only when the original key is recoverable)
|
|
818
|
+
|
|
819
|
+
|
|
820
|
+
### Example Usage
|
|
821
|
+
|
|
822
|
+
<!-- UsageSnippet language="typescript" operationID="rerollKey" method="post" path="/v2/keys.rerollKey" -->
|
|
823
|
+
```typescript
|
|
824
|
+
import { Unkey } from "@unkey/api";
|
|
825
|
+
|
|
826
|
+
const unkey = new Unkey({
|
|
827
|
+
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
async function run() {
|
|
831
|
+
const result = await unkey.keys.rerollKey({
|
|
832
|
+
keyId: "key_2cGKbMxRyIzhCxo1Idjz8q",
|
|
833
|
+
expiration: 86400000,
|
|
834
|
+
});
|
|
835
|
+
|
|
836
|
+
console.log(result);
|
|
837
|
+
}
|
|
838
|
+
|
|
839
|
+
run();
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
### Standalone function
|
|
843
|
+
|
|
844
|
+
The standalone function version of this method:
|
|
845
|
+
|
|
846
|
+
```typescript
|
|
847
|
+
import { UnkeyCore } from "@unkey/api/core.js";
|
|
848
|
+
import { keysRerollKey } from "@unkey/api/funcs/keysRerollKey.js";
|
|
849
|
+
|
|
850
|
+
// Use `UnkeyCore` for best tree-shaking performance.
|
|
851
|
+
// You can create one instance of it to use across an application.
|
|
852
|
+
const unkey = new UnkeyCore({
|
|
853
|
+
rootKey: process.env["UNKEY_ROOT_KEY"] ?? "",
|
|
854
|
+
});
|
|
855
|
+
|
|
856
|
+
async function run() {
|
|
857
|
+
const res = await keysRerollKey(unkey, {
|
|
858
|
+
keyId: "key_2cGKbMxRyIzhCxo1Idjz8q",
|
|
859
|
+
expiration: 86400000,
|
|
860
|
+
});
|
|
861
|
+
if (res.ok) {
|
|
862
|
+
const { value: result } = res;
|
|
863
|
+
console.log(result);
|
|
864
|
+
} else {
|
|
865
|
+
console.log("keysRerollKey failed:", res.error);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
run();
|
|
870
|
+
```
|
|
871
|
+
|
|
872
|
+
### Parameters
|
|
873
|
+
|
|
874
|
+
| Parameter | Type | Required | Description |
|
|
875
|
+
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
876
|
+
| `request` | [components.V2KeysRerollKeyRequestBody](../../models/components/v2keysrerollkeyrequestbody.md) | :heavy_check_mark: | The request object to use for the request. |
|
|
877
|
+
| `options` | RequestOptions | :heavy_minus_sign: | Used to set various options for making HTTP requests. |
|
|
878
|
+
| `options.fetchOptions` | [RequestInit](https://developer.mozilla.org/en-US/docs/Web/API/Request/Request#options) | :heavy_minus_sign: | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All `Request` options, except `method` and `body`, are allowed. |
|
|
879
|
+
| `options.retries` | [RetryConfig](../../lib/utils/retryconfig.md) | :heavy_minus_sign: | Enables retrying HTTP requests under certain failure conditions. |
|
|
880
|
+
|
|
881
|
+
### Response
|
|
882
|
+
|
|
883
|
+
**Promise\<[components.V2KeysRerollKeyResponseBody](../../models/components/v2keysrerollkeyresponsebody.md)\>**
|
|
884
|
+
|
|
885
|
+
### Errors
|
|
886
|
+
|
|
887
|
+
| Error Type | Status Code | Content Type |
|
|
888
|
+
| ---------------------------------- | ---------------------------------- | ---------------------------------- |
|
|
889
|
+
| errors.BadRequestErrorResponse | 400 | application/json |
|
|
890
|
+
| errors.UnauthorizedErrorResponse | 401 | application/json |
|
|
891
|
+
| errors.ForbiddenErrorResponse | 403 | application/json |
|
|
892
|
+
| errors.NotFoundErrorResponse | 404 | application/json |
|
|
893
|
+
| errors.InternalServerErrorResponse | 500 | application/json |
|
|
894
|
+
| errors.APIError | 4XX, 5XX | \*/\* |
|
|
895
|
+
|
|
783
896
|
## setPermissions
|
|
784
897
|
|
|
785
898
|
Replace all permissions on a key with the specified set in a single atomic operation.
|
|
@@ -537,7 +537,8 @@ run();
|
|
|
537
537
|
|
|
538
538
|
## listPermissions
|
|
539
539
|
|
|
540
|
-
Retrieve all permissions in your workspace.
|
|
540
|
+
Retrieve all permissions in your workspace.
|
|
541
|
+
Results are paginated and sorted by their id.
|
|
541
542
|
|
|
542
543
|
**Required Permissions**
|
|
543
544
|
|
|
@@ -622,7 +623,8 @@ run();
|
|
|
622
623
|
|
|
623
624
|
## listRoles
|
|
624
625
|
|
|
625
|
-
Retrieve all roles in your workspace including their assigned permissions.
|
|
626
|
+
Retrieve all roles in your workspace including their assigned permissions.
|
|
627
|
+
Results are paginated and sorted by their id.
|
|
626
628
|
|
|
627
629
|
**Required Permissions**
|
|
628
630
|
|
|
@@ -8,7 +8,7 @@ dotenv.config();
|
|
|
8
8
|
* Example usage of the @unkey/api SDK
|
|
9
9
|
*
|
|
10
10
|
* To run this example from the examples directory:
|
|
11
|
-
* npm run build && npx tsx apisCreateApi.ts
|
|
11
|
+
* npm run build && npx tsx apisCreateApi.example.ts
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
import { Unkey } from "@unkey/api";
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"..": {
|
|
20
20
|
"name": "@unkey/api",
|
|
21
|
-
"version": "2.0.
|
|
21
|
+
"version": "2.0.4",
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"zod": "^3.20.0"
|
|
24
24
|
},
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"express": "^4.21.2",
|
|
37
37
|
"globals": "^15.14.0",
|
|
38
38
|
"tshy": "^2.0.0",
|
|
39
|
-
"typescript": "
|
|
40
|
-
"typescript-eslint": "^8.
|
|
39
|
+
"typescript": "~5.8.3",
|
|
40
|
+
"typescript-eslint": "^8.26.0"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@modelcontextprotocol/sdk": ">=1.5.0 <1.10.0"
|
package/jsr.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unkey/api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.4",
|
|
4
4
|
"author": "Speakeasy",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -52,8 +52,8 @@
|
|
|
52
52
|
"express": "^4.21.2",
|
|
53
53
|
"globals": "^15.14.0",
|
|
54
54
|
"tshy": "^2.0.0",
|
|
55
|
-
"typescript": "
|
|
56
|
-
"typescript-eslint": "^8.
|
|
55
|
+
"typescript": "~5.8.3",
|
|
56
|
+
"typescript-eslint": "^8.26.0"
|
|
57
57
|
},
|
|
58
58
|
"dependencies": {
|
|
59
59
|
"zod": "^3.20.0"
|
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import { UnkeyCore } from "../core.js";
|
|
6
|
+
import { encodeJSON } from "../lib/encodings.js";
|
|
7
|
+
import * as M from "../lib/matchers.js";
|
|
8
|
+
import { compactMap } from "../lib/primitives.js";
|
|
9
|
+
import { safeParse } from "../lib/schemas.js";
|
|
10
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
11
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
12
|
+
import { pathToFunc } from "../lib/url.js";
|
|
13
|
+
import * as components from "../models/components/index.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
23
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
24
|
+
import { UnkeyError } from "../models/errors/unkeyerror.js";
|
|
25
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
26
|
+
import { Result } from "../types/fp.js";
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Reroll Key
|
|
30
|
+
*
|
|
31
|
+
* @remarks
|
|
32
|
+
* Generate a new API key while preserving the configuration from an existing key.
|
|
33
|
+
*
|
|
34
|
+
* This operation creates a fresh key with a new token while maintaining all settings from the original key:
|
|
35
|
+
* - Permissions and roles
|
|
36
|
+
* - Custom metadata
|
|
37
|
+
* - Rate limit configurations
|
|
38
|
+
* - Identity associations
|
|
39
|
+
* - Remaining credits
|
|
40
|
+
* - Recovery settings
|
|
41
|
+
*
|
|
42
|
+
* **Key Generation:**
|
|
43
|
+
* - The system attempts to extract the prefix from the original key
|
|
44
|
+
* - If prefix extraction fails, the default API prefix is used
|
|
45
|
+
* - Key length follows the API's default byte configuration (or 16 bytes if not specified)
|
|
46
|
+
*
|
|
47
|
+
* **Original Key Handling:**
|
|
48
|
+
* - The original key will be revoked after the duration specified in `expiration`
|
|
49
|
+
* - Set `expiration` to 0 to revoke immediately
|
|
50
|
+
* - This allows for graceful key rotation with an overlap period
|
|
51
|
+
*
|
|
52
|
+
* Common use cases include:
|
|
53
|
+
* - Rotating keys for security compliance
|
|
54
|
+
* - Issuing replacement keys for compromised credentials
|
|
55
|
+
* - Creating backup keys with identical permissions
|
|
56
|
+
*
|
|
57
|
+
* **Important:** Analytics and usage metrics are tracked at both the key level AND identity level. If the original key has an identity, the new key will inherit it, allowing you to track usage across both individual keys and the overall identity.
|
|
58
|
+
*
|
|
59
|
+
* **Required Permissions**
|
|
60
|
+
*
|
|
61
|
+
* Your root key must have:
|
|
62
|
+
* - `api.*.create_key` or `api.<api_id>.create_key`
|
|
63
|
+
* - `api.*.encrypt_key` or `api.<api_id>.encrypt_key` (only when the original key is recoverable)
|
|
64
|
+
*/
|
|
65
|
+
export function keysRerollKey(
|
|
66
|
+
client: UnkeyCore,
|
|
67
|
+
request: components.V2KeysRerollKeyRequestBody,
|
|
68
|
+
options?: RequestOptions,
|
|
69
|
+
): APIPromise<
|
|
70
|
+
Result<
|
|
71
|
+
components.V2KeysRerollKeyResponseBody,
|
|
72
|
+
| errors.BadRequestErrorResponse
|
|
73
|
+
| errors.UnauthorizedErrorResponse
|
|
74
|
+
| errors.ForbiddenErrorResponse
|
|
75
|
+
| errors.NotFoundErrorResponse
|
|
76
|
+
| errors.InternalServerErrorResponse
|
|
77
|
+
| UnkeyError
|
|
78
|
+
| ResponseValidationError
|
|
79
|
+
| ConnectionError
|
|
80
|
+
| RequestAbortedError
|
|
81
|
+
| RequestTimeoutError
|
|
82
|
+
| InvalidRequestError
|
|
83
|
+
| UnexpectedClientError
|
|
84
|
+
| SDKValidationError
|
|
85
|
+
>
|
|
86
|
+
> {
|
|
87
|
+
return new APIPromise($do(
|
|
88
|
+
client,
|
|
89
|
+
request,
|
|
90
|
+
options,
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function $do(
|
|
95
|
+
client: UnkeyCore,
|
|
96
|
+
request: components.V2KeysRerollKeyRequestBody,
|
|
97
|
+
options?: RequestOptions,
|
|
98
|
+
): Promise<
|
|
99
|
+
[
|
|
100
|
+
Result<
|
|
101
|
+
components.V2KeysRerollKeyResponseBody,
|
|
102
|
+
| errors.BadRequestErrorResponse
|
|
103
|
+
| errors.UnauthorizedErrorResponse
|
|
104
|
+
| errors.ForbiddenErrorResponse
|
|
105
|
+
| errors.NotFoundErrorResponse
|
|
106
|
+
| errors.InternalServerErrorResponse
|
|
107
|
+
| UnkeyError
|
|
108
|
+
| ResponseValidationError
|
|
109
|
+
| ConnectionError
|
|
110
|
+
| RequestAbortedError
|
|
111
|
+
| RequestTimeoutError
|
|
112
|
+
| InvalidRequestError
|
|
113
|
+
| UnexpectedClientError
|
|
114
|
+
| SDKValidationError
|
|
115
|
+
>,
|
|
116
|
+
APICall,
|
|
117
|
+
]
|
|
118
|
+
> {
|
|
119
|
+
const parsed = safeParse(
|
|
120
|
+
request,
|
|
121
|
+
(value) =>
|
|
122
|
+
components.V2KeysRerollKeyRequestBody$outboundSchema.parse(value),
|
|
123
|
+
"Input validation failed",
|
|
124
|
+
);
|
|
125
|
+
if (!parsed.ok) {
|
|
126
|
+
return [parsed, { status: "invalid" }];
|
|
127
|
+
}
|
|
128
|
+
const payload = parsed.value;
|
|
129
|
+
const body = encodeJSON("body", payload, { explode: true });
|
|
130
|
+
|
|
131
|
+
const path = pathToFunc("/v2/keys.rerollKey")();
|
|
132
|
+
|
|
133
|
+
const headers = new Headers(compactMap({
|
|
134
|
+
"Content-Type": "application/json",
|
|
135
|
+
Accept: "application/json",
|
|
136
|
+
}));
|
|
137
|
+
|
|
138
|
+
const secConfig = await extractSecurity(client._options.rootKey);
|
|
139
|
+
const securityInput = secConfig == null ? {} : { rootKey: secConfig };
|
|
140
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
141
|
+
|
|
142
|
+
const context = {
|
|
143
|
+
options: client._options,
|
|
144
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
145
|
+
operationID: "rerollKey",
|
|
146
|
+
oAuth2Scopes: [],
|
|
147
|
+
|
|
148
|
+
resolvedSecurity: requestSecurity,
|
|
149
|
+
|
|
150
|
+
securitySource: client._options.rootKey,
|
|
151
|
+
retryConfig: options?.retries
|
|
152
|
+
|| client._options.retryConfig
|
|
153
|
+
|| {
|
|
154
|
+
strategy: "backoff",
|
|
155
|
+
backoff: {
|
|
156
|
+
initialInterval: 50,
|
|
157
|
+
maxInterval: 1000,
|
|
158
|
+
exponent: 1.5,
|
|
159
|
+
maxElapsedTime: 10000,
|
|
160
|
+
},
|
|
161
|
+
retryConnectionErrors: true,
|
|
162
|
+
}
|
|
163
|
+
|| { strategy: "none" },
|
|
164
|
+
retryCodes: options?.retryCodes || ["5XX"],
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const requestRes = client._createRequest(context, {
|
|
168
|
+
security: requestSecurity,
|
|
169
|
+
method: "POST",
|
|
170
|
+
baseURL: options?.serverURL,
|
|
171
|
+
path: path,
|
|
172
|
+
headers: headers,
|
|
173
|
+
body: body,
|
|
174
|
+
userAgent: client._options.userAgent,
|
|
175
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
176
|
+
}, options);
|
|
177
|
+
if (!requestRes.ok) {
|
|
178
|
+
return [requestRes, { status: "invalid" }];
|
|
179
|
+
}
|
|
180
|
+
const req = requestRes.value;
|
|
181
|
+
|
|
182
|
+
const doResult = await client._do(req, {
|
|
183
|
+
context,
|
|
184
|
+
errorCodes: ["400", "401", "403", "404", "4XX", "500", "5XX"],
|
|
185
|
+
retryConfig: context.retryConfig,
|
|
186
|
+
retryCodes: context.retryCodes,
|
|
187
|
+
});
|
|
188
|
+
if (!doResult.ok) {
|
|
189
|
+
return [doResult, { status: "request-error", request: req }];
|
|
190
|
+
}
|
|
191
|
+
const response = doResult.value;
|
|
192
|
+
|
|
193
|
+
const responseFields = {
|
|
194
|
+
HttpMeta: { Response: response, Request: req },
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const [result] = await M.match<
|
|
198
|
+
components.V2KeysRerollKeyResponseBody,
|
|
199
|
+
| errors.BadRequestErrorResponse
|
|
200
|
+
| errors.UnauthorizedErrorResponse
|
|
201
|
+
| errors.ForbiddenErrorResponse
|
|
202
|
+
| errors.NotFoundErrorResponse
|
|
203
|
+
| errors.InternalServerErrorResponse
|
|
204
|
+
| UnkeyError
|
|
205
|
+
| ResponseValidationError
|
|
206
|
+
| ConnectionError
|
|
207
|
+
| RequestAbortedError
|
|
208
|
+
| RequestTimeoutError
|
|
209
|
+
| InvalidRequestError
|
|
210
|
+
| UnexpectedClientError
|
|
211
|
+
| SDKValidationError
|
|
212
|
+
>(
|
|
213
|
+
M.json(200, components.V2KeysRerollKeyResponseBody$inboundSchema),
|
|
214
|
+
M.jsonErr(400, errors.BadRequestErrorResponse$inboundSchema),
|
|
215
|
+
M.jsonErr(401, errors.UnauthorizedErrorResponse$inboundSchema),
|
|
216
|
+
M.jsonErr(403, errors.ForbiddenErrorResponse$inboundSchema),
|
|
217
|
+
M.jsonErr(404, errors.NotFoundErrorResponse$inboundSchema),
|
|
218
|
+
M.jsonErr(500, errors.InternalServerErrorResponse$inboundSchema),
|
|
219
|
+
M.fail("4XX"),
|
|
220
|
+
M.fail("5XX"),
|
|
221
|
+
)(response, req, { extraFields: responseFields });
|
|
222
|
+
if (!result.ok) {
|
|
223
|
+
return [result, { status: "complete", request: req, response }];
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
return [result, { status: "complete", request: req, response }];
|
|
227
|
+
}
|
|
@@ -29,7 +29,8 @@ import { Result } from "../types/fp.js";
|
|
|
29
29
|
* List permissions
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
|
-
* Retrieve all permissions in your workspace.
|
|
32
|
+
* Retrieve all permissions in your workspace.
|
|
33
|
+
* Results are paginated and sorted by their id.
|
|
33
34
|
*
|
|
34
35
|
* **Required Permissions**
|
|
35
36
|
*
|
|
@@ -29,7 +29,8 @@ import { Result } from "../types/fp.js";
|
|
|
29
29
|
* List roles
|
|
30
30
|
*
|
|
31
31
|
* @remarks
|
|
32
|
-
* Retrieve all roles in your workspace including their assigned permissions.
|
|
32
|
+
* Retrieve all roles in your workspace including their assigned permissions.
|
|
33
|
+
* Results are paginated and sorted by their id.
|
|
33
34
|
*
|
|
34
35
|
* **Required Permissions**
|
|
35
36
|
*
|
package/src/lib/config.ts
CHANGED
|
@@ -58,7 +58,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
58
58
|
export const SDK_METADATA = {
|
|
59
59
|
language: "typescript",
|
|
60
60
|
openapiDocVersion: "2.0.0",
|
|
61
|
-
sdkVersion: "2.0.
|
|
62
|
-
genVersion: "2.
|
|
63
|
-
userAgent: "speakeasy-sdk/typescript 2.0.
|
|
61
|
+
sdkVersion: "2.0.4",
|
|
62
|
+
genVersion: "2.683.1",
|
|
63
|
+
userAgent: "speakeasy-sdk/typescript 2.0.4 2.683.1 2.0.0 @unkey/api",
|
|
64
64
|
} as const;
|
package/src/mcp-server/server.ts
CHANGED
|
@@ -29,6 +29,7 @@ import { tool$keysDeleteKey } from "./tools/keysDeleteKey.js";
|
|
|
29
29
|
import { tool$keysGetKey } from "./tools/keysGetKey.js";
|
|
30
30
|
import { tool$keysRemovePermissions } from "./tools/keysRemovePermissions.js";
|
|
31
31
|
import { tool$keysRemoveRoles } from "./tools/keysRemoveRoles.js";
|
|
32
|
+
import { tool$keysRerollKey } from "./tools/keysRerollKey.js";
|
|
32
33
|
import { tool$keysSetPermissions } from "./tools/keysSetPermissions.js";
|
|
33
34
|
import { tool$keysSetRoles } from "./tools/keysSetRoles.js";
|
|
34
35
|
import { tool$keysUpdateCredits } from "./tools/keysUpdateCredits.js";
|
|
@@ -59,7 +60,7 @@ export function createMCPServer(deps: {
|
|
|
59
60
|
}) {
|
|
60
61
|
const server = new McpServer({
|
|
61
62
|
name: "Unkey",
|
|
62
|
-
version: "2.0.
|
|
63
|
+
version: "2.0.4",
|
|
63
64
|
});
|
|
64
65
|
|
|
65
66
|
const client = new UnkeyCore({
|
|
@@ -105,6 +106,7 @@ export function createMCPServer(deps: {
|
|
|
105
106
|
tool(tool$keysGetKey);
|
|
106
107
|
tool(tool$keysRemovePermissions);
|
|
107
108
|
tool(tool$keysRemoveRoles);
|
|
109
|
+
tool(tool$keysRerollKey);
|
|
108
110
|
tool(tool$keysSetPermissions);
|
|
109
111
|
tool(tool$keysSetRoles);
|
|
110
112
|
tool(tool$keysUpdateCredits);
|