-
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
6d80230
commit c11f53d
Showing
5 changed files
with
73 additions
and
1 deletion.
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
34 changes: 34 additions & 0 deletions
34
packages/payload/packages/signature/packages/signature/src/Payload.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type { Payload } from '@xyo-network/payload-model' | ||
import { | ||
isPayloadOfSchemaType, isPayloadOfSchemaTypeWithMeta, isPayloadOfSchemaTypeWithSources, | ||
} from '@xyo-network/payload-model' | ||
|
||
import { SignatureSchema } from './Schema.ts' | ||
|
||
// TODO: openssl list -digest-algorithms | ||
export type Digest = 'sha512' | 'sha3-256' | ||
|
||
export interface SignatureFields { | ||
digestAlgorithm: Digest | ||
signature: string | ||
} | ||
|
||
/** | ||
* A Signature Payload | ||
*/ | ||
export type Signature = Payload<SignatureFields, SignatureSchema> | ||
|
||
/** | ||
* Identity function for determine if an object is a Signature | ||
*/ | ||
export const isSignature = isPayloadOfSchemaType<Signature>(SignatureSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Signature with sources | ||
*/ | ||
export const isSignatureWithSources = isPayloadOfSchemaTypeWithSources<Signature>(SignatureSchema) | ||
|
||
/** | ||
* Identity function for determine if an object is a Signature with meta | ||
*/ | ||
export const isSignatureWithMeta = isPayloadOfSchemaTypeWithMeta<Signature>(SignatureSchema) |
2 changes: 2 additions & 0 deletions
2
packages/payload/packages/signature/packages/signature/src/Schema.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export const SignatureSchema = 'network.xyo.signing.signature' as const | ||
export type SignatureSchema = typeof SignatureSchema |
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,2 @@ | ||
export * from './Payload.ts' | ||
export * from './Schema.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