@limrun/api 0.70.1 → 0.70.2

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.
Files changed (115) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/client.d.mts +1 -0
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +1 -0
  5. package/client.d.ts.map +1 -1
  6. package/client.js +1 -0
  7. package/client.js.map +1 -1
  8. package/client.mjs +1 -0
  9. package/client.mjs.map +1 -1
  10. package/exec-client.d.mts +9 -0
  11. package/exec-client.d.mts.map +1 -1
  12. package/exec-client.d.ts +9 -0
  13. package/exec-client.d.ts.map +1 -1
  14. package/exec-client.js.map +1 -1
  15. package/exec-client.mjs.map +1 -1
  16. package/index.d.mts +1 -0
  17. package/index.d.mts.map +1 -1
  18. package/index.d.ts +1 -0
  19. package/index.d.ts.map +1 -1
  20. package/index.js +1 -0
  21. package/index.js.map +1 -1
  22. package/index.mjs +1 -0
  23. package/index.mjs.map +1 -1
  24. package/instance-client.d.mts +2 -0
  25. package/instance-client.d.mts.map +1 -1
  26. package/instance-client.d.ts +2 -0
  27. package/instance-client.d.ts.map +1 -1
  28. package/instance-client.js +6 -2
  29. package/instance-client.js.map +1 -1
  30. package/instance-client.mjs +6 -2
  31. package/instance-client.mjs.map +1 -1
  32. package/ios-client.d.mts +3 -0
  33. package/ios-client.d.mts.map +1 -1
  34. package/ios-client.d.ts +3 -0
  35. package/ios-client.d.ts.map +1 -1
  36. package/ios-client.js +5 -2
  37. package/ios-client.js.map +1 -1
  38. package/ios-client.mjs +5 -2
  39. package/ios-client.mjs.map +1 -1
  40. package/package.json +1 -1
  41. package/resources/android-instances.d.mts +7 -1
  42. package/resources/android-instances.d.mts.map +1 -1
  43. package/resources/android-instances.d.ts +7 -1
  44. package/resources/android-instances.d.ts.map +1 -1
  45. package/resources/daemon-client-shared.d.mts +3 -0
  46. package/resources/daemon-client-shared.d.mts.map +1 -1
  47. package/resources/daemon-client-shared.d.ts +3 -0
  48. package/resources/daemon-client-shared.d.ts.map +1 -1
  49. package/resources/daemon-client-shared.js +2 -0
  50. package/resources/daemon-client-shared.js.map +1 -1
  51. package/resources/daemon-client-shared.mjs +2 -0
  52. package/resources/daemon-client-shared.mjs.map +1 -1
  53. package/resources/gradle-instances-helpers.d.mts +3 -0
  54. package/resources/gradle-instances-helpers.d.mts.map +1 -1
  55. package/resources/gradle-instances-helpers.d.ts +3 -0
  56. package/resources/gradle-instances-helpers.d.ts.map +1 -1
  57. package/resources/gradle-instances-helpers.js +2 -0
  58. package/resources/gradle-instances-helpers.js.map +1 -1
  59. package/resources/gradle-instances-helpers.mjs +2 -0
  60. package/resources/gradle-instances-helpers.mjs.map +1 -1
  61. package/resources/gradle-instances.d.mts +10 -1
  62. package/resources/gradle-instances.d.mts.map +1 -1
  63. package/resources/gradle-instances.d.ts +10 -1
  64. package/resources/gradle-instances.d.ts.map +1 -1
  65. package/resources/index.d.mts +1 -0
  66. package/resources/index.d.mts.map +1 -1
  67. package/resources/index.d.ts +1 -0
  68. package/resources/index.d.ts.map +1 -1
  69. package/resources/index.js +2 -0
  70. package/resources/index.js.map +1 -1
  71. package/resources/index.mjs +1 -0
  72. package/resources/index.mjs.map +1 -1
  73. package/resources/ios-instances.d.mts +7 -1
  74. package/resources/ios-instances.d.mts.map +1 -1
  75. package/resources/ios-instances.d.ts +7 -1
  76. package/resources/ios-instances.d.ts.map +1 -1
  77. package/resources/secrets.d.mts +66 -0
  78. package/resources/secrets.d.mts.map +1 -0
  79. package/resources/secrets.d.ts +66 -0
  80. package/resources/secrets.d.ts.map +1 -0
  81. package/resources/secrets.js +141 -0
  82. package/resources/secrets.js.map +1 -0
  83. package/resources/secrets.mjs +137 -0
  84. package/resources/secrets.mjs.map +1 -0
  85. package/resources/xcode-instances-helpers.d.mts +3 -0
  86. package/resources/xcode-instances-helpers.d.mts.map +1 -1
  87. package/resources/xcode-instances-helpers.d.ts +3 -0
  88. package/resources/xcode-instances-helpers.d.ts.map +1 -1
  89. package/resources/xcode-instances-helpers.js +2 -0
  90. package/resources/xcode-instances-helpers.js.map +1 -1
  91. package/resources/xcode-instances-helpers.mjs +2 -0
  92. package/resources/xcode-instances-helpers.mjs.map +1 -1
  93. package/resources/xcode-instances.d.mts +10 -1
  94. package/resources/xcode-instances.d.mts.map +1 -1
  95. package/resources/xcode-instances.d.ts +10 -1
  96. package/resources/xcode-instances.d.ts.map +1 -1
  97. package/src/client.ts +1 -0
  98. package/src/exec-client.ts +9 -0
  99. package/src/index.ts +2 -0
  100. package/src/instance-client.ts +9 -3
  101. package/src/ios-client.ts +23 -10
  102. package/src/resources/android-instances.ts +7 -1
  103. package/src/resources/daemon-client-shared.ts +5 -0
  104. package/src/resources/gradle-instances-helpers.ts +5 -0
  105. package/src/resources/gradle-instances.ts +10 -1
  106. package/src/resources/index.ts +2 -0
  107. package/src/resources/ios-instances.ts +7 -1
  108. package/src/resources/secrets.ts +210 -0
  109. package/src/resources/xcode-instances-helpers.ts +5 -0
  110. package/src/resources/xcode-instances.ts +10 -1
  111. package/src/version.ts +1 -1
  112. package/version.d.mts +1 -1
  113. package/version.d.ts +1 -1
  114. package/version.js +1 -1
  115. package/version.mjs +1 -1
