@nevermined-io/ui-widgets 0.5.6 → 0.5.8
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 +40 -33
- package/dist/iframe-manager.d.ts +23 -0
- package/dist/iframe-manager.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +90 -80
- package/dist/messages.d.ts.map +1 -1
- package/dist/nevermined-widgets.d.ts.map +1 -1
- package/dist/types.d.ts +19 -13
- package/dist/types.d.ts.map +1 -1
- package/dist/utils/errors.d.ts +4 -12
- package/dist/utils/errors.d.ts.map +1 -1
- package/dist/widgets/checkout.d.ts +14 -2
- package/dist/widgets/checkout.d.ts.map +1 -1
- package/dist/widgets/delegations.d.ts +12 -0
- package/dist/widgets/delegations.d.ts.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Browser SDK for embedding Nevermined flows (checkout, card enrollment, card management, delegations) into your own website via secure iframes.
|
|
4
4
|
|
|
5
|
-
Pairs with [`@nevermined-io/ui-widgets-server`](https://www.npmjs.com/package/@nevermined-io/ui-widgets-server), which mints
|
|
5
|
+
Pairs with [`@nevermined-io/ui-widgets-server`](https://www.npmjs.com/package/@nevermined-io/ui-widgets-server), which mints widget sessions server-to-server from your backend and hands the response to this SDK.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -19,12 +19,14 @@ ESM-only. Works in any modern browser bundler (Vite, webpack 5, Rspack, esbuild,
|
|
|
19
19
|
```ts
|
|
20
20
|
import { NeverminedWidgets } from '@nevermined-io/ui-widgets'
|
|
21
21
|
|
|
22
|
-
// 1. Get
|
|
23
|
-
|
|
22
|
+
// 1. Get a widget session from your backend (see ui-widgets-server). The
|
|
23
|
+
// backend calls Nevermined with your widget key `rawSecret` and forwards
|
|
24
|
+
// the response — the secret never reaches the browser.
|
|
25
|
+
const session = await fetch('/api/widget-session').then((r) => r.json())
|
|
24
26
|
|
|
25
27
|
// 2. Initialize the SDK
|
|
26
28
|
const nvm = await NeverminedWidgets.initialize({
|
|
27
|
-
|
|
29
|
+
session,
|
|
28
30
|
environment: 'sandbox',
|
|
29
31
|
})
|
|
30
32
|
|
|
@@ -33,8 +35,8 @@ nvm.checkout.start({
|
|
|
33
35
|
did: 'did:nv:abc...',
|
|
34
36
|
container: document.getElementById('checkout')!,
|
|
35
37
|
onReady: () => console.log('iframe ready'),
|
|
36
|
-
onSuccess: result => console.log('purchase complete', result),
|
|
37
|
-
onError: error => console.error('checkout error', error),
|
|
38
|
+
onSuccess: (result) => console.log('purchase complete', result),
|
|
39
|
+
onError: (error) => console.error('checkout error', error),
|
|
38
40
|
onClose: () => console.log('user closed the iframe'),
|
|
39
41
|
})
|
|
40
42
|
```
|
|
@@ -43,13 +45,13 @@ The widget renders inside `container` as an iframe. The host page never sees Str
|
|
|
43
45
|
|
|
44
46
|
## Environments
|
|
45
47
|
|
|
46
|
-
| Value | API base URL
|
|
47
|
-
| ----------------- |
|
|
48
|
-
| `live` | `https://api.live.nevermined.app`
|
|
49
|
-
| `sandbox` | `https://api.sandbox.nevermined.app`
|
|
50
|
-
| `staging_live` | `https://api.live.nevermined.dev`
|
|
51
|
-
| `staging_sandbox` | `https://api.sandbox.nevermined.dev`
|
|
52
|
-
| `local` | `http://localhost:3001`
|
|
48
|
+
| Value | API base URL | Webapp URL |
|
|
49
|
+
| ----------------- | ------------------------------------ | ------------------------ |
|
|
50
|
+
| `live` | `https://api.live.nevermined.app` | `https://nevermined.app` |
|
|
51
|
+
| `sandbox` | `https://api.sandbox.nevermined.app` | `https://nevermined.app` |
|
|
52
|
+
| `staging_live` | `https://api.live.nevermined.dev` | `https://nevermined.dev` |
|
|
53
|
+
| `staging_sandbox` | `https://api.sandbox.nevermined.dev` | `https://nevermined.dev` |
|
|
54
|
+
| `local` | `http://localhost:3001` | `http://localhost:4200` |
|
|
53
55
|
|
|
54
56
|
`local` is for developing against a self-hosted stack. Production integrations should use `live` or `sandbox`.
|
|
55
57
|
|
|
@@ -57,11 +59,11 @@ The widget renders inside `container` as an iframe. The host page never sees Str
|
|
|
57
59
|
|
|
58
60
|
### `NeverminedWidgets.initialize(config)`
|
|
59
61
|
|
|
60
|
-
|
|
62
|
+
Accepts a widget session minted server-to-server by your backend (typically via `@nevermined-io/ui-widgets-server.createWidgetSession`) and returns a `NeverminedWidgets` instance you keep around for the lifetime of the page (or until logout). The SDK does **not** mint sessions itself; the widget key `rawSecret` stays on your backend.
|
|
61
63
|
|
|
62
64
|
```ts
|
|
63
65
|
const nvm = await NeverminedWidgets.initialize({
|
|
64
|
-
|
|
66
|
+
session, // WidgetSession returned by your backend
|
|
65
67
|
environment: 'live',
|
|
66
68
|
})
|
|
67
69
|
```
|
|
@@ -70,7 +72,7 @@ The session refreshes itself automatically in the background. If a refresh fails
|
|
|
70
72
|
|
|
71
73
|
```ts
|
|
72
74
|
nvm.on('session-expired', () => {
|
|
73
|
-
// Fetch a
|
|
75
|
+
// Fetch a fresh widget session from your backend and re-initialize.
|
|
74
76
|
})
|
|
75
77
|
```
|
|
76
78
|
|
|
@@ -139,15 +141,15 @@ Tears down any active iframe, stops the session refresh timer, and clears event
|
|
|
139
141
|
|
|
140
142
|
### `WidgetInitError`
|
|
141
143
|
|
|
142
|
-
Thrown by `NeverminedWidgets.initialize()` when the
|
|
144
|
+
Thrown by `NeverminedWidgets.initialize()` when the session is missing or malformed, or the refresh network call fails later.
|
|
143
145
|
|
|
144
146
|
```ts
|
|
145
147
|
try {
|
|
146
|
-
await NeverminedWidgets.initialize({
|
|
148
|
+
await NeverminedWidgets.initialize({ session, environment: 'live' })
|
|
147
149
|
} catch (err) {
|
|
148
150
|
if (err instanceof WidgetInitError) {
|
|
149
|
-
// err.code:
|
|
150
|
-
// |
|
|
151
|
+
// err.code: MISSING_SESSION | INVALID_SESSION | INVALID_ENVIRONMENT
|
|
152
|
+
// | NETWORK_ERROR
|
|
151
153
|
}
|
|
152
154
|
}
|
|
153
155
|
```
|
|
@@ -168,8 +170,8 @@ Errors surfaced through `onError` callbacks have a normalized shape:
|
|
|
168
170
|
type EmbedError = {
|
|
169
171
|
code: 'UNAUTHORIZED' | 'NETWORK' | 'PAYMENT_NOT_CONFIRMED' | 'UNKNOWN'
|
|
170
172
|
message: string
|
|
171
|
-
status?: number
|
|
172
|
-
apiCode?: string
|
|
173
|
+
status?: number // HTTP status when applicable
|
|
174
|
+
apiCode?: string // BCK.* error code when the iframe surfaces one
|
|
173
175
|
}
|
|
174
176
|
```
|
|
175
177
|
|
|
@@ -178,21 +180,26 @@ type EmbedError = {
|
|
|
178
180
|
The SDK and the embedded iframes communicate over `window.postMessage` with a versioned message envelope. Most consumers never need to deal with this directly, but the types are exported in case you want to inspect frames or build a custom integration:
|
|
179
181
|
|
|
180
182
|
```ts
|
|
181
|
-
import {
|
|
183
|
+
import {
|
|
184
|
+
WidgetMessageType,
|
|
185
|
+
parseMessage,
|
|
186
|
+
createMessage,
|
|
187
|
+
WIDGET_MESSAGE_VERSION,
|
|
188
|
+
} from '@nevermined-io/ui-widgets'
|
|
182
189
|
```
|
|
183
190
|
|
|
184
191
|
Message types:
|
|
185
192
|
|
|
186
|
-
| Type | Direction
|
|
187
|
-
| ----------------- |
|
|
188
|
-
| `nvm:booted` | iframe → parent
|
|
189
|
-
| `nvm:init` | parent → iframe
|
|
190
|
-
| `nvm:ready` | iframe → parent
|
|
191
|
-
| `nvm:resize` | iframe → parent
|
|
192
|
-
| `nvm:success` | iframe → parent
|
|
193
|
-
| `nvm:error` | iframe → parent
|
|
194
|
-
| `nvm:card-action` | iframe → parent
|
|
195
|
-
| `nvm:close` | iframe ↔ parent
|
|
193
|
+
| Type | Direction | When |
|
|
194
|
+
| ----------------- | --------------- | --------------------------------------------------------- |
|
|
195
|
+
| `nvm:booted` | iframe → parent | DOM mounted, before the iframe knows the session token |
|
|
196
|
+
| `nvm:init` | parent → iframe | SDK responds to `booted` with the session token |
|
|
197
|
+
| `nvm:ready` | iframe → parent | Auth validated, iframe rendered |
|
|
198
|
+
| `nvm:resize` | iframe → parent | Iframe content height changed |
|
|
199
|
+
| `nvm:success` | iframe → parent | Terminal success (purchase complete, card enrolled, etc.) |
|
|
200
|
+
| `nvm:error` | iframe → parent | Error (terminal or recoverable; check `EmbedError.code`) |
|
|
201
|
+
| `nvm:card-action` | iframe → parent | Per-row action inside `listCards` (e.g. delegate) |
|
|
202
|
+
| `nvm:close` | iframe ↔ parent | Iframe is being dismissed |
|
|
196
203
|
|
|
197
204
|
All frames carry `version: '1'`. The SDK rejects frames with mismatched versions to keep upgrades safe.
|
|
198
205
|
|
package/dist/iframe-manager.d.ts
CHANGED
|
@@ -2,7 +2,30 @@ import { type WidgetMessage } from './messages.js';
|
|
|
2
2
|
export interface IframeOptions {
|
|
3
3
|
container?: HTMLElement;
|
|
4
4
|
style?: Partial<CSSStyleDeclaration>;
|
|
5
|
+
/**
|
|
6
|
+
* Fixed CSS width for inline (container) mode. #1668: the widget renders
|
|
7
|
+
* as a fixed-size box, like a Privy UI component, so the integrator can
|
|
8
|
+
* place it predictably on their page. Clamped to
|
|
9
|
+
* `[INLINE_MIN_WIDTH, INLINE_MAX_WIDTH]`. Default: `INLINE_DEFAULT_WIDTH`
|
|
10
|
+
* — the constants are the single source of truth, so future re-tunings
|
|
11
|
+
* don't require touching this JSDoc. Ignored in fullscreen overlay mode.
|
|
12
|
+
*/
|
|
13
|
+
width?: number;
|
|
14
|
+
/**
|
|
15
|
+
* Fixed CSS height for inline mode. Clamped to
|
|
16
|
+
* `[INLINE_MIN_HEIGHT, INLINE_MAX_HEIGHT]`. Default: `INLINE_DEFAULT_HEIGHT`.
|
|
17
|
+
* The embed content uses responsive CSS to adapt to the dimensions the
|
|
18
|
+
* integrator picks — within the clamped range — without distorting (no
|
|
19
|
+
* CSS transform scale). Ignored in fullscreen overlay mode.
|
|
20
|
+
*/
|
|
21
|
+
height?: number;
|
|
5
22
|
}
|
|
23
|
+
export declare const INLINE_MIN_WIDTH = 440;
|
|
24
|
+
export declare const INLINE_MAX_WIDTH = 720;
|
|
25
|
+
export declare const INLINE_DEFAULT_WIDTH = 480;
|
|
26
|
+
export declare const INLINE_MIN_HEIGHT = 640;
|
|
27
|
+
export declare const INLINE_MAX_HEIGHT = 960;
|
|
28
|
+
export declare const INLINE_DEFAULT_HEIGHT = 720;
|
|
6
29
|
export declare class IframeManager {
|
|
7
30
|
private expectedOrigin;
|
|
8
31
|
private iframe;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../src/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAEhE,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"iframe-manager.d.ts","sourceRoot":"","sources":["../src/iframe-manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,aAAa,EAAE,MAAM,eAAe,CAAA;AAEhE,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,KAAK,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,CAAA;IACpC;;;;;;;OAOG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AASD,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,gBAAgB,MAAM,CAAA;AACnC,eAAO,MAAM,oBAAoB,MAAM,CAAA;AACvC,eAAO,MAAM,iBAAiB,MAAM,CAAA;AACpC,eAAO,MAAM,iBAAiB,MAAM,CAAA;AACpC,eAAO,MAAM,qBAAqB,MAAM,CAAA;AAMxC,qBAAa,aAAa;IAOZ,OAAO,CAAC,cAAc;IANlC,OAAO,CAAC,MAAM,CAAiC;IAC/C,OAAO,CAAC,eAAe,CAA0C;IACjE,OAAO,CAAC,qBAAqB,CAAsC;IACnE,OAAO,CAAC,eAAe,CAA+C;IACtE,OAAO,CAAC,SAAS,CAAQ;gBAEL,cAAc,EAAE,MAAM;IAQ1C,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,iBAAiB;IAiD/D,OAAO,IAAI,IAAI;IAYf,WAAW,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI;IAKrC,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,aAAa,KAAK,IAAI,GAAG,MAAM,IAAI;IAO5D,eAAe,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,KAAK,IAAI,GAAG,MAAM,IAAI;IAO9D,OAAO,CAAC,cAAc;CAiCvB"}
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NeverminedWidgets={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=[`local`,`sandbox`,`live`,`staging_sandbox`,`staging_live`],n={local:`http://localhost:3001`,sandbox:`https://api.sandbox.nevermined.app`,live:`https://api.live.nevermined.app`,staging_sandbox:`https://api.sandbox.nevermined.dev`,staging_live:`https://api.live.nevermined.dev`},r={local:`http://localhost:4200`,sandbox:`https://nevermined.app`,live:`https://nevermined.app`,staging_sandbox:`https://nevermined.dev`,staging_live:`https://nevermined.dev`};function i(e){return n[e]}function a(e){return r[e]}var o={MISSING_INIT_TOKEN:{numericCode:`WDG.0001`,message:`initToken is required and must be a non-empty string`},INVALID_ENVIRONMENT:{numericCode:`WDG.0002`,message:`environment must be one of: sandbox, live, staging_sandbox, staging_live, local`},INVALID_INIT_TOKEN:{numericCode:`WDG.0003`,message:`Init token is invalid or expired`},INVALID_RESPONSE:{numericCode:`WDG.0004`,message:`Server response is missing required fields`},NETWORK_ERROR:{numericCode:`WDG.0005`,message:`Network request failed`},SESSION_EXPIRED:{numericCode:`WDG.0006`,message:`Widget session has expired`}},s=class extends Error{constructor(e,t,n){super(t??o[e].message,{cause:n}),this.code=e,this.name=`WidgetInitError`}},c=class extends Error{code=`SESSION_EXPIRED`;constructor(){super(o.SESSION_EXPIRED.message),this.name=`WidgetSessionExpiredError`}},l=class extends Error{constructor(e,t,n){super(e),this.status=t,this.apiCode=n,this.name=`WidgetApiError`}},u=.8,d=class{session;expiresMs;timer=null;constructor(e){this.session=e,this.expiresMs=new Date(e.expiresAt).getTime(),Number.isNaN(this.expiresMs)&&console.warn(`[SessionManager] malformed expiresAt, session will be treated as expired:`,e.expiresAt)}isValid(){return!Number.isNaN(this.expiresMs)&&this.expiresMs>Date.now()}getToken(){return this.session.sessionToken}getSession(){return this.session}startAutoRefresh(e,t){if(this.stopAutoRefresh(),!this.isValid()){t();return}let n=Math.max(0,Math.floor((this.expiresMs-Date.now())*u));this.timer=setTimeout(()=>{this.timer=null,e().then(n=>{if(this.session=n,this.expiresMs=new Date(n.expiresAt).getTime(),!this.isValid()){t();return}this.startAutoRefresh(e,t)},e=>{console.error(`[SessionManager] session refresh failed:`,e),t()})},n)}stopAutoRefresh(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}},f=class{listeners=new Map;on(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),this}off(e,t){let n=this.listeners.get(e);return n?(n.delete(t),n.size===0&&this.listeners.delete(e),this):this}once(e,t){let n=r=>{this.off(e,n),t(r)};return this.on(e,n)}removeAllListeners(e){return e===void 0?this.listeners.clear():this.listeners.delete(e),this}emit(e,t){let n=this.listeners.get(e);n&&[...n].forEach(e=>{try{e(t)}catch(e){console.error(`[TypedEventEmitter] Handler threw:`,e)}})}},p=function(e){return e.INIT=`nvm:init`,e.CLOSE=`nvm:close`,e.BOOTED=`nvm:booted`,e.READY=`nvm:ready`,e.RESIZE=`nvm:resize`,e.SUCCESS=`nvm:success`,e.ERROR=`nvm:error`,e.CARD_ACTION=`nvm:card-action`,e.AUTH_MISMATCH=`nvm:auth-mismatch`,e.AUTH_SWITCH_REQUEST=`nvm:auth-switch-request`,e}({}),m=`1`,h=`1`;function g(e){return typeof e==`string`&&Object.values(p).includes(e)}function _(e,t){return{type:e,version:h,payload:t}}function v(e){if(typeof e!=`object`||!e)return{ok:!1,reason:`not an object`};let t=e;return g(t.type)?t.version===h?{ok:!0,message:{type:t.type,version:t.version,payload:t.payload}}:{ok:!1,reason:`version mismatch: received "${t.version}", expected "${h}"`}:{ok:!1,reason:typeof t.type==`string`&&t.type.startsWith(`nvm:`)?`unknown nvm: type "${t.type}"`:`missing or unknown type`}}var y=class{iframe=null;messageHandlers=new Set;protocolErrorHandlers=new Set;messageListener=null;destroyed=!1;constructor(e){if(this.expectedOrigin=e,e===`*`)throw Error(`[IframeManager] Wildcard origin "*" is not allowed — pass an explicit origin`)}create(e,t){this.iframe?.remove();let n=document.createElement(`iframe`);return n.src=e,n.style.width=`100%`,n.style.height=`100%`,n.style.border=`none`,n.style.display=`block`,n.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),t?.container||(n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.right=`0`,n.style.bottom=`0`,n.style.zIndex=`9999`),t?.style&&Object.assign(n.style,t.style),(t?.container??document.body).appendChild(n),this.iframe=n,n}destroy(){this.destroyed=!0,this.messageListener&&=(window.removeEventListener(`message`,this.messageListener),null),this.messageHandlers.clear(),this.protocolErrorHandlers.clear(),this.iframe?.remove(),this.iframe=null}postMessage(e){this.destroyed||this.iframe?.contentWindow?.postMessage(e,this.expectedOrigin)}onMessage(e){return this.destroyed?()=>void 0:(this.messageHandlers.add(e),this.ensureListener(),()=>this.messageHandlers.delete(e))}onProtocolError(e){return this.destroyed?()=>void 0:(this.protocolErrorHandlers.add(e),this.ensureListener(),()=>this.protocolErrorHandlers.delete(e))}ensureListener(){this.messageListener||(this.messageListener=e=>{if(e.origin!==this.expectedOrigin)return;let t=v(e.data);if(!t.ok){console.warn(`[IframeManager] Discarding message from ${this.expectedOrigin}: ${t.reason}`),this.protocolErrorHandlers.forEach(e=>{try{e(t.reason)}catch(e){console.error(`[IframeManager] Protocol error handler threw:`,e)}});return}this.messageHandlers.forEach(e=>{try{e(t.message)}catch(e){console.error(`[IframeManager] Message handler threw:`,e)}})},window.addEventListener(`message`,this.messageListener))}},b={code:`UNKNOWN`,message:`Unknown widget error`},x=class{manager=null;destroyed=!1;constructor(e,t){this.session=e,this.webappBase=t}start(e){if(this.destroyed)throw Error(`[CheckoutWidget] cannot start: instance has been destroyed`);if(!e.did||typeof e.did!=`string`)throw Error(`[CheckoutWidget] did is required`);this.manager?.destroy();let t=new URL(this.webappBase).origin,n=window.location.origin,r=new URL(`/embed/checkout/${encodeURIComponent(e.did)}`,this.webappBase);r.searchParams.set(`parentOrigin`,n),e.planId&&r.searchParams.set(`planId`,e.planId);let i=new y(t);this.manager=i,i.create(r.toString(),{container:e.container}),i.onMessage(t=>this.handleMessage(t,e))}destroy(){this.destroyed=!0,this.manager?.destroy(),this.manager=null}handleMessage(e,t){if(!w(e,t))switch(e.type){case p.BOOTED:this.manager?.postMessage(_(p.INIT,{sessionToken:this.session.getToken()})),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=e.payload??{};t.onSuccess?.({did:n.did??t.did,planId:n.planId??t.planId,txHash:n.txHash});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??b);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}};function S(e){if(typeof e!=`object`||!e)return null;let t=e.expectedEmail;return typeof t!=`string`||t.length===0?null:{expectedEmail:t}}function C(e){if(typeof e!=`object`||!e)return null;let t=e.requestedEmail,n=e.expectedEmail;return typeof t!=`string`||t.length===0||typeof n!=`string`||n.length===0?null:{requestedEmail:t,expectedEmail:n}}function w(e,t){if(e.type===p.AUTH_MISMATCH){let n=S(e.payload);return n&&t.onAuthMismatch?.(n),!0}if(e.type===p.AUTH_SWITCH_REQUEST){let n=C(e.payload);return n&&t.onAuthSwitchRequest?.(n),!0}return!1}var T={code:`UNKNOWN`,message:`Unknown widget error`},E={code:`UNKNOWN`,message:`Malformed nvm:success payload — paymentMethodId missing or invalid`},D={code:`UNKNOWN`,message:`Malformed nvm:success payload — delegationId missing or invalid`},O=class{manager=null;destroyed=!1;constructor(e,t,n){this.session=e,this.webappBase=t,this.apiBase=n}enrollCard(e){this.assertAlive(`enrollCard`),this.mountIframe(`/embed/cards/enroll`,e.container).onMessage(t=>this.handleEnrollMessage(t,e))}listCards(e){this.assertAlive(`listCards`),this.mountIframe(`/embed/cards/list`,e.container).onMessage(t=>this.handleListMessage(t,e))}createDelegation(e){if(this.assertAlive(`createDelegation`),typeof e.paymentMethodId!=`string`||e.paymentMethodId.length===0)throw Error(`[DelegationsWidget] createDelegation: paymentMethodId is required`);this.mountIframe(`/embed/cards/delegate`,e.container,{paymentMethodId:e.paymentMethodId}).onMessage(t=>this.handleCreateDelegationMessage(t,e))}async revokeCard(e){if(typeof e!=`string`||e.length===0)throw Error(`[DelegationsWidget] revokeCard: paymentMethodId is required`);await this.deleteWithSession(`${this.apiBase}/api/v1/widgets/payment-methods/${encodeURIComponent(e)}`,`Failed to revoke payment method`)}async revokeDelegation(e){if(typeof e!=`string`||e.length===0)throw Error(`[DelegationsWidget] revokeDelegation: delegationId is required`);await this.deleteWithSession(`${this.apiBase}/api/v1/widgets/delegation/${encodeURIComponent(e)}`,`Failed to revoke delegation`)}destroy(){this.destroyed=!0,this.manager?.destroy(),this.manager=null}assertAlive(e){if(this.destroyed)throw Error(`[DelegationsWidget] cannot ${e}: instance has been destroyed`)}mountIframe(e,t,n={}){this.manager?.destroy();let r=new URL(this.webappBase).origin,i=window.location.origin,a=new URL(e,this.webappBase);a.searchParams.set(`parentOrigin`,i);for(let[e,t]of Object.entries(n))a.searchParams.set(e,t);let o=new y(r);return this.manager=o,o.create(a.toString(),{container:t}),o}postInitOnBooted(){this.manager?.postMessage(_(p.INIT,{sessionToken:this.session.getToken()}))}handleEnrollMessage(e,t){if(!w(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=(e.payload??{}).paymentMethodId;if(typeof n!=`string`||n.length===0){t.onError?.(E);return}t.onSuccess?.({paymentMethodId:n});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??T);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}handleListMessage(e,t){if(!w(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.CARD_ACTION:{let n=e.payload??{};if(n.action!==`delegate`||typeof n.paymentMethodId!=`string`||n.paymentMethodId.length===0)return;t.onCardAction?.({action:n.action,paymentMethodId:n.paymentMethodId});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??T);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}handleCreateDelegationMessage(e,t){if(!w(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=(e.payload??{}).delegationId;if(typeof n!=`string`||n.length===0){t.onError?.(D);return}t.onSuccess?.({delegationId:n,paymentMethodId:t.paymentMethodId});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??T);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}async deleteWithSession(e,t){let n;try{n=await fetch(e,{method:`DELETE`,headers:{Authorization:`Bearer ${this.session.getToken()}`,Accept:`application/json`}})}catch(e){throw new l(e instanceof Error&&e.message?e.message:t)}if(n.ok)return;let r,i=t;try{let e=await n.json();typeof e?.message==`string`&&e.message.length>0&&(i=e.message),typeof e?.code==`string`&&(r=e.code)}catch{}throw new l(i,n.status,r)}};function k(e){if(typeof e!=`object`||!e)return!1;let t=e;return[`sessionToken`,`userId`,`expiresAt`,`apiKeyHash`].every(e=>typeof t[e]==`string`)&&typeof t.userWallet==`string`&&t.userWallet.startsWith(`0x`)}var A=class e{_checkout=null;_delegations=null;events=new f;constructor(e,t,n){this.sessionManager=e,this._account=t,this.environment=n}static async initialize(n){let{initToken:r,environment:a}=n;if(!r||typeof r!=`string`)throw new s(`MISSING_INIT_TOKEN`);if(!a||!t.includes(a))throw new s(`INVALID_ENVIRONMENT`);let o=i(a),c;try{c=await fetch(`${o}/api/v1/widgets/session`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({initToken:r})})}catch(e){throw console.error(`[NeverminedWidgets] fetch failed:`,e),new s(`NETWORK_ERROR`,void 0,e)}if(!c.ok)throw c.status===401?new s(`INVALID_INIT_TOKEN`):new s(`NETWORK_ERROR`,`Request failed with status ${c.status}`);let l;try{l=await c.json()}catch(e){throw new s(`INVALID_RESPONSE`,void 0,e)}if(!k(l))throw new s(`INVALID_RESPONSE`);let u=new d(l),f=new e(u,{userId:l.userId,userWallet:l.userWallet},a);return u.startAutoRefresh(()=>f.refreshSession(),()=>f.events.emit(`session-expired`,void 0)),f}async refreshSession(){let e=await fetch(`${i(this.environment)}/api/v1/widgets/session/refresh`,{method:`POST`,headers:{Authorization:`Bearer ${this.sessionManager.getToken()}`}});if(!e.ok)throw Error(`Session refresh failed with status ${e.status}`);let t=await e.json();if(!k(t))throw Error(`Session refresh returned an invalid response`);return t}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(e,t),this}get account(){return this._account}get hasValidSession(){return this.sessionManager.isValid()}getSessionToken(){if(!this.sessionManager.isValid())throw new c;return this.sessionManager.getToken()}get checkout(){return this._checkout||=new x(this.sessionManager,a(this.environment)),this._checkout}get delegations(){return this._delegations||=new O(this.sessionManager,a(this.environment),i(this.environment)),this._delegations}destroy(){this.sessionManager.stopAutoRefresh(),this._checkout?.destroy(),this._checkout=null,this._delegations?.destroy(),this._delegations=null,this.events.removeAllListeners()}};e.CheckoutWidget=x,e.DelegationsWidget=O,e.IframeManager=y,e.NeverminedWidgets=A,e.SessionManager=d,e.TypedEventEmitter=f,e.WIDGET_MESSAGE_VERSION=m,e.WidgetApiError=l,e.WidgetInitError=s,e.WidgetMessageType=p,e.WidgetSessionExpiredError=c,e.createMessage=_,e.parseMessage=v});
|
|
1
|
+
(function(e,t){typeof exports==`object`&&typeof module<`u`?t(exports):typeof define==`function`&&define.amd?define([`exports`],t):(e=typeof globalThis<`u`?globalThis:e||self,t(e.NeverminedWidgets={}))})(this,function(e){Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=[`local`,`sandbox`,`live`,`staging_sandbox`,`staging_live`],n={local:`http://localhost:3001`,sandbox:`https://api.sandbox.nevermined.app`,live:`https://api.live.nevermined.app`,staging_sandbox:`https://api.sandbox.nevermined.dev`,staging_live:`https://api.live.nevermined.dev`},r={local:`http://localhost:4200`,sandbox:`https://nevermined.app`,live:`https://nevermined.app`,staging_sandbox:`https://nevermined.dev`,staging_live:`https://nevermined.dev`};function i(e){return n[e]}function a(e){return r[e]}var o={MISSING_SESSION:{numericCode:`WDG.0001`,message:`session is required — pass the WidgetSession returned by createWidgetSession on the backend`},INVALID_ENVIRONMENT:{numericCode:`WDG.0002`,message:`environment must be one of: sandbox, live, staging_sandbox, staging_live, local`},INVALID_SESSION:{numericCode:`WDG.0003`,message:`session is missing required fields`},SESSION_EXPIRED:{numericCode:`WDG.0006`,message:`Widget session has expired`}},s=class extends Error{code;constructor(e,t,n){super(t??o[e].message,{cause:n}),this.code=e,this.name=`WidgetInitError`}},c=class extends Error{code=`SESSION_EXPIRED`;constructor(){super(o.SESSION_EXPIRED.message),this.name=`WidgetSessionExpiredError`}},l=class extends Error{status;apiCode;constructor(e,t,n){super(e),this.status=t,this.apiCode=n,this.name=`WidgetApiError`}},u=.8,d=class{session;expiresMs;timer=null;constructor(e){this.session=e,this.expiresMs=new Date(e.expiresAt).getTime(),Number.isNaN(this.expiresMs)&&console.warn(`[SessionManager] malformed expiresAt, session will be treated as expired:`,e.expiresAt)}isValid(){return!Number.isNaN(this.expiresMs)&&this.expiresMs>Date.now()}getToken(){return this.session.sessionToken}getSession(){return this.session}startAutoRefresh(e,t){if(this.stopAutoRefresh(),!this.isValid()){t();return}let n=Math.max(0,Math.floor((this.expiresMs-Date.now())*u));this.timer=setTimeout(()=>{this.timer=null,e().then(n=>{if(this.session=n,this.expiresMs=new Date(n.expiresAt).getTime(),!this.isValid()){t();return}this.startAutoRefresh(e,t)},e=>{console.error(`[SessionManager] session refresh failed:`,e),t()})},n)}stopAutoRefresh(){this.timer!==null&&(clearTimeout(this.timer),this.timer=null)}},f=class{listeners=new Map;on(e,t){let n=this.listeners.get(e)??new Set;return n.add(t),this.listeners.set(e,n),this}off(e,t){let n=this.listeners.get(e);return n?(n.delete(t),n.size===0&&this.listeners.delete(e),this):this}once(e,t){let n=r=>{this.off(e,n),t(r)};return this.on(e,n)}removeAllListeners(e){return e===void 0?this.listeners.clear():this.listeners.delete(e),this}emit(e,t){let n=this.listeners.get(e);n&&[...n].forEach(e=>{try{e(t)}catch(e){console.error(`[TypedEventEmitter] Handler threw:`,e)}})}},p=function(e){return e.INIT=`nvm:init`,e.CLOSE=`nvm:close`,e.BOOTED=`nvm:booted`,e.READY=`nvm:ready`,e.RESIZE=`nvm:resize`,e.SUCCESS=`nvm:success`,e.ERROR=`nvm:error`,e.CARD_ACTION=`nvm:card-action`,e.AUTH_MISMATCH=`nvm:auth-mismatch`,e.AUTH_SWITCH_REQUEST=`nvm:auth-switch-request`,e}({}),m=`1`,h=`1`;function g(e){return typeof e==`string`&&Object.values(p).includes(e)}function _(e,t){return{type:e,version:h,payload:t}}function v(e){if(typeof e!=`object`||!e)return{ok:!1,reason:`not an object`};let t=e;return g(t.type)?t.version===h?{ok:!0,message:{type:t.type,version:t.version,payload:t.payload}}:{ok:!1,reason:`version mismatch: received "${t.version}", expected "${h}"`}:{ok:!1,reason:typeof t.type==`string`&&t.type.startsWith(`nvm:`)?`unknown nvm: type "${t.type}"`:`missing or unknown type`}}function y(e,t,n){return Math.max(t,Math.min(n,Math.round(e)))}var b=class{expectedOrigin;iframe=null;messageHandlers=new Set;protocolErrorHandlers=new Set;messageListener=null;destroyed=!1;constructor(e){if(this.expectedOrigin=e,e===`*`)throw Error(`[IframeManager] Wildcard origin "*" is not allowed — pass an explicit origin`)}create(e,t){this.iframe?.remove();let n=document.createElement(`iframe`);if(n.src=e,n.style.display=`block`,n.setAttribute(`sandbox`,`allow-scripts allow-same-origin allow-forms`),!t?.container)n.style.width=`100%`,n.style.height=`100%`,n.style.border=`none`,n.style.position=`fixed`,n.style.top=`0`,n.style.left=`0`,n.style.right=`0`,n.style.bottom=`0`,n.style.zIndex=`9999`;else{let e=y(t.width??480,440,720),r=y(t.height??720,640,960);n.style.width=`${e}px`,n.style.height=`${r}px`,n.style.border=`1px solid #e5e7eb`,n.style.borderRadius=`8px`,n.style.boxSizing=`border-box`}return t?.style&&Object.assign(n.style,t.style),(t?.container??document.body).appendChild(n),this.iframe=n,n}destroy(){this.destroyed=!0,this.messageListener&&=(window.removeEventListener(`message`,this.messageListener),null),this.messageHandlers.clear(),this.protocolErrorHandlers.clear(),this.iframe?.remove(),this.iframe=null}postMessage(e){this.destroyed||this.iframe?.contentWindow?.postMessage(e,this.expectedOrigin)}onMessage(e){return this.destroyed?()=>void 0:(this.messageHandlers.add(e),this.ensureListener(),()=>this.messageHandlers.delete(e))}onProtocolError(e){return this.destroyed?()=>void 0:(this.protocolErrorHandlers.add(e),this.ensureListener(),()=>this.protocolErrorHandlers.delete(e))}ensureListener(){this.messageListener||(this.messageListener=e=>{if(e.origin!==this.expectedOrigin)return;let t=v(e.data);if(!t.ok){console.warn(`[IframeManager] Discarding message from ${this.expectedOrigin}: ${t.reason}`),this.protocolErrorHandlers.forEach(e=>{try{e(t.reason)}catch(e){console.error(`[IframeManager] Protocol error handler threw:`,e)}});return}this.messageHandlers.forEach(e=>{try{e(t.message)}catch(e){console.error(`[IframeManager] Message handler threw:`,e)}})},window.addEventListener(`message`,this.messageListener))}},x={code:`UNKNOWN`,message:`Unknown widget error`},S=class{session;webappBase;manager=null;destroyed=!1;constructor(e,t){this.session=e,this.webappBase=t}start(e){if(this.destroyed)throw Error(`[CheckoutWidget] cannot start: instance has been destroyed`);if(!e.did||typeof e.did!=`string`)throw Error(`[CheckoutWidget] did is required`);this.manager?.destroy();let t=new URL(this.webappBase).origin,n=window.location.origin,r=new URL(`/embed/checkout/${encodeURIComponent(e.did)}`,this.webappBase);r.searchParams.set(`parentOrigin`,n),e.planId&&r.searchParams.set(`planId`,e.planId);let i=new b(t);this.manager=i,i.create(r.toString(),{container:e.container,width:e.width,height:e.height}),i.onMessage(t=>this.handleMessage(t,e))}destroy(){this.destroyed=!0,this.manager?.destroy(),this.manager=null}handleMessage(e,t){if(!T(e,t))switch(e.type){case p.BOOTED:this.manager?.postMessage(_(p.INIT,{sessionToken:this.session.getToken()})),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=e.payload??{};t.onSuccess?.({did:n.did??t.did,planId:n.planId??t.planId,txHash:n.txHash});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??x);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}};function C(e){if(typeof e!=`object`||!e)return null;let t=e.expectedEmail;return typeof t!=`string`||t.length===0?null:{expectedEmail:t}}function w(e){if(typeof e!=`object`||!e)return null;let t=e.requestedEmail,n=e.expectedEmail;return typeof t!=`string`||t.length===0||typeof n!=`string`||n.length===0?null:{requestedEmail:t,expectedEmail:n}}function T(e,t){if(e.type===p.AUTH_MISMATCH){let n=C(e.payload);return n&&t.onAuthMismatch?.(n),!0}if(e.type===p.AUTH_SWITCH_REQUEST){let n=w(e.payload);return n&&t.onAuthSwitchRequest?.(n),!0}return!1}var E={code:`UNKNOWN`,message:`Unknown widget error`},D={code:`UNKNOWN`,message:`Malformed nvm:success payload — paymentMethodId missing or invalid`},O={code:`UNKNOWN`,message:`Malformed nvm:success payload — delegationId missing or invalid`},k=class{session;webappBase;apiBase;manager=null;destroyed=!1;constructor(e,t,n){this.session=e,this.webappBase=t,this.apiBase=n}enrollCard(e){this.assertAlive(`enrollCard`),this.mountIframe(`/embed/cards/enroll`,e.container,void 0,{width:e.width,height:e.height}).onMessage(t=>this.handleEnrollMessage(t,e))}listCards(e){this.assertAlive(`listCards`),this.mountIframe(`/embed/cards/list`,e.container,void 0,{width:e.width,height:e.height}).onMessage(t=>this.handleListMessage(t,e))}createDelegation(e){if(this.assertAlive(`createDelegation`),typeof e.paymentMethodId!=`string`||e.paymentMethodId.length===0)throw Error(`[DelegationsWidget] createDelegation: paymentMethodId is required`);this.mountIframe(`/embed/cards/delegate`,e.container,{paymentMethodId:e.paymentMethodId},{width:e.width,height:e.height}).onMessage(t=>this.handleCreateDelegationMessage(t,e))}async revokeCard(e){if(typeof e!=`string`||e.length===0)throw Error(`[DelegationsWidget] revokeCard: paymentMethodId is required`);await this.deleteWithSession(`${this.apiBase}/api/v1/widgets/payment-methods/${encodeURIComponent(e)}`,`Failed to revoke payment method`)}async revokeDelegation(e){if(typeof e!=`string`||e.length===0)throw Error(`[DelegationsWidget] revokeDelegation: delegationId is required`);await this.deleteWithSession(`${this.apiBase}/api/v1/widgets/delegation/${encodeURIComponent(e)}`,`Failed to revoke delegation`)}destroy(){this.destroyed=!0,this.manager?.destroy(),this.manager=null}assertAlive(e){if(this.destroyed)throw Error(`[DelegationsWidget] cannot ${e}: instance has been destroyed`)}mountIframe(e,t,n={},r={}){this.manager?.destroy();let i=new URL(this.webappBase).origin,a=window.location.origin,o=new URL(e,this.webappBase);o.searchParams.set(`parentOrigin`,a);for(let[e,t]of Object.entries(n))o.searchParams.set(e,t);let s=new b(i);return this.manager=s,s.create(o.toString(),{container:t,width:r.width,height:r.height}),s}postInitOnBooted(){this.manager?.postMessage(_(p.INIT,{sessionToken:this.session.getToken()}))}handleEnrollMessage(e,t){if(!T(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=(e.payload??{}).paymentMethodId;if(typeof n!=`string`||n.length===0){t.onError?.(D);return}t.onSuccess?.({paymentMethodId:n});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??E);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}handleListMessage(e,t){if(!T(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.CARD_ACTION:{let n=e.payload??{};if(n.action!==`delegate`||typeof n.paymentMethodId!=`string`||n.paymentMethodId.length===0)return;t.onCardAction?.({action:n.action,paymentMethodId:n.paymentMethodId});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??E);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}handleCreateDelegationMessage(e,t){if(!T(e,t))switch(e.type){case p.BOOTED:this.postInitOnBooted(),t.onBooted?.();return;case p.READY:t.onReady?.();return;case p.SUCCESS:{let n=(e.payload??{}).delegationId;if(typeof n!=`string`||n.length===0){t.onError?.(O);return}t.onSuccess?.({delegationId:n,paymentMethodId:t.paymentMethodId});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??E);return}case p.CLOSE:t.onClose?.(),this.destroy();return;default:return}}async deleteWithSession(e,t){let n;try{n=await fetch(e,{method:`DELETE`,headers:{Authorization:`Bearer ${this.session.getToken()}`,Accept:`application/json`}})}catch(e){throw new l(e instanceof Error&&e.message?e.message:t)}if(n.ok)return;let r,i=t;try{let e=await n.json();typeof e?.message==`string`&&e.message.length>0&&(i=e.message),typeof e?.code==`string`&&(r=e.code)}catch{}throw new l(i,n.status,r)}};function A(e){if(typeof e!=`object`||!e)return!1;let t=e;return[`sessionToken`,`userId`,`expiresAt`,`apiKeyHash`].every(e=>typeof t[e]==`string`)&&typeof t.userWallet==`string`&&t.userWallet.startsWith(`0x`)}var j=class e{sessionManager;_account;environment;_checkout=null;_delegations=null;events=new f;constructor(e,t,n){this.sessionManager=e,this._account=t,this.environment=n}static async initialize(n){let{session:r,environment:i}=n;if(!r||typeof r!=`object`)throw new s(`MISSING_SESSION`);if(!i||!t.includes(i))throw new s(`INVALID_ENVIRONMENT`);if(!A(r))throw new s(`INVALID_SESSION`);let a=new d(r),o=new e(a,{userId:r.userId,userWallet:r.userWallet},i);return a.startAutoRefresh(()=>o.refreshSession(),()=>o.events.emit(`session-expired`,void 0)),o}async refreshSession(){let e=await fetch(`${i(this.environment)}/api/v1/widgets/session/refresh`,{method:`POST`,headers:{Authorization:`Bearer ${this.sessionManager.getToken()}`}});if(!e.ok)throw Error(`Session refresh failed with status ${e.status}`);let t=await e.json();if(!A(t))throw Error(`Session refresh returned an invalid response`);return t}on(e,t){return this.events.on(e,t),this}off(e,t){return this.events.off(e,t),this}get account(){return this._account}get hasValidSession(){return this.sessionManager.isValid()}getSessionToken(){if(!this.sessionManager.isValid())throw new c;return this.sessionManager.getToken()}get checkout(){return this._checkout||=new S(this.sessionManager,a(this.environment)),this._checkout}get delegations(){return this._delegations||=new k(this.sessionManager,a(this.environment),i(this.environment)),this._delegations}destroy(){this.sessionManager.stopAutoRefresh(),this._checkout?.destroy(),this._checkout=null,this._delegations?.destroy(),this._delegations=null,this.events.removeAllListeners()}};e.CheckoutWidget=S,e.DelegationsWidget=k,e.IframeManager=b,e.NeverminedWidgets=j,e.SessionManager=d,e.TypedEventEmitter=f,e.WIDGET_MESSAGE_VERSION=m,e.WidgetApiError=l,e.WidgetInitError=s,e.WidgetMessageType=p,e.WidgetSessionExpiredError=c,e.createMessage=_,e.parseMessage=v});
|
package/dist/index.mjs
CHANGED
|
@@ -27,31 +27,24 @@ function i(e) {
|
|
|
27
27
|
//#endregion
|
|
28
28
|
//#region src/utils/errors.ts
|
|
29
29
|
var a = {
|
|
30
|
-
|
|
30
|
+
MISSING_SESSION: {
|
|
31
31
|
numericCode: "WDG.0001",
|
|
32
|
-
message: "
|
|
32
|
+
message: "session is required — pass the WidgetSession returned by createWidgetSession on the backend"
|
|
33
33
|
},
|
|
34
34
|
INVALID_ENVIRONMENT: {
|
|
35
35
|
numericCode: "WDG.0002",
|
|
36
36
|
message: "environment must be one of: sandbox, live, staging_sandbox, staging_live, local"
|
|
37
37
|
},
|
|
38
|
-
|
|
38
|
+
INVALID_SESSION: {
|
|
39
39
|
numericCode: "WDG.0003",
|
|
40
|
-
message: "
|
|
41
|
-
},
|
|
42
|
-
INVALID_RESPONSE: {
|
|
43
|
-
numericCode: "WDG.0004",
|
|
44
|
-
message: "Server response is missing required fields"
|
|
45
|
-
},
|
|
46
|
-
NETWORK_ERROR: {
|
|
47
|
-
numericCode: "WDG.0005",
|
|
48
|
-
message: "Network request failed"
|
|
40
|
+
message: "session is missing required fields"
|
|
49
41
|
},
|
|
50
42
|
SESSION_EXPIRED: {
|
|
51
43
|
numericCode: "WDG.0006",
|
|
52
44
|
message: "Widget session has expired"
|
|
53
45
|
}
|
|
54
46
|
}, o = class extends Error {
|
|
47
|
+
code;
|
|
55
48
|
constructor(e, t, n) {
|
|
56
49
|
super(t ?? a[e].message, { cause: n }), this.code = e, this.name = "WidgetInitError";
|
|
57
50
|
}
|
|
@@ -61,6 +54,8 @@ var a = {
|
|
|
61
54
|
super(a.SESSION_EXPIRED.message), this.name = "WidgetSessionExpiredError";
|
|
62
55
|
}
|
|
63
56
|
}, c = class extends Error {
|
|
57
|
+
status;
|
|
58
|
+
apiCode;
|
|
64
59
|
constructor(e, t, n) {
|
|
65
60
|
super(e), this.status = t, this.apiCode = n, this.name = "WidgetApiError";
|
|
66
61
|
}
|
|
@@ -164,9 +159,11 @@ function _(e) {
|
|
|
164
159
|
reason: typeof t.type == "string" && t.type.startsWith("nvm:") ? `unknown nvm: type "${t.type}"` : "missing or unknown type"
|
|
165
160
|
};
|
|
166
161
|
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
162
|
+
function v(e, t, n) {
|
|
163
|
+
return Math.max(t, Math.min(n, Math.round(e)));
|
|
164
|
+
}
|
|
165
|
+
var y = class {
|
|
166
|
+
expectedOrigin;
|
|
170
167
|
iframe = null;
|
|
171
168
|
messageHandlers = /* @__PURE__ */ new Set();
|
|
172
169
|
protocolErrorHandlers = /* @__PURE__ */ new Set();
|
|
@@ -178,7 +175,12 @@ var v = class {
|
|
|
178
175
|
create(e, t) {
|
|
179
176
|
this.iframe?.remove();
|
|
180
177
|
let n = document.createElement("iframe");
|
|
181
|
-
|
|
178
|
+
if (n.src = e, n.style.display = "block", n.setAttribute("sandbox", "allow-scripts allow-same-origin allow-forms"), !t?.container) n.style.width = "100%", n.style.height = "100%", n.style.border = "none", n.style.position = "fixed", n.style.top = "0", n.style.left = "0", n.style.right = "0", n.style.bottom = "0", n.style.zIndex = "9999";
|
|
179
|
+
else {
|
|
180
|
+
let e = v(t.width ?? 480, 440, 720), r = v(t.height ?? 720, 640, 960);
|
|
181
|
+
n.style.width = `${e}px`, n.style.height = `${r}px`, n.style.border = "1px solid #e5e7eb", n.style.borderRadius = "8px", n.style.boxSizing = "border-box";
|
|
182
|
+
}
|
|
183
|
+
return t?.style && Object.assign(n.style, t.style), (t?.container ?? document.body).appendChild(n), this.iframe = n, n;
|
|
182
184
|
}
|
|
183
185
|
destroy() {
|
|
184
186
|
this.destroyed = !0, this.messageListener &&= (window.removeEventListener("message", this.messageListener), null), this.messageHandlers.clear(), this.protocolErrorHandlers.clear(), this.iframe?.remove(), this.iframe = null;
|
|
@@ -215,10 +217,12 @@ var v = class {
|
|
|
215
217
|
});
|
|
216
218
|
}, window.addEventListener("message", this.messageListener));
|
|
217
219
|
}
|
|
218
|
-
},
|
|
220
|
+
}, b = {
|
|
219
221
|
code: "UNKNOWN",
|
|
220
222
|
message: "Unknown widget error"
|
|
221
|
-
},
|
|
223
|
+
}, x = class {
|
|
224
|
+
session;
|
|
225
|
+
webappBase;
|
|
222
226
|
manager = null;
|
|
223
227
|
destroyed = !1;
|
|
224
228
|
constructor(e, t) {
|
|
@@ -230,14 +234,18 @@ var v = class {
|
|
|
230
234
|
this.manager?.destroy();
|
|
231
235
|
let t = new URL(this.webappBase).origin, n = window.location.origin, r = new URL(`/embed/checkout/${encodeURIComponent(e.did)}`, this.webappBase);
|
|
232
236
|
r.searchParams.set("parentOrigin", n), e.planId && r.searchParams.set("planId", e.planId);
|
|
233
|
-
let i = new
|
|
234
|
-
this.manager = i, i.create(r.toString(), {
|
|
237
|
+
let i = new y(t);
|
|
238
|
+
this.manager = i, i.create(r.toString(), {
|
|
239
|
+
container: e.container,
|
|
240
|
+
width: e.width,
|
|
241
|
+
height: e.height
|
|
242
|
+
}), i.onMessage((t) => this.handleMessage(t, e));
|
|
235
243
|
}
|
|
236
244
|
destroy() {
|
|
237
245
|
this.destroyed = !0, this.manager?.destroy(), this.manager = null;
|
|
238
246
|
}
|
|
239
247
|
handleMessage(e, t) {
|
|
240
|
-
if (!
|
|
248
|
+
if (!w(e, t)) switch (e.type) {
|
|
241
249
|
case f.BOOTED:
|
|
242
250
|
this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() })), t.onBooted?.();
|
|
243
251
|
return;
|
|
@@ -255,7 +263,7 @@ var v = class {
|
|
|
255
263
|
}
|
|
256
264
|
case f.ERROR: {
|
|
257
265
|
let n = e.payload;
|
|
258
|
-
t.onError?.(n?.error ??
|
|
266
|
+
t.onError?.(n?.error ?? b);
|
|
259
267
|
return;
|
|
260
268
|
}
|
|
261
269
|
case f.CLOSE:
|
|
@@ -265,12 +273,12 @@ var v = class {
|
|
|
265
273
|
}
|
|
266
274
|
}
|
|
267
275
|
};
|
|
268
|
-
function
|
|
276
|
+
function S(e) {
|
|
269
277
|
if (typeof e != "object" || !e) return null;
|
|
270
278
|
let t = e.expectedEmail;
|
|
271
279
|
return typeof t != "string" || t.length === 0 ? null : { expectedEmail: t };
|
|
272
280
|
}
|
|
273
|
-
function
|
|
281
|
+
function C(e) {
|
|
274
282
|
if (typeof e != "object" || !e) return null;
|
|
275
283
|
let t = e.requestedEmail, n = e.expectedEmail;
|
|
276
284
|
return typeof t != "string" || t.length === 0 || typeof n != "string" || n.length === 0 ? null : {
|
|
@@ -278,43 +286,55 @@ function S(e) {
|
|
|
278
286
|
expectedEmail: n
|
|
279
287
|
};
|
|
280
288
|
}
|
|
281
|
-
function
|
|
289
|
+
function w(e, t) {
|
|
282
290
|
if (e.type === f.AUTH_MISMATCH) {
|
|
283
|
-
let n =
|
|
291
|
+
let n = S(e.payload);
|
|
284
292
|
return n && t.onAuthMismatch?.(n), !0;
|
|
285
293
|
}
|
|
286
294
|
if (e.type === f.AUTH_SWITCH_REQUEST) {
|
|
287
|
-
let n =
|
|
295
|
+
let n = C(e.payload);
|
|
288
296
|
return n && t.onAuthSwitchRequest?.(n), !0;
|
|
289
297
|
}
|
|
290
298
|
return !1;
|
|
291
299
|
}
|
|
292
300
|
//#endregion
|
|
293
301
|
//#region src/widgets/delegations.ts
|
|
294
|
-
var
|
|
302
|
+
var T = {
|
|
295
303
|
code: "UNKNOWN",
|
|
296
304
|
message: "Unknown widget error"
|
|
297
|
-
},
|
|
305
|
+
}, E = {
|
|
298
306
|
code: "UNKNOWN",
|
|
299
307
|
message: "Malformed nvm:success payload — paymentMethodId missing or invalid"
|
|
300
|
-
},
|
|
308
|
+
}, D = {
|
|
301
309
|
code: "UNKNOWN",
|
|
302
310
|
message: "Malformed nvm:success payload — delegationId missing or invalid"
|
|
303
|
-
},
|
|
311
|
+
}, O = class {
|
|
312
|
+
session;
|
|
313
|
+
webappBase;
|
|
314
|
+
apiBase;
|
|
304
315
|
manager = null;
|
|
305
316
|
destroyed = !1;
|
|
306
317
|
constructor(e, t, n) {
|
|
307
318
|
this.session = e, this.webappBase = t, this.apiBase = n;
|
|
308
319
|
}
|
|
309
320
|
enrollCard(e) {
|
|
310
|
-
this.assertAlive("enrollCard"), this.mountIframe("/embed/cards/enroll", e.container
|
|
321
|
+
this.assertAlive("enrollCard"), this.mountIframe("/embed/cards/enroll", e.container, void 0, {
|
|
322
|
+
width: e.width,
|
|
323
|
+
height: e.height
|
|
324
|
+
}).onMessage((t) => this.handleEnrollMessage(t, e));
|
|
311
325
|
}
|
|
312
326
|
listCards(e) {
|
|
313
|
-
this.assertAlive("listCards"), this.mountIframe("/embed/cards/list", e.container
|
|
327
|
+
this.assertAlive("listCards"), this.mountIframe("/embed/cards/list", e.container, void 0, {
|
|
328
|
+
width: e.width,
|
|
329
|
+
height: e.height
|
|
330
|
+
}).onMessage((t) => this.handleListMessage(t, e));
|
|
314
331
|
}
|
|
315
332
|
createDelegation(e) {
|
|
316
333
|
if (this.assertAlive("createDelegation"), typeof e.paymentMethodId != "string" || e.paymentMethodId.length === 0) throw Error("[DelegationsWidget] createDelegation: paymentMethodId is required");
|
|
317
|
-
this.mountIframe("/embed/cards/delegate", e.container, { paymentMethodId: e.paymentMethodId }
|
|
334
|
+
this.mountIframe("/embed/cards/delegate", e.container, { paymentMethodId: e.paymentMethodId }, {
|
|
335
|
+
width: e.width,
|
|
336
|
+
height: e.height
|
|
337
|
+
}).onMessage((t) => this.handleCreateDelegationMessage(t, e));
|
|
318
338
|
}
|
|
319
339
|
async revokeCard(e) {
|
|
320
340
|
if (typeof e != "string" || e.length === 0) throw Error("[DelegationsWidget] revokeCard: paymentMethodId is required");
|
|
@@ -330,19 +350,23 @@ var w = {
|
|
|
330
350
|
assertAlive(e) {
|
|
331
351
|
if (this.destroyed) throw Error(`[DelegationsWidget] cannot ${e}: instance has been destroyed`);
|
|
332
352
|
}
|
|
333
|
-
mountIframe(e, t, n = {}) {
|
|
353
|
+
mountIframe(e, t, n = {}, r = {}) {
|
|
334
354
|
this.manager?.destroy();
|
|
335
|
-
let
|
|
336
|
-
|
|
337
|
-
for (let [e, t] of Object.entries(n))
|
|
338
|
-
let
|
|
339
|
-
return this.manager =
|
|
355
|
+
let i = new URL(this.webappBase).origin, a = window.location.origin, o = new URL(e, this.webappBase);
|
|
356
|
+
o.searchParams.set("parentOrigin", a);
|
|
357
|
+
for (let [e, t] of Object.entries(n)) o.searchParams.set(e, t);
|
|
358
|
+
let s = new y(i);
|
|
359
|
+
return this.manager = s, s.create(o.toString(), {
|
|
360
|
+
container: t,
|
|
361
|
+
width: r.width,
|
|
362
|
+
height: r.height
|
|
363
|
+
}), s;
|
|
340
364
|
}
|
|
341
365
|
postInitOnBooted() {
|
|
342
366
|
this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() }));
|
|
343
367
|
}
|
|
344
368
|
handleEnrollMessage(e, t) {
|
|
345
|
-
if (!
|
|
369
|
+
if (!w(e, t)) switch (e.type) {
|
|
346
370
|
case f.BOOTED:
|
|
347
371
|
this.postInitOnBooted(), t.onBooted?.();
|
|
348
372
|
return;
|
|
@@ -352,7 +376,7 @@ var w = {
|
|
|
352
376
|
case f.SUCCESS: {
|
|
353
377
|
let n = (e.payload ?? {}).paymentMethodId;
|
|
354
378
|
if (typeof n != "string" || n.length === 0) {
|
|
355
|
-
t.onError?.(
|
|
379
|
+
t.onError?.(E);
|
|
356
380
|
return;
|
|
357
381
|
}
|
|
358
382
|
t.onSuccess?.({ paymentMethodId: n });
|
|
@@ -360,7 +384,7 @@ var w = {
|
|
|
360
384
|
}
|
|
361
385
|
case f.ERROR: {
|
|
362
386
|
let n = e.payload;
|
|
363
|
-
t.onError?.(n?.error ??
|
|
387
|
+
t.onError?.(n?.error ?? T);
|
|
364
388
|
return;
|
|
365
389
|
}
|
|
366
390
|
case f.CLOSE:
|
|
@@ -370,7 +394,7 @@ var w = {
|
|
|
370
394
|
}
|
|
371
395
|
}
|
|
372
396
|
handleListMessage(e, t) {
|
|
373
|
-
if (!
|
|
397
|
+
if (!w(e, t)) switch (e.type) {
|
|
374
398
|
case f.BOOTED:
|
|
375
399
|
this.postInitOnBooted(), t.onBooted?.();
|
|
376
400
|
return;
|
|
@@ -388,7 +412,7 @@ var w = {
|
|
|
388
412
|
}
|
|
389
413
|
case f.ERROR: {
|
|
390
414
|
let n = e.payload;
|
|
391
|
-
t.onError?.(n?.error ??
|
|
415
|
+
t.onError?.(n?.error ?? T);
|
|
392
416
|
return;
|
|
393
417
|
}
|
|
394
418
|
case f.CLOSE:
|
|
@@ -398,7 +422,7 @@ var w = {
|
|
|
398
422
|
}
|
|
399
423
|
}
|
|
400
424
|
handleCreateDelegationMessage(e, t) {
|
|
401
|
-
if (!
|
|
425
|
+
if (!w(e, t)) switch (e.type) {
|
|
402
426
|
case f.BOOTED:
|
|
403
427
|
this.postInitOnBooted(), t.onBooted?.();
|
|
404
428
|
return;
|
|
@@ -408,7 +432,7 @@ var w = {
|
|
|
408
432
|
case f.SUCCESS: {
|
|
409
433
|
let n = (e.payload ?? {}).delegationId;
|
|
410
434
|
if (typeof n != "string" || n.length === 0) {
|
|
411
|
-
t.onError?.(
|
|
435
|
+
t.onError?.(D);
|
|
412
436
|
return;
|
|
413
437
|
}
|
|
414
438
|
t.onSuccess?.({
|
|
@@ -419,7 +443,7 @@ var w = {
|
|
|
419
443
|
}
|
|
420
444
|
case f.ERROR: {
|
|
421
445
|
let n = e.payload;
|
|
422
|
-
t.onError?.(n?.error ??
|
|
446
|
+
t.onError?.(n?.error ?? T);
|
|
423
447
|
return;
|
|
424
448
|
}
|
|
425
449
|
case f.CLOSE:
|
|
@@ -452,7 +476,7 @@ var w = {
|
|
|
452
476
|
};
|
|
453
477
|
//#endregion
|
|
454
478
|
//#region src/nevermined-widgets.ts
|
|
455
|
-
function
|
|
479
|
+
function k(e) {
|
|
456
480
|
if (typeof e != "object" || !e) return !1;
|
|
457
481
|
let t = e;
|
|
458
482
|
return [
|
|
@@ -462,7 +486,10 @@ function O(e) {
|
|
|
462
486
|
"apiKeyHash"
|
|
463
487
|
].every((e) => typeof t[e] == "string") && typeof t.userWallet == "string" && t.userWallet.startsWith("0x");
|
|
464
488
|
}
|
|
465
|
-
var
|
|
489
|
+
var A = class t {
|
|
490
|
+
sessionManager;
|
|
491
|
+
_account;
|
|
492
|
+
environment;
|
|
466
493
|
_checkout = null;
|
|
467
494
|
_delegations = null;
|
|
468
495
|
events = new d();
|
|
@@ -470,32 +497,15 @@ var k = class t {
|
|
|
470
497
|
this.sessionManager = e, this._account = t, this.environment = n;
|
|
471
498
|
}
|
|
472
499
|
static async initialize(n) {
|
|
473
|
-
let {
|
|
474
|
-
if (!
|
|
475
|
-
if (!
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
});
|
|
483
|
-
} catch (e) {
|
|
484
|
-
throw console.error("[NeverminedWidgets] fetch failed:", e), new o("NETWORK_ERROR", void 0, e);
|
|
485
|
-
}
|
|
486
|
-
if (!c.ok) throw c.status === 401 ? new o("INVALID_INIT_TOKEN") : new o("NETWORK_ERROR", `Request failed with status ${c.status}`);
|
|
487
|
-
let l;
|
|
488
|
-
try {
|
|
489
|
-
l = await c.json();
|
|
490
|
-
} catch (e) {
|
|
491
|
-
throw new o("INVALID_RESPONSE", void 0, e);
|
|
492
|
-
}
|
|
493
|
-
if (!O(l)) throw new o("INVALID_RESPONSE");
|
|
494
|
-
let d = new u(l), f = new t(d, {
|
|
495
|
-
userId: l.userId,
|
|
496
|
-
userWallet: l.userWallet
|
|
497
|
-
}, a);
|
|
498
|
-
return d.startAutoRefresh(() => f.refreshSession(), () => f.events.emit("session-expired", void 0)), f;
|
|
500
|
+
let { session: r, environment: i } = n;
|
|
501
|
+
if (!r || typeof r != "object") throw new o("MISSING_SESSION");
|
|
502
|
+
if (!i || !e.includes(i)) throw new o("INVALID_ENVIRONMENT");
|
|
503
|
+
if (!k(r)) throw new o("INVALID_SESSION");
|
|
504
|
+
let a = new u(r), s = new t(a, {
|
|
505
|
+
userId: r.userId,
|
|
506
|
+
userWallet: r.userWallet
|
|
507
|
+
}, i);
|
|
508
|
+
return a.startAutoRefresh(() => s.refreshSession(), () => s.events.emit("session-expired", void 0)), s;
|
|
499
509
|
}
|
|
500
510
|
async refreshSession() {
|
|
501
511
|
let e = await fetch(`${r(this.environment)}/api/v1/widgets/session/refresh`, {
|
|
@@ -504,7 +514,7 @@ var k = class t {
|
|
|
504
514
|
});
|
|
505
515
|
if (!e.ok) throw Error(`Session refresh failed with status ${e.status}`);
|
|
506
516
|
let t = await e.json();
|
|
507
|
-
if (!
|
|
517
|
+
if (!k(t)) throw Error("Session refresh returned an invalid response");
|
|
508
518
|
return t;
|
|
509
519
|
}
|
|
510
520
|
on(e, t) {
|
|
@@ -524,14 +534,14 @@ var k = class t {
|
|
|
524
534
|
return this.sessionManager.getToken();
|
|
525
535
|
}
|
|
526
536
|
get checkout() {
|
|
527
|
-
return this._checkout ||= new
|
|
537
|
+
return this._checkout ||= new x(this.sessionManager, i(this.environment)), this._checkout;
|
|
528
538
|
}
|
|
529
539
|
get delegations() {
|
|
530
|
-
return this._delegations ||= new
|
|
540
|
+
return this._delegations ||= new O(this.sessionManager, i(this.environment), r(this.environment)), this._delegations;
|
|
531
541
|
}
|
|
532
542
|
destroy() {
|
|
533
543
|
this.sessionManager.stopAutoRefresh(), this._checkout?.destroy(), this._checkout = null, this._delegations?.destroy(), this._delegations = null, this.events.removeAllListeners();
|
|
534
544
|
}
|
|
535
545
|
};
|
|
536
546
|
//#endregion
|
|
537
|
-
export {
|
|
547
|
+
export { x as CheckoutWidget, O as DelegationsWidget, y as IframeManager, A as NeverminedWidgets, u as SessionManager, d as TypedEventEmitter, p as WIDGET_MESSAGE_VERSION, c as WidgetApiError, o as WidgetInitError, f as WidgetMessageType, s as WidgetSessionExpiredError, g as createMessage, _ as parseMessage };
|
package/dist/messages.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAE3B,IAAI,aAAa;IACjB,KAAK,cAAc;IAEnB,MAAM,eAAe;IACrB,KAAK,cAAc;IACnB,MAAM,eAAe;IACrB,OAAO,gBAAgB;IACvB,KAAK,cAAc;IAInB,WAAW,oBAAoB;IAI/B,aAAa,sBAAsB;
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../src/messages.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB;IAE3B,IAAI,aAAa;IACjB,KAAK,cAAc;IAEnB,MAAM,eAAe;IACrB,KAAK,cAAc;IACnB,MAAM,eAAe;IACrB,OAAO,gBAAgB;IACvB,KAAK,cAAc;IAInB,WAAW,oBAAoB;IAI/B,aAAa,sBAAsB;IAKnC,mBAAmB,4BAA4B;CAChD;AAED,MAAM,WAAW,aAAa,CAAC,CAAC,GAAG,OAAO;IACxC,IAAI,EAAE,iBAAiB,CAAA;IACvB,OAAO,EAAE,GAAG,CAAA;IACZ,OAAO,CAAC,EAAE,CAAC,CAAA;CACZ;AAED,eAAO,MAAM,sBAAsB,EAAG,GAAY,CAAA;AAWlD,wBAAgB,aAAa,CAAC,CAAC,EAAE,IAAI,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAMvF;AAED,MAAM,MAAM,WAAW,CAAC,CAAC,GAAG,OAAO,IAC/B;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,aAAa,CAAC,CAAC,CAAC,CAAA;CAAE,GACvC;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAEjC,wBAAgB,YAAY,CAAC,IAAI,EAAE,OAAO,GAAG,WAAW,CA8BvD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nevermined-widgets.d.ts","sourceRoot":"","sources":["../src/nevermined-widgets.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAA8B,MAAM,YAAY,CAAA;AAMzF,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAE5D,UAAU,uBAA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BAAuB,EACzC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,GACrD,IAAI;IAKP,IAAI,OAAO,IAAI,aAAa,CAE3B;IAED,IAAI,eAAe,IAAI,OAAO,CAE7B;IAED,eAAe,IAAI,MAAM;IAKzB,IAAI,QAAQ,IAAI,cAAc,CAK7B;IAED,IAAI,WAAW,IAAI,iBAAiB,CASnC;IAED;;;;;;;;OAQG;IACH,OAAO,IAAI,IAAI;CAQhB"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
export declare const ENVIRONMENTS: readonly ["local", "sandbox", "live", "staging_sandbox", "staging_live"];
|
|
2
2
|
export type Environment = (typeof ENVIRONMENTS)[number];
|
|
3
3
|
export interface WidgetConfig {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Widget session minted server-to-server by the integrator backend
|
|
6
|
+
* (typically via `@nevermined-io/ui-widgets-server.createWidgetSession`).
|
|
7
|
+
* Forward the response object verbatim — the SDK never holds the widget
|
|
8
|
+
* key `rawSecret`.
|
|
9
|
+
*/
|
|
10
|
+
session: WidgetSession;
|
|
5
11
|
environment: Environment;
|
|
6
12
|
}
|
|
7
13
|
export interface WidgetSession {
|
|
@@ -31,34 +37,34 @@ export interface EmbedError {
|
|
|
31
37
|
/**
|
|
32
38
|
* Emitted (via the per-widget `onAuthMismatch` callback) when the iframe
|
|
33
39
|
* detects a live host Privy session whose email does not match the email
|
|
34
|
-
*
|
|
35
|
-
* (continue as the host identity, or switch to the
|
|
36
|
-
* signing out of Privy inside the iframe) and the host page is informed
|
|
37
|
-
* it can mirror that affordance on its own UI. The widget is effectively
|
|
38
|
-
* halted until either button is clicked or the host re-
|
|
39
|
-
*
|
|
40
|
+
* the widget session was minted for. The iframe renders a two-button prompt
|
|
41
|
+
* (continue as the host identity, or switch to the widget-session identity
|
|
42
|
+
* by signing out of Privy inside the iframe) and the host page is informed
|
|
43
|
+
* so it can mirror that affordance on its own UI. The widget is effectively
|
|
44
|
+
* halted until either button is clicked or the host re-mints a widget
|
|
45
|
+
* session via the action below.
|
|
40
46
|
*/
|
|
41
47
|
export interface AuthMismatchDetail {
|
|
42
|
-
/** Email
|
|
48
|
+
/** Email the widget session was minted for (normalized — trimmed, lower-cased). */
|
|
43
49
|
expectedEmail: string;
|
|
44
50
|
}
|
|
45
51
|
/**
|
|
46
52
|
* Emitted (via the per-widget `onAuthSwitchRequest` callback) when the user
|
|
47
53
|
* picks "Continue as <hostEmail>" on the mismatch prompt. The host page is
|
|
48
|
-
* expected to re-
|
|
54
|
+
* expected to re-mint a widget session bound to `requestedEmail` and reopen
|
|
49
55
|
* the widget; the iframe stays on the prompt until that happens.
|
|
50
56
|
*
|
|
51
57
|
* **Security note for integrators:** the SDK posts this event to the host
|
|
52
58
|
* via `window.postMessage`, but the host's `window.addEventListener('message',
|
|
53
59
|
* ...)` listens to ALL frames on the page. Validate `event.origin === <your
|
|
54
|
-
* widget host>` (e.g. `https://app.nevermined.io`) before re-
|
|
55
|
-
* — otherwise a malicious sub-frame could spoof this event and
|
|
56
|
-
* backend into minting a
|
|
60
|
+
* widget host>` (e.g. `https://app.nevermined.io`) before re-minting a
|
|
61
|
+
* session — otherwise a malicious sub-frame could spoof this event and
|
|
62
|
+
* trick your backend into minting a session for an attacker-supplied email.
|
|
57
63
|
*/
|
|
58
64
|
export interface AuthSwitchRequestDetail {
|
|
59
65
|
/** Email the user wants the widget to operate under (their live Privy identity). */
|
|
60
66
|
requestedEmail: string;
|
|
61
|
-
/** Email
|
|
67
|
+
/** Email the original widget session was minted for, for reference / telemetry. */
|
|
62
68
|
expectedEmail: string;
|
|
63
69
|
}
|
|
64
70
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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-1,23 +1,15 @@
|
|
|
1
1
|
export declare const WIDGET_ERRORS: {
|
|
2
|
-
readonly
|
|
2
|
+
readonly MISSING_SESSION: {
|
|
3
3
|
readonly numericCode: "WDG.0001";
|
|
4
|
-
readonly message: "
|
|
4
|
+
readonly message: "session is required — pass the WidgetSession returned by createWidgetSession on the backend";
|
|
5
5
|
};
|
|
6
6
|
readonly INVALID_ENVIRONMENT: {
|
|
7
7
|
readonly numericCode: "WDG.0002";
|
|
8
8
|
readonly message: "environment must be one of: sandbox, live, staging_sandbox, staging_live, local";
|
|
9
9
|
};
|
|
10
|
-
readonly
|
|
10
|
+
readonly INVALID_SESSION: {
|
|
11
11
|
readonly numericCode: "WDG.0003";
|
|
12
|
-
readonly message: "
|
|
13
|
-
};
|
|
14
|
-
readonly INVALID_RESPONSE: {
|
|
15
|
-
readonly numericCode: "WDG.0004";
|
|
16
|
-
readonly message: "Server response is missing required fields";
|
|
17
|
-
};
|
|
18
|
-
readonly NETWORK_ERROR: {
|
|
19
|
-
readonly numericCode: "WDG.0005";
|
|
20
|
-
readonly message: "Network request failed";
|
|
12
|
+
readonly message: "session is missing required fields";
|
|
21
13
|
};
|
|
22
14
|
readonly SESSION_EXPIRED: {
|
|
23
15
|
readonly numericCode: "WDG.0006";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/utils/errors.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;CAemD,CAAA;AAE7E,MAAM,MAAM,eAAe,GAAG,MAAM,OAAO,aAAa,CAAA;AAExD,qBAAa,eAAgB,SAAQ,KAAK;aAEtB,IAAI,EAAE,eAAe;gBAArB,IAAI,EAAE,eAAe,EACrC,OAAO,CAAC,EAAE,MAAM,EAChB,KAAK,CAAC,EAAE,OAAO;CAKlB;AAED,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,QAAQ,CAAC,IAAI,EAAG,iBAAiB,CAAS;;CAM3C;AAED;;;;;GAKG;AACH,qBAAa,cAAe,SAAQ,KAAK;aAGrB,MAAM,CAAC,EAAE,MAAM;aACf,OAAO,CAAC,EAAE,MAAM;gBAFhC,OAAO,EAAE,MAAM,EACC,MAAM,CAAC,EAAE,MAAM,YAAA,EACf,OAAO,CAAC,EAAE,MAAM,YAAA;CAKnC"}
|
|
@@ -10,20 +10,32 @@ export interface CheckoutOptions {
|
|
|
10
10
|
did: string;
|
|
11
11
|
planId?: string;
|
|
12
12
|
container?: HTMLElement;
|
|
13
|
+
/**
|
|
14
|
+
* Fixed iframe width in pixels. Clamped by the SDK to a supported range
|
|
15
|
+
* (see `INLINE_MIN_WIDTH` / `INLINE_MAX_WIDTH` / `INLINE_DEFAULT_WIDTH`
|
|
16
|
+
* in `iframe-manager`). Ignored in fullscreen overlay mode (no container).
|
|
17
|
+
*/
|
|
18
|
+
width?: number;
|
|
19
|
+
/**
|
|
20
|
+
* Fixed iframe height in pixels. Clamped by the SDK to a supported range
|
|
21
|
+
* (see `INLINE_MIN_HEIGHT` / `INLINE_MAX_HEIGHT` / `INLINE_DEFAULT_HEIGHT`
|
|
22
|
+
* in `iframe-manager`). Ignored in fullscreen overlay mode.
|
|
23
|
+
*/
|
|
24
|
+
height?: number;
|
|
13
25
|
onBooted?: () => void;
|
|
14
26
|
onReady?: () => void;
|
|
15
27
|
onSuccess?: (result: CheckoutResult) => void;
|
|
16
28
|
onError?: (error: EmbedError) => void;
|
|
17
29
|
/**
|
|
18
30
|
* Fires when the iframe detects that the live host Privy session belongs
|
|
19
|
-
* to a different account than the email
|
|
31
|
+
* to a different account than the email the widget session was minted for.
|
|
20
32
|
* The iframe stays mounted on a two-button prompt; the host can mirror that
|
|
21
33
|
* affordance on its own UI. See `AuthMismatchDetail`.
|
|
22
34
|
*/
|
|
23
35
|
onAuthMismatch?: (detail: AuthMismatchDetail) => void;
|
|
24
36
|
/**
|
|
25
37
|
* Fires when, on the mismatch prompt, the user picks "Continue as
|
|
26
|
-
* <hostEmail>". The host should re-
|
|
38
|
+
* <hostEmail>". The host should re-mint a widget session bound to
|
|
27
39
|
* `requestedEmail` and reopen the widget. The iframe stays on the prompt
|
|
28
40
|
* until then. See `AuthSwitchRequestDetail`.
|
|
29
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../src/widgets/checkout.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAC9C,OAAO,EAAoC,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACrF,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAE1F,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,MAAM,WAAW,eAAe;IAC9B,GAAG,EAAE,MAAM,CAAA;IACX,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAA;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IACrD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC/D,OAAO,CAAC,EAAE,MAAM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AI,CAAA;IACrD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAID;;;;;;;;GAQG;AACH,qBAAa,cAAc;IAKvB,OAAO,CAAC,QAAQ,CAAC,OAAO;IACxB,OAAO,CAAC,QAAQ,CAAC,UAAU;IAL7B,OAAO,CAAC,OAAO,CAA6B;IAC5C,OAAO,CAAC,SAAS,CAAQ;gBAGN,OAAO,EAAE,cAAc,EACvB,UAAU,EAAE,MAAM;IAGrC;;;;OAIG;IACH,KAAK,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;IA4BrC,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,aAAa;CAwCtB;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,GAAG,IAAI,CAK7E;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,OAAO,GAAG,uBAAuB,GAAG,IAAI,CAOvF;AAED,MAAM,WAAW,mBAAmB;IAClC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IACrD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;CAChE;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAY3F"}
|
|
@@ -5,6 +5,10 @@ export interface EnrollCardResult {
|
|
|
5
5
|
}
|
|
6
6
|
export interface EnrollCardOptions {
|
|
7
7
|
container?: HTMLElement;
|
|
8
|
+
/** See `CheckoutOptions.width`. */
|
|
9
|
+
width?: number;
|
|
10
|
+
/** See `CheckoutOptions.height`. */
|
|
11
|
+
height?: number;
|
|
8
12
|
onBooted?: () => void;
|
|
9
13
|
onReady?: () => void;
|
|
10
14
|
onSuccess?: (result: EnrollCardResult) => void;
|
|
@@ -22,6 +26,10 @@ export interface CardAction {
|
|
|
22
26
|
}
|
|
23
27
|
export interface ListCardsOptions {
|
|
24
28
|
container?: HTMLElement;
|
|
29
|
+
/** See `CheckoutOptions.width`. */
|
|
30
|
+
width?: number;
|
|
31
|
+
/** See `CheckoutOptions.height`. */
|
|
32
|
+
height?: number;
|
|
25
33
|
onBooted?: () => void;
|
|
26
34
|
onReady?: () => void;
|
|
27
35
|
onCardAction?: (action: CardAction) => void;
|
|
@@ -39,6 +47,10 @@ export interface CreateDelegationResult {
|
|
|
39
47
|
export interface CreateDelegationOptions {
|
|
40
48
|
paymentMethodId: string;
|
|
41
49
|
container?: HTMLElement;
|
|
50
|
+
/** See `CheckoutOptions.width`. */
|
|
51
|
+
width?: number;
|
|
52
|
+
/** See `CheckoutOptions.height`. */
|
|
53
|
+
height?: number;
|
|
42
54
|
onBooted?: () => void;
|
|
43
55
|
onReady?: () => void;
|
|
44
56
|
onSuccess?: (result: CreateDelegationResult) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"delegations.d.ts","sourceRoot":"","sources":["../../src/widgets/delegations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AAE9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAI1F,MAAM,WAAW,gBAAgB;IAC/B,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,WAAW,CAAA;IACvB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,KAAK,IAAI,CAAA;IAC9C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAA;IACrC,4CAA4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C,iBAAiB;IA+CzB,OAAO,CAAC,6BAA6B;YA2CvB,iBAAiB;CAgChC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nevermined-io/ui-widgets",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.8",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"!**/*.tsbuildinfo"
|
|
19
19
|
],
|
|
20
20
|
"devDependencies": {
|
|
21
|
-
"vite": "^8.0.
|
|
21
|
+
"vite": "^8.0.13",
|
|
22
22
|
"vite-plugin-dts": "^4.5.4"
|
|
23
23
|
}
|
|
24
24
|
}
|