@rehers/rehers-roleplay-sdk 2.1.5 → 2.2.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/README.md +1 -12
- package/index.d.ts +0 -2
- package/package.json +1 -1
- package/roleplay-sdk.js +9 -9
package/README.md
CHANGED
|
@@ -25,7 +25,6 @@ Or load via CDN:
|
|
|
25
25
|
userId: 'user_789',
|
|
26
26
|
userEmail: 'john@example.com',
|
|
27
27
|
userRole: 'member', // optional — "owner", "admin", or "member"
|
|
28
|
-
trialUrl: 'https://seamless.ai/pricing', // optional — shown when user not found
|
|
29
28
|
onReady: function() {
|
|
30
29
|
console.log('SDK ready');
|
|
31
30
|
},
|
|
@@ -77,16 +76,7 @@ Or load via CDN:
|
|
|
77
76
|
|
|
78
77
|
## Trial Mode
|
|
79
78
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```js
|
|
83
|
-
SeamlessRoleplay.init({
|
|
84
|
-
publishableKey: 'pk_live_abc123',
|
|
85
|
-
userId: 'unknown_user',
|
|
86
|
-
userEmail: 'unknown@example.com',
|
|
87
|
-
trialUrl: 'https://seamless.ai/pricing',
|
|
88
|
-
});
|
|
89
|
-
```
|
|
79
|
+
When the backend returns `USER_NOT_FOUND`, it includes a `paymentLink` in the response. The SDK automatically captures it and renders a trial screen directing the user to sign up — no client-side configuration needed.
|
|
90
80
|
|
|
91
81
|
## API
|
|
92
82
|
|
|
@@ -99,7 +89,6 @@ SeamlessRoleplay.init({
|
|
|
99
89
|
| `userEmail` | `string` | Yes | User email for secure account matching |
|
|
100
90
|
| `userRole` | `string` | No | User role — `"owner"`, `"admin"`, or `"member"` |
|
|
101
91
|
| `userToken` | `string` | No | Signed JWT for identity verification |
|
|
102
|
-
| `trialUrl` | `string` | No | URL shown when user not found |
|
|
103
92
|
| `origin` | `string` | No | Override app origin (dev only) |
|
|
104
93
|
| `onReady` | `function` | No | Called when session is ready |
|
|
105
94
|
| `onError` | `function` | No | Called on init error `({ code, message })` |
|
package/index.d.ts
CHANGED
|
@@ -9,8 +9,6 @@ export interface SeamlessRoleplayInitOptions {
|
|
|
9
9
|
userRole?: "owner" | "admin" | "member";
|
|
10
10
|
/** Optional signed JWT for identity verification */
|
|
11
11
|
userToken?: string;
|
|
12
|
-
/** URL shown when the user is not found (trial mode) */
|
|
13
|
-
trialUrl?: string;
|
|
14
12
|
/** Override the app origin — where the iframe loads from (for dev/testing only) */
|
|
15
13
|
origin?: string;
|
|
16
14
|
/** Called when the SDK session is ready */
|
package/package.json
CHANGED
package/roleplay-sdk.js
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
var userEmail = null;
|
|
22
22
|
var userRole = null;
|
|
23
23
|
var userToken = null;
|
|
24
|
-
var
|
|
24
|
+
var paymentLink = null;
|
|
25
25
|
var appOrigin = null;
|
|
26
26
|
|
|
27
27
|
var sessionToken = null;
|
|
@@ -116,6 +116,7 @@
|
|
|
116
116
|
if (data.error === "USER_NOT_FOUND") {
|
|
117
117
|
// Trial mode — not a fatal error
|
|
118
118
|
sessionToken = null;
|
|
119
|
+
if (data.paymentLink) paymentLink = data.paymentLink;
|
|
119
120
|
resolve({ trialMode: true });
|
|
120
121
|
return;
|
|
121
122
|
}
|
|
@@ -216,7 +217,7 @@
|
|
|
216
217
|
userId: userId,
|
|
217
218
|
contacts: addToScenarioPendingContacts,
|
|
218
219
|
};
|
|
219
|
-
if (
|
|
220
|
+
if (paymentLink) msg.paymentLink = paymentLink;
|
|
220
221
|
sendToIframe(msg);
|
|
221
222
|
} else if (token && pendingContactData) {
|
|
222
223
|
sendToIframe({
|
|
@@ -231,16 +232,16 @@
|
|
|
231
232
|
liUrl: pendingContactData.liUrl || undefined,
|
|
232
233
|
},
|
|
233
234
|
});
|
|
234
|
-
} else if (
|
|
235
|
+
} else if (paymentLink) {
|
|
235
236
|
sendToIframe({
|
|
236
237
|
type: "seamless-session-init",
|
|
237
|
-
|
|
238
|
+
paymentLink: paymentLink,
|
|
238
239
|
contact: null,
|
|
239
240
|
});
|
|
240
241
|
} else {
|
|
241
242
|
sendToIframe({
|
|
242
243
|
type: "seamless-session-init",
|
|
243
|
-
|
|
244
|
+
paymentLink: null,
|
|
244
245
|
contact: null,
|
|
245
246
|
});
|
|
246
247
|
}
|
|
@@ -373,7 +374,6 @@
|
|
|
373
374
|
userEmail = opts.userEmail || null;
|
|
374
375
|
userRole = opts.userRole || null;
|
|
375
376
|
userToken = opts.userToken || null;
|
|
376
|
-
trialUrl = opts.trialUrl || null;
|
|
377
377
|
appOrigin = opts.origin || null;
|
|
378
378
|
initCallbacks.onReady = opts.onReady || null;
|
|
379
379
|
initCallbacks.onError = opts.onError || null;
|
|
@@ -382,8 +382,8 @@
|
|
|
382
382
|
// Fetch session immediately
|
|
383
383
|
fetchSession()
|
|
384
384
|
.then(function (result) {
|
|
385
|
-
if (result.trialMode && !
|
|
386
|
-
// User not found and no
|
|
385
|
+
if (result.trialMode && !paymentLink) {
|
|
386
|
+
// User not found and no payment link from server — still call onReady
|
|
387
387
|
// The open() will show an error state in the iframe
|
|
388
388
|
}
|
|
389
389
|
if (initCallbacks.onReady) initCallbacks.onReady();
|
|
@@ -703,7 +703,7 @@
|
|
|
703
703
|
userEmail = null;
|
|
704
704
|
userRole = null;
|
|
705
705
|
userToken = null;
|
|
706
|
-
|
|
706
|
+
paymentLink = null;
|
|
707
707
|
sessionToken = null;
|
|
708
708
|
sessionExpiresAt = 0;
|
|
709
709
|
fetchingSession = null;
|