-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
26 changed files
with
464 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,5 @@ | ||
import { AuthSignature } from './auth-sig'; | ||
import { EIP4361AuthProvider } from './providers'; | ||
|
||
export const EIP4361_AUTH_METHOD = 'EIP4361'; | ||
|
||
export interface AuthProvider { | ||
getOrCreateAuthSignature(): Promise<AuthSignature>; | ||
} | ||
|
||
export type AuthProviders = { | ||
[EIP4361_AUTH_METHOD]?: EIP4361AuthProvider; | ||
// Fallback to satisfy type checking | ||
[key: string]: AuthProvider | undefined; | ||
}; | ||
|
||
export const USER_ADDRESS_PARAM_DEFAULT = ':userAddress'; | ||
|
||
export const AUTH_METHOD_FOR_PARAM: Record<string, string> = { | ||
[USER_ADDRESS_PARAM_DEFAULT]: EIP4361_AUTH_METHOD, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { SiweMessage } from 'siwe'; | ||
import { z } from 'zod'; | ||
|
||
export const EIP4361_AUTH_METHOD = 'EIP4361'; | ||
|
||
const isSiweMessage = (message: string): boolean => { | ||
try { | ||
new SiweMessage(message); | ||
return true; | ||
} catch { | ||
return false; | ||
} | ||
}; | ||
|
||
export const EIP4361TypedDataSchema = z | ||
.string() | ||
.refine(isSiweMessage, { message: 'Invalid SIWE message' }); |
19 changes: 4 additions & 15 deletions
19
packages/taco-auth/src/providers/eip4361.ts → ...aco-auth/src/providers/eip4361/eip4361.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
export * from './eip4361'; | ||
export * from './external-eip4361'; | ||
export * from './eip4361/eip4361'; | ||
export * from './eip4361/external-eip4361'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.