@delopay/sdk 0.60.0 → 0.62.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
@@ -2329,6 +2415,23 @@ var Users = class {
2329
2415
  async addUser(params) {
2330
2416
  return this.request("POST", "/user/employees/add", { body: params });
2331
2417
  }
2418
+ /**
2419
+ * Impersonate one of your own team members — `POST /user/employees/impersonate`.
2420
+ *
2421
+ * Mints a session token **as** the given member, so the dashboard renders
2422
+ * exactly what they see (useful for support and role verification). The
2423
+ * caller needs the *Impersonation* permission, and the member's role must
2424
+ * rank **strictly below** the caller's (`Profile < Merchant < Organization`);
2425
+ * the server rejects self-impersonation, cross-merchant targets, and
2426
+ * equal/higher roles.
2427
+ *
2428
+ * The returned token is tab-scoped by design: open it in a fresh tab (e.g.
2429
+ * `/auth/impersonate?token=…`) rather than replacing the caller's own
2430
+ * session. No auth cookie is set on the response.
2431
+ */
2432
+ async impersonateEmployee(params) {
2433
+ return this.request("POST", "/user/employees/impersonate", { body: params });
2434
+ }
2332
2435
  async acceptInvitation(params) {
2333
2436
  return this.request("POST", "/user/employees/invite/accept", { body: params });
2334
2437
  }