How to use the @authx/authx.Authorization function in @authx/authx

To help you get started, we’ve selected a few @authx/authx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github the-control-group / authx / packages / tools / src / scripts / bootstrap.ts View on Github external
userId: user.id,
    details: {
      hash: await hash(password, authority.details.rounds)
    }
  });

  const role = new Role({
    id: v4(),
    enabled: true,
    name: "Super Administrator",
    description: "A super administrator has full access to all resources.",
    scopes: ["**:**:**"],
    userIds: [user.id]
  });

  const authorization = new Authorization({
    id: v4(),
    enabled: true,
    scopes: ["**:**:**"],
    userId: user.id,
    grantId: null,
    secret: randomBytes(16).toString("hex")
  });

  console.log(JSON.stringify({ id: user.id, password: password }));

  try {
    await tx.query("BEGIN DEFERRABLE");

    await bootstrap(tx, {
      user: {
        data: user,