How to use the @authx/authx.Role 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
}
  });

  const password = randomBytes(16).toString("hex");
  const credential = new PasswordCredential({
    id: v4(),
    enabled: true,
    authorityId: authority.id,
    authorityUserId: user.id,
    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")
  });