@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.
- package/CHANGELOG.md +66 -0
- package/dist/availability.d.cts +1 -1
- package/dist/availability.d.ts +1 -1
- package/dist/cart.d.cts +1 -1
- package/dist/cart.d.ts +1 -1
- package/dist/category.d.cts +1 -1
- package/dist/category.d.ts +1 -1
- package/dist/checkout.d.cts +1 -1
- package/dist/checkout.d.ts +1 -1
- package/dist/{chunk-LQFRJSVT.js → chunk-5XZ6MSXW.js} +13 -2
- package/dist/chunk-5XZ6MSXW.js.map +1 -0
- package/dist/{chunk-PRN3T6TY.js → chunk-UA4BM6OP.js} +20 -2
- package/dist/chunk-UA4BM6OP.js.map +1 -0
- package/dist/companies.d.cts +1 -1
- package/dist/companies.d.ts +1 -1
- package/dist/contacts.d.cts +1 -1
- package/dist/contacts.d.ts +1 -1
- package/dist/{context-DK8jg6y5.d.cts → context-D64-B1Rz.d.cts} +13 -0
- package/dist/{context-DK8jg6y5.d.ts → context-D64-B1Rz.d.ts} +13 -0
- package/dist/{customer-groups-BfHDqExS.d.cts → customer-groups-B6xrwf59.d.cts} +1 -1
- package/dist/{customer-groups-Cs6-Cwzg.d.ts → customer-groups-YZg22bFc.d.ts} +1 -1
- package/dist/customer-groups.cjs +11 -0
- package/dist/customer-groups.cjs.map +1 -1
- package/dist/customer-groups.d.cts +2 -2
- package/dist/customer-groups.d.ts +2 -2
- package/dist/customer-groups.js +1 -1
- package/dist/customer.cjs +18 -0
- package/dist/customer.cjs.map +1 -1
- package/dist/customer.d.cts +46 -2
- package/dist/customer.d.ts +46 -2
- package/dist/customer.js +1 -1
- package/dist/index.cjs +35 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +45 -7
- package/dist/index.d.ts +45 -7
- package/dist/index.js +10 -5
- package/dist/index.js.map +1 -1
- package/dist/locations.d.cts +1 -1
- package/dist/locations.d.ts +1 -1
- package/dist/media.d.cts +1 -1
- package/dist/media.d.ts +1 -1
- package/dist/orders.d.cts +1 -1
- package/dist/orders.d.ts +1 -1
- package/dist/payment.d.cts +1 -1
- package/dist/payment.d.ts +1 -1
- package/dist/price.d.cts +1 -1
- package/dist/price.d.ts +1 -1
- package/dist/product.d.cts +1 -1
- package/dist/product.d.ts +1 -1
- package/dist/segment.d.cts +1 -1
- package/dist/segment.d.ts +1 -1
- package/package.json +1 -1
- package/dist/chunk-LQFRJSVT.js.map +0 -1
- package/dist/chunk-PRN3T6TY.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,71 @@
|
|
|
1
1
|
# @viu/emporix-sdk
|
|
2
2
|
|
|
3
|
+
## 2.38.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#294](https://github.com/viuteam/emporix-sdk/pull/294) [`ebf7e61`](https://github.com/viuteam/emporix-sdk/commit/ebf7e610f21c37e000e96fbe651902860bb0fce0) Thanks [@amnael1](https://github.com/amnael1)! - fix(sdk): send `Emporix-Tenant` on every request
|
|
8
|
+
|
|
9
|
+
The tenant is already in the path of nearly every endpoint, so this header looks
|
|
10
|
+
redundant. It is not: Emporix validates dashboard and IAM user tokens against it
|
|
11
|
+
and answers **401** without it, even when `Authorization: Bearer …` is correct.
|
|
12
|
+
|
|
13
|
+
Found while embedding the SDK in a Management Dashboard perspective. Every read
|
|
14
|
+
and write failed with 401 despite a valid host-supplied token, and nothing in
|
|
15
|
+
the request looked wrong — the header is simply absent from the SDK's
|
|
16
|
+
`buildHeaders`, which is not a diagnosable symptom.
|
|
17
|
+
|
|
18
|
+
`@emporix/api-calls`, the client library the Management Dashboard itself uses,
|
|
19
|
+
sets the header whenever a tenant is known — it is an Emporix convention, not a
|
|
20
|
+
dashboard-only quirk. So this is unconditional rather than opt-in: `HttpClient`
|
|
21
|
+
emits it whenever `tenant` is set, and `createCore` always passes it. Every
|
|
22
|
+
client built through `createEmporixClient` gets it.
|
|
23
|
+
|
|
24
|
+
**Behaviour change for every consumer.** Storefront traffic now carries one
|
|
25
|
+
extra header on each request. It is placed _before_ `RequestOptions.headers`, so
|
|
26
|
+
a caller can still override it per request — the same escape hatch
|
|
27
|
+
`Accept-Language` has. Only `Authorization` remains non-negotiable.
|
|
28
|
+
|
|
29
|
+
`HttpClientOptions.tenant` is optional so a bare `new HttpClient(...)` stays
|
|
30
|
+
constructible; the header is then omitted entirely, matching what
|
|
31
|
+
`@emporix/api-calls` does with an empty tenant.
|
|
32
|
+
|
|
33
|
+
Also covers `requestStream` — it shares `buildHeaders`. Token requests
|
|
34
|
+
(`core/auth.ts`) are unaffected, as with `EmporixConfig.fetch`.
|
|
35
|
+
|
|
36
|
+
## 2.37.0
|
|
37
|
+
|
|
38
|
+
### Minor Changes
|
|
39
|
+
|
|
40
|
+
- [#292](https://github.com/viuteam/emporix-sdk/pull/292) [`6efa5b0`](https://github.com/viuteam/emporix-sdk/commit/6efa5b02ab213ab92a7b57edbd09845d1d017a6a) Thanks [@amnael1](https://github.com/amnael1)! - feat(sdk): wrap the two operations an audit found unwrapped
|
|
41
|
+
|
|
42
|
+
An operation-by-operation audit of all 44 vendored specs found the SDK covering
|
|
43
|
+
every non-deprecated operation except two. Both are now wrapped:
|
|
44
|
+
- **`client.customers.validateToken(auth)`** — `GET /customer/{tenant}/validateauthtoken`.
|
|
45
|
+
Reports what a customer token carries: `scope`, `sessionId`, `email`,
|
|
46
|
+
`legalEntityId`, `expires_in`. A check rather than a predicate — an invalid
|
|
47
|
+
token answers `401`, which surfaces as `EmporixAuthError`. Useful when the
|
|
48
|
+
token came from elsewhere (an SSO exchange, a Managed Dashboard host) and you
|
|
49
|
+
need its scopes before deciding what to render.
|
|
50
|
+
- **`client.iam.users.getGroup(userId, groupId, auth)`** —
|
|
51
|
+
`GET /iam/{tenant}/users/{userId}/groups/{groupId}`. The collection read
|
|
52
|
+
(`users.getGroups`) was already there; the item read was not, so a caller
|
|
53
|
+
holding both ids had to page the collection to resolve one group.
|
|
54
|
+
|
|
55
|
+
`SessionContextService`'s doc comment now states which operations it
|
|
56
|
+
deliberately does **not** wrap and why: Emporix exposes the same four
|
|
57
|
+
session-context operations addressed by an explicit session id, which lets a
|
|
58
|
+
caller read and rewrite someone else's session. That is an administrative
|
|
59
|
+
surface and does not belong on the object a storefront holds.
|
|
60
|
+
|
|
61
|
+
No behaviour changes to existing methods.
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- [#291](https://github.com/viuteam/emporix-sdk/pull/291) [`15e5f63`](https://github.com/viuteam/emporix-sdk/commit/15e5f63cd682bc528aad7ca9ae898e0249750a69) Thanks [@viu-release-bot](https://github.com/apps/viu-release-bot)! - chore(sdk): sync generated types with upstream Emporix API specs
|
|
66
|
+
|
|
67
|
+
Updated services: ai-service
|
|
68
|
+
|
|
3
69
|
## 2.36.1
|
|
4
70
|
|
|
5
71
|
### Patch Changes
|
package/dist/availability.d.cts
CHANGED
package/dist/availability.d.ts
CHANGED
package/dist/cart.d.cts
CHANGED
package/dist/cart.d.ts
CHANGED
package/dist/category.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.cjs';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.cjs';
|
|
3
3
|
import { Product } from './product.cjs';
|
|
4
4
|
|
package/dist/category.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext, P as PaginatedItems } from './context-D64-B1Rz.js';
|
|
2
2
|
import { a as QueryFor } from './query-mLQs2WFr.js';
|
|
3
3
|
import { Product } from './product.js';
|
|
4
4
|
|
package/dist/checkout.d.cts
CHANGED
package/dist/checkout.d.ts
CHANGED
|
@@ -51,6 +51,17 @@ var IamService = class {
|
|
|
51
51
|
path: `${this.base()}/users/${userId}/groups`,
|
|
52
52
|
auth
|
|
53
53
|
}),
|
|
54
|
+
/**
|
|
55
|
+
* Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).
|
|
56
|
+
* The collection read above returns the same shape per entry; this exists
|
|
57
|
+
* because Emporix exposes the item separately and a caller holding both ids
|
|
58
|
+
* should not have to page the collection to resolve one group.
|
|
59
|
+
*/
|
|
60
|
+
getGroup: async (userId, groupId, auth) => this.ctx.http.request({
|
|
61
|
+
method: "GET",
|
|
62
|
+
path: `${this.base()}/users/${encodeURIComponent(userId)}/groups/${encodeURIComponent(groupId)}`,
|
|
63
|
+
auth
|
|
64
|
+
}),
|
|
54
65
|
getScopes: async (userId, auth) => this.ctx.http.request({
|
|
55
66
|
method: "GET",
|
|
56
67
|
path: `${this.base()}/users/${userId}/scopes`,
|
|
@@ -220,5 +231,5 @@ var CustomerGroupsService = class {
|
|
|
220
231
|
};
|
|
221
232
|
|
|
222
233
|
export { CustomerGroupsService, IamService };
|
|
223
|
-
//# sourceMappingURL=chunk-
|
|
224
|
-
//# sourceMappingURL=chunk-
|
|
234
|
+
//# sourceMappingURL=chunk-5XZ6MSXW.js.map
|
|
235
|
+
//# sourceMappingURL=chunk-5XZ6MSXW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/iam.ts","../src/services/customer-groups.ts"],"names":[],"mappings":";AA+BO,IAAM,aAAN,MAAiB;AAAA,EAEtB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,KAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,KAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,CAAA;AAAA,EAChC;AAAA,EAES,KAAA,GAAQ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AAA,CAAK,OAAA,CAAc;AAAA,MAChC,MAAA,EAAQ,QAAA;AAAA,MACR,IAAA,EAAM,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,QAAA,EAAW,OAAO,UAAU,MAAM,CAAA,CAAA;AAAA,MAC/D;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"chunk-5XZ6MSXW.js","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n IamUser,\n IamUserDetail,\n IamUserCreate,\n IamUserUpdate,\n IamUserScopes,\n IamUserCreated,\n IamGroup,\n IamGroupCreate,\n IamGroupUpdate,\n IamGroupCreated,\n IamGroupMemberInput,\n IamGroupMemberCreated,\n IamAccessControl,\n IamAccessControlUpsert,\n IamAccessControlCreated,\n IamScope,\n IamScopeUpsert,\n IamScopeCreated,\n} from \"./iam-types\";\n\nexport type * from \"./iam-types\";\n\n/**\n * IAM admin CRUD: users, user-groups, access-controls, scopes. Every method\n * requires an explicit `auth` (admin/service token; `getMe*` take the caller's\n * customer token). The deprecated legacy-RBAC model (roles/permissions/\n * resources/templates) is intentionally not wrapped.\n */\nexport class IamService {\n static readonly channel = \"iam\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}`;\n }\n\n readonly users = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/users`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamUserCreate, auth: AuthContext): Promise<IamUserCreated> =>\n this.ctx.http.request<IamUserCreated>({\n method: \"POST\",\n path: `${this.base()}/users`,\n auth,\n body: input,\n }),\n get: async (userId: string, auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}`,\n auth,\n }),\n getMe: async (auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/me`,\n auth,\n }),\n update: async (userId: string, input: IamUserUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/users/${userId}`,\n auth,\n body: input,\n });\n },\n delete: async (userId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/users/${userId}`,\n auth,\n });\n },\n getGroups: async (userId: string, auth: AuthContext): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/groups`,\n auth,\n }),\n /**\n * Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).\n * The collection read above returns the same shape per entry; this exists\n * because Emporix exposes the item separately and a caller holding both ids\n * should not have to page the collection to resolve one group.\n */\n getGroup: async (userId: string, groupId: string, auth: AuthContext): Promise<IamGroup> =>\n this.ctx.http.request<IamGroup>({\n method: \"GET\",\n path: `${this.base()}/users/${encodeURIComponent(userId)}/groups/${encodeURIComponent(groupId)}`,\n auth,\n }),\n getScopes: async (userId: string, auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/scopes`,\n auth,\n }),\n getMyScopes: async (auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/me/scopes`,\n auth,\n }),\n getAccessControls: async (userId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/access-controls`,\n auth,\n }),\n getMyAccessControls: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/me/access-controls`,\n auth,\n }),\n };\n\n readonly groups = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/groups`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamGroupCreate, auth: AuthContext): Promise<IamGroupCreated> =>\n this.ctx.http.request<IamGroupCreated>({\n method: \"POST\",\n path: `${this.base()}/groups`,\n auth,\n body: input,\n }),\n get: async (groupId: string, auth: AuthContext): Promise<IamGroup> =>\n this.ctx.http.request<IamGroup>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n }),\n update: async (groupId: string, input: IamGroupUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n body: input,\n });\n },\n delete: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n });\n },\n listUsers: async (groupId: string, auth: AuthContext): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n }),\n addUser: async (\n groupId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"POST\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n body: input,\n }),\n updateUser: async (\n groupId: string,\n userType: string,\n userId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}/users/${userType}/${userId}`,\n auth,\n body: input,\n }),\n removeAllUsers: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n });\n },\n listAccessControls: async (groupId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/access-controls`,\n auth,\n }),\n };\n\n readonly accessControls = {\n list: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/access-controls`,\n auth,\n }),\n get: async (id: string, auth: AuthContext): Promise<IamAccessControl> =>\n this.ctx.http.request<IamAccessControl>({\n method: \"GET\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n }),\n upsert: async (\n id: string,\n input: IamAccessControlUpsert,\n auth: AuthContext,\n ): Promise<IamAccessControlCreated> =>\n this.ctx.http.request<IamAccessControlCreated>({\n method: \"PUT\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n body: input,\n }),\n delete: async (id: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n });\n },\n };\n\n readonly scopes = {\n list: async (auth: AuthContext): Promise<IamScope[]> =>\n this.ctx.http.request<IamScope[]>({\n method: \"GET\",\n path: `${this.base()}/scopes`,\n auth,\n }),\n get: async (scopeId: string, auth: AuthContext): Promise<IamScope> =>\n this.ctx.http.request<IamScope>({\n method: \"GET\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n }),\n upsertCustom: async (\n scopeId: string,\n input: IamScopeUpsert,\n auth: AuthContext,\n ): Promise<IamScopeCreated> =>\n this.ctx.http.request<IamScopeCreated>({\n method: \"PUT\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n body: input,\n }),\n deleteCustom: async (scopeId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n });\n },\n };\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type { GroupsQueryDocument, AssignmentCreateRequest } from \"../generated/iam\";\nimport { IamService } from \"./iam\";\n\n/**\n * Access to IAM customer groups for a legal entity. Thin B2B-friendly wrapper\n * over {@link IamService.groups}; kept for backward compatibility.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n static readonly channel = \"iam\" as const;\n private readonly iam: IamService;\n constructor(private readonly ctx: ClientContext) {\n this.iam = new IamService(ctx);\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.iam.groups.list(auth, { \"b2b.legalEntityId\": legalEntityId });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n // `addUser` returns `AssignmentIdResponse` (id optional); the original public\n // contract is `{ id: string }` (the old `request<{id:string}>` asserted the\n // same). Cast to preserve that contract — the wire body is identical.\n return (await this.iam.groups.addUser(groupId, member, auth)) as { id: string };\n }\n\n /**\n * Removes a user from a group. Uses `DELETE …/groups/{groupId}/users/{userId}`\n * directly — this endpoint is deprecated upstream and intentionally not\n * exposed on {@link IamService}, so it is not delegated. No non-deprecated\n * single-user removal exists.\n */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/iam/${this.ctx.tenant}/groups/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -141,6 +141,24 @@ var CustomerService = class {
|
|
|
141
141
|
auth: requireCustomer(auth)
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
+
/**
|
|
145
|
+
* Validates a customer token and returns what the tenant knows about it —
|
|
146
|
+
* `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`
|
|
147
|
+
* (`GET /validateauthtoken`). Requires customer/raw auth.
|
|
148
|
+
*
|
|
149
|
+
* An invalid or expired token answers `401`, which surfaces as
|
|
150
|
+
* {@link EmporixAuthError} rather than a falsy result: this is a check, not a
|
|
151
|
+
* predicate. Reach for it when you hold a token from elsewhere — an SSO
|
|
152
|
+
* exchange, a Managed Dashboard host — and need its scopes before deciding
|
|
153
|
+
* what to render, instead of discovering them from a failed call.
|
|
154
|
+
*/
|
|
155
|
+
async validateToken(auth) {
|
|
156
|
+
return this.ctx.http.request({
|
|
157
|
+
method: "GET",
|
|
158
|
+
path: `/customer/${this.ctx.tenant}/validateauthtoken`,
|
|
159
|
+
auth: requireCustomer(auth)
|
|
160
|
+
});
|
|
161
|
+
}
|
|
144
162
|
/** Updates the authenticated customer. Requires customer/raw auth. */
|
|
145
163
|
async update(patch, auth) {
|
|
146
164
|
return this.ctx.http.request({
|
|
@@ -265,5 +283,5 @@ var CustomerService = class {
|
|
|
265
283
|
};
|
|
266
284
|
|
|
267
285
|
export { CustomerService };
|
|
268
|
-
//# sourceMappingURL=chunk-
|
|
269
|
-
//# sourceMappingURL=chunk-
|
|
286
|
+
//# sourceMappingURL=chunk-UA4BM6OP.js.map
|
|
287
|
+
//# sourceMappingURL=chunk-UA4BM6OP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/customer.ts"],"names":[],"mappings":";;;;AAoFA,SAAS,SAAA,CACP,QAAA,EACA,IAAA,EACA,IAAA,GAAoC,EAAC,EACpB;AACjB,EAAA,MAAM,aAAA,GAAgB,IAAA,CAAK,YAAA,IAAgB,IAAA,CAAK,WAAA;AAChD,EAAA,IAAI,CAAC,aAAA,EAAe;AAClB,IAAA,MAAM,IAAI,gBAAA,CAAiB,CAAA,EAAG,QAAQ,CAAA,+BAAA,CAAA,EAAmC,QAAW,IAAI,CAAA;AAAA,EAC1F;AACA,EAAA,OAAO;AAAA,IACL,aAAA;AAAA,IACA,WAAW,IAAA,CAAK,UAAA,IAAc,IAAA,CAAK,SAAA,IAAa,KAAK,cAAA,IAAkB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AAA,IACH;AAAA,GACF;AACF","file":"chunk-UA4BM6OP.js","sourcesContent":["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"]}
|
package/dist/companies.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
|
|
2
2
|
import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-fWB4nrso.cjs';
|
|
3
3
|
export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-fWB4nrso.cjs';
|
|
4
4
|
|
package/dist/companies.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
|
|
2
2
|
import { L as LegalEntity, e as LegalEntityCreate, f as LegalEntityUpdate } from './types.gen-fWB4nrso.js';
|
|
3
3
|
export { A as AccountLimit, d as CustomerGroup, g as LegalInfo } from './types.gen-fWB4nrso.js';
|
|
4
4
|
|
package/dist/contacts.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.cjs';
|
|
2
2
|
import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-fWB4nrso.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
package/dist/contacts.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as ClientContext, b as AuthContext } from './context-
|
|
1
|
+
import { C as ClientContext, b as AuthContext } from './context-D64-B1Rz.js';
|
|
2
2
|
import { C as ContactAssignment, a as ContactAssignmentCreate, b as ContactAssignmentUpdate } from './types.gen-fWB4nrso.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
@@ -384,6 +384,19 @@ interface HttpResult<T> {
|
|
|
384
384
|
/** Construction options for {@link HttpClient}. */
|
|
385
385
|
interface HttpClientOptions {
|
|
386
386
|
host: string;
|
|
387
|
+
/**
|
|
388
|
+
* Tenant, emitted as `Emporix-Tenant` on every request.
|
|
389
|
+
*
|
|
390
|
+
* The tenant is already in the path of nearly every endpoint, so this looks
|
|
391
|
+
* redundant — it is not. Emporix validates dashboard/IAM user tokens against
|
|
392
|
+
* this header and answers 401 without it, even when `Authorization` is
|
|
393
|
+
* correct. `@emporix/api-calls`, the client library the Management Dashboard
|
|
394
|
+
* itself uses, sets it whenever a tenant is known.
|
|
395
|
+
*
|
|
396
|
+
* Optional so a bare `new HttpClient(...)` stays constructible; every client
|
|
397
|
+
* built through `createCore` passes it.
|
|
398
|
+
*/
|
|
399
|
+
tenant?: string;
|
|
387
400
|
provider: TokenProvider;
|
|
388
401
|
logger: Logger;
|
|
389
402
|
retry: {
|
|
@@ -384,6 +384,19 @@ interface HttpResult<T> {
|
|
|
384
384
|
/** Construction options for {@link HttpClient}. */
|
|
385
385
|
interface HttpClientOptions {
|
|
386
386
|
host: string;
|
|
387
|
+
/**
|
|
388
|
+
* Tenant, emitted as `Emporix-Tenant` on every request.
|
|
389
|
+
*
|
|
390
|
+
* The tenant is already in the path of nearly every endpoint, so this looks
|
|
391
|
+
* redundant — it is not. Emporix validates dashboard/IAM user tokens against
|
|
392
|
+
* this header and answers 401 without it, even when `Authorization` is
|
|
393
|
+
* correct. `@emporix/api-calls`, the client library the Management Dashboard
|
|
394
|
+
* itself uses, sets it whenever a tenant is known.
|
|
395
|
+
*
|
|
396
|
+
* Optional so a bare `new HttpClient(...)` stays constructible; every client
|
|
397
|
+
* built through `createCore` passes it.
|
|
398
|
+
*/
|
|
399
|
+
tenant?: string;
|
|
387
400
|
provider: TokenProvider;
|
|
388
401
|
logger: Logger;
|
|
389
402
|
retry: {
|
package/dist/customer-groups.cjs
CHANGED
|
@@ -53,6 +53,17 @@ var IamService = class {
|
|
|
53
53
|
path: `${this.base()}/users/${userId}/groups`,
|
|
54
54
|
auth
|
|
55
55
|
}),
|
|
56
|
+
/**
|
|
57
|
+
* Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).
|
|
58
|
+
* The collection read above returns the same shape per entry; this exists
|
|
59
|
+
* because Emporix exposes the item separately and a caller holding both ids
|
|
60
|
+
* should not have to page the collection to resolve one group.
|
|
61
|
+
*/
|
|
62
|
+
getGroup: async (userId, groupId, auth) => this.ctx.http.request({
|
|
63
|
+
method: "GET",
|
|
64
|
+
path: `${this.base()}/users/${encodeURIComponent(userId)}/groups/${encodeURIComponent(groupId)}`,
|
|
65
|
+
auth
|
|
66
|
+
}),
|
|
56
67
|
getScopes: async (userId, auth) => this.ctx.http.request({
|
|
57
68
|
method: "GET",
|
|
58
69
|
path: `${this.base()}/users/${userId}/scopes`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/services/iam.ts","../src/services/customer-groups.ts"],"names":[],"mappings":";;;AA+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AA;AAAA,MACR,IAAA,EAAM,QAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,QAAA,EAAW,OAAO,UAAU,MAAM,CAAA,CAAA;AAAA,MAC/D;AAAA,KACD,CAAA;AAAA,EACH;AACF","file":"customer-groups.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n IamUser,\n IamUserDetail,\n IamUserCreate,\n IamUserUpdate,\n IamUserScopes,\n IamUserCreated,\n IamGroup,\n IamGroupCreate,\n IamGroupUpdate,\n IamGroupCreated,\n IamGroupMemberInput,\n IamGroupMemberCreated,\n IamAccessControl,\n IamAccessControlUpsert,\n IamAccessControlCreated,\n IamScope,\n IamScopeUpsert,\n IamScopeCreated,\n} from \"./iam-types\";\n\nexport type * from \"./iam-types\";\n\n/**\n * IAM admin CRUD: users, user-groups, access-controls, scopes. Every method\n * requires an explicit `auth` (admin/service token; `getMe*` take the caller's\n * customer token). The deprecated legacy-RBAC model (roles/permissions/\n * resources/templates) is intentionally not wrapped.\n */\nexport class IamService {\n static readonly channel = \"iam\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}`;\n }\n\n readonly users = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/users`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamUserCreate, auth: AuthContext): Promise<IamUserCreated> =>\n this.ctx.http.request<IamUserCreated>({\n method: \"POST\",\n path: `${this.base()}/users`,\n auth,\n body: input,\n }),\n get: async (userId: string, auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}`,\n auth,\n }),\n getMe: async (auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/me`,\n auth,\n }),\n update: async (userId: string, input: IamUserUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/users/${userId}`,\n auth,\n body: input,\n });\n },\n delete: async (userId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/users/${userId}`,\n auth,\n });\n },\n getGroups: async (userId: string, auth: AuthContext): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/groups`,\n auth,\n }),\n getScopes: async (userId: string, auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/scopes`,\n auth,\n }),\n getMyScopes: async (auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/me/scopes`,\n auth,\n }),\n getAccessControls: async (userId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/access-controls`,\n auth,\n }),\n getMyAccessControls: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/me/access-controls`,\n auth,\n }),\n };\n\n readonly groups = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/groups`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamGroupCreate, auth: AuthContext): Promise<IamGroupCreated> =>\n this.ctx.http.request<IamGroupCreated>({\n method: \"POST\",\n path: `${this.base()}/groups`,\n auth,\n body: input,\n }),\n get: async (groupId: string, auth: AuthContext): Promise<IamGroup> =>\n this.ctx.http.request<IamGroup>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n }),\n update: async (groupId: string, input: IamGroupUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n body: input,\n });\n },\n delete: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n });\n },\n listUsers: async (groupId: string, auth: AuthContext): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n }),\n addUser: async (\n groupId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"POST\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n body: input,\n }),\n updateUser: async (\n groupId: string,\n userType: string,\n userId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}/users/${userType}/${userId}`,\n auth,\n body: input,\n }),\n removeAllUsers: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n });\n },\n listAccessControls: async (groupId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/access-controls`,\n auth,\n }),\n };\n\n readonly accessControls = {\n list: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/access-controls`,\n auth,\n }),\n get: async (id: string, auth: AuthContext): Promise<IamAccessControl> =>\n this.ctx.http.request<IamAccessControl>({\n method: \"GET\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n }),\n upsert: async (\n id: string,\n input: IamAccessControlUpsert,\n auth: AuthContext,\n ): Promise<IamAccessControlCreated> =>\n this.ctx.http.request<IamAccessControlCreated>({\n method: \"PUT\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n body: input,\n }),\n delete: async (id: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n });\n },\n };\n\n readonly scopes = {\n list: async (auth: AuthContext): Promise<IamScope[]> =>\n this.ctx.http.request<IamScope[]>({\n method: \"GET\",\n path: `${this.base()}/scopes`,\n auth,\n }),\n get: async (scopeId: string, auth: AuthContext): Promise<IamScope> =>\n this.ctx.http.request<IamScope>({\n method: \"GET\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n }),\n upsertCustom: async (\n scopeId: string,\n input: IamScopeUpsert,\n auth: AuthContext,\n ): Promise<IamScopeCreated> =>\n this.ctx.http.request<IamScopeCreated>({\n method: \"PUT\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n body: input,\n }),\n deleteCustom: async (scopeId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n });\n },\n };\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type { GroupsQueryDocument, AssignmentCreateRequest } from \"../generated/iam\";\nimport { IamService } from \"./iam\";\n\n/**\n * Access to IAM customer groups for a legal entity. Thin B2B-friendly wrapper\n * over {@link IamService.groups}; kept for backward compatibility.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n static readonly channel = \"iam\" as const;\n private readonly iam: IamService;\n constructor(private readonly ctx: ClientContext) {\n this.iam = new IamService(ctx);\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.iam.groups.list(auth, { \"b2b.legalEntityId\": legalEntityId });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n // `addUser` returns `AssignmentIdResponse` (id optional); the original public\n // contract is `{ id: string }` (the old `request<{id:string}>` asserted the\n // same). Cast to preserve that contract — the wire body is identical.\n return (await this.iam.groups.addUser(groupId, member, auth)) as { id: string };\n }\n\n /**\n * Removes a user from a group. Uses `DELETE …/groups/{groupId}/users/{userId}`\n * directly — this endpoint is deprecated upstream and intentionally not\n * exposed on {@link IamService}, so it is not delegated. No non-deprecated\n * single-user removal exists.\n */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/iam/${this.ctx.tenant}/groups/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/services/iam.ts","../src/services/customer-groups.ts"],"names":[],"mappings":";;;AA+BO,IAAM,aAAN,MAAiB;AAAA,EAEtB,YAA6B,GAAA,EAAoB;AAApB,IAAA,IAAA,CAAA,GAAA,GAAA,GAAA;AAAA,EAAqB;AAAA,EAArB,GAAA;AAAA,EAD7B,OAAgB,OAAA,GAAU,KAAA;AAAA,EAGlB,IAAA,GAAe;AACrB,IAAA,OAAO,CAAA,KAAA,EAAQ,IAAA,CAAK,GAAA,CAAI,MAAM,CAAA,CAAA;AAAA,EAChC;AAAA,EAES,KAAA,GAAQ;AAAA,IACf,MAAM,OAAO,IAAA,EAAmB,UAC9B,IAAA,CAAK,GAAA,CAAI,KAAK,OAAA,CAAmB;AAAA,MAC/B,MAAA,EAAQ,KAAA;AAAA,MACR,IAAA,EAAM,CAAA,EAAG,IAAA,CAAK,IAAA,EAAM,CAAA,MAAA,CAAA;AAAA,MACpB,IAAA;AAA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er-groups.cjs","sourcesContent":["import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type {\n IamUser,\n IamUserDetail,\n IamUserCreate,\n IamUserUpdate,\n IamUserScopes,\n IamUserCreated,\n IamGroup,\n IamGroupCreate,\n IamGroupUpdate,\n IamGroupCreated,\n IamGroupMemberInput,\n IamGroupMemberCreated,\n IamAccessControl,\n IamAccessControlUpsert,\n IamAccessControlCreated,\n IamScope,\n IamScopeUpsert,\n IamScopeCreated,\n} from \"./iam-types\";\n\nexport type * from \"./iam-types\";\n\n/**\n * IAM admin CRUD: users, user-groups, access-controls, scopes. Every method\n * requires an explicit `auth` (admin/service token; `getMe*` take the caller's\n * customer token). The deprecated legacy-RBAC model (roles/permissions/\n * resources/templates) is intentionally not wrapped.\n */\nexport class IamService {\n static readonly channel = \"iam\" as const;\n constructor(private readonly ctx: ClientContext) {}\n\n private base(): string {\n return `/iam/${this.ctx.tenant}`;\n }\n\n readonly users = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/users`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamUserCreate, auth: AuthContext): Promise<IamUserCreated> =>\n this.ctx.http.request<IamUserCreated>({\n method: \"POST\",\n path: `${this.base()}/users`,\n auth,\n body: input,\n }),\n get: async (userId: string, auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}`,\n auth,\n }),\n getMe: async (auth: AuthContext): Promise<IamUserDetail> =>\n this.ctx.http.request<IamUserDetail>({\n method: \"GET\",\n path: `${this.base()}/users/me`,\n auth,\n }),\n update: async (userId: string, input: IamUserUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/users/${userId}`,\n auth,\n body: input,\n });\n },\n delete: async (userId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/users/${userId}`,\n auth,\n });\n },\n getGroups: async (userId: string, auth: AuthContext): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/groups`,\n auth,\n }),\n /**\n * Reads one of a user's groups (`GET /users/{userId}/groups/{groupId}`).\n * The collection read above returns the same shape per entry; this exists\n * because Emporix exposes the item separately and a caller holding both ids\n * should not have to page the collection to resolve one group.\n */\n getGroup: async (userId: string, groupId: string, auth: AuthContext): Promise<IamGroup> =>\n this.ctx.http.request<IamGroup>({\n method: \"GET\",\n path: `${this.base()}/users/${encodeURIComponent(userId)}/groups/${encodeURIComponent(groupId)}`,\n auth,\n }),\n getScopes: async (userId: string, auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/scopes`,\n auth,\n }),\n getMyScopes: async (auth: AuthContext): Promise<IamUserScopes> =>\n this.ctx.http.request<IamUserScopes>({\n method: \"GET\",\n path: `${this.base()}/users/me/scopes`,\n auth,\n }),\n getAccessControls: async (userId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/${userId}/access-controls`,\n auth,\n }),\n getMyAccessControls: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/users/me/access-controls`,\n auth,\n }),\n };\n\n readonly groups = {\n list: async (auth: AuthContext, query?: Record<string, string | number>): Promise<IamGroup[]> =>\n this.ctx.http.request<IamGroup[]>({\n method: \"GET\",\n path: `${this.base()}/groups`,\n auth,\n ...(query ? { query } : {}),\n }),\n create: async (input: IamGroupCreate, auth: AuthContext): Promise<IamGroupCreated> =>\n this.ctx.http.request<IamGroupCreated>({\n method: \"POST\",\n path: `${this.base()}/groups`,\n auth,\n body: input,\n }),\n get: async (groupId: string, auth: AuthContext): Promise<IamGroup> =>\n this.ctx.http.request<IamGroup>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n }),\n update: async (groupId: string, input: IamGroupUpdate, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n body: input,\n });\n },\n delete: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}`,\n auth,\n });\n },\n listUsers: async (groupId: string, auth: AuthContext): Promise<IamUser[]> =>\n this.ctx.http.request<IamUser[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n }),\n addUser: async (\n groupId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"POST\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n body: input,\n }),\n updateUser: async (\n groupId: string,\n userType: string,\n userId: string,\n input: IamGroupMemberInput,\n auth: AuthContext,\n ): Promise<IamGroupMemberCreated> =>\n this.ctx.http.request<IamGroupMemberCreated>({\n method: \"PUT\",\n path: `${this.base()}/groups/${groupId}/users/${userType}/${userId}`,\n auth,\n body: input,\n }),\n removeAllUsers: async (groupId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/groups/${groupId}/users`,\n auth,\n });\n },\n listAccessControls: async (groupId: string, auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/groups/${groupId}/access-controls`,\n auth,\n }),\n };\n\n readonly accessControls = {\n list: async (auth: AuthContext): Promise<IamAccessControl[]> =>\n this.ctx.http.request<IamAccessControl[]>({\n method: \"GET\",\n path: `${this.base()}/access-controls`,\n auth,\n }),\n get: async (id: string, auth: AuthContext): Promise<IamAccessControl> =>\n this.ctx.http.request<IamAccessControl>({\n method: \"GET\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n }),\n upsert: async (\n id: string,\n input: IamAccessControlUpsert,\n auth: AuthContext,\n ): Promise<IamAccessControlCreated> =>\n this.ctx.http.request<IamAccessControlCreated>({\n method: \"PUT\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n body: input,\n }),\n delete: async (id: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/access-controls/${id}`,\n auth,\n });\n },\n };\n\n readonly scopes = {\n list: async (auth: AuthContext): Promise<IamScope[]> =>\n this.ctx.http.request<IamScope[]>({\n method: \"GET\",\n path: `${this.base()}/scopes`,\n auth,\n }),\n get: async (scopeId: string, auth: AuthContext): Promise<IamScope> =>\n this.ctx.http.request<IamScope>({\n method: \"GET\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n }),\n upsertCustom: async (\n scopeId: string,\n input: IamScopeUpsert,\n auth: AuthContext,\n ): Promise<IamScopeCreated> =>\n this.ctx.http.request<IamScopeCreated>({\n method: \"PUT\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n body: input,\n }),\n deleteCustom: async (scopeId: string, auth: AuthContext): Promise<void> => {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `${this.base()}/scopes/${scopeId}`,\n auth,\n });\n },\n };\n}\n","import type { ClientContext } from \"../core/context\";\nimport type { AuthContext } from \"../core/auth\";\nimport type { GroupsQueryDocument, AssignmentCreateRequest } from \"../generated/iam\";\nimport { IamService } from \"./iam\";\n\n/**\n * Access to IAM customer groups for a legal entity. Thin B2B-friendly wrapper\n * over {@link IamService.groups}; kept for backward compatibility.\n *\n * `listForCompany` requires `iam.group_read`; the member mutations\n * (`addMember`/`removeMember`) require `iam.group_manage` — typically only\n * granted to Admin-group customers; a 403 surfaces as\n * `EmporixInsufficientScopeError`.\n */\nexport class CustomerGroupsService {\n static readonly channel = \"iam\" as const;\n private readonly iam: IamService;\n constructor(private readonly ctx: ClientContext) {\n this.iam = new IamService(ctx);\n }\n\n /** Lists customer groups belonging to one legal entity. */\n async listForCompany(legalEntityId: string, auth: AuthContext): Promise<GroupsQueryDocument[]> {\n return this.iam.groups.list(auth, { \"b2b.legalEntityId\": legalEntityId });\n }\n\n /** Adds a user (customer or employee) to a group. */\n async addMember(\n groupId: string,\n member: AssignmentCreateRequest,\n auth: AuthContext,\n ): Promise<{ id: string }> {\n // `addUser` returns `AssignmentIdResponse` (id optional); the original public\n // contract is `{ id: string }` (the old `request<{id:string}>` asserted the\n // same). Cast to preserve that contract — the wire body is identical.\n return (await this.iam.groups.addUser(groupId, member, auth)) as { id: string };\n }\n\n /**\n * Removes a user from a group. Uses `DELETE …/groups/{groupId}/users/{userId}`\n * directly — this endpoint is deprecated upstream and intentionally not\n * exposed on {@link IamService}, so it is not delegated. No non-deprecated\n * single-user removal exists.\n */\n async removeMember(groupId: string, userId: string, auth: AuthContext): Promise<void> {\n await this.ctx.http.request<void>({\n method: \"DELETE\",\n path: `/iam/${this.ctx.tenant}/groups/${groupId}/users/${userId}`,\n auth,\n });\n }\n}\n"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-
|
|
2
|
-
import './context-
|
|
1
|
+
export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-B6xrwf59.cjs';
|
|
2
|
+
import './context-D64-B1Rz.cjs';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-
|
|
2
|
-
import './context-
|
|
1
|
+
export { g as CustomerGroupsService, j as IamGroup, c as IamGroupMemberAssignment } from './customer-groups-YZg22bFc.js';
|
|
2
|
+
import './context-D64-B1Rz.js';
|
package/dist/customer-groups.js
CHANGED
package/dist/customer.cjs
CHANGED
|
@@ -187,6 +187,24 @@ var CustomerService = class {
|
|
|
187
187
|
auth: requireCustomer(auth)
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Validates a customer token and returns what the tenant knows about it —
|
|
192
|
+
* `scope`, `sessionId`, `email`, `legalEntityId`, `expires_in`
|
|
193
|
+
* (`GET /validateauthtoken`). Requires customer/raw auth.
|
|
194
|
+
*
|
|
195
|
+
* An invalid or expired token answers `401`, which surfaces as
|
|
196
|
+
* {@link EmporixAuthError} rather than a falsy result: this is a check, not a
|
|
197
|
+
* predicate. Reach for it when you hold a token from elsewhere — an SSO
|
|
198
|
+
* exchange, a Managed Dashboard host — and need its scopes before deciding
|
|
199
|
+
* what to render, instead of discovering them from a failed call.
|
|
200
|
+
*/
|
|
201
|
+
async validateToken(auth) {
|
|
202
|
+
return this.ctx.http.request({
|
|
203
|
+
method: "GET",
|
|
204
|
+
path: `/customer/${this.ctx.tenant}/validateauthtoken`,
|
|
205
|
+
auth: requireCustomer(auth)
|
|
206
|
+
});
|
|
207
|
+
}
|
|
190
208
|
/** Updates the authenticated customer. Requires customer/raw auth. */
|
|
191
209
|
async update(patch, auth) {
|
|
192
210
|
return this.ctx.http.request({
|