@delopay/sdk 0.60.0 → 0.61.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/dist/index.cjs CHANGED
@@ -175,6 +175,92 @@ var ApiKeys = class {
175
175
  async list(merchantId) {
176
176
  return this.request("GET", `/api-keys/${encodeURIComponent(merchantId)}/list`);
177
177
  }
178
+ // --- Profile-scoped (shop-level) API keys ---------------------------------
179
+ //
180
+ // JWT-authenticated routes under `/account/{merchantId}/profile/api-keys`.
181
+ // The caller's shop (business profile) comes from the JWT, never from the
182
+ // request, so a shop-scoped user can only mint/list/manage keys pinned to
183
+ // their own shop. Requires a backend with profile-scoped API key support
184
+ // (DeloPay-net/delopay-backend#344).
185
+ /**
186
+ * Create a new API key pinned to the caller's shop (business profile).
187
+ * `POST /account/{merchantId}/profile/api-keys`
188
+ *
189
+ * @param merchantId - The merchant account ID.
190
+ * @param params - Key creation parameters (name, expiry, etc.).
191
+ * @returns The newly created key including the plaintext secret (shown once
192
+ * only) and the `profile_id` it is pinned to.
193
+ *
194
+ * @example
195
+ * ```typescript
196
+ * const { api_key } = await delopay.apiKeys.createByProfile('merch_123', {
197
+ * name: 'Shop key',
198
+ * expiration: 'never',
199
+ * });
200
+ * ```
201
+ */
202
+ async createByProfile(merchantId, params) {
203
+ return this.request("POST", `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {
204
+ body: params
205
+ });
206
+ }
207
+ /**
208
+ * List API keys pinned to the caller's shop (business profile) only.
209
+ * `GET /account/{merchantId}/profile/api-keys`
210
+ *
211
+ * @param merchantId - The merchant account ID.
212
+ * @param params - Optional pagination constraints (`limit`, `skip`).
213
+ * @returns Array of API key metadata objects belonging to the caller's shop.
214
+ */
215
+ async listByProfile(merchantId, params) {
216
+ return this.request("GET", `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {
217
+ query: params
218
+ });
219
+ }
220
+ /**
221
+ * Retrieve metadata about a shop-pinned API key (does not return the
222
+ * plaintext secret). `GET /account/{merchantId}/profile/api-keys/{keyId}`
223
+ *
224
+ * @param merchantId - The merchant account ID.
225
+ * @param keyId - The API key ID.
226
+ * @returns The API key metadata.
227
+ */
228
+ async retrieveByProfile(merchantId, keyId) {
229
+ return this.request(
230
+ "GET",
231
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`
232
+ );
233
+ }
234
+ /**
235
+ * Update a shop-pinned API key's name, description, or expiry.
236
+ * `POST /account/{merchantId}/profile/api-keys/{keyId}`
237
+ *
238
+ * @param merchantId - The merchant account ID.
239
+ * @param keyId - The API key ID to update.
240
+ * @param params - Fields to update.
241
+ * @returns The updated API key metadata.
242
+ */
243
+ async updateByProfile(merchantId, keyId, params) {
244
+ return this.request(
245
+ "POST",
246
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,
247
+ { body: params }
248
+ );
249
+ }
250
+ /**
251
+ * Revoke a shop-pinned API key, immediately invalidating it.
252
+ * `DELETE /account/{merchantId}/profile/api-keys/{keyId}`
253
+ *
254
+ * @param merchantId - The merchant account ID.
255
+ * @param keyId - The API key ID to revoke.
256
+ * @returns Revocation confirmation.
257
+ */
258
+ async revokeByProfile(merchantId, keyId) {
259
+ return this.request(
260
+ "DELETE",
261
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`
262
+ );
263
+ }
178
264
  };
179
265
 
180
266
  // src/resources/authentication.ts