@mastra/auth-okta 0.2.6 → 0.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/_types/{@internal_auth/dist/_types/@internal_core → @internal_auth@0.0.37/dist/_types/@internal_core@0.1.4}/dist/base/index.d.ts +1 -1
- package/dist/_types/{@internal_auth/dist/_types/@internal_core/dist/index-TNVgGNjs.d.ts → @internal_auth@0.0.37/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts} +3 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/permissions.generated.d.ts +12 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/index.d.ts +15 -0
- package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/provider/index.d.ts +74 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/types/index.d.ts +7 -0
- package/dist/auth-provider.d.ts +5 -2
- package/dist/auth-provider.d.ts.map +1 -1
- package/dist/index.cjs +52 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +52 -1
- package/dist/index.js.map +1 -1
- package/dist/rbac-provider.d.ts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +7 -7
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/capabilities.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/defaults/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/defaults/rbac/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/defaults/rbac/static.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/defaults/roles.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/fga-check.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/acl.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/fga.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/rbac.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/interfaces/user.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/ee/license.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/session/cookie.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/session/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/dist/session/memory.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.37}/package.json +0 -0
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { LRUCache } from "lru-cache";
|
|
2
2
|
import { createRemoteJWKSet, jwtVerify } from "jose";
|
|
3
|
-
// ../../packages/_internals/auth/dist/ee-
|
|
3
|
+
// ../../packages/_internals/auth/dist/ee-iTj2bRDt.js
|
|
4
4
|
/**
|
|
5
5
|
* FGA enforcement utility for checking fine-grained authorization.
|
|
6
6
|
*
|
|
@@ -599,6 +599,41 @@ var MastraBase = class {
|
|
|
599
599
|
}
|
|
600
600
|
};
|
|
601
601
|
// ../../packages/_internals/auth/dist/provider/index.js
|
|
602
|
+
function pickString(...values) {
|
|
603
|
+
for (const value of values) if (typeof value === "string" && value.trim()) return value;
|
|
604
|
+
}
|
|
605
|
+
/**
|
|
606
|
+
* Normalize an arbitrary provider-specific user object to the stable
|
|
607
|
+
* {@link MastraUser} shape surfaced to `DynamicArgument` callbacks.
|
|
608
|
+
*
|
|
609
|
+
* Picks `id` from `id`/`sub`/`userId` (numeric ids are stringified),
|
|
610
|
+
* `avatarUrl` from `avatarUrl`/`picture`, and passes `name`/`email`/`role`
|
|
611
|
+
* through when they are non-empty strings.
|
|
612
|
+
*
|
|
613
|
+
* @throws when no id can be derived — override `toMastraUser()` on the auth
|
|
614
|
+
* provider for user shapes this default cannot handle.
|
|
615
|
+
*/
|
|
616
|
+
function normalizeMastraUser(user) {
|
|
617
|
+
if (typeof user === "string" && user.trim()) return { id: user };
|
|
618
|
+
if (user === null || typeof user !== "object") throw new Error(`Unable to normalize authenticated user of type "${typeof user}" to a MastraUser. Override toMastraUser() on your auth provider to supply a normalized user.`);
|
|
619
|
+
const record = user;
|
|
620
|
+
const rawId = [
|
|
621
|
+
record.id,
|
|
622
|
+
record.sub,
|
|
623
|
+
record.userId
|
|
624
|
+
].find((value) => typeof value === "string" && value.trim() || typeof value === "number");
|
|
625
|
+
if (rawId === void 0) throw new Error("Unable to derive a user id (looked at `id`, `sub`, and `userId`) while normalizing the authenticated user. Override toMastraUser() on your auth provider to supply a normalized user.");
|
|
626
|
+
const normalized = { id: typeof rawId === "number" ? String(rawId) : rawId };
|
|
627
|
+
const name = pickString(record.name);
|
|
628
|
+
const email = pickString(record.email);
|
|
629
|
+
const avatarUrl = pickString(record.avatarUrl, record.picture);
|
|
630
|
+
const role = pickString(record.role);
|
|
631
|
+
if (name) normalized.name = name;
|
|
632
|
+
if (email) normalized.email = email;
|
|
633
|
+
if (avatarUrl) normalized.avatarUrl = avatarUrl;
|
|
634
|
+
if (role) normalized.role = role;
|
|
635
|
+
return normalized;
|
|
636
|
+
}
|
|
602
637
|
var MastraAuthProvider = class extends MastraBase {
|
|
603
638
|
protected;
|
|
604
639
|
public;
|
|
@@ -612,6 +647,18 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
612
647
|
this.public = options?.public;
|
|
613
648
|
if (options?.mapUserToResourceId) this.mapUserToResourceId = options.mapUserToResourceId;
|
|
614
649
|
}
|
|
650
|
+
/**
|
|
651
|
+
* Normalize the authenticated provider-specific user to the stable
|
|
652
|
+
* {@link MastraUser} shape surfaced to `DynamicArgument` callbacks as the
|
|
653
|
+
* optional `user` argument.
|
|
654
|
+
*
|
|
655
|
+
* The default implementation handles common user shapes (see
|
|
656
|
+
* {@link normalizeMastraUser}); override it when your provider's user type
|
|
657
|
+
* needs custom mapping.
|
|
658
|
+
*/
|
|
659
|
+
toMastraUser(user) {
|
|
660
|
+
return normalizeMastraUser(user);
|
|
661
|
+
}
|
|
615
662
|
registerOptions(opts) {
|
|
616
663
|
if (opts?.authorizeUser) this.authorizeUser = opts.authorizeUser.bind(this);
|
|
617
664
|
if (opts?.mapUserToResourceId) this.mapUserToResourceId = opts.mapUserToResourceId;
|
|
@@ -805,6 +852,10 @@ var MastraAuthOkta = class extends MastraAuthProvider {
|
|
|
805
852
|
return null;
|
|
806
853
|
}
|
|
807
854
|
}
|
|
855
|
+
/** The Okta authorization server is the authorization server for MCP clients. */
|
|
856
|
+
getOAuthMetadata() {
|
|
857
|
+
return { authorizationServers: [this.issuer] };
|
|
858
|
+
}
|
|
808
859
|
/**
|
|
809
860
|
* Authorize a user.
|
|
810
861
|
*/
|