Skip to content

Commit

Permalink
Add Signature type
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelBCarter committed Aug 29, 2024
1 parent 6d80230 commit c11f53d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@
},
"module": "dist/neutral/index.mjs",
"types": "dist/neutral/index.d.ts",
"dependencies": {},
"dependencies": {
"@xyo-network/payload-model": "^3.1.4"
},
"devDependencies": {
"@xylabs/ts-scripts-yarn3": "^4.0.7",
"@xylabs/tsconfig": "^4.0.7",
Expand Down
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)
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './Payload.ts'
export * from './Schema.ts'
32 changes: 32 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6918,6 +6918,16 @@ __metadata:
languageName: node
linkType: hard

"@xyo-network/payload-model@npm:^3.1.4":
version: 3.1.4
resolution: "@xyo-network/payload-model@npm:3.1.4"
dependencies:
"@xylabs/hex": "npm:^4.0.5"
"@xylabs/object": "npm:^4.0.5"
checksum: 10/bcf311626a8f9ebc7f570e20dd5646242361c20e2db21229e99ee3f65a4c71c2340f32927720b0e9ffb3ec010e6a15b422e7edef428306f7a05544e500e0ddd4
languageName: node
linkType: hard

"@xyo-network/payload-plugin@npm:^3.0.15":
version: 3.0.15
resolution: "@xyo-network/payload-plugin@npm:3.0.15"
Expand Down Expand Up @@ -7393,6 +7403,28 @@ __metadata:
languageName: node
linkType: hard

"@xyo-network/signature-payload-plugin@workspace:^, @xyo-network/signature-payload-plugin@workspace:packages/payload/packages/signature/packages/signature":
version: 0.0.0-use.local
resolution: "@xyo-network/signature-payload-plugin@workspace:packages/payload/packages/signature/packages/signature"
dependencies:
"@xylabs/ts-scripts-yarn3": "npm:^4.0.7"
"@xylabs/tsconfig": "npm:^4.0.7"
"@xyo-network/payload-model": "npm:^3.1.4"
typescript: "npm:^5.5.4"
languageName: unknown
linkType: soft

"@xyo-network/signature-payload-plugins@workspace:packages/payload/packages/signature":
version: 0.0.0-use.local
resolution: "@xyo-network/signature-payload-plugins@workspace:packages/payload/packages/signature"
dependencies:
"@xylabs/ts-scripts-yarn3": "npm:^4.0.7"
"@xylabs/tsconfig": "npm:^4.0.7"
"@xyo-network/signature-payload-plugin": "workspace:^"
typescript: "npm:^5.5.4"
languageName: unknown
linkType: soft

"@xyo-network/stock-market-payload-plugins@workspace:^, @xyo-network/stock-market-payload-plugins@workspace:packages/payload/packages/stock/packages/market":
version: 0.0.0-use.local
resolution: "@xyo-network/stock-market-payload-plugins@workspace:packages/payload/packages/stock/packages/market"
Expand Down

0 comments on commit c11f53d

Please sign in to comment.