This repository has been archived by the owner on Aug 1, 2024. It is now read-only.
forked from nucypher/taco-web
-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
f452c6a
commit e6c4e1b
Showing
13 changed files
with
33 additions
and
383 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,30 +1,20 @@ | ||
import { AuthSignature } from './auth-sig'; | ||
import { EIP4361AuthProvider, EIP712AuthProvider } from './providers'; | ||
import { EIP4361AuthProvider } from './providers'; | ||
|
||
/** | ||
* @deprecated Use EIP4361_AUTH_METHOD instead. | ||
*/ | ||
export const EIP712_AUTH_METHOD = 'EIP712'; | ||
export const EIP4361_AUTH_METHOD = 'EIP4361'; | ||
|
||
|
||
export interface AuthProvider { | ||
getOrCreateAuthSignature(): Promise<AuthSignature>; | ||
} | ||
|
||
export type AuthProviders = { | ||
[EIP712_AUTH_METHOD]?: EIP712AuthProvider; | ||
[EIP4361_AUTH_METHOD]?: EIP4361AuthProvider; | ||
// Fallback to satisfy type checking | ||
[key: string]: AuthProvider | undefined; | ||
}; | ||
|
||
export const USER_ADDRESS_PARAM_DEFAULT = ':userAddress'; | ||
export const USER_ADDRESS_PARAM_EIP712 = `:userAddress${EIP712_AUTH_METHOD}`; | ||
export const USER_ADDRESS_PARAM_EIP4361 = `:userAddress${EIP4361_AUTH_METHOD}`; | ||
|
||
export const AUTH_METHOD_FOR_PARAM: Record<string, string> = { | ||
[USER_ADDRESS_PARAM_DEFAULT]: EIP4361_AUTH_METHOD, | ||
[USER_ADDRESS_PARAM_EIP712]: EIP712_AUTH_METHOD, | ||
[USER_ADDRESS_PARAM_EIP4361]: 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,15 @@ | ||
import { EthAddressSchema } from '@nucypher/shared'; | ||
import { z } from 'zod'; | ||
|
||
import { EIP4361_AUTH_METHOD, EIP712_AUTH_METHOD } from './auth-provider'; | ||
import { EIP4361TypedDataSchema, EIP712TypedDataSchema } from './providers'; | ||
import { EIP4361_AUTH_METHOD } from './auth-provider'; | ||
import { EIP4361TypedDataSchema } from './providers'; | ||
|
||
|
||
export const authSignatureSchema = z.object({ | ||
signature: z.string(), | ||
address: EthAddressSchema, | ||
scheme: z.enum([EIP712_AUTH_METHOD, EIP4361_AUTH_METHOD]), | ||
typedData: z.union([ | ||
EIP4361TypedDataSchema, | ||
// TODO(#536): Remove post EIP712 deprecation | ||
EIP712TypedDataSchema, | ||
]), | ||
scheme: z.enum([EIP4361_AUTH_METHOD]), | ||
typedData: EIP4361TypedDataSchema, | ||
}); | ||
|
||
export type AuthSignature = z.infer<typeof authSignatureSchema>; |
This file was deleted.
Oops, something went wrong.
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,4 +1,3 @@ | ||
export * from './providers'; | ||
export * from './helper'; | ||
export * from './auth-sig'; | ||
export * from './auth-provider'; |
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export * from './eip712'; | ||
export * from './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
Oops, something went wrong.