@dotbots-boutique/auth-sdk 1.0.10 → 1.0.11
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/cjs/index.js +6 -1
- package/dist/esm/index.js +6 -1
- package/dist/types/DotBotsAuth.d.ts +1 -1
- package/dist/types/index.js +6 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -198,6 +198,7 @@ class PostMessageHandler {
|
|
|
198
198
|
*/
|
|
199
199
|
sendCharge(appId, featureCode, amount, transactionId) {
|
|
200
200
|
if (this.isInIframe()) {
|
|
201
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, amount: ${amount}, transactionId: ${transactionId}`);
|
|
201
202
|
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, amount, transactionId }, this.marketplaceOrigin);
|
|
202
203
|
}
|
|
203
204
|
}
|
|
@@ -336,6 +337,7 @@ class DotBotsAuth {
|
|
|
336
337
|
async charge(featureCode, paidBy, quantity) {
|
|
337
338
|
this.assertInitialized();
|
|
338
339
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
340
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
339
341
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
340
342
|
method: 'POST',
|
|
341
343
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -343,12 +345,15 @@ class DotBotsAuth {
|
|
|
343
345
|
});
|
|
344
346
|
if (response.status === 402) {
|
|
345
347
|
const body = await response.json();
|
|
348
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
346
349
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
347
350
|
}
|
|
348
351
|
if (!response.ok) {
|
|
352
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
349
353
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
350
354
|
}
|
|
351
355
|
const result = await response.json();
|
|
356
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, amount: ${result.amount}`);
|
|
352
357
|
this.postMessageHandler.sendCharge(this.config.appId, featureCode, result.amount, result.transactionId);
|
|
353
358
|
this.emit('charged');
|
|
354
359
|
return result;
|
|
@@ -443,7 +448,7 @@ class DotBotsAuth {
|
|
|
443
448
|
}
|
|
444
449
|
}
|
|
445
450
|
}
|
|
446
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
451
|
+
DotBotsAuth.SDK_VERSION = '1.0.11';
|
|
447
452
|
|
|
448
453
|
exports.DotBotsAuth = DotBotsAuth;
|
|
449
454
|
exports.DotBotsAuthError = DotBotsAuthError;
|
package/dist/esm/index.js
CHANGED
|
@@ -196,6 +196,7 @@ class PostMessageHandler {
|
|
|
196
196
|
*/
|
|
197
197
|
sendCharge(appId, featureCode, amount, transactionId) {
|
|
198
198
|
if (this.isInIframe()) {
|
|
199
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, amount: ${amount}, transactionId: ${transactionId}`);
|
|
199
200
|
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, amount, transactionId }, this.marketplaceOrigin);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
@@ -334,6 +335,7 @@ class DotBotsAuth {
|
|
|
334
335
|
async charge(featureCode, paidBy, quantity) {
|
|
335
336
|
this.assertInitialized();
|
|
336
337
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
338
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
337
339
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
338
340
|
method: 'POST',
|
|
339
341
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -341,12 +343,15 @@ class DotBotsAuth {
|
|
|
341
343
|
});
|
|
342
344
|
if (response.status === 402) {
|
|
343
345
|
const body = await response.json();
|
|
346
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
344
347
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
345
348
|
}
|
|
346
349
|
if (!response.ok) {
|
|
350
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
347
351
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
348
352
|
}
|
|
349
353
|
const result = await response.json();
|
|
354
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, amount: ${result.amount}`);
|
|
350
355
|
this.postMessageHandler.sendCharge(this.config.appId, featureCode, result.amount, result.transactionId);
|
|
351
356
|
this.emit('charged');
|
|
352
357
|
return result;
|
|
@@ -441,6 +446,6 @@ class DotBotsAuth {
|
|
|
441
446
|
}
|
|
442
447
|
}
|
|
443
448
|
}
|
|
444
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
449
|
+
DotBotsAuth.SDK_VERSION = '1.0.11';
|
|
445
450
|
|
|
446
451
|
export { DotBotsAuth, DotBotsAuthError };
|
|
@@ -8,7 +8,7 @@ export declare class DotBotsAuth {
|
|
|
8
8
|
private readonly listeners;
|
|
9
9
|
private cachedUser;
|
|
10
10
|
private initialized;
|
|
11
|
-
static readonly SDK_VERSION = "1.0.
|
|
11
|
+
static readonly SDK_VERSION = "1.0.11";
|
|
12
12
|
constructor(config: DotBotsConfig);
|
|
13
13
|
initialize(): Promise<void>;
|
|
14
14
|
getUser(): Promise<DotBotsUser>;
|
package/dist/types/index.js
CHANGED
|
@@ -196,6 +196,7 @@ class PostMessageHandler {
|
|
|
196
196
|
*/
|
|
197
197
|
sendCharge(appId, featureCode, amount, transactionId) {
|
|
198
198
|
if (this.isInIframe()) {
|
|
199
|
+
console.warn(`[DotBotsAuth] Sending DOTBOTS_CHARGE postMessage — featureCode: ${featureCode}, amount: ${amount}, transactionId: ${transactionId}`);
|
|
199
200
|
window.parent.postMessage({ type: 'DOTBOTS_CHARGE', appId, featureCode, amount, transactionId }, this.marketplaceOrigin);
|
|
200
201
|
}
|
|
201
202
|
}
|
|
@@ -334,6 +335,7 @@ class DotBotsAuth {
|
|
|
334
335
|
async charge(featureCode, paidBy, quantity) {
|
|
335
336
|
this.assertInitialized();
|
|
336
337
|
const baseUrl = this.proxyConfigManager.getBaseUrl();
|
|
338
|
+
console.warn(`[DotBotsAuth] charge() — featureCode: ${featureCode}, paidBy: ${paidBy}, quantity: ${quantity ?? 1}`);
|
|
337
339
|
const response = await this.buildRequest(`${baseUrl}/payments/charge`, {
|
|
338
340
|
method: 'POST',
|
|
339
341
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -341,12 +343,15 @@ class DotBotsAuth {
|
|
|
341
343
|
});
|
|
342
344
|
if (response.status === 402) {
|
|
343
345
|
const body = await response.json();
|
|
346
|
+
console.error(`[DotBotsAuth] charge() failed — 402: ${body.error}`, body.reason);
|
|
344
347
|
throw new DotBotsAuthError('PAYMENT_FAILED', body.error, body.reason);
|
|
345
348
|
}
|
|
346
349
|
if (!response.ok) {
|
|
350
|
+
console.error(`[DotBotsAuth] charge() failed — HTTP ${response.status}`);
|
|
347
351
|
throw new DotBotsAuthError('NETWORK_ERROR', 'Payment request failed');
|
|
348
352
|
}
|
|
349
353
|
const result = await response.json();
|
|
354
|
+
console.warn(`[DotBotsAuth] charge() success — transactionId: ${result.transactionId}, amount: ${result.amount}`);
|
|
350
355
|
this.postMessageHandler.sendCharge(this.config.appId, featureCode, result.amount, result.transactionId);
|
|
351
356
|
this.emit('charged');
|
|
352
357
|
return result;
|
|
@@ -441,6 +446,6 @@ class DotBotsAuth {
|
|
|
441
446
|
}
|
|
442
447
|
}
|
|
443
448
|
}
|
|
444
|
-
DotBotsAuth.SDK_VERSION = '1.0.
|
|
449
|
+
DotBotsAuth.SDK_VERSION = '1.0.11';
|
|
445
450
|
|
|
446
451
|
export { DotBotsAuth, DotBotsAuthError };
|