@delopay/sdk 0.59.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.
@@ -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
@@ -363,6 +449,22 @@ var Connectors = class {
363
449
  `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`
364
450
  );
365
451
  }
452
+ /**
453
+ * Clone a connector into another shop (business profile) of the same
454
+ * merchant. `POST /account/{accountId}/connectors/{connectorId}/clone`
455
+ *
456
+ * Credentials are copied server-side, re-encrypted under the same merchant
457
+ * key — the caller never handles them (list/retrieve mask credentials, so a
458
+ * client-side copy is impossible). Returns the newly created connector in
459
+ * the target shop.
460
+ */
461
+ async clone(accountId, connectorId, params) {
462
+ return this.request(
463
+ "POST",
464
+ `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/clone`,
465
+ { body: params }
466
+ );
467
+ }
366
468
  // --- Advanced operations (Task 4.8) ---
367
469
  /** Verify connector credentials. `POST /account/connectors/verify` */
368
470
  async verify(params) {
@@ -4134,4 +4236,4 @@ export {
4134
4236
  applyBrandingVariables,
4135
4237
  shadowFor
4136
4238
  };
4137
- //# sourceMappingURL=chunk-7KPAARZE.js.map
4239
+ //# sourceMappingURL=chunk-ADPSXHH7.js.map