@moonpay/platform-sdk-core 1.17.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -215,6 +215,21 @@ interface CoreClientOptions extends ClientContextOptions, UrlBuilderOptions {
215
215
  */
216
216
  createTransport: () => FrameTransport;
217
217
  }
218
+ /**
219
+ * Customer-scoped credentials the client holds after a successful connection.
220
+ * Surfaced to partners via `getCredentials()` — see that method for caveats.
221
+ */
222
+ interface Credentials {
223
+ /** Short-lived bearer token scoped to the connected customer. */
224
+ accessToken: string;
225
+ /** Token identifying the SDK client; used when launching frames. */
226
+ clientToken: string;
227
+ }
228
+ /** Returned by `getCredentials()` when no customer session is active yet. */
229
+ interface GetCredentialsError {
230
+ code: 'noActiveSession';
231
+ message: string;
232
+ }
218
233
  interface CoreClient {
219
234
  /** Access the internal context (for platform SDKs). */
220
235
  readonly context: ClientContext;
@@ -222,6 +237,18 @@ interface CoreClient {
222
237
  readonly frameBaseUrl: string | undefined;
223
238
  /** Factory to create transports (for platform SDKs). */
224
239
  createTransport(): FrameTransport;
240
+ /**
241
+ * Returns the connected customer's credentials so the `accessToken` can be
242
+ * forwarded to your backend for customer-scoped Platform API calls (e.g.
243
+ * server-side quote fetching).
244
+ *
245
+ * Advanced escape hatch — the SDK otherwise keeps these internal. The
246
+ * `accessToken` is short-lived and scoped to the connected customer. Errs
247
+ * with `noActiveSession` until a customer session exists (populated by
248
+ * `getConnection()` / `connect()` / `setupAuth()`). Synchronous: returns a
249
+ * `Result` directly, not a Promise.
250
+ */
251
+ getCredentials(): Result<Credentials, GetCredentialsError>;
225
252
  getQuote(params: GetQuoteParams): Promise<Result<{
226
253
  data: Quote;
227
254
  }, GetQuoteError>>;
@@ -362,4 +389,4 @@ declare function isTrustedFrameOrigin(origin: string): boolean;
362
389
  */
363
390
  declare function isTrustedFrameUrl(value: string): boolean;
364
391
 
365
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListAssetsParams, type ListTransactionsParams, type PresentationMode, TRUSTED_FRAME_ORIGIN_PATTERNS, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyClientTokenParam, applyPresentationParam, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getAssets, getCustomer, getCustomerUploadUrl, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, isSecureRandomAvailable, isTrustedFrameOrigin, isTrustedFrameUrl, listTransactions, presentationParams, simulateBankTransfer, submitCustomerFiles, submitCustomerKyc, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
392
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, type Credentials, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type GetCredentialsError, type KeyPair, type ListAssetsParams, type ListTransactionsParams, type PresentationMode, TRUSTED_FRAME_ORIGIN_PATTERNS, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyClientTokenParam, applyPresentationParam, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getAssets, getCustomer, getCustomerUploadUrl, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, isSecureRandomAvailable, isTrustedFrameOrigin, isTrustedFrameUrl, listTransactions, presentationParams, simulateBankTransfer, submitCustomerFiles, submitCustomerKyc, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
package/dist/index.d.ts CHANGED
@@ -215,6 +215,21 @@ interface CoreClientOptions extends ClientContextOptions, UrlBuilderOptions {
215
215
  */
216
216
  createTransport: () => FrameTransport;
217
217
  }
218
+ /**
219
+ * Customer-scoped credentials the client holds after a successful connection.
220
+ * Surfaced to partners via `getCredentials()` — see that method for caveats.
221
+ */
222
+ interface Credentials {
223
+ /** Short-lived bearer token scoped to the connected customer. */
224
+ accessToken: string;
225
+ /** Token identifying the SDK client; used when launching frames. */
226
+ clientToken: string;
227
+ }
228
+ /** Returned by `getCredentials()` when no customer session is active yet. */
229
+ interface GetCredentialsError {
230
+ code: 'noActiveSession';
231
+ message: string;
232
+ }
218
233
  interface CoreClient {
219
234
  /** Access the internal context (for platform SDKs). */
220
235
  readonly context: ClientContext;
@@ -222,6 +237,18 @@ interface CoreClient {
222
237
  readonly frameBaseUrl: string | undefined;
223
238
  /** Factory to create transports (for platform SDKs). */
224
239
  createTransport(): FrameTransport;
240
+ /**
241
+ * Returns the connected customer's credentials so the `accessToken` can be
242
+ * forwarded to your backend for customer-scoped Platform API calls (e.g.
243
+ * server-side quote fetching).
244
+ *
245
+ * Advanced escape hatch — the SDK otherwise keeps these internal. The
246
+ * `accessToken` is short-lived and scoped to the connected customer. Errs
247
+ * with `noActiveSession` until a customer session exists (populated by
248
+ * `getConnection()` / `connect()` / `setupAuth()`). Synchronous: returns a
249
+ * `Result` directly, not a Promise.
250
+ */
251
+ getCredentials(): Result<Credentials, GetCredentialsError>;
225
252
  getQuote(params: GetQuoteParams): Promise<Result<{
226
253
  data: Quote;
227
254
  }, GetQuoteError>>;
@@ -362,4 +389,4 @@ declare function isTrustedFrameOrigin(origin: string): boolean;
362
389
  */
363
390
  declare function isTrustedFrameUrl(value: string): boolean;
364
391
 
365
- export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type KeyPair, type ListAssetsParams, type ListTransactionsParams, type PresentationMode, TRUSTED_FRAME_ORIGIN_PATTERNS, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyClientTokenParam, applyPresentationParam, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getAssets, getCustomer, getCustomerUploadUrl, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, isSecureRandomAvailable, isTrustedFrameOrigin, isTrustedFrameUrl, listTransactions, presentationParams, simulateBankTransfer, submitCustomerFiles, submitCustomerKyc, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
392
+ export { type ClientContext, type ClientContextOptions, type CoreClient, type CoreClientOptions, type Credentials, FRAME_PATHS, type FrameHandle, type FrameOptions, type FrameOrchestratorOptions, type FrameTransport, type GetCredentialsError, type KeyPair, type ListAssetsParams, type ListTransactionsParams, type PresentationMode, TRUSTED_FRAME_ORIGIN_PATTERNS, type ThemeOptions, type UrlBuilderOptions, apiFetch, applyClientTokenParam, applyPresentationParam, applyThemeParam, buildFrameUrl, createClientContext, createClientCore, createFrameOrchestrator, createIdentity, decryptCredentials, deletePaymentMethod, generateKeyPair, getAssets, getCustomer, getCustomerUploadUrl, getIdentity, getIdentityUploadUrl, getPaymentMethods, getQuote, getTransaction, isSecureRandomAvailable, isTrustedFrameOrigin, isTrustedFrameUrl, listTransactions, presentationParams, simulateBankTransfer, submitCustomerFiles, submitCustomerKyc, submitIdentityFiles, themeParams, updateIdentity, verifyIdentity };
package/dist/index.js CHANGED
@@ -206,6 +206,7 @@ async function simulateBankTransfer(ctx, id, params) {
206
206
  }
207
207
 
208
208
  // src/client.ts
209
+ import { err as err4, ok as ok4 } from "@moonpay/platform-protocol/result";
209
210
  function createClientCore(options) {
210
211
  const ctx = createClientContext({
211
212
  apiBaseUrl: options.apiBaseUrl
@@ -218,6 +219,10 @@ function createClientCore(options) {
218
219
  return options.frameBaseUrl;
219
220
  },
220
221
  createTransport: options.createTransport,
222
+ getCredentials: () => ctx.accessToken ? ok4({ accessToken: ctx.accessToken, clientToken: ctx.clientToken }) : err4({
223
+ code: "noActiveSession",
224
+ message: "No active session. Connect a customer (getConnection / connect / setupAuth) before requesting credentials."
225
+ }),
221
226
  getQuote: (params) => getQuote(ctx, params),
222
227
  getAssets: (params) => getAssets(ctx, params),
223
228
  getPaymentMethods: () => getPaymentMethods(ctx),