@serve.zone/interfaces 19.8.0 → 20.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/changelog.md +28 -0
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/data/immutableimage.d.ts +2 -0
- package/dist_ts/data/immutableimage.js +1 -1
- package/dist_ts/data/index.d.ts +1 -0
- package/dist_ts/data/index.js +2 -1
- package/dist_ts/data/isolatedrestore.js +7 -82
- package/dist_ts/data/secret.d.ts +205 -0
- package/dist_ts/data/secret.js +469 -0
- package/dist_ts/data/secretbundle.d.ts +4 -0
- package/dist_ts/data/secretgroup.d.ts +4 -0
- package/dist_ts/data/service.d.ts +18 -6
- package/dist_ts/data/service.js +1 -1
- package/dist_ts/platform/index.d.ts +3 -1
- package/dist_ts/platform/index.js +4 -2
- package/dist_ts/platform/storagemigration.d.ts +346 -0
- package/dist_ts/platform/storagemigration.golden.d.ts +49 -0
- package/dist_ts/platform/storagemigration.golden.js +207 -0
- package/dist_ts/platform/storagemigration.js +1554 -0
- package/dist_ts/private/canonicaljson.d.ts +14 -0
- package/dist_ts/private/canonicaljson.js +154 -0
- package/dist_ts/requests/index.d.ts +2 -1
- package/dist_ts/requests/index.js +3 -2
- package/dist_ts/requests/secret.d.ts +198 -0
- package/dist_ts/requests/secret.js +2 -0
- package/dist_ts/runtime.d.ts +41 -0
- package/dist_ts/runtime.js +33 -0
- package/package.json +9 -2
- package/readme.md +162 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/data/immutableimage.ts +2 -0
- package/ts/data/index.ts +1 -0
- package/ts/data/isolatedrestore.ts +12 -93
- package/ts/data/secret.ts +835 -0
- package/ts/data/secretbundle.ts +4 -0
- package/ts/data/secretgroup.ts +4 -0
- package/ts/data/service.ts +26 -6
- package/ts/platform/index.ts +3 -0
- package/ts/platform/storagemigration.golden.ts +241 -0
- package/ts/platform/storagemigration.ts +3082 -0
- package/ts/private/canonicaljson.ts +221 -0
- package/ts/requests/index.ts +2 -0
- package/ts/requests/secret.ts +256 -0
- package/ts/runtime.ts +80 -0
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
export const strictCanonicalJsonRules = Object.freeze({
|
|
2
|
+
version: 1 as const,
|
|
3
|
+
encoding: 'utf-8' as const,
|
|
4
|
+
objectKeyOrdering: 'utf-16-code-unit-ascending' as const,
|
|
5
|
+
arrayOrdering: 'preserved-dense' as const,
|
|
6
|
+
unicodeNormalization: 'preserved' as const,
|
|
7
|
+
numberEncoding: 'safe-integer-json-no-negative-zero' as const,
|
|
8
|
+
digest: 'sha256-lowercase-hex' as const,
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
export type TCanonicalJsonFailure = (reasonArg: string) => never;
|
|
12
|
+
|
|
13
|
+
const assertUnicodeScalarString = (
|
|
14
|
+
valueArg: string,
|
|
15
|
+
fieldNameArg: string,
|
|
16
|
+
failArg: TCanonicalJsonFailure,
|
|
17
|
+
): void => {
|
|
18
|
+
for (let index = 0; index < valueArg.length; index++) {
|
|
19
|
+
const codeUnit = valueArg.charCodeAt(index);
|
|
20
|
+
if (codeUnit >= 0xd800 && codeUnit <= 0xdbff) {
|
|
21
|
+
const followingCodeUnit = valueArg.charCodeAt(index + 1);
|
|
22
|
+
if (
|
|
23
|
+
!Number.isInteger(followingCodeUnit) ||
|
|
24
|
+
followingCodeUnit < 0xdc00 ||
|
|
25
|
+
followingCodeUnit > 0xdfff
|
|
26
|
+
) {
|
|
27
|
+
failArg(`${fieldNameArg} must not contain an unpaired UTF-16 surrogate`);
|
|
28
|
+
}
|
|
29
|
+
index++;
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (codeUnit >= 0xdc00 && codeUnit <= 0xdfff) {
|
|
33
|
+
failArg(`${fieldNameArg} must not contain an unpaired UTF-16 surrogate`);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
const readStrictRecord = (
|
|
39
|
+
valueArg: object,
|
|
40
|
+
fieldNameArg: string,
|
|
41
|
+
failArg: TCanonicalJsonFailure,
|
|
42
|
+
): Record<string, unknown> => {
|
|
43
|
+
const prototype = Object.getPrototypeOf(valueArg);
|
|
44
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
45
|
+
return failArg(`${fieldNameArg} must be a plain object`);
|
|
46
|
+
}
|
|
47
|
+
const record = valueArg as Record<string, unknown>;
|
|
48
|
+
const ownKeys = Reflect.ownKeys(record);
|
|
49
|
+
if (ownKeys.some((keyArg) => typeof keyArg !== 'string')) {
|
|
50
|
+
return failArg(`${fieldNameArg} must not contain symbol keys`);
|
|
51
|
+
}
|
|
52
|
+
for (const key of ownKeys as string[]) {
|
|
53
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
54
|
+
if (
|
|
55
|
+
!descriptor ||
|
|
56
|
+
!descriptor.enumerable ||
|
|
57
|
+
!Object.hasOwn(descriptor, 'value')
|
|
58
|
+
) {
|
|
59
|
+
return failArg(
|
|
60
|
+
`${fieldNameArg} must contain enumerable data properties only`,
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return record;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const readStrictArray = (
|
|
68
|
+
valueArg: unknown[],
|
|
69
|
+
fieldNameArg: string,
|
|
70
|
+
failArg: TCanonicalJsonFailure,
|
|
71
|
+
): unknown[] => {
|
|
72
|
+
if (Object.getPrototypeOf(valueArg) !== Array.prototype) {
|
|
73
|
+
return failArg(`${fieldNameArg} must be a dense plain array`);
|
|
74
|
+
}
|
|
75
|
+
for (let index = 0; index < valueArg.length; index++) {
|
|
76
|
+
if (!Object.hasOwn(valueArg, index)) {
|
|
77
|
+
return failArg(`${fieldNameArg} must not contain sparse entries`);
|
|
78
|
+
}
|
|
79
|
+
const descriptor = Object.getOwnPropertyDescriptor(valueArg, String(index));
|
|
80
|
+
if (
|
|
81
|
+
!descriptor ||
|
|
82
|
+
!descriptor.enumerable ||
|
|
83
|
+
!Object.hasOwn(descriptor, 'value')
|
|
84
|
+
) {
|
|
85
|
+
return failArg(`${fieldNameArg} must contain enumerable data entries only`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
for (const key of Reflect.ownKeys(valueArg)) {
|
|
89
|
+
if (key === 'length') {
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (
|
|
93
|
+
typeof key !== 'string' ||
|
|
94
|
+
!/^(?:0|[1-9][0-9]*)$/.test(key) ||
|
|
95
|
+
Number(key) >= valueArg.length
|
|
96
|
+
) {
|
|
97
|
+
return failArg(`${fieldNameArg} must not contain extra properties`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return valueArg;
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
export const canonicalizeStrictJson = (
|
|
104
|
+
valueArg: unknown,
|
|
105
|
+
failArg: TCanonicalJsonFailure,
|
|
106
|
+
fieldNameArg = 'canonical JSON input',
|
|
107
|
+
): string => {
|
|
108
|
+
const ancestors = new Set<object>();
|
|
109
|
+
|
|
110
|
+
const visit = (currentValueArg: unknown, currentFieldNameArg: string): string => {
|
|
111
|
+
if (currentValueArg === null) {
|
|
112
|
+
return 'null';
|
|
113
|
+
}
|
|
114
|
+
if (typeof currentValueArg === 'boolean') {
|
|
115
|
+
return currentValueArg ? 'true' : 'false';
|
|
116
|
+
}
|
|
117
|
+
if (typeof currentValueArg === 'string') {
|
|
118
|
+
assertUnicodeScalarString(currentValueArg, currentFieldNameArg, failArg);
|
|
119
|
+
return JSON.stringify(currentValueArg);
|
|
120
|
+
}
|
|
121
|
+
if (typeof currentValueArg === 'number') {
|
|
122
|
+
if (
|
|
123
|
+
!Number.isSafeInteger(currentValueArg) ||
|
|
124
|
+
Object.is(currentValueArg, -0)
|
|
125
|
+
) {
|
|
126
|
+
return failArg(`${currentFieldNameArg} must contain safe integers only`);
|
|
127
|
+
}
|
|
128
|
+
return String(currentValueArg);
|
|
129
|
+
}
|
|
130
|
+
if (!currentValueArg || typeof currentValueArg !== 'object') {
|
|
131
|
+
return failArg(`${currentFieldNameArg} contains a non-JSON value`);
|
|
132
|
+
}
|
|
133
|
+
if (ancestors.has(currentValueArg)) {
|
|
134
|
+
return failArg(`${currentFieldNameArg} contains a cycle`);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ancestors.add(currentValueArg);
|
|
138
|
+
try {
|
|
139
|
+
if (Array.isArray(currentValueArg)) {
|
|
140
|
+
const array = readStrictArray(
|
|
141
|
+
currentValueArg,
|
|
142
|
+
currentFieldNameArg,
|
|
143
|
+
failArg,
|
|
144
|
+
);
|
|
145
|
+
return `[${array
|
|
146
|
+
.map((entryArg, indexArg) =>
|
|
147
|
+
visit(entryArg, `${currentFieldNameArg}[${indexArg}]`),
|
|
148
|
+
)
|
|
149
|
+
.join(',')}]`;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const record = readStrictRecord(
|
|
153
|
+
currentValueArg,
|
|
154
|
+
currentFieldNameArg,
|
|
155
|
+
failArg,
|
|
156
|
+
);
|
|
157
|
+
const keys = Object.keys(record).sort((leftArg, rightArg) => {
|
|
158
|
+
return leftArg < rightArg ? -1 : leftArg > rightArg ? 1 : 0;
|
|
159
|
+
});
|
|
160
|
+
return `{${keys
|
|
161
|
+
.map((keyArg) => {
|
|
162
|
+
assertUnicodeScalarString(
|
|
163
|
+
keyArg,
|
|
164
|
+
`${currentFieldNameArg} key`,
|
|
165
|
+
failArg,
|
|
166
|
+
);
|
|
167
|
+
return `${JSON.stringify(keyArg)}:${visit(
|
|
168
|
+
record[keyArg],
|
|
169
|
+
`${currentFieldNameArg}.${keyArg}`,
|
|
170
|
+
)}`;
|
|
171
|
+
})
|
|
172
|
+
.join(',')}}`;
|
|
173
|
+
} finally {
|
|
174
|
+
ancestors.delete(currentValueArg);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
return visit(valueArg, fieldNameArg);
|
|
179
|
+
};
|
|
180
|
+
|
|
181
|
+
export const createSha256Hex = async (
|
|
182
|
+
contentsArg: Uint8Array,
|
|
183
|
+
failArg: TCanonicalJsonFailure,
|
|
184
|
+
): Promise<string> => {
|
|
185
|
+
const subtle = globalThis.crypto?.subtle;
|
|
186
|
+
if (!subtle) {
|
|
187
|
+
return failArg('Web Crypto SHA-256 is unavailable in this runtime');
|
|
188
|
+
}
|
|
189
|
+
const digest = await subtle.digest('SHA-256', new Uint8Array(contentsArg));
|
|
190
|
+
return Array.from(new Uint8Array(digest), (byteArg) =>
|
|
191
|
+
byteArg.toString(16).padStart(2, '0'),
|
|
192
|
+
).join('');
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
export const createCanonicalJsonSha256Hex = async (
|
|
196
|
+
canonicalJsonArg: string,
|
|
197
|
+
failArg: TCanonicalJsonFailure,
|
|
198
|
+
): Promise<string> => {
|
|
199
|
+
return createSha256Hex(new TextEncoder().encode(canonicalJsonArg), failArg);
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
export const deepFreezeValue = <T>(
|
|
203
|
+
valueArg: T,
|
|
204
|
+
seenArg = new WeakSet<object>(),
|
|
205
|
+
): T => {
|
|
206
|
+
if (!valueArg || typeof valueArg !== 'object') {
|
|
207
|
+
return valueArg;
|
|
208
|
+
}
|
|
209
|
+
const object = valueArg as object;
|
|
210
|
+
if (ArrayBuffer.isView(object) || seenArg.has(object)) {
|
|
211
|
+
return valueArg;
|
|
212
|
+
}
|
|
213
|
+
seenArg.add(object);
|
|
214
|
+
for (const key of Reflect.ownKeys(object)) {
|
|
215
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
216
|
+
if (descriptor && Object.hasOwn(descriptor, 'value')) {
|
|
217
|
+
deepFreezeValue(descriptor.value, seenArg);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return Object.freeze(valueArg);
|
|
221
|
+
};
|
package/ts/requests/index.ts
CHANGED
|
@@ -25,6 +25,7 @@ import * as networkRequests from './network.js';
|
|
|
25
25
|
import * as nodeRequests from './node.js';
|
|
26
26
|
import * as platformRequests from './platform.js';
|
|
27
27
|
import * as routingRequests from './routing.js';
|
|
28
|
+
import * as secretRequests from './secret.js';
|
|
28
29
|
import * as secretBundleRequests from './secretbundle.js';
|
|
29
30
|
import * as secretGroupRequests from './secretgroup.js';
|
|
30
31
|
import * as serverRequests from './server.js';
|
|
@@ -61,6 +62,7 @@ export {
|
|
|
61
62
|
nodeRequests as node,
|
|
62
63
|
platformRequests as platform,
|
|
63
64
|
routingRequests as routing,
|
|
65
|
+
secretRequests as secret,
|
|
64
66
|
secretBundleRequests as secretbundle,
|
|
65
67
|
secretGroupRequests as secretgroup,
|
|
66
68
|
serverRequests as server,
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import type * as plugins from '../plugins.js';
|
|
2
|
+
import type {
|
|
3
|
+
IResolvedSecretManifestEntry,
|
|
4
|
+
ISecretMetadata,
|
|
5
|
+
ISecretSetAttachment,
|
|
6
|
+
ISecretSetConsumerRolloutStatus,
|
|
7
|
+
ISecretSetMetadata,
|
|
8
|
+
ISecretVersionMetadata,
|
|
9
|
+
ISecretVersionRetentionReference,
|
|
10
|
+
TSecretDelivery,
|
|
11
|
+
TSecretEnvironment,
|
|
12
|
+
} from '../data/secret.js';
|
|
13
|
+
import type { IIdentityCredential } from '../data/user.js';
|
|
14
|
+
|
|
15
|
+
export type TSecretMutationTarget =
|
|
16
|
+
| { kind: 'service'; serviceId: string }
|
|
17
|
+
| { kind: 'secret-set'; secretSetId: string };
|
|
18
|
+
|
|
19
|
+
export type TSecretValueInput =
|
|
20
|
+
| { mode: 'provided'; value: string }
|
|
21
|
+
/** Server-generated runtime-only value; plaintext is never returned. */
|
|
22
|
+
| { mode: 'generated'; bytes: 32 | 48 | 64 };
|
|
23
|
+
|
|
24
|
+
export interface IReq_ListSecrets extends plugins.typedrequestInterfaces.implementsTR<
|
|
25
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
26
|
+
IReq_ListSecrets
|
|
27
|
+
> {
|
|
28
|
+
method: 'listSecrets';
|
|
29
|
+
request: {
|
|
30
|
+
identity: IIdentityCredential;
|
|
31
|
+
target: TSecretMutationTarget;
|
|
32
|
+
environment?: TSecretEnvironment;
|
|
33
|
+
};
|
|
34
|
+
response: {
|
|
35
|
+
secrets: ISecretMetadata[];
|
|
36
|
+
/** Observable CAS fence for the selected service or SecretSet. */
|
|
37
|
+
targetSecretsRevision: number;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface IReq_GetSecretMetadata extends plugins.typedrequestInterfaces.implementsTR<
|
|
42
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
43
|
+
IReq_GetSecretMetadata
|
|
44
|
+
> {
|
|
45
|
+
method: 'getSecretMetadata';
|
|
46
|
+
request: {
|
|
47
|
+
identity: IIdentityCredential;
|
|
48
|
+
secretId: string;
|
|
49
|
+
};
|
|
50
|
+
response: {
|
|
51
|
+
secret: ISecretMetadata;
|
|
52
|
+
versions: ISecretVersionMetadata[];
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export interface IReq_CreateSecret extends plugins.typedrequestInterfaces.implementsTR<
|
|
57
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
58
|
+
IReq_CreateSecret
|
|
59
|
+
> {
|
|
60
|
+
method: 'createSecret';
|
|
61
|
+
request: {
|
|
62
|
+
identity: IIdentityCredential;
|
|
63
|
+
target: TSecretMutationTarget;
|
|
64
|
+
key: string;
|
|
65
|
+
environment: TSecretEnvironment;
|
|
66
|
+
name: string;
|
|
67
|
+
description?: string;
|
|
68
|
+
tags?: Array<{ key: string; value: string }>;
|
|
69
|
+
delivery: TSecretDelivery;
|
|
70
|
+
valueInput: TSecretValueInput;
|
|
71
|
+
expectedTargetSecretsRevision: number;
|
|
72
|
+
};
|
|
73
|
+
response: {
|
|
74
|
+
secret: ISecretMetadata;
|
|
75
|
+
version: ISecretVersionMetadata;
|
|
76
|
+
/** Post-create CAS revision for the selected target. */
|
|
77
|
+
targetSecretsRevision: number;
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface IReq_RotateSecret extends plugins.typedrequestInterfaces.implementsTR<
|
|
82
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
83
|
+
IReq_RotateSecret
|
|
84
|
+
> {
|
|
85
|
+
method: 'rotateSecret';
|
|
86
|
+
request: {
|
|
87
|
+
identity: IIdentityCredential;
|
|
88
|
+
secretId: string;
|
|
89
|
+
valueInput: TSecretValueInput;
|
|
90
|
+
expectedSecretRevision: number;
|
|
91
|
+
expectedActiveVersionId?: string;
|
|
92
|
+
};
|
|
93
|
+
response: {
|
|
94
|
+
secret: ISecretMetadata;
|
|
95
|
+
version: ISecretVersionMetadata;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export interface IReq_ChangeSecretLifecycle extends plugins.typedrequestInterfaces.implementsTR<
|
|
100
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
101
|
+
IReq_ChangeSecretLifecycle
|
|
102
|
+
> {
|
|
103
|
+
method: 'changeSecretLifecycle';
|
|
104
|
+
request: {
|
|
105
|
+
identity: IIdentityCredential;
|
|
106
|
+
secretId: string;
|
|
107
|
+
action: 'retire' | 'revoke' | 'delete' | 'request-purge';
|
|
108
|
+
expectedSecretRevision: number;
|
|
109
|
+
};
|
|
110
|
+
response: {
|
|
111
|
+
secret: ISecretMetadata;
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface IReq_GetSecretVersionPurgePreflight
|
|
116
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
117
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
118
|
+
IReq_GetSecretVersionPurgePreflight
|
|
119
|
+
> {
|
|
120
|
+
method: 'getSecretVersionPurgePreflight';
|
|
121
|
+
request: {
|
|
122
|
+
identity: IIdentityCredential;
|
|
123
|
+
secretId: string;
|
|
124
|
+
secretVersionId: string;
|
|
125
|
+
};
|
|
126
|
+
response: {
|
|
127
|
+
purgeAllowed: boolean;
|
|
128
|
+
references: ISecretVersionRetentionReference[];
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface IReq_ListSecretSets extends plugins.typedrequestInterfaces.implementsTR<
|
|
133
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
134
|
+
IReq_ListSecretSets
|
|
135
|
+
> {
|
|
136
|
+
method: 'listSecretSets';
|
|
137
|
+
request: {
|
|
138
|
+
identity: IIdentityCredential;
|
|
139
|
+
organizationId: string;
|
|
140
|
+
};
|
|
141
|
+
response: {
|
|
142
|
+
secretSets: ISecretSetMetadata[];
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface IReq_CreateSecretSet extends plugins.typedrequestInterfaces.implementsTR<
|
|
147
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
148
|
+
IReq_CreateSecretSet
|
|
149
|
+
> {
|
|
150
|
+
method: 'createSecretSet';
|
|
151
|
+
request: {
|
|
152
|
+
identity: IIdentityCredential;
|
|
153
|
+
organizationId: string;
|
|
154
|
+
name: string;
|
|
155
|
+
description?: string;
|
|
156
|
+
};
|
|
157
|
+
response: {
|
|
158
|
+
secretSet: ISecretSetMetadata;
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export interface IReq_UpdateSecretSet extends plugins.typedrequestInterfaces.implementsTR<
|
|
163
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
164
|
+
IReq_UpdateSecretSet
|
|
165
|
+
> {
|
|
166
|
+
method: 'updateSecretSet';
|
|
167
|
+
request: {
|
|
168
|
+
identity: IIdentityCredential;
|
|
169
|
+
secretSetId: string;
|
|
170
|
+
name: string;
|
|
171
|
+
description?: string;
|
|
172
|
+
expectedRevision: number;
|
|
173
|
+
};
|
|
174
|
+
response: {
|
|
175
|
+
secretSet: ISecretSetMetadata;
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface IReq_ChangeSecretSetLifecycle
|
|
180
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
181
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
182
|
+
IReq_ChangeSecretSetLifecycle
|
|
183
|
+
> {
|
|
184
|
+
method: 'changeSecretSetLifecycle';
|
|
185
|
+
request: {
|
|
186
|
+
identity: IIdentityCredential;
|
|
187
|
+
secretSetId: string;
|
|
188
|
+
action: 'retire' | 'delete';
|
|
189
|
+
expectedRevision: number;
|
|
190
|
+
};
|
|
191
|
+
response: {
|
|
192
|
+
secretSet: ISecretSetMetadata;
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface IReq_GetSecretSetConsumerRollout
|
|
197
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
198
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
199
|
+
IReq_GetSecretSetConsumerRollout
|
|
200
|
+
> {
|
|
201
|
+
method: 'getSecretSetConsumerRollout';
|
|
202
|
+
request: {
|
|
203
|
+
identity: IIdentityCredential;
|
|
204
|
+
secretSetId: string;
|
|
205
|
+
rolloutId: string;
|
|
206
|
+
cursor?: string;
|
|
207
|
+
limit?: number;
|
|
208
|
+
};
|
|
209
|
+
response: {
|
|
210
|
+
consumers: ISecretSetConsumerRolloutStatus[];
|
|
211
|
+
nextCursor?: string;
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export interface IReq_SetServiceSecretSetAttachments
|
|
216
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
217
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
218
|
+
IReq_SetServiceSecretSetAttachments
|
|
219
|
+
> {
|
|
220
|
+
method: 'setServiceSecretSetAttachments';
|
|
221
|
+
request: {
|
|
222
|
+
identity: IIdentityCredential;
|
|
223
|
+
serviceId: string;
|
|
224
|
+
attachments: ISecretSetAttachment[];
|
|
225
|
+
expectedSecretConfigurationRevision: number;
|
|
226
|
+
};
|
|
227
|
+
response: {
|
|
228
|
+
attachments: ISecretSetAttachment[];
|
|
229
|
+
/** Post-update attachment CAS revision. */
|
|
230
|
+
secretConfigurationRevision: number;
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export interface ISecretResolutionPreviewCollision {
|
|
235
|
+
environment: TSecretEnvironment;
|
|
236
|
+
key: string;
|
|
237
|
+
sourceSecretIds: string[];
|
|
238
|
+
reason: 'duplicate-secret-set-key' | 'duplicate-service-key' | 'invalid-alias';
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export interface IReq_PreviewServiceSecretResolution
|
|
242
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
243
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
244
|
+
IReq_PreviewServiceSecretResolution
|
|
245
|
+
> {
|
|
246
|
+
method: 'previewServiceSecretResolution';
|
|
247
|
+
request: {
|
|
248
|
+
identity: IIdentityCredential;
|
|
249
|
+
serviceId: string;
|
|
250
|
+
attachments?: ISecretSetAttachment[];
|
|
251
|
+
};
|
|
252
|
+
response: {
|
|
253
|
+
entries: IResolvedSecretManifestEntry[];
|
|
254
|
+
collisions: ISecretResolutionPreviewCollision[];
|
|
255
|
+
};
|
|
256
|
+
}
|
package/ts/runtime.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type * as plugins from './plugins.js';
|
|
2
|
+
import type {
|
|
3
|
+
IIdentityCredential,
|
|
4
|
+
IResolvedSecretManifest,
|
|
5
|
+
TSha256Digest,
|
|
6
|
+
} from './data/index.js';
|
|
7
|
+
import {
|
|
8
|
+
validateResolvedSecretManifest,
|
|
9
|
+
verifyResolvedSecretManifestDigest,
|
|
10
|
+
} from './data/secret.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Runtime-only material. This module is exported only under the Node condition
|
|
14
|
+
* and is intentionally unreachable from the universal/browser-facing barrel.
|
|
15
|
+
*/
|
|
16
|
+
export interface IResolvedSecretMaterialValue {
|
|
17
|
+
secretVersionId: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IResolvedSecretMaterial {
|
|
22
|
+
schemaVersion: 1;
|
|
23
|
+
/** Full value-free manifest so the runtime can verify its canonical digest. */
|
|
24
|
+
manifest: IResolvedSecretManifest;
|
|
25
|
+
/** Plaintext values keyed only by the exact version IDs pinned by the manifest. */
|
|
26
|
+
values: IResolvedSecretMaterialValue[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Verifies the immutable manifest and requires exactly one material value for
|
|
31
|
+
* every pinned version. Callers separately compare the verified manifest
|
|
32
|
+
* reference to the request and their authenticated cluster scope.
|
|
33
|
+
*/
|
|
34
|
+
export const verifyResolvedSecretMaterial = async (
|
|
35
|
+
materialArg: unknown,
|
|
36
|
+
): Promise<boolean> => {
|
|
37
|
+
if (!materialArg || typeof materialArg !== 'object' || Array.isArray(materialArg)) return false;
|
|
38
|
+
const material = materialArg as Partial<IResolvedSecretMaterial>;
|
|
39
|
+
if (!material.manifest || !Array.isArray(material.values)) return false;
|
|
40
|
+
if (material.schemaVersion !== 1) return false;
|
|
41
|
+
if (validateResolvedSecretManifest(material.manifest).length > 0) return false;
|
|
42
|
+
if (!await verifyResolvedSecretManifestDigest(material.manifest)) return false;
|
|
43
|
+
if (!material.values.every((valueArg) => (
|
|
44
|
+
Boolean(valueArg)
|
|
45
|
+
&& typeof valueArg === 'object'
|
|
46
|
+
&& typeof valueArg.secretVersionId === 'string'
|
|
47
|
+
&& typeof valueArg.value === 'string'
|
|
48
|
+
))) return false;
|
|
49
|
+
const expectedVersionIds = material.manifest.entries
|
|
50
|
+
.map((entryArg) => entryArg.secretVersionId)
|
|
51
|
+
.sort();
|
|
52
|
+
const actualVersionIds = material.values
|
|
53
|
+
.map((valueArg) => valueArg.secretVersionId)
|
|
54
|
+
.sort();
|
|
55
|
+
return new Set(actualVersionIds).size === actualVersionIds.length
|
|
56
|
+
&& JSON.stringify(actualVersionIds) === JSON.stringify(expectedVersionIds);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Cluster and organization are derived from the verified JWT. A caller cannot
|
|
61
|
+
* select either scope through request fields.
|
|
62
|
+
*/
|
|
63
|
+
export interface IReq_GetResolvedSecretMaterial
|
|
64
|
+
extends plugins.typedrequestInterfaces.implementsTR<
|
|
65
|
+
plugins.typedrequestInterfaces.ITypedRequest,
|
|
66
|
+
IReq_GetResolvedSecretMaterial
|
|
67
|
+
> {
|
|
68
|
+
method: 'getResolvedSecretMaterial';
|
|
69
|
+
request: {
|
|
70
|
+
identity: IIdentityCredential;
|
|
71
|
+
serviceId: string;
|
|
72
|
+
secretRolloutId: string;
|
|
73
|
+
secretRolloutGeneration: number;
|
|
74
|
+
manifestId: string;
|
|
75
|
+
manifestDigest: TSha256Digest;
|
|
76
|
+
};
|
|
77
|
+
response: {
|
|
78
|
+
material: IResolvedSecretMaterial;
|
|
79
|
+
};
|
|
80
|
+
}
|