@benji-money/connect-sdk 1.1.0-beta.2 → 1.1.0-beta.4
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 +23 -3
- package/dist/connect-sdk.umd.global.js +459 -43
- package/dist/connect-sdk.umd.global.js.map +1 -1
- package/dist/index.cjs +473 -44
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +43 -3
- package/dist/index.d.ts +43 -3
- package/dist/index.js +471 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/connect-sdk.umd.d.ts +0 -14
package/README.md
CHANGED
|
@@ -86,6 +86,8 @@ The SDK accepts the following configuration options:
|
|
|
86
86
|
|
|
87
87
|
- `environment` (required): One of `local`, `development`, `sandbox`, or `production`
|
|
88
88
|
- `token` (required): Your API connect token
|
|
89
|
+
- `mode` (optional): `BenjiConnectMode` — `CONNECT` (default), `TRANSFER`, `REDEEM`, or `LOGIN`
|
|
90
|
+
- `authType` (optional): `PartnerIntegrationType` — LOGIN only; omit or set `DUMMY` for the visible modal iframe; set to your partner type (1–6) for popup-only auth
|
|
89
91
|
- `onSuccess` (optional): Callback function called when connect completed successfully
|
|
90
92
|
- `onError` (optional): Callback function called when error occurs in the connect flow
|
|
91
93
|
- `onExit` (optional): Callback function called when the user exits the connect flow
|
|
@@ -94,6 +96,14 @@ The SDK accepts the following configuration options:
|
|
|
94
96
|
- `placement` (optional): Placement relative to `anchor` — see [Placement](#placement) below
|
|
95
97
|
- `offset` (optional): Pixel gap after placement — `{ top?: number; left?: number }` (default `{ top: 0, left: 0 }`)
|
|
96
98
|
|
|
99
|
+
### Modes
|
|
100
|
+
|
|
101
|
+
| Mode | Visible UX | Notes |
|
|
102
|
+
| ---- | ---------- | ----- |
|
|
103
|
+
| **CONNECT** (default) | Centered or anchored modal iframe | No `authType`; standard connect / verify flow |
|
|
104
|
+
| **LOGIN + DUMMY / no `authType`** | Same visible modal iframe | Partner auth runs in a nested iframe inside Benji Connect |
|
|
105
|
+
| **LOGIN + non-DUMMY** | Partner popup only | Pass `authType`; Benji Connect iframe is headless — see [LOGIN popup example](#login-popup-example) below |
|
|
106
|
+
|
|
97
107
|
### Placement
|
|
98
108
|
|
|
99
109
|
Placement uses [Floating UI](https://floating-ui.com/docs/computePosition#placement) / CSS logical naming (`start` / `end`). In **LTR** layouts:
|
|
@@ -104,6 +114,11 @@ Placement uses [Floating UI](https://floating-ui.com/docs/computePosition#placem
|
|
|
104
114
|
| `bottom-end` | Below the anchor, right edge aligned with anchor's right edge |
|
|
105
115
|
| `bottom-start` | Below the anchor, left edge aligned with anchor's left edge |
|
|
106
116
|
|
|
117
|
+
**What `anchor` positions:**
|
|
118
|
+
|
|
119
|
+
- **CONNECT, TRANSFER, REDEEM, and LOGIN + DUMMY:** the modal iframe
|
|
120
|
+
- **LOGIN + non-DUMMY:** the partner-auth popup window (modal iframe stays headless)
|
|
121
|
+
|
|
107
122
|
**Defaults:**
|
|
108
123
|
|
|
109
124
|
- No `anchor` → centered modal (unchanged behavior for existing integrations)
|
|
@@ -129,30 +144,35 @@ Prefer selector, ref, or getter when the anchor can re-render (e.g. disabled/loa
|
|
|
129
144
|
- **Anchored** popovers use the full design size when width and height checks pass; otherwise they fall back to a scaled centered modal
|
|
130
145
|
- Scroll, resize, and visual viewport changes while open recompute placement and size
|
|
131
146
|
|
|
132
|
-
|
|
147
|
+
#### LOGIN popup example
|
|
148
|
+
|
|
149
|
+
Popup below a top-right login button; pass `authType` for non-DUMMY partners:
|
|
133
150
|
|
|
134
151
|
```typescript
|
|
135
152
|
import {
|
|
136
153
|
ConnectSDK,
|
|
137
154
|
BenjiConnectMode,
|
|
138
155
|
BenjiConnectPlacement,
|
|
156
|
+
PartnerIntegrationType,
|
|
139
157
|
} from "@benji-money/connect-sdk";
|
|
140
158
|
|
|
141
|
-
// Prefer a live binding (selector or ref) when the button may re-render before open()
|
|
142
159
|
const sdk = new ConnectSDK({
|
|
143
160
|
environment: "sandbox",
|
|
144
161
|
token: connectToken,
|
|
145
162
|
mode: BenjiConnectMode.LOGIN,
|
|
163
|
+
authType: PartnerIntegrationType.OAUTH_PKCE,
|
|
146
164
|
anchor: "#login-btn",
|
|
147
165
|
placement: BenjiConnectPlacement.BOTTOM_END,
|
|
148
166
|
offset: { top: 8 },
|
|
149
167
|
onSuccess: (token) => { /* ... */ },
|
|
168
|
+
onError: (error) => { /* popup blocked, etc. */ },
|
|
169
|
+
onExit: (metadata) => { /* POPUP_CLOSED when user dismisses popup */ },
|
|
150
170
|
});
|
|
151
171
|
|
|
152
172
|
await sdk.open();
|
|
153
173
|
```
|
|
154
174
|
|
|
155
|
-
> **`bottom-end`**
|
|
175
|
+
> **`bottom-end`** positions the **partner popup** below the anchor with its right edge aligned to the anchor's right edge. The Benji Connect iframe stays headless (not visible).
|
|
156
176
|
|
|
157
177
|
### Environments
|
|
158
178
|
|