generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated tenant gate interface to allow custom message to surface to t…
…he DWN message sender (#661)
- Loading branch information
1 parent
b7306d5
commit 53d560d
Showing
5 changed files
with
60 additions
and
15 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,33 @@ | ||
/** | ||
* The result of the isActiveTenant() call. | ||
*/ | ||
export type ActiveTenantCheckResult = { | ||
/** | ||
* `true` if the given DID is an active tenant of the DWN; `false` otherwise. | ||
*/ | ||
isActiveTenant: boolean; | ||
|
||
/** | ||
* An optional detail message if the given DID is not an active tenant of the DWN. | ||
*/ | ||
detail?: string; | ||
}; | ||
|
||
/** | ||
* An interface that gates tenant access to the DWN. | ||
*/ | ||
export interface TenantGate { | ||
/** | ||
* @returns `true` if the given DID is an active tenant of the DWN; `false` otherwise | ||
*/ | ||
isActiveTenant(did: string): Promise<boolean>; | ||
isActiveTenant(did: string): Promise<ActiveTenantCheckResult>; | ||
} | ||
|
||
/** | ||
* A tenant gate that treats every DID as an active tenant. | ||
*/ | ||
export class AllowAllTenantGate implements TenantGate { | ||
public async isActiveTenant(_did: string): Promise<boolean> { | ||
return true; | ||
public async isActiveTenant(_did: string): Promise<ActiveTenantCheckResult> { | ||
return { isActiveTenant: true }; | ||
} | ||
} |
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