@origincloud/kms 0.0.0-stage → 0.28.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/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@origincloud/kms",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.28.0",
4
+ "description": "Origin Cloud's KMS service: grants: permission for one platform host to use one key for one operation and one encryption context, for at most an hour at a time.",
5
+ "license": "Apache-2.0",
6
+ "homepage": "https://github.com/origincloudhq/sdk-typescript#readme",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/origincloudhq/sdk-typescript.git",
10
+ "directory": "packages/kms"
11
+ },
12
+ "bugs": "https://github.com/origincloudhq/sdk-typescript/issues",
13
+ "keywords": [
14
+ "origincloud",
15
+ "origin-cloud",
16
+ "sdk",
17
+ "kms"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "engines": {
22
+ "node": ">=20"
23
+ },
24
+ "exports": {
25
+ "./*": {
26
+ "types": "./dist/*/index.d.ts",
27
+ "default": "./dist/*/index.js"
28
+ },
29
+ "./package.json": "./package.json"
30
+ },
31
+ "files": [
32
+ "dist",
33
+ "src",
34
+ "!dist/**/*.tsbuildinfo"
35
+ ],
36
+ "peerDependencies": {
37
+ "@origincloud/core": "^0.28.0"
38
+ },
39
+ "devDependencies": {
40
+ "@origincloud/core": "^0.28.0"
41
+ }
42
+ }
@@ -0,0 +1,240 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+ // source: origincloud/kms/v1beta1/grant.proto
3
+
4
+ import {
5
+ type CallOptions,
6
+ type Client,
7
+ type Empty,
8
+ type Service,
9
+ newRequestId,
10
+ pathValue,
11
+ query,
12
+ } from "@origincloud/core";
13
+
14
+ /**
15
+ * Calls GrantService.
16
+ *
17
+ * A key's grants.
18
+ *
19
+ * Making, renewing and deleting a grant needs `kms.grant.create`,
20
+ * `kms.grant.update` and `kms.grant.delete` on the key's project, which the
21
+ * platform's own services hold where you let them use your keys; none of
22
+ * them lets the holder use the key itself. Reading and listing need
23
+ * `kms.grant.get` and `kms.grant.list`.
24
+ */
25
+ export class GrantClient {
26
+ /**
27
+ * The endpoint the client sends its calls to, which also serves the
28
+ * operations its methods answer with.
29
+ */
30
+ readonly service: Service;
31
+
32
+ /** A client of GrantService that sends its calls through `client`. */
33
+ constructor(client: Client) {
34
+ this.service = client.service("kms", true);
35
+ }
36
+
37
+ /**
38
+ * Returns a grant that hasn't expired; an expired one is `NOT_FOUND`. A
39
+ * grant made moments ago may be refused with `SERVICE_UNAVAILABLE`,
40
+ * retryable, until its zone's change arrives. Needs `kms.grant.get` on
41
+ * the project.
42
+ */
43
+ async getGrant(request: GetGrantRequest, options?: CallOptions): Promise<Grant> {
44
+ const p0 = pathValue("name", request.name, "projects/*/regions/*/keys/*/grants/*");
45
+ return this.service.call<Grant>(
46
+ {
47
+ method: "GET",
48
+ path: `/v1beta1/${p0}`,
49
+ query: query(request, ["name"]),
50
+ idempotent: true,
51
+ },
52
+ options,
53
+ );
54
+ }
55
+
56
+ /**
57
+ * Lists a key's grants that haven't expired, in every zone, ordered by
58
+ * name. A grant made moments ago may be missing from the list until its
59
+ * zone's change arrives. Needs `kms.grant.list` on the project.
60
+ */
61
+ async listGrants(request: ListGrantsRequest, options?: CallOptions): Promise<ListGrantsResponse> {
62
+ const p0 = pathValue("parent", request.parent, "projects/*/regions/*/keys/*");
63
+ return this.service.call<ListGrantsResponse>(
64
+ {
65
+ method: "GET",
66
+ path: `/v1beta1/${p0}/grants`,
67
+ query: query(request, ["parent"]),
68
+ idempotent: true,
69
+ },
70
+ options,
71
+ );
72
+ }
73
+
74
+ /**
75
+ * Iterates over everything listGrants lists from the request's page on,
76
+ * fetching the next page as the loop reaches it. A page that fails ends
77
+ * the iteration with its error.
78
+ */
79
+ async *allGrants(request: ListGrantsRequest, options?: CallOptions): AsyncGenerator<Grant, void, undefined> {
80
+ for (let page = request; ; ) {
81
+ const response = await this.listGrants(page, options);
82
+ yield* response.grants ?? [];
83
+ if (!response.nextPageToken) return;
84
+ page = { ...page, pageToken: response.nextPageToken };
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Makes a grant on an `ENCRYPT_DECRYPT` key for one host, refused with
90
+ * `BAD_REQUEST` for a key of another purpose, a host that isn't one of
91
+ * the region's, an empty encryption context, or a `ttl` outside 1 to 60
92
+ * minutes, and with `CONFLICT` for a key that isn't enabled. Needs
93
+ * `kms.grant.create` on the project.
94
+ */
95
+ async createGrant(request: CreateGrantRequest, options?: CallOptions): Promise<Grant> {
96
+ if (!request.requestId) request = { ...request, requestId: newRequestId() };
97
+ const p0 = pathValue("parent", request.parent, "projects/*/regions/*/keys/*");
98
+ return this.service.call<Grant>(
99
+ {
100
+ method: "POST",
101
+ path: `/v1beta1/${p0}/grants`,
102
+ body: request.grant,
103
+ query: query(request, ["parent", "grant"]),
104
+ idempotent: true,
105
+ },
106
+ options,
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Extends a grant that hasn't expired to `ttl` from now. An expired
112
+ * grant isn't renewed: `CONFLICT`, and a new one is made instead. Needs
113
+ * `kms.grant.update` on the project.
114
+ */
115
+ async renewGrant(request: RenewGrantRequest, options?: CallOptions): Promise<Grant> {
116
+ const p0 = pathValue("name", request.name, "projects/*/regions/*/keys/*/grants/*");
117
+ return this.service.call<Grant>(
118
+ {
119
+ method: "POST",
120
+ path: `/v1beta1/${p0}:renew`,
121
+ body: request,
122
+ },
123
+ options,
124
+ );
125
+ }
126
+
127
+ /**
128
+ * Ends a grant before it expires: from then on it opens nothing. Needs
129
+ * `kms.grant.delete` on the project.
130
+ */
131
+ async deleteGrant(request: DeleteGrantRequest, options?: CallOptions): Promise<Empty> {
132
+ const p0 = pathValue("name", request.name, "projects/*/regions/*/keys/*/grants/*");
133
+ return this.service.call<Empty>(
134
+ {
135
+ method: "DELETE",
136
+ path: `/v1beta1/${p0}`,
137
+ query: query(request, ["name"]),
138
+ },
139
+ options,
140
+ );
141
+ }
142
+ }
143
+
144
+ /**
145
+ * A grant: one host may use one key for one operation, with exactly one
146
+ * encryption context, until `expireTime`.
147
+ */
148
+ export interface Grant {
149
+ /** The grant's resource name. */
150
+ name?: string;
151
+ /** What the host may do with the key. */
152
+ operation?: Grant_Operation;
153
+ /**
154
+ * The platform host the grant is for, by the SPIFFE ID its certificate
155
+ * names, which ends in `/zones/{zone}/hosts/{host}`.
156
+ */
157
+ grantee?: string;
158
+ /** The encryption context a use must carry, exactly; never empty. */
159
+ encryptionContext?: Record<string, string>;
160
+ /** How long the grant lives from now: 1 to 60 minutes. */
161
+ ttl?: string;
162
+ /** The zone that keeps the grant: its host's. */
163
+ zone?: string;
164
+ /** Who made the grant. */
165
+ delegate?: string;
166
+ /** When the grant was made. */
167
+ createTime?: string;
168
+ /** When the grant was last renewed, or made. */
169
+ renewTime?: string;
170
+ /** When the grant stops opening anything unless renewed before. */
171
+ expireTime?: string;
172
+ }
173
+
174
+ /** What a grant lets its host do. */
175
+ export const Grant_Operation = {
176
+ /** Not set. */
177
+ OPERATION_UNSPECIFIED: "OPERATION_UNSPECIFIED",
178
+ /**
179
+ * Decrypt ciphertexts made under the key with the grant's encryption
180
+ * context.
181
+ */
182
+ DECRYPT: "DECRYPT",
183
+ } as const;
184
+
185
+ /** What a grant lets its host do. */
186
+ export type Grant_Operation = (typeof Grant_Operation)[keyof typeof Grant_Operation];
187
+
188
+ /** The request for GetGrant. */
189
+ export interface GetGrantRequest {
190
+ /** The grant to return. */
191
+ name?: string;
192
+ }
193
+
194
+ /** The request for ListGrants. */
195
+ export interface ListGrantsRequest {
196
+ /** The key whose grants to list. */
197
+ parent?: string;
198
+ /**
199
+ * The most grants to return; the server clamps it, and 0 means its
200
+ * default.
201
+ */
202
+ pageSize?: number;
203
+ /** A previous response's `nextPageToken`, for the page after it. */
204
+ pageToken?: string;
205
+ }
206
+
207
+ /** The response for ListGrants. */
208
+ export interface ListGrantsResponse {
209
+ /** The grants on this page. */
210
+ grants?: Grant[];
211
+ /** The token for the next page; empty on the last one. */
212
+ nextPageToken?: string;
213
+ }
214
+
215
+ /** The request for CreateGrant. */
216
+ export interface CreateGrantRequest {
217
+ /** The key to grant. */
218
+ parent?: string;
219
+ /** The grant to make: its operation, host, encryption context and `ttl`. */
220
+ grant?: Grant;
221
+ /**
222
+ * A UUID; a repeat with the same id within a day returns the grant the
223
+ * first request made, instead of making a second.
224
+ */
225
+ requestId?: string;
226
+ }
227
+
228
+ /** The request for RenewGrant. */
229
+ export interface RenewGrantRequest {
230
+ /** The grant to renew. */
231
+ name?: string;
232
+ /** How long the grant lives from now: 1 to 60 minutes. */
233
+ ttl?: string;
234
+ }
235
+
236
+ /** The request for DeleteGrant. */
237
+ export interface DeleteGrantRequest {
238
+ /** The grant to end. */
239
+ name?: string;
240
+ }
@@ -0,0 +1,4 @@
1
+ // Code generated by the SDK's generator (generator/). DO NOT EDIT.
2
+
3
+ export * from "./grant.js";
4
+ export * from "./key.js";