@plyaz/types 1.12.0 → 1.12.1
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/api/index.cjs +1 -1
- package/dist/api/index.cjs.map +1 -1
- package/dist/auth/enums.d.ts +4 -0
- package/dist/auth/index.cjs +6 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.js +6 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/types.d.ts +34 -0
- package/dist/index.cjs +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/auth/config/index.d.ts +0 -1
- package/dist/auth/config/types.d.ts +0 -67
package/dist/auth/index.d.ts
CHANGED
package/dist/auth/index.js
CHANGED
|
@@ -37,6 +37,11 @@ var AUTH_PROVIDER = {
|
|
|
37
37
|
/** Authentication via connected blockchain wallet. */
|
|
38
38
|
Wallet: "wallet"
|
|
39
39
|
};
|
|
40
|
+
var AUTH_PROVIDER_TYPE = /* @__PURE__ */ ((AUTH_PROVIDER_TYPE2) => {
|
|
41
|
+
AUTH_PROVIDER_TYPE2["ClerkSupabase"] = "CLERK_SUPABASE";
|
|
42
|
+
AUTH_PROVIDER_TYPE2["InternalDb"] = "INTERNAL_DB";
|
|
43
|
+
return AUTH_PROVIDER_TYPE2;
|
|
44
|
+
})(AUTH_PROVIDER_TYPE || {});
|
|
40
45
|
var loginCredentialsSchema = z.object({
|
|
41
46
|
// The user's email address. Must be a valid email format.
|
|
42
47
|
email: z.string().email("Invalid email format"),
|
|
@@ -44,6 +49,6 @@ var loginCredentialsSchema = z.object({
|
|
|
44
49
|
password: z.string()
|
|
45
50
|
});
|
|
46
51
|
|
|
47
|
-
export { AUTH_PROVIDER, USER_ROLE, USER_STATUS, loginCredentialsSchema };
|
|
52
|
+
export { AUTH_PROVIDER, AUTH_PROVIDER_TYPE, USER_ROLE, USER_STATUS, loginCredentialsSchema };
|
|
48
53
|
//# sourceMappingURL=index.js.map
|
|
49
54
|
//# sourceMappingURL=index.js.map
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/auth/enums.ts","../../src/auth/schemas.ts"],"names":[],"mappings":";;;;;AAYO,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,UAAA,EAAY;AACd;AAcO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,SAAA,EAAW,WAAA;AAAA;AAAA,EAGX,MAAA,EAAQ;AACV;AAcO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,MAAA,EAAQ;AACV;
|
|
1
|
+
{"version":3,"sources":["../../src/auth/enums.ts","../../src/auth/schemas.ts"],"names":["AUTH_PROVIDER_TYPE"],"mappings":";;;;;AAYO,IAAM,SAAA,GAAY;AAAA;AAAA,EAEvB,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,IAAA,EAAM,MAAA;AAAA;AAAA,EAGN,GAAA,EAAK,KAAA;AAAA;AAAA,EAGL,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,UAAA,EAAY;AACd;AAcO,IAAM,WAAA,GAAc;AAAA;AAAA,EAEzB,MAAA,EAAQ,QAAA;AAAA;AAAA,EAGR,QAAA,EAAU,UAAA;AAAA;AAAA,EAGV,OAAA,EAAS,SAAA;AAAA;AAAA,EAGT,SAAA,EAAW,WAAA;AAAA;AAAA,EAGX,MAAA,EAAQ;AACV;AAcO,IAAM,aAAA,GAAgB;AAAA;AAAA,EAE3B,KAAA,EAAO,OAAA;AAAA;AAAA,EAGP,MAAA,EAAQ;AACV;AAEO,IAAK,kBAAA,qBAAAA,mBAAAA,KAAL;AACL,EAAAA,oBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,EAAAA,oBAAA,YAAA,CAAA,GAAa,aAAA;AAFH,EAAA,OAAAA,mBAAAA;AAAA,CAAA,EAAA,kBAAA,IAAA,EAAA;ACvEL,IAAM,sBAAA,GAAyB,EAAE,MAAA,CAAO;AAAA;AAAA,EAE7C,KAAA,EAAO,CAAA,CAAE,MAAA,EAAO,CAAE,MAAM,sBAAsB,CAAA;AAAA;AAAA,EAG9C,QAAA,EAAU,EAAE,MAAA;AACd,CAAC","file":"index.js","sourcesContent":["/**\n * Enum representing the different roles a user can have within the system.\n * @description Roles are used to determine access levels, permissions, and user-specific experiences.\n *\n * @example\n * ```typescript\n * import { USER_ROLE } from '@plyaz/types';\n *\n * const userRole = USER_ROLE.Athlete; // 'athlete'\n * const isAdmin = userRole === USER_ROLE.Admin || userRole === USER_ROLE.SuperAdmin;\n * ```\n */\nexport const USER_ROLE = {\n /** A user who is an athlete and participates in sports activities. */\n Athlete: 'athlete',\n\n /** A user who scouts and discovers talent. */\n Scout: 'scout',\n\n /** A user who acts as an agent representing athletes or clubs. */\n Agent: 'agent',\n\n /** A user representing a sports club or organization. */\n Club: 'club',\n\n /** A fan or supporter of athletes or clubs. */\n Fan: 'fan',\n\n /** A system administrator with access to management tools. */\n Admin: 'admin',\n\n /** A super admin with the highest level of access and control. */\n SuperAdmin: 'super.admin',\n} as const;\n\n/**\n * Enum representing the current status of a user account.\n * @description Statuses are used to determine login availability, visibility, and user flow.\n *\n * @example\n * ```typescript\n * import { USER_STATUS } from '@plyaz/types';\n *\n * const isAccessible = status === USER_STATUS.Active;\n * const needsReview = status === USER_STATUS.Pending;\n * ```\n */\nexport const USER_STATUS = {\n /** Active user with full access. */\n Active: 'active',\n\n /** Inactive user, typically not currently using the platform. */\n Inactive: 'inactive',\n\n /** User account is awaiting approval or completion of setup. */\n Pending: 'pending',\n\n /** User has been temporarily suspended due to policy violations or manual review. */\n Suspended: 'suspended',\n\n /** User has been permanently banned from the platform. */\n Banned: 'banned',\n} as const;\n\n/**\n * Enum representing the supported authentication providers for user login.\n * @description Auth Providers allowed such as Email, Wallet, etc.\n *\n * @example\n * ```typescript\n * import { AUTH_PROVIDER } from '@plyaz/types';\n *\n * const provider = AUTH_PROVIDER.Wallet; // 'wallet'\n * const isWeb3Auth = provider === AUTH_PROVIDER.Wallet;\n * ```\n */\nexport const AUTH_PROVIDER = {\n /** Authentication via email and password. */\n Email: 'email',\n\n /** Authentication via connected blockchain wallet. */\n Wallet: 'wallet',\n} as const;\n\nexport enum AUTH_PROVIDER_TYPE {\n ClerkSupabase = 'CLERK_SUPABASE',\n InternalDb = 'INTERNAL_DB',\n}\n","import { z } from 'zod';\n\n/**\n * Zod schema for validating user login credentials.\n * @description Ensures the input object contains a valid email address and a password string.\n * @example\n * ```ts\n * LoginCredentialsSchema.parse({\n * email: \"user@example.com\",\n * password: \"\"\n * });\n * ```\n */\nexport const loginCredentialsSchema = z.object({\n // The user's email address. Must be a valid email format.\n email: z.string().email('Invalid email format'),\n\n // The user's password. No format constraints applied here.\n password: z.string(),\n});\n\n/**\n * Type inferred from {@link loginCredentialsSchema}.\n * @description Represents the shape of validated login credentials input.\n */\nexport type LoginCredentialsInput = z.infer<typeof loginCredentialsSchema>;\n"]}
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -28,3 +28,37 @@ export type UserContext = {
|
|
|
28
28
|
email: string;
|
|
29
29
|
createdAt: Date;
|
|
30
30
|
};
|
|
31
|
+
/**
|
|
32
|
+
* @fileoverview Defines the contract for all authentication service providers
|
|
33
|
+
* responsible for handling the synchronization between an external identity
|
|
34
|
+
* source (like Clerk, Auth0, etc.) and the internal database user structure.
|
|
35
|
+
*
|
|
36
|
+
* Any provider implementing this interface must handle user lookup, creation,
|
|
37
|
+
* and issuance of the necessary internal tokens (like the Supabase RLS JWT).
|
|
38
|
+
*/
|
|
39
|
+
export interface AuthServiceProvider {
|
|
40
|
+
/**
|
|
41
|
+
* Synchronizes an external user's identity with the internal application database.
|
|
42
|
+
*
|
|
43
|
+
* This is typically called immediately after a successful authentication with
|
|
44
|
+
* an external provider to ensure the user exists in the local database,
|
|
45
|
+
* update their metadata, and issue an internal authorization token (e.g., RLS JWT).
|
|
46
|
+
*
|
|
47
|
+
* @param externalId The unique identifier from the external authentication provider (e.g., Clerk's 'sub').
|
|
48
|
+
* @param email The user's primary email address from the external provider.
|
|
49
|
+
* @returns A Promise resolving to an object containing the internal UserContext and the provider-specific RLS JWT.
|
|
50
|
+
*/
|
|
51
|
+
syncUserFromExternalToken(externalId: string, email: string): Promise<{
|
|
52
|
+
user: UserContext;
|
|
53
|
+
supabaseRlsToken: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Retrieves a user's context from the internal database using their internal ID.
|
|
57
|
+
*
|
|
58
|
+
* This method is generally used by trusted backend services and must bypass RLS.
|
|
59
|
+
*
|
|
60
|
+
* @param userId The internal database UUID of the user.
|
|
61
|
+
* @returns A Promise resolving to the user's basic context (`UserContext`) or `null` if not found.
|
|
62
|
+
*/
|
|
63
|
+
getUserById(userId: string): Promise<UserContext | null>;
|
|
64
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -43,6 +43,11 @@ var AUTH_PROVIDER = {
|
|
|
43
43
|
/** Authentication via connected blockchain wallet. */
|
|
44
44
|
Wallet: "wallet"
|
|
45
45
|
};
|
|
46
|
+
var AUTH_PROVIDER_TYPE = /* @__PURE__ */ ((AUTH_PROVIDER_TYPE2) => {
|
|
47
|
+
AUTH_PROVIDER_TYPE2["ClerkSupabase"] = "CLERK_SUPABASE";
|
|
48
|
+
AUTH_PROVIDER_TYPE2["InternalDb"] = "INTERNAL_DB";
|
|
49
|
+
return AUTH_PROVIDER_TYPE2;
|
|
50
|
+
})(AUTH_PROVIDER_TYPE || {});
|
|
46
51
|
|
|
47
52
|
// node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
|
|
48
53
|
var external_exports = {};
|
|
@@ -4505,7 +4510,7 @@ var ALL_EVENTS = {
|
|
|
4505
4510
|
...CACHE_EVENTS
|
|
4506
4511
|
};
|
|
4507
4512
|
|
|
4508
|
-
// node_modules/.pnpm/@plyaz+config@1.6.
|
|
4513
|
+
// node_modules/.pnpm/@plyaz+config@1.6.4_next@15.4.7_react-dom@19.2.0_react@19.2.0_typescript@5.9.3_zod@3.25.76/node_modules/@plyaz/config/dist/index.mjs
|
|
4509
4514
|
globalThis.process.env.NODE_ENV === "development";
|
|
4510
4515
|
globalThis.process.env.NODE_ENV === "production";
|
|
4511
4516
|
globalThis.process.env.NODE_ENV === "test";
|
|
@@ -5690,6 +5695,7 @@ exports.ALERT_TYPES = ALERT_TYPES;
|
|
|
5690
5695
|
exports.ALL_EVENTS = ALL_EVENTS;
|
|
5691
5696
|
exports.API_ERROR_CODES = API_ERROR_CODES;
|
|
5692
5697
|
exports.AUTH_PROVIDER = AUTH_PROVIDER;
|
|
5698
|
+
exports.AUTH_PROVIDER_TYPE = AUTH_PROVIDER_TYPE;
|
|
5693
5699
|
exports.CACHE_DURATION_MS = CACHE_DURATION_MS;
|
|
5694
5700
|
exports.CACHE_EVENTS = CACHE_EVENTS;
|
|
5695
5701
|
exports.CHAIN_ID = CHAIN_ID;
|