@rehers/rehers-roleplay-sdk 2.1.4 → 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 CHANGED
@@ -24,8 +24,7 @@ Or load via CDN:
24
24
  publishableKey: 'pk_live_abc123',
25
25
  userId: 'user_789',
26
26
  userEmail: 'john@example.com',
27
- role: 'member', // optional — "owner", "admin", or "member"
28
- trialUrl: 'https://seamless.ai/pricing', // optional — shown when user not found
27
+ userRole: 'member', // optional — "owner", "admin", or "member"
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
- If the user doesn't have an active account, provide a `trialUrl` during init. When the backend returns `USER_NOT_FOUND`, the SDK will render a trial screen:
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
 
@@ -97,9 +87,8 @@ SeamlessRoleplay.init({
97
87
  | `publishableKey` | `string` | Yes | Publishable API key |
98
88
  | `userId` | `string` | Yes | Your user's unique identifier |
99
89
  | `userEmail` | `string` | Yes | User email for secure account matching |
100
- | `role` | `string` | No | User role — `"owner"`, `"admin"`, or `"member"` |
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 })` |
@@ -157,7 +146,7 @@ SDK Backend
157
146
  ───────────────── ─────────────────
158
147
  POST /api/sdk/session
159
148
  X-Publishable-Key: pk_live_abc123
160
- Body: { userId, userEmail, role? }
149
+ Body: { userId, userEmail, userRole? }
161
150
  1. Validate key + origin
162
151
  2. Validate userId + userEmail combo
163
152
  3. Find/create user
package/index.d.ts CHANGED
@@ -6,11 +6,9 @@ export interface SeamlessRoleplayInitOptions {
6
6
  /** User email — required for secure account matching */
7
7
  userEmail: string;
8
8
  /** Optional user role for syncing permissions ("owner" | "admin" | "member") */
9
- role?: "owner" | "admin" | "member";
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rehers/rehers-roleplay-sdk",
3
- "version": "2.1.4",
3
+ "version": "2.2.0",
4
4
  "description": "Seamless Roleplay SDK — embed roleplay call sessions via a modal + iframe",
5
5
  "main": "roleplay-sdk.js",
6
6
  "types": "index.d.ts",
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 trialUrl = null;
24
+ var paymentLink = null;
25
25
  var appOrigin = null;
26
26
 
27
27
  var sessionToken = null;
@@ -84,7 +84,7 @@
84
84
  var url = getApiOrigin() + "/api/sdk/session";
85
85
  var body = { userId: userId };
86
86
  if (userEmail) body.userEmail = userEmail;
87
- if (userRole) body.role = userRole;
87
+ if (userRole) body.userRole = userRole;
88
88
  if (userToken) body.userToken = userToken;
89
89
 
90
90
  var xhr = new XMLHttpRequest();
@@ -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 (trialUrl) msg.trialUrl = trialUrl;
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 (trialUrl) {
235
+ } else if (paymentLink) {
235
236
  sendToIframe({
236
237
  type: "seamless-session-init",
237
- trialUrl: trialUrl,
238
+ paymentLink: paymentLink,
238
239
  contact: null,
239
240
  });
240
241
  } else {
241
242
  sendToIframe({
242
243
  type: "seamless-session-init",
243
- trialUrl: null,
244
+ paymentLink: null,
244
245
  contact: null,
245
246
  });
246
247
  }
@@ -371,9 +372,8 @@
371
372
  publishableKey = opts.publishableKey;
372
373
  userId = opts.userId;
373
374
  userEmail = opts.userEmail || null;
374
- userRole = opts.role || null;
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 && !trialUrl) {
386
- // User not found and no trial URL configured — still call onReady
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
- trialUrl = null;
706
+ paymentLink = null;
707
707
  sessionToken = null;
708
708
  sessionExpiresAt = 0;
709
709
  fetchingSession = null;