Skip to content

Commit

Permalink
add sdk hooks import
Browse files Browse the repository at this point in the history
  • Loading branch information
samteb committed Aug 29, 2024
1 parent 84928ad commit 905fd96
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 16 deletions.
2 changes: 1 addition & 1 deletion apps/devtool/src/app/_hooks/useAccountSignature.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Curves, KeyTypes, PublicKey, SigningAlg, hexToBase64Url } from '@narval/signature'
import { Curves, KeyTypes, PublicKey, SigningAlg, hexToBase64Url } from '@narval/armory-sdk'
import { signMessage } from '@wagmi/core'
import { useEffect, useState } from 'react'
import { useAccount } from 'wagmi'
Expand Down
4 changes: 2 additions & 2 deletions apps/devtool/src/app/_hooks/useAuthServerApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import {
AuthorizationRequestStatus,
EntityStoreClient,
Evaluate,
Request
Request,
SigningAlg
} from '@narval/armory-sdk'
import { SigningAlg } from '@narval/signature'
import { useMemo, useState } from 'react'
import { SetOptional } from 'type-fest'
import { extractErrorMessage, getUrlProtocol } from '../_lib/utils'
Expand Down
9 changes: 5 additions & 4 deletions apps/devtool/src/app/_hooks/useDataStoreApi.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { EntityStoreClient, PolicyStoreClient } from '@narval/armory-sdk'
import {
Entities,
EntityData,
EntityStore,
EntityStoreClient,
EntityUtil,
Policy,
PolicyData,
PolicyStore
} from '@narval/policy-engine-shared'
import { SigningAlg } from '@narval/signature'
PolicyStore,
PolicyStoreClient,
SigningAlg
} from '@narval/armory-sdk'
import { useEffect, useMemo, useState } from 'react'
import { backOff, extractErrorMessage, getHost, isValidUrl } from '../_lib/utils'
import useAccountSignature from './useAccountSignature'
Expand Down
4 changes: 2 additions & 2 deletions apps/devtool/src/app/_hooks/useEngineApi.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import {
EngineClientConfig,
EvaluationRequest,
SigningAlg,
onboardEngineClient,
pingEngine,
sendEvaluationRequest,
syncPolicyEngine
} from '@narval/armory-sdk'
import { EvaluationRequest } from '@narval/policy-engine-shared'
import { SigningAlg } from '@narval/signature'
import { useMemo, useState } from 'react'
import { extractErrorMessage, getUrlProtocol } from '../_lib/utils'
import useAccountSignature from './useAccountSignature'
Expand Down
14 changes: 9 additions & 5 deletions apps/devtool/src/app/_hooks/useVaultApi.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ import {
GenerateKeyRequest,
ImportPrivateKeyRequest,
ImportSeedRequest,
Jwk,
Request,
RsaPublicKey,
SigningAlg,
VaultAdminClient,
VaultClient
VaultClient,
rsaKeyToKid,
rsaPublicKeySchema
} from '@narval/armory-sdk'
import { Request } from '@narval/policy-engine-shared'
import { Alg, Jwk, RsaPublicKey, SigningAlg, rsaKeyToKid, rsaPublicKeySchema } from '@narval/signature'
import { exportJWK, importSPKI } from 'jose'
import { useMemo, useState } from 'react'
import { extractErrorMessage, getHost, isValidUrl } from '../_lib/utils'
Expand Down Expand Up @@ -81,13 +85,13 @@ const useVaultApi = () => {
} = vaultClientData

const getJwkFromRsaPem = async (pem: string): Promise<RsaPublicKey | null> => {
const key = await importSPKI(pem, Alg.RS256, { extractable: true })
const key = await importSPKI(pem, SigningAlg.RS256, { extractable: true })
const jwk = await exportJWK(key)
const kid = rsaKeyToKid(jwk as Jwk)

return rsaPublicKeySchema.parse({
...jwk,
alg: Alg.RS256,
alg: SigningAlg.RS256,
kid
})
}
Expand Down
11 changes: 9 additions & 2 deletions packages/armory-sdk/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export * from './lib/vault'

export { resourceId } from './lib/utils'

export type { Alg, PrivateKey, PublicKey, RsaPublicKey } from '@narval/signature'
export type { Alg, Jwk, PrivateKey, PublicKey, RsaPublicKey } from '@narval/signature'

export {
Curves,
Expand All @@ -27,6 +27,8 @@ export {
privateKeyToJwk,
publicKeySchema,
publicKeyToJwk,
rsaKeyToKid,
rsaPublicKeySchema,
signJwt
} from '@narval/signature'

Expand All @@ -41,6 +43,7 @@ export type {
Eip712TypedData,
Entities,
EntityType,
EvaluationRequest,
Hex,
JwtString,
Policy,
Expand All @@ -50,13 +53,17 @@ export type {
TransactionRequest,
UserAccountEntity,
UserEntity,
ValueOperators,
ValueOperators
} from '@narval/policy-engine-shared'

export {
AccountType,
Action,
EntityData,
EntityStore,
EntityUtil,
PolicyData,
PolicyStore,
UserRole,
getAddress,
hexSchema,
Expand Down

0 comments on commit 905fd96

Please sign in to comment.