@byline/admin 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/abilities.js +5 -24
- package/dist/index.js +8 -30
- package/dist/lib/assert-admin-actor.js +13 -74
- package/dist/lib/create-command.js +6 -16
- package/dist/modules/admin-account/commands.js +35 -24
- package/dist/modules/admin-account/components/change-password.d.ts +8 -0
- package/dist/modules/admin-account/components/change-password.js +192 -0
- package/dist/modules/admin-account/components/change-password.module.js +8 -0
- package/dist/modules/admin-account/components/change-password_module.css +27 -0
- package/dist/modules/admin-account/components/container.d.ts +29 -0
- package/dist/modules/admin-account/components/container.js +298 -0
- package/dist/modules/admin-account/components/container.module.js +28 -0
- package/dist/modules/admin-account/components/container_module.css +106 -0
- package/dist/modules/admin-account/components/update.d.ts +8 -0
- package/dist/modules/admin-account/components/update.js +207 -0
- package/dist/modules/admin-account/components/update.module.js +8 -0
- package/dist/modules/admin-account/components/update_module.css +27 -0
- package/dist/modules/admin-account/errors.js +14 -45
- package/dist/modules/admin-account/index.js +4 -34
- package/dist/modules/admin-account/schemas.js +25 -59
- package/dist/modules/admin-account/service.js +56 -61
- package/dist/modules/admin-permissions/abilities.js +6 -24
- package/dist/modules/admin-permissions/commands.js +42 -28
- package/dist/modules/admin-permissions/components/inspector.d.ts +4 -0
- package/dist/modules/admin-permissions/components/inspector.js +284 -0
- package/dist/modules/admin-permissions/components/inspector.module.js +56 -0
- package/dist/modules/admin-permissions/components/inspector_module.css +238 -0
- package/dist/modules/admin-permissions/dto.js +3 -16
- package/dist/modules/admin-permissions/errors.js +14 -27
- package/dist/modules/admin-permissions/index.js +6 -26
- package/dist/modules/admin-permissions/repository.js +1 -8
- package/dist/modules/admin-permissions/schemas.js +33 -70
- package/dist/modules/admin-permissions/service.js +88 -92
- package/dist/modules/admin-roles/abilities.js +8 -30
- package/dist/modules/admin-roles/commands.js +89 -55
- package/dist/modules/admin-roles/components/create.d.ts +7 -0
- package/dist/modules/admin-roles/components/create.js +177 -0
- package/dist/modules/admin-roles/components/create.module.js +8 -0
- package/dist/modules/admin-roles/components/create_module.css +27 -0
- package/dist/modules/admin-roles/components/permissions.d.ts +10 -0
- package/dist/modules/admin-roles/components/permissions.js +303 -0
- package/dist/modules/admin-roles/components/permissions.module.js +44 -0
- package/dist/modules/admin-roles/components/permissions_module.css +192 -0
- package/dist/modules/admin-roles/components/update.d.ts +8 -0
- package/dist/modules/admin-roles/components/update.js +166 -0
- package/dist/modules/admin-roles/components/update.module.js +8 -0
- package/dist/modules/admin-roles/components/update_module.css +27 -0
- package/dist/modules/admin-roles/dto.js +3 -16
- package/dist/modules/admin-roles/errors.js +16 -40
- package/dist/modules/admin-roles/index.js +6 -26
- package/dist/modules/admin-roles/repository.js +1 -8
- package/dist/modules/admin-roles/schemas.js +41 -71
- package/dist/modules/admin-roles/service.js +79 -82
- package/dist/modules/admin-users/abilities.js +9 -38
- package/dist/modules/admin-users/commands.js +92 -50
- package/dist/modules/admin-users/components/create.d.ts +8 -0
- package/dist/modules/admin-users/components/create.js +268 -0
- package/dist/modules/admin-users/components/create.module.js +10 -0
- package/dist/modules/admin-users/components/create_module.css +45 -0
- package/dist/modules/admin-users/components/roles.d.ts +11 -0
- package/dist/modules/admin-users/components/roles.js +148 -0
- package/dist/modules/admin-users/components/roles.module.js +18 -0
- package/dist/modules/admin-users/components/roles_module.css +75 -0
- package/dist/modules/admin-users/components/set-password.d.ts +8 -0
- package/dist/modules/admin-users/components/set-password.js +170 -0
- package/dist/modules/admin-users/components/set-password.module.js +9 -0
- package/dist/modules/admin-users/components/set-password_module.css +31 -0
- package/dist/modules/admin-users/components/update.d.ts +8 -0
- package/dist/modules/admin-users/components/update.js +254 -0
- package/dist/modules/admin-users/components/update.module.js +9 -0
- package/dist/modules/admin-users/components/update_module.css +34 -0
- package/dist/modules/admin-users/dto.js +3 -18
- package/dist/modules/admin-users/errors.js +17 -43
- package/dist/modules/admin-users/index.js +7 -27
- package/dist/modules/admin-users/repository.js +1 -8
- package/dist/modules/admin-users/schemas.js +44 -75
- package/dist/modules/admin-users/seed-super-admin.js +9 -34
- package/dist/modules/admin-users/service.js +76 -91
- package/dist/modules/auth/components/sign-in-form.d.ts +12 -0
- package/dist/modules/auth/components/sign-in-form.js +115 -0
- package/dist/modules/auth/components/sign-in-form.module.js +12 -0
- package/dist/modules/auth/components/sign-in-form_module.css +41 -0
- package/dist/modules/auth/index.js +3 -24
- package/dist/modules/auth/jwt-session-provider.js +179 -149
- package/dist/modules/auth/password.js +11 -53
- package/dist/modules/auth/phc.js +21 -54
- package/dist/modules/auth/refresh-tokens-repository.js +1 -8
- package/dist/modules/auth/resolve-actor.js +6 -28
- package/dist/services/admin-services-context.d.ts +16 -0
- package/dist/services/admin-services-context.js +13 -0
- package/dist/services/admin-services-types.d.ts +129 -0
- package/dist/services/admin-services-types.js +1 -0
- package/dist/store.js +1 -8
- package/dist/vendor/noble-argon2/_blake.js +277 -45
- package/dist/vendor/noble-argon2/_md.js +81 -136
- package/dist/vendor/noble-argon2/_u64.js +65 -67
- package/dist/vendor/noble-argon2/argon2.js +181 -342
- package/dist/vendor/noble-argon2/blake2.js +252 -327
- package/dist/vendor/noble-argon2/utils.js +110 -490
- package/dist/vendor/noble-argon2/utils.js.LICENSE.txt +1 -0
- package/package.json +89 -10
- package/src/abilities.ts +32 -0
- package/src/declarations.d.ts +4 -0
- package/src/index.ts +39 -0
- package/src/lib/assert-admin-actor.ts +90 -0
- package/src/lib/create-command.ts +109 -0
- package/src/modules/admin-account/commands.ts +76 -0
- package/src/modules/admin-account/components/change-password.module.css +40 -0
- package/src/modules/admin-account/components/change-password.tsx +232 -0
- package/src/modules/admin-account/components/container.module.css +158 -0
- package/src/modules/admin-account/components/container.tsx +229 -0
- package/src/modules/admin-account/components/update.module.css +40 -0
- package/src/modules/admin-account/components/update.tsx +263 -0
- package/src/modules/admin-account/errors.ts +75 -0
- package/src/modules/admin-account/index.ts +60 -0
- package/src/modules/admin-account/schemas.ts +84 -0
- package/src/modules/admin-account/service.ts +92 -0
- package/src/modules/admin-permissions/abilities.ts +46 -0
- package/src/modules/admin-permissions/commands.ts +103 -0
- package/src/modules/admin-permissions/components/inspector.module.css +326 -0
- package/src/modules/admin-permissions/components/inspector.tsx +298 -0
- package/src/modules/admin-permissions/dto.ts +28 -0
- package/src/modules/admin-permissions/errors.ts +57 -0
- package/src/modules/admin-permissions/index.ts +72 -0
- package/src/modules/admin-permissions/repository.ts +49 -0
- package/src/modules/admin-permissions/schemas.ts +128 -0
- package/src/modules/admin-permissions/service.ts +137 -0
- package/src/modules/admin-roles/abilities.ts +62 -0
- package/src/modules/admin-roles/commands.ts +161 -0
- package/src/modules/admin-roles/components/create.module.css +40 -0
- package/src/modules/admin-roles/components/create.tsx +218 -0
- package/src/modules/admin-roles/components/permissions.module.css +279 -0
- package/src/modules/admin-roles/components/permissions.tsx +396 -0
- package/src/modules/admin-roles/components/update.module.css +40 -0
- package/src/modules/admin-roles/components/update.tsx +218 -0
- package/src/modules/admin-roles/dto.ts +30 -0
- package/src/modules/admin-roles/errors.ts +76 -0
- package/src/modules/admin-roles/index.ts +81 -0
- package/src/modules/admin-roles/repository.ts +96 -0
- package/src/modules/admin-roles/schemas.ts +139 -0
- package/src/modules/admin-roles/service.ts +136 -0
- package/src/modules/admin-users/abilities.ts +76 -0
- package/src/modules/admin-users/commands.ts +157 -0
- package/src/modules/admin-users/components/create.module.css +63 -0
- package/src/modules/admin-users/components/create.tsx +323 -0
- package/src/modules/admin-users/components/roles.module.css +119 -0
- package/src/modules/admin-users/components/roles.tsx +172 -0
- package/src/modules/admin-users/components/set-password.module.css +46 -0
- package/src/modules/admin-users/components/set-password.tsx +199 -0
- package/src/modules/admin-users/components/update.module.css +49 -0
- package/src/modules/admin-users/components/update.tsx +328 -0
- package/src/modules/admin-users/dto.ts +39 -0
- package/src/modules/admin-users/errors.ts +84 -0
- package/src/modules/admin-users/index.ts +91 -0
- package/src/modules/admin-users/repository.ts +161 -0
- package/src/modules/admin-users/schemas.ts +168 -0
- package/src/modules/admin-users/seed-super-admin.ts +102 -0
- package/src/modules/admin-users/service.ts +166 -0
- package/src/modules/auth/components/sign-in-form.module.css +62 -0
- package/src/modules/auth/components/sign-in-form.tsx +132 -0
- package/src/modules/auth/index.ts +31 -0
- package/src/modules/auth/jwt-session-provider.ts +301 -0
- package/src/modules/auth/password.ts +94 -0
- package/src/modules/auth/phc.ts +121 -0
- package/src/modules/auth/refresh-tokens-repository.ts +74 -0
- package/src/modules/auth/resolve-actor.ts +42 -0
- package/src/services/admin-services-context.tsx +52 -0
- package/src/services/admin-services-types.ts +177 -0
- package/src/store.ts +32 -0
- package/src/vendor/noble-argon2/LICENSE +21 -0
- package/src/vendor/noble-argon2/README.md +87 -0
- package/src/vendor/noble-argon2/_blake.ts +58 -0
- package/src/vendor/noble-argon2/_md.ts +223 -0
- package/src/vendor/noble-argon2/_u64.ts +118 -0
- package/src/vendor/noble-argon2/argon2.ts +668 -0
- package/src/vendor/noble-argon2/blake2.ts +583 -0
- package/src/vendor/noble-argon2/utils.ts +849 -0
|
@@ -1,35 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
import { AdminAuth } from '@byline/auth';
|
|
9
|
-
/**
|
|
10
|
-
* Build an `AdminAuth` from a user id by reading the admin-users row and
|
|
11
|
-
* collecting the distinct abilities granted through every role the user
|
|
12
|
-
* holds.
|
|
13
|
-
*
|
|
14
|
-
* Returns `null` when the user does not exist or is not enabled — callers
|
|
15
|
-
* interpret a null result as "no actor, sign-in refused". The enablement
|
|
16
|
-
* check lives here (rather than in the session provider) so that any code
|
|
17
|
-
* path resolving an actor from a stored user id — sign-in, token refresh,
|
|
18
|
-
* seeded super-admin context — applies the same gate.
|
|
19
|
-
*
|
|
20
|
-
* Consumes the admin-users and admin-permissions repositories through the
|
|
21
|
-
* `AdminStore` bundle; adapter-agnostic.
|
|
22
|
-
*/
|
|
23
|
-
export async function resolveActor(store, adminUserId) {
|
|
1
|
+
import { AdminAuth } from "@byline/auth";
|
|
2
|
+
async function resolveActor(store, adminUserId) {
|
|
24
3
|
const user = await store.adminUsers.getById(adminUserId);
|
|
25
|
-
if (!user)
|
|
26
|
-
|
|
27
|
-
if (!user.is_enabled)
|
|
28
|
-
return null;
|
|
4
|
+
if (!user) return null;
|
|
5
|
+
if (!user.is_enabled) return null;
|
|
29
6
|
const abilities = await store.adminPermissions.listAbilitiesForUser(adminUserId);
|
|
30
7
|
return new AdminAuth({
|
|
31
8
|
id: user.id,
|
|
32
9
|
abilities,
|
|
33
|
-
isSuperAdmin: user.is_super_admin
|
|
10
|
+
isSuperAdmin: user.is_super_admin
|
|
34
11
|
});
|
|
35
12
|
}
|
|
13
|
+
export { resolveActor };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
import { type ReactNode } from 'react';
|
|
9
|
+
import type { BylineAdminServices } from './admin-services-types.js';
|
|
10
|
+
export type { AdminServiceCall, BylineAdminServices, ChangeAccountPasswordInput, CreateAdminRoleInput, CreateAdminUserInput, SetAdminUserPasswordInput, SetRoleAbilitiesInput, SetUserRolesInput, SignInInput, SignInResult, UpdateAccountInput, UpdateAdminRoleInput, UpdateAdminUserInput, WhoHasAbilityInput, } from './admin-services-types.js';
|
|
11
|
+
interface BylineAdminServicesProviderProps {
|
|
12
|
+
services: BylineAdminServices;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}
|
|
15
|
+
export declare const BylineAdminServicesProvider: ({ services, children, }: BylineAdminServicesProviderProps) => import("react").JSX.Element;
|
|
16
|
+
export declare const useBylineAdminServices: () => BylineAdminServices;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
const AdminServicesContext = /*#__PURE__*/ createContext(null);
|
|
4
|
+
const BylineAdminServicesProvider = ({ services, children })=>/*#__PURE__*/ jsx(AdminServicesContext.Provider, {
|
|
5
|
+
value: services,
|
|
6
|
+
children: children
|
|
7
|
+
});
|
|
8
|
+
const useBylineAdminServices = ()=>{
|
|
9
|
+
const ctx = useContext(AdminServicesContext);
|
|
10
|
+
if (!ctx) throw new Error('@byline/admin: BylineAdminServicesProvider missing. Wrap your admin tree with <BylineAdminServicesProvider services={…} />.');
|
|
11
|
+
return ctx;
|
|
12
|
+
};
|
|
13
|
+
export { BylineAdminServicesProvider, useBylineAdminServices };
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) Infonomic Company Limited
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Framework-neutral function contracts that admin UI components in
|
|
10
|
+
* `@byline/ui` need from the host application. The host wires concrete
|
|
11
|
+
* implementations via `BylineAdminServicesProvider` — typically thin
|
|
12
|
+
* adapters around TanStack Start server functions, Next.js server
|
|
13
|
+
* actions, or any other RPC-style transport.
|
|
14
|
+
*
|
|
15
|
+
* The call shape `(args: { data: TInput }) => Promise<TOutput>` mirrors
|
|
16
|
+
* TanStack Start's `createServerFn().handler()` calling convention so a
|
|
17
|
+
* webapp host can pass its server fns through as-is. Other transports
|
|
18
|
+
* just need a tiny adapter.
|
|
19
|
+
*
|
|
20
|
+
* Scope: Phase 2.1 covers the framework-neutral admin UI components
|
|
21
|
+
* only — the 15 forms, modals, and inner widgets that don't touch
|
|
22
|
+
* TanStack Router. Page containers (list/edit/delete pages) keep using
|
|
23
|
+
* server fns directly today and move into `@byline/host-tanstack-start`
|
|
24
|
+
* in Phase 3 along with the route factories.
|
|
25
|
+
*/
|
|
26
|
+
import type { AccountResponse, ChangeAccountPasswordRequest, UpdateAccountRequest } from '../modules/admin-account/index.js';
|
|
27
|
+
import type { SetRoleAbilitiesResponse, WhoHasAbilityResponse } from '../modules/admin-permissions/index.js';
|
|
28
|
+
import type { AdminRoleResponse, UserRolesResponse } from '../modules/admin-roles/index.js';
|
|
29
|
+
import type { AdminUserResponse } from '../modules/admin-users/index.js';
|
|
30
|
+
/**
|
|
31
|
+
* The TanStack Start `createServerFn(...).handler(...)` calling shape:
|
|
32
|
+
* `fn({ data: input }) → Promise<output>`. Hosts using a different
|
|
33
|
+
* transport supply small adapters that match this shape.
|
|
34
|
+
*/
|
|
35
|
+
export type AdminServiceCall<TInput, TOutput> = (args: {
|
|
36
|
+
data: TInput;
|
|
37
|
+
}) => Promise<TOutput>;
|
|
38
|
+
export interface SignInInput {
|
|
39
|
+
email: string;
|
|
40
|
+
password: string;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The admin UI's sign-in form does not consume the `SignInResult`
|
|
44
|
+
* payload directly — on success it navigates via `window.location`. The
|
|
45
|
+
* shape is left as `unknown` here so each host's session provider can
|
|
46
|
+
* supply whatever envelope it produces without forcing a public type.
|
|
47
|
+
*/
|
|
48
|
+
export type SignInResult = unknown;
|
|
49
|
+
/** Same shape as `UpdateAccountRequest` from `@byline/admin/admin-account`. */
|
|
50
|
+
export type UpdateAccountInput = UpdateAccountRequest;
|
|
51
|
+
/** Same shape as `ChangeAccountPasswordRequest` from `@byline/admin/admin-account`. */
|
|
52
|
+
export type ChangeAccountPasswordInput = ChangeAccountPasswordRequest;
|
|
53
|
+
export interface CreateAdminUserInput {
|
|
54
|
+
email: string;
|
|
55
|
+
password: string;
|
|
56
|
+
given_name?: string | null;
|
|
57
|
+
family_name?: string | null;
|
|
58
|
+
username?: string | null;
|
|
59
|
+
is_super_admin: boolean;
|
|
60
|
+
is_enabled: boolean;
|
|
61
|
+
is_email_verified: boolean;
|
|
62
|
+
}
|
|
63
|
+
export interface UpdateAdminUserInput {
|
|
64
|
+
id: string;
|
|
65
|
+
vid: number;
|
|
66
|
+
patch: {
|
|
67
|
+
email?: string;
|
|
68
|
+
given_name?: string | null;
|
|
69
|
+
family_name?: string | null;
|
|
70
|
+
username?: string | null;
|
|
71
|
+
is_super_admin?: boolean;
|
|
72
|
+
is_enabled?: boolean;
|
|
73
|
+
is_email_verified?: boolean;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export interface SetAdminUserPasswordInput {
|
|
77
|
+
id: string;
|
|
78
|
+
vid: number;
|
|
79
|
+
password: string;
|
|
80
|
+
}
|
|
81
|
+
export interface SetUserRolesInput {
|
|
82
|
+
userId: string;
|
|
83
|
+
roleIds: string[];
|
|
84
|
+
}
|
|
85
|
+
export interface CreateAdminRoleInput {
|
|
86
|
+
name: string;
|
|
87
|
+
machine_name: string;
|
|
88
|
+
description: string | null;
|
|
89
|
+
}
|
|
90
|
+
export interface UpdateAdminRoleInput {
|
|
91
|
+
id: string;
|
|
92
|
+
vid: number;
|
|
93
|
+
patch: {
|
|
94
|
+
name?: string;
|
|
95
|
+
description?: string | null;
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
export interface SetRoleAbilitiesInput {
|
|
99
|
+
id: string;
|
|
100
|
+
abilities: string[];
|
|
101
|
+
}
|
|
102
|
+
export interface WhoHasAbilityInput {
|
|
103
|
+
ability: string;
|
|
104
|
+
}
|
|
105
|
+
export interface BylineAdminServices {
|
|
106
|
+
adminSignIn: AdminServiceCall<SignInInput, SignInResult>;
|
|
107
|
+
updateAccount: AdminServiceCall<UpdateAccountInput, AccountResponse>;
|
|
108
|
+
changeAccountPassword: AdminServiceCall<ChangeAccountPasswordInput, AccountResponse>;
|
|
109
|
+
createAdminUser: AdminServiceCall<CreateAdminUserInput, AdminUserResponse>;
|
|
110
|
+
updateAdminUser: AdminServiceCall<UpdateAdminUserInput, AdminUserResponse>;
|
|
111
|
+
setAdminUserPassword: AdminServiceCall<SetAdminUserPasswordInput, AdminUserResponse>;
|
|
112
|
+
setUserRoles: AdminServiceCall<SetUserRolesInput, UserRolesResponse>;
|
|
113
|
+
createAdminRole: AdminServiceCall<CreateAdminRoleInput, AdminRoleResponse>;
|
|
114
|
+
updateAdminRole: AdminServiceCall<UpdateAdminRoleInput, AdminRoleResponse>;
|
|
115
|
+
setRoleAbilities: AdminServiceCall<SetRoleAbilitiesInput, SetRoleAbilitiesResponse>;
|
|
116
|
+
whoHasAbility: AdminServiceCall<WhoHasAbilityInput, WhoHasAbilityResponse>;
|
|
117
|
+
/**
|
|
118
|
+
* Diff helper. Loads a specific historical version of a document so
|
|
119
|
+
* the diff modal can compare it against the current version. Returns
|
|
120
|
+
* the same shape as the regular document loader — the diff modal
|
|
121
|
+
* consumes only `doc.fields` (or strips known meta keys when an
|
|
122
|
+
* older flat-shape doc is encountered).
|
|
123
|
+
*
|
|
124
|
+
* Positional-args shape rather than `{ data }` because this helper
|
|
125
|
+
* predates the contract and is consumed only by `DiffModal`. Hosts
|
|
126
|
+
* adapt their server fn into this call signature.
|
|
127
|
+
*/
|
|
128
|
+
getCollectionDocumentVersion: (collection: string, documentId: string, versionId: string, locale: string | undefined) => Promise<Record<string, unknown>>;
|
|
129
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/dist/store.js
CHANGED
|
@@ -1,8 +1 @@
|
|
|
1
|
-
|
|
2
|
-
* This Source Code is subject to the terms of the Mozilla Public
|
|
3
|
-
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
4
|
-
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) Infonomic Company Limited
|
|
7
|
-
*/
|
|
8
|
-
export {};
|
|
1
|
+
export { };
|
|
@@ -1,52 +1,284 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
1
|
+
import { rotr } from "./utils.js";
|
|
2
|
+
const BSIGMA = /* @__PURE__ */ Uint8Array.from([
|
|
3
|
+
0,
|
|
4
|
+
1,
|
|
5
|
+
2,
|
|
6
|
+
3,
|
|
7
|
+
4,
|
|
8
|
+
5,
|
|
9
|
+
6,
|
|
10
|
+
7,
|
|
11
|
+
8,
|
|
12
|
+
9,
|
|
13
|
+
10,
|
|
14
|
+
11,
|
|
15
|
+
12,
|
|
16
|
+
13,
|
|
17
|
+
14,
|
|
18
|
+
15,
|
|
19
|
+
14,
|
|
20
|
+
10,
|
|
21
|
+
4,
|
|
22
|
+
8,
|
|
23
|
+
9,
|
|
24
|
+
15,
|
|
25
|
+
13,
|
|
26
|
+
6,
|
|
27
|
+
1,
|
|
28
|
+
12,
|
|
29
|
+
0,
|
|
30
|
+
2,
|
|
31
|
+
11,
|
|
32
|
+
7,
|
|
33
|
+
5,
|
|
34
|
+
3,
|
|
35
|
+
11,
|
|
36
|
+
8,
|
|
37
|
+
12,
|
|
38
|
+
0,
|
|
39
|
+
5,
|
|
40
|
+
2,
|
|
41
|
+
15,
|
|
42
|
+
13,
|
|
43
|
+
10,
|
|
44
|
+
14,
|
|
45
|
+
3,
|
|
46
|
+
6,
|
|
47
|
+
7,
|
|
48
|
+
1,
|
|
49
|
+
9,
|
|
50
|
+
4,
|
|
51
|
+
7,
|
|
52
|
+
9,
|
|
53
|
+
3,
|
|
54
|
+
1,
|
|
55
|
+
13,
|
|
56
|
+
12,
|
|
57
|
+
11,
|
|
58
|
+
14,
|
|
59
|
+
2,
|
|
60
|
+
6,
|
|
61
|
+
5,
|
|
62
|
+
10,
|
|
63
|
+
4,
|
|
64
|
+
0,
|
|
65
|
+
15,
|
|
66
|
+
8,
|
|
67
|
+
9,
|
|
68
|
+
0,
|
|
69
|
+
5,
|
|
70
|
+
7,
|
|
71
|
+
2,
|
|
72
|
+
4,
|
|
73
|
+
10,
|
|
74
|
+
15,
|
|
75
|
+
14,
|
|
76
|
+
1,
|
|
77
|
+
11,
|
|
78
|
+
12,
|
|
79
|
+
6,
|
|
80
|
+
8,
|
|
81
|
+
3,
|
|
82
|
+
13,
|
|
83
|
+
2,
|
|
84
|
+
12,
|
|
85
|
+
6,
|
|
86
|
+
10,
|
|
87
|
+
0,
|
|
88
|
+
11,
|
|
89
|
+
8,
|
|
90
|
+
3,
|
|
91
|
+
4,
|
|
92
|
+
13,
|
|
93
|
+
7,
|
|
94
|
+
5,
|
|
95
|
+
15,
|
|
96
|
+
14,
|
|
97
|
+
1,
|
|
98
|
+
9,
|
|
99
|
+
12,
|
|
100
|
+
5,
|
|
101
|
+
1,
|
|
102
|
+
15,
|
|
103
|
+
14,
|
|
104
|
+
13,
|
|
105
|
+
4,
|
|
106
|
+
10,
|
|
107
|
+
0,
|
|
108
|
+
7,
|
|
109
|
+
6,
|
|
110
|
+
3,
|
|
111
|
+
9,
|
|
112
|
+
2,
|
|
113
|
+
8,
|
|
114
|
+
11,
|
|
115
|
+
13,
|
|
116
|
+
11,
|
|
117
|
+
7,
|
|
118
|
+
14,
|
|
119
|
+
12,
|
|
120
|
+
1,
|
|
121
|
+
3,
|
|
122
|
+
9,
|
|
123
|
+
5,
|
|
124
|
+
0,
|
|
125
|
+
15,
|
|
126
|
+
4,
|
|
127
|
+
8,
|
|
128
|
+
6,
|
|
129
|
+
2,
|
|
130
|
+
10,
|
|
131
|
+
6,
|
|
132
|
+
15,
|
|
133
|
+
14,
|
|
134
|
+
9,
|
|
135
|
+
11,
|
|
136
|
+
3,
|
|
137
|
+
0,
|
|
138
|
+
8,
|
|
139
|
+
12,
|
|
140
|
+
2,
|
|
141
|
+
13,
|
|
142
|
+
7,
|
|
143
|
+
1,
|
|
144
|
+
4,
|
|
145
|
+
10,
|
|
146
|
+
5,
|
|
147
|
+
10,
|
|
148
|
+
2,
|
|
149
|
+
8,
|
|
150
|
+
4,
|
|
151
|
+
7,
|
|
152
|
+
6,
|
|
153
|
+
1,
|
|
154
|
+
5,
|
|
155
|
+
15,
|
|
156
|
+
11,
|
|
157
|
+
9,
|
|
158
|
+
14,
|
|
159
|
+
3,
|
|
160
|
+
12,
|
|
161
|
+
13,
|
|
162
|
+
0,
|
|
163
|
+
0,
|
|
164
|
+
1,
|
|
165
|
+
2,
|
|
166
|
+
3,
|
|
167
|
+
4,
|
|
168
|
+
5,
|
|
169
|
+
6,
|
|
170
|
+
7,
|
|
171
|
+
8,
|
|
172
|
+
9,
|
|
173
|
+
10,
|
|
174
|
+
11,
|
|
175
|
+
12,
|
|
176
|
+
13,
|
|
177
|
+
14,
|
|
178
|
+
15,
|
|
179
|
+
14,
|
|
180
|
+
10,
|
|
181
|
+
4,
|
|
182
|
+
8,
|
|
183
|
+
9,
|
|
184
|
+
15,
|
|
185
|
+
13,
|
|
186
|
+
6,
|
|
187
|
+
1,
|
|
188
|
+
12,
|
|
189
|
+
0,
|
|
190
|
+
2,
|
|
191
|
+
11,
|
|
192
|
+
7,
|
|
193
|
+
5,
|
|
194
|
+
3,
|
|
195
|
+
11,
|
|
196
|
+
8,
|
|
197
|
+
12,
|
|
198
|
+
0,
|
|
199
|
+
5,
|
|
200
|
+
2,
|
|
201
|
+
15,
|
|
202
|
+
13,
|
|
203
|
+
10,
|
|
204
|
+
14,
|
|
205
|
+
3,
|
|
206
|
+
6,
|
|
207
|
+
7,
|
|
208
|
+
1,
|
|
209
|
+
9,
|
|
210
|
+
4,
|
|
211
|
+
7,
|
|
212
|
+
9,
|
|
213
|
+
3,
|
|
214
|
+
1,
|
|
215
|
+
13,
|
|
216
|
+
12,
|
|
217
|
+
11,
|
|
218
|
+
14,
|
|
219
|
+
2,
|
|
220
|
+
6,
|
|
221
|
+
5,
|
|
222
|
+
10,
|
|
223
|
+
4,
|
|
224
|
+
0,
|
|
225
|
+
15,
|
|
226
|
+
8,
|
|
227
|
+
9,
|
|
228
|
+
0,
|
|
229
|
+
5,
|
|
230
|
+
7,
|
|
231
|
+
2,
|
|
232
|
+
4,
|
|
233
|
+
10,
|
|
234
|
+
15,
|
|
235
|
+
14,
|
|
236
|
+
1,
|
|
237
|
+
11,
|
|
238
|
+
12,
|
|
239
|
+
6,
|
|
240
|
+
8,
|
|
241
|
+
3,
|
|
242
|
+
13,
|
|
243
|
+
2,
|
|
244
|
+
12,
|
|
245
|
+
6,
|
|
246
|
+
10,
|
|
247
|
+
0,
|
|
248
|
+
11,
|
|
249
|
+
8,
|
|
250
|
+
3,
|
|
251
|
+
4,
|
|
252
|
+
13,
|
|
253
|
+
7,
|
|
254
|
+
5,
|
|
255
|
+
15,
|
|
256
|
+
14,
|
|
257
|
+
1,
|
|
258
|
+
9
|
|
32
259
|
]);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
// `m[sigma[r][2i]] ^ u[sigma[r][2i+1]]` addend in the 32-bit path.
|
|
36
|
-
export function G1s(a, b, c, d, x) {
|
|
37
|
-
a = (a + b + x) | 0;
|
|
260
|
+
function G1s(a, b, c, d, x) {
|
|
261
|
+
a = a + b + x | 0;
|
|
38
262
|
d = rotr(d ^ a, 16);
|
|
39
|
-
c =
|
|
263
|
+
c = c + d | 0;
|
|
40
264
|
b = rotr(b ^ c, 12);
|
|
41
|
-
return {
|
|
265
|
+
return {
|
|
266
|
+
a,
|
|
267
|
+
b,
|
|
268
|
+
c,
|
|
269
|
+
d
|
|
270
|
+
};
|
|
42
271
|
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
// `m[sigma[r][2i + 1]] ^ u[sigma[r][2i]]` addend in the 32-bit path.
|
|
46
|
-
export function G2s(a, b, c, d, x) {
|
|
47
|
-
a = (a + b + x) | 0;
|
|
272
|
+
function G2s(a, b, c, d, x) {
|
|
273
|
+
a = a + b + x | 0;
|
|
48
274
|
d = rotr(d ^ a, 8);
|
|
49
|
-
c =
|
|
275
|
+
c = c + d | 0;
|
|
50
276
|
b = rotr(b ^ c, 7);
|
|
51
|
-
return {
|
|
277
|
+
return {
|
|
278
|
+
a,
|
|
279
|
+
b,
|
|
280
|
+
c,
|
|
281
|
+
d
|
|
282
|
+
};
|
|
52
283
|
}
|
|
284
|
+
export { BSIGMA, G1s, G2s };
|