@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.
@@ -100,6 +100,92 @@ var ApiKeys = class {
100
100
  async list(merchantId) {
101
101
  return this.request("GET", `/api-keys/${encodeURIComponent(merchantId)}/list`);
102
102
  }
103
+ // --- Profile-scoped (shop-level) API keys ---------------------------------
104
+ //
105
+ // JWT-authenticated routes under `/account/{merchantId}/profile/api-keys`.
106
+ // The caller's shop (business profile) comes from the JWT, never from the
107
+ // request, so a shop-scoped user can only mint/list/manage keys pinned to
108
+ // their own shop. Requires a backend with profile-scoped API key support
109
+ // (DeloPay-net/delopay-backend#344).
110
+ /**
111
+ * Create a new API key pinned to the caller's shop (business profile).
112
+ * `POST /account/{merchantId}/profile/api-keys`
113
+ *
114
+ * @param merchantId - The merchant account ID.
115
+ * @param params - Key creation parameters (name, expiry, etc.).
116
+ * @returns The newly created key including the plaintext secret (shown once
117
+ * only) and the `profile_id` it is pinned to.
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * const { api_key } = await delopay.apiKeys.createByProfile('merch_123', {
122
+ * name: 'Shop key',
123
+ * expiration: 'never',
124
+ * });
125
+ * ```
126
+ */
127
+ async createByProfile(merchantId, params) {
128
+ return this.request("POST", `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {
129
+ body: params
130
+ });
131
+ }
132
+ /**
133
+ * List API keys pinned to the caller's shop (business profile) only.
134
+ * `GET /account/{merchantId}/profile/api-keys`
135
+ *
136
+ * @param merchantId - The merchant account ID.
137
+ * @param params - Optional pagination constraints (`limit`, `skip`).
138
+ * @returns Array of API key metadata objects belonging to the caller's shop.
139
+ */
140
+ async listByProfile(merchantId, params) {
141
+ return this.request("GET", `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {
142
+ query: params
143
+ });
144
+ }
145
+ /**
146
+ * Retrieve metadata about a shop-pinned API key (does not return the
147
+ * plaintext secret). `GET /account/{merchantId}/profile/api-keys/{keyId}`
148
+ *
149
+ * @param merchantId - The merchant account ID.
150
+ * @param keyId - The API key ID.
151
+ * @returns The API key metadata.
152
+ */
153
+ async retrieveByProfile(merchantId, keyId) {
154
+ return this.request(
155
+ "GET",
156
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`
157
+ );
158
+ }
159
+ /**
160
+ * Update a shop-pinned API key's name, description, or expiry.
161
+ * `POST /account/{merchantId}/profile/api-keys/{keyId}`
162
+ *
163
+ * @param merchantId - The merchant account ID.
164
+ * @param keyId - The API key ID to update.
165
+ * @param params - Fields to update.
166
+ * @returns The updated API key metadata.
167
+ */
168
+ async updateByProfile(merchantId, keyId, params) {
169
+ return this.request(
170
+ "POST",
171
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,
172
+ { body: params }
173
+ );
174
+ }
175
+ /**
176
+ * Revoke a shop-pinned API key, immediately invalidating it.
177
+ * `DELETE /account/{merchantId}/profile/api-keys/{keyId}`
178
+ *
179
+ * @param merchantId - The merchant account ID.
180
+ * @param keyId - The API key ID to revoke.
181
+ * @returns Revocation confirmation.
182
+ */
183
+ async revokeByProfile(merchantId, keyId) {
184
+ return this.request(
185
+ "DELETE",
186
+ `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`
187
+ );
188
+ }
103
189
  };
104
190
 
105
191
  // src/resources/authentication.ts
@@ -2254,6 +2340,23 @@ var Users = class {
2254
2340
  async addUser(params) {
2255
2341
  return this.request("POST", "/user/employees/add", { body: params });
2256
2342
  }
2343
+ /**
2344
+ * Impersonate one of your own team members — `POST /user/employees/impersonate`.
2345
+ *
2346
+ * Mints a session token **as** the given member, so the dashboard renders
2347
+ * exactly what they see (useful for support and role verification). The
2348
+ * caller needs the *Impersonation* permission, and the member's role must
2349
+ * rank **strictly below** the caller's (`Profile < Merchant < Organization`);
2350
+ * the server rejects self-impersonation, cross-merchant targets, and
2351
+ * equal/higher roles.
2352
+ *
2353
+ * The returned token is tab-scoped by design: open it in a fresh tab (e.g.
2354
+ * `/auth/impersonate?token=…`) rather than replacing the caller's own
2355
+ * session. No auth cookie is set on the response.
2356
+ */
2357
+ async impersonateEmployee(params) {
2358
+ return this.request("POST", "/user/employees/impersonate", { body: params });
2359
+ }
2257
2360
  async acceptInvitation(params) {
2258
2361
  return this.request("POST", "/user/employees/invite/accept", { body: params });
2259
2362
  }
@@ -4150,4 +4253,4 @@ export {
4150
4253
  applyBrandingVariables,
4151
4254
  shadowFor
4152
4255
  };
4153
- //# sourceMappingURL=chunk-6GBHQKUX.js.map
4256
+ //# sourceMappingURL=chunk-2OWZIFZO.js.map