@nevermined-io/ui-widgets 0.5.7 → 0.5.9

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
@@ -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 the short-lived init tokens this SDK exchanges for an authenticated widget session.
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 an init token from your backend (see ui-widgets-server)
23
- const { initToken } = await fetch('/api/widget-init-token').then(r => r.json())
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
- initToken,
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 | Webapp URL |
47
- | ----------------- | --------------------------------------- | --------------------------- |
48
- | `live` | `https://api.live.nevermined.app` | `https://nevermined.app` |
49
- | `sandbox` | `https://api.sandbox.nevermined.app` | `https://nevermined.app` |
50
- | `staging_live` | `https://api.live.nevermined.dev` | `https://nevermined.dev` |
51
- | `staging_sandbox` | `https://api.sandbox.nevermined.dev` | `https://nevermined.dev` |
52
- | `local` | `http://localhost:3001` | `http://localhost:4200` |
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
- Exchanges the init token for a widget session. Returns a `NeverminedWidgets` instance you keep around for the lifetime of the page (or until logout).
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
- initToken: '...', // from your backend
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 new init token from your backend and re-initialize.
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 init token is rejected, the response is malformed, or the network call fails.
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({ initToken, environment: 'live' })
148
+ await NeverminedWidgets.initialize({ session, environment: 'live' })
147
149
  } catch (err) {
148
150
  if (err instanceof WidgetInitError) {
149
- // err.code: MISSING_INIT_TOKEN | INVALID_INIT_TOKEN | INVALID_ENVIRONMENT
150
- // | INVALID_RESPONSE | NETWORK_ERROR
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 // HTTP status when applicable
172
- apiCode?: string // BCK.* error code when the iframe surfaces one
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 { WidgetMessageType, parseMessage, createMessage, WIDGET_MESSAGE_VERSION } from '@nevermined-io/ui-widgets'
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 | When |
187
- | ----------------- | ------------------ | --------------------------------------------------------- |
188
- | `nvm:booted` | iframe → parent | DOM mounted, before the iframe knows the session token |
189
- | `nvm:init` | parent → iframe | SDK responds to `booted` with the session token |
190
- | `nvm:ready` | iframe → parent | Auth validated, iframe rendered |
191
- | `nvm:resize` | iframe → parent | Iframe content height changed |
192
- | `nvm:success` | iframe → parent | Terminal success (purchase complete, card enrolled, etc.) |
193
- | `nvm:error` | iframe → parent | Error (terminal or recoverable; check `EmbedError.code`) |
194
- | `nvm:card-action` | iframe → parent | Per-row action inside `listCards` (e.g. delegate) |
195
- | `nvm:close` | iframe ↔ parent | Iframe is being dismissed |
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
 
@@ -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;CACrC;AAED,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;IA6B/D,OAAO,IAAI,IAAI;IAYf,WAAW,CAAC,GAAG,EA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AO,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.d.ts CHANGED
@@ -6,9 +6,9 @@ export { DelegationsWidget } from './widgets/delegations.js';
6
6
  export { TypedEventEmitter } from './event-emitter.js';
7
7
  export { WidgetMessageType, WIDGET_MESSAGE_VERSION, createMessage, parseMessage, } from './messages.js';
8
8
  export { WidgetApiError, WidgetInitError, WidgetSessionExpiredError } from './utils/errors.js';
9
- export type { WidgetConfig, WidgetSession, WidgetAccount, Environment, EmbedError, AuthMismatchDetail, AuthSwitchRequestDetail, } from './types.js';
9
+ export type { WidgetConfig, WidgetSession, WidgetAccount, Environment, EmbedError, AuthMismatchDetail, AuthSwitchRequestDetail, WidgetSuccessHandle, WidgetSuccessEvent, } from './types.js';
10
10
  export type { IframeOptions } from './iframe-manager.js';
11
11
  export type { CheckoutOptions, CheckoutResult } from './widgets/checkout.js';
12
- export type { CardAction, CreateDelegationOptions, CreateDelegationResult, EnrollCardOptions, EnrollCardResult, ListCardsOptions, } from './widgets/delegations.js';
12
+ export type { CardAction, CreateDelegationOptions, CreateDelegationResult, EnrollCardOptions, EnrollCardProvider, EnrollCardResult, ListCardsOptions, } from './widgets/delegations.js';
13
13
  export type { WidgetMessage, ParseResult } from './messages.js';
14
14
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAA;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;A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YAAY,EACV,YAAY,EACZ,aAAa,EACb,aAAa,EACb,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,YAAY,CAAA;AACnB,YAAY,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAC5E,YAAY,EACV,UAAU,EACV,uBAAuB,EACvB,sBAAsB,EACtB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,0BAA0B,CAAA;AACjC,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA"}
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,i))}destroy(){this.destroyed=!0,this.manager?.destroy(),this.manager=null}closeFromIframe(e,t){this.destroyed||this.manager!==t||(this.destroy(),e.onClose?.())}buildSuccessHandle(e,t){return{close:()=>this.closeFromIframe(e,t)}}handleMessage(e,t,n){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 r=e.payload??{},i={did:r.did??t.did,planId:r.planId??t.planId,txHash:r.txHash};t.onSuccess?.({result:i,handle:this.buildSuccessHandle(t,n)});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??x);return}case p.CLOSE:this.closeFromIframe(t,n);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`);let t=e.provider??`stripe`,n=this.mountIframe(`/embed/cards/enroll`,e.container,{provider:t},{width:e.width,height:e.height});n.onMessage(t=>this.handleEnrollMessage(t,e,n))}listCards(e){this.assertAlive(`listCards`);let t=this.mountIframe(`/embed/cards/list`,e.container,void 0,{width:e.width,height:e.height});t.onMessage(n=>this.handleListMessage(n,e,t))}createDelegation(e){if(this.assertAlive(`createDelegation`),typeof e.paymentMethodId!=`string`||e.paymentMethodId.length===0)throw Error(`[DelegationsWidget] createDelegation: paymentMethodId is required`);let t=this.mountIframe(`/embed/cards/delegate`,e.container,{paymentMethodId:e.paymentMethodId},{width:e.width,height:e.height});t.onMessage(n=>this.handleCreateDelegationMessage(n,e,t))}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,n){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 r=(e.payload??{}).paymentMethodId;if(typeof r!=`string`||r.length===0){t.onError?.(D);return}t.onSuccess?.({result:{paymentMethodId:r},handle:this.buildSuccessHandle(t,n)});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??E);return}case p.CLOSE:this.closeFromIframe(t,n);return;default:return}}handleListMessage(e,t,n){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`&&n.action!==`revoked`||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:this.closeFromIframe(t,n);return;default:return}}handleCreateDelegationMessage(e,t,n){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 r=(e.payload??{}).delegationId;if(typeof r!=`string`||r.length===0){t.onError?.(O);return}t.onSuccess?.({result:{delegationId:r,paymentMethodId:t.paymentMethodId},handle:this.buildSuccessHandle(t,n)});return}case p.ERROR:{let n=e.payload;t.onError?.(n?.error??E);return}case p.CLOSE:this.closeFromIframe(t,n);return;default:return}}closeFromIframe(e,t){this.destroyed||this.manager!==t||(this.destroy(),e.onClose?.())}buildSuccessHandle(e,t){return{close:()=>this.closeFromIframe(e,t)}}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
- MISSING_INIT_TOKEN: {
30
+ MISSING_SESSION: {
31
31
  numericCode: "WDG.0001",
32
- message: "initToken is required and must be a non-empty string"
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
- INVALID_INIT_TOKEN: {
38
+ INVALID_SESSION: {
39
39
  numericCode: "WDG.0003",
40
- message: "Init token is invalid or expired"
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
- //#endregion
168
- //#region src/iframe-manager.ts
169
- var v = class {
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
- 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;
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
- }, y = {
220
+ }, b = {
219
221
  code: "UNKNOWN",
220
222
  message: "Unknown widget error"
221
- }, b = class {
223
+ }, x = class {
224
+ session;
225
+ webappBase;
222
226
  manager = null;
223
227
  destroyed = !1;
224
228
  constructor(e, t) {
@@ -230,14 +234,24 @@ 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 v(t);
234
- this.manager = i, i.create(r.toString(), { container: e.container }), i.onMessage((t) => this.handleMessage(t, e));
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, i));
235
243
  }
236
244
  destroy() {
237
245
  this.destroyed = !0, this.manager?.destroy(), this.manager = null;
238
246
  }
239
- handleMessage(e, t) {
240
- if (!C(e, t)) switch (e.type) {
247
+ closeFromIframe(e, t) {
248
+ this.destroyed || this.manager !== t || (this.destroy(), e.onClose?.());
249
+ }
250
+ buildSuccessHandle(e, t) {
251
+ return { close: () => this.closeFromIframe(e, t) };
252
+ }
253
+ handleMessage(e, t, n) {
254
+ if (!w(e, t)) switch (e.type) {
241
255
  case f.BOOTED:
242
256
  this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() })), t.onBooted?.();
243
257
  return;
@@ -245,32 +259,35 @@ var v = class {
245
259
  t.onReady?.();
246
260
  return;
247
261
  case f.SUCCESS: {
248
- let n = e.payload ?? {};
262
+ let r = e.payload ?? {}, i = {
263
+ did: r.did ?? t.did,
264
+ planId: r.planId ?? t.planId,
265
+ txHash: r.txHash
266
+ };
249
267
  t.onSuccess?.({
250
- did: n.did ?? t.did,
251
- planId: n.planId ?? t.planId,
252
- txHash: n.txHash
268
+ result: i,
269
+ handle: this.buildSuccessHandle(t, n)
253
270
  });
254
271
  return;
255
272
  }
256
273
  case f.ERROR: {
257
274
  let n = e.payload;
258
- t.onError?.(n?.error ?? y);
275
+ t.onError?.(n?.error ?? b);
259
276
  return;
260
277
  }
261
278
  case f.CLOSE:
262
- t.onClose?.(), this.destroy();
279
+ this.closeFromIframe(t, n);
263
280
  return;
264
281
  default: return;
265
282
  }
266
283
  }
267
284
  };
268
- function x(e) {
285
+ function S(e) {
269
286
  if (typeof e != "object" || !e) return null;
270
287
  let t = e.expectedEmail;
271
288
  return typeof t != "string" || t.length === 0 ? null : { expectedEmail: t };
272
289
  }
273
- function S(e) {
290
+ function C(e) {
274
291
  if (typeof e != "object" || !e) return null;
275
292
  let t = e.requestedEmail, n = e.expectedEmail;
276
293
  return typeof t != "string" || t.length === 0 || typeof n != "string" || n.length === 0 ? null : {
@@ -278,43 +295,60 @@ function S(e) {
278
295
  expectedEmail: n
279
296
  };
280
297
  }
281
- function C(e, t) {
298
+ function w(e, t) {
282
299
  if (e.type === f.AUTH_MISMATCH) {
283
- let n = x(e.payload);
300
+ let n = S(e.payload);
284
301
  return n && t.onAuthMismatch?.(n), !0;
285
302
  }
286
303
  if (e.type === f.AUTH_SWITCH_REQUEST) {
287
- let n = S(e.payload);
304
+ let n = C(e.payload);
288
305
  return n && t.onAuthSwitchRequest?.(n), !0;
289
306
  }
290
307
  return !1;
291
308
  }
292
309
  //#endregion
293
310
  //#region src/widgets/delegations.ts
294
- var w = {
311
+ var T = {
295
312
  code: "UNKNOWN",
296
313
  message: "Unknown widget error"
297
- }, T = {
314
+ }, E = {
298
315
  code: "UNKNOWN",
299
316
  message: "Malformed nvm:success payload — paymentMethodId missing or invalid"
300
- }, E = {
317
+ }, D = {
301
318
  code: "UNKNOWN",
302
319
  message: "Malformed nvm:success payload — delegationId missing or invalid"
303
- }, D = class {
320
+ }, O = class {
321
+ session;
322
+ webappBase;
323
+ apiBase;
304
324
  manager = null;
305
325
  destroyed = !1;
306
326
  constructor(e, t, n) {
307
327
  this.session = e, this.webappBase = t, this.apiBase = n;
308
328
  }
309
329
  enrollCard(e) {
310
- this.assertAlive("enrollCard"), this.mountIframe("/embed/cards/enroll", e.container).onMessage((t) => this.handleEnrollMessage(t, e));
330
+ this.assertAlive("enrollCard");
331
+ let t = e.provider ?? "stripe", n = this.mountIframe("/embed/cards/enroll", e.container, { provider: t }, {
332
+ width: e.width,
333
+ height: e.height
334
+ });
335
+ n.onMessage((t) => this.handleEnrollMessage(t, e, n));
311
336
  }
312
337
  listCards(e) {
313
- this.assertAlive("listCards"), this.mountIframe("/embed/cards/list", e.container).onMessage((t) => this.handleListMessage(t, e));
338
+ this.assertAlive("listCards");
339
+ let t = this.mountIframe("/embed/cards/list", e.container, void 0, {
340
+ width: e.width,
341
+ height: e.height
342
+ });
343
+ t.onMessage((n) => this.handleListMessage(n, e, t));
314
344
  }
315
345
  createDelegation(e) {
316
346
  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 }).onMessage((t) => this.handleCreateDelegationMessage(t, e));
347
+ let t = this.mountIframe("/embed/cards/delegate", e.container, { paymentMethodId: e.paymentMethodId }, {
348
+ width: e.width,
349
+ height: e.height
350
+ });
351
+ t.onMessage((n) => this.handleCreateDelegationMessage(n, e, t));
318
352
  }
319
353
  async revokeCard(e) {
320
354
  if (typeof e != "string" || e.length === 0) throw Error("[DelegationsWidget] revokeCard: paymentMethodId is required");
@@ -330,19 +364,23 @@ var w = {
330
364
  assertAlive(e) {
331
365
  if (this.destroyed) throw Error(`[DelegationsWidget] cannot ${e}: instance has been destroyed`);
332
366
  }
333
- mountIframe(e, t, n = {}) {
367
+ mountIframe(e, t, n = {}, r = {}) {
334
368
  this.manager?.destroy();
335
- let r = new URL(this.webappBase).origin, i = window.location.origin, a = new URL(e, this.webappBase);
336
- a.searchParams.set("parentOrigin", i);
337
- for (let [e, t] of Object.entries(n)) a.searchParams.set(e, t);
338
- let o = new v(r);
339
- return this.manager = o, o.create(a.toString(), { container: t }), o;
369
+ let i = new URL(this.webappBase).origin, a = window.location.origin, o = new URL(e, this.webappBase);
370
+ o.searchParams.set("parentOrigin", a);
371
+ for (let [e, t] of Object.entries(n)) o.searchParams.set(e, t);
372
+ let s = new y(i);
373
+ return this.manager = s, s.create(o.toString(), {
374
+ container: t,
375
+ width: r.width,
376
+ height: r.height
377
+ }), s;
340
378
  }
341
379
  postInitOnBooted() {
342
380
  this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() }));
343
381
  }
344
- handleEnrollMessage(e, t) {
345
- if (!C(e, t)) switch (e.type) {
382
+ handleEnrollMessage(e, t, n) {
383
+ if (!w(e, t)) switch (e.type) {
346
384
  case f.BOOTED:
347
385
  this.postInitOnBooted(), t.onBooted?.();
348
386
  return;
@@ -350,27 +388,30 @@ var w = {
350
388
  t.onReady?.();
351
389
  return;
352
390
  case f.SUCCESS: {
353
- let n = (e.payload ?? {}).paymentMethodId;
354
- if (typeof n != "string" || n.length === 0) {
355
- t.onError?.(T);
391
+ let r = (e.payload ?? {}).paymentMethodId;
392
+ if (typeof r != "string" || r.length === 0) {
393
+ t.onError?.(E);
356
394
  return;
357
395
  }
358
- t.onSuccess?.({ paymentMethodId: n });
396
+ t.onSuccess?.({
397
+ result: { paymentMethodId: r },
398
+ handle: this.buildSuccessHandle(t, n)
399
+ });
359
400
  return;
360
401
  }
361
402
  case f.ERROR: {
362
403
  let n = e.payload;
363
- t.onError?.(n?.error ?? w);
404
+ t.onError?.(n?.error ?? T);
364
405
  return;
365
406
  }
366
407
  case f.CLOSE:
367
- t.onClose?.(), this.destroy();
408
+ this.closeFromIframe(t, n);
368
409
  return;
369
410
  default: return;
370
411
  }
371
412
  }
372
- handleListMessage(e, t) {
373
- if (!C(e, t)) switch (e.type) {
413
+ handleListMessage(e, t, n) {
414
+ if (!w(e, t)) switch (e.type) {
374
415
  case f.BOOTED:
375
416
  this.postInitOnBooted(), t.onBooted?.();
376
417
  return;
@@ -379,7 +420,7 @@ var w = {
379
420
  return;
380
421
  case f.CARD_ACTION: {
381
422
  let n = e.payload ?? {};
382
- if (n.action !== "delegate" || typeof n.paymentMethodId != "string" || n.paymentMethodId.length === 0) return;
423
+ if (n.action !== "delegate" && n.action !== "revoked" || typeof n.paymentMethodId != "string" || n.paymentMethodId.length === 0) return;
383
424
  t.onCardAction?.({
384
425
  action: n.action,
385
426
  paymentMethodId: n.paymentMethodId
@@ -388,17 +429,17 @@ var w = {
388
429
  }
389
430
  case f.ERROR: {
390
431
  let n = e.payload;
391
- t.onError?.(n?.error ?? w);
432
+ t.onError?.(n?.error ?? T);
392
433
  return;
393
434
  }
394
435
  case f.CLOSE:
395
- t.onClose?.(), this.destroy();
436
+ this.closeFromIframe(t, n);
396
437
  return;
397
438
  default: return;
398
439
  }
399
440
  }
400
- handleCreateDelegationMessage(e, t) {
401
- if (!C(e, t)) switch (e.type) {
441
+ handleCreateDelegationMessage(e, t, n) {
442
+ if (!w(e, t)) switch (e.type) {
402
443
  case f.BOOTED:
403
444
  this.postInitOnBooted(), t.onBooted?.();
404
445
  return;
@@ -406,28 +447,37 @@ var w = {
406
447
  t.onReady?.();
407
448
  return;
408
449
  case f.SUCCESS: {
409
- let n = (e.payload ?? {}).delegationId;
410
- if (typeof n != "string" || n.length === 0) {
411
- t.onError?.(E);
450
+ let r = (e.payload ?? {}).delegationId;
451
+ if (typeof r != "string" || r.length === 0) {
452
+ t.onError?.(D);
412
453
  return;
413
454
  }
414
455
  t.onSuccess?.({
415
- delegationId: n,
416
- paymentMethodId: t.paymentMethodId
456
+ result: {
457
+ delegationId: r,
458
+ paymentMethodId: t.paymentMethodId
459
+ },
460
+ handle: this.buildSuccessHandle(t, n)
417
461
  });
418
462
  return;
419
463
  }
420
464
  case f.ERROR: {
421
465
  let n = e.payload;
422
- t.onError?.(n?.error ?? w);
466
+ t.onError?.(n?.error ?? T);
423
467
  return;
424
468
  }
425
469
  case f.CLOSE:
426
- t.onClose?.(), this.destroy();
470
+ this.closeFromIframe(t, n);
427
471
  return;
428
472
  default: return;
429
473
  }
430
474
  }
475
+ closeFromIframe(e, t) {
476
+ this.destroyed || this.manager !== t || (this.destroy(), e.onClose?.());
477
+ }
478
+ buildSuccessHandle(e, t) {
479
+ return { close: () => this.closeFromIframe(e, t) };
480
+ }
431
481
  async deleteWithSession(e, t) {
432
482
  let n;
433
483
  try {
@@ -452,7 +502,7 @@ var w = {
452
502
  };
453
503
  //#endregion
454
504
  //#region src/nevermined-widgets.ts
455
- function O(e) {
505
+ function k(e) {
456
506
  if (typeof e != "object" || !e) return !1;
457
507
  let t = e;
458
508
  return [
@@ -462,7 +512,10 @@ function O(e) {
462
512
  "apiKeyHash"
463
513
  ].every((e) => typeof t[e] == "string") && typeof t.userWallet == "string" && t.userWallet.startsWith("0x");
464
514
  }
465
- var k = class t {
515
+ var A = class t {
516
+ sessionManager;
517
+ _account;
518
+ environment;
466
519
  _checkout = null;
467
520
  _delegations = null;
468
521
  events = new d();
@@ -470,32 +523,15 @@ var k = class t {
470
523
  this.sessionManager = e, this._account = t, this.environment = n;
471
524
  }
472
525
  static async initialize(n) {
473
- let { initToken: i, environment: a } = n;
474
- if (!i || typeof i != "string") throw new o("MISSING_INIT_TOKEN");
475
- if (!a || !e.includes(a)) throw new o("INVALID_ENVIRONMENT");
476
- let s = r(a), c;
477
- try {
478
- c = await fetch(`${s}/api/v1/widgets/session`, {
479
- method: "POST",
480
- headers: { "Content-Type": "application/json" },
481
- body: JSON.stringify({ initToken: i })
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;
526
+ let { session: r, environment: i } = n;
527
+ if (!r || typeof r != "object") throw new o("MISSING_SESSION");
528
+ if (!i || !e.includes(i)) throw new o("INVALID_ENVIRONMENT");
529
+ if (!k(r)) throw new o("INVALID_SESSION");
530
+ let a = new u(r), s = new t(a, {
531
+ userId: r.userId,
532
+ userWallet: r.userWallet
533
+ }, i);
534
+ return a.startAutoRefresh(() => s.refreshSession(), () => s.events.emit("session-expired", void 0)), s;
499
535
  }
500
536
  async refreshSession() {
501
537
  let e = await fetch(`${r(this.environment)}/api/v1/widgets/session/refresh`, {
@@ -504,7 +540,7 @@ var k = class t {
504
540
  });
505
541
  if (!e.ok) throw Error(`Session refresh failed with status ${e.status}`);
506
542
  let t = await e.json();
507
- if (!O(t)) throw Error("Session refresh returned an invalid response");
543
+ if (!k(t)) throw Error("Session refresh returned an invalid response");
508
544
  return t;
509
545
  }
510
546
  on(e, t) {
@@ -524,14 +560,14 @@ var k = class t {
524
560
  return this.sessionManager.getToken();
525
561
  }
526
562
  get checkout() {
527
- return this._checkout ||= new b(this.sessionManager, i(this.environment)), this._checkout;
563
+ return this._checkout ||= new x(this.sessionManager, i(this.environment)), this._checkout;
528
564
  }
529
565
  get delegations() {
530
- return this._delegations ||= new D(this.sessionManager, i(this.environment), r(this.environment)), this._delegations;
566
+ return this._delegations ||= new O(this.sessionManager, i(this.environment), r(this.environment)), this._delegations;
531
567
  }
532
568
  destroy() {
533
569
  this.sessionManager.stopAutoRefresh(), this._checkout?.destroy(), this._checkout = null, this._delegations?.destroy(), this._delegations = null, this.events.removeAllListeners();
534
570
  }
535
571
  };
536
572
  //#endregion
537
- export { b as CheckoutWidget, D as DelegationsWidget, v as IframeManager, k 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 };
573
+ 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 };
@@ -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;IAInC,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
+ {"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;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MM,UAAU,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,iBAAiB,CAAC;YA0B3D,cAAc;IAwB5B,EAAE,CAAC,CAAC,SAAS,MAAM,uBAAuB,EACxC,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,CAAC,OAAO,EAAE,uBAAuB,CAAC,CAAC,CAAC,KAAK,IAAI,GACrD,IAAI;IAKP,GAAG,CAAC,CAAC,SAAS,MAAM,uBAAuB,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
- initToken: string;
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 {
@@ -24,41 +30,80 @@ export interface WidgetAccount {
24
30
  }
25
31
  export interface EmbedError {
26
32
  code: 'UNAUTHORIZED' | 'NETWORK' | 'PAYMENT_NOT_CONFIRMED' | 'UNKNOWN';
33
+ /**
34
+ * Raw, host-facing message. Carries the underlying detail (e.g. the backend
35
+ * `NVMException.message`) and is what the SDK forwards over the `nvm:error`
36
+ * postMessage for the integrator to log. May contain operational/technical
37
+ * text, so it is NOT safe to render in an end-user surface verbatim.
38
+ */
27
39
  message: string;
40
+ /**
41
+ * Safe, user-facing message. Generic per-`code` copy with no operational
42
+ * detail — render this (falling back to `message`) in any UI shown to the
43
+ * end user, such as the widgets' terminal error panels. Optional and
44
+ * additive: existing host integrations that only read `message` are
45
+ * unaffected.
46
+ */
47
+ userMessage?: string;
28
48
  status?: number;
29
49
  apiCode?: string;
30
50
  }
31
51
  /**
32
52
  * Emitted (via the per-widget `onAuthMismatch` callback) when the iframe
33
53
  * detects a live host Privy session whose email does not match the email
34
- * baked into the widget init token. The iframe renders a two-button prompt
35
- * (continue as the host identity, or switch to the init-token identity by
36
- * signing out of Privy inside the iframe) and the host page is informed so
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-issues an init
39
- * token via the action below.
54
+ * the widget session was minted for. The iframe renders a two-button prompt
55
+ * (continue as the host identity, or switch to the widget-session identity
56
+ * by signing out of Privy inside the iframe) and the host page is informed
57
+ * so it can mirror that affordance on its own UI. The widget is effectively
58
+ * halted until either button is clicked or the host re-mints a widget
59
+ * session via the action below.
40
60
  */
41
61
  export interface AuthMismatchDetail {
42
- /** Email expected by the widget init token (normalized — trimmed, lower-cased). */
62
+ /** Email the widget session was minted for (normalized — trimmed, lower-cased). */
43
63
  expectedEmail: string;
44
64
  }
45
65
  /**
46
66
  * Emitted (via the per-widget `onAuthSwitchRequest` callback) when the user
47
67
  * picks "Continue as <hostEmail>" on the mismatch prompt. The host page is
48
- * expected to re-issue an init token bound to `requestedEmail` and reopen
68
+ * expected to re-mint a widget session bound to `requestedEmail` and reopen
49
69
  * the widget; the iframe stays on the prompt until that happens.
50
70
  *
51
71
  * **Security note for integrators:** the SDK posts this event to the host
52
72
  * via `window.postMessage`, but the host's `window.addEventListener('message',
53
73
  * ...)` listens to ALL frames on the page. Validate `event.origin === <your
54
- * widget host>` (e.g. `https://app.nevermined.io`) before re-issuing tokens
55
- * — otherwise a malicious sub-frame could spoof this event and trick your
56
- * backend into minting a token for an attacker-supplied email.
74
+ * widget host>` (e.g. `https://app.nevermined.io`) before re-minting a
75
+ * session — otherwise a malicious sub-frame could spoof this event and
76
+ * trick your backend into minting a session for an attacker-supplied email.
57
77
  */
58
78
  export interface AuthSwitchRequestDetail {
59
79
  /** Email the user wants the widget to operate under (their live Privy identity). */
60
80
  requestedEmail: string;
61
- /** Email originally baked into the init token, for reference / telemetry. */
81
+ /** Email the original widget session was minted for, for reference / telemetry. */
62
82
  expectedEmail: string;
63
83
  }
84
+ /**
85
+ * Control surface passed to every widget's `onSuccess` callback (#1668
86
+ * sub-tasks 3 + 4). The iframe stays mounted indefinitely after a
87
+ * successful action so the integrator can show their own post-action UI
88
+ * (toast, next-step prompt, etc.) while the success state remains visible
89
+ * inside the widget. The integrator dismisses the widget by calling
90
+ * `handle.close()` — which destroys the iframe and invokes `onClose` —
91
+ * whenever their own flow is ready.
92
+ */
93
+ export interface WidgetSuccessHandle {
94
+ /**
95
+ * Destroys the iframe and invokes the widget's `onClose` callback.
96
+ * Idempotent: calling close on an already-closed widget is a no-op.
97
+ */
98
+ close(): void;
99
+ }
100
+ /**
101
+ * Payload shape passed to every widget's `onSuccess` callback. `result`
102
+ * is the per-widget data (paymentMethodId, delegationId, etc.); `handle`
103
+ * lets the integrator dismiss the widget on their own schedule.
104
+ */
105
+ export interface WidgetSuccessEvent<T> {
106
+ result: T;
107
+ handle: WidgetSuccessHandle;
108
+ }
64
109
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,0EAA2E,CAAA;AACpG,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,CAAC,CAAA;AAEvD,MAAM,WAAW,YAAY;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,WAAW,CAAA;CACzB;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AAM,CAAA;CAClB;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;CAC1B;AAED,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,cAAc,GAAG,SAAS,GAAG,uBAAuB,GAAG,SAAS,CAAA;IACtE;;;;;OAKG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;;;;;OAMG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,uBAAuB;IACtC,oFAAoF;IACpF,cAAc,EAAE,MAAM,CAAA;IACtB,mFAAmF;IACnF,aAAa,EAAE,MAAM,CAAA;CACtB;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAA;CACd;AAED;;;;GAIG;AACH,MAAM,WAAW,kBAAkB,CAAC,CAAC;IACnC,MAAM,EAAE,CAAC,CAAA;IACT,MAAM,EAAE,mBAAmB,CAAA;CAC5B"}
@@ -1,23 +1,15 @@
1
1
  export declare const WIDGET_ERRORS: {
2
- readonly MISSING_INIT_TOKEN: {
2
+ readonly MISSING_SESSION: {
3
3
  readonly numericCode: "WDG.0001";
4
- readonly message: "initToken is required and must be a non-empty string";
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 INVALID_INIT_TOKEN: {
10
+ readonly INVALID_SESSION: {
11
11
  readonly numericCode: "WDG.0003";
12
- readonly message: "Init token is invalid or expired";
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;;;;;;;;;;;;;;;;;;;;;;;;;CAgBmD,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"}
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"}
@@ -1,6 +1,6 @@
1
1
  import { SessionManager } from '../session.js';
2
2
  import { type WidgetMessage } from '../messages.js';
3
- import type { AuthMismatchDetail, AuthSwitchRequestDetail, EmbedError } from '../types.js';
3
+ import type { AuthMismatchDetail, AuthSwitchRequestDetail, EmbedError, WidgetSuccessEvent } from '../types.js';
4
4
  export interface CheckoutResult {
5
5
  did: string;
6
6
  planId?: string;
@@ -10,20 +10,37 @@ 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
- onSuccess?: (result: CheckoutResult) => void;
27
+ /**
28
+ * Fires when the iframe posts `nvm:success`. The widget stays mounted in
29
+ * its success state — the integrator dismisses it via `event.handle.close()`
30
+ * when their own post-success flow is ready. There is no auto-dismiss.
31
+ */
32
+ onSuccess?: (event: WidgetSuccessEvent<CheckoutResult>) => void;
16
33
  onError?: (error: EmbedError) => void;
17
34
  /**
18
35
  * Fires when the iframe detects that the live host Privy session belongs
19
- * to a different account than the email baked into the widget init token.
36
+ * to a different account than the email the widget session was minted for.
20
37
  * The iframe stays mounted on a two-button prompt; the host can mirror that
21
38
  * affordance on its own UI. See `AuthMismatchDetail`.
22
39
  */
23
40
  onAuthMismatch?: (detail: AuthMismatchDetail) => void;
24
41
  /**
25
42
  * Fires when, on the mismatch prompt, the user picks "Continue as
26
- * <hostEmail>". The host should re-issue an init token bound to
43
+ * <hostEmail>". The host should re-mint a widget session bound to
27
44
  * `requestedEmail` and reopen the widget. The iframe stays on the prompt
28
45
  * until then. See `AuthSwitchRequestDetail`.
29
46
  */
@@ -52,6 +69,25 @@ export declare class CheckoutWidget {
52
69
  */
53
70
  start(options: CheckoutOptions): void;
54
71
  destroy(): void;
72
+ /**
73
+ * Shared close path for `handle.close()` (integrator-driven) and
74
+ * `nvm:close` (iframe-driven). Idempotent — multiple calls collapse to a
75
+ * single `onClose` + destroy, which matters because `handle.close()`
76
+ * could race with a `nvm:close` from the iframe if the integrator's
77
+ * post-success UI happens to mount instantly.
78
+ *
79
+ * `manager` is the IframeManager this close was bound to when the handle
80
+ * was minted. A stale handle from a previous mount (the instance was
81
+ * remounted via a second `start()` without an intervening close) must NOT
82
+ * tear down the now-live iframe, so we bail once it no longer owns
83
+ * `this.manager`.
84
+ *
85
+ * Ordering is load-bearing: `destroy()` runs before `onClose()` so a
86
+ * throwing `onClose` cannot leak a second close — `destroyed` is already
87
+ * true by the time the callback runs.
88
+ */
89
+ private closeFromIframe;
90
+ private buildSuccessHandle;
55
91
  private handleMessage;
56
92
  }
57
93
  /**
@@ -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,aA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.js';
2
+ import type { AuthMismatchDetail, AuthSwitchRequestDetail, EmbedError, WidgetSuccessEvent } from '../types.js';
3
3
  export interface EnrollCardResult {
4
4
  paymentMethodId: string;
5
5
  }
6
+ /**
7
+ * #1668 sub-task 2: which tokenization flow renders inside the embedded
8
+ * enrol-card iframe.
9
+ *
10
+ * - `'stripe'` (default): Stripe Elements + SetupIntent. The existing flow.
11
+ * - `'braintree'`: Braintree Drop-in (PayPal vault).
12
+ * - `'visa'`: Visa Agentic Tokens via VGS Collect → CMP. **Requires an
13
+ * HTTPS parent page** — the Visa VTS iframe enforces
14
+ * `frame-ancestors 'self' https:` so a non-HTTPS host (e.g. plain
15
+ * `http://localhost`) cannot embed this provider.
16
+ */
17
+ export type EnrollCardProvider = 'stripe' | 'braintree' | 'visa';
6
18
  export interface EnrollCardOptions {
7
19
  container?: HTMLElement;
20
+ /** See `CheckoutOptions.width`. */
21
+ width?: number;
22
+ /** See `CheckoutOptions.height`. */
23
+ height?: number;
24
+ /** See `EnrollCardProvider`. Defaults to `'stripe'`. */
25
+ provider?: EnrollCardProvider;
8
26
  onBooted?: () => void;
9
27
  onReady?: () => void;
10
- onSuccess?: (result: EnrollCardResult) => void;
28
+ /** See `CheckoutOptions.onSuccess`. */
29
+ onSuccess?: (event: WidgetSuccessEvent<EnrollCardResult>) => void;
11
30
  onError?: (error: EmbedError) => void;
12
31
  /** See `CheckoutOptions.onAuthMismatch`. */
13
32
  onAuthMismatch?: (detail: AuthMismatchDetail) => void;
@@ -16,12 +35,21 @@ export interface EnrollCardOptions {
16
35
  onClose?: () => void;
17
36
  }
18
37
  export interface CardAction {
19
- /** Currently the only emitted action; reserved as a discriminator for future ones. */
20
- action: 'delegate';
38
+ /**
39
+ * `delegate` — the user asked to create a delegation for this card (host
40
+ * should mount `createDelegation`). `revoked` — the user removed this card
41
+ * inline; the list iframe stays open so this is an intra-flow event, not
42
+ * flow completion (which is why it is NOT an `nvm:success`). See #1411.
43
+ */
44
+ action: 'delegate' | 'revoked';
21
45
  paymentMethodId: string;
22
46
  }
23
47
  export interface ListCardsOptions {
24
48
  container?: HTMLElement;
49
+ /** See `CheckoutOptions.width`. */
50
+ width?: number;
51
+ /** See `CheckoutOptions.height`. */
52
+ height?: number;
25
53
  onBooted?: () => void;
26
54
  onReady?: () => void;
27
55
  onCardAction?: (action: CardAction) => void;
@@ -39,9 +67,14 @@ export interface CreateDelegationResult {
39
67
  export interface CreateDelegationOptions {
40
68
  paymentMethodId: string;
41
69
  container?: HTMLElement;
70
+ /** See `CheckoutOptions.width`. */
71
+ width?: number;
72
+ /** See `CheckoutOptions.height`. */
73
+ height?: number;
42
74
  onBooted?: () => void;
43
75
  onReady?: () => void;
44
- onSuccess?: (result: CreateDelegationResult) => void;
76
+ /** See `CheckoutOptions.onSuccess`. */
77
+ onSuccess?: (event: WidgetSuccessEvent<CreateDelegationResult>) => void;
45
78
  onError?: (error: EmbedError) => void;
46
79
  /** See `CheckoutOptions.onAuthMismatch`. */
47
80
  onAuthMismatch?: (detail: AuthMismatchDetail) => void;
@@ -81,8 +114,9 @@ export declare class DelegationsWidget {
81
114
  enrollCard(options: EnrollCardOptions): void;
82
115
  /**
83
116
  * Mounts the cards-list iframe at `/embed/cards/list`. Per-row actions
84
- * (currently only "Create Delegation") are forwarded via `onCardAction` so
85
- * the host can mount the appropriate follow-up widget.
117
+ * ("Create Delegation" `'delegate'`, "Remove Card" → `'revoked'`) are
118
+ * forwarded via `onCardAction` so the host can react (mount a follow-up
119
+ * widget, refresh its own list, etc.). See `CardAction`.
86
120
  */
87
121
  listCards(options: ListCardsOptions): void;
88
122
  /**
@@ -110,6 +144,25 @@ export declare class DelegationsWidget {
110
144
  private handleEnrollMessage;
111
145
  private handleListMessage;
112
146
  private handleCreateDelegationMessage;
147
+ /**
148
+ * #1668: shared close path for `handle.close()` (integrator-driven) and
149
+ * `nvm:close` (iframe-driven). Idempotent so a race between the
150
+ * integrator dismissing the widget and the iframe emitting CLOSE
151
+ * collapses to a single `onClose` + destroy. Generic over the three
152
+ * options shapes — only `onClose` is referenced.
153
+ *
154
+ * `manager` is the IframeManager this close was bound to when the handle
155
+ * was minted. The three iframe flows share the single `manager` slot, so a
156
+ * stale handle from an earlier flow (e.g. an uncalled `enrollCard` success
157
+ * handle held past a later `createDelegation`) must NOT tear down the
158
+ * now-live iframe — we bail once it no longer owns `this.manager`.
159
+ *
160
+ * Ordering is load-bearing: `destroy()` runs before `onClose()` so a
161
+ * throwing `onClose` cannot leak a second close — `destroyed` is already
162
+ * true by the time the callback runs.
163
+ */
164
+ private closeFromIframe;
165
+ private buildSuccessHandle;
113
166
  private deleteWithSession;
114
167
  }
115
168
  //# sourceMappingURL=delegations.d.ts.map
@@ -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,4CAA4C;IAC5C,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,kBAAkB,KAAK,IAAI,CAAA;IACrD,iDAAiD;IACjD,mBAAmB,CAAC,EAAE,CAAC,MAAM,EAAE,uBAAuB,KAAK,IAAI,CAAA;IAC/D,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;CACrB;AAED,MAAM,W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AO,EAAE,MAAM;IAGlC;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI;IAY5C;;;;;OAKG;IACH,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI;IAS1C;;;;OAIG;IACH,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI;IAgBxD;;;;OAIG;IACG,UAAU,CAAC,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAUxD;;;;OAIG;IACG,gBAAgB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,WAAW;IAMnB,OAAO,CAAC,WAAW;IAuBnB,OAAO,CAAC,gBAAgB;IAMxB,OAAO,CAAC,mBAAmB;IA8C3B,OAAO,CAAC,iBAAiB;IAkDzB,OAAO,CAAC,6BAA6B;IA8CrC;;;;;;;;;;;;;;;;OAgBG;IACH,OAAO,CAAC,eAAe;IAMvB,OAAO,CAAC,kBAAkB;YAMZ,iBAAiB;CAgChC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nevermined-io/ui-widgets",
3
- "version": "0.5.7",
3
+ "version": "0.5.9",
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.5",
21
+ "vite": "^8.0.13",
22
22
  "vite-plugin-dts": "^4.5.4"
23
23
  }
24
24
  }