@mastra/auth-workos 1.2.0 → 1.3.0

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/index.js CHANGED
@@ -722,6 +722,23 @@ var MastraRBACWorkos = class {
722
722
  const userPermissions = await this.getPermissions(user);
723
723
  return permissions.some((required) => userPermissions.some((p) => matchesPermission(p, required)));
724
724
  }
725
+ /**
726
+ * Get all available roles defined in the role mapping.
727
+ *
728
+ * Returns role IDs and names derived from the roleMapping keys,
729
+ * excluding the `_default` fallback entry.
730
+ */
731
+ async getAvailableRoles() {
732
+ return Object.keys(this.options.roleMapping).filter((key) => key !== "_default").map((key) => ({ id: key, name: key.charAt(0).toUpperCase() + key.slice(1) }));
733
+ }
734
+ /**
735
+ * Get resolved permissions for a specific role.
736
+ *
737
+ * Looks up the role in the roleMapping and returns its permissions.
738
+ */
739
+ async getPermissionsForRole(roleId) {
740
+ return resolvePermissionsFromMapping([roleId], this.options.roleMapping);
741
+ }
725
742
  /**
726
743
  * Clear the roles cache.
727
744
  *