@nevermined-io/ui-widgets 0.5.8 → 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/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;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAA;AAC5D,OAAO,EA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BAAkB,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_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});
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
@@ -239,12 +239,18 @@ var y = class {
239
239
  container: e.container,
240
240
  width: e.width,
241
241
  height: e.height
242
- }), i.onMessage((t) => this.handleMessage(t, e));
242
+ }), i.onMessage((t) => this.handleMessage(t, e, i));
243
243
  }
244
244
  destroy() {
245
245
  this.destroyed = !0, this.manager?.destroy(), this.manager = null;
246
246
  }
247
- handleMessage(e, t) {
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) {
248
254
  if (!w(e, t)) switch (e.type) {
249
255
  case f.BOOTED:
250
256
  this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() })), t.onBooted?.();
@@ -253,11 +259,14 @@ var y = class {
253
259
  t.onReady?.();
254
260
  return;
255
261
  case f.SUCCESS: {
256
- 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
+ };
257
267
  t.onSuccess?.({
258
- did: n.did ?? t.did,
259
- planId: n.planId ?? t.planId,
260
- txHash: n.txHash
268
+ result: i,
269
+ handle: this.buildSuccessHandle(t, n)
261
270
  });
262
271
  return;
263
272
  }
@@ -267,7 +276,7 @@ var y = class {
267
276
  return;
268
277
  }
269
278
  case f.CLOSE:
270
- t.onClose?.(), this.destroy();
279
+ this.closeFromIframe(t, n);
271
280
  return;
272
281
  default: return;
273
282
  }
@@ -318,23 +327,28 @@ var T = {
318
327
  this.session = e, this.webappBase = t, this.apiBase = n;
319
328
  }
320
329
  enrollCard(e) {
321
- this.assertAlive("enrollCard"), this.mountIframe("/embed/cards/enroll", e.container, void 0, {
330
+ this.assertAlive("enrollCard");
331
+ let t = e.provider ?? "stripe", n = this.mountIframe("/embed/cards/enroll", e.container, { provider: t }, {
322
332
  width: e.width,
323
333
  height: e.height
324
- }).onMessage((t) => this.handleEnrollMessage(t, e));
334
+ });
335
+ n.onMessage((t) => this.handleEnrollMessage(t, e, n));
325
336
  }
326
337
  listCards(e) {
327
- this.assertAlive("listCards"), this.mountIframe("/embed/cards/list", e.container, void 0, {
338
+ this.assertAlive("listCards");
339
+ let t = this.mountIframe("/embed/cards/list", e.container, void 0, {
328
340
  width: e.width,
329
341
  height: e.height
330
- }).onMessage((t) => this.handleListMessage(t, e));
342
+ });
343
+ t.onMessage((n) => this.handleListMessage(n, e, t));
331
344
  }
332
345
  createDelegation(e) {
333
346
  if (this.assertAlive("createDelegation"), typeof e.paymentMethodId != "string" || e.paymentMethodId.length === 0) throw Error("[DelegationsWidget] createDelegation: paymentMethodId is required");
334
- this.mountIframe("/embed/cards/delegate", e.container, { paymentMethodId: e.paymentMethodId }, {
347
+ let t = this.mountIframe("/embed/cards/delegate", e.container, { paymentMethodId: e.paymentMethodId }, {
335
348
  width: e.width,
336
349
  height: e.height
337
- }).onMessage((t) => this.handleCreateDelegationMessage(t, e));
350
+ });
351
+ t.onMessage((n) => this.handleCreateDelegationMessage(n, e, t));
338
352
  }
