@unchainedshop/api 3.0.0-rc8 → 3.0.0-rc9
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/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts +4 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts +4 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js +1 -1
- package/lib/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.js.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.d.ts.map +1 -1
- package/lib/resolvers/mutations/accounts/resetPassword.js +12 -43
- package/lib/resolvers/mutations/accounts/resetPassword.js.map +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.d.ts +1 -3
- package/lib/resolvers/mutations/countries/updateCountry.d.ts.map +1 -1
- package/lib/resolvers/mutations/countries/updateCountry.js +1 -5
- package/lib/resolvers/mutations/countries/updateCountry.js.map +1 -1
- package/lib/resolvers/queries/users/validateResetPasswordToken.js +2 -2
- package/lib/resolvers/queries/users/validateResetPasswordToken.js.map +1 -1
- package/package.json +6 -6
- package/src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts +1 -1
- package/src/resolvers/mutations/accounts/resetPassword.ts +13 -46
- package/src/resolvers/mutations/countries/updateCountry.ts +2 -7
- package/src/resolvers/queries/users/validateResetPasswordToken.ts +2 -2
- package/lib/resolvers/type/dispatch-types.d.ts +0 -15
- package/lib/resolvers/type/dispatch-types.d.ts.map +0 -1
- package/lib/resolvers/type/dispatch-types.js +0 -13
- package/lib/resolvers/type/dispatch-types.js.map +0 -1
- package/lib/resolvers/type/stock-types.d.ts +0 -14
- package/lib/resolvers/type/stock-types.d.ts.map +0 -1
- package/lib/resolvers/type/stock-types.js +0 -12
- package/lib/resolvers/type/stock-types.js.map +0 -1
|
@@ -2,5 +2,8 @@ import { Context } from '../../../context.js';
|
|
|
2
2
|
export default function createWebAuthnCredentialCreationOptions(root: never, { extensionOptions, username }: {
|
|
3
3
|
username: string;
|
|
4
4
|
extensionOptions: any;
|
|
5
|
-
}, { modules, userId, getHeader }: Context): Promise<
|
|
5
|
+
}, { modules, userId, getHeader }: Context): Promise<Omit<import("fido2-lib").PublicKeyCredentialCreationOptions, "challenge" | "requestId"> & {
|
|
6
|
+
challenge: string;
|
|
7
|
+
requestId: number;
|
|
8
|
+
}>;
|
|
6
9
|
//# sourceMappingURL=createWebAuthnCredentialCreationOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWebAuthnCredentialCreationOptions.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,uCAAuC,CACnE,IAAI,EAAE,KAAK,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAA;CAAE,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"createWebAuthnCredentialCreationOptions.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialCreationOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,uCAAuC,CACnE,IAAI,EAAE,KAAK,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAA;CAAE,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO;;;GAaxC"}
|
|
@@ -2,5 +2,8 @@ import { Context } from '../../../context.js';
|
|
|
2
2
|
export default function createWebAuthnCredentialRequestOptions(root: never, { extensionOptions, username }: {
|
|
3
3
|
username: string;
|
|
4
4
|
extensionOptions: any;
|
|
5
|
-
}, { modules, userId, getHeader }: Context): Promise<
|
|
5
|
+
}, { modules, userId, getHeader }: Context): Promise<Omit<import("fido2-lib").PublicKeyCredentialRequestOptions, "challenge" | "requestId"> & {
|
|
6
|
+
challenge: string;
|
|
7
|
+
requestId: number;
|
|
8
|
+
}>;
|
|
6
9
|
//# sourceMappingURL=createWebAuthnCredentialRequestOptions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWebAuthnCredentialRequestOptions.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,sCAAsC,CAClE,IAAI,EAAE,KAAK,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAA;CAAE,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"createWebAuthnCredentialRequestOptions.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,sCAAsC,CAClE,IAAI,EAAE,KAAK,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAA;CAAE,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,OAAO;;;GAqBxC"}
|
|
@@ -8,7 +8,7 @@ export default async function createWebAuthnCredentialRequestOptions(root, { ext
|
|
|
8
8
|
const user = await modules.users.findUserByUsername(username);
|
|
9
9
|
options.allowCredentials = user?.services?.webAuthn?.map(({ id, type }) => ({
|
|
10
10
|
id,
|
|
11
|
-
type: type ||
|
|
11
|
+
type: type || 'public-key',
|
|
12
12
|
}));
|
|
13
13
|
}
|
|
14
14
|
return options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createWebAuthnCredentialRequestOptions.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,sCAAsC,CAClE,IAAW,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAA+C,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAW;IAEvC,GAAG,CAAC,mDAAmD,QAAQ,EAAE,EAAE;QACjE,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,8BAA8B,CACzE,SAAS,CAAC,QAAQ,CAAC,EACnB,QAAQ,EACR,gBAAgB,CACjB,CAAC;IAEF,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC9D,OAAO,CAAC,gBAAgB,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1E,EAAE;YACF,IAAI,EAAE,IAAI,IAAI,
|
|
1
|
+
{"version":3,"file":"createWebAuthnCredentialRequestOptions.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/createWebAuthnCredentialRequestOptions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,sCAAsC,CAClE,IAAW,EACX,EAAE,gBAAgB,EAAE,QAAQ,EAA+C,EAC3E,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAW;IAEvC,GAAG,CAAC,mDAAmD,QAAQ,EAAE,EAAE;QACjE,MAAM;KACP,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,8BAA8B,CACzE,SAAS,CAAC,QAAQ,CAAC,EACnB,QAAQ,EACR,gBAAgB,CACjB,CAAC;IAEF,IAAI,QAAQ,IAAI,OAAO,EAAE,CAAC;QACxB,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;QAC9D,OAAO,CAAC,gBAAgB,GAAG,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC;YAC1E,EAAE;YACF,IAAI,EAAE,IAAI,IAAI,YAAY;SAC3B,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/resetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,aAAa,CACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EAAE,OAAO;;;
|
|
1
|
+
{"version":3,"file":"resetPassword.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/resetPassword.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,aAAa,CACzC,IAAI,EAAE,KAAK,EACX,MAAM,EAAE;IAAE,WAAW,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,EAC/C,OAAO,EAAE,OAAO;;;GA2BjB"}
|
|
@@ -6,55 +6,24 @@ export default async function resetPassword(root, params, context) {
|
|
|
6
6
|
if (!params.newPassword) {
|
|
7
7
|
throw new Error('Password is required');
|
|
8
8
|
}
|
|
9
|
-
let user = await modules.users.findUserByResetToken(params.token);
|
|
10
|
-
if (!user)
|
|
11
|
-
throw new InvalidResetTokenError({});
|
|
12
9
|
try {
|
|
13
|
-
await modules.users.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// verified: false,
|
|
25
|
-
// },
|
|
26
|
-
// },
|
|
27
|
-
// },
|
|
28
|
-
// {
|
|
29
|
-
// $set: {
|
|
30
|
-
// 'emails.$[email].verified': true,
|
|
31
|
-
// },
|
|
32
|
-
// },
|
|
33
|
-
// {
|
|
34
|
-
// arrayFilters: [{ 'email.address': resetTicket.address }],
|
|
35
|
-
// },
|
|
36
|
-
// );
|
|
37
|
-
// if (updatedUser) {
|
|
38
|
-
// await modules.accounts.emit('VerifyEmailSuccess', updatedUser);
|
|
39
|
-
// }
|
|
40
|
-
// } catch (e) {
|
|
41
|
-
// /* */
|
|
42
|
-
// }
|
|
43
|
-
// }
|
|
10
|
+
let user = await modules.users.resetPassword(params.token, params.newPassword);
|
|
11
|
+
if (!user)
|
|
12
|
+
throw new InvalidResetTokenError({});
|
|
13
|
+
user = await context.modules.users.updateHeartbeat(user._id, {
|
|
14
|
+
remoteAddress: context.remoteAddress,
|
|
15
|
+
remotePort: context.remotePort,
|
|
16
|
+
userAgent: context.userAgent,
|
|
17
|
+
locale: context.localeContext.baseName,
|
|
18
|
+
countryCode: context.countryContext,
|
|
19
|
+
});
|
|
20
|
+
return context.login(user);
|
|
44
21
|
}
|
|
45
22
|
catch (e) {
|
|
46
23
|
if (e.cause === 'PASSWORD_INVALID')
|
|
47
|
-
throw new PasswordInvalidError({
|
|
24
|
+
throw new PasswordInvalidError({});
|
|
48
25
|
else
|
|
49
26
|
throw e;
|
|
50
27
|
}
|
|
51
|
-
user = await context.modules.users.updateHeartbeat(user._id, {
|
|
52
|
-
remoteAddress: context.remoteAddress,
|
|
53
|
-
remotePort: context.remotePort,
|
|
54
|
-
userAgent: context.userAgent,
|
|
55
|
-
locale: context.localeContext.baseName,
|
|
56
|
-
countryCode: context.countryContext,
|
|
57
|
-
});
|
|
58
|
-
return context.login(user);
|
|
59
28
|
}
|
|
60
29
|
//# sourceMappingURL=resetPassword.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resetPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGlF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,IAAW,EACX,MAA+C,EAC/C,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,GAAG,CAAC,wBAAwB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1C,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;
|
|
1
|
+
{"version":3,"file":"resetPassword.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/accounts/resetPassword.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAGlF,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,IAAW,EACX,MAA+C,EAC/C,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,GAAG,CAAC,wBAAwB,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAE1C,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;IAC1C,CAAC;IAED,IAAI,CAAC;QACH,IAAI,IAAI,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;QAC/E,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,sBAAsB,CAAC,EAAE,CAAC,CAAC;QAEhD,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,eAAe,CAAC,IAAI,CAAC,GAAG,EAAE;YAC3D,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,UAAU,EAAE,OAAO,CAAC,UAAU;YAC9B,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,MAAM,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ;YACtC,WAAW,EAAE,OAAO,CAAC,cAAc;SACpC,CAAC,CAAC;QAEH,OAAO,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC;IAAC,OAAO,CAAC,EAAE,CAAC;QACX,IAAI,CAAC,CAAC,KAAK,KAAK,kBAAkB;YAAE,MAAM,IAAI,oBAAoB,CAAC,EAAE,CAAC,CAAC;;YAClE,MAAM,CAAC,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { Country } from '@unchainedshop/core-countries';
|
|
2
2
|
import { Context } from '../../../context.js';
|
|
3
3
|
export default function updateCountry(root: never, { country, countryId }: {
|
|
4
|
-
country: Country
|
|
5
|
-
defaultCurrencyId: string;
|
|
6
|
-
};
|
|
4
|
+
country: Country;
|
|
7
5
|
countryId: string;
|
|
8
6
|
}, { userId, modules }: Context): Promise<Country>;
|
|
9
7
|
//# sourceMappingURL=updateCountry.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateCountry.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/countries/updateCountry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,aAAa,CACzC,IAAI,EAAE,KAAK,EACX,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"updateCountry.d.ts","sourceRoot":"","sources":["../../../../src/resolvers/mutations/countries/updateCountry.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,+BAA+B,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,wBAA8B,aAAa,CACzC,IAAI,EAAE,KAAK,EACX,EAAE,OAAO,EAAE,SAAS,EAAE,EAAE;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,EAC/D,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,OAAO,oBAY7B"}
|
|
@@ -6,11 +6,7 @@ export default async function updateCountry(root, { country, countryId }, { user
|
|
|
6
6
|
throw new InvalidIdError({ countryId });
|
|
7
7
|
if (!(await modules.countries.countryExists({ countryId })))
|
|
8
8
|
throw new CountryNotFoundError({ countryId });
|
|
9
|
-
|
|
10
|
-
currencyId: country.defaultCurrencyId,
|
|
11
|
-
});
|
|
12
|
-
const defaultCurrencyCode = country?.defaultCurrencyCode || currencyObject?.isoCode;
|
|
13
|
-
await modules.countries.update(countryId, { ...country, defaultCurrencyCode });
|
|
9
|
+
await modules.countries.update(countryId, country);
|
|
14
10
|
return modules.countries.findCountry({ countryId });
|
|
15
11
|
}
|
|
16
12
|
//# sourceMappingURL=updateCountry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"updateCountry.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/countries/updateCountry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,IAAW,EACX,EAAE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"updateCountry.js","sourceRoot":"","sources":["../../../../src/resolvers/mutations/countries/updateCountry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAE5C,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AAG1E,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,aAAa,CACzC,IAAW,EACX,EAAE,OAAO,EAAE,SAAS,EAA2C,EAC/D,EAAE,MAAM,EAAE,OAAO,EAAW;IAE5B,GAAG,CAAC,0BAA0B,SAAS,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;IAEvD,IAAI,CAAC,SAAS;QAAE,MAAM,IAAI,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAExD,IAAI,CAAC,CAAC,MAAM,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;QACzD,MAAM,IAAI,oBAAoB,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;IAEhD,MAAM,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,OAAO,CAAC,SAAS,CAAC,WAAW,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -2,7 +2,7 @@ import { log } from '@unchainedshop/logger';
|
|
|
2
2
|
export default async function validateResetPasswordToken(root, params, context) {
|
|
3
3
|
const { modules, userId } = context;
|
|
4
4
|
log('query validateResetPasswordToken', { userId, token: params.token });
|
|
5
|
-
const
|
|
6
|
-
return !!
|
|
5
|
+
const resetToken = await modules.users.findResetToken(params.token);
|
|
6
|
+
return !!resetToken;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=validateResetPasswordToken.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateResetPasswordToken.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/users/validateResetPasswordToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,0BAA0B,CACtD,IAAW,EACX,MAAyB,EACzB,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,GAAG,CAAC,kCAAkC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAEzE,MAAM,
|
|
1
|
+
{"version":3,"file":"validateResetPasswordToken.js","sourceRoot":"","sources":["../../../../src/resolvers/queries/users/validateResetPasswordToken.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAG5C,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,0BAA0B,CACtD,IAAW,EACX,MAAyB,EACzB,OAAgB;IAEhB,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAEpC,GAAG,CAAC,kCAAkC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC;IAEzE,MAAM,UAAU,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAEpE,OAAO,CAAC,CAAC,UAAU,CAAC;AACtB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/api",
|
|
3
|
-
"version": "3.0.0-
|
|
3
|
+
"version": "3.0.0-rc9",
|
|
4
4
|
"main": "lib/api-index.js",
|
|
5
5
|
"types": "lib/api-index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -71,11 +71,11 @@
|
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
|
-
"@unchainedshop/core": "^3.0.0-
|
|
75
|
-
"@unchainedshop/events": "^3.0.0-
|
|
76
|
-
"@unchainedshop/logger": "^3.0.0-
|
|
77
|
-
"@unchainedshop/roles": "^3.0.0-
|
|
78
|
-
"@unchainedshop/utils": "^3.0.0-
|
|
74
|
+
"@unchainedshop/core": "^3.0.0-rc9",
|
|
75
|
+
"@unchainedshop/events": "^3.0.0-rc9",
|
|
76
|
+
"@unchainedshop/logger": "^3.0.0-rc9",
|
|
77
|
+
"@unchainedshop/roles": "^3.0.0-rc9",
|
|
78
|
+
"@unchainedshop/utils": "^3.0.0-rc9",
|
|
79
79
|
"accounting": "0.4.1",
|
|
80
80
|
"dataloader": "^2.2.3",
|
|
81
81
|
"expiry-map": "^2.0.0",
|
|
@@ -20,7 +20,7 @@ export default async function createWebAuthnCredentialRequestOptions(
|
|
|
20
20
|
const user = await modules.users.findUserByUsername(username);
|
|
21
21
|
options.allowCredentials = user?.services?.webAuthn?.map(({ id, type }) => ({
|
|
22
22
|
id,
|
|
23
|
-
type: type ||
|
|
23
|
+
type: type || 'public-key',
|
|
24
24
|
}));
|
|
25
25
|
}
|
|
26
26
|
|
|
@@ -14,55 +14,22 @@ export default async function resetPassword(
|
|
|
14
14
|
if (!params.newPassword) {
|
|
15
15
|
throw new Error('Password is required');
|
|
16
16
|
}
|
|
17
|
-
let user = await modules.users.findUserByResetToken(params.token);
|
|
18
|
-
|
|
19
|
-
if (!user) throw new InvalidResetTokenError({});
|
|
20
17
|
|
|
21
18
|
try {
|
|
22
|
-
await modules.users.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// verified: false,
|
|
35
|
-
// },
|
|
36
|
-
// },
|
|
37
|
-
// },
|
|
38
|
-
// {
|
|
39
|
-
// $set: {
|
|
40
|
-
// 'emails.$[email].verified': true,
|
|
41
|
-
// },
|
|
42
|
-
// },
|
|
43
|
-
// {
|
|
44
|
-
// arrayFilters: [{ 'email.address': resetTicket.address }],
|
|
45
|
-
// },
|
|
46
|
-
// );
|
|
47
|
-
// if (updatedUser) {
|
|
48
|
-
// await modules.accounts.emit('VerifyEmailSuccess', updatedUser);
|
|
49
|
-
// }
|
|
50
|
-
// } catch (e) {
|
|
51
|
-
// /* */
|
|
52
|
-
// }
|
|
53
|
-
// }
|
|
19
|
+
let user = await modules.users.resetPassword(params.token, params.newPassword);
|
|
20
|
+
if (!user) throw new InvalidResetTokenError({});
|
|
21
|
+
|
|
22
|
+
user = await context.modules.users.updateHeartbeat(user._id, {
|
|
23
|
+
remoteAddress: context.remoteAddress,
|
|
24
|
+
remotePort: context.remotePort,
|
|
25
|
+
userAgent: context.userAgent,
|
|
26
|
+
locale: context.localeContext.baseName,
|
|
27
|
+
countryCode: context.countryContext,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return context.login(user);
|
|
54
31
|
} catch (e) {
|
|
55
|
-
if (e.cause === 'PASSWORD_INVALID') throw new PasswordInvalidError({
|
|
32
|
+
if (e.cause === 'PASSWORD_INVALID') throw new PasswordInvalidError({});
|
|
56
33
|
else throw e;
|
|
57
34
|
}
|
|
58
|
-
|
|
59
|
-
user = await context.modules.users.updateHeartbeat(user._id, {
|
|
60
|
-
remoteAddress: context.remoteAddress,
|
|
61
|
-
remotePort: context.remotePort,
|
|
62
|
-
userAgent: context.userAgent,
|
|
63
|
-
locale: context.localeContext.baseName,
|
|
64
|
-
countryCode: context.countryContext,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
return context.login(user);
|
|
68
35
|
}
|
|
@@ -5,7 +5,7 @@ import { Context } from '../../../context.js';
|
|
|
5
5
|
|
|
6
6
|
export default async function updateCountry(
|
|
7
7
|
root: never,
|
|
8
|
-
{ country, countryId }: { country: Country
|
|
8
|
+
{ country, countryId }: { country: Country; countryId: string },
|
|
9
9
|
{ userId, modules }: Context,
|
|
10
10
|
) {
|
|
11
11
|
log(`mutation updateCountry ${countryId}`, { userId });
|
|
@@ -15,12 +15,7 @@ export default async function updateCountry(
|
|
|
15
15
|
if (!(await modules.countries.countryExists({ countryId })))
|
|
16
16
|
throw new CountryNotFoundError({ countryId });
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
currencyId: country.defaultCurrencyId,
|
|
20
|
-
});
|
|
21
|
-
const defaultCurrencyCode = country?.defaultCurrencyCode || currencyObject?.isoCode;
|
|
22
|
-
|
|
23
|
-
await modules.countries.update(countryId, { ...country, defaultCurrencyCode });
|
|
18
|
+
await modules.countries.update(countryId, country);
|
|
24
19
|
|
|
25
20
|
return modules.countries.findCountry({ countryId });
|
|
26
21
|
}
|
|
@@ -10,7 +10,7 @@ export default async function validateResetPasswordToken(
|
|
|
10
10
|
|
|
11
11
|
log('query validateResetPasswordToken', { userId, token: params.token });
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const resetToken = await modules.users.findResetToken(params.token);
|
|
14
14
|
|
|
15
|
-
return !!
|
|
15
|
+
return !!resetToken;
|
|
16
16
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
export declare const Dispatch: {
|
|
5
|
-
_id: (params: {
|
|
6
|
-
product: Product;
|
|
7
|
-
deliveryProvider: DeliveryProvider;
|
|
8
|
-
warehousingProvider: WarehousingProvider;
|
|
9
|
-
referenceDate: Date;
|
|
10
|
-
quantity: number;
|
|
11
|
-
country: string;
|
|
12
|
-
userId?: string;
|
|
13
|
-
}) => Promise<string>;
|
|
14
|
-
};
|
|
15
|
-
//# sourceMappingURL=dispatch-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/dispatch-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,eAAO,MAAM,QAAQ;kBACC;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,aAAa,EAAE,IAAI,CAAC;QACpB,QAAQ,EAAE,MAAM,CAAC;QACjB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAYF,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
2
|
-
export const Dispatch = {
|
|
3
|
-
_id: async (params) => await sha256([
|
|
4
|
-
params.product._id,
|
|
5
|
-
params.deliveryProvider._id,
|
|
6
|
-
params.warehousingProvider._id,
|
|
7
|
-
params.referenceDate,
|
|
8
|
-
params.quantity,
|
|
9
|
-
params.country,
|
|
10
|
-
params.userId || 'ANONYMOUS',
|
|
11
|
-
].join('')),
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=dispatch-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/dispatch-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,GAAG,EAAE,KAAK,EAAE,MAQX,EAAE,EAAE,CACH,MAAM,MAAM,CACV;QACE,MAAM,CAAC,OAAO,CAAC,GAAG;QAClB,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC3B,MAAM,CAAC,mBAAmB,CAAC,GAAG;QAC9B,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,QAAQ;QACf,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,MAAM,IAAI,WAAW;KAC7B,CAAC,IAAI,CAAC,EAAE,CAAC,CACX;CACJ,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { DeliveryProvider } from '@unchainedshop/core-delivery';
|
|
2
|
-
import { Product } from '@unchainedshop/core-products';
|
|
3
|
-
import { WarehousingProvider } from '@unchainedshop/core-warehousing';
|
|
4
|
-
export declare const Stock: {
|
|
5
|
-
_id: (params: {
|
|
6
|
-
product: Product;
|
|
7
|
-
deliveryProvider: DeliveryProvider;
|
|
8
|
-
warehousingProvider: WarehousingProvider;
|
|
9
|
-
referenceDate: Date;
|
|
10
|
-
country: string;
|
|
11
|
-
userId?: string;
|
|
12
|
-
}) => Promise<string>;
|
|
13
|
-
};
|
|
14
|
-
//# sourceMappingURL=stock-types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stock-types.d.ts","sourceRoot":"","sources":["../../../src/resolvers/type/stock-types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAGtE,eAAO,MAAM,KAAK;kBACI;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,gBAAgB,EAAE,gBAAgB,CAAC;QACnC,mBAAmB,EAAE,mBAAmB,CAAC;QACzC,aAAa,EAAE,IAAI,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;CAWF,CAAC"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { sha256 } from '@unchainedshop/utils';
|
|
2
|
-
export const Stock = {
|
|
3
|
-
_id: async (params) => await sha256([
|
|
4
|
-
params.product._id,
|
|
5
|
-
params.deliveryProvider._id,
|
|
6
|
-
params.warehousingProvider._id,
|
|
7
|
-
params.referenceDate,
|
|
8
|
-
params.country,
|
|
9
|
-
params.userId || 'ANONYMOUS',
|
|
10
|
-
].join('')),
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=stock-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stock-types.js","sourceRoot":"","sources":["../../../src/resolvers/type/stock-types.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,MAAM,CAAC,MAAM,KAAK,GAAG;IACnB,GAAG,EAAE,KAAK,EAAE,MAOX,EAAE,EAAE,CACH,MAAM,MAAM,CACV;QACE,MAAM,CAAC,OAAO,CAAC,GAAG;QAClB,MAAM,CAAC,gBAAgB,CAAC,GAAG;QAC3B,MAAM,CAAC,mBAAmB,CAAC,GAAG;QAC9B,MAAM,CAAC,aAAa;QACpB,MAAM,CAAC,OAAO;QACd,MAAM,CAAC,MAAM,IAAI,WAAW;KAC7B,CAAC,IAAI,CAAC,EAAE,CAAC,CACX;CACJ,CAAC"}
|