@wix/secrets 1.0.31 → 1.0.32

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.
@@ -1 +1,2 @@
1
- export * as secrets from '@wix/secrets_secrets';
1
+ import * as secrets from '@wix/secrets_secrets';
2
+ export { secrets };
@@ -24,5 +24,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
24
24
  };
25
25
  Object.defineProperty(exports, "__esModule", { value: true });
26
26
  exports.secrets = void 0;
27
- exports.secrets = __importStar(require("@wix/secrets_secrets"));
27
+ const secrets = __importStar(require("@wix/secrets_secrets"));
28
+ exports.secrets = secrets;
28
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gEAAgD"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8DAAgD;AAEvC,0BAAO"}
@@ -1 +1,2 @@
1
- export * as secrets from '@wix/secrets_secrets';
1
+ import * as secrets from '@wix/secrets_secrets';
2
+ export { secrets };
package/build/es/index.js CHANGED
@@ -1,2 +1,3 @@
1
- export * as secrets from '@wix/secrets_secrets';
1
+ import * as secrets from '@wix/secrets_secrets';
2
+ export { secrets };
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,OAAO,EAAE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wix/secrets",
3
- "version": "1.0.31",
3
+ "version": "1.0.32",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"
@@ -18,7 +18,7 @@
18
18
  "type-bundles"
19
19
  ],
20
20
  "dependencies": {
21
- "@wix/secrets_secrets": "1.0.20"
21
+ "@wix/secrets_secrets": "1.0.21"
22
22
  },
23
23
  "devDependencies": {
24
24
  "glob": "^10.4.1",
@@ -27,8 +27,9 @@
27
27
  "typescript": "^5.3.2"
28
28
  },
29
29
  "scripts": {
30
- "build": "tsc -b tsconfig.json tsconfig.esm.json && npm run build:dts-bundles",
31
- "build:dts-bundles": "test -f config/rollup-config.js && rollup --config config/rollup-config.js || echo 'Warning: config/rollup-config.js not found!'",
30
+ "build": "tsc -b tsconfig.json tsconfig.esm.json && npm run build:dts-bundles && npm run build:validate-dts",
31
+ "build:dts-bundles": "test -f config/rollup-config.js && NODE_OPTIONS=--max-old-space-size=8192 rollup --config config/rollup-config.js || echo 'Warning: config/rollup-config.js not found!'",
32
+ "build:validate-dts": "tsc type-bundles/*.d.ts --noEmit",
32
33
  "test": ":"
33
34
  },
34
35
  "wix": {
@@ -42,5 +43,5 @@
42
43
  "fqdn": ""
43
44
  }
44
45
  },
45
- "falconPackageHash": "615c42017ade1a03bea476ef5c2d3ebf8d8e3fe74a7012850d805162"
46
+ "falconPackageHash": "5c624b6e2479b12081513a8d1f88006bf58489807c15deb35946876f"
46
47
  }
@@ -1,3 +1,47 @@
1
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
2
+ interface HttpClient {
3
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
4
+ fetchWithAuth: typeof fetch;
5
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
6
+ }
7
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
8
+ type HttpResponse<T = any> = {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: any;
13
+ request?: any;
14
+ };
15
+ type RequestOptions<_TResponse = any, Data = any> = {
16
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
+ url: string;
18
+ data?: Data;
19
+ params?: URLSearchParams;
20
+ } & APIMetadata;
21
+ type APIMetadata = {
22
+ methodFqn?: string;
23
+ entityFqdn?: string;
24
+ packageName?: string;
25
+ };
26
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
27
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
28
+ __type: 'event-definition';
29
+ type: Type;
30
+ isDomainEvent?: boolean;
31
+ transformations?: (envelope: unknown) => Payload;
32
+ __payload: Payload;
33
+ };
34
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
35
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
36
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
37
+
38
+ declare global {
39
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
40
+ interface SymbolConstructor {
41
+ readonly observable: symbol;
42
+ }
43
+ }
44
+
1
45
  interface Secret {
2
46
  /**
3
47
  * The secret's unique ID.
@@ -24,6 +68,10 @@ interface Secret {
24
68
  */
25
69
  _updatedDate?: Date;
26
70
  }
71
+ interface GetSecretValueRequest {
72
+ /** The name of the secret to get the value of. */
73
+ name: string;
74
+ }
27
75
  interface GetSecretValueResponse {
28
76
  /**
29
77
  * The plaintext, unencrypted value of the secret.
@@ -31,10 +79,117 @@ interface GetSecretValueResponse {
31
79
  */
32
80
  value?: string;
33
81
  }
82
+ interface ListSecretInfoRequest {
83
+ }
34
84
  interface ListSecretInfoResponse {
35
85
  /** Object containing information for each secret. */
36
86
  secrets?: Secret[];
37
87
  }
