@mastra/auth-workos 1.6.8-alpha.0 → 1.6.9-alpha.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.36/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.36/dist/_types/@internal_core@0.1.4/dist/index-Diz1p9N7.d.ts} +3 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/permissions.generated.d.ts +12 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/index.d.ts +15 -0
- package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/provider/index.d.ts +74 -2
- package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/types/index.d.ts +7 -0
- package/dist/auth-provider.d.ts +3 -3
- package/dist/fga-provider.d.ts +1 -1
- package/dist/index.cjs +48 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +48 -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 +8 -8
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/capabilities.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/defaults/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/defaults/rbac/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/defaults/rbac/static.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/defaults/roles.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/fga-check.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/acl.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/fga.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/rbac.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/interfaces/user.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/ee/license.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/session/cookie.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/session/index.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/dist/session/memory.d.ts +0 -0
- /package/dist/_types/{@internal_auth → @internal_auth@0.0.36}/package.json +0 -0
package/dist/index.js
CHANGED
|
@@ -270,6 +270,41 @@ var MastraBase = class {
|
|
|
270
270
|
}
|
|
271
271
|
};
|
|
272
272
|
// ../../packages/_internals/auth/dist/provider/index.js
|
|
273
|
+
function pickString(...values) {
|
|
274
|
+
for (const value of values) if (typeof value === "string" && value.trim()) return value;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Normalize an arbitrary provider-specific user object to the stable
|
|
278
|
+
* {@link MastraUser} shape surfaced to `DynamicArgument` callbacks.
|
|
279
|
+
*
|
|
280
|
+
* Picks `id` from `id`/`sub`/`userId` (numeric ids are stringified),
|
|
281
|
+
* `avatarUrl` from `avatarUrl`/`picture`, and passes `name`/`email`/`role`
|
|
282
|
+
* through when they are non-empty strings.
|
|
283
|
+
*
|
|
284
|
+
* @throws when no id can be derived — override `toMastraUser()` on the auth
|
|
285
|
+
* provider for user shapes this default cannot handle.
|
|
286
|
+
*/
|
|
287
|
+
function normalizeMastraUser(user) {
|
|
288
|
+
if (typeof user === "string" && user.trim()) return { id: user };
|
|
289
|
+
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.`);
|
|
290
|
+
const record = user;
|
|
291
|
+
const rawId = [
|
|
292
|
+
record.id,
|
|
293
|
+
record.sub,
|
|
294
|
+
record.userId
|
|
295
|
+
].find((value) => typeof value === "string" && value.trim() || typeof value === "number");
|
|
296
|
+
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.");
|
|
297
|
+
const normalized = { id: typeof rawId === "number" ? String(rawId) : rawId };
|
|
298
|
+
const name = pickString(record.name);
|
|
299
|
+
const email = pickString(record.email);
|
|
300
|
+
const avatarUrl = pickString(record.avatarUrl, record.picture);
|
|
301
|
+
const role = pickString(record.role);
|
|
302
|
+
if (name) normalized.name = name;
|
|
303
|
+
if (email) normalized.email = email;
|
|
304
|
+
if (avatarUrl) normalized.avatarUrl = avatarUrl;
|
|
305
|
+
if (role) normalized.role = role;
|
|
306
|
+
return normalized;
|
|
307
|
+
}
|
|
273
308
|
var MastraAuthProvider = class extends MastraBase {
|
|
274
309
|
protected;
|
|
275
310
|
public;
|
|
@@ -283,6 +318,18 @@ var MastraAuthProvider = class extends MastraBase {
|
|
|
283
318
|
this.public = options?.public;
|
|
284
319
|
if (options?.mapUserToResourceId) this.mapUserToResourceId = options.mapUserToResourceId;
|
|
285
320
|
}
|
|
321
|
+
/**
|
|
322
|
+
* Normalize the authenticated provider-specific user to the stable
|
|
323
|
+
* {@link MastraUser} shape surfaced to `DynamicArgument` callbacks as the
|
|
324
|
+
* optional `user` argument.
|
|
325
|
+
*
|
|
326
|
+
* The default implementation handles common user shapes (see
|
|
327
|
+
* {@link normalizeMastraUser}); override it when your provider's user type
|
|
328
|
+
* needs custom mapping.
|
|
329
|
+
*/
|
|
330
|
+
toMastraUser(user) {
|
|
331
|
+
return normalizeMastraUser(user);
|
|
332
|
+
}
|
|
286
333
|
registerOptions(opts) {
|
|
287
334
|
if (opts?.authorizeUser) this.authorizeUser = opts.authorizeUser.bind(this);
|
|
288
335
|
if (opts?.mapUserToResourceId) this.mapUserToResourceId = opts.mapUserToResourceId;
|
|
@@ -934,7 +981,7 @@ var MastraAuthWorkos = class extends MastraAuthProvider {
|
|
|
934
981
|
return this.redirectUri;
|
|
935
982
|
}
|
|
936
983
|
};
|
|
937
|
-
// ../../packages/_internals/auth/dist/ee-
|
|
984
|
+
// ../../packages/_internals/auth/dist/ee-iTj2bRDt.js
|
|
938
985
|
/**
|
|
939
986
|
* FGA enforcement utility for checking fine-grained authorization.
|
|
940
987
|
*
|