autumn-js
Version:
Autumn JS Library
56 lines (54 loc) • 1.79 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
// src/better-auth/utils/resolveIdentityFromScope.ts
var resolveIdentityFromScope_exports = {};
__export(resolveIdentityFromScope_exports, {
resolveIdentityFromScope: () => resolveIdentityFromScope
});
module.exports = __toCommonJS(resolveIdentityFromScope_exports);
var resolveIdentityFromScope = ({
session,
organization,
customerScope
}) => {
if (!session?.user) return null;
const userIdentity = {
customerId: session.user.id,
customerData: {
name: session.user.name,
email: session.user.email
}
};
const orgIdentity = organization ? {
customerId: organization.id,
customerData: { name: organization.name }
} : null;
switch (customerScope) {
case "organization":
return orgIdentity;
case "user_and_organization":
return orgIdentity ?? userIdentity;
default:
return userIdentity;
}
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
resolveIdentityFromScope
});