Skip to content

Commit 8837745

Browse files
Re-export types used by capabilities (#128)
1 parent 3e7d1cb commit 8837745

File tree

6 files changed

+24
-12
lines changed

6 files changed

+24
-12
lines changed

packages/cre-http-trigger/src/create-jwt.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ export const createJWT = async (request: JSONRPCRequest, privateKey: Hex): Promi
4242
}
4343

4444
// Encode header and payload to base64url
45-
const encodedHeader = base64URLEncode(Buffer.from(JSON.stringify(header), 'utf8').toString('base64'))
46-
const encodedPayload = base64URLEncode(Buffer.from(JSON.stringify(payload), 'utf8').toString('base64'))
45+
const encodedHeader = base64URLEncode(
46+
Buffer.from(JSON.stringify(header), 'utf8').toString('base64'),
47+
)
48+
const encodedPayload = base64URLEncode(
49+
Buffer.from(JSON.stringify(payload), 'utf8').toString('base64'),
50+
)
4751
const rawMessage = `${encodedHeader}.${encodedPayload}`
4852

4953
// Sign the message - viem's signMessage handles the Ethereum Signed Message prefix and hashing
@@ -64,11 +68,7 @@ export const createJWT = async (request: JSONRPCRequest, privateKey: Hex): Promi
6468
// Ensure r and s are exactly 32 bytes each by padding with leading zeros if needed
6569
const rBuffer = Buffer.from(r.slice(2).padStart(64, '0'), 'hex') // 32 bytes = 64 hex chars
6670
const sBuffer = Buffer.from(s.slice(2).padStart(64, '0'), 'hex') // 32 bytes = 64 hex chars
67-
const signatureBytes = Buffer.concat([
68-
rBuffer,
69-
sBuffer,
70-
Buffer.from([Number(recoveryId)]),
71-
])
71+
const signatureBytes = Buffer.concat([rBuffer, sBuffer, Buffer.from([Number(recoveryId)])])
7272
const encodedSignature = base64URLEncode(signatureBytes.toString('base64'))
7373
return `${rawMessage}.${encodedSignature}`
7474
}

packages/cre-http-trigger/src/trigger-workflow.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
import stringify from 'json-stable-stringify'
12
import { v4 as uuidv4 } from 'uuid'
23
import { privateKeyToAccount } from 'viem/accounts'
3-
import stringify from 'json-stable-stringify'
44
import { createJWT, type JSONRPCRequest } from './create-jwt'
55
import { getConfig } from './get-config'
66
import type { TriggerInput, WorkflowSelector } from './schemas'

packages/cre-http-trigger/src/utils.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,4 @@ export const sha256 = (data: any): string => {
99

1010
// Helper function to convert base64 string to base64url by replacing URL-unsafe characters
1111
export const base64URLEncode = (str: string): string =>
12-
str
13-
.replace(/\+/g, '-')
14-
.replace(/\//g, '_')
15-
.replace(/=/g, '')
12+
str.replace(/\+/g, '-').replace(/\//g, '_').replace(/=/g, '')

packages/cre-sdk/src/pb.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ export * as HTTP_TRIGGER_PB from '@cre/generated/capabilities/networking/http/v1
44
export * as CRON_TRIGGER_PB from '@cre/generated/capabilities/scheduler/cron/v1/trigger_pb'
55
export * as SDK_PB from '@cre/generated/sdk/v1alpha/sdk_pb'
66
export * as VALUES_PB from '@cre/generated/values/v1/values_pb'
7+
export * as BUFBUILD_TYPES from '@cre/sdk/types/bufbuild-types'

packages/cre-sdk/src/sdk/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ export * from './cre'
22
export * from './report'
33
export type * from './runtime'
44
export * from './runtime'
5+
export * from './types/bufbuild-types'
56
export * from './utils'
67
// Export HTTP response helpers
78
export * from './utils/capabilities/http/http-helpers'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* This file re-exports the types, internally used by the SDK capabilities, that are normally coming with @bufbuild/protobuf library.
3+
*/
4+
export type {
5+
Any,
6+
AnyJson,
7+
Empty,
8+
EmptyJson,
9+
Struct,
10+
StructJson,
11+
Timestamp,
12+
TimestampJson,
13+
} from '@bufbuild/protobuf/wkt'

0 commit comments

Comments
 (0)