339
353
  async revokeCard(e) {
340
354
  if (typeof e != "string" || e.length === 0) throw Error("[DelegationsWidget] revokeCard: paymentMethodId is required");
@@ -365,7 +379,7 @@ var T = {
365
379
  postInitOnBooted() {
366
380
  this.manager?.postMessage(g(f.INIT, { sessionToken: this.session.getToken() }));
367
381
  }
368
- handleEnrollMessage(e, t) {
382
+ handleEnrollMessage(e, t, n) {
369
383
  if (!w(e, t)) switch (e.type) {
370
384
  case f.BOOTED:
371
385
  this.postInitOnBooted(), t.onBooted?.();
@@ -374,12 +388,15 @@ var T = {
374
388
  t.onReady?.();
375
389
  return;
376
390
  case f.SUCCESS: {
377
- let n = (e.payload ?? {}).paymentMethodId;
378
- if (typeof n != "string" || n.length === 0) {
391
+ let r = (e.payload ?? {}).paymentMethodId;
392
+ if (typeof r != "string" || r.length === 0) {
379
393
  t.onError?.(E);
380
394
  return;
381
395
  }
382
- t.onSuccess?.({ paymentMethodId: n });
396
+ t.onSuccess?.({
397
+ result: { paymentMethodId: r },
398
+ handle: this.buildSuccessHandle(t, n)
399
+ });
383
400
  return;
384
401
  }
385
402
  case f.ERROR: {
@@ -388,12 +405,12 @@ var T = {
388
405
  return;
389
406
  }
390
407
  case f.CLOSE:
391
- t.onClose?.(), this.destroy();
408
+ this.closeFromIframe(t, n);
392
409
  return;
393
410
  default: return;
394
411
  }
395
412
  }
396
- handleListMessage(e, t) {
413
+ handleListMessage(e, t, n) {
397
414
  if (!w(e, t)) switch (e.type) {
398
415
  case f.BOOTED:
399
416
  this.postInitOnBooted(), t.onBooted?.();
@@ -403,7 +420,7 @@ var T = {
403
420
  return;
404
421
  case f.CARD_ACTION: {
405
422
  let n = e.payload ?? {};
406
- 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;
407
424
  t.onCardAction?.({
408
425
  action: n.action,
409
426
  paymentMethodId: n.paymentMethodId
@@ -416,12 +433,12 @@ var T = {
416
433
  return;
417
434
  }
418
435
  case f.CLOSE:
419
- t.onClose?.(), this.destroy();
436
+ this.closeFromIframe(t, n);
420
437
  return;
421
438
  default: return;
422
439
  }
423
440
  }
424
- handleCreateDelegationMessage(e, t) {
441
+ handleCreateDelegationMessage(e, t, n) {
425
442
  if (!w(e, t)) switch (e.type) {
426
443
  case f.BOOTED:
427
444
  this.postInitOnBooted(), t.onBooted?.();
@@ -430,14 +447,17 @@ var T = {
430
447
  t.onReady?.();
431
448
  return;
432
449
  case f.SUCCESS: {
433
- let n = (e.payload ?? {}).delegationId;
434
- if (typeof n != "string" || n.length === 0) {
450
+ let r = (e.payload ?? {}).delegationId;
451
+ if (typeof r != "string" || r.length === 0) {
435
452
  t.onError?.(D);
436
453
  return;
437
454
  }
438
455
  t.onSuccess?.({
439
- delegationId: n,
440
- paymentMethodId: t.paymentMethodId
456
+ result: {
457
+ delegationId: r,
458
+ paymentMethodId: t.paymentMethodId
459
+ },
460
+ handle: this.buildSuccessHandle(t, n)
441
461
  });
442
462
  return;
443
463
  }
@@ -447,11 +467,17 @@ var T = {
447
467
  return;
448
468
  }
449
469
  case f.CLOSE:
450
- t.onClose?.(), this.destroy();
470
+ this.closeFromIframe(t, n);
451
471
  return;
452
472
  default: return;
453
473
  }
454
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
+ }
455
481
  async deleteWithSession(e, t) {
456
482
  let n;
457
483
  try {
package/dist/types.d.ts CHANGED
@@ -30,7 +30,21 @@ export interface WidgetAccount {
30
30
  }
31
31
  export interface EmbedError {
32
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
+ */
33
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;
34
48
  status?: number;
35
49
  apiCode?: string;
36
50
  }
@@ -67,4 +81,29 @@ export interface AuthSwitchRequestDetail {
67
81
  /** Email the original widget session was minted for, for reference / telemetry. */
68
82
  expectedEmail: string;
69
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
+ }
70
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;;;;;OAKG;IACH,OAAO,EAAE,aAAa,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,KAAK,MAAM,EAAE,CAAA;IACzB;;;;;;OAMG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,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,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,MAAM,CAAA;CACjB;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF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;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,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;
@@ -24,7 +24,12 @@ export interface CheckoutOptions {
24
24
  height?: number;
25
25
  onBooted?: () => void;
26
26
  onReady?: () => void;
27
- 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;
28
33
  onError?: (error: EmbedError) => void;
29
34
  /**
30
35
  * Fires when the iframe detects that the live host Privy session belongs
@@ -64,6 +69,25 @@ export declare class CheckoutWidget {
64
69
  */
65
70
  start(options: CheckoutOptions): void;
66
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;
67
91
  private handleMessage;
68
92
  }
69
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,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;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,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,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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"}
@@ -1,17 +1,32 @@
1
1
  import { SessionManager } from '../session.js';
2
- import type { AuthMismatchDetail, AuthSwitchRequestDetail, EmbedError } from '../types.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;
8
20
  /** See `CheckoutOptions.width`. */
9
21
  width?: number;
10
22
  /** See `CheckoutOptions.height`. */
11
23
  height?: number;
24
+ /** See `EnrollCardProvider`. Defaults to `'stripe'`. */
25
+ provider?: EnrollCardProvider;
12
26
  onBooted?: () => void;
13
27
  onReady?: () => void;
14
- onSuccess?: (result: EnrollCardResult) => void;
28
+ /** See `CheckoutOptions.onSuccess`. */
29
+ onSuccess?: (event: WidgetSuccessEvent<EnrollCardResult>) => void;
15
30
  onError?: (error: EmbedError) => void;
16
31
  /** See `CheckoutOptions.onAuthMismatch`. */
17
32
  onAuthMismatch?: (detail: AuthMismatchDetail) => void;
@@ -20,8 +35,13 @@ export interface EnrollCardOptions {
20
35
  onClose?: () => void;
21
36
  }
22
37
  export interface CardAction {
23
- /** Currently the only emitted action; reserved as a discriminator for future ones. */
24
- 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';
25
45
  paymentMethodId: string;
26
46
  }
27
47
  export interface ListCardsOptions {
@@ -53,7 +73,8 @@ export interface CreateDelegationOptions {
53
73
  height?: number;
54
74
  onBooted?: () => void;
55
75
  onReady?: () => void;
56
- onSuccess?: (result: CreateDelegationResult) => void;
76
+ /** See `CheckoutOptions.onSuccess`. */
77
+ onSuccess?: (event: WidgetSuccessEvent<CreateDelegationResult>) => void;
57
78
  onError?: (error: EmbedError) => void;
58
79
  /** See `CheckoutOptions.onAuthMismatch`. */
59
80
  onAuthMismatch?: (detail: AuthMismatchDetail) => void;
@@ -93,8 +114,9 @@ export declare class DelegationsWidget {
93
114
  enrollCard(options: EnrollCardOptions): void;
94
115
  /**
95
116
  * Mounts the cards-list iframe at `/embed/cards/list`. Per-row actions
96
- * (currently only "Create Delegation") are forwarded via `onCardAction` so
97
- * 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`.
98
120
  */
99
121
  listCards(options: ListCardsOptions): void;
100
122
  /**
@@ -122,6 +144,25 @@ export declare class DelegationsWidget {
122
144
  private handleEnrollMessage;
123
145
  private handleListMessage;
124
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;
125
166
  private deleteWithSession;
126
167
  }
127
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,mCAAmC;IACnC,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,oCAAoC;IACpC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAA;IACrB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;IACpB,SAAS,CAAC,EAAE,CAAC,MAAM,EAAE,gBAAgB,K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
  {
2
2
  "name": "@nevermined-io/ui-widgets",
3
- "version": "0.5.8",
3
+ "version": "0.5.9",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",