@viu/emporix-sdk 2.36.1 → 2.38.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.
Files changed (54) hide show
  1. package/CHANGELOG.md +66 -0
  2. package/dist/availability.d.cts +1 -1
  3. package/dist/availability.d.ts +1 -1
  4. package/dist/cart.d.cts +1 -1
  5. package/dist/cart.d.ts +1 -1
  6. package/dist/category.d.cts +1 -1
  7. package/dist/category.d.ts +1 -1
  8. package/dist/checkout.d.cts +1 -1
  9. package/dist/checkout.d.ts +1 -1
  10. package/dist/{chunk-LQFRJSVT.js → chunk-5XZ6MSXW.js} +13 -2
  11. package/dist/chunk-5XZ6MSXW.js.map +1 -0
  12. package/dist/{chunk-PRN3T6TY.js → chunk-UA4BM6OP.js} +20 -2
  13. package/dist/chunk-UA4BM6OP.js.map +1 -0
  14. package/dist/companies.d.cts +1 -1
  15. package/dist/companies.d.ts +1 -1
  16. package/dist/contacts.d.cts +1 -1
  17. package/dist/contacts.d.ts +1 -1
  18. package/dist/{context-DK8jg6y5.d.cts → context-D64-B1Rz.d.cts} +13 -0
  19. package/dist/{context-DK8jg6y5.d.ts → context-D64-B1Rz.d.ts} +13 -0
  20. package/dist/{customer-groups-BfHDqExS.d.cts → customer-groups-B6xrwf59.d.cts} +1 -1
  21. package/dist/{customer-groups-Cs6-Cwzg.d.ts → customer-groups-YZg22bFc.d.ts} +1 -1
  22. package/dist/customer-groups.cjs +11 -0
  23. package/dist/customer-groups.cjs.map +1 -1
  24. package/dist/customer-groups.d.cts +2 -2
  25. package/dist/customer-groups.d.ts +2 -2
  26. package/dist/customer-groups.js +1 -1
  27. package/dist/customer.cjs +18 -0
  28. package/dist/customer.cjs.map +1 -1
  29. package/dist/customer.d.cts +46 -2
  30. package/dist/customer.d.ts +46 -2
  31. package/dist/customer.js +1 -1
  32. package/dist/index.cjs +35 -1
  33. package/dist/index.cjs.map +1 -1
  34. package/dist/index.d.cts +45 -7
  35. package/dist/index.d.ts +45 -7
  36. package/dist/index.js +10 -5
  37. package/dist/index.js.map +1 -1
  38. package/dist/locations.d.cts +1 -1
  39. package/dist/locations.d.ts +1 -1
  40. package/dist/media.d.cts +1 -1
  41. package/dist/media.d.ts +1 -1
  42. package/dist/orders.d.cts +1 -1
  43. package/dist/orders.d.ts +1 -1
  44. package/dist/payment.d.cts +1 -1
  45. package/dist/payment.d.ts +1 -1
  46. package/dist/price.d.cts +1 -1
  47. package/dist/price.d.ts +1 -1
  48. package/dist/product.d.cts +1 -1
  49. package/dist/product.d.ts +1 -1
  50. package/dist/segment.d.cts +1 -1
  51. package/dist/segment.d.ts +1 -1
  52. package/package.json +1 -1
  53. package/dist/chunk-LQFRJSVT.js.map +0 -1
  54. package/dist/chunk-PRN3T6TY.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/errors.ts","../src/core/require-customer.ts","../src/services/customer.ts"],"names":[],"mappings":";;;AACA,IAAM,kBAAA,uBAAyB,GAAA,CAAI;AAAA,EACjC,cAAA;AAAA,EAAgB,eAAA;AAAA,EAAiB,OAAA;AAAA,EAAS,eAAA;AAAA,EAAiB,WAAA;AAAA,EAC3D,QAAA;AAAA,EAAU,eAAA;AAAA,EAAiB,eAAA;AAAA,EAAiB;AAC9C,CAAC,CAAA;AAED,SAAS,MAAM,IAAA,EAAwB;AACrC,EAAA,IAAI,MAAM,OAAA,CAAQ,IAAI,GAAG,OAAO,IAAA,CAAK,IAAI,KAAK,CAAA;AAC9C,EAAA,IAAI,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,EAAU;AACpC,IAAA,MAAM,MAA+B,EAAC;AACtC,IAAA,KAAA,MAAW,CAAC,CAAA,EAAG,CAAC,KAAK,MAAA,CAAO,OAAA,CAAQ,IAA+B,CAAA,EAAG;AACpE,MAAA,GAAA,CAAI,CAAC,CAAA,GAAI,kBAAA,CAAmB,GAAA,CAAI,CAAA,CAAE,aAAa,CAAA,GAAI,gBAAA,GAAmB,KAAA,CA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SACtB,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAiB;AAAA,MAC7B,MAAA,EAAQ,KAAA;AAAA,MACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,CAAA;AAAA,MACrD,IAAA,EAAM,gBAAgB,IAAI;AAAA,KAC3B,CAAA;AAAA,IACH,OAAA,EAAS,OAAO,EAAA,EAAY,IAAA,EAAgB,IAAA,KAAsC;AAChF,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,MAAA;AAAA,QACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,KAAA,CAAA;AAAA,QACrD,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH,CAAA;AAAA,IACA,UAAA,EAAY,OAAO,EAAA,EAAY,IAAA,EAAgB,IAAA,KAAsC;AACnF,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,QAAA;AAAA,QACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,KAAA,CAAA;AAAA,QACrD,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"customer.cjs","sourcesContent":["/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { AuthContext } from \"./auth\";\nimport { EmporixAuthError } from \"./errors\";\n\n/**\n * Enforces a caller-owned customer or raw token. Throws `EmporixAuthError`\n * for any other `AuthContext` kind (or when `auth` is missing). Shared by\n * services whose endpoints require a customer scope (`/me`, payments,\n * customer-segments…).\n */\nexport function requireCustomer(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"raw\")) return auth;\n throw new EmporixAuthError(\"This operation requires a customer or raw AuthContext\");\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext, AnonymousSession } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { requireCustomer } from \"../core/require-customer\";\nimport type {\n Customer as GeneratedCustomer,\n Address as GeneratedAddress,\n CustomerSignup,\n CustomerUpdateDto,\n PasswordChangeDto,\n PasswordResetRequestDto,\n PasswordUpdate,\n AddressCreateDto,\n AddressUpdateDto,\n ChangeEmailRequestDto,\n UpdateEmail,\n RefreshToken,\n} from \"../generated/customer\";\n\n/**\n * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to\n * idiomatic names: `access_token` → `customerToken`, `saas_token` →\n * `saasToken`. `saasToken` is a JWT required for the checkout (`saas-token`\n * header). The wire's `*_token` (snake_case) fields are canonical; the\n * camelCase variants are deprecated in the Emporix spec.\n */\nexport interface CustomerSession {\n customerToken: string;\n /** JWT required for completing checkout (sent as the `saas-token` header). */\n saasToken: string;\n refreshToken: string;\n /** Same session as the anonymous token — preserves the cart across login. */\n sessionId: string | undefined;\n /** Customer access-token lifetime in seconds. */\n expiresIn: number | undefined;\n /** Only set by `socialLogin`: the IdP access token echoed by Emporix. */\n socialAccessToken?: string;\n /** Only set by `socialLogin`: the IdP ID token echoed by Emporix. */\n socialIdToken?: string;\n}\n\n/** Customer profile as returned by the Customer service (all generated fields). */\nexport type Customer = GeneratedCustomer;\n\n/** A customer address as returned by the Customer service (all generated fields). */\nexport type Address = GeneratedAddress;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CustomerSignupInput = CustomerSignup;\nexport type CustomerUpdateInput = CustomerUpdateDto;\nexport type PasswordChangeInput = PasswordChangeDto;\nexport type PasswordResetRequestInput = PasswordResetRequestDto;\nexport type PasswordResetConfirmInput = PasswordUpdate;\nexport type AddressCreateInput = AddressCreateDto;\nexport type AddressUpdateInput = AddressUpdateDto;\nexport type ChangeEmailInput = ChangeEmailRequestDto;\nexport type ConfirmEmailChangeInput = UpdateEmail;\nexport type ResendActivationInput = RefreshToken;\n\n/** Union of the wire shapes the four session endpoints return. snake_case is\n * canonical; camelCase is the deprecated fallback (vendored spec, design §2). */\ninterface WireSession {\n access_token?: string;\n saas_token?: string;\n refresh_token?: string;\n session_id?: string;\n expires_in?: string | number;\n accessToken?: string;\n saasToken?: string;\n refreshToken?: string;\n social_access_token?: string;\n social_id_token?: string;\n}\n\n/** Wire→facade mapping shared by login/refresh/socialLogin/exchangeToken.\n * Throws instead of fabricating an empty session: `customerToken: \"\"` would\n * read as authenticated downstream and 401-loop every subsequent call. */\nfunction toSession(\n endpoint: string,\n wire: WireSession,\n opts: { carrySaasToken?: string } = {},\n): CustomerSession {\n const customerToken = wire.access_token ?? wire.accessToken;\n if (!customerToken) {\n throw new EmporixAuthError(`${endpoint}: response missing access_token`, undefined, wire);\n }\n return {\n customerToken,\n saasToken: wire.saas_token ?? wire.saasToken ?? opts.carrySaasToken ?? \"\",\n refreshToken: wire.refresh_token ?? wire.refreshToken ?? \"\",\n sessionId: wire.session_id,\n expiresIn: wire.expires_in != null ? Number(wire.expires_in) : undefined,\n ...(wire.social_access_token ? { socialAccessToken: wire.social_access_token } : {}),\n ...(wire.social_id_token ? { socialIdToken: wire.social_id_token } : {}),\n };\n}\n\n/** Customer signup, session, profile and addresses. */\nexport class CustomerService {\n static readonly channel = \"customer\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Obtains an anonymous storefront session (accessToken + sessionId + refreshToken). */\n async anonymous(): Promise<AnonymousSession> {\n return this.ctx.tokenProvider.getAnonymousToken();\n }\n\n /** Registers a customer. Default auth: anonymous. */\n async signup(\n input: CustomerSignupInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup`,\n auth,\n body: input,\n });\n }\n\n /**\n * Logs a customer in. Threads the anonymous token so the session (and its\n * cart) survives — losing it silently creates a new session per Emporix docs.\n * Wire `accessToken` is mapped to `customerToken`.\n */\n async login(\n creds: { email: string; password: string },\n opts: { anonymousToken?: string } = {},\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const effective: AuthContext = opts.anonymousToken\n ? { kind: \"raw\", token: opts.anonymousToken }\n : auth;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/login`,\n auth: effective,\n body: creds,\n });\n return toSession(\"login\", wire);\n }\n\n /**\n * Refreshes an authenticated customer session via its refresh token,\n * preserving the same `sessionId`. Calls\n * `GET /customer/{tenant}/refreshauthtoken?refreshToken=…`, which **must be\n * authorized with an anonymous token** (default auth: anonymous) — not the\n * expired customer token. The refresh response does **not** include a\n * `saas_token`; pass the original `saasToken` to carry it forward (it has\n * its own, independent lifetime).\n */\n async refresh(\n input: { refreshToken: string; saasToken?: string; legalEntityId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { refreshToken: input.refreshToken };\n if (input.legalEntityId) query.legalEntityId = input.legalEntityId;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/refreshauthtoken`,\n query,\n auth,\n });\n // Refresh does not return a saas_token — carry the original forward.\n return toSession(\n \"refresh\",\n wire,\n input.saasToken !== undefined ? { carrySaasToken: input.saasToken } : {},\n );\n }\n\n /**\n * Logs the customer out server-side: `GET /customer/{tenant}/logout?\n * accessToken=…` authorized with the customer token. Invalidates the\n * access token (204 No Content). Requires customer/raw auth — the token is\n * sent both as the bearer and the `accessToken` query param (per Emporix).\n */\n async logout(auth?: AuthContext): Promise<void> {\n const ctx = requireCustomer(auth);\n const token = (ctx as { token: string }).token;\n await this.ctx.http.request<void>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/logout`,\n query: { accessToken: token },\n auth: ctx,\n });\n }\n\n /**\n * Authorization-Code SSO: exchanges the IdP `code` for an Emporix customer\n * session via `POST /customer/{tenant}/socialLogin`. The browser performs\n * the IdP redirect itself; the SDK only does this Emporix exchange.\n * Default auth: anonymous (Emporix requires an anonymous Bearer). The\n * response has no `session_id` and returns `expires_in` as a string —\n * normalized to a number here.\n */\n async socialLogin(\n input: { code: string; redirectUri: string; codeVerifier?: string; sessionId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = {\n code: input.code,\n redirect_uri: input.redirectUri,\n };\n if (input.codeVerifier) query.code_verifier = input.codeVerifier;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/socialLogin`,\n query,\n auth,\n ...(input.sessionId ? { headers: { \"session-id\": input.sessionId } } : {}),\n });\n return toSession(\"socialLogin\", wire);\n }\n\n /**\n * RFC 8693 token exchange: exchanges an external IdP JWT for an Emporix\n * customer session via `POST /customer/{tenant}/exchangeauthtoken`.\n * Emporix uses a proprietary query-param wire (not the RFC form body).\n * Default auth: anonymous. `config` selects a site-specific IdP config\n * (multi-site); omit for the tenant default. Returns `session_id` and a\n * fresh `saas_token`; `expires_in` is an integer (normalized anyway).\n */\n async exchangeToken(\n input: { subjectToken: string; config?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { subjectAccessToken: input.subjectToken };\n if (input.config) query.config = input.config;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/exchangeauthtoken`,\n query,\n auth,\n });\n return toSession(\"exchangeToken\", wire);\n }\n\n /** Returns the authenticated customer. Requires customer/raw auth. */\n async me(auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n });\n }\n\n /** Updates the authenticated customer. Requires customer/raw auth. */\n async update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n body: patch,\n });\n }\n\n /** Changes the password. Requires customer/raw auth. */\n async changePassword(input: PasswordChangeInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Requests a password reset email. Default auth: anonymous. */\n async requestPasswordReset(\n input: PasswordResetRequestInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset`,\n auth,\n body: input,\n });\n }\n\n /** Confirms a password reset. Default auth: anonymous. */\n async confirmPasswordReset(\n input: PasswordResetConfirmInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset/update`,\n auth,\n body: input,\n });\n }\n\n /**\n * Completes double opt-in signup with the emailed token, creating the account\n * and returning a logged-in {@link CustomerSession}. Default auth: anonymous.\n */\n async confirmSignup(\n token: string,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/signup/optin/${encodeURIComponent(token)}`,\n auth,\n });\n return toSession(\"confirmSignup\", wire);\n }\n\n /** Resends the double opt-in activation link. Default auth: anonymous. */\n async resendActivation(\n input: ResendActivationInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup/optin/refresh_token`,\n auth,\n body: input,\n });\n }\n\n /** Requests a login-email change (emails a confirmation token). Requires customer/raw auth. */\n async changeEmail(input: ChangeEmailInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Confirms a login-email change with the emailed token. Default auth: anonymous. */\n async confirmEmailChange(\n input: ConfirmEmailChangeInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change/confirm`,\n auth,\n body: input,\n });\n }\n\n /** Address sub-resource. All operations require customer/raw auth. */\n readonly addresses = {\n list: async (auth?: AuthContext): Promise<Address[]> =>\n this.ctx.http.request<Address[]>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n }),\n add: async (address: AddressCreateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n body: address,\n }),\n update: async (id: string, patch: AddressUpdateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n body: patch,\n }),\n remove: async (id: string, auth?: AuthContext): Promise<void> =>\n this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n get: async (id: string, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n addTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n removeTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n };\n}\n"]}