@@ -0,0 +1,210 @@
1
+ import { APIResource } from '../core/resource';
2
+ import { APIPromise } from '../core/api-promise';
3
+ import { RequestOptions } from '../internal/request-options';
4
+ import { buildHeaders } from '../internal/headers';
5
+ import { getDefaultFetch } from '../internal/shims';
6
+
7
+ /** Descriptive data stored by Limrun. Never put credentials in metadata. */
8
+ export interface SecretMetadata {
9
+ id: string;
10
+ name: string;
11
+ type: string;
12
+ organizationId: string;
13
+ metadata: Record<string, unknown>;
14
+ storageLocation: 'us' | 'eu';
15
+ state: 'pending' | 'ready' | 'deleting';
16
+ createdAt: string;
17
+ }
18
+ export interface SecretCreateParams {
19
+ name: string;
20
+ type: string;
21
+ metadata?: Record<string, unknown>;
22
+ }
23
+ export interface SecretUpdateParams {
24
+ /** Replaces descriptive metadata; does not change the name, type, or value. */
25
+ metadata: Record<string, unknown>;
26
+ }
27
+ export interface SecretListParams {
28
+ nameFilter?: string;
29
+ limit?: number;
30
+ offset?: number;
31
+ }
32
+ export interface SecretListResponse {
33
+ secrets: SecretMetadata[];
34
+ }
35
+ export interface SecretAccessToken {
36
+ accessToken: string;
37
+ expiresAt: string;
38
+ resource: string;
39
+ action: 'read' | 'write';
40
+ }
41
+ export interface SecretRequestOptions extends RequestOptions {
42
+ /** Defaults to the organization returned by whoami. */
43
+ organizationId?: string;
44
+ }
45
+ export interface SecretValueOptions extends RequestOptions {
46
+ /** Transport for direct Google requests, separate from the authenticated Limrun transport. */
47
+ storageFetch?: typeof fetch;
48
+ }
49
+
50
+ const resourcePattern = /^projects\/[a-zA-Z0-9-]+\/secrets\/secret_[0-7][0-9a-hjkmnp-tv-z]{25}$/;
51
+ const maxBytes = 65536;
52
+
53
+ function checksum(bytes: Uint8Array): string {
54
+ let crc = 0xffffffff;
55
+ for (const byte of bytes) {
56
+ crc ^= byte;
57
+ for (let bit = 0; bit < 8; bit++) crc = (crc >>> 1) ^ (crc & 1 ? 0x82f63b78 : 0);
58
+ }
59
+ return String((crc ^ 0xffffffff) >>> 0);
60
+ }
61
+
62
+ export class Secrets extends APIResource {
63
+ /** Create a container. Duplicate names return 409; values are written separately. */
64
+ create(body: SecretCreateParams, options?: RequestOptions): APIPromise<SecretMetadata> {
65
+ return this._client.post('/v1/secrets', { body, ...options });
66
+ }
67
+
68
+ /** Update descriptive metadata by TID or name/<exact name>, without accessing its value. */
69
+ update(target: string, body: SecretUpdateParams, options?: RequestOptions): APIPromise<SecretMetadata> {
70
+ return this._client.patch(`/v1/secrets/${encodeURIComponent(target)}`, { body, ...options });
71
+ }
72
+
73
+ private async collection(
74
+ options: SecretRequestOptions = {},
75
+ ): Promise<{ path: string; options: RequestOptions }> {
76
+ const { organizationId, ...request } = options;
77
+ let org = organizationId;
78
+ if (!org) {
79
+ const identity = await this._client.get<{
80
+ organization?: { id?: string };
81
+ user?: { defaultOrganization?: { id?: string } };
82
+ }>('/v1/whoami', request);
83
+ org = identity.organization?.id ?? identity.user?.defaultOrganization?.id;
84
+ }
85
+ if (!org) throw new Error('No organization found. Provide organizationId explicitly.');
86
+ return { path: `/v1/organizations/${encodeURIComponent(org)}/secrets`, options: request };
87
+ }
88
+
89
+ /** List metadata visible to this credential. Values are never included. */
90
+ async list(query: SecretListParams = {}, options?: SecretRequestOptions): Promise<SecretListResponse> {
91
+ const collection = await this.collection(options);
92
+ return this._client.get(collection.path, { ...collection.options, query });
93
+ }
94
+
95
+ /** Fetch metadata by TID or name/<exact name>. */
96
+ async get(target: string, options?: SecretRequestOptions): Promise<SecretMetadata> {
97
+ if (target.startsWith('name/')) {
98
+ const result = await this.list({ nameFilter: target.slice(5), limit: 1 }, options);
99
+ if (!result.secrets[0]) throw new Error('Secret not found.');
100
+ return result.secrets[0];
101
+ }
102
+ const collection = await this.collection(options);
103
+ return this._client.get(`${collection.path}/${encodeURIComponent(target)}`, collection.options);
104
+ }
105
+
106
+ /** Delete the container and all its versions. */
107
+ async delete(target: string, options?: SecretRequestOptions): Promise<void> {
108
+ const id = target.startsWith('name/') ? (await this.get(target, options)).id : target;
109
+ const collection = await this.collection(options);
110
+ await this._client.delete(`${collection.path}/${encodeURIComponent(id)}`, {
111
+ ...collection.options,
112
+ headers: buildHeaders([{ Accept: '*/*' }, collection.options.headers]),
113
+ });
114
+ }
115
+
116
+ /** Mint access to one secret; no metadata-read permission is needed. */
117
+ createAccessToken(
118
+ target: string,
119
+ action: 'read' | 'write',
120
+ options?: RequestOptions,
121
+ ): APIPromise<SecretAccessToken> {
122
+ // Debug logging must not expose the provider bearer credential.
123
+ return this._client.withOptions({ logLevel: 'off' }).post('/v1/secrets/access_tokens', {
124
+ ...options,
125
+ body: { target, action },
126
+ });
127
+ }
128
+
129
+ private async transfer(
130
+ target: string,
131
+ action: 'read' | 'write',
132
+ bytes: Uint8Array | undefined,
133
+ options: SecretValueOptions = {},
134
+ ): Promise<Response> {
135
+ const { storageFetch = getDefaultFetch(), ...request } = options;
136
+ const timeout = AbortSignal.timeout(options.timeout ?? this._client.timeout);
137
+ const signal = options.signal ? AbortSignal.any([options.signal, timeout]) : timeout;
138
+ const grant = await this.createAccessToken(target, action, { ...request, signal });
139
+ if (
140
+ grant.action !== action ||
141
+ !resourcePattern.test(grant.resource) ||
142
+ (!target.startsWith('name/') && !grant.resource.endsWith(`/${target}`))
143
+ ) {
144
+ throw new Error('Invalid secret access grant.');
145
+ }
146
+ signal.throwIfAborted();
147
+ let response: Response;
148
+ try {
149
+ response = await storageFetch(
150
+ `https://secretmanager.googleapis.com/v1/${grant.resource}${
151
+ action === 'read' ? '/versions/latest:access' : ':addVersion'
152
+ }`,
153
+ {
154
+ method: action === 'read' ? 'GET' : 'POST',
155
+ credentials: 'omit',
156
+ ...{ cache: 'no-store', referrerPolicy: 'no-referrer' },
157
+ redirect: 'error',
158
+ signal,
159
+ headers: {
160
+ Authorization: `Bearer ${grant.accessToken}`,
161
+ ...(bytes ? { 'Content-Type': 'application/json' } : {}),
162
+ },
163
+ ...(bytes ?
164
+ {
165
+ body: JSON.stringify({
166
+ payload: {
167
+ data: btoa(Array.from(bytes, (b) => String.fromCharCode(b)).join('')),
168
+ dataCrc32c: checksum(bytes),
169
+ },
170
+ }),
171
+ }
172
+ : {}),
173
+ },
174
+ );
175
+ } catch {
176
+ throw new Error(
177
+ signal.aborted ? 'Secret storage request was aborted.' : 'Secret storage request failed.',
178
+ );
179
+ }
180
+ // Provider error bodies may echo secret material. Never include them in errors or logs.
181
+ if (!response.ok) throw new Error(`Secret storage request failed (HTTP ${response.status}).`);
182
+ return response;
183
+ }
184
+
185
+ /** Read bytes directly from Google. Does not fetch or cache metadata. */
186
+ async read(target: string, options?: SecretValueOptions): Promise<Uint8Array> {
187
+ const response = await this.transfer(target, 'read', undefined, options);
188
+ let value: { payload?: { data?: string; dataCrc32c?: string } };
189
+ let bytes: Uint8Array;
190
+ try {
191
+ value = (await response.json()) as typeof value;
192
+ if (typeof value.payload?.data !== 'string' || value.payload.data.length > Math.ceil(maxBytes / 3) * 4)
193
+ throw new Error();
194
+ bytes = Uint8Array.from(atob(value.payload.data), (c) => c.charCodeAt(0));
195
+ } catch {
196
+ throw new Error('Secret storage returned an invalid value.');
197
+ }
198
+ if (bytes.length > maxBytes || checksum(bytes) !== String(value.payload?.dataCrc32c))
199
+ throw new Error('Secret integrity check failed.');
200
+ return bytes;
201
+ }
202
+
203
+ /** Add a version directly in Google. Accepts UTF-8 text or binary data, up to 64 KiB. */
204
+ async write(target: string, value: string | Uint8Array, options?: SecretValueOptions): Promise<void> {
205
+ const bytes = typeof value === 'string' ? new TextEncoder().encode(value) : value;
206
+ if (!bytes.length || bytes.length > maxBytes)
207
+ throw new Error('Secret values must contain between 1 byte and 64 KiB.');
208
+ await this.transfer(target, 'write', bytes, options);
209
+ }
210
+ }
@@ -293,6 +293,9 @@ export type XcodeBuildOptions = {
293
293
  * silently ignore this option.
294
294
  */
295
295
  env?: string[];
296
+ /** Secret references resolved by the workload; overrides saved bindings for this operation. */
297
+ envFromSecret?: Record<string, string>;
298
+ fileFromSecret?: Record<string, string>;
296
299
  /**
297
300
  * Run `git init` in the synced workspace before project generation,
298
301
  * dependency resolution, and xcodebuild.
@@ -1074,6 +1077,8 @@ export class XcodeInstances extends GeneratedXcodeInstances {
1074
1077
  ...(options?.appstore && { testflight: options.appstore }),
1075
1078
  ...(options?.buildSettings && { buildSettings: options.buildSettings }),
1076
1079
  ...(options?.env?.length && { env: options.env }),
1080
+ ...(options?.envFromSecret && { envFromSecret: options.envFromSecret }),
1081
+ ...(options?.fileFromSecret && { fileFromSecret: options.fileFromSecret }),
1077
1082
  ...(options?.gitInit !== undefined && { gitInit: options.gitInit }),
1078
1083
  ...(options?.logProcessor && { logProcessor: options.logProcessor }),
1079
1084
  ...(options?.webhook && { webhook: options.webhook }),
@@ -81,6 +81,9 @@ export namespace XcodeInstance {
81
81
 
82
82
  export interface Spec {
83
83
  /** Current effective permissions. Present on live GETs; historical records may omit it. */
84
+ /** Environment variable names mapped to secret TIDs or name/<exact-name> targets. */
85
+ envFromSecret?: Record<string, string>;
86
+ fileFromSecret?: Record<string, string>;
84
87
  role?: { permissions: string[] };
85
88
 
86
89
  inactivityTimeout: string;
@@ -126,7 +129,10 @@ export interface XcodeInstanceUpdateParams {
126
129
  /** Replaces all customer labels. Use {} to clear them. Omission preserves labels. */
127
130
  metadata?: { labels: { [key: string]: string } };
128
131
  spec?: {
129
- role: {
132
+ /** Replaces saved bindings. Use {} to clear them. */
133
+ envFromSecret?: Record<string, string>;
134
+ fileFromSecret?: Record<string, string>;
135
+ role?: {
130
136
  /** Replaces the complete list. Use [] to remove delegated permissions. */
131
137
  permissions: string[];
132
138
  };
@@ -165,6 +171,9 @@ export namespace XcodeInstanceCreateParams {
165
171
 
166
172
  export interface Spec {
167
173
  /** Inline instance role. Omit for the organization's compatibility default. */
174
+ /** Environment variable names mapped to secret TIDs or name/<exact-name> targets. */
175
+ envFromSecret?: Record<string, string>;
176
+ fileFromSecret?: Record<string, string>;
168
177
  role?: {
169
178
  /** Asset permissions delegated by the creator. An empty array grants nothing. */
170
179
  permissions: Array<string>;
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '0.70.1'; // x-release-please-version
1
+ export const VERSION = '0.70.2'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.70.1";
1
+ export declare const VERSION = "0.70.2";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "0.70.1";
1
+ export declare const VERSION = "0.70.2";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '0.70.1'; // x-release-please-version
4
+ exports.VERSION = '0.70.2'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '0.70.1'; // x-release-please-version
1
+ export const VERSION = '0.70.2'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map