88
+ interface CreateSecretRequest {
89
+ /** The object including the fields of a new secret. */
90
+ secret: Secret;
91
+ }
92
+ interface CreateSecretResponse {
93
+ /**
94
+ * The globally-unique ID assigned to the secret.
95
+ *
96
+ */
97
+ _id?: string;
98
+ }
99
+ interface DeleteSecretRequest {
100
+ /**
101
+ * The unique ID of the secret to be deleted.
102
+ *
103
+ */
104
+ _id: string;
105
+ }
106
+ interface DeleteSecretResponse {
107
+ }
108
+ interface UpdateSecretRequest {
109
+ /** The unique ID of the secret to be updated. */
110
+ _id: string;
111
+ /** The secret fields to update. */
112
+ secret: Secret;
113
+ }
114
+ interface UpdateSecretResponse {
115
+ }
116
+ interface DomainEvent extends DomainEventBodyOneOf {
117
+ createdEvent?: EntityCreatedEvent;
118
+ updatedEvent?: EntityUpdatedEvent;
119
+ deletedEvent?: EntityDeletedEvent;
120
+ actionEvent?: ActionEvent;
121
+ /**
122
+ * Unique event ID.
123
+ * Allows clients to ignore duplicate webhooks.
124
+ */
125
+ _id?: string;
126
+ /**
127
+ * Assumes actions are also always typed to an entity_type
128
+ * Example: wix.stores.catalog.product, wix.bookings.session, wix.payments.transaction
129
+ */
130
+ entityFqdn?: string;
131
+ /**
132
+ * This is top level to ease client code dispatching of messages (switch on entity_fqdn+slug)
133
+ * This is although the created/updated/deleted notion is duplication of the oneof types
134
+ * Example: created/updated/deleted/started/completed/email_opened
135
+ */
136
+ slug?: string;
137
+ /** ID of the entity associated with the event. */
138
+ entityId?: string;
139
+ /** Event timestamp. */
140
+ eventTime?: Date;
141
+ /**
142
+ * Whether the event was triggered as a result of a privacy regulation application
143
+ * (for example, GDPR).
144
+ */
145
+ triggeredByAnonymizeRequest?: boolean | null;
146
+ /** If present, indicates the action that triggered the event. */
147
+ originatedFrom?: string | null;
148
+ /**
149
+ * A sequence number defining the order of updates to the underlying entity.
150
+ * For example, given that some entity was updated at 16:00 and than again at 16:01,
151
+ * it is guaranteed that the sequence number of the second update is strictly higher than the first.
152
+ * As the consumer, you can use this value to ensure that you handle messages in the correct order.
153
+ * To do so, you will need to persist this number on your end, and compare the sequence number from the
154
+ * message against the one you have stored. Given that the stored number is higher, you should ignore the message.
155
+ */
156
+ entityEventSequence?: string | null;
157
+ }
158
+ /** @oneof */
159
+ interface DomainEventBodyOneOf {
160
+ createdEvent?: EntityCreatedEvent;
161
+ updatedEvent?: EntityUpdatedEvent;
162
+ deletedEvent?: EntityDeletedEvent;
163
+ actionEvent?: ActionEvent;
164
+ }
165
+ interface EntityCreatedEvent {
166
+ entity?: string;
167
+ }
168
+ interface EntityUpdatedEvent {
169
+ /**
170
+ * Since platformized APIs only expose PATCH and not PUT we can't assume that the fields sent from the client are the actual diff.
171
+ * This means that to generate a list of changed fields (as opposed to sent fields) one needs to traverse both objects.
172
+ * We don't want to impose this on all developers and so we leave this traversal to the notification recipients which need it.
173
+ */
174
+ currentEntity?: string;
175
+ }
176
+ interface EntityDeletedEvent {
177
+ /** Entity that was deleted */
178
+ deletedEntity?: string | null;
179
+ }
180
+ interface ActionEvent {
181
+ body?: string;
182
+ }
183
+ interface MessageEnvelope {
184
+ /** App instance ID. */
185
+ instanceId?: string | null;
186
+ /** Event type. */
187
+ eventType?: string;
188
+ /** The identification type and identity data. */
189
+ identity?: IdentificationData;
190
+ /** Stringify payload. */
191
+ data?: string;
192
+ }
38
193
  interface IdentificationData extends IdentificationDataIdOneOf {
39
194
  /** ID of a site visitor that has not logged in to the site. */
40
195
  anonymousVisitorId?: string;
@@ -68,8 +223,8 @@ declare enum WebhookIdentityType {
68
223
  interface GetSecretValueResponseNonNullableFields {
69
224
  value: string;
70
225
  }
71
- interface ListSecretInfoResponseNonNullableFields {
72
- secrets: Secret[];
226
+ interface CreateSecretResponseNonNullableFields {
227
+ _id: string;
73
228
  }
74
229
  interface BaseEventMetadata {
75
230
  /** App instance ID. */
@@ -129,67 +284,141 @@ interface SecretUpdatedEnvelope {
129
284
  metadata: EventMetadata;
130
285
  }
131
286
 
132
- type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
133
- interface HttpClient {
134
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
135
- fetchWithAuth: (url: string | URL, init?: RequestInit) => Promise<Response>;
287
+ declare function getSecretValue$1(httpClient: HttpClient): GetSecretValueSignature;
288
+ interface GetSecretValueSignature {
289
+ /**
290
+ * Retrieves the secret value specified by the secret name.
291
+ *
292
+ * The `getSecretValue()` function returns a Promise that resolves to the value of the secret with the specified given name.
293
+ *
294
+ * >**Note:**
295
+ * > Only use a secret's value in the backend code. Returning the secret value in the frontend is a security risk.
296
+ * @param - The name of the secret to get the value of.
297
+ * @returns Fulfilled - The value of the secret. Rejected - Error message.
298
+ */
299
+ (name: string): Promise<GetSecretValueResponse & GetSecretValueResponseNonNullableFields>;
136
300
  }
137
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
138
- type HttpResponse<T = any> = {
139
- data: T;
140
- status: number;
141
- statusText: string;
142
- headers: any;
143
- request?: any;
144
- };
145
- type RequestOptions<_TResponse = any, Data = any> = {
146
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
147
- url: string;
148
- data?: Data;
149
- params?: URLSearchParams;
150
- } & APIMetadata;
151
- type APIMetadata = {
152
- methodFqn?: string;
153
- entityFqdn?: string;
154
- packageName?: string;
155
- };
156
- type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
157
- type EventDefinition<Payload = unknown, Type extends string = string> = {
158
- __type: 'event-definition';
159
- type: Type;
160
- isDomainEvent?: boolean;
161
- transformations?: (envelope: unknown) => Payload;
162
- __payload: Payload;
163
- };
164
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
165
- type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
166
- type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
167
-
168
- declare global {
169
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
170
- interface SymbolConstructor {
171
- readonly observable: symbol;
172
- }
301
+ declare function listSecretInfo$1(httpClient: HttpClient): ListSecretInfoSignature;
302
+ interface ListSecretInfoSignature {
303
+ /**
304
+ * Retrieves a list of objects containing information about all secrets.
305
+ *
306
+ * The `listSecretInfo()` function returns a Promise that resolves to a list containing information about all secrets stored on your site.
307
+ *
308
+ * > **Note:**
309
+ * > - The secret's value does not get returned for security reasons. To retrieve a secret's value, use the [`getSecretValue()`](#getSecretValue) function.
310
+ * @returns Fulfilled - A list of objects containing information about your site's secrets. Rejected - Error message.
311
+ */
312
+ (): Promise<ListSecretInfoResponse>;
313
+ }
314
+ declare function createSecret$1(httpClient: HttpClient): CreateSecretSignature;
315
+ interface CreateSecretSignature {
316
+ /**
317
+ * Creates a new secret.
318
+ *
319
+ * The `createSecret()` function returns a Promise that resolves secret ID when the secret is created.
320
+ *
321
+ * >**Notes:**
322
+ * > - The secret's name cannot start with `'wix'` or be identical to an existing secret's name.
323
+ * > - Don't leave private keys in your code. Leaving them in your code is a security risk. Make sure to delete the keys from the code after running `createSecret()`.
324
+ * @param - Fields of a new secret.
325
+ * @returns Fulfilled - The ID of the created secret.
326
+ * Rejected - Error message.
327
+ */
328
+ (secret: Secret): Promise<string>;
329
+ }
330
+ declare function deleteSecret$1(httpClient: HttpClient): DeleteSecretSignature;
331
+ interface DeleteSecretSignature {
332
+ /**
333
+ * Deletes an existing secret by ID.
334
+ *
335
+ * The `deleteSecret()` function returns a Promise that resolves when the secret is deleted. You can retrieve the secret `_id` using the [`listSecretInfo()`](#listsecretinfo) function.
336
+ *
337
+ * >**Note:**
338
+ * > Deleting a secret is irreversible and will break all code using the secret.
339
+ *
340
+ * @param - The unique ID of the secret to be deleted.
341
+ * @returns Fulfilled - When the secret is successfully deleted. Rejected - Error message.
342
+ */
343
+ (_id: string): Promise<void>;
344
+ }
345
+ declare function updateSecret$1(httpClient: HttpClient): UpdateSecretSignature;
346
+ interface UpdateSecretSignature {
347
+ /**
348
+ * Updates the specified fields of an existing secret by ID.
349
+ *
350
+ *
351
+ * The `updateSecret()` function returns a Promise that resolves when the secret is successfully updated. You can update one or more fields. Only fields passed in the `secret` object will be updated. All other properties will remain unchanged.
352
+ *
353
+ * You can retrieve the `_id` parameter from the [`listSecretInfo()`](#listsecretinfo) function. The secret `_id` is different from the secret `name` used by the [`getSecretValue()`](#getsecretvalue) function.
354
+ *
355
+ * > **Notes:**
356
+ * > - Changing a secret's name or value will break all code using the secret.
357
+ * > - You can't rename the secret with a name of an existing secret.
358
+ * > - Don't leave private keys in your code! Leaving them in is a security risk. Make sure to delete the keys from the code after running `updateSecret()`.
359
+ * @param - The unique ID of the secret to be updated.
360
+ * @param - The secret fields to update.
361
+ * @returns Fulfilled - When the secret is updated.
362
+ * Rejected - Error message.
363
+ */
364
+ (_id: string, secret: Secret): Promise<void>;
173
365
  }
174
-
175
- declare function getSecretValue$1(httpClient: HttpClient): (name: string) => Promise<GetSecretValueResponse & GetSecretValueResponseNonNullableFields>;
176
- declare function listSecretInfo$1(httpClient: HttpClient): () => Promise<ListSecretInfoResponse & ListSecretInfoResponseNonNullableFields>;
177
- declare function createSecret$1(httpClient: HttpClient): (secret: Secret) => Promise<string>;
178
- declare function deleteSecret$1(httpClient: HttpClient): (_id: string) => Promise<void>;
179
- declare function updateSecret$1(httpClient: HttpClient): (_id: string, secret: Secret) => Promise<void>;
180
366
  declare const onSecretCreated$1: EventDefinition<SecretCreatedEnvelope, "wix.velo.secrets_vault.v1.secret_created">;
181
367
  declare const onSecretDeleted$1: EventDefinition<SecretDeletedEnvelope, "wix.velo.secrets_vault.v1.secret_deleted">;
182
368
  declare const onSecretUpdated$1: EventDefinition<SecretUpdatedEnvelope, "wix.velo.secrets_vault.v1.secret_updated">;
183
369
 
184
- declare const getSecretValue: BuildRESTFunction<typeof getSecretValue$1>;
185
- declare const listSecretInfo: BuildRESTFunction<typeof listSecretInfo$1>;
186
- declare const createSecret: BuildRESTFunction<typeof createSecret$1>;
187
- declare const deleteSecret: BuildRESTFunction<typeof deleteSecret$1>;
188
- declare const updateSecret: BuildRESTFunction<typeof updateSecret$1>;
189
- declare const onSecretCreated: BuildEventDefinition<typeof onSecretCreated$1>;
190
- declare const onSecretDeleted: BuildEventDefinition<typeof onSecretDeleted$1>;
191
- declare const onSecretUpdated: BuildEventDefinition<typeof onSecretUpdated$1>;
370
+ declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
371
+
372
+ declare const getSecretValue: BuildRESTFunction<typeof getSecretValue$1> & typeof getSecretValue$1;
373
+ declare const listSecretInfo: BuildRESTFunction<typeof listSecretInfo$1> & typeof listSecretInfo$1;
374
+ declare const createSecret: BuildRESTFunction<typeof createSecret$1> & typeof createSecret$1;
375
+ declare const deleteSecret: BuildRESTFunction<typeof deleteSecret$1> & typeof deleteSecret$1;
376
+ declare const updateSecret: BuildRESTFunction<typeof updateSecret$1> & typeof updateSecret$1;
377
+
378
+ type _publicOnSecretCreatedType = typeof onSecretCreated$1;
379
+ /** */
380
+ declare const onSecretCreated: ReturnType<typeof createEventModule<_publicOnSecretCreatedType>>;
381
+
382
+ type _publicOnSecretDeletedType = typeof onSecretDeleted$1;
383
+ /** */
384
+ declare const onSecretDeleted: ReturnType<typeof createEventModule<_publicOnSecretDeletedType>>;
385
+
386
+ type _publicOnSecretUpdatedType = typeof onSecretUpdated$1;
387
+ /** */
388
+ declare const onSecretUpdated: ReturnType<typeof createEventModule<_publicOnSecretUpdatedType>>;
192
389
 
390
+ type context_ActionEvent = ActionEvent;
391
+ type context_BaseEventMetadata = BaseEventMetadata;
392
+ type context_CreateSecretRequest = CreateSecretRequest;
393
+ type context_CreateSecretResponse = CreateSecretResponse;
394
+ type context_CreateSecretResponseNonNullableFields = CreateSecretResponseNonNullableFields;
395
+ type context_DeleteSecretRequest = DeleteSecretRequest;
396
+ type context_DeleteSecretResponse = DeleteSecretResponse;
397
+ type context_DomainEvent = DomainEvent;
398
+ type context_DomainEventBodyOneOf = DomainEventBodyOneOf;
399
+ type context_EntityCreatedEvent = EntityCreatedEvent;
400
+ type context_EntityDeletedEvent = EntityDeletedEvent;
401
+ type context_EntityUpdatedEvent = EntityUpdatedEvent;
402
+ type context_EventMetadata = EventMetadata;
403
+ type context_GetSecretValueRequest = GetSecretValueRequest;
404
+ type context_GetSecretValueResponse = GetSecretValueResponse;
405
+ type context_GetSecretValueResponseNonNullableFields = GetSecretValueResponseNonNullableFields;
406
+ type context_IdentificationData = IdentificationData;
407
+ type context_IdentificationDataIdOneOf = IdentificationDataIdOneOf;
408
+ type context_ListSecretInfoRequest = ListSecretInfoRequest;
409
+ type context_ListSecretInfoResponse = ListSecretInfoResponse;
410
+ type context_MessageEnvelope = MessageEnvelope;
411
+ type context_Secret = Secret;
412
+ type context_SecretCreatedEnvelope = SecretCreatedEnvelope;
413
+ type context_SecretDeletedEnvelope = SecretDeletedEnvelope;
414
+ type context_SecretUpdatedEnvelope = SecretUpdatedEnvelope;
415
+ type context_UpdateSecretRequest = UpdateSecretRequest;
416
+ type context_UpdateSecretResponse = UpdateSecretResponse;
417
+ type context_WebhookIdentityType = WebhookIdentityType;
418
+ declare const context_WebhookIdentityType: typeof WebhookIdentityType;
419
+ type context__publicOnSecretCreatedType = _publicOnSecretCreatedType;
420
+ type context__publicOnSecretDeletedType = _publicOnSecretDeletedType;
421
+ type context__publicOnSecretUpdatedType = _publicOnSecretUpdatedType;
193
422
  declare const context_createSecret: typeof createSecret;
194
423
  declare const context_deleteSecret: typeof deleteSecret;
195
424
  declare const context_getSecretValue: typeof getSecretValue;
@@ -199,7 +428,7 @@ declare const context_onSecretDeleted: typeof onSecretDeleted;
199
428
  declare const context_onSecretUpdated: typeof onSecretUpdated;
200
429
  declare const context_updateSecret: typeof updateSecret;
201
430
  declare namespace context {
202
- export { context_createSecret as createSecret, context_deleteSecret as deleteSecret, context_getSecretValue as getSecretValue, context_listSecretInfo as listSecretInfo, context_onSecretCreated as onSecretCreated, context_onSecretDeleted as onSecretDeleted, context_onSecretUpdated as onSecretUpdated, context_updateSecret as updateSecret };
431
+ export { type context_ActionEvent as ActionEvent, type context_BaseEventMetadata as BaseEventMetadata, type context_CreateSecretRequest as CreateSecretRequest, type context_CreateSecretResponse as CreateSecretResponse, type context_CreateSecretResponseNonNullableFields as CreateSecretResponseNonNullableFields, type context_DeleteSecretRequest as DeleteSecretRequest, type context_DeleteSecretResponse as DeleteSecretResponse, type context_DomainEvent as DomainEvent, type context_DomainEventBodyOneOf as DomainEventBodyOneOf, type context_EntityCreatedEvent as EntityCreatedEvent, type context_EntityDeletedEvent as EntityDeletedEvent, type context_EntityUpdatedEvent as EntityUpdatedEvent, type context_EventMetadata as EventMetadata, type context_GetSecretValueRequest as GetSecretValueRequest, type context_GetSecretValueResponse as GetSecretValueResponse, type context_GetSecretValueResponseNonNullableFields as GetSecretValueResponseNonNullableFields, type context_IdentificationData as IdentificationData, type context_IdentificationDataIdOneOf as IdentificationDataIdOneOf, type context_ListSecretInfoRequest as ListSecretInfoRequest, type context_ListSecretInfoResponse as ListSecretInfoResponse, type context_MessageEnvelope as MessageEnvelope, type context_Secret as Secret, type context_SecretCreatedEnvelope as SecretCreatedEnvelope, type context_SecretDeletedEnvelope as SecretDeletedEnvelope, type context_SecretUpdatedEnvelope as SecretUpdatedEnvelope, type context_UpdateSecretRequest as UpdateSecretRequest, type context_UpdateSecretResponse as UpdateSecretResponse, context_WebhookIdentityType as WebhookIdentityType, type context__publicOnSecretCreatedType as _publicOnSecretCreatedType, type context__publicOnSecretDeletedType as _publicOnSecretDeletedType, type context__publicOnSecretUpdatedType as _publicOnSecretUpdatedType, context_createSecret as createSecret, context_deleteSecret as deleteSecret, context_getSecretValue as getSecretValue, context_listSecretInfo as listSecretInfo, context_onSecretCreated as onSecretCreated, context_onSecretDeleted as onSecretDeleted, context_onSecretUpdated as onSecretUpdated, onSecretCreated$1 as publicOnSecretCreated, onSecretDeleted$1 as publicOnSecretDeleted, onSecretUpdated$1 as publicOnSecretUpdated, context_updateSecret as updateSecret };
203
432
  }
204
433
 
205
434
  export { context as secrets };
@@ -1,3 +1,47 @@
1
+ type RESTFunctionDescriptor<T extends (...args: any[]) => any = (...args: any[]) => any> = (httpClient: HttpClient) => T;
2
+ interface HttpClient {
3
+ request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
4
+ fetchWithAuth: typeof fetch;
5
+ wixAPIFetch: (relativeUrl: string, options: RequestInit) => Promise<Response>;
6
+ }
7
+ type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
8
+ type HttpResponse<T = any> = {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: any;
13
+ request?: any;
14
+ };
15
+ type RequestOptions<_TResponse = any, Data = any> = {
16
+ method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
17
+ url: string;
18
+ data?: Data;
19
+ params?: URLSearchParams;
20
+ } & APIMetadata;
21
+ type APIMetadata = {
22
+ methodFqn?: string;
23
+ entityFqdn?: string;
24
+ packageName?: string;
25
+ };
26
+ type BuildRESTFunction<T extends RESTFunctionDescriptor> = T extends RESTFunctionDescriptor<infer U> ? U : never;
27
+ type EventDefinition<Payload = unknown, Type extends string = string> = {
28
+ __type: 'event-definition';
29
+ type: Type;
30
+ isDomainEvent?: boolean;
31
+ transformations?: (envelope: unknown) => Payload;
32
+ __payload: Payload;
33
+ };
34
+ declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
35
+ type EventHandler<T extends EventDefinition> = (payload: T['__payload']) => void | Promise<void>;
36
+ type BuildEventDefinition<T extends EventDefinition<any, string>> = (handler: EventHandler<T>) => void;
37
+
38
+ declare global {
39
+ // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
40
+ interface SymbolConstructor {
41
+ readonly observable: symbol;
42
+ }
43
+ }
44
+
1
45
  interface Secret {
2
46
  /**
3
47
  * The secret's unique ID.
@@ -179,9 +223,6 @@ declare enum WebhookIdentityType {
179
223
  interface GetSecretValueResponseNonNullableFields {
180
224
  value: string;
181
225
  }
182
- interface ListSecretInfoResponseNonNullableFields {
183
- secrets: Secret[];
184
- }
185
226
  interface CreateSecretResponseNonNullableFields {
186
227
  _id: string;
187
228
  }
@@ -243,56 +284,108 @@ interface SecretUpdatedEnvelope {
243
284
  metadata: EventMetadata;
244
285
  }
245
286
 
246
- interface HttpClient {
247
- request<TResponse, TData = any>(req: RequestOptionsFactory<TResponse, TData>): Promise<HttpResponse<TResponse>>;
248
- fetchWithAuth: (url: string | URL, init?: RequestInit) => Promise<Response>;
287
+ declare function getSecretValue$1(httpClient: HttpClient): GetSecretValueSignature;
288
+ interface GetSecretValueSignature {
289
+ /**
290
+ * Retrieves the secret value specified by the secret name.
291
+ *
292
+ * The `getSecretValue()` function returns a Promise that resolves to the value of the secret with the specified given name.
293
+ *
294
+ * >**Note:**
295
+ * > Only use a secret's value in the backend code. Returning the secret value in the frontend is a security risk.
296
+ * @param - The name of the secret to get the value of.
297
+ * @returns Fulfilled - The value of the secret. Rejected - Error message.
298
+ */
299
+ (name: string): Promise<GetSecretValueResponse & GetSecretValueResponseNonNullableFields>;
249
300
  }
250
- type RequestOptionsFactory<TResponse = any, TData = any> = (context: any) => RequestOptions<TResponse, TData>;
251
- type HttpResponse<T = any> = {
252
- data: T;
253
- status: number;
254
- statusText: string;
255
- headers: any;
256
- request?: any;
257
- };
258
- type RequestOptions<_TResponse = any, Data = any> = {
259
- method: 'POST' | 'GET' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
260
- url: string;
261
- data?: Data;
262
- params?: URLSearchParams;
263
- } & APIMetadata;
264
- type APIMetadata = {
265
- methodFqn?: string;
266
- entityFqdn?: string;
267
- packageName?: string;
268
- };
269
- type EventDefinition<Payload = unknown, Type extends string = string> = {
270
- __type: 'event-definition';
271
- type: Type;
272
- isDomainEvent?: boolean;
273
- transformations?: (envelope: unknown) => Payload;
274
- __payload: Payload;
275
- };
276
- declare function EventDefinition<Type extends string>(type: Type, isDomainEvent?: boolean, transformations?: (envelope: any) => unknown): <Payload = unknown>() => EventDefinition<Payload, Type>;
277
-
278
- declare global {
279
- // eslint-disable-next-line @typescript-eslint/consistent-type-definitions -- It has to be an `interface` so that it can be merged.
280
- interface SymbolConstructor {
281
- readonly observable: symbol;
282
- }
301
+ declare function listSecretInfo$1(httpClient: HttpClient): ListSecretInfoSignature;
302
+ interface ListSecretInfoSignature {
303
+ /**
304
+ * Retrieves a list of objects containing information about all secrets.
305
+ *
306
+ * The `listSecretInfo()` function returns a Promise that resolves to a list containing information about all secrets stored on your site.
307
+ *
308
+ * > **Note:**
309
+ * > - The secret's value does not get returned for security reasons. To retrieve a secret's value, use the [`getSecretValue()`](#getSecretValue) function.
310
+ * @returns Fulfilled - A list of objects containing information about your site's secrets. Rejected - Error message.
311
+ */
312
+ (): Promise<ListSecretInfoResponse>;
313
+ }
314
+ declare function createSecret$1(httpClient: HttpClient): CreateSecretSignature;
315
+ interface CreateSecretSignature {
316
+ /**
317
+ * Creates a new secret.
318
+ *
319
+ * The `createSecret()` function returns a Promise that resolves secret ID when the secret is created.
320
+ *
321
+ * >**Notes:**
322
+ * > - The secret's name cannot start with `'wix'` or be identical to an existing secret's name.
323
+ * > - Don't leave private keys in your code. Leaving them in your code is a security risk. Make sure to delete the keys from the code after running `createSecret()`.
324
+ * @param - Fields of a new secret.
325
+ * @returns Fulfilled - The ID of the created secret.
326
+ * Rejected - Error message.
327
+ */
328
+ (secret: Secret): Promise<string>;
329
+ }
330
+ declare function deleteSecret$1(httpClient: HttpClient): DeleteSecretSignature;
331
+ interface DeleteSecretSignature {
332
+ /**
333
+ * Deletes an existing secret by ID.
334
+ *
335
+ * The `deleteSecret()` function returns a Promise that resolves when the secret is deleted. You can retrieve the secret `_id` using the [`listSecretInfo()`](#listsecretinfo) function.
336
+ *
337
+ * >**Note:**
338
+ * > Deleting a secret is irreversible and will break all code using the secret.
339
+ *
340
+ * @param - The unique ID of the secret to be deleted.
341
+ * @returns Fulfilled - When the secret is successfully deleted. Rejected - Error message.
342
+ */
343
+ (_id: string): Promise<void>;
283
344
  }
345
+ declare function updateSecret$1(httpClient: HttpClient): UpdateSecretSignature;
346
+ interface UpdateSecretSignature {
347
+ /**
348
+ * Updates the specified fields of an existing secret by ID.
349
+ *
350
+ *
351
+ * The `updateSecret()` function returns a Promise that resolves when the secret is successfully updated. You can update one or more fields. Only fields passed in the `secret` object will be updated. All other properties will remain unchanged.
352
+ *
353
+ * You can retrieve the `_id` parameter from the [`listSecretInfo()`](#listsecretinfo) function. The secret `_id` is different from the secret `name` used by the [`getSecretValue()`](#getsecretvalue) function.
354
+ *
355
+ * > **Notes:**
356
+ * > - Changing a secret's name or value will break all code using the secret.
357
+ * > - You can't rename the secret with a name of an existing secret.
358
+ * > - Don't leave private keys in your code! Leaving them in is a security risk. Make sure to delete the keys from the code after running `updateSecret()`.
359
+ * @param - The unique ID of the secret to be updated.
360
+ * @param - The secret fields to update.
361
+ * @returns Fulfilled - When the secret is updated.
362
+ * Rejected - Error message.
363
+ */
364
+ (_id: string, secret: Secret): Promise<void>;
365
+ }
366
+ declare const onSecretCreated$1: EventDefinition<SecretCreatedEnvelope, "wix.velo.secrets_vault.v1.secret_created">;
367
+ declare const onSecretDeleted$1: EventDefinition<SecretDeletedEnvelope, "wix.velo.secrets_vault.v1.secret_deleted">;
368
+ declare const onSecretUpdated$1: EventDefinition<SecretUpdatedEnvelope, "wix.velo.secrets_vault.v1.secret_updated">;
284
369
 
285
- declare const __metadata: {
286
- PACKAGE_NAME: string;
287
- };
288
- declare function getSecretValue(httpClient: HttpClient): (name: string) => Promise<GetSecretValueResponse & GetSecretValueResponseNonNullableFields>;
289
- declare function listSecretInfo(httpClient: HttpClient): () => Promise<ListSecretInfoResponse & ListSecretInfoResponseNonNullableFields>;
290
- declare function createSecret(httpClient: HttpClient): (secret: Secret) => Promise<string>;
291
- declare function deleteSecret(httpClient: HttpClient): (_id: string) => Promise<void>;
292
- declare function updateSecret(httpClient: HttpClient): (_id: string, secret: Secret) => Promise<void>;
293
- declare const onSecretCreated: EventDefinition<SecretCreatedEnvelope, "wix.velo.secrets_vault.v1.secret_created">;
294
- declare const onSecretDeleted: EventDefinition<SecretDeletedEnvelope, "wix.velo.secrets_vault.v1.secret_deleted">;
295
- declare const onSecretUpdated: EventDefinition<SecretUpdatedEnvelope, "wix.velo.secrets_vault.v1.secret_updated">;
370
+ declare function createEventModule<T extends EventDefinition<any, string>>(eventDefinition: T): BuildEventDefinition<T> & T;
371
+
372
+ declare const getSecretValue: BuildRESTFunction<typeof getSecretValue$1> & typeof getSecretValue$1;
373
+ declare const listSecretInfo: BuildRESTFunction<typeof listSecretInfo$1> & typeof listSecretInfo$1;
374
+ declare const createSecret: BuildRESTFunction<typeof createSecret$1> & typeof createSecret$1;
375
+ declare const deleteSecret: BuildRESTFunction<typeof deleteSecret$1> & typeof deleteSecret$1;
376
+ declare const updateSecret: BuildRESTFunction<typeof updateSecret$1> & typeof updateSecret$1;
377
+
378
+ type _publicOnSecretCreatedType = typeof onSecretCreated$1;
379
+ /** */
380
+ declare const onSecretCreated: ReturnType<typeof createEventModule<_publicOnSecretCreatedType>>;
381
+
382
+ type _publicOnSecretDeletedType = typeof onSecretDeleted$1;
383
+ /** */
384
+ declare const onSecretDeleted: ReturnType<typeof createEventModule<_publicOnSecretDeletedType>>;
385
+
386
+ type _publicOnSecretUpdatedType = typeof onSecretUpdated$1;
387
+ /** */
388
+ declare const onSecretUpdated: ReturnType<typeof createEventModule<_publicOnSecretUpdatedType>>;
296
389
 
297
390
  type index_d_ActionEvent = ActionEvent;
298
391
  type index_d_BaseEventMetadata = BaseEventMetadata;
@@ -314,7 +407,6 @@ type index_d_IdentificationData = IdentificationData;
314
407
  type index_d_IdentificationDataIdOneOf = IdentificationDataIdOneOf;
315
408
  type index_d_ListSecretInfoRequest = ListSecretInfoRequest;
316
409
  type index_d_ListSecretInfoResponse = ListSecretInfoResponse;
317
- type index_d_ListSecretInfoResponseNonNullableFields = ListSecretInfoResponseNonNullableFields;
318
410
  type index_d_MessageEnvelope = MessageEnvelope;
319
411
  type index_d_Secret = Secret;
320
412
  type index_d_SecretCreatedEnvelope = SecretCreatedEnvelope;
@@ -324,7 +416,9 @@ type index_d_UpdateSecretRequest = UpdateSecretRequest;
324
416
  type index_d_UpdateSecretResponse = UpdateSecretResponse;
325
417
  type index_d_WebhookIdentityType = WebhookIdentityType;
326
418
  declare const index_d_WebhookIdentityType: typeof WebhookIdentityType;
327
- declare const index_d___metadata: typeof __metadata;
419
+ type index_d__publicOnSecretCreatedType = _publicOnSecretCreatedType;
420
+ type index_d__publicOnSecretDeletedType = _publicOnSecretDeletedType;
421
+ type index_d__publicOnSecretUpdatedType = _publicOnSecretUpdatedType;
328
422
  declare const index_d_createSecret: typeof createSecret;
329
423
  declare const index_d_deleteSecret: typeof deleteSecret;
330
424
  declare const index_d_getSecretValue: typeof getSecretValue;
@@ -334,7 +428,7 @@ declare const index_d_onSecretDeleted: typeof onSecretDeleted;
334
428
  declare const index_d_onSecretUpdated: typeof onSecretUpdated;
335
429
  declare const index_d_updateSecret: typeof updateSecret;
336
430
  declare namespace index_d {
337
- export { type index_d_ActionEvent as ActionEvent, type index_d_BaseEventMetadata as BaseEventMetadata, type index_d_CreateSecretRequest as CreateSecretRequest, type index_d_CreateSecretResponse as CreateSecretResponse, type index_d_CreateSecretResponseNonNullableFields as CreateSecretResponseNonNullableFields, type index_d_DeleteSecretRequest as DeleteSecretRequest, type index_d_DeleteSecretResponse as DeleteSecretResponse, type index_d_DomainEvent as DomainEvent, type index_d_DomainEventBodyOneOf as DomainEventBodyOneOf, type index_d_EntityCreatedEvent as EntityCreatedEvent, type index_d_EntityDeletedEvent as EntityDeletedEvent, type index_d_EntityUpdatedEvent as EntityUpdatedEvent, type index_d_EventMetadata as EventMetadata, type index_d_GetSecretValueRequest as GetSecretValueRequest, type index_d_GetSecretValueResponse as GetSecretValueResponse, type index_d_GetSecretValueResponseNonNullableFields as GetSecretValueResponseNonNullableFields, type index_d_IdentificationData as IdentificationData, type index_d_IdentificationDataIdOneOf as IdentificationDataIdOneOf, type index_d_ListSecretInfoRequest as ListSecretInfoRequest, type index_d_ListSecretInfoResponse as ListSecretInfoResponse, type index_d_ListSecretInfoResponseNonNullableFields as ListSecretInfoResponseNonNullableFields, type index_d_MessageEnvelope as MessageEnvelope, type index_d_Secret as Secret, type index_d_SecretCreatedEnvelope as SecretCreatedEnvelope, type index_d_SecretDeletedEnvelope as SecretDeletedEnvelope, type index_d_SecretUpdatedEnvelope as SecretUpdatedEnvelope, type index_d_UpdateSecretRequest as UpdateSecretRequest, type index_d_UpdateSecretResponse as UpdateSecretResponse, index_d_WebhookIdentityType as WebhookIdentityType, index_d___metadata as __metadata, index_d_createSecret as createSecret, index_d_deleteSecret as deleteSecret, index_d_getSecretValue as getSecretValue, index_d_listSecretInfo as listSecretInfo, index_d_onSecretCreated as onSecretCreated, index_d_onSecretDeleted as onSecretDeleted, index_d_onSecretUpdated as onSecretUpdated, index_d_updateSecret as updateSecret };
431
+ export { type index_d_ActionEvent as ActionEvent, type index_d_BaseEventMetadata as BaseEventMetadata, type index_d_CreateSecretRequest as CreateSecretRequest, type index_d_CreateSecretResponse as CreateSecretResponse, type index_d_CreateSecretResponseNonNullableFields as CreateSecretResponseNonNullableFields, type index_d_DeleteSecretRequest as DeleteSecretRequest, type index_d_DeleteSecretResponse as DeleteSecretResponse, type index_d_DomainEvent as DomainEvent, type index_d_DomainEventBodyOneOf as DomainEventBodyOneOf, type index_d_EntityCreatedEvent as EntityCreatedEvent, type index_d_EntityDeletedEvent as EntityDeletedEvent, type index_d_EntityUpdatedEvent as EntityUpdatedEvent, type index_d_EventMetadata as EventMetadata, type index_d_GetSecretValueRequest as GetSecretValueRequest, type index_d_GetSecretValueResponse as GetSecretValueResponse, type index_d_GetSecretValueResponseNonNullableFields as GetSecretValueResponseNonNullableFields, type index_d_IdentificationData as IdentificationData, type index_d_IdentificationDataIdOneOf as IdentificationDataIdOneOf, type index_d_ListSecretInfoRequest as ListSecretInfoRequest, type index_d_ListSecretInfoResponse as ListSecretInfoResponse, type index_d_MessageEnvelope as MessageEnvelope, type index_d_Secret as Secret, type index_d_SecretCreatedEnvelope as SecretCreatedEnvelope, type index_d_SecretDeletedEnvelope as SecretDeletedEnvelope, type index_d_SecretUpdatedEnvelope as SecretUpdatedEnvelope, type index_d_UpdateSecretRequest as UpdateSecretRequest, type index_d_UpdateSecretResponse as UpdateSecretResponse, index_d_WebhookIdentityType as WebhookIdentityType, type index_d__publicOnSecretCreatedType as _publicOnSecretCreatedType, type index_d__publicOnSecretDeletedType as _publicOnSecretDeletedType, type index_d__publicOnSecretUpdatedType as _publicOnSecretUpdatedType, index_d_createSecret as createSecret, index_d_deleteSecret as deleteSecret, index_d_getSecretValue as getSecretValue, index_d_listSecretInfo as listSecretInfo, index_d_onSecretCreated as onSecretCreated, index_d_onSecretDeleted as onSecretDeleted, index_d_onSecretUpdated as onSecretUpdated, onSecretCreated$1 as publicOnSecretCreated, onSecretDeleted$1 as publicOnSecretDeleted, onSecretUpdated$1 as publicOnSecretUpdated, index_d_updateSecret as updateSecret };
338
432
  }
339
433
 
340
434
  export { index_d as secrets };
@@ -60,9 +60,6 @@ interface UpdateSecretResponse$1 {
60
60
  interface GetSecretValueResponseNonNullableFields$1 {
61
61
  value: string;
62
62
  }
63
- interface ListSecretInfoResponseNonNullableFields$1 {
64
- secrets: Secret$1[];
65
- }
66
63
  interface CreateSecretResponseNonNullableFields$1 {
67
64
  id: string;
68
65
  }
@@ -141,9 +138,6 @@ interface UpdateSecretResponse {
141
138
  interface GetSecretValueResponseNonNullableFields {
142
139
  value: string;
143
140
  }
144
- interface ListSecretInfoResponseNonNullableFields {
145
- secrets: Secret[];
146
- }
147
141
  interface CreateSecretResponseNonNullableFields {
148
142
  _id: string;
149
143
  }
@@ -161,7 +155,7 @@ type __PublicMethodMetaInfo<K = string, M = unknown, T = unknown, S = unknown, Q
161
155
  declare function getSecretValue(): __PublicMethodMetaInfo<'GET', {
162
156
  name: string;
163
157
  }, GetSecretValueRequest, GetSecretValueRequest$1, GetSecretValueResponse & GetSecretValueResponseNonNullableFields, GetSecretValueResponse$1 & GetSecretValueResponseNonNullableFields$1>;
164
- declare function listSecretInfo(): __PublicMethodMetaInfo<'GET', {}, ListSecretInfoRequest, ListSecretInfoRequest$1, ListSecretInfoResponse & ListSecretInfoResponseNonNullableFields, ListSecretInfoResponse$1 & ListSecretInfoResponseNonNullableFields$1>;
158
+ declare function listSecretInfo(): __PublicMethodMetaInfo<'GET', {}, ListSecretInfoRequest, ListSecretInfoRequest$1, ListSecretInfoResponse, ListSecretInfoResponse$1>;
165
159
  declare function createSecret(): __PublicMethodMetaInfo<'POST', {}, CreateSecretRequest, CreateSecretRequest$1, CreateSecretResponse & CreateSecretResponseNonNullableFields, CreateSecretResponse$1 & CreateSecretResponseNonNullableFields$1>;
166
160
  declare function deleteSecret(): __PublicMethodMetaInfo<'DELETE', {
167
161
  id: string;