@unchainedshop/api 4.8.3 → 4.8.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/acl.d.ts CHANGED
@@ -2,11 +2,11 @@ import type { CheckPermissionArgs } from '@unchainedshop/roles';
2
2
  export declare const ensureActionExists: (action: any, userOptions: any) => void;
3
3
  export declare const ensureIsFunction: (fn: any, action: any, options: any, key: any) => void;
4
4
  declare const checkAction: (context: any, action: any, args?: CheckPermissionArgs, options?: any) => Promise<void>;
5
- declare const checkResolver: (action: any, userOptions?: any) => (fn: any, name?: string) => (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
5
+ declare const checkResolver: (action: any, userOptions?: any) => (fn: any, name?: string) => (root: any, params: any, context: any, info: any) => Promise<any>;
6
6
  declare const checkTypeResolver: (action: any, key: any) => (obj: any, params: any, context: any) => Promise<any>;
7
7
  declare const resolverDecorator: (action: any, userOptions?: any) => (target: any, key: any, descriptor: any) => {
8
8
  configurable: boolean;
9
- get(): (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
9
+ get(): (root: any, params: any, context: any, info: any) => Promise<any>;
10
10
  };
11
11
  export default resolverDecorator;
12
12
  export { resolverDecorator, checkResolver, checkTypeResolver, checkAction };
package/lib/acl.js CHANGED
@@ -36,12 +36,11 @@ const wrapFunction = (fn, name, action, userOptions) => {
36
36
  const key = name || fn.name;
37
37
  const options = { ...defaultOptions, ...userOptions };
38
38
  ensureIsFunction(fn, action, options, key);
39
- return async (root, params, context, ...other) => {
40
- const args = options.mapArgs(root, params, ...other);
41
- await checkAction(context, action, args, {
42
- key: options.showKey ? key : '',
43
- });
44
- return fn(root, params, context, ...other);
39
+ const actionOptions = { key: options.showKey ? key : '' };
40
+ return async (root, params, context, info) => {
41
+ const args = options.mapArgs(root, params, info);
42
+ await checkAction(context, action, args, actionOptions);
43
+ return fn(root, params, context, info);
45
44
  };
46
45
  };
47
46
  const checkResolver = (action, userOptions) => {
package/lib/context.d.ts CHANGED
@@ -3,6 +3,7 @@ import { type UnchainedLoaders } from './loaders/index.ts';
3
3
  import { type UnchainedLocaleContext } from './locale-context.ts';
4
4
  import type { UnchainedServerOptions } from './api-index.ts';
5
5
  import type { User } from '@unchainedshop/core-users';
6
+ export declare const IN_LOGIN_RESPONSE: unique symbol;
6
7
  export type LoginFn = (user: User, options?: {
7
8
  impersonator?: User;
8
9
  }) => Promise<{
package/lib/context.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import instantiateLoaders, {} from "./loaders/index.js";
2
2
  import { getLocaleContext } from "./locale-context.js";
3
3
  const { npm_package_version, UNCHAINED_API_VERSION } = process.env;
4
+ export const IN_LOGIN_RESPONSE = Symbol('inLoginMethodResponse');
4
5
  let context;
5
6
  export const getCurrentContextResolver = () => context;
6
7
  export const setCurrentContextResolver = (newContext) => {
@@ -5,7 +5,7 @@ import MongoStore from "../mongo-store.js";
5
5
  import { Passport } from 'passport';
6
6
  import { mongodb } from '@unchainedshop/mongodb';
7
7
  import { emit } from '@unchainedshop/events';
8
- import { getCurrentContextResolver } from "../context.js";
8
+ import { getCurrentContextResolver, IN_LOGIN_RESPONSE, } from "../context.js";
9
9
  import createBulkImportMiddleware from "./createBulkImportMiddleware.js";
10
10
  import createERCMetadataMiddleware from "./createERCMetadataMiddleware.js";
11
11
  import createTempUploadMiddleware from "./createTempUploadMiddleware.js";
@@ -57,7 +57,7 @@ const addContext = async function middlewareWithContext(req, res, next) {
57
57
  tokenExpires: new Date(req.session?.cookie._expires),
58
58
  };
59
59
  await emit(API_EVENTS.API_LOGIN_TOKEN_CREATED, tokenObject);
60
- user._inLoginMethodResponse = true;
60
+ user[IN_LOGIN_RESPONSE] = true;
61
61
  return { user, ...tokenObject };
62
62
  };
63
63
  const logout = async (sessionId) => {
@@ -1,4 +1,4 @@
1
- import { getCurrentContextResolver } from "../context.js";
1
+ import { getCurrentContextResolver, IN_LOGIN_RESPONSE, } from "../context.js";
2
2
  import bulkImportHandler from "./bulkImportHandler.js";
3
3
  import ercMetadataHandler from "./ercMetadataHandler.js";
4
4
  import MongoStore from "../mongo-store.js";
@@ -36,7 +36,7 @@ const middlewareHook = async function middlewareHook(req, reply) {
36
36
  tokenExpires: new Date(req.session.cookie._expires),
37
37
  };
38
38
  await emit(API_EVENTS.API_LOGIN_TOKEN_CREATED, tokenObject);
39
- user._inLoginMethodResponse = true;
39
+ user[IN_LOGIN_RESPONSE] = true;
40
40
  return { user, ...tokenObject };
41
41
  };
42
42
  const logout = async function logout() {
@@ -1,20 +1,19 @@
1
1
  export default function buildTextMap(localeMap, texts, buildId) {
2
2
  const textsMap = {};
3
- for (let j = 0; j < texts.length; j++) {
4
- const text = texts[j];
5
- if (!text.locale)
6
- continue;
7
- const localesForText = localeMap[text.locale];
8
- if (!localesForText)
9
- continue;
10
- const idPart = buildId(text);
11
- for (let k = 0; k < localesForText.length; k++) {
12
- const locale = localesForText[k];
13
- const key = locale + idPart;
14
- if (textsMap[key] && locale !== text.locale) {
3
+ const localeMapKeys = Object.keys(localeMap);
4
+ for (const originLocale of localeMapKeys) {
5
+ const localesForText = localeMap[originLocale];
6
+ for (const text of texts) {
7
+ if (originLocale !== text.locale)
15
8
  continue;
9
+ const idPart = buildId(text);
10
+ for (const locale of localesForText) {
11
+ const key = locale + idPart;
12
+ if (textsMap[key] && locale !== text.locale) {
13
+ continue;
14
+ }
15
+ textsMap[key] = text;
16
16
  }
17
- textsMap[key] = text;
18
17
  }
19
18
  }
20
19
  return textsMap;
@@ -171,6 +171,11 @@ declare const loaders: (unchainedAPI: UnchainedCore) => {
171
171
  }, import("@unchainedshop/core-quotations").Quotation | null, {
172
172
  quotationId: string;
173
173
  }>;
174
+ tokenExportStatusLoader: import("dataloader")<{
175
+ token: import("@unchainedshop/core-warehousing").TokenSurrogate;
176
+ }, import("@unchainedshop/core-warehousing").TokenStatus, {
177
+ token: import("@unchainedshop/core-warehousing").TokenSurrogate;
178
+ }>;
174
179
  };
175
180
  export type UnchainedLoaders = Awaited<ReturnType<typeof loaders>>;
176
181
  export default loaders;
@@ -27,6 +27,7 @@ import paymentProviderLoader from "./paymentProviderLoader.js";
27
27
  import warehousingProviderLoader from "./warehousingProviderLoader.js";
28
28
  import orderLoader from "./orderLoader.js";
29
29
  import quotationLoader from "./quotationLoader.js";
30
+ import tokenExportStatusLoader from "./tokenExportStatusLoader.js";
30
31
  const loaders = (unchainedAPI) => {
31
32
  return {
32
33
  assortmentLoader: assortmentLoader(unchainedAPI),
@@ -58,6 +59,7 @@ const loaders = (unchainedAPI) => {
58
59
  warehousingProviderLoader: warehousingProviderLoader(unchainedAPI),
59
60
  orderLoader: orderLoader(unchainedAPI),
60
61
  quotationLoader: quotationLoader(unchainedAPI),
62
+ tokenExportStatusLoader: tokenExportStatusLoader(unchainedAPI),
61
63
  };
62
64
  };
63
65
  export default loaders;
@@ -0,0 +1,9 @@
1
+ import type { UnchainedCore } from '@unchainedshop/core';
2
+ import type { TokenSurrogate, TokenStatus as TokenStatusType } from '@unchainedshop/core-warehousing';
3
+ import DataLoader from 'dataloader';
4
+ declare const _default: (unchainedAPI: UnchainedCore) => DataLoader<{
5
+ token: TokenSurrogate;
6
+ }, TokenStatusType, {
7
+ token: TokenSurrogate;
8
+ }>;
9
+ export default _default;
@@ -0,0 +1,31 @@
1
+ import { TokenStatus } from '@unchainedshop/core-warehousing';
2
+ import { WorkStatus } from '@unchainedshop/core-worker';
3
+ import DataLoader from 'dataloader';
4
+ export default (unchainedAPI) => new DataLoader(async (queries) => {
5
+ const tokensNeedingWorkCheck = [];
6
+ for (const { token } of queries) {
7
+ if (!(token.walletAddress && !token.userId)) {
8
+ tokensNeedingWorkCheck.push(token);
9
+ }
10
+ }
11
+ let exportingTokenIds;
12
+ if (tokensNeedingWorkCheck.length > 0) {
13
+ const workItems = await unchainedAPI.modules.worker.findWorkQueue({
14
+ types: ['EXPORT_TOKEN'],
15
+ status: [WorkStatus.NEW, WorkStatus.ALLOCATED],
16
+ });
17
+ exportingTokenIds = new Set(workItems.map((item) => item.input?.token?._id).filter(Boolean));
18
+ }
19
+ else {
20
+ exportingTokenIds = new Set();
21
+ }
22
+ return queries.map(({ token }) => {
23
+ if (token.walletAddress && !token.userId) {
24
+ return TokenStatus.DECENTRALIZED;
25
+ }
26
+ if (exportingTokenIds.has(token._id)) {
27
+ return TokenStatus.EXPORTING;
28
+ }
29
+ return TokenStatus.CENTRALIZED;
30
+ });
31
+ });
@@ -1,158 +1,158 @@
1
1
  declare const _default: {
2
- logout: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
3
- loginAsGuest: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
4
- impersonate: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
5
- stopImpersonation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
6
- createWebAuthnCredentialCreationOptions: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
7
- createWebAuthnCredentialRequestOptions: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
8
- addPushSubscription: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
9
- removePushSubscription: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
10
- addWebAuthnCredentials: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
11
- removeWebAuthnCredentials: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
12
- addWeb3Address: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
13
- removeWeb3Address: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
14
- verifyWeb3Address: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
15
- verifyEmail: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
16
- loginWithPassword: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
17
- loginWithWebAuthn: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
18
- pageView: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
19
- createUser: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
20
- forgotPassword: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
21
- resetPassword: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
22
- sendVerificationEmail: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
23
- sendEnrollmentEmail: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
24
- changePassword: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
25
- heartbeat: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
26
- addEmail: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
27
- removeEmail: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
28
- updateUserProfile: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
29
- removeUser: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
30
- setPassword: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
31
- prepareUserAvatarUpload: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
32
- setUserTags: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
33
- setUsername: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
34
- setRoles: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
35
- enrollUser: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
36
- registerPaymentCredentials: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
37
- markPaymentCredentialsPreferred: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
38
- removePaymentCredentials: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
39
- createLanguage: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
40
- updateLanguage: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
41
- removeLanguage: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
42
- createCountry: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
43
- updateCountry: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
44
- removeCountry: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
45
- createProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
46
- publishProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
47
- unpublishProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
48
- removeProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
49
- updateProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
50
- updateProductTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
51
- updateProductMediaTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
52
- confirmMediaUpload: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
53
- prepareProductMediaUpload: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
54
- reorderProductMedia: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
55
- removeProductMedia: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
56
- updateProductCommerce: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
57
- updateProductWarehousing: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
58
- updateProductSupply: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
59
- updateProductPlan: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
60
- updateProductTokenization: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
61
- removeProductVariation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
62
- updateProductVariationTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
63
- removeProductVariationOption: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
64
- createProductVariation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
65
- createProductBundleItem: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
66
- removeBundleItem: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
67
- createProductVariationOption: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
68
- addProductAssignment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
69
- removeProductAssignment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
70
- createCurrency: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
71
- updateCurrency: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
72
- removeCurrency: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
73
- createCart: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
74
- addCartProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
75
- addMultipleCartProducts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
76
- addCartDiscount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
77
- addCartQuotation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
78
- updateCart: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
79
- emptyCart: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
80
- checkoutCart: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
81
- updateCartItem: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
82
- removeCartItem: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
83
- removeCartDiscount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
84
- updateCartDeliveryPickUp: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
85
- updateCartDeliveryShipping: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
86
- updateCartPaymentGeneric: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
87
- updateCartPaymentInvoice: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
88
- setOrderPaymentProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
89
- setOrderDeliveryProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
90
- updateOrderDeliveryShipping: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
91
- updateOrderDeliveryPickUp: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
92
- updateOrderPaymentGeneric: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
93
- updateOrderPaymentInvoice: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
94
- removeOrder: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
95
- confirmOrder: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
96
- rejectOrder: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
97
- payOrder: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
98
- deliverOrder: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
99
- createEnrollment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
100
- terminateEnrollment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
101
- activateEnrollment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
102
- updateEnrollment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
103
- createPaymentProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
104
- updatePaymentProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
105
- removePaymentProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
106
- createDeliveryProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
107
- updateDeliveryProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
108
- removeDeliveryProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
109
- createWarehousingProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
110
- updateWarehousingProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
111
- removeWarehousingProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
112
- exportToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
113
- invalidateToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
114
- createFilter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
115
- updateFilter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
116
- removeFilter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
117
- updateFilterTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
118
- removeFilterOption: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
119
- createFilterOption: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
120
- createAssortment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
121
- prepareAssortmentMediaUpload: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
122
- updateAssortment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
123
- removeAssortment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
124
- reorderAssortmentMedia: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
125
- removeAssortmentMedia: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
126
- updateAssortmentMediaTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
127
- updateAssortmentTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
128
- addAssortmentProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
129
- removeAssortmentProduct: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
130
- reorderAssortmentProducts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
131
- addAssortmentLink: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
132
- removeAssortmentLink: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
133
- reorderAssortmentLinks: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
134
- addAssortmentFilter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
135
- removeAssortmentFilter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
136
- reorderAssortmentFilters: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
137
- createProductReview: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
138
- updateProductReview: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
139
- removeProductReview: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
140
- addProductReviewVote: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
141
- removeProductReviewVote: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
142
- requestQuotation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
143
- rejectQuotation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
144
- verifyQuotation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
145
- makeQuotationProposal: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
146
- bookmark: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
147
- createBookmark: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
148
- removeBookmark: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
149
- addWork: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
150
- allocateWork: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
151
- finishWork: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
152
- removeWork: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
153
- processNextWork: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
154
- signPaymentProviderForCredentialRegistration: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
155
- signPaymentProviderForCheckout: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
156
- removeUserProductReviews: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
2
+ logout: (root: any, params: any, context: any, info: any) => Promise<any>;
3
+ loginAsGuest: (root: any, params: any, context: any, info: any) => Promise<any>;
4
+ impersonate: (root: any, params: any, context: any, info: any) => Promise<any>;
5
+ stopImpersonation: (root: any, params: any, context: any, info: any) => Promise<any>;
6
+ createWebAuthnCredentialCreationOptions: (root: any, params: any, context: any, info: any) => Promise<any>;
7
+ createWebAuthnCredentialRequestOptions: (root: any, params: any, context: any, info: any) => Promise<any>;
8
+ addPushSubscription: (root: any, params: any, context: any, info: any) => Promise<any>;
9
+ removePushSubscription: (root: any, params: any, context: any, info: any) => Promise<any>;
10
+ addWebAuthnCredentials: (root: any, params: any, context: any, info: any) => Promise<any>;
11
+ removeWebAuthnCredentials: (root: any, params: any, context: any, info: any) => Promise<any>;
12
+ addWeb3Address: (root: any, params: any, context: any, info: any) => Promise<any>;
13
+ removeWeb3Address: (root: any, params: any, context: any, info: any) => Promise<any>;
14
+ verifyWeb3Address: (root: any, params: any, context: any, info: any) => Promise<any>;
15
+ verifyEmail: (root: any, params: any, context: any, info: any) => Promise<any>;
16
+ loginWithPassword: (root: any, params: any, context: any, info: any) => Promise<any>;
17
+ loginWithWebAuthn: (root: any, params: any, context: any, info: any) => Promise<any>;
18
+ pageView: (root: any, params: any, context: any, info: any) => Promise<any>;
19
+ createUser: (root: any, params: any, context: any, info: any) => Promise<any>;
20
+ forgotPassword: (root: any, params: any, context: any, info: any) => Promise<any>;
21
+ resetPassword: (root: any, params: any, context: any, info: any) => Promise<any>;
22
+ sendVerificationEmail: (root: any, params: any, context: any, info: any) => Promise<any>;
23
+ sendEnrollmentEmail: (root: any, params: any, context: any, info: any) => Promise<any>;
24
+ changePassword: (root: any, params: any, context: any, info: any) => Promise<any>;
25
+ heartbeat: (root: any, params: any, context: any, info: any) => Promise<any>;
26
+ addEmail: (root: any, params: any, context: any, info: any) => Promise<any>;
27
+ removeEmail: (root: any, params: any, context: any, info: any) => Promise<any>;
28
+ updateUserProfile: (root: any, params: any, context: any, info: any) => Promise<any>;
29
+ removeUser: (root: any, params: any, context: any, info: any) => Promise<any>;
30
+ setPassword: (root: any, params: any, context: any, info: any) => Promise<any>;
31
+ prepareUserAvatarUpload: (root: any, params: any, context: any, info: any) => Promise<any>;
32
+ setUserTags: (root: any, params: any, context: any, info: any) => Promise<any>;
33
+ setUsername: (root: any, params: any, context: any, info: any) => Promise<any>;
34
+ setRoles: (root: any, params: any, context: any, info: any) => Promise<any>;
35
+ enrollUser: (root: any, params: any, context: any, info: any) => Promise<any>;
36
+ registerPaymentCredentials: (root: any, params: any, context: any, info: any) => Promise<any>;
37
+ markPaymentCredentialsPreferred: (root: any, params: any, context: any, info: any) => Promise<any>;
38
+ removePaymentCredentials: (root: any, params: any, context: any, info: any) => Promise<any>;
39
+ createLanguage: (root: any, params: any, context: any, info: any) => Promise<any>;
40
+ updateLanguage: (root: any, params: any, context: any, info: any) => Promise<any>;
41
+ removeLanguage: (root: any, params: any, context: any, info: any) => Promise<any>;
42
+ createCountry: (root: any, params: any, context: any, info: any) => Promise<any>;
43
+ updateCountry: (root: any, params: any, context: any, info: any) => Promise<any>;
44
+ removeCountry: (root: any, params: any, context: any, info: any) => Promise<any>;
45
+ createProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
46
+ publishProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
47
+ unpublishProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
48
+ removeProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
49
+ updateProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
50
+ updateProductTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
51
+ updateProductMediaTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
52
+ confirmMediaUpload: (root: any, params: any, context: any, info: any) => Promise<any>;
53
+ prepareProductMediaUpload: (root: any, params: any, context: any, info: any) => Promise<any>;
54
+ reorderProductMedia: (root: any, params: any, context: any, info: any) => Promise<any>;
55
+ removeProductMedia: (root: any, params: any, context: any, info: any) => Promise<any>;
56
+ updateProductCommerce: (root: any, params: any, context: any, info: any) => Promise<any>;
57
+ updateProductWarehousing: (root: any, params: any, context: any, info: any) => Promise<any>;
58
+ updateProductSupply: (root: any, params: any, context: any, info: any) => Promise<any>;
59
+ updateProductPlan: (root: any, params: any, context: any, info: any) => Promise<any>;
60
+ updateProductTokenization: (root: any, params: any, context: any, info: any) => Promise<any>;
61
+ removeProductVariation: (root: any, params: any, context: any, info: any) => Promise<any>;
62
+ updateProductVariationTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
63
+ removeProductVariationOption: (root: any, params: any, context: any, info: any) => Promise<any>;
64
+ createProductVariation: (root: any, params: any, context: any, info: any) => Promise<any>;
65
+ createProductBundleItem: (root: any, params: any, context: any, info: any) => Promise<any>;
66
+ removeBundleItem: (root: any, params: any, context: any, info: any) => Promise<any>;
67
+ createProductVariationOption: (root: any, params: any, context: any, info: any) => Promise<any>;
68
+ addProductAssignment: (root: any, params: any, context: any, info: any) => Promise<any>;
69
+ removeProductAssignment: (root: any, params: any, context: any, info: any) => Promise<any>;
70
+ createCurrency: (root: any, params: any, context: any, info: any) => Promise<any>;
71
+ updateCurrency: (root: any, params: any, context: any, info: any) => Promise<any>;
72
+ removeCurrency: (root: any, params: any, context: any, info: any) => Promise<any>;
73
+ createCart: (root: any, params: any, context: any, info: any) => Promise<any>;
74
+ addCartProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
75
+ addMultipleCartProducts: (root: any, params: any, context: any, info: any) => Promise<any>;
76
+ addCartDiscount: (root: any, params: any, context: any, info: any) => Promise<any>;
77
+ addCartQuotation: (root: any, params: any, context: any, info: any) => Promise<any>;
78
+ updateCart: (root: any, params: any, context: any, info: any) => Promise<any>;
79
+ emptyCart: (root: any, params: any, context: any, info: any) => Promise<any>;
80
+ checkoutCart: (root: any, params: any, context: any, info: any) => Promise<any>;
81
+ updateCartItem: (root: any, params: any, context: any, info: any) => Promise<any>;
82
+ removeCartItem: (root: any, params: any, context: any, info: any) => Promise<any>;
83
+ removeCartDiscount: (root: any, params: any, context: any, info: any) => Promise<any>;
84
+ updateCartDeliveryPickUp: (root: any, params: any, context: any, info: any) => Promise<any>;
85
+ updateCartDeliveryShipping: (root: any, params: any, context: any, info: any) => Promise<any>;
86
+ updateCartPaymentGeneric: (root: any, params: any, context: any, info: any) => Promise<any>;
87
+ updateCartPaymentInvoice: (root: any, params: any, context: any, info: any) => Promise<any>;
88
+ setOrderPaymentProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
89
+ setOrderDeliveryProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
90
+ updateOrderDeliveryShipping: (root: any, params: any, context: any, info: any) => Promise<any>;
91
+ updateOrderDeliveryPickUp: (root: any, params: any, context: any, info: any) => Promise<any>;
92
+ updateOrderPaymentGeneric: (root: any, params: any, context: any, info: any) => Promise<any>;
93
+ updateOrderPaymentInvoice: (root: any, params: any, context: any, info: any) => Promise<any>;
94
+ removeOrder: (root: any, params: any, context: any, info: any) => Promise<any>;
95
+ confirmOrder: (root: any, params: any, context: any, info: any) => Promise<any>;
96
+ rejectOrder: (root: any, params: any, context: any, info: any) => Promise<any>;
97
+ payOrder: (root: any, params: any, context: any, info: any) => Promise<any>;
98
+ deliverOrder: (root: any, params: any, context: any, info: any) => Promise<any>;
99
+ createEnrollment: (root: any, params: any, context: any, info: any) => Promise<any>;
100
+ terminateEnrollment: (root: any, params: any, context: any, info: any) => Promise<any>;
101
+ activateEnrollment: (root: any, params: any, context: any, info: any) => Promise<any>;
102
+ updateEnrollment: (root: any, params: any, context: any, info: any) => Promise<any>;
103
+ createPaymentProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
104
+ updatePaymentProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
105
+ removePaymentProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
106
+ createDeliveryProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
107
+ updateDeliveryProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
108
+ removeDeliveryProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
109
+ createWarehousingProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
110
+ updateWarehousingProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
111
+ removeWarehousingProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
112
+ exportToken: (root: any, params: any, context: any, info: any) => Promise<any>;
113
+ invalidateToken: (root: any, params: any, context: any, info: any) => Promise<any>;
114
+ createFilter: (root: any, params: any, context: any, info: any) => Promise<any>;
115
+ updateFilter: (root: any, params: any, context: any, info: any) => Promise<any>;
116
+ removeFilter: (root: any, params: any, context: any, info: any) => Promise<any>;
117
+ updateFilterTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
118
+ removeFilterOption: (root: any, params: any, context: any, info: any) => Promise<any>;
119
+ createFilterOption: (root: any, params: any, context: any, info: any) => Promise<any>;
120
+ createAssortment: (root: any, params: any, context: any, info: any) => Promise<any>;
121
+ prepareAssortmentMediaUpload: (root: any, params: any, context: any, info: any) => Promise<any>;
122
+ updateAssortment: (root: any, params: any, context: any, info: any) => Promise<any>;
123
+ removeAssortment: (root: any, params: any, context: any, info: any) => Promise<any>;
124
+ reorderAssortmentMedia: (root: any, params: any, context: any, info: any) => Promise<any>;
125
+ removeAssortmentMedia: (root: any, params: any, context: any, info: any) => Promise<any>;
126
+ updateAssortmentMediaTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
127
+ updateAssortmentTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
128
+ addAssortmentProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
129
+ removeAssortmentProduct: (root: any, params: any, context: any, info: any) => Promise<any>;
130
+ reorderAssortmentProducts: (root: any, params: any, context: any, info: any) => Promise<any>;
131
+ addAssortmentLink: (root: any, params: any, context: any, info: any) => Promise<any>;
132
+ removeAssortmentLink: (root: any, params: any, context: any, info: any) => Promise<any>;
133
+ reorderAssortmentLinks: (root: any, params: any, context: any, info: any) => Promise<any>;
134
+ addAssortmentFilter: (root: any, params: any, context: any, info: any) => Promise<any>;
135
+ removeAssortmentFilter: (root: any, params: any, context: any, info: any) => Promise<any>;
136
+ reorderAssortmentFilters: (root: any, params: any, context: any, info: any) => Promise<any>;
137
+ createProductReview: (root: any, params: any, context: any, info: any) => Promise<any>;
138
+ updateProductReview: (root: any, params: any, context: any, info: any) => Promise<any>;
139
+ removeProductReview: (root: any, params: any, context: any, info: any) => Promise<any>;
140
+ addProductReviewVote: (root: any, params: any, context: any, info: any) => Promise<any>;
141
+ removeProductReviewVote: (root: any, params: any, context: any, info: any) => Promise<any>;
142
+ requestQuotation: (root: any, params: any, context: any, info: any) => Promise<any>;
143
+ rejectQuotation: (root: any, params: any, context: any, info: any) => Promise<any>;
144
+ verifyQuotation: (root: any, params: any, context: any, info: any) => Promise<any>;
145
+ makeQuotationProposal: (root: any, params: any, context: any, info: any) => Promise<any>;
146
+ bookmark: (root: any, params: any, context: any, info: any) => Promise<any>;
147
+ createBookmark: (root: any, params: any, context: any, info: any) => Promise<any>;
148
+ removeBookmark: (root: any, params: any, context: any, info: any) => Promise<any>;
149
+ addWork: (root: any, params: any, context: any, info: any) => Promise<any>;
150
+ allocateWork: (root: any, params: any, context: any, info: any) => Promise<any>;
151
+ finishWork: (root: any, params: any, context: any, info: any) => Promise<any>;
152
+ removeWork: (root: any, params: any, context: any, info: any) => Promise<any>;
153
+ processNextWork: (root: any, params: any, context: any, info: any) => Promise<any>;
154
+ signPaymentProviderForCredentialRegistration: (root: any, params: any, context: any, info: any) => Promise<any>;
155
+ signPaymentProviderForCheckout: (root: any, params: any, context: any, info: any) => Promise<any>;
156
+ removeUserProductReviews: (root: any, params: any, context: any, info: any) => Promise<any>;
157
157
  };
158
158
  export default _default;
@@ -1,4 +1,5 @@
1
1
  import { log } from '@unchainedshop/logger';
2
+ import { Roles } from '@unchainedshop/roles';
2
3
  import { InvalidIdError, UserNotFoundError } from "../../../errors.js";
3
4
  export default async function setRoles(root, params, { modules, userId }) {
4
5
  const foreignUserId = params.userId;
@@ -7,5 +8,9 @@ export default async function setRoles(root, params, { modules, userId }) {
7
8
  throw new InvalidIdError({ foreignUserId });
8
9
  if (!(await modules.users.userExists({ userId: foreignUserId })))
9
10
  throw new UserNotFoundError({ userId: foreignUserId });
11
+ const invalidRoles = params.roles.filter((role) => !Roles.roles[role]);
12
+ if (invalidRoles.length > 0) {
13
+ throw new Error(`Invalid role names: ${invalidRoles.join(', ')}`);
14
+ }
10
15
  return modules.users.updateRoles(foreignUserId, params.roles);
11
16
  }
@@ -3,76 +3,76 @@ import impersonator from './users/impersonator.ts';
3
3
  declare const _default: {
4
4
  me: typeof me;
5
5
  impersonator: typeof impersonator;
6
- user: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
7
- users: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
8
- usersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
9
- product: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
10
- products: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
11
- productsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
12
- productCatalogPrices: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
13
- languagesCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
14
- languages: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
15
- language: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
16
- countriesCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
17
- countries: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
18
- country: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
19
- currenciesCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
20
- currencies: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
21
- currency: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
22
- paymentProviders: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
23
- paymentProvidersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
24
- paymentProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
25
- paymentInterfaces: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
26
- deliveryProvidersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
27
- deliveryProviders: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
28
- deliveryProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
29
- deliveryInterfaces: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
30
- warehousingProvidersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
31
- warehousingProviders: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
32
- warehousingProvider: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
33
- warehousingInterfaces: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
34
- token: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
35
- tokens: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
36
- tokensCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
37
- translatedProductTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
38
- translatedProductMediaTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
39
- translatedProductVariationTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
40
- ordersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
41
- orders: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
42
- order: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
43
- assortmentsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
44
- assortments: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
45
- translatedAssortmentMediaTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
46
- assortment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
47
- filtersCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
48
- filters: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
49
- filter: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
50
- shopInfo: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
51
- translatedAssortmentTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
52
- translatedFilterTexts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
53
- productReview: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
54
- productReviews: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
55
- productReviewsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
56
- quotation: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
57
- quotations: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
58
- quotationsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
59
- searchProducts: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
60
- searchAssortments: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
61
- workQueue: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
62
- workQueueCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
63
- activeWorkTypes: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
64
- enrollment: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
65
- enrollments: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
66
- enrollmentsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
67
- work: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
68
- event: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
69
- events: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
70
- eventsCount: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
71
- registeredEventTypes: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
72
- validateResetPasswordToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
73
- validateVerifyEmailToken: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
74
- workStatistics: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
75
- eventStatistics: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
76
- orderStatistics: (root: any, params: any, context: any, ...other: any[]) => Promise<any>;
6
+ user: (root: any, params: any, context: any, info: any) => Promise<any>;
7
+ users: (root: any, params: any, context: any, info: any) => Promise<any>;
8
+ usersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
9
+ product: (root: any, params: any, context: any, info: any) => Promise<any>;
10
+ products: (root: any, params: any, context: any, info: any) => Promise<any>;
11
+ productsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
12
+ productCatalogPrices: (root: any, params: any, context: any, info: any) => Promise<any>;
13
+ languagesCount: (root: any, params: any, context: any, info: any) => Promise<any>;
14
+ languages: (root: any, params: any, context: any, info: any) => Promise<any>;
15
+ language: (root: any, params: any, context: any, info: any) => Promise<any>;
16
+ countriesCount: (root: any, params: any, context: any, info: any) => Promise<any>;
17
+ countries: (root: any, params: any, context: any, info: any) => Promise<any>;
18
+ country: (root: any, params: any, context: any, info: any) => Promise<any>;
19
+ currenciesCount: (root: any, params: any, context: any, info: any) => Promise<any>;
20
+ currencies: (root: any, params: any, context: any, info: any) => Promise<any>;
21
+ currency: (root: any, params: any, context: any, info: any) => Promise<any>;
22
+ paymentProviders: (root: any, params: any, context: any, info: any) => Promise<any>;
23
+ paymentProvidersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
24
+ paymentProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
25
+ paymentInterfaces: (root: any, params: any, context: any, info: any) => Promise<any>;
26
+ deliveryProvidersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
27
+ deliveryProviders: (root: any, params: any, context: any, info: any) => Promise<any>;
28
+ deliveryProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
29
+ deliveryInterfaces: (root: any, params: any, context: any, info: any) => Promise<any>;
30
+ warehousingProvidersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
31
+ warehousingProviders: (root: any, params: any, context: any, info: any) => Promise<any>;
32
+ warehousingProvider: (root: any, params: any, context: any, info: any) => Promise<any>;
33
+ warehousingInterfaces: (root: any, params: any, context: any, info: any) => Promise<any>;
34
+ token: (root: any, params: any, context: any, info: any) => Promise<any>;
35
+ tokens: (root: any, params: any, context: any, info: any) => Promise<any>;
36
+ tokensCount: (root: any, params: any, context: any, info: any) => Promise<any>;
37
+ translatedProductTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
38
+ translatedProductMediaTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
39
+ translatedProductVariationTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
40
+ ordersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
41
+ orders: (root: any, params: any, context: any, info: any) => Promise<any>;
42
+ order: (root: any, params: any, context: any, info: any) => Promise<any>;
43
+ assortmentsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
44
+ assortments: (root: any, params: any, context: any, info: any) => Promise<any>;
45
+ translatedAssortmentMediaTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
46
+ assortment: (root: any, params: any, context: any, info: any) => Promise<any>;
47
+ filtersCount: (root: any, params: any, context: any, info: any) => Promise<any>;
48
+ filters: (root: any, params: any, context: any, info: any) => Promise<any>;
49
+ filter: (root: any, params: any, context: any, info: any) => Promise<any>;
50
+ shopInfo: (root: any, params: any, context: any, info: any) => Promise<any>;
51
+ translatedAssortmentTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
52
+ translatedFilterTexts: (root: any, params: any, context: any, info: any) => Promise<any>;
53
+ productReview: (root: any, params: any, context: any, info: any) => Promise<any>;
54
+ productReviews: (root: any, params: any, context: any, info: any) => Promise<any>;
55
+ productReviewsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
56
+ quotation: (root: any, params: any, context: any, info: any) => Promise<any>;
57
+ quotations: (root: any, params: any, context: any, info: any) => Promise<any>;
58
+ quotationsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
59
+ searchProducts: (root: any, params: any, context: any, info: any) => Promise<any>;
60
+ searchAssortments: (root: any, params: any, context: any, info: any) => Promise<any>;
61
+ workQueue: (root: any, params: any, context: any, info: any) => Promise<any>;
62
+ workQueueCount: (root: any, params: any, context: any, info: any) => Promise<any>;
63
+ activeWorkTypes: (root: any, params: any, context: any, info: any) => Promise<any>;
64
+ enrollment: (root: any, params: any, context: any, info: any) => Promise<any>;
65
+ enrollments: (root: any, params: any, context: any, info: any) => Promise<any>;
66
+ enrollmentsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
67
+ work: (root: any, params: any, context: any, info: any) => Promise<any>;
68
+ event: (root: any, params: any, context: any, info: any) => Promise<any>;
69
+ events: (root: any, params: any, context: any, info: any) => Promise<any>;
70
+ eventsCount: (root: any, params: any, context: any, info: any) => Promise<any>;
71
+ registeredEventTypes: (root: any, params: any, context: any, info: any) => Promise<any>;
72
+ validateResetPasswordToken: (root: any, params: any, context: any, info: any) => Promise<any>;
73
+ validateVerifyEmailToken: (root: any, params: any, context: any, info: any) => Promise<any>;
74
+ workStatistics: (root: any, params: any, context: any, info: any) => Promise<any>;
75
+ eventStatistics: (root: any, params: any, context: any, info: any) => Promise<any>;
76
+ orderStatistics: (root: any, params: any, context: any, info: any) => Promise<any>;
77
77
  };
78
78
  export default _default;
@@ -776,12 +776,12 @@ declare const types: {
776
776
  Token: {
777
777
  product: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { loaders }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-products").Product>;
778
778
  user: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { loaders }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-users").User | null>;
779
- status: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { services }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
779
+ status: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, { loaders }: import("../../context.ts").Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
780
780
  ercMetadata: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, { forceLocale }: {
781
781
  forceLocale: string;
782
782
  }, context: import("../../context.ts").Context) => Promise<any>;
783
- isInvalidateable: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, _params: never, { services }: import("../../context.ts").Context) => Promise<boolean>;
784
- accessKey: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, requestContext: import("../../context.ts").Context) => Promise<string | null>;
783
+ isInvalidateable: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, _params: never, { loaders, services }: import("../../context.ts").Context) => Promise<boolean>;
784
+ accessKey: (token: import("@unchainedshop/core-warehousing").TokenSurrogate, params: never, requestContext: import("../../context.ts").Context) => Promise<string>;
785
785
  };
786
786
  User: import("./user-types.ts").UserHelperTypes;
787
787
  WebAuthnCredentials: {
@@ -1,6 +1,7 @@
1
+ import { IN_LOGIN_RESPONSE } from "../../context.js";
1
2
  export const LoginMethodResponse = {
2
3
  user({ user }) {
3
- user._inLoginMethodResponse = true;
4
+ user[IN_LOGIN_RESPONSE] = true;
4
5
  return user;
5
6
  },
6
7
  };
@@ -3,10 +3,10 @@ import type { TokenSurrogate } from '@unchainedshop/core-warehousing';
3
3
  export declare const Token: {
4
4
  product: (token: TokenSurrogate, params: never, { loaders }: Context) => Promise<import("@unchainedshop/core-products").Product>;
5
5
  user: (token: TokenSurrogate, params: never, { loaders }: Context) => Promise<import("@unchainedshop/core-users").User | null>;
6
- status: (token: TokenSurrogate, params: never, { services }: Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
6
+ status: (token: TokenSurrogate, params: never, { loaders }: Context) => Promise<import("@unchainedshop/core-warehousing").TokenStatus>;
7
7
  ercMetadata: (token: TokenSurrogate, { forceLocale }: {
8
8
  forceLocale: string;
9
9
  }, context: Context) => Promise<any>;
10
- isInvalidateable: (token: TokenSurrogate, _params: never, { services }: Context) => Promise<boolean>;
11
- accessKey: (token: TokenSurrogate, params: never, requestContext: Context) => Promise<string | null>;
10
+ isInvalidateable: (token: TokenSurrogate, _params: never, { loaders, services }: Context) => Promise<boolean>;
11
+ accessKey: (token: TokenSurrogate, params: never, requestContext: Context) => Promise<string>;
12
12
  };
@@ -9,8 +9,8 @@ export const Token = {
9
9
  return null;
10
10
  return loaders.userLoader.load({ userId: token.userId });
11
11
  },
12
- status: async (token, params, { services }) => {
13
- return services.warehousing.resolveTokenStatus({ token });
12
+ status: async (token, params, { loaders }) => {
13
+ return loaders.tokenExportStatusLoader.load({ token });
14
14
  },
15
15
  ercMetadata: async (token, { forceLocale }, context) => {
16
16
  const { loaders, services } = context;
@@ -21,12 +21,13 @@ export const Token = {
21
21
  locale: forceLocale ? new Intl.Locale(forceLocale) : context.locale,
22
22
  });
23
23
  },
24
- isInvalidateable: async (token, _params, { services }) => {
25
- return services.warehousing.isTokenInvalidateable({ token });
24
+ isInvalidateable: async (token, _params, { loaders, services }) => {
25
+ const product = await loaders.productLoader.load({ productId: token.productId });
26
+ return services.warehousing.isTokenInvalidateable({ token, product });
26
27
  },
27
28
  accessKey: async (token, params, requestContext) => {
28
29
  const { modules } = requestContext;
29
30
  await checkAction(requestContext, actions.updateToken, [undefined, { tokenId: token._id }]);
30
- return modules.warehousing.buildAccessKeyForToken(token._id);
31
+ return modules.warehousing.buildAccessKeyFromToken(token);
31
32
  },
32
33
  };
package/lib/roles/all.js CHANGED
@@ -1,6 +1,8 @@
1
+ import { timingSafeStringEqual } from '@unchainedshop/utils';
2
+ import { IN_LOGIN_RESPONSE } from "../context.js";
1
3
  export const all = (role, actions) => {
2
4
  const isInLoginMutationResponse = (root) => {
3
- if (root && root._inLoginMethodResponse) {
5
+ if (root && root[IN_LOGIN_RESPONSE]) {
4
6
  return true;
5
7
  }
6
8
  return false;
@@ -18,8 +20,8 @@ export const all = (role, actions) => {
18
20
  if (isOwnedByUser)
19
21
  return true;
20
22
  const accessKeyHeader = context.getHeader('x-token-accesskey');
21
- const accessKey = await context.modules.warehousing.buildAccessKeyForToken(tokenId);
22
- if (accessKeyHeader && accessKeyHeader === accessKey)
23
+ const accessKey = await context.modules.warehousing.buildAccessKeyFromToken(token);
24
+ if (accessKeyHeader && accessKey && (await timingSafeStringEqual(accessKeyHeader, accessKey)))
23
25
  return true;
24
26
  return false;
25
27
  };
@@ -145,6 +147,6 @@ export const all = (role, actions) => {
145
147
  role.allow(actions.createUser, () => true);
146
148
  role.allow(actions.forgotPassword, () => true);
147
149
  role.allow(actions.resetPassword, () => true);
148
- role.allow(actions.changePassword, () => true);
150
+ role.allow(actions.changePassword, () => false);
149
151
  role.allow(actions.heartbeat, () => true);
150
152
  };
@@ -166,6 +166,7 @@ export const loggedIn = (role, actions) => {
166
166
  role.allow(actions.manageBookmarks, isOwnedBookmark);
167
167
  role.allow(actions.bookmarkProduct, () => true);
168
168
  role.allow(actions.voteProductReview, () => true);
169
+ role.allow(actions.changePassword, () => true);
169
170
  role.allow(actions.registerPaymentCredentials, () => true);
170
171
  role.allow(actions.managePaymentCredentials, isOwnedPaymentCredential);
171
172
  role.allow(actions.confirmMediaUpload, () => true);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@unchainedshop/api",
3
3
  "description": "GraphQL API layer for the Unchained Engine with Express/Fastify adapters and MCP server",
4
- "version": "4.8.3",
4
+ "version": "4.8.9",
5
5
  "main": "lib/api-index.js",
6
6
  "types": "lib/api-index.d.ts",
7
7
  "type": "module",