@nevermined-io/payments 1.10.0 → 1.11.1
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/api/nvm-api.d.ts +4 -0
- package/dist/api/nvm-api.d.ts.map +1 -1
- package/dist/api/nvm-api.js +7 -0
- package/dist/api/nvm-api.js.map +1 -1
- package/dist/api/organizations-api/organizations-api.d.ts +19 -1
- package/dist/api/organizations-api/organizations-api.d.ts.map +1 -1
- package/dist/api/organizations-api/organizations-api.js +53 -0
- package/dist/api/organizations-api/organizations-api.js.map +1 -1
- package/dist/api/organizations-api/types.d.ts +33 -0
- package/dist/api/organizations-api/types.d.ts.map +1 -1
- package/dist/api/organizations-api/types.js.map +1 -1
- package/dist/common/api-version.d.ts +1 -1
- package/dist/common/api-version.js +1 -1
- package/dist/common/api-version.js.map +1 -1
- package/dist/common/types.d.ts +1 -1
- package/dist/common/types.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/core/server-manager.d.ts.map +1 -1
- package/dist/mcp/core/server-manager.js +3 -0
- package/dist/mcp/core/server-manager.js.map +1 -1
- package/dist/mcp/http/mcp-handler.d.ts +7 -0
- package/dist/mcp/http/mcp-handler.d.ts.map +1 -1
- package/dist/mcp/http/mcp-handler.js +8 -1
- package/dist/mcp/http/mcp-handler.js.map +1 -1
- package/dist/mcp/http/oauth-metadata.d.ts.map +1 -1
- package/dist/mcp/http/oauth-metadata.js +31 -6
- package/dist/mcp/http/oauth-metadata.js.map +1 -1
- package/dist/mcp/http/oauth-router.d.ts +17 -16
- package/dist/mcp/http/oauth-router.d.ts.map +1 -1
- package/dist/mcp/http/oauth-router.js +56 -28
- package/dist/mcp/http/oauth-router.js.map +1 -1
- package/dist/mpp/codec.d.ts +92 -0
- package/dist/mpp/codec.d.ts.map +1 -0
- package/dist/mpp/codec.js +405 -0
- package/dist/mpp/codec.js.map +1 -0
- package/dist/mpp/errors.d.ts +165 -0
- package/dist/mpp/errors.d.ts.map +1 -0
- package/dist/mpp/errors.js +177 -0
- package/dist/mpp/errors.js.map +1 -0
- package/dist/mpp/fetch.d.ts +196 -0
- package/dist/mpp/fetch.d.ts.map +1 -0
- package/dist/mpp/fetch.js +493 -0
- package/dist/mpp/fetch.js.map +1 -0
- package/dist/mpp/index.d.ts +11 -0
- package/dist/mpp/index.d.ts.map +1 -0
- package/dist/mpp/index.js +20 -0
- package/dist/mpp/index.js.map +1 -0
- package/dist/mpp/mpp-api.d.ts +153 -0
- package/dist/mpp/mpp-api.d.ts.map +1 -0
- package/dist/mpp/mpp-api.js +298 -0
- package/dist/mpp/mpp-api.js.map +1 -0
- package/dist/mpp/types.d.ts +43 -0
- package/dist/mpp/types.d.ts.map +1 -0
- package/dist/mpp/types.js +9 -0
- package/dist/mpp/types.js.map +1 -0
- package/dist/payments.d.ts +13 -0
- package/dist/payments.d.ts.map +1 -1
- package/dist/payments.js +3 -0
- package/dist/payments.js.map +1 -1
- package/dist/x402/delegation-api.d.ts +3 -1
- package/dist/x402/delegation-api.d.ts.map +1 -1
- package/dist/x402/delegation-api.js.map +1 -1
- package/dist/x402/express/index.d.ts +2 -0
- package/dist/x402/express/index.d.ts.map +1 -1
- package/dist/x402/express/index.js +2 -0
- package/dist/x402/express/index.js.map +1 -1
- package/dist/x402/express/middleware.d.ts +33 -1
- package/dist/x402/express/middleware.d.ts.map +1 -1
- package/dist/x402/express/middleware.js +831 -1
- package/dist/x402/express/middleware.js.map +1 -1
- package/dist/x402/express/mpp-support.d.ts +58 -0
- package/dist/x402/express/mpp-support.d.ts.map +1 -0
- package/dist/x402/express/mpp-support.js +67 -0
- package/dist/x402/express/mpp-support.js.map +1 -0
- package/dist/x402/express/raw-body.d.ts +24 -0
- package/dist/x402/express/raw-body.d.ts.map +1 -0
- package/dist/x402/express/raw-body.js +34 -0
- package/dist/x402/express/raw-body.js.map +1 -0
- package/dist/x402/token-request.d.ts +15 -0
- package/dist/x402/token-request.d.ts.map +1 -0
- package/dist/x402/token-request.js +66 -0
- package/dist/x402/token-request.js.map +1 -0
- package/dist/x402/token.d.ts.map +1 -1
- package/dist/x402/token.js +7 -51
- package/dist/x402/token.js.map +1 -1
- package/package.json +1 -1
package/dist/api/nvm-api.d.ts
CHANGED
|
@@ -22,6 +22,10 @@ export declare const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = "/api/v1/protocol/tok
|
|
|
22
22
|
export declare const API_URL_CREATE_PERMISSION = "/api/v1/x402/permissions";
|
|
23
23
|
export declare const API_URL_VERIFY_PERMISSIONS = "/api/v1/x402/verify";
|
|
24
24
|
export declare const API_URL_SETTLE_PERMISSIONS = "/api/v1/x402/settle";
|
|
25
|
+
export declare const API_URL_MPP_CREATE_PERMISSION = "/api/v1/mpp/permissions";
|
|
26
|
+
export declare const API_URL_MPP_CHALLENGE = "/api/v1/mpp/challenge";
|
|
27
|
+
export declare const API_URL_MPP_VERIFY = "/api/v1/mpp/verify";
|
|
28
|
+
export declare const API_URL_MPP_SETTLE = "/api/v1/mpp/settle";
|
|
25
29
|
export declare const API_URL_STRIPE_CHECKOUT = "/api/v1/fiat/stripe/payment";
|
|
26
30
|
export declare const API_URL_CREATE_USER = "/api/v1/organizations/account";
|
|
27
31
|
export declare const API_URL_GET_MEMBERS = "/api/v1/organizations/members";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nvm-api.d.ts","sourceRoot":"","sources":["../../src/api/nvm-api.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,qBAAqB,2BAA2B,CAAA;AAC7D,eAAO,MAAM,sBAAsB,4BAA4B,CAAA;AAC/D,eAAO,MAAM,gCAAgC,kCAAkC,CAAA;AAC/E,eAAO,MAAM,iBAAiB,qCAAqC,CAAA;AACnE,eAAO,MAAM,oBAAoB,qCAAqC,CAAA;AACtE,eAAO,MAAM,uBAAuB,2CAA2C,CAAA;AAI/E,eAAO,MAAM,k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,MAAM,CAAA;KAAE,CAAA;CACpC;AAED,qBAAa,kBAAkB;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,gBAAgB,UAAO;IACvB,SAAS,CAAC,EAAE,MAAM,CAAY;IAC9B,OAAO,CAAC,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAK;CACzC;AAED,8BAAsB,kBAAkB;;IAyCtC,QAAQ,CAAC,YAAY,EAAE,MAAM,EAAE,UAAU,EAAE,kBAAkB;IAW7D,YAAY,CAAC,cAAc,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,EAAE,WAAW,CAAC,EAAE,MAAM;;;IActE,OAAO,CACX,MAAM,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE,GAAG,EACV,UAAU,GAAE,kBAEX;IAqBG,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,GAAE,kBAA+C;IAI5E,IAAI,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;IAI3D,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;IAI1D,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,UAAU,EAAE,kBAAkB;CAGpE"}
|
package/dist/api/nvm-api.js
CHANGED
|
@@ -26,6 +26,13 @@ export const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = '/api/v1/protocol/token/valid
|
|
|
26
26
|
export const API_URL_CREATE_PERMISSION = '/api/v1/x402/permissions';
|
|
27
27
|
export const API_URL_VERIFY_PERMISSIONS = '/api/v1/x402/verify';
|
|
28
28
|
export const API_URL_SETTLE_PERMISSIONS = '/api/v1/x402/settle';
|
|
29
|
+
// MPP seller/buyer surface. Sibling routes of /api/v1/x402, never children:
|
|
30
|
+
// an MPP access token is byte-identical to an x402 one on the wire, so the
|
|
31
|
+
// route is what fixes the protocol. See nvm-monorepo#2641.
|
|
32
|
+
export const API_URL_MPP_CREATE_PERMISSION = '/api/v1/mpp/permissions';
|
|
33
|
+
export const API_URL_MPP_CHALLENGE = '/api/v1/mpp/challenge';
|
|
34
|
+
export const API_URL_MPP_VERIFY = '/api/v1/mpp/verify';
|
|
35
|
+
export const API_URL_MPP_SETTLE = '/api/v1/mpp/settle';
|
|
29
36
|
export const API_URL_STRIPE_CHECKOUT = '/api/v1/fiat/stripe/payment';
|
|
30
37
|
export const API_URL_CREATE_USER = '/api/v1/organizations/account';
|
|
31
38
|
export const API_URL_GET_MEMBERS = '/api/v1/organizations/members';
|
package/dist/api/nvm-api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nvm-api.js","sourceRoot":"","sources":["../../src/api/nvm-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAA;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MAAM,CAAC,MAAM,gCAAgC,GAAG,+BAA+B,CAAA;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAA;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wCAAwC,CAAA;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAA;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAAgC,CAAA;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,uCAAuC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;IAED,KAAK,CAAC,MAAM,CAAC,GAAW,EAAE,IAAS,EAAE,UAA8B;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import axios from 'axios'\n\nexport const API_URL_REGISTER_PLAN = '/api/v1/protocol/plans'\nexport const API_URL_REGISTER_AGENT = '/api/v1/protocol/agents'\nexport const API_URL_REGISTER_AGENTS_AND_PLAN = '/api/v1/protocol/agents/plans'\nexport const API_URL_GET_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_UPDATE_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_GET_AGENT_PLANS = '/api/v1/protocol/agents/:agentId/plans'\n// GET: the caller's own agents (?orgId= scopes to an org the caller belongs to).\n// Same path as API_URL_REGISTER_AGENT (disambiguated by GET vs POST); mirrors\n// the existing API_URL_REGISTER_PLAN / API_URL_GET_PLANS pair below.\nexport const API_URL_GET_AGENTS = '/api/v1/protocol/agents'\nexport const API_URL_GET_PLAN = '/api/v1/protocol/plans/:planId'\nexport const API_URL_GET_PLANS = '/api/v1/protocol/plans'\nexport const API_URL_GET_PLAN_AGENTS = '/api/v1/protocol/plans/:planId/agents'\nexport const API_URL_ORDER_PLAN = '/api/v1/protocol/plans/:planId/order'\nexport const API_URL_MINT_PLAN = '/api/v1/protocol/plans/mint'\nexport const API_URL_MINT_EXPIRABLE_PLAN = '/api/v1/protocol/plans/mintExpirable'\nexport const API_URL_ADD_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REMOVE_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_PLAN_BALANCE = '/api/v1/protocol/plans/:planId/balance/:holderAddress'\nexport const API_URL_INITIALIZE_AGENT = '/api/v1/protocol/agents/initialize/:agentId'\nexport const API_URL_SIMULATE_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/start'\nexport const API_URL_SIMULATE_REDEEM_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/finish'\nexport const API_URL_TRACK_AGENT_SUB_TASK = '/api/v1/protocol/agent-sub-tasks'\nexport const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = '/api/v1/protocol/token/validate/:agentId'\nexport const API_URL_CREATE_PERMISSION = '/api/v1/x402/permissions'\nexport const API_URL_VERIFY_PERMISSIONS = '/api/v1/x402/verify'\nexport const API_URL_SETTLE_PERMISSIONS = '/api/v1/x402/settle'\nexport const API_URL_STRIPE_CHECKOUT = '/api/v1/fiat/stripe/payment'\nexport const API_URL_CREATE_USER = '/api/v1/organizations/account'\nexport const API_URL_GET_MEMBERS = '/api/v1/organizations/members'\nexport const API_URL_MY_MEMBERSHIPS = '/api/v1/organizations/my-memberships'\nexport const API_URL_ORG_ACTIVITY = '/api/v1/organizations/:orgId/activity'\nexport const API_URL_CONNECT_STRIPE_ACCOUNT = '/api/v1/fiat/stripe/account'\n\nexport interface BackendApiOptions {\n /**\n * The host of the backend server\n */\n backendHost: string\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n apiKey?: string\n\n /**\n * The host of the Nevermined Proxy\n */\n proxyHost?: string\n\n /**\n * Additional headers to send with the requests\n */\n headers?: { [key: string]: string }\n}\n\nexport class HTTPRequestOptions {\n accessToken?: string\n sendThroughProxy = true\n proxyHost?: string = undefined\n headers?: { [key: string]: string } = {}\n}\n\nexport abstract class AbstractHTTPClient {\n // protected opts: BackendApiOptions\n // private hasKey = false\n // private agentId = ''\n\n // constructor(opts: BackendApiOptions) {\n // const defaultHeaders = {\n // Accept: 'application/json',\n // ...opts.headers,\n // ...(opts.apiKey && { Authorization: `Bearer ${opts.apiKey}` }),\n // }\n\n // this.opts = {\n // ...opts,\n // headers: defaultHeaders,\n // }\n\n // try {\n // if (this.opts.apiKey && this.opts.apiKey.length > 0) {\n // const jwt = decodeJwt(this.opts.apiKey)\n // if (isEthereumAddress(jwt.sub)) {\n // this.hasKey = true\n // }\n // }\n // } catch {\n // this.hasKey = false\n // }\n\n // let backendUrl\n // try {\n // backendUrl = new URL(this.opts.backendHost)\n // this.opts.backendHost = backendUrl.origin\n // } catch (error) {\n // throw new Error(`Invalid URL: ${this.opts.backendHost} - ${(error as Error).message}`)\n // }\n // }\n\n constructor() {\n // Empty constructor - required for abstract class implementation\n }\n\n parseUrl(urlRequested: string, reqOptions: HTTPRequestOptions) {\n let _host: URL\n if (reqOptions.sendThroughProxy) {\n if (!reqOptions.proxyHost)\n throw new Error('Proxy host is required when sendThroughProxy is true')\n return `${new URL(reqOptions.proxyHost).origin}${new URL(urlRequested).href}`\n } else {\n return urlRequested\n }\n }\n\n parseHeaders(requestHeaders: { [key: string]: string }, accessToken?: string) {\n return {\n ...(accessToken && { Authorization: `Bearer ${accessToken}` }),\n ...requestHeaders,\n }\n }\n\n // setBearerToken(token: string) {\n // this.opts.headers = {\n // ...this.opts.headers,\n // Authorization: `Bearer ${token}`,\n // }\n // }\n\n async request(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n url: string,\n data?: any,\n reqOptions: HTTPRequestOptions = {\n sendThroughProxy: false,\n },\n ) {\n try {\n const response = await axios({\n method,\n url: this.parseUrl(url, reqOptions),\n headers: this.parseHeaders(reqOptions.headers || {}, reqOptions.accessToken),\n ...(data && { data }), // Only include `data` for methods that support it\n })\n\n return response\n } catch (err) {\n if (axios.isAxiosError(err) && err.response) {\n throw new Error(\n `HTTP ${err.response.status}: ${err.response.data?.message || 'Request failed'}`,\n )\n }\n throw new Error('Network error or request failed without a response.')\n }\n }\n\n async get(url: string, reqOptions: HTTPRequestOptions = { sendThroughProxy: true }) {\n return this.request('GET', url, undefined, reqOptions)\n }\n\n async post(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('POST', url, data, reqOptions)\n }\n\n async put(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('PUT', url, data, reqOptions)\n }\n\n async delete(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('DELETE', url, data, reqOptions)\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"nvm-api.js","sourceRoot":"","sources":["../../src/api/nvm-api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAA;AAC7D,MAAM,CAAC,MAAM,sBAAsB,GAAG,yBAAyB,CAAA;AAC/D,MAAM,CAAC,MAAM,gCAAgC,GAAG,+BAA+B,CAAA;AAC/E,MAAM,CAAC,MAAM,iBAAiB,GAAG,kCAAkC,CAAA;AACnE,MAAM,CAAC,MAAM,oBAAoB,GAAG,kCAAkC,CAAA;AACtE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wCAAwC,CAAA;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,qEAAqE;AACrE,MAAM,CAAC,MAAM,kBAAkB,GAAG,yBAAyB,CAAA;AAC3D,MAAM,CAAC,MAAM,gBAAgB,GAAG,gCAAgC,CAAA;AAChE,MAAM,CAAC,MAAM,iBAAiB,GAAG,wBAAwB,CAAA;AACzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,uCAAuC,CAAA;AAC9E,MAAM,CAAC,MAAM,kBAAkB,GAAG,sCAAsC,CAAA;AACxE,MAAM,CAAC,MAAM,iBAAiB,GAAG,6BAA6B,CAAA;AAC9D,MAAM,CAAC,MAAM,2BAA2B,GAAG,sCAAsC,CAAA;AACjF,MAAM,CAAC,MAAM,sBAAsB,GAAG,+CAA+C,CAAA;AACrF,MAAM,CAAC,MAAM,yBAAyB,GAAG,+CAA+C,CAAA;AACxF,MAAM,CAAC,MAAM,oBAAoB,GAAG,uDAAuD,CAAA;AAC3F,MAAM,CAAC,MAAM,wBAAwB,GAAG,6CAA6C,CAAA;AACrF,MAAM,CAAC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U,CAAC,CAAA;IACtD,CAAC;CACF","sourcesContent":["import axios from 'axios'\n\nexport const API_URL_REGISTER_PLAN = '/api/v1/protocol/plans'\nexport const API_URL_REGISTER_AGENT = '/api/v1/protocol/agents'\nexport const API_URL_REGISTER_AGENTS_AND_PLAN = '/api/v1/protocol/agents/plans'\nexport const API_URL_GET_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_UPDATE_AGENT = '/api/v1/protocol/agents/:agentId'\nexport const API_URL_GET_AGENT_PLANS = '/api/v1/protocol/agents/:agentId/plans'\n// GET: the caller's own agents (?orgId= scopes to an org the caller belongs to).\n// Same path as API_URL_REGISTER_AGENT (disambiguated by GET vs POST); mirrors\n// the existing API_URL_REGISTER_PLAN / API_URL_GET_PLANS pair below.\nexport const API_URL_GET_AGENTS = '/api/v1/protocol/agents'\nexport const API_URL_GET_PLAN = '/api/v1/protocol/plans/:planId'\nexport const API_URL_GET_PLANS = '/api/v1/protocol/plans'\nexport const API_URL_GET_PLAN_AGENTS = '/api/v1/protocol/plans/:planId/agents'\nexport const API_URL_ORDER_PLAN = '/api/v1/protocol/plans/:planId/order'\nexport const API_URL_MINT_PLAN = '/api/v1/protocol/plans/mint'\nexport const API_URL_MINT_EXPIRABLE_PLAN = '/api/v1/protocol/plans/mintExpirable'\nexport const API_URL_ADD_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_REMOVE_PLAN_AGENT = '/api/v1/protocol/agents/:agentId/plan/:planId'\nexport const API_URL_PLAN_BALANCE = '/api/v1/protocol/plans/:planId/balance/:holderAddress'\nexport const API_URL_INITIALIZE_AGENT = '/api/v1/protocol/agents/initialize/:agentId'\nexport const API_URL_SIMULATE_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/start'\nexport const API_URL_SIMULATE_REDEEM_AGENT_REQUEST = '/api/v1/protocol/agents/simulate/finish'\nexport const API_URL_TRACK_AGENT_SUB_TASK = '/api/v1/protocol/agent-sub-tasks'\nexport const API_URL_VALIDATE_AGENT_ACCESS_TOKEN = '/api/v1/protocol/token/validate/:agentId'\nexport const API_URL_CREATE_PERMISSION = '/api/v1/x402/permissions'\nexport const API_URL_VERIFY_PERMISSIONS = '/api/v1/x402/verify'\nexport const API_URL_SETTLE_PERMISSIONS = '/api/v1/x402/settle'\n// MPP seller/buyer surface. Sibling routes of /api/v1/x402, never children:\n// an MPP access token is byte-identical to an x402 one on the wire, so the\n// route is what fixes the protocol. See nvm-monorepo#2641.\nexport const API_URL_MPP_CREATE_PERMISSION = '/api/v1/mpp/permissions'\nexport const API_URL_MPP_CHALLENGE = '/api/v1/mpp/challenge'\nexport const API_URL_MPP_VERIFY = '/api/v1/mpp/verify'\nexport const API_URL_MPP_SETTLE = '/api/v1/mpp/settle'\nexport const API_URL_STRIPE_CHECKOUT = '/api/v1/fiat/stripe/payment'\nexport const API_URL_CREATE_USER = '/api/v1/organizations/account'\nexport const API_URL_GET_MEMBERS = '/api/v1/organizations/members'\nexport const API_URL_MY_MEMBERSHIPS = '/api/v1/organizations/my-memberships'\nexport const API_URL_ORG_ACTIVITY = '/api/v1/organizations/:orgId/activity'\nexport const API_URL_CONNECT_STRIPE_ACCOUNT = '/api/v1/fiat/stripe/account'\n\nexport interface BackendApiOptions {\n /**\n * The host of the backend server\n */\n backendHost: string\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n apiKey?: string\n\n /**\n * The host of the Nevermined Proxy\n */\n proxyHost?: string\n\n /**\n * Additional headers to send with the requests\n */\n headers?: { [key: string]: string }\n}\n\nexport class HTTPRequestOptions {\n accessToken?: string\n sendThroughProxy = true\n proxyHost?: string = undefined\n headers?: { [key: string]: string } = {}\n}\n\nexport abstract class AbstractHTTPClient {\n // protected opts: BackendApiOptions\n // private hasKey = false\n // private agentId = ''\n\n // constructor(opts: BackendApiOptions) {\n // const defaultHeaders = {\n // Accept: 'application/json',\n // ...opts.headers,\n // ...(opts.apiKey && { Authorization: `Bearer ${opts.apiKey}` }),\n // }\n\n // this.opts = {\n // ...opts,\n // headers: defaultHeaders,\n // }\n\n // try {\n // if (this.opts.apiKey && this.opts.apiKey.length > 0) {\n // const jwt = decodeJwt(this.opts.apiKey)\n // if (isEthereumAddress(jwt.sub)) {\n // this.hasKey = true\n // }\n // }\n // } catch {\n // this.hasKey = false\n // }\n\n // let backendUrl\n // try {\n // backendUrl = new URL(this.opts.backendHost)\n // this.opts.backendHost = backendUrl.origin\n // } catch (error) {\n // throw new Error(`Invalid URL: ${this.opts.backendHost} - ${(error as Error).message}`)\n // }\n // }\n\n constructor() {\n // Empty constructor - required for abstract class implementation\n }\n\n parseUrl(urlRequested: string, reqOptions: HTTPRequestOptions) {\n let _host: URL\n if (reqOptions.sendThroughProxy) {\n if (!reqOptions.proxyHost)\n throw new Error('Proxy host is required when sendThroughProxy is true')\n return `${new URL(reqOptions.proxyHost).origin}${new URL(urlRequested).href}`\n } else {\n return urlRequested\n }\n }\n\n parseHeaders(requestHeaders: { [key: string]: string }, accessToken?: string) {\n return {\n ...(accessToken && { Authorization: `Bearer ${accessToken}` }),\n ...requestHeaders,\n }\n }\n\n // setBearerToken(token: string) {\n // this.opts.headers = {\n // ...this.opts.headers,\n // Authorization: `Bearer ${token}`,\n // }\n // }\n\n async request(\n method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH',\n url: string,\n data?: any,\n reqOptions: HTTPRequestOptions = {\n sendThroughProxy: false,\n },\n ) {\n try {\n const response = await axios({\n method,\n url: this.parseUrl(url, reqOptions),\n headers: this.parseHeaders(reqOptions.headers || {}, reqOptions.accessToken),\n ...(data && { data }), // Only include `data` for methods that support it\n })\n\n return response\n } catch (err) {\n if (axios.isAxiosError(err) && err.response) {\n throw new Error(\n `HTTP ${err.response.status}: ${err.response.data?.message || 'Request failed'}`,\n )\n }\n throw new Error('Network error or request failed without a response.')\n }\n }\n\n async get(url: string, reqOptions: HTTPRequestOptions = { sendThroughProxy: true }) {\n return this.request('GET', url, undefined, reqOptions)\n }\n\n async post(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('POST', url, data, reqOptions)\n }\n\n async put(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('PUT', url, data, reqOptions)\n }\n\n async delete(url: string, data: any, reqOptions: HTTPRequestOptions) {\n return this.request('DELETE', url, data, reqOptions)\n }\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PaymentOptions } from '../../common/types.js';
|
|
2
2
|
import { BasePaymentsAPI } from '../base-payments.js';
|
|
3
|
-
import { CreateUserResponse, MyMembership, OrganizationActivityFilters, OrganizationActivityPage, OrganizationMemberRole, OrganizationMembersResponse, StripeCheckoutResult } from './types.js';
|
|
3
|
+
import { CreateUserResponse, CustomerOnboardingResponse, MyMembership, OrganizationActivityFilters, OrganizationActivityPage, OrganizationMemberRole, OrganizationMembersResponse, StripeCheckoutResult } from './types.js';
|
|
4
4
|
export declare class OrganizationsAPI extends BasePaymentsAPI {
|
|
5
5
|
static getInstance(options: PaymentOptions): OrganizationsAPI;
|
|
6
6
|
/**
|
|
@@ -11,6 +11,24 @@ export declare class OrganizationsAPI extends BasePaymentsAPI {
|
|
|
11
11
|
* @returns The created member
|
|
12
12
|
*/
|
|
13
13
|
createMember(userId: string, userEmail?: string, userRole?: OrganizationMemberRole): Promise<CreateUserResponse>;
|
|
14
|
+
/**
|
|
15
|
+
* Onboard a **white-label customer** into the organization (#2418).
|
|
16
|
+
*
|
|
17
|
+
* Provisions a Nevermined account for `email` under the caller's organization
|
|
18
|
+
* without consuming a member seat, and returns a usable, scoped NVM API key
|
|
19
|
+
* the org can use to transparently act on the customer's behalf (purchase
|
|
20
|
+
* plans / redeem credits). The customer is recorded in the org's Customers
|
|
21
|
+
* list.
|
|
22
|
+
*
|
|
23
|
+
* If the email already belongs to an account the org does NOT own, no key is
|
|
24
|
+
* issued: an email challenge is sent to the owner and the result carries
|
|
25
|
+
* `consentRequired: true`. Call again once the owner has consented to complete
|
|
26
|
+
* onboarding.
|
|
27
|
+
*
|
|
28
|
+
* @param email - The customer's email address.
|
|
29
|
+
* @returns The onboarding result — either `{ nvmApiKey, userId, userWallet, isCustomer, customerRecorded }` or `{ consentRequired: true }`.
|
|
30
|
+
*/
|
|
31
|
+
onboardCustomer(email: string): Promise<CustomerOnboardingResponse>;
|
|
14
32
|
/**
|
|
15
33
|
*
|
|
16
34
|
* @param role - The role of the members to get
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizations-api.d.ts","sourceRoot":"","sources":["../../../src/api/organizations-api/organizations-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAQrD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB;IAI7D;;;;;;OAMG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,OAAO,CAAC,kBAAkB,CAAC;IAqB9B;;;;;;;OAOG;IACG,UAAU,CACd,IAAI,CAAC,EAAE,sBAAsB,EAC7B,QAAQ,CAAC,EAAE,OAAO,EAClB,IAAI,SAAI,EACR,MAAM,SAAM,GACX,OAAO,CAAC,2BAA2B,CAAC;IAuBvC;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAYjD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,uBAAuB,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,wBAAwB,CAAC;IAiCpC;;;;;;;OAOG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC;CAuBjC"}
|
|
1
|
+
{"version":3,"file":"organizations-api.d.ts","sourceRoot":"","sources":["../../../src/api/organizations-api/organizations-api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAQrD,OAAO,EACL,kBAAkB,EAClB,0BAA0B,EAC1B,YAAY,EACZ,2BAA2B,EAC3B,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,oBAAoB,EACrB,MAAM,YAAY,CAAA;AAEnB,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,MAAM,CAAC,WAAW,CAAC,OAAO,EAAE,cAAc,GAAG,gBAAgB;IAI7D;;;;;;OAMG;IACG,YAAY,CAChB,MAAM,EAAE,MAAM,EACd,SAAS,CAAC,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,sBAAsB,GAChC,OAAO,CAAC,kBAAkB,CAAC;IAqB9B;;;;;;;;;;;;;;;;OAgBG;IACG,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC;IAwCzE;;;;;;;OAOG;IACG,UAAU,CACd,IAAI,CAAC,EAAE,sBAAsB,EAC7B,QAAQ,CAAC,EAAE,OAAO,EAClB,IAAI,SAAI,EACR,MAAM,SAAM,GACX,OAAO,CAAC,2BAA2B,CAAC;IAuBvC;;;;;;;;;;;;;;;;;OAiBG;IACG,gBAAgB,IAAI,OAAO,CAAC,YAAY,EAAE,CAAC;IAYjD;;;;;;;;;;;;;;;;;;;;OAoBG;IACG,uBAAuB,CAC3B,KAAK,EAAE,MAAM,EACb,OAAO,GAAE,2BAAgC,GACxC,OAAO,CAAC,wBAAwB,CAAC;IAiCpC;;;;;;;OAOG;IACG,oBAAoB,CACxB,SAAS,EAAE,MAAM,EACjB,eAAe,EAAE,MAAM,EACvB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,oBAAoB,CAAC;CAuBjC"}
|
|
@@ -31,6 +31,59 @@ export class OrganizationsAPI extends BasePaymentsAPI {
|
|
|
31
31
|
nvmApiKey: data.walletResult.hash,
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Onboard a **white-label customer** into the organization (#2418).
|
|
36
|
+
*
|
|
37
|
+
* Provisions a Nevermined account for `email` under the caller's organization
|
|
38
|
+
* without consuming a member seat, and returns a usable, scoped NVM API key
|
|
39
|
+
* the org can use to transparently act on the customer's behalf (purchase
|
|
40
|
+
* plans / redeem credits). The customer is recorded in the org's Customers
|
|
41
|
+
* list.
|
|
42
|
+
*
|
|
43
|
+
* If the email already belongs to an account the org does NOT own, no key is
|
|
44
|
+
* issued: an email challenge is sent to the owner and the result carries
|
|
45
|
+
* `consentRequired: true`. Call again once the owner has consented to complete
|
|
46
|
+
* onboarding.
|
|
47
|
+
*
|
|
48
|
+
* @param email - The customer's email address.
|
|
49
|
+
* @returns The onboarding result — either `{ nvmApiKey, userId, userWallet, isCustomer, customerRecorded }` or `{ consentRequired: true }`.
|
|
50
|
+
*/
|
|
51
|
+
async onboardCustomer(email) {
|
|
52
|
+
const body = { email, as: 'customer' };
|
|
53
|
+
const options = this.getBackendHTTPOptions('POST', body);
|
|
54
|
+
const url = new URL(API_URL_CREATE_USER, this.environment.backend);
|
|
55
|
+
const response = await fetch(url, options);
|
|
56
|
+
if (!response.ok) {
|
|
57
|
+
const error = await response.json().catch(() => ({ message: 'Unknown error' }));
|
|
58
|
+
throw PaymentsError.fromBackend('Unable to onboard customer', error);
|
|
59
|
+
}
|
|
60
|
+
const wallet = (await response.json())?.walletResult ?? {};
|
|
61
|
+
// Existing, non-owned account: opaque consent-pending outcome. The backend
|
|
62
|
+
// signals it with HTTP 202 and `walletResult.consentRequired`; treat either
|
|
63
|
+
// as authoritative so a body-parsing quirk can't slip through as "success".
|
|
64
|
+
// No identity or key is disclosed.
|
|
65
|
+
if (response.status === 202 || wallet.consentRequired) {
|
|
66
|
+
return { consentRequired: true };
|
|
67
|
+
}
|
|
68
|
+
// New account or the org's returning customer: the Bearer MUST be present.
|
|
69
|
+
// The backend returns the usable credential as `walletResult.hash`
|
|
70
|
+
// (`<env>:<JWT>`) — the sibling `nvmApiKey` is the encrypted server-side
|
|
71
|
+
// blob and is NOT a valid Bearer. Surface `hash` as `nvmApiKey`, exactly as
|
|
72
|
+
// createMember does. A 2xx without a hash means a partial/unexpected payload
|
|
73
|
+
// — fail loudly rather than hand back a "success" carrying no credential.
|
|
74
|
+
if (!wallet.hash) {
|
|
75
|
+
throw PaymentsError.internal('Customer onboarding did not return an API key (unexpected backend response)');
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
consentRequired: false,
|
|
79
|
+
nvmApiKey: wallet.hash,
|
|
80
|
+
userId: wallet.userId,
|
|
81
|
+
userWallet: wallet.userWallet,
|
|
82
|
+
isCustomer: wallet.isCustomer,
|
|
83
|
+
customerRecorded: wallet.customerRecorded,
|
|
84
|
+
expiresAt: wallet.expiresAt,
|
|
85
|
+
};
|
|
86
|
+
}
|
|
34
87
|
/**
|
|
35
88
|
*
|
|
36
89
|
* @param role - The role of the members to get
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"organizations-api.js","sourceRoot":"","sources":["../../../src/api/organizations-api/organizations-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACrD,OAAO,EACL,8BAA8B,EAC9B,mBAAmB,EACnB,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,GACrB,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Q,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;SACvD,CAAA;IACH,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,oBAAoB,CACxB,SAAiB,EACjB,eAAuB,EACvB,SAAiB;QAEjB,MAAM,IAAI,GAAG;YACX,SAAS;YACT,eAAe;YACf,SAAS;SACV,CAAA;QACD,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,8BAA8B,EAAE,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;QAC7E,MAAM,OAAO,GAAG,IAAI,CAAC,qBAAqB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;QACxD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,OAAO,EAAE,eAAe,EAAE,CAAC,CAAC,CAAA;YAC/E,MAAM,aAAa,CAAC,WAAW,CAAC,+BAA+B,EAAE,KAAK,CAAC,CAAA;QACzE,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAClC,OAAO;YACL,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../../common/payments.error.js'\nimport { PaymentOptions } from '../../common/types.js'\nimport { BasePaymentsAPI } from '../base-payments.js'\nimport {\n API_URL_CONNECT_STRIPE_ACCOUNT,\n API_URL_CREATE_USER,\n API_URL_GET_MEMBERS,\n API_URL_MY_MEMBERSHIPS,\n API_URL_ORG_ACTIVITY,\n} from '../nvm-api.js'\nimport {\n CreateUserResponse,\n MyMembership,\n OrganizationActivityFilters,\n OrganizationActivityPage,\n OrganizationMemberRole,\n OrganizationMembersResponse,\n StripeCheckoutResult,\n} from './types.js'\n\nexport class OrganizationsAPI extends BasePaymentsAPI {\n static getInstance(options: PaymentOptions): OrganizationsAPI {\n return new OrganizationsAPI(options)\n }\n\n /**\n * Create a new member in the organization\n * @param userId - The unique external ID of the new member\n * @param userEmail - The email of the new member\n * @param userRole - The role of the new member\n * @returns The created member\n */\n async createMember(\n userId: string,\n userEmail?: string,\n userRole?: OrganizationMemberRole,\n ): Promise<CreateUserResponse> {\n const body = {\n uniqueExternalId: userId,\n email: userEmail,\n role: userRole,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_CREATE_USER, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to create user', error)\n }\n\n const data = await response.json()\n return {\n ...data.walletResult,\n nvmApiKey: data.walletResult.hash,\n }\n }\n\n /**\n *\n * @param role - The role of the members to get\n * @param isActive - The active status of the members to get\n * @param page - The page of the members to get\n * @param offset - The number of members to get per page\n * @returns The list of members\n */\n async getMembers(\n role?: OrganizationMemberRole,\n isActive?: boolean,\n page = 1,\n offset = 100,\n ): Promise<OrganizationMembersResponse> {\n const body = {\n role,\n isActive,\n page,\n offset,\n }\n const url = new URL(API_URL_GET_MEMBERS, this.environment.backend)\n const options = this.getBackendHTTPOptions('POST', body)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to get members', error)\n }\n\n const data = await response.json()\n return {\n members: data.members,\n total: data.totalResults,\n }\n }\n\n /**\n * Lists every organization the authenticated user is an active member of,\n * with their role and the organization's tier.\n *\n * Powers workspace pickers in third-party tools built on the SDK, and the\n * \"where will this publish?\" UX when a user belongs to multiple orgs.\n *\n * @returns An array of {@link MyMembership} — empty when the user has no\n * active memberships and operates as a personal account.\n *\n * @example\n * ```ts\n * const memberships = await payments.organizations.getMyMemberships()\n * for (const m of memberships) {\n * console.log(`${m.orgName} — ${m.role}`)\n * }\n * ```\n */\n async getMyMemberships(): Promise<MyMembership[]> {\n const url = new URL(API_URL_MY_MEMBERSHIPS, this.environment.backend)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to fetch memberships', error)\n }\n const data = (await response.json()) as MyMembership[]\n return Array.isArray(data) ? data : []\n }\n\n /**\n * Lists events emitted into the activity feed of an organization the\n * caller is an active member of (member invites, customer events,\n * subscription transitions, webhook deliveries, …).\n *\n * Requires the caller to be a Member or Admin of `orgId`; the backend\n * returns 403 otherwise. Premium+ entitlement is enforced server-side.\n *\n * @param orgId - The organization id (e.g. `org-…`) whose feed to read.\n * @param filters - Optional filter set — see {@link OrganizationActivityFilters}.\n * @returns A paginated {@link OrganizationActivityPage}.\n *\n * @example\n * ```ts\n * const page = await payments.organizations.getOrganizationActivity(orgId, {\n * eventType: OrganizationActivityEventType.MemberInvited,\n * page: 1,\n * limit: 25,\n * })\n * ```\n */\n async getOrganizationActivity(\n orgId: string,\n filters: OrganizationActivityFilters = {},\n ): Promise<OrganizationActivityPage> {\n if (!orgId) {\n throw new PaymentsError('orgId is required')\n }\n const params = new URLSearchParams()\n if (filters.eventType !== undefined) {\n const eventType = Array.isArray(filters.eventType)\n ? filters.eventType.map(String).join(',')\n : String(filters.eventType)\n if (eventType.length > 0) params.set('eventType', eventType)\n }\n if (filters.actorUserId) params.set('actorUserId', filters.actorUserId)\n if (filters.from) params.set('from', filters.from)\n if (filters.to) params.set('to', filters.to)\n if (filters.page !== undefined) params.set('page', String(filters.page))\n if (filters.limit !== undefined) params.set('limit', String(filters.limit))\n\n const path = API_URL_ORG_ACTIVITY.replace(':orgId', encodeURIComponent(orgId))\n const queryString = params.toString()\n const url = new URL(queryString ? `${path}?${queryString}` : path, this.environment.backend)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to fetch organization activity', error)\n }\n const data = (await response.json()) as Partial<OrganizationActivityPage>\n return {\n items: Array.isArray(data.items) ? data.items : [],\n total: typeof data.total === 'number' ? data.total : 0,\n }\n }\n\n /**\n * Connect user with Stripe\n * @param userEmail - The email of the user\n * @param userCountryCode - The country code of the user\n * @param returnUrl - The return URL after the Stripe connection is completed\n * @returns The Stripe checkout result including the stripe account link, stripe account id, user id, user country code, link created at and link expires at.\n * The stripe account link is the link that the user needs to click to connect with Stripe.\n */\n async connectStripeAccount(\n userEmail: string,\n userCountryCode: string,\n returnUrl: string,\n ): Promise<StripeCheckoutResult> {\n const body = {\n userEmail,\n userCountryCode,\n returnUrl,\n }\n const url = new URL(API_URL_CONNECT_STRIPE_ACCOUNT, this.environment.backend)\n const options = this.getBackendHTTPOptions('POST', body)\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to connect with Stripe', error)\n }\n const data = await response.json()\n return {\n stripeAccountLink: data.stripeAccountLink,\n stripeAccountId: data.stripeAccountId,\n userId: data.userId,\n userCountryCode: data.userCountryCode,\n linkCreatedAt: data.linkCreatedAt,\n linkExpiresAt: data.linkExpiresAt,\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"organizations-api.js","sourceRoot":"","sources":["../../../src/api/organizations-api/organizations-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAA;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,C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AAe;YACrC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,aAAa,EAAE,IAAI,CAAC,aAAa;SAClC,CAAA;IACH,CAAC;CACF","sourcesContent":["import { PaymentsError } from '../../common/payments.error.js'\nimport { PaymentOptions } from '../../common/types.js'\nimport { BasePaymentsAPI } from '../base-payments.js'\nimport {\n API_URL_CONNECT_STRIPE_ACCOUNT,\n API_URL_CREATE_USER,\n API_URL_GET_MEMBERS,\n API_URL_MY_MEMBERSHIPS,\n API_URL_ORG_ACTIVITY,\n} from '../nvm-api.js'\nimport {\n CreateUserResponse,\n CustomerOnboardingResponse,\n MyMembership,\n OrganizationActivityFilters,\n OrganizationActivityPage,\n OrganizationMemberRole,\n OrganizationMembersResponse,\n StripeCheckoutResult,\n} from './types.js'\n\nexport class OrganizationsAPI extends BasePaymentsAPI {\n static getInstance(options: PaymentOptions): OrganizationsAPI {\n return new OrganizationsAPI(options)\n }\n\n /**\n * Create a new member in the organization\n * @param userId - The unique external ID of the new member\n * @param userEmail - The email of the new member\n * @param userRole - The role of the new member\n * @returns The created member\n */\n async createMember(\n userId: string,\n userEmail?: string,\n userRole?: OrganizationMemberRole,\n ): Promise<CreateUserResponse> {\n const body = {\n uniqueExternalId: userId,\n email: userEmail,\n role: userRole,\n }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_CREATE_USER, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to create user', error)\n }\n\n const data = await response.json()\n return {\n ...data.walletResult,\n nvmApiKey: data.walletResult.hash,\n }\n }\n\n /**\n * Onboard a **white-label customer** into the organization (#2418).\n *\n * Provisions a Nevermined account for `email` under the caller's organization\n * without consuming a member seat, and returns a usable, scoped NVM API key\n * the org can use to transparently act on the customer's behalf (purchase\n * plans / redeem credits). The customer is recorded in the org's Customers\n * list.\n *\n * If the email already belongs to an account the org does NOT own, no key is\n * issued: an email challenge is sent to the owner and the result carries\n * `consentRequired: true`. Call again once the owner has consented to complete\n * onboarding.\n *\n * @param email - The customer's email address.\n * @returns The onboarding result — either `{ nvmApiKey, userId, userWallet, isCustomer, customerRecorded }` or `{ consentRequired: true }`.\n */\n async onboardCustomer(email: string): Promise<CustomerOnboardingResponse> {\n const body = { email, as: 'customer' }\n const options = this.getBackendHTTPOptions('POST', body)\n const url = new URL(API_URL_CREATE_USER, this.environment.backend)\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to onboard customer', error)\n }\n\n const wallet = (await response.json())?.walletResult ?? {}\n // Existing, non-owned account: opaque consent-pending outcome. The backend\n // signals it with HTTP 202 and `walletResult.consentRequired`; treat either\n // as authoritative so a body-parsing quirk can't slip through as \"success\".\n // No identity or key is disclosed.\n if (response.status === 202 || wallet.consentRequired) {\n return { consentRequired: true }\n }\n // New account or the org's returning customer: the Bearer MUST be present.\n // The backend returns the usable credential as `walletResult.hash`\n // (`<env>:<JWT>`) — the sibling `nvmApiKey` is the encrypted server-side\n // blob and is NOT a valid Bearer. Surface `hash` as `nvmApiKey`, exactly as\n // createMember does. A 2xx without a hash means a partial/unexpected payload\n // — fail loudly rather than hand back a \"success\" carrying no credential.\n if (!wallet.hash) {\n throw PaymentsError.internal(\n 'Customer onboarding did not return an API key (unexpected backend response)',\n )\n }\n return {\n consentRequired: false,\n nvmApiKey: wallet.hash,\n userId: wallet.userId,\n userWallet: wallet.userWallet,\n isCustomer: wallet.isCustomer,\n customerRecorded: wallet.customerRecorded,\n expiresAt: wallet.expiresAt,\n }\n }\n\n /**\n *\n * @param role - The role of the members to get\n * @param isActive - The active status of the members to get\n * @param page - The page of the members to get\n * @param offset - The number of members to get per page\n * @returns The list of members\n */\n async getMembers(\n role?: OrganizationMemberRole,\n isActive?: boolean,\n page = 1,\n offset = 100,\n ): Promise<OrganizationMembersResponse> {\n const body = {\n role,\n isActive,\n page,\n offset,\n }\n const url = new URL(API_URL_GET_MEMBERS, this.environment.backend)\n const options = this.getBackendHTTPOptions('POST', body)\n\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to get members', error)\n }\n\n const data = await response.json()\n return {\n members: data.members,\n total: data.totalResults,\n }\n }\n\n /**\n * Lists every organization the authenticated user is an active member of,\n * with their role and the organization's tier.\n *\n * Powers workspace pickers in third-party tools built on the SDK, and the\n * \"where will this publish?\" UX when a user belongs to multiple orgs.\n *\n * @returns An array of {@link MyMembership} — empty when the user has no\n * active memberships and operates as a personal account.\n *\n * @example\n * ```ts\n * const memberships = await payments.organizations.getMyMemberships()\n * for (const m of memberships) {\n * console.log(`${m.orgName} — ${m.role}`)\n * }\n * ```\n */\n async getMyMemberships(): Promise<MyMembership[]> {\n const url = new URL(API_URL_MY_MEMBERSHIPS, this.environment.backend)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to fetch memberships', error)\n }\n const data = (await response.json()) as MyMembership[]\n return Array.isArray(data) ? data : []\n }\n\n /**\n * Lists events emitted into the activity feed of an organization the\n * caller is an active member of (member invites, customer events,\n * subscription transitions, webhook deliveries, …).\n *\n * Requires the caller to be a Member or Admin of `orgId`; the backend\n * returns 403 otherwise. Premium+ entitlement is enforced server-side.\n *\n * @param orgId - The organization id (e.g. `org-…`) whose feed to read.\n * @param filters - Optional filter set — see {@link OrganizationActivityFilters}.\n * @returns A paginated {@link OrganizationActivityPage}.\n *\n * @example\n * ```ts\n * const page = await payments.organizations.getOrganizationActivity(orgId, {\n * eventType: OrganizationActivityEventType.MemberInvited,\n * page: 1,\n * limit: 25,\n * })\n * ```\n */\n async getOrganizationActivity(\n orgId: string,\n filters: OrganizationActivityFilters = {},\n ): Promise<OrganizationActivityPage> {\n if (!orgId) {\n throw new PaymentsError('orgId is required')\n }\n const params = new URLSearchParams()\n if (filters.eventType !== undefined) {\n const eventType = Array.isArray(filters.eventType)\n ? filters.eventType.map(String).join(',')\n : String(filters.eventType)\n if (eventType.length > 0) params.set('eventType', eventType)\n }\n if (filters.actorUserId) params.set('actorUserId', filters.actorUserId)\n if (filters.from) params.set('from', filters.from)\n if (filters.to) params.set('to', filters.to)\n if (filters.page !== undefined) params.set('page', String(filters.page))\n if (filters.limit !== undefined) params.set('limit', String(filters.limit))\n\n const path = API_URL_ORG_ACTIVITY.replace(':orgId', encodeURIComponent(orgId))\n const queryString = params.toString()\n const url = new URL(queryString ? `${path}?${queryString}` : path, this.environment.backend)\n const options = this.getBackendHTTPOptions('GET')\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to fetch organization activity', error)\n }\n const data = (await response.json()) as Partial<OrganizationActivityPage>\n return {\n items: Array.isArray(data.items) ? data.items : [],\n total: typeof data.total === 'number' ? data.total : 0,\n }\n }\n\n /**\n * Connect user with Stripe\n * @param userEmail - The email of the user\n * @param userCountryCode - The country code of the user\n * @param returnUrl - The return URL after the Stripe connection is completed\n * @returns The Stripe checkout result including the stripe account link, stripe account id, user id, user country code, link created at and link expires at.\n * The stripe account link is the link that the user needs to click to connect with Stripe.\n */\n async connectStripeAccount(\n userEmail: string,\n userCountryCode: string,\n returnUrl: string,\n ): Promise<StripeCheckoutResult> {\n const body = {\n userEmail,\n userCountryCode,\n returnUrl,\n }\n const url = new URL(API_URL_CONNECT_STRIPE_ACCOUNT, this.environment.backend)\n const options = this.getBackendHTTPOptions('POST', body)\n const response = await fetch(url, options)\n if (!response.ok) {\n const error = await response.json().catch(() => ({ message: 'Unknown error' }))\n throw PaymentsError.fromBackend('Unable to connect with Stripe', error)\n }\n const data = await response.json()\n return {\n stripeAccountLink: data.stripeAccountLink,\n stripeAccountId: data.stripeAccountId,\n userId: data.userId,\n userCountryCode: data.userCountryCode,\n linkCreatedAt: data.linkCreatedAt,\n linkExpiresAt: data.linkExpiresAt,\n }\n }\n}\n"]}
|
|
@@ -26,6 +26,39 @@ export type CreateUserResponse = {
|
|
|
26
26
|
userWallet: string;
|
|
27
27
|
alreadyMember: boolean;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Result of onboarding a white-label customer via
|
|
31
|
+
* `POST /organizations/account` with `as: 'customer'` (nvm-monorepo #2418).
|
|
32
|
+
*
|
|
33
|
+
* A discriminated union on `consentRequired` — narrow on it to get the right
|
|
34
|
+
* shape with no impossible states:
|
|
35
|
+
* - `{ consentRequired: true }` — the email belongs to an account the org does
|
|
36
|
+
* NOT own. NO key is issued (HTTP 202); an email challenge was sent to the
|
|
37
|
+
* owner and the account's identity is deliberately withheld. Retry once they
|
|
38
|
+
* consent.
|
|
39
|
+
* - `{ consentRequired: false, nvmApiKey, ... }` — a new account or the org's
|
|
40
|
+
* returning customer. A usable, scoped `nvmApiKey` is always present and the
|
|
41
|
+
* customer is recorded in the org's Customers list.
|
|
42
|
+
*/
|
|
43
|
+
export type CustomerOnboardingResponse = {
|
|
44
|
+
consentRequired: true;
|
|
45
|
+
} | {
|
|
46
|
+
consentRequired: false;
|
|
47
|
+
/** The usable NVM API key (Bearer credential). Always present in this branch. */
|
|
48
|
+
nvmApiKey: string;
|
|
49
|
+
userId: string;
|
|
50
|
+
userWallet: string;
|
|
51
|
+
/** True when a key was issued for a customer (new account or renewal). */
|
|
52
|
+
isCustomer: boolean;
|
|
53
|
+
/** Whether the customer was written to the org's Customers list (best-effort). */
|
|
54
|
+
customerRecorded: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* ISO-8601 expiry of the credential (#2924). Track it and re-onboard to
|
|
57
|
+
* refresh before it lapses. Optional: returned for the credential outcome,
|
|
58
|
+
* but an older backend may omit it.
|
|
59
|
+
*/
|
|
60
|
+
expiresAt?: string;
|
|
61
|
+
};
|
|
29
62
|
/**
|
|
30
63
|
* A single organization the authenticated user is an active member of.
|
|
31
64
|
* Returned by `OrganizationsAPI.getMyMemberships()` and used by clients to
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/organizations-api/types.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;;;;;;;;;GAUG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,6CAA6C;IAC7C,KAAK,EAAE,MAAM,CAAA;IACb,wCAAwC;IACxC,OAAO,EAAE,MAAM,CAAA;IACf,8CAA8C;IAC9C,IAAI,EAAE,sBAAsB,CAAA;IAC5B,+DAA+D;IAC/D,OAAO,EAAE,gBAAgB,CAAA;IACzB,2DAA2D;IAC3D,OAAO,EAAE,OAAO,CAAA;IAChB;;;;;;OAMG;IACH,sBAAsB,EAAE,OAAO,CAAA;CAChC,CAAA;AAED;;;;;GAKG;AACH,oBAAY,6BAA6B;IAEvC,aAAa,mBAAmB;IAChC,YAAY,kBAAkB;IAC9B,iBAAiB,wBAAwB;IACzC,iBAAiB,uBAAuB;IACxC,iBAAiB,uBAAuB;IACxC,aAAa,mBAAmB;IAChC,iBAAiB,uBAAuB;IACxC,iBAAiB,uBAAuB;IAExC,YAAY,kBAAkB;IAC9B,WAAW,iBAAiB;IAC5B,aAAa,mBAAmB;IAEhC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EAAE,MAAM,CAAA;IACb,sCAAsC;IACtC,KAAK,CAAC,EAAE,MAAM,CAAA;CACf,CAAA;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,EAAE,EAAE,MAAM,CAAA;IACV,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,CAAA;IACnB,IAAI,EAAE,sBAAsB,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/api/organizations-api/types.ts"],"names":[],"mappings":"AAAA,oBAAY,sBAAsB;IAChC,KAAK,UAAU;IACf,MAAM,WAAW;IACjB,MAAM,WAAW;CAClB;AAED;;;;;;;;;;GAUG;AACH,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,KAAK,UAAU;CAChB;AAED,MAAM,MAAM,kBAAkB,GAAG;IAC/B,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,OAAO,CAAA;CACvB,CAAA;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,0BAA0B,GAClC;IAAE,eAAe,EAAE,IAA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EAAE,sBAAsB,CAAA;IAC5B,QAAQ,EAAE,OAAO,CAAA;CAClB,CAAA;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,OAAO,EAAE,kBAAkB,EAAE,CAAA;IAC7B,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB,iBAAiB,EAAE,MAAM,CAAA;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,eAAe,EAAE,MAAM,CAAA;IACvB,aAAa,EAAE,MAAM,CAAA;IACrB,aAAa,EAAE,MAAM,CAAA;CACtB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/organizations-api/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;AACnB,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;IACzB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/api/organizations-api/types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,sBAIX;AAJD,WAAY,sBAAsB;IAChC,yCAAe,CAAA;IACf,2CAAiB,CAAA;IACjB,2CAAiB,CAAA;AACnB,CAAC,EAJW,sBAAsB,KAAtB,sBAAsB,QAIjC;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;IACzB,qCAAiB,CAAA;IACjB,mCAAe,CAAA;AACjB,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAwED;;;;;GAKG;AACH,MAAM,CAAN,IAAY,6BA0BX;AA1BD,WAAY,6BAA6B;IACvC,uBAAuB;IACvB,iEAAgC,CAAA;IAChC,+DAA8B,CAAA;IAC9B,0EAAyC,CAAA;IACzC,yEAAwC,CAAA;IACxC,yEAAwC,CAAA;IACxC,iEAAgC,CAAA;IAChC,yEAAwC,CAAA;IACxC,yEAAwC,CAAA;IACxC,qBAAqB;IACrB,+DAA8B,CAAA;IAC9B,6DAA4B,CAAA;IAC5B,iEAAgC,CAAA;IAChC,qBAAqB;IACrB,iEAAgC,CAAA;IAChC,qEAAoC,CAAA;IACpC,yEAAwC,CAAA;IACxC,yBAAyB;IACzB,+EAA8C,CAAA;IAC9C,mFAAkD,CAAA;IAClD,+EAA8C,CAAA;IAC9C,2EAA0C,CAAA;IAC1C,mBAAmB;IACnB,uEAAsC,CAAA;IACtC,iEAAgC,CAAA;AAClC,CAAC,EA1BW,6BAA6B,KAA7B,6BAA6B,QA0BxC","sourcesContent":["export enum OrganizationMemberRole {\n Admin = 'Admin',\n Member = 'Member',\n Client = 'Client',\n}\n\n/**\n * Tier of an organization. Mirrors the backend `OrganizationType` enum at\n * `libs/commons/src/lib/types/types.ts` in nvm-monorepo.\n *\n * - `Premium` / `Enterprise` — the paid tiers from Epic #1339.\n * - `Lapsed` — an org whose paid subscription has expired; replaces the\n * retired `Free` bucket (the backend never emits `Free` for new rows).\n * - `Other` — legacy pre-tiered-pricing bucket still returned for orgs that\n * pre-date the tier system; inherits Premium-equivalent caps and features\n * server-side.\n */\nexport enum OrganizationType {\n Premium = 'Premium',\n Enterprise = 'Enterprise',\n Lapsed = 'Lapsed',\n Other = 'Other',\n}\n\nexport type CreateUserResponse = {\n nvmApiKey: string\n userId: string\n userWallet: string\n alreadyMember: boolean\n}\n\n/**\n * Result of onboarding a white-label customer via\n * `POST /organizations/account` with `as: 'customer'` (nvm-monorepo #2418).\n *\n * A discriminated union on `consentRequired` — narrow on it to get the right\n * shape with no impossible states:\n * - `{ consentRequired: true }` — the email belongs to an account the org does\n * NOT own. NO key is issued (HTTP 202); an email challenge was sent to the\n * owner and the account's identity is deliberately withheld. Retry once they\n * consent.\n * - `{ consentRequired: false, nvmApiKey, ... }` — a new account or the org's\n * returning customer. A usable, scoped `nvmApiKey` is always present and the\n * customer is recorded in the org's Customers list.\n */\nexport type CustomerOnboardingResponse =\n | { consentRequired: true }\n | {\n consentRequired: false\n /** The usable NVM API key (Bearer credential). Always present in this branch. */\n nvmApiKey: string\n userId: string\n userWallet: string\n /** True when a key was issued for a customer (new account or renewal). */\n isCustomer: boolean\n /** Whether the customer was written to the org's Customers list (best-effort). */\n customerRecorded: boolean\n /**\n * ISO-8601 expiry of the credential (#2924). Track it and re-onboard to\n * refresh before it lapses. Optional: returned for the credential outcome,\n * but an older backend may omit it.\n */\n expiresAt?: string\n }\n\n/**\n * A single organization the authenticated user is an active member of.\n * Returned by `OrganizationsAPI.getMyMemberships()` and used by clients to\n * power workspace pickers and \"where will this publish?\" UX.\n *\n * Shape mirrors `MyMembershipDto` in the Nevermined backend\n * (`apps/api/src/organizations/dto/my-membership.dto.ts`).\n */\nexport type MyMembership = {\n /** Stable organization id (e.g. `org-…`). */\n orgId: string\n /** Display name of the organization. */\n orgName: string\n /** Caller's role inside this organization. */\n role: OrganizationMemberRole\n /** Tier of the organization — see {@link OrganizationType}. */\n orgType: OrganizationType\n /** Whether the caller is an Admin of this organization. */\n isAdmin: boolean\n /**\n * `true` when the org has at least one `organizationSubscription` row —\n * the org has previously been associated with a paid tier (active,\n * past_due, trialing, lapsed, or canceled). Combined with\n * `orgType === Lapsed` it distinguishes \"subscription expired\" from\n * \"free org that never subscribed\".\n */\n hasSubscriptionHistory: boolean\n}\n\n/**\n * Event types emitted into the organization activity feed. Values mirror\n * the backend enum in `@nevermined-io/commons`. Stored on the wire as\n * dot-namespaced lowercase strings — the SDK accepts any string for\n * forward-compatibility when new event types are introduced server-side.\n */\nexport enum OrganizationActivityEventType {\n // Membership lifecycle\n MemberInvited = 'member.invited',\n MemberJoined = 'member.joined',\n MemberRoleChanged = 'member.role_changed',\n MemberDeactivated = 'member.deactivated',\n MemberReactivated = 'member.reactivated',\n MemberRemoved = 'member.removed',\n InvitationRevoked = 'invitation.revoked',\n InvitationExpired = 'invitation.expired',\n // Resource lifecycle\n AgentCreated = 'agent.created',\n PlanCreated = 'plan.created',\n PlanPurchased = 'plan.purchased',\n // Customer lifecycle\n CustomerAdded = 'customer.added',\n CustomerBlocked = 'customer.blocked',\n CustomerUnblocked = 'customer.unblocked',\n // Subscription lifecycle\n SubscriptionUpgraded = 'subscription.upgraded',\n SubscriptionDowngraded = 'subscription.downgraded',\n SubscriptionCanceled = 'subscription.canceled',\n SubscriptionLapsed = 'subscription.lapsed',\n // Webhook delivery\n WebhookDelivered = 'webhook.delivered',\n WebhookFailed = 'webhook.failed',\n}\n\n/**\n * The resource an activity event is about. `kind` describes the resource\n * type (`plan`, `agent`, `member`, `subscription`, `invitation`, `customer`,\n * `webhook`) and `id` is the resource's identifier. Extras vary by kind —\n * e.g. invitations include `role` + `email`, members include `role` +\n * `userId`, subscriptions include `tier`.\n */\nexport type OrganizationActivityEventSubject = {\n kind: string\n id: string\n [key: string]: unknown\n}\n\n/**\n * A single event emitted into the organization activity feed. Shape mirrors\n * `OrganizationActivityEventResponseDto` in the Nevermined backend.\n */\nexport type OrganizationActivityEvent = {\n /** Activity event ID (e.g. `ae-{uuid}`). */\n id: string\n /**\n * Backend-emitted event type. Use {@link OrganizationActivityEventType}\n * for known values; the field stays a plain string so a new server-side\n * event type doesn't break consumers.\n */\n eventType: OrganizationActivityEventType | string\n /** User who triggered the event, or `null` for system-emitted events. */\n actorUserId: string | null\n /** Resource the event is about — see {@link OrganizationActivityEventSubject}. */\n subject: OrganizationActivityEventSubject\n /** Optional payload (e.g. previous/current values on role/status changes). */\n metadata: Record<string, unknown> | null\n /** ISO-8601 timestamp of when the event occurred. */\n occurredAt: string\n}\n\n/**\n * Paginated page of activity events. The backend only echoes `items` and\n * `total`; `page` / `limit` are not in the response — they're the values\n * the caller asked for in {@link OrganizationActivityFilters}.\n */\nexport type OrganizationActivityPage = {\n items: OrganizationActivityEvent[]\n total: number\n}\n\n/** Filters accepted by `OrganizationsAPI.getOrganizationActivity`. */\nexport type OrganizationActivityFilters = {\n /**\n * Restrict to one or more event types. Accepts a single string, an enum\n * value, or an array (sent to the backend as a comma-separated list).\n */\n eventType?: OrganizationActivityEventType | string | Array<OrganizationActivityEventType | string>\n /** Restrict to events triggered by a specific user. */\n actorUserId?: string\n /** ISO-8601 lower bound (inclusive) on `occurredAt`. */\n from?: string\n /** ISO-8601 upper bound (exclusive) on `occurredAt`. */\n to?: string\n /** Page number — 1-based. */\n page?: number\n /** Page size — backend cap is 200. */\n limit?: number\n}\n\nexport type OrganizationMember = {\n createdAt: string\n updatedAt: string\n id: string\n userId: string\n orgId: string\n userAddress: string\n role: OrganizationMemberRole\n isActive: boolean\n}\n\nexport type OrganizationMembersResponse = {\n members: OrganizationMember[]\n total: number\n}\n\nexport type StripeCheckoutResult = {\n stripeAccountId: string\n stripeAccountLink: string\n userId: string\n userCountryCode: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n"]}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Callers can override the pin per `Payments` instance via
|
|
13
13
|
* `options.version`.
|
|
14
14
|
*
|
|
15
|
-
* @see https://
|
|
15
|
+
* @see https://nevermined.ai/docs/development-guide/api-versioning
|
|
16
16
|
*/
|
|
17
17
|
export declare const LOCKED_API_VERSION = "1.1";
|
|
18
18
|
/**
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* Callers can override the pin per `Payments` instance via
|
|
13
13
|
* `options.version`.
|
|
14
14
|
*
|
|
15
|
-
* @see https://
|
|
15
|
+
* @see https://nevermined.ai/docs/development-guide/api-versioning
|
|
16
16
|
*/
|
|
17
17
|
export const LOCKED_API_VERSION = '1.1';
|
|
18
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-version.js","sourceRoot":"","sources":["../../src/common/api-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA","sourcesContent":["/**\n * The Nevermined **backend API** version (nvm-monorepo MAJOR.MINOR) this SDK\n * release is built and tested against — NOT the version of the SDK package\n * itself. Every HTTP request the SDK sends to the Nevermined backend carries\n * this value in the {@link API_VERSION_HEADER} header so the backend keeps\n * serving the matching API contract even after newer backend deployments.\n *\n * Bump this constant deliberately, and only when the SDK targets a newer\n * backend contract: update the value, run the e2e suite against a staging\n * backend running that version, then cut a minor SDK release.\n *\n * Callers can override the pin per `Payments` instance via\n * `options.version`.\n *\n * @see https://
|
|
1
|
+
{"version":3,"file":"api-version.js","sourceRoot":"","sources":["../../src/common/api-version.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAA;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,oBAAoB,CAAA","sourcesContent":["/**\n * The Nevermined **backend API** version (nvm-monorepo MAJOR.MINOR) this SDK\n * release is built and tested against — NOT the version of the SDK package\n * itself. Every HTTP request the SDK sends to the Nevermined backend carries\n * this value in the {@link API_VERSION_HEADER} header so the backend keeps\n * serving the matching API contract even after newer backend deployments.\n *\n * Bump this constant deliberately, and only when the SDK targets a newer\n * backend contract: update the value, run the e2e suite against a staging\n * backend running that version, then cut a minor SDK release.\n *\n * Callers can override the pin per `Payments` instance via\n * `options.version`.\n *\n * @see https://nevermined.ai/docs/development-guide/api-versioning\n */\nexport const LOCKED_API_VERSION = '1.1'\n\n/**\n * Name of the HTTP request header carrying the backend API version the SDK\n * is pinned to. Sent on every backend call with the resolved instance\n * version (defaults to {@link LOCKED_API_VERSION}).\n */\nexport const API_VERSION_HEADER = 'Nevermined-Version'\n"]}
|
package/dist/common/types.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface PaymentOptions {
|
|
|
43
43
|
* built and tested against. Override only to deliberately target a
|
|
44
44
|
* different backend contract.
|
|
45
45
|
*
|
|
46
|
-
* @see https://
|
|
46
|
+
* @see https://nevermined.ai/docs/development-guide/api-versioning
|
|
47
47
|
*/
|
|
48
48
|
version?: string;
|
|
49
49
|
/**
|
package/dist/common/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AA2KA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,yEAAgB,CAAA;IAChB,iFAAoB,CAAA;AACtB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,yBAAa,CAAA;AACf,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAY,4CAA4C,CAAA;AACvF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAY,4CAA4C,CAAA;AAE/F;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,+DAAS,CAAA;IACT,uDAAK,CAAA;IACL,2DAAO,CAAA;AACT,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,mFAAoB,CAAA;I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e,QAI1B;AA+CD;;GAEG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAmC;IAClE,aAAa,EAAE,cAAc;IAC7B,qBAAqB,EAAE,QAAQ;CAChC,CAAA;AAED;;GAEG;AACH,MAAM,sBAAsB,GAA2B;IACrD,OAAO,EAAE,cAAc,EAAE,eAAe;IACxC,eAAe,EAAE,cAAc,EAAE,eAAe;IAChD,IAAI,EAAE,aAAa,EAAE,eAAe;IACpC,YAAY,EAAE,aAAa,EAAE,eAAe;CAC7C,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB,EAAE,WAA6B;IACrF,IAAI,MAAM,KAAK,aAAa,IAAI,WAAW,EAAE,CAAC;QAC5C,OAAO,sBAAsB,CAAC,WAAW,CAAC,IAAI,cAAc,CAAA;IAC9D,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,OAAO,CAAC,KAAK,aAAa,IAAI,CAAC,KAAK,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * The payment scheme to use.\n * - 'nvm' (default): Nevermined-issued x402 access tokens covering both\n * credit-based ERC-4337 payments and fiat card delegations (Stripe,\n * Braintree, Visa).\n */\nexport type PaymentScheme = 'nvm'\n\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n *\n * @deprecated The environment is now derived from the NVM API key prefix\n * (`<prefix>:<jwt>`), so this option is no longer required. It is still\n * accepted for backward compatibility and as a fallback when the key prefix\n * is unrecognized (e.g. local/custom development), but when the prefix maps\n * to a known environment the key wins and this option is ignored (a one-time\n * deprecation warning is emitted). It will be removed in a future release.\n */\n environment?: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The payment scheme to use. Defaults to 'nvm'.\n */\n scheme?: PaymentScheme\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * Pins the Nevermined backend API version (MAJOR.MINOR) sent with every\n * request via the `Nevermined-Version` header. Defaults to\n * {@link LOCKED_API_VERSION} — the backend contract this SDK release is\n * built and tested against. Override only to deliberately target a\n * different backend contract.\n *\n * @see https://docs.nevermined.app/api-reference/versioning\n */\n version?: string\n\n /**\n * Optional organization ID to use as the active workspace for every\n * authenticated backend request. When set, the SDK sends an\n * `X-Current-Org-Id` header so the backend scopes published agents,\n * plans, and other resources to this organization.\n *\n * If omitted the backend falls back to the API key's org tag or to the\n * caller's most-recent active membership (see `CurrentOrgContextGuard`\n * in nvm-monorepo).\n *\n * Override per-call via the `organizationId` option on create methods.\n *\n * @see Payments.setOrganizationId\n */\n organizationId?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n /**\n * Optional currency for the plan (e.g., 'USD', 'EUR', 'USDC', 'EURC').\n * When omitted, the backend determines the default based on the payment type.\n */\n currency?: Currency | string\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether burns of these credits are mirrored on-chain. When `false`\n * (default) the credits ledger lives in the API's Postgres and burns\n * are recorded off-chain only. When `true` an `OnchainMirrorWorker`\n * replays each off-chain burn to `NFT1155Credits` for audit.\n */\n onchainMirror: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Supported currencies for payment plans.\n * - Fiat: USD, EUR (processed via Stripe)\n * - Crypto: USDC, EURC (ERC20 stablecoins on Base)\n */\nexport enum Currency {\n USD = 'USD',\n EUR = 'EUR',\n USDC = 'USDC',\n EURC = 'EURC',\n}\n\n/** EURC token address on Base Mainnet (chain 8453) */\nexport const EURC_TOKEN_ADDRESS: Address = '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42'\n/** EURC token address on Base Sepolia testnet (chain 84532) */\nexport const EURC_TOKEN_ADDRESS_TESTNET: Address = '0x808456652fdb597867f38412077A9182bf77359F'\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * Optional allowlist of upstream endpoints that require a valid Payment Plan\n * subscription. When provided, the Nevermined platform enforces this list as\n * **Additional Security** (defense-in-depth) on top of any per-route gating\n * the Payments library middleware applies in your agent. When omitted, no\n * route-level allowlist is enforced — your library middleware remains the\n * sole gate.\n */\n endpoints?: Endpoint[]\n /**\n * The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc.\n */\n openEndpoints?: string[]\n /**\n * Optional URL to a discoverable agent definition (OpenAPI spec, MCP\n * Manifest, or A2A agent card). Stored as metadata for documentation /\n * discovery — not consumed at runtime by the Nevermined platform.\n */\n agentDefinitionUrl?: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n\n/**\n * x402 payment scheme type.\n * - 'nvm:erc4337': Crypto payments via ERC-4337 smart accounts\n * - 'nvm:card-delegation': Fiat/Stripe card delegation payments\n */\nexport type X402SchemeType = 'nvm:erc4337' | 'nvm:card-delegation'\n\n/**\n * Default network for each x402 scheme (backward-compat: defaults to Base Sepolia).\n */\nexport const X402_SCHEME_NETWORKS: Record<X402SchemeType, string> = {\n 'nvm:erc4337': 'eip155:84532',\n 'nvm:card-delegation': 'stripe',\n}\n\n/**\n * Environment-specific network for the erc4337 scheme.\n */\nconst ERC4337_NETWORK_BY_ENV: Record<string, string> = {\n sandbox: 'eip155:84532', // Base Sepolia\n staging_sandbox: 'eip155:84532', // Base Sepolia\n live: 'eip155:8453', // Base Mainnet\n staging_live: 'eip155:8453', // Base Mainnet\n}\n\n/**\n * Return the default network for a scheme, accounting for the environment.\n *\n * For `nvm:erc4337`, the network depends on the environment:\n * - sandbox / staging_sandbox → `eip155:84532` (Base Sepolia)\n * - live / staging_live → `eip155:8453` (Base Mainnet)\n *\n * Falls back to `X402_SCHEME_NETWORKS` when no environment is given.\n */\nexport function getDefaultNetwork(scheme: X402SchemeType, environment?: EnvironmentName): string {\n if (scheme === 'nvm:erc4337' && environment) {\n return ERC4337_NETWORK_BY_ENV[environment] ?? 'eip155:84532'\n }\n return X402_SCHEME_NETWORKS[scheme]\n}\n\n/**\n * Type guard to check if a value is a valid x402 scheme type.\n */\nexport function isValidScheme(s: unknown): s is X402SchemeType {\n return s === 'nvm:erc4337' || s === 'nvm:card-delegation'\n}\n\n/**\n * Currency codes accepted for a delegation. Lowercase, mirroring the\n * backend's `@IsIn(['usd','eur','usdc','eurc'])` constraint on\n * `POST /api/v1/delegation/create` and the Python SDK's `DelegationCurrency`.\n * Card providers use `'usd'`/`'eur'`; erc4337 uses `'usdc'`/`'eurc'`.\n */\nexport type DelegationCurrency = 'usd' | 'eur' | 'usdc' | 'eurc'\n\n/**\n * Configuration for delegation-based payments (both crypto and card schemes).\n *\n * The supported flow is **create-first**: create a delegation with\n * {@link DelegationAPI.createDelegation}, then request the access token with\n * `delegationConfig: { delegationId }`.\n *\n * @remarks\n * The inline create-on-the-fly fields (`providerPaymentMethodId`,\n * `spendingLimitCents`, `durationSecs`, `currency`, `merchantAccountId`,\n * `maxTransactions`, `cardId`) are individually deprecated. Calling\n * {@link X402TokenAPI.getX402AccessToken} with a `delegationConfig` that lacks\n * `delegationId` but carries one of those fields emits a runtime deprecation\n * warning; create the delegation first and pass only `delegationId` (optionally\n * `apiKeyId`) here. The interface itself is NOT deprecated — the\n * `{ delegationId }` reuse path is the supported way to configure a token request.\n */\nexport interface DelegationConfig {\n /**\n * PaymentMethod entity UUID — references an enrolled card.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n cardId?: string\n /** Existing delegation UUID to reuse instead of creating a new one. The supported (non-deprecated) path. */\n delegationId?: string\n /**\n * Stripe payment method ID (e.g., 'pm_...'). Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n providerPaymentMethodId?: string\n /**\n * Maximum spending limit in cents. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n spendingLimitCents?: number\n /**\n * Duration of the delegation in seconds. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n durationSecs?: number\n /**\n * Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n currency?: DelegationCurrency\n /**\n * Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n merchantAccountId?: string\n /**\n * Maximum number of transactions allowed.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n maxTransactions?: number\n /**\n * Plan ID to scope a newly-created delegation to. Optional and additive:\n * delegations are plan-agnostic by default; supplying `planId` opts into a\n * plan-bound delegation. (Visa delegations are always plan-specific and\n * require it server-side.)\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n planId?: string\n /** NVM API Key ID to scope the delegation to. Active (non-deprecated). */\n apiKeyId?: string\n}\n\n/**\n * Payload for creating a new delegation via POST /api/v1/delegation/create.\n */\nexport interface CreateDelegationPayload {\n /** Delegation provider: 'stripe' | 'braintree' | 'visa' for card, 'erc4337' for crypto */\n provider: 'stripe' | 'braintree' | 'visa' | 'erc4337'\n /** Payment method ID from the provider (Stripe 'pm_...', Braintree vault token, or Visa Agentic token id). Required for card providers. */\n providerPaymentMethodId?: string\n /** Maximum spending limit in cents */\n spendingLimitCents: number\n /** Duration of the delegation in seconds */\n durationSecs: number\n /** Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). Required by the backend — no silent default. */\n currency: DelegationCurrency\n /**\n * Plan ID to scope the delegation to. Optional and additive: delegations are\n * plan-agnostic by default; supplying `planId` opts into a plan-bound\n * delegation. (Visa delegations are always plan-specific and require it.)\n */\n planId?: string\n /** Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId) */\n merchantAccountId?: string\n /** Maximum number of transactions allowed */\n maxTransactions?: number\n /** NVM API Key ID to scope the delegation to */\n apiKeyId?: string\n}\n\n/**\n * Response from creating a delegation.\n */\nexport interface CreateDelegationResponse {\n /** Delegation token (for card delegations) */\n delegationToken?: string\n /** Delegation UUID */\n delegationId: string\n}\n\n/**\n * Options for x402 token generation that control scheme and delegation behavior.\n */\nexport interface X402TokenOptions {\n /** The x402 scheme to use (defaults to 'nvm:erc4337') */\n scheme?: X402SchemeType\n /** Network identifier (auto-derived from scheme if omitted) */\n network?: string\n /** Delegation configuration for both erc4337 and card-delegation schemes */\n delegationConfig?: DelegationConfig\n}\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/common/types.ts"],"names":[],"mappings":"AA2KA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,+DAAW,CAAA;IACX,yEAAgB,CAAA;IAChB,iFAAoB,CAAA;AACtB,CAAC,EAJW,aAAa,KAAb,aAAa,QAIxB;AAED;;;;GAIG;AACH,MAAM,CAAN,IAAY,QAKX;AALD,WAAY,QAAQ;IAClB,uBAAW,CAAA;IACX,uBAAW,CAAA;IACX,yBAAa,CAAA;IACb,yBAAa,CAAA;AACf,CAAC,EALW,QAAQ,KAAR,QAAQ,QAKnB;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,kBAAkB,GAAY,4CAA4C,CAAA;AACvF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,0BAA0B,GAAY,4CAA4C,CAAA;AAE/F;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,+DAAS,CAAA;IACT,uDAAK,CAAA;IACL,2DAAO,CAAA;AACT,CAAC,EAJW,eAAe,KAAf,eAAe,QAI1B;AAED;;;;;;;GAOG;AACH,MAAM,CAAN,IAAY,kBAKX;AALD,WAAY,kBAAkB;IAC5B,mFAAoB,CAAA;IACpB,uEAAc,CAAA;IACd,+EAAkB,CAAA;IAClB,iFAAmB,CAAA;AACrB,CAAC,EALW,kBAAkB,KAAlB,kBAAkB,QAK7B;AA2KD;;GAEG;AACH,MAAM,OAAO,iBAAiB;IAsB5B;;;OAGG;IACH,YAAY,OAAoC;QApBhD;;;WAGG;QACH,c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IACxC,eAAe,EAAE,cAAc,EAAE,eAAe;IAChD,IAAI,EAAE,aAAa,EAAE,eAAe;IACpC,YAAY,EAAE,aAAa,EAAE,eAAe;CAC7C,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAsB,EAAE,WAA6B;IACrF,IAAI,MAAM,KAAK,aAAa,IAAI,WAAW,EAAE,CAAC;QAC5C,OAAO,sBAAsB,CAAC,WAAW,CAAC,IAAI,cAAc,CAAA;IAC9D,CAAC;IACD,OAAO,oBAAoB,CAAC,MAAM,CAAC,CAAA;AACrC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,aAAa,CAAC,CAAU;IACtC,OAAO,CAAC,KAAK,aAAa,IAAI,CAAC,KAAK,qBAAqB,CAAA;AAC3D,CAAC","sourcesContent":["import { EnvironmentName } from '../environments.js'\n\n/**\n * The payment scheme to use.\n * - 'nvm' (default): Nevermined-issued x402 access tokens covering both\n * credit-based ERC-4337 payments and fiat card delegations (Stripe,\n * Braintree, Visa).\n */\nexport type PaymentScheme = 'nvm'\n\nexport interface PaymentOptions {\n /**\n * The Nevermined environment to connect to.\n *\n * @deprecated The environment is now derived from the NVM API key prefix\n * (`<prefix>:<jwt>`), so this option is no longer required. It is still\n * accepted for backward compatibility and as a fallback when the key prefix\n * is unrecognized (e.g. local/custom development), but when the prefix maps\n * to a known environment the key wins and this option is ignored (a one-time\n * deprecation warning is emitted). It will be removed in a future release.\n */\n environment?: EnvironmentName\n\n /**\n * The Nevermined API Key. This key identify your user and is required to interact with the Nevermined API.\n * You can get your API key by logging in to the Nevermined App.\n * @see https://nevermined.ai/docs/tutorials/integration/nvm-api-keys\n */\n nvmApiKey: string\n\n /**\n * The payment scheme to use. Defaults to 'nvm'.\n */\n scheme?: PaymentScheme\n\n /**\n * The URL to return to the app after a successful login.\n */\n returnUrl?: string\n\n /**\n * The app id. This attribute is optional and helps to associate assets registered into Nevermined with a common identifier.\n */\n appId?: string\n\n /**\n * Pins the Nevermined backend API version (MAJOR.MINOR) sent with every\n * request via the `Nevermined-Version` header. Defaults to\n * {@link LOCKED_API_VERSION} — the backend contract this SDK release is\n * built and tested against. Override only to deliberately target a\n * different backend contract.\n *\n * @see https://nevermined.ai/docs/development-guide/api-versioning\n */\n version?: string\n\n /**\n * Optional organization ID to use as the active workspace for every\n * authenticated backend request. When set, the SDK sends an\n * `X-Current-Org-Id` header so the backend scopes published agents,\n * plans, and other resources to this organization.\n *\n * If omitted the backend falls back to the API key's org tag or to the\n * caller's most-recent active membership (see `CurrentOrgContextGuard`\n * in nvm-monorepo).\n *\n * Override per-call via the `organizationId` option on create methods.\n *\n * @see Payments.setOrganizationId\n */\n organizationId?: string\n}\n\nexport interface Endpoint {\n [verb: string]: string\n}\n\nexport interface ApiResponse<T> {\n success: boolean\n data?: T\n error?: string\n}\n\nexport type Address = `0x${string}`\n\n/**\n * Definition of the price configuration for a Payment Plan\n */\nexport interface PlanPriceConfig {\n /**\n * The address of the token (ERC20 or Native if zero address) for paying the plan\n */\n tokenAddress?: Address\n /**\n * The amounts to be paid for the plan\n */\n amounts: bigint[]\n /**\n * The receivers of the payments of the plan\n */\n receivers: string[]\n /**\n * The address of the smart contract that calculates the price\n */\n contractAddress?: Address\n /**\n * The address of the fee controller contract, if any\n * @remarks if not given, the fee controller is the default one\n */\n feeController?: Address\n /**\n * The address of the external price contract, if any\n */\n externalPriceAddress?: Address\n /**\n * The address of the template contract, if any\n */\n templateAddress?: Address\n /**\n * Whether this is a crypto payment (true) or fiat payment (false)\n */\n isCrypto: boolean\n /**\n * Optional currency for the plan (e.g., 'USD', 'EUR', 'USDC', 'EURC').\n * When omitted, the backend determines the default based on the payment type.\n */\n currency?: Currency | string\n}\n\n/**\n * Definition of the credits configuration for a payment plan\n */\nexport interface PlanCreditsConfig {\n /**\n * Whether the redemption amount is fixed (true) or dynamic (false)\n */\n isRedemptionAmountFixed: boolean\n /**\n * How the credits can be redeemed\n */\n redemptionType: PlanRedemptionType\n /**\n * Whether burns of these credits are mirrored on-chain. When `false`\n * (default) the credits ledger lives in the API's Postgres and burns\n * are recorded off-chain only. When `true` an `OnchainMirrorWorker`\n * replays each off-chain burn to `NFT1155Credits` for audit.\n */\n onchainMirror: boolean\n /**\n * The duration of the credits in seconds\n * @remarks 0 means non-expirable\n */\n durationSecs: bigint\n /**\n * The amount of credits that are granted when purchasing the plan (as string for API)\n */\n amount: bigint\n /**\n * The minimum number of credits redeemed when using the plan\n */\n minAmount: bigint\n /**\n * The maximum number of credits redeemed when using the plan\n */\n maxAmount: bigint\n /**\n * The address of the NFT contract that represents the plan's credits\n */\n nftAddress?: Address\n}\n\n/**\n * Different types of prices that can be configured for a plan\n * @remarks 0 - FIXED_PRICE, 1 - FIXED_FIAT_PRICE, 2 - SMART_CONTRACT_PRICE\n * If FIXED_PRICE it means the plan can be paid in crypto by a fixed amount of a ERC20 or Native token\n * If FIXED_FIAT_PRICE it means the plan can be paid in fiat by a fixed amount (typically USD)\n * If SMART_CONTRACT_PRICE it means the plan can be paid in crypto and the amount to be paid is calculated by a smart contract\n */\nexport enum PlanPriceType {\n FIXED_PRICE,\n FIXED_FIAT_PRICE,\n SMART_CONTRACT_PRICE,\n}\n\n/**\n * Supported currencies for payment plans.\n * - Fiat: USD, EUR (processed via Stripe)\n * - Crypto: USDC, EURC (ERC20 stablecoins on Base)\n */\nexport enum Currency {\n USD = 'USD',\n EUR = 'EUR',\n USDC = 'USDC',\n EURC = 'EURC',\n}\n\n/** EURC token address on Base Mainnet (chain 8453) */\nexport const EURC_TOKEN_ADDRESS: Address = '0x60a3E35Cc302bFA44Cb288Bc5a4F316Fdb1adb42'\n/** EURC token address on Base Sepolia testnet (chain 84532) */\nexport const EURC_TOKEN_ADDRESS_TESTNET: Address = '0x808456652fdb597867f38412077A9182bf77359F'\n\n/**\n * Different types of credits that can be obtained when purchasing a plan\n * @remarks 0 - EXPIRABLE, 1 - FIXED, 2 - DYNAMIC\n * If EXPIRABLE it means the credits can be used for a fixed amount of time (calculated in seconds)\n * If FIXED it means the credits can be used for a fixed amount of times\n * If DYNAMIC it means the credits can be used but the redemption amount is dynamic\n */\nexport enum PlanCreditsType {\n EXPIRABLE,\n FIXED,\n DYNAMIC,\n}\n\n/**\n * Different types of redemptions criterias that can be used when redeeming credits\n * @remarks 0 - ONLY_GLOBAL_ROLE, 1 - ONLY_OWNER, 2 - ROLE_AND_OWNER\n * If ONLY_GLOBAL_ROLE it means the credits can be redeemed only by an account with the `CREDITS_BURNER_ROLE`\n * If ONLY_OWNER it means the credits can be redeemed only by the owner of the Plan\n * If ONLY_PLAN_ROLE it means the credits can be redeemed by an account with specifics grants for the plan\n * If ONLY_SUBSCRIBER means only the subscriber (the one who holds the credits NFT) can redeem\n */\nexport enum PlanRedemptionType {\n ONLY_GLOBAL_ROLE = 0, // NVM Proxy can burn\n ONLY_OWNER = 1, // Agent can burn\n ONLY_PLAN_ROLE = 2,\n ONLY_SUBSCRIBER = 4, // Subscriber who ordered the plan can redeem\n}\n\nexport interface PlanBalance {\n planId: string\n planName: string\n planType: string\n holderAddress: Address\n balance: bigint\n creditsContract: Address\n isSubscriber: boolean\n pricePerCredit: number\n}\n\nexport interface StartAgentRequest {\n agentRequestId: string\n agentName: string\n agentId: string\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n batch: boolean\n}\n\nexport interface ValidationAgentRequest {\n balance: PlanBalance\n urlMatching: string\n verbMatching: string\n}\n\nexport interface AgentAccessCredentials {\n accessToken: string\n proxies?: string[]\n}\n\nexport interface SubscriberRequestStatus {\n planId: string\n agentId: string\n isValid: boolean\n code: number\n message?: string\n}\n\nexport interface NvmAPIResult {\n success: boolean\n message?: string\n txHash?: string\n httpStatus?: number\n data?: APIOutputData\n when?: Date\n}\n\nexport interface APIOutputData {\n [key: string]: any\n}\n\nexport interface StripeCheckoutResult {\n stripeCheckoutSessionId: string\n checkoutLink: string\n clientReferenceId: string\n paymentStatus?: string\n linkCreatedAt: number\n linkExpiresAt: number\n}\n\n/**\n * Metadata attributes describing the AI Agent.\n */\nexport interface AgentMetadata {\n /**\n * Name of the Agent\n */\n name: string\n /**\n * Description of the Agent\n */\n description?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n author?: string\n /**\n * The author of the Agent (organization or person) that own the Agent.\n */\n license?: string\n /**\n * Tags describing the AI Agent\n */\n tags?: string[]\n /**\n * Some description or instructions about how to integrate the Agent.\n */\n integration?: string\n /**\n * A link to some same usage of the Agent.\n */\n sampleLink?: string\n /**\n * Text describing the API of the Agent.\n */\n apiDescription?: string\n /**\n * The date when the Agent was created.\n */\n dateCreated?: Date\n\n // internalAttributes?: any\n}\n\n/**\n * Metadata attributes describing the Payment Plan.\n */\nexport interface PlanMetadata extends AgentMetadata {\n /**\n * Indicates if a payment plan is a Trial plan.\n * A Trial plan is a plan that allows users to test the AI Agents associated with it typically without any cost.\n * @remarks A Trial plan only can be purchased once by a user.\n */\n isTrialPlan?: boolean\n /**\n * Indicates if a payment plan is limited by credits.\n * If 'time', the plan will be limited by time.\n * If 'credits', the plan will be limited by credits.\n */\n accessLimit?: 'credits' | 'time'\n}\n\n/**\n * It describes the API exposed by an AI Agent.\n * This information is necessary to query the AI Agent and to know which endpoints are available.\n */\nexport interface AgentAPIAttributes {\n /**\n * Optional allowlist of upstream endpoints that require a valid Payment Plan\n * subscription. When provided, the Nevermined platform enforces this list as\n * **Additional Security** (defense-in-depth) on top of any per-route gating\n * the Payments library middleware applies in your agent. When omitted, no\n * route-level allowlist is enforced — your library middleware remains the\n * sole gate.\n */\n endpoints?: Endpoint[]\n /**\n * The list of endpoints of the upstream service that publicly available. The access to these endpoints don't require subscription to the Payment Plan. They are useful to expose documentation, etc.\n */\n openEndpoints?: string[]\n /**\n * Optional URL to a discoverable agent definition (OpenAPI spec, MCP\n * Manifest, or A2A agent card). Stored as metadata for documentation /\n * discovery — not consumed at runtime by the Nevermined platform.\n */\n agentDefinitionUrl?: string\n\n /////// AUTHORIZATION ///////\n\n /**\n * The upstream agent/service authentication type ('none', 'basic', 'bearer' or 'oauth').\n */\n authType?: 'none' | 'basic' | 'oauth' | 'bearer'\n /**\n * The upstream agent/service username for authentication. Only if `authType` is 'basic'.\n */\n username?: string\n /**\n * The upstream agent/service password for authentication. Only if `authType` is 'basic'.\n */\n password?: string\n /**\n * The upstream agent/service bearer token for authentication. Only if `authType` is 'bearer' or 'oauth'.\n */\n token?: string\n}\n\n/**\n * Options for pagination in API requests to the Nevermined API.\n */\nexport class PaginationOptions {\n /**\n * The field to sort the results by.\n * If not provided, the default sorting defined by the API will be applied.\n */\n sortBy?: string\n /**\n * The order in which to sort the results.\n * Default is 'desc' (descending).\n */\n sortOrder: 'asc' | 'desc' = 'desc'\n /**\n * The page number to retrieve.\n * Default is 1.\n */\n page = 1\n /**\n * The number of items per page.\n * Default is 10.\n */\n offset = 10\n\n /**\n * Constructs a new PaginationOptions instance.\n * @param options - Optional initial values for the pagination options.\n */\n constructor(options?: Partial<PaginationOptions>) {\n if (options) {\n this.sortBy = options.sortBy\n this.sortOrder = options.sortOrder || 'desc'\n this.page = options.page || 1\n this.offset = options.offset || 10\n }\n }\n\n /**\n * It returns a string representation of the pagination options\n * @returns A string representation of the pagination options as URL query parameters.\n * This can be used to append to API requests for pagination.\n */\n asQueryParams(): string {\n const params: Record<string, string> = {}\n if (this.sortBy) {\n params.sortBy = this.sortBy\n }\n params.sortOrder = this.sortOrder\n params.page = this.page.toString()\n params.pageSize = this.offset.toString()\n\n return new URLSearchParams(params).toString()\n }\n}\n\n/**\n * Status of an agent task\n */\nexport enum AgentTaskStatus {\n SUCCESS = 'SUCCESS',\n FAILED = 'FAILED',\n PENDING = 'PENDING',\n}\n\n/**\n * Data transfer object for tracking agent sub tasks\n */\nexport interface TrackAgentSubTaskDto {\n /**\n * The unique identifier of the agent task\n */\n agentRequestId: string\n\n /**\n * The number of credits burned in this agent sub task (optional)\n * @defaultValue 0\n */\n creditsToRedeem?: number\n\n /**\n * A tag to categorize this agent sub task (optional)\n */\n tag?: string\n\n /**\n * A description of this agent sub task (optional)\n */\n description?: string\n\n /**\n * The status of the agent sub task (optional)\n */\n status?: AgentTaskStatus\n}\n\nexport type SimulationRequestOptions = {\n agentName?: string\n planName?: string\n batch?: boolean\n pricePerCredit?: number\n}\n\n/**\n * x402 payment scheme type.\n * - 'nvm:erc4337': Crypto payments via ERC-4337 smart accounts\n * - 'nvm:card-delegation': Fiat/Stripe card delegation payments\n */\nexport type X402SchemeType = 'nvm:erc4337' | 'nvm:card-delegation'\n\n/**\n * Default network for each x402 scheme (backward-compat: defaults to Base Sepolia).\n */\nexport const X402_SCHEME_NETWORKS: Record<X402SchemeType, string> = {\n 'nvm:erc4337': 'eip155:84532',\n 'nvm:card-delegation': 'stripe',\n}\n\n/**\n * Environment-specific network for the erc4337 scheme.\n */\nconst ERC4337_NETWORK_BY_ENV: Record<string, string> = {\n sandbox: 'eip155:84532', // Base Sepolia\n staging_sandbox: 'eip155:84532', // Base Sepolia\n live: 'eip155:8453', // Base Mainnet\n staging_live: 'eip155:8453', // Base Mainnet\n}\n\n/**\n * Return the default network for a scheme, accounting for the environment.\n *\n * For `nvm:erc4337`, the network depends on the environment:\n * - sandbox / staging_sandbox → `eip155:84532` (Base Sepolia)\n * - live / staging_live → `eip155:8453` (Base Mainnet)\n *\n * Falls back to `X402_SCHEME_NETWORKS` when no environment is given.\n */\nexport function getDefaultNetwork(scheme: X402SchemeType, environment?: EnvironmentName): string {\n if (scheme === 'nvm:erc4337' && environment) {\n return ERC4337_NETWORK_BY_ENV[environment] ?? 'eip155:84532'\n }\n return X402_SCHEME_NETWORKS[scheme]\n}\n\n/**\n * Type guard to check if a value is a valid x402 scheme type.\n */\nexport function isValidScheme(s: unknown): s is X402SchemeType {\n return s === 'nvm:erc4337' || s === 'nvm:card-delegation'\n}\n\n/**\n * Currency codes accepted for a delegation. Lowercase, mirroring the\n * backend's `@IsIn(['usd','eur','usdc','eurc'])` constraint on\n * `POST /api/v1/delegation/create` and the Python SDK's `DelegationCurrency`.\n * Card providers use `'usd'`/`'eur'`; erc4337 uses `'usdc'`/`'eurc'`.\n */\nexport type DelegationCurrency = 'usd' | 'eur' | 'usdc' | 'eurc'\n\n/**\n * Configuration for delegation-based payments (both crypto and card schemes).\n *\n * The supported flow is **create-first**: create a delegation with\n * {@link DelegationAPI.createDelegation}, then request the access token with\n * `delegationConfig: { delegationId }`.\n *\n * @remarks\n * The inline create-on-the-fly fields (`providerPaymentMethodId`,\n * `spendingLimitCents`, `durationSecs`, `currency`, `merchantAccountId`,\n * `maxTransactions`, `cardId`) are individually deprecated. Calling\n * {@link X402TokenAPI.getX402AccessToken} with a `delegationConfig` that lacks\n * `delegationId` but carries one of those fields emits a runtime deprecation\n * warning; create the delegation first and pass only `delegationId` (optionally\n * `apiKeyId`) here. The interface itself is NOT deprecated — the\n * `{ delegationId }` reuse path is the supported way to configure a token request.\n */\nexport interface DelegationConfig {\n /**\n * PaymentMethod entity UUID — references an enrolled card.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n cardId?: string\n /** Existing delegation UUID to reuse instead of creating a new one. The supported (non-deprecated) path. */\n delegationId?: string\n /**\n * Stripe payment method ID (e.g., 'pm_...'). Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n providerPaymentMethodId?: string\n /**\n * Maximum spending limit in cents. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n spendingLimitCents?: number\n /**\n * Duration of the delegation in seconds. Required only for new delegations.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n durationSecs?: number\n /**\n * Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n currency?: DelegationCurrency\n /**\n * Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId).\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n merchantAccountId?: string\n /**\n * Maximum number of transactions allowed.\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n maxTransactions?: number\n /**\n * Plan ID to scope a newly-created delegation to. Optional and additive:\n * delegations are plan-agnostic by default; supplying `planId` opts into a\n * plan-bound delegation. (Visa delegations are always plan-specific and\n * require it server-side.)\n * @deprecated Inline create-on-the-fly. Create the delegation first and pass `delegationId`.\n */\n planId?: string\n /** NVM API Key ID to scope the delegation to. Active (non-deprecated). */\n apiKeyId?: string\n}\n\n/**\n * Payload for creating a new delegation via POST /api/v1/delegation/create.\n */\nexport interface CreateDelegationPayload {\n /** Delegation provider: 'stripe' | 'braintree' | 'visa' for card, 'erc4337' for crypto */\n provider: 'stripe' | 'braintree' | 'visa' | 'erc4337'\n /** Payment method ID from the provider (Stripe 'pm_...', Braintree vault token, or Visa Agentic token id). Required for card providers. */\n providerPaymentMethodId?: string\n /** Maximum spending limit in cents */\n spendingLimitCents: number\n /** Duration of the delegation in seconds */\n durationSecs: number\n /** Currency code (e.g., 'usd' for card providers, 'usdc' for erc4337). Required by the backend — no silent default. */\n currency: DelegationCurrency\n /**\n * Plan ID to scope the delegation to. Optional and additive: delegations are\n * plan-agnostic by default; supplying `planId` opts into a plan-bound\n * delegation. (Visa delegations are always plan-specific and require it.)\n */\n planId?: string\n /** Merchant account ID (Stripe Connect acct_xxx or Braintree merchantId) */\n merchantAccountId?: string\n /** Maximum number of transactions allowed */\n maxTransactions?: number\n /** NVM API Key ID to scope the delegation to */\n apiKeyId?: string\n}\n\n/**\n * Response from creating a delegation.\n */\nexport interface CreateDelegationResponse {\n /** Delegation token (for card delegations) */\n delegationToken?: string\n /** Delegation UUID */\n delegationId: string\n}\n\n/**\n * Options for x402 token generation that control scheme and delegation behavior.\n */\nexport interface X402TokenOptions {\n /** The x402 scheme to use (defaults to 'nvm:erc4337') */\n scheme?: X402SchemeType\n /** Network identifier (auto-derived from scheme if omitted) */\n network?: string\n /** Delegation configuration for both erc4337 and card-delegation schemes */\n delegationConfig?: DelegationConfig\n}\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/faci
|
|
|
18
18
|
export { DelegationAPI } from './x402/delegation-api.js';
|
|
19
19
|
export type { PaymentMethodSummary, UpdatePaymentMethodDto, DelegationSummary, DelegationListResponse, PurchasingPower, ListOptions, } from './x402/delegation-api.js';
|
|
20
20
|
export type { X402PaymentRequired, X402PaymentAccepted, X402Resource, X402Scheme, X402SchemeExtra, VerifyPermissionsParams, VerifyPermissionsResult, SettlePermissionsParams, SettlePermissionsResult, } from './x402/facilitator-api.js';
|
|
21
|
+
export * from './mpp/index.js';
|
|
21
22
|
export type { CreditsContext, CreditsOption, PaywallOptions, McpConfig, PaywallContext, AuthResult, } from './mcp/types/paywall.types.js';
|
|
22
23
|
export type { OAuthUrls, OAuthConfig, HttpRouterConfig, HttpServerConfig, HttpServerResult, } from './mcp/types/http.types.js';
|
|
23
24
|
export type { ExtendedMcpConfig } from './mcp/index.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,YAAY,CAAA;AAC1B,cAAc,yBAAyB,CAAA;AACvC,cAAc,mBAAmB,CAAA;AACjC,cAAc,4BAA4B,CAAA;AAC1C,cAAc,oBAAoB,CAAA;AAClC,cAAc,oBAAoB,CAAA;AAClC,cAAc,8CAA8C,CAAA;AAC5D,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAA;AACrD,OAAO,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAA;AAC9D,YAAY,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAChE,OAAO,EAAE,gBA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AAmB,CAAA;AAC1B,OAAO,EACL,sBAAsB,EACtB,yBAAyB,EACzB,0BAA0B,EAC1B,iCAAiC,GAClC,MAAM,qBAAqB,CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,8 @@ export { OrganizationMemberRole, OrganizationType, OrganizationActivityEventType
|
|
|
14
14
|
// x402 utilities and types
|
|
15
15
|
export { buildPaymentRequired, resolveNetwork, resolveScheme } from './x402/facilitator-api.js';
|
|
16
16
|
export { DelegationAPI } from './x402/delegation-api.js';
|
|
17
|
+
// MPP (Machine Payments Protocol) public surface
|
|
18
|
+
export * from './mpp/index.js';
|
|
17
19
|
// MCP HTTP utilities
|
|
18
20
|
export { createRequireAuthMiddleware } from './mcp/http/oauth-router.js';
|
|
19
21
|
// x402 v2 A2A in-band transport utilities (mirrors the Python X402A2AUtils)
|