1
+ {"version":3,"sources":["../src/core/errors.ts","../src/core/require-customer.ts","../src/services/customer.ts"],"names":[],"mappings":";;;AACA,IAAM,kBAAA,uBAAyB,GAAA,CAAI;AAAA,EACjC,cAAA;AAAA,EAAgB,eAAA;AAAA,EAAiB,OAAA;AAAA,EAAS,eAAA;AAAA,EAAiB,WAAA;AAAA,EAC3D,QAAA;AAAA,EAAU,eAAA;AAAA,EAAiB,eAAA;AAAA,EAAiB;AAC9C,CAAC,CAAA;AAED,SAAS,MAAM,IAAA,EAAwB;AACrC,EAAA,IAAI,MAAM,OAAA,CAAQ,IAAI,GAAG,OAAO,IAAA,CAAK,IAAI,KAAK,C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,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH,CAAA;AAAA,IACA,UAAA,EAAY,OAAO,EAAA,EAAY,IAAA,EAAgB,IAAA,KAAsC;AACnF,MAAA,MAAM,IAAA,CAAK,GAAA,CAAI,IAAA,CAAK,OAAA,CAAc;AAAA,QAChC,MAAA,EAAQ,QAAA;AAAA,QACR,MAAM,CAAA,UAAA,EAAa,IAAA,CAAK,GAAA,CAAI,MAAM,iBAAiB,EAAE,CAAA,KAAA,CAAA;AAAA,QACrD,OAAO,EAAE,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,GAAG,CAAA,EAAE;AAAA,QAC9B,IAAA,EAAM,gBAAgB,IAAI;AAAA,OAC3B,CAAA;AAAA,IACH;AAAA,GACF;AACF","file":"customer.cjs","sourcesContent":["/** Keys whose values are stripped from any serialised error body. */\nconst REDACTED_BODY_KEYS = new Set([\n \"access_token\", \"refresh_token\", \"token\", \"customertoken\", \"saastoken\",\n \"secret\", \"client_secret\", \"authorization\", \"password\",\n]);\n\nfunction scrub(body: unknown): unknown {\n if (Array.isArray(body)) return body.map(scrub);\n if (body && typeof body === \"object\") {\n const out: Record<string, unknown> = {};\n for (const [k, v] of Object.entries(body as Record<string, unknown>)) {\n out[k] = REDACTED_BODY_KEYS.has(k.toLowerCase()) ? \"***redacted***\" : scrub(v);\n }\n return out;\n }\n return body;\n}\n\n/** Base class for every error thrown by the SDK. */\nexport class EmporixError extends Error {\n readonly status: number | undefined;\n readonly body: unknown;\n constructor(message: string, status?: number, body?: unknown) {\n super(message);\n this.name = new.target.name;\n this.status = status;\n this.body = body;\n Object.setPrototypeOf(this, new.target.prototype);\n }\n /** Safe serialisation — token-like body fields are redacted. */\n toJSON(): Record<string, unknown> {\n return { name: this.name, message: this.message, status: this.status, body: scrub(this.body) };\n }\n}\n\n/** 401 — authentication failed or token expired. */\nexport class EmporixAuthError extends EmporixError {}\n/** 403 — authenticated but not permitted. */\nexport class EmporixForbiddenError extends EmporixError {}\n/** 404 — resource not found. */\nexport class EmporixNotFoundError extends EmporixError {}\n/** 400/422 — request validation failed. */\nexport class EmporixValidationError extends EmporixError {}\n/** 5xx — server-side failure. */\nexport class EmporixServerError extends EmporixError {}\n/** Request aborted by the configured connect/read timeout. No HTTP status. */\nexport class EmporixTimeoutError extends EmporixError {}\n/** DNS/TLS/connection-level failure before or during the exchange. No HTTP status. */\nexport class EmporixNetworkError extends EmporixError {}\n\n/**\n * 403 with a `missing scope: <name>` hint in the body's `details` array.\n * Subclasses {@link EmporixForbiddenError} so existing 403 catches still work.\n */\nexport class EmporixInsufficientScopeError extends EmporixForbiddenError {\n readonly requiredScope: string | undefined;\n constructor(message: string, status: number, body: unknown, requiredScope?: string) {\n super(message, status, body);\n this.requiredScope = requiredScope;\n }\n}\n\nconst SCOPE_HINT_RE = /missing scope[: ]+([a-z0-9._-]+)/i;\n\nfunction extractRequiredScope(body: unknown): string | undefined {\n if (body && typeof body === \"object\" && \"details\" in body) {\n const details = (body as { details?: unknown }).details;\n if (Array.isArray(details)) {\n for (const d of details) {\n if (typeof d === \"string\") {\n const m = d.match(SCOPE_HINT_RE);\n if (m) return m[1];\n }\n }\n }\n }\n return undefined;\n}\n\n/** Maps an HTTP status to the matching {@link EmporixError} subclass. */\nexport function errorFromResponse(status: number, message: string, body: unknown): EmporixError {\n if (status === 401) return new EmporixAuthError(message, status, body);\n if (status === 403) {\n const scope = extractRequiredScope(body);\n if (scope) return new EmporixInsufficientScopeError(message, status, body, scope);\n return new EmporixForbiddenError(message, status, body);\n }\n if (status === 404) return new EmporixNotFoundError(message, status, body);\n if (status === 400 || status === 422) return new EmporixValidationError(message, status, body);\n if (status >= 500) return new EmporixServerError(message, status, body);\n return new EmporixError(message, status, body);\n}\n","import type { AuthContext } from \"./auth\";\nimport { EmporixAuthError } from \"./errors\";\n\n/**\n * Enforces a caller-owned customer or raw token. Throws `EmporixAuthError`\n * for any other `AuthContext` kind (or when `auth` is missing). Shared by\n * services whose endpoints require a customer scope (`/me`, payments,\n * customer-segments…).\n */\nexport function requireCustomer(auth: AuthContext | undefined): AuthContext {\n if (auth && (auth.kind === \"customer\" || auth.kind === \"raw\")) return auth;\n throw new EmporixAuthError(\"This operation requires a customer or raw AuthContext\");\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext, AnonymousSession } from \"../core/auth\";\nimport { EmporixAuthError } from \"../core/errors\";\nimport { requireCustomer } from \"../core/require-customer\";\nimport type {\n Customer as GeneratedCustomer,\n Address as GeneratedAddress,\n CustomerSignup,\n CustomerUpdateDto,\n PasswordChangeDto,\n PasswordResetRequestDto,\n PasswordUpdate,\n AddressCreateDto,\n AddressUpdateDto,\n ChangeEmailRequestDto,\n UpdateEmail,\n RefreshToken,\n ValidateTokenResponse,\n} from \"../generated/customer\";\n\n/**\n * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to\n * idiomatic names: `access_token` → `customerToken`, `saas_token` →\n * `saasToken`. `saasToken` is a JWT required for the checkout (`saas-token`\n * header). The wire's `*_token` (snake_case) fields are canonical; the\n * camelCase variants are deprecated in the Emporix spec.\n */\nexport interface CustomerSession {\n customerToken: string;\n /** JWT required for completing checkout (sent as the `saas-token` header). */\n saasToken: string;\n refreshToken: string;\n /** Same session as the anonymous token — preserves the cart across login. */\n sessionId: string | undefined;\n /** Customer access-token lifetime in seconds. */\n expiresIn: number | undefined;\n /** Only set by `socialLogin`: the IdP access token echoed by Emporix. */\n socialAccessToken?: string;\n /** Only set by `socialLogin`: the IdP ID token echoed by Emporix. */\n socialIdToken?: string;\n}\n\n/** Customer profile as returned by the Customer service (all generated fields). */\nexport type Customer = GeneratedCustomer;\n\n/** A customer address as returned by the Customer service (all generated fields). */\nexport type Address = GeneratedAddress;\n\n/** Generated request bodies (caller sends the exact wire shape). */\nexport type CustomerSignupInput = CustomerSignup;\nexport type CustomerUpdateInput = CustomerUpdateDto;\nexport type PasswordChangeInput = PasswordChangeDto;\nexport type PasswordResetRequestInput = PasswordResetRequestDto;\nexport type PasswordResetConfirmInput = PasswordUpdate;\nexport type AddressCreateInput = AddressCreateDto;\nexport type AddressUpdateInput = AddressUpdateDto;\nexport type ChangeEmailInput = ChangeEmailRequestDto;\nexport type ConfirmEmailChangeInput = UpdateEmail;\nexport type ResendActivationInput = RefreshToken;\n/**\n * What `validateToken` reports about a customer token: `scope` is the\n * space-separated scope list, plus `sessionId`, `email`, `legalEntityId` and\n * `expires_in`. Every field is optional upstream.\n */\nexport type CustomerTokenValidation = ValidateTokenResponse;\n\n/** Union of the wire shapes the four session endpoints return. snake_case is\n * canonical; camelCase is the deprecated fallback (vendored spec, design §2). */\ninterface WireSession {\n access_token?: string;\n saas_token?: string;\n refresh_token?: string;\n session_id?: string;\n expires_in?: string | number;\n accessToken?: string;\n saasToken?: string;\n refreshToken?: string;\n social_access_token?: string;\n social_id_token?: string;\n}\n\n/** Wire→facade mapping shared by login/refresh/socialLogin/exchangeToken.\n * Throws instead of fabricating an empty session: `customerToken: \"\"` would\n * read as authenticated downstream and 401-loop every subsequent call. */\nfunction toSession(\n endpoint: string,\n wire: WireSession,\n opts: { carrySaasToken?: string } = {},\n): CustomerSession {\n const customerToken = wire.access_token ?? wire.accessToken;\n if (!customerToken) {\n throw new EmporixAuthError(`${endpoint}: response missing access_token`, undefined, wire);\n }\n return {\n customerToken,\n saasToken: wire.saas_token ?? wire.saasToken ?? opts.carrySaasToken ?? \"\",\n refreshToken: wire.refresh_token ?? wire.refreshToken ?? \"\",\n sessionId: wire.session_id,\n expiresIn: wire.expires_in != null ? Number(wire.expires_in) : undefined,\n ...(wire.social_access_token ? { socialAccessToken: wire.social_access_token } : {}),\n ...(wire.social_id_token ? { socialIdToken: wire.social_id_token } : {}),\n };\n}\n\n/** Customer signup, session, profile and addresses. */\nexport class CustomerService {\n static readonly channel = \"customer\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n /** Obtains an anonymous storefront session (accessToken + sessionId + refreshToken). */\n async anonymous(): Promise<AnonymousSession> {\n return this.ctx.tokenProvider.getAnonymousToken();\n }\n\n /** Registers a customer. Default auth: anonymous. */\n async signup(\n input: CustomerSignupInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup`,\n auth,\n body: input,\n });\n }\n\n /**\n * Logs a customer in. Threads the anonymous token so the session (and its\n * cart) survives — losing it silently creates a new session per Emporix docs.\n * Wire `accessToken` is mapped to `customerToken`.\n */\n async login(\n creds: { email: string; password: string },\n opts: { anonymousToken?: string } = {},\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const effective: AuthContext = opts.anonymousToken\n ? { kind: \"raw\", token: opts.anonymousToken }\n : auth;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/login`,\n auth: effective,\n body: creds,\n });\n return toSession(\"login\", wire);\n }\n\n /**\n * Refreshes an authenticated customer session via its refresh token,\n * preserving the same `sessionId`. Calls\n * `GET /customer/{tenant}/refreshauthtoken?refreshToken=…`, which **must be\n * authorized with an anonymous token** (default auth: anonymous) — not the\n * expired customer token. The refresh response does **not** include a\n * `saas_token`; pass the original `saasToken` to carry it forward (it has\n * its own, independent lifetime).\n */\n async refresh(\n input: { refreshToken: string; saasToken?: string; legalEntityId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { refreshToken: input.refreshToken };\n if (input.legalEntityId) query.legalEntityId = input.legalEntityId;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/refreshauthtoken`,\n query,\n auth,\n });\n // Refresh does not return a saas_token — carry the original forward.\n return toSession(\n \"refresh\",\n wire,\n input.saasToken !== undefined ? { carrySaasToken: input.saasToken } : {},\n );\n }\n\n /**\n * Logs the customer out server-side: `GET /customer/{tenant}/logout?\n * accessToken=…` authorized with the customer token. Invalidates the\n * access token (204 No Content). Requires customer/raw auth — the token is\n * sent both as the bearer and the `accessToken` query param (per Emporix).\n */\n async logout(auth?: AuthContext): Promise<void> {\n const ctx = requireCustomer(auth);\n const token = (ctx as { token: string }).token;\n await this.ctx.http.request<void>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/logout`,\n query: { accessToken: token },\n auth: ctx,\n });\n }\n\n /**\n * Authorization-Code SSO: exchanges the IdP `code` for an Emporix customer\n * session via `POST /customer/{tenant}/socialLogin`. The browser performs\n * the IdP redirect itself; the SDK only does this Emporix exchange.\n * Default auth: anonymous (Emporix requires an anonymous Bearer). The\n * response has no `session_id` and returns `expires_in` as a string —\n * normalized to a number here.\n */\n async socialLogin(\n input: { code: string; redirectUri: string; codeVerifier?: string; sessionId?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = {\n code: input.code,\n redirect_uri: input.redirectUri,\n };\n if (input.codeVerifier) query.code_verifier = input.codeVerifier;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/socialLogin`,\n query,\n auth,\n ...(input.sessionId ? { headers: { \"session-id\": input.sessionId } } : {}),\n });\n return toSession(\"socialLogin\", wire);\n }\n\n /**\n * RFC 8693 token exchange: exchanges an external IdP JWT for an Emporix\n * customer session via `POST /customer/{tenant}/exchangeauthtoken`.\n * Emporix uses a proprietary query-param wire (not the RFC form body).\n * Default auth: anonymous. `config` selects a site-specific IdP config\n * (multi-site); omit for the tenant default. Returns `session_id` and a\n * fresh `saas_token`; `expires_in` is an integer (normalized anyway).\n */\n async exchangeToken(\n input: { subjectToken: string; config?: string },\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const query: Record<string, string> = { subjectAccessToken: input.subjectToken };\n if (input.config) query.config = input.config;\n const wire = await this.ctx.http.request<WireSession>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/exchangeauthtoken`,\n query,\n auth,\n });\n return toSession(\"exchangeToken\", wire);\n }\n\n /** Returns the authenticated customer. Requires customer/raw auth. */\n async me(auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n });\n }\n\n /**\n * Validates a customer token and returns what the tenant knows about it —\n * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`\n * (`GET /validateauthtoken`). Requires customer/raw auth.\n *\n * An invalid or expired token answers `401`, which surfaces as\n * {@link EmporixAuthError} rather than a falsy result: this is a check, not a\n * predicate. Reach for it when you hold a token from elsewhere — an SSO\n * exchange, a Managed Dashboard host — and need its scopes before deciding\n * what to render, instead of discovering them from a failed call.\n */\n async validateToken(auth?: AuthContext): Promise<CustomerTokenValidation> {\n return this.ctx.http.request<CustomerTokenValidation>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/validateauthtoken`,\n auth: requireCustomer(auth),\n });\n }\n\n /** Updates the authenticated customer. Requires customer/raw auth. */\n async update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer> {\n return this.ctx.http.request<Customer>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me`,\n auth: requireCustomer(auth),\n body: patch,\n });\n }\n\n /** Changes the password. Requires customer/raw auth. */\n async changePassword(input: PasswordChangeInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Requests a password reset email. Default auth: anonymous. */\n async requestPasswordReset(\n input: PasswordResetRequestInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset`,\n auth,\n body: input,\n });\n }\n\n /** Confirms a password reset. Default auth: anonymous. */\n async confirmPasswordReset(\n input: PasswordResetConfirmInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/password/reset/update`,\n auth,\n body: input,\n });\n }\n\n /**\n * Completes double opt-in signup with the emailed token, creating the account\n * and returning a logged-in {@link CustomerSession}. Default auth: anonymous.\n */\n async confirmSignup(\n token: string,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<CustomerSession> {\n const wire = await this.ctx.http.request<WireSession>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/signup/optin/${encodeURIComponent(token)}`,\n auth,\n });\n return toSession(\"confirmSignup\", wire);\n }\n\n /** Resends the double opt-in activation link. Default auth: anonymous. */\n async resendActivation(\n input: ResendActivationInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/signup/optin/refresh_token`,\n auth,\n body: input,\n });\n }\n\n /** Requests a login-email change (emails a confirmation token). Requires customer/raw auth. */\n async changeEmail(input: ChangeEmailInput, auth?: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change`,\n auth: requireCustomer(auth),\n body: input,\n });\n }\n\n /** Confirms a login-email change with the emailed token. Default auth: anonymous. */\n async confirmEmailChange(\n input: ConfirmEmailChangeInput,\n auth: AuthContext = { kind: \"anonymous\" },\n ): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/accounts/internal/email/change/confirm`,\n auth,\n body: input,\n });\n }\n\n /** Address sub-resource. All operations require customer/raw auth. */\n readonly addresses = {\n list: async (auth?: AuthContext): Promise<Address[]> =>\n this.ctx.http.request<Address[]>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n }),\n add: async (address: AddressCreateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses`,\n auth: requireCustomer(auth),\n body: address,\n }),\n update: async (id: string, patch: AddressUpdateInput, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"PUT\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n body: patch,\n }),\n remove: async (id: string, auth?: AuthContext): Promise<void> =>\n this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n get: async (id: string, auth?: AuthContext): Promise<Address> =>\n this.ctx.http.request<Address>({\n method: \"GET\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}`,\n auth: requireCustomer(auth),\n }),\n addTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"POST\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n removeTags: async (id: string, tags: string[], auth?: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/customer/${this.ctx.tenant}/me/addresses/${id}/tags`,\n query: { tags: tags.join(\",\") },\n auth: requireCustomer(auth),\n });\n },\n };\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-DK8jg6y5.cjs';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-D64-B1Rz.cjs';
2
2
 
3
3
  type AccountId = {
4
4
  /**
@@ -314,6 +314,32 @@ type UpdateEmail = {
314
314
  */
315
315
  token?: string;
316
316
  };
317
+ type ValidateTokenResponse = {
318
+ /**
319
+ * Type of the token. Usually it's `Bearer`.
320
+ */
321
+ token_type?: string;
322
+ /**
323
+ * Specifies the token's expiration time, represented in seconds.
324
+ */
325
+ expires_in?: number;
326
+ /**
327
+ * A list of scopes assigned to the user.
328
+ */
329
+ scope?: string;
330
+ /**
331
+ * Identifier of the user session.
332
+ */
333
+ sessionId?: string;
334
+ /**
335
+ * Customer email used to login (generate the token).
336
+ */
337
+ email?: string;
338
+ /**
339
+ * Legal Entity ID.
340
+ */
341
+ legalEntityId?: string;
342
+ };
317
343
 
318
344
  /**
319
345
  * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to
@@ -351,6 +377,12 @@ type AddressUpdateInput = AddressUpdateDto;
351
377
  type ChangeEmailInput = ChangeEmailRequestDto;
352
378
  type ConfirmEmailChangeInput = UpdateEmail;
353
379
  type ResendActivationInput = RefreshToken;
380
+ /**
381
+ * What `validateToken` reports about a customer token: `scope` is the
382
+ * space-separated scope list, plus `sessionId`, `email`, `legalEntityId` and
383
+ * `expires_in`. Every field is optional upstream.
384
+ */
385
+ type CustomerTokenValidation = ValidateTokenResponse;
354
386
  /** Customer signup, session, profile and addresses. */
355
387
  declare class CustomerService {
356
388
  private readonly ctx;
@@ -420,6 +452,18 @@ declare class CustomerService {
420
452
  }, auth?: AuthContext): Promise<CustomerSession>;
421
453
  /** Returns the authenticated customer. Requires customer/raw auth. */
422
454
  me(auth?: AuthContext): Promise<Customer>;
455
+ /**
456
+ * Validates a customer token and returns what the tenant knows about it —
457
+ * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`
458
+ * (`GET /validateauthtoken`). Requires customer/raw auth.
459
+ *
460
+ * An invalid or expired token answers `401`, which surfaces as
461
+ * {@link EmporixAuthError} rather than a falsy result: this is a check, not a
462
+ * predicate. Reach for it when you hold a token from elsewhere — an SSO
463
+ * exchange, a Managed Dashboard host — and need its scopes before deciding
464
+ * what to render, instead of discovering them from a failed call.
465
+ */
466
+ validateToken(auth?: AuthContext): Promise<CustomerTokenValidation>;
423
467
  /** Updates the authenticated customer. Requires customer/raw auth. */
424
468
  update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer>;
425
469
  /** Changes the password. Requires customer/raw auth. */
@@ -451,4 +495,4 @@ declare class CustomerService {
451
495
  };
452
496
  }
453
497
 
454
- export { type Address, type AddressCreateInput, type AddressUpdateInput, type ChangeEmailInput, type ConfirmEmailChangeInput, type Customer, CustomerService, type CustomerSession, type CustomerSignupInput, type CustomerUpdateInput, type PasswordChangeInput, type PasswordResetConfirmInput, type PasswordResetRequestInput, type ResendActivationInput };
498
+ export { type Address, type AddressCreateInput, type AddressUpdateInput, type ChangeEmailInput, type ConfirmEmailChangeInput, type Customer, CustomerService, type CustomerSession, type CustomerSignupInput, type CustomerTokenValidation, type CustomerUpdateInput, type PasswordChangeInput, type PasswordResetConfirmInput, type PasswordResetRequestInput, type ResendActivationInput };
@@ -1,4 +1,4 @@
1
- import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-DK8jg6y5.js';
1
+ import { C as ClientContext, A as AnonymousSession, b as AuthContext } from './context-D64-B1Rz.js';
2
2
 
3
3
  type AccountId = {
4
4
  /**
@@ -314,6 +314,32 @@ type UpdateEmail = {
314
314
  */
315
315
  token?: string;
316
316
  };
317
+ type ValidateTokenResponse = {
318
+ /**
319
+ * Type of the token. Usually it's `Bearer`.
320
+ */
321
+ token_type?: string;
322
+ /**
323
+ * Specifies the token's expiration time, represented in seconds.
324
+ */
325
+ expires_in?: number;
326
+ /**
327
+ * A list of scopes assigned to the user.
328
+ */
329
+ scope?: string;
330
+ /**
331
+ * Identifier of the user session.
332
+ */
333
+ sessionId?: string;
334
+ /**
335
+ * Customer email used to login (generate the token).
336
+ */
337
+ email?: string;
338
+ /**
339
+ * Legal Entity ID.
340
+ */
341
+ legalEntityId?: string;
342
+ };
317
343
 
318
344
  /**
319
345
  * Caller-owned customer session. Maps the Emporix `CustomerToken` wire shape to
@@ -351,6 +377,12 @@ type AddressUpdateInput = AddressUpdateDto;
351
377
  type ChangeEmailInput = ChangeEmailRequestDto;
352
378
  type ConfirmEmailChangeInput = UpdateEmail;
353
379
  type ResendActivationInput = RefreshToken;
380
+ /**
381
+ * What `validateToken` reports about a customer token: `scope` is the
382
+ * space-separated scope list, plus `sessionId`, `email`, `legalEntityId` and
383
+ * `expires_in`. Every field is optional upstream.
384
+ */
385
+ type CustomerTokenValidation = ValidateTokenResponse;
354
386
  /** Customer signup, session, profile and addresses. */
355
387
  declare class CustomerService {
356
388
  private readonly ctx;
@@ -420,6 +452,18 @@ declare class CustomerService {
420
452
  }, auth?: AuthContext): Promise<CustomerSession>;
421
453
  /** Returns the authenticated customer. Requires customer/raw auth. */
422
454
  me(auth?: AuthContext): Promise<Customer>;
455
+ /**
456
+ * Validates a customer token and returns what the tenant knows about it —
457
+ * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`
458
+ * (`GET /validateauthtoken`). Requires customer/raw auth.
459
+ *
460
+ * An invalid or expired token answers `401`, which surfaces as
461
+ * {@link EmporixAuthError} rather than a falsy result: this is a check, not a
462
+ * predicate. Reach for it when you hold a token from elsewhere — an SSO
463
+ * exchange, a Managed Dashboard host — and need its scopes before deciding
464
+ * what to render, instead of discovering them from a failed call.
465
+ */
466
+ validateToken(auth?: AuthContext): Promise<CustomerTokenValidation>;
423
467
  /** Updates the authenticated customer. Requires customer/raw auth. */
424
468
  update(patch: CustomerUpdateInput, auth?: AuthContext): Promise<Customer>;
425
469
  /** Changes the password. Requires customer/raw auth. */
@@ -451,4 +495,4 @@ declare class CustomerService {
451
495
  };
452
496
  }
453
497
 
454
- export { type Address, type AddressCreateInput, type AddressUpdateInput, type ChangeEmailInput, type ConfirmEmailChangeInput, type Customer, CustomerService, type CustomerSession, type CustomerSignupInput, type CustomerUpdateInput, type PasswordChangeInput, type PasswordResetConfirmInput, type PasswordResetRequestInput, type ResendActivationInput };
498
+ export { type Address, type AddressCreateInput, type AddressUpdateInput, type ChangeEmailInput, type ConfirmEmailChangeInput, type Customer, CustomerService, type CustomerSession, type CustomerSignupInput, type CustomerTokenValidation, type CustomerUpdateInput, type PasswordChangeInput, type PasswordResetConfirmInput, type PasswordResetRequestInput, type ResendActivationInput };
package/dist/customer.js CHANGED
@@ -1,4 +1,4 @@
1
- export { CustomerService } from './chunk-PRN3T6TY.js';
1
+ export { CustomerService } from './chunk-UA4BM6OP.js';
2
2
  import './chunk-3BDDYX3V.js';
3
3
  import './chunk-UWGGF4MC.js';
4
4
  //# sourceMappingURL=customer.js.map
package/dist/index.cjs CHANGED
@@ -741,6 +741,10 @@ var HttpClient = class {
741
741
  doFetch;
742
742
  buildHeaders(o, token, isFormData) {
743
743
  return {
744
+ // Before `o.headers` on purpose: a caller may override the tenant for a
745
+ // single request, the way `Accept-Language` can be overridden. Only
746
+ // `Authorization` is non-negotiable.
747
+ ...this.opts.tenant !== void 0 ? { "Emporix-Tenant": this.opts.tenant } : {},
744
748
  ...this.opts.requestContext?.language ? { "Accept-Language": this.opts.requestContext.language } : {},
745
749
  ...o.headers ?? {},
746
750
  Authorization: `Bearer ${token}`,
@@ -995,7 +999,7 @@ var HttpClient = class {
995
999
  };
996
1000
 
997
1001
  // package.json
998
- var version = "2.36.1";
1002
+ var version = "2.38.0";
999
1003
 
1000
1004
  // src/version.ts
1001
1005
  var SDK_VERSION = version;
@@ -1029,6 +1033,7 @@ function createCore(config) {
1029
1033
  logger: root.child({ service }),
1030
1034
  http: new HttpClient({
1031
1035
  host: cfg.host,
1036
+ tenant: cfg.tenant,
1032
1037
  provider: tokenProvider,
1033
1038
  logger: root.child({ service: "http" }),
1034
1039
  retry: cfg.retry,
@@ -1212,6 +1217,24 @@ var CustomerService = class {
1212
1217
  auth: requireCustomer(auth2)
1213
1218
  });
1214
1219
  }
1220
+ /**
1221
+ * Validates a customer token and returns what the tenant knows about it —
1222
+ * `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`
1223
+ * (`GET /validateauthtoken`). Requires customer/raw auth.
1224
+ *
1225
+ * An invalid or expired token answers `401`, which surfaces as
1226
+ * {@link EmporixAuthError} rather than a falsy result: this is a check, not a
1227
+ * predicate. Reach for it when you hold a token from elsewhere — an SSO
1228
+ * exchange, a Managed Dashboard host — and need its scopes before deciding
1229
+ * what to render, instead of discovering them from a failed call.
1230
+ */
1231
+ async validateToken(auth2) {
1232
+ return this.ctx.http.request({
1233
+ method: "GET",
1234
+ path: `/customer/${this.ctx.tenant}/validateauthtoken`,
1235
+ auth: requireCustomer(auth2)
1236
+ });
1237
+ }
1215
1238
  /** Updates the authenticated customer. Requires customer/raw auth. */
1216
1239
  async update(patch, auth2) {
1217
1240
  return this.ctx.http.request({
@@ -4142,6 +4165,17 @@ var IamService = class {
4142
4165
  path: `${this.base()}/users/${userId}/groups`,
4143
4166
  auth: auth2
4144
4167
  }),
4168
+ /**
4169
+ * Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).
4170
+ * The collection read above returns the same shape per entry; this exists
4171
+ * because Emporix exposes the item separately and a caller holding both ids
4172
+ * should not have to page the collection to resolve one group.
4173
+ */
4174
+ getGroup: async (userId, groupId, auth2) => this.ctx.http.request({
4175
+ method: "GET",
4176
+ path: `${this.base()}/users/${encodeURIComponent(userId)}/groups/${encodeURIComponent(groupId)}`,
4177
+ auth: auth2
4178
+ }),
4145
4179
  getScopes: async (userId, auth2) => this.ctx.http.request({
4146
4180
  method: "GET",
4147
4181
  path: `${this.base()}/users/${userId}/scopes`,