Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Trent Larson | bb83982bc7 | 2 months ago |
Trent Larson | 1e61c55e5b | 2 months ago |
Trent Larson | 7a2551cbae | 2 months ago |
Trent Larson | 947f307305 | 2 months ago |
Trent Larson | a23f6d10ad | 2 months ago |
Trent Larson | 8228970116 | 2 months ago |
Trent Larson | 2d5a09de00 | 2 months ago |
Trent Larson | 400a4a1e06 | 2 months ago |
Trent Larson | 8750c78897 | 2 months ago |
8 changed files with 147 additions and 57 deletions
@ -1,14 +1,19 @@ |
|||||
# syntax=docker/dockerfile:1 |
# syntax=docker/dockerfile:1 |
||||
|
|
||||
FROM node:22-alpine |
FROM node:22-alpine AS builder |
||||
ARG IMAGE_API_VERSION |
ARG IMAGE_API_VERSION |
||||
RUN npm install -g pnpm |
RUN npm install -g pnpm |
||||
RUN apk add git |
RUN apk add git |
||||
RUN git clone https://gitea.anomalistdesign.com/log-trade/image-api.git |
RUN git clone https://gitea.anomalistdesign.com/log-trade/image-api.git |
||||
|
|
||||
WORKDIR image-api |
WORKDIR image-api |
||||
RUN git checkout $IMAGE_API_VERSION |
RUN git checkout $IMAGE_API_VERSION |
||||
|
# dev dependencies like TypeScript are needed to build |
||||
RUN pnpm install |
RUN pnpm install |
||||
RUN pnpm build |
RUN pnpm build |
||||
|
RUN pnpm install --prod |
||||
|
|
||||
|
FROM node:22-alpine |
||||
|
COPY --from=builder /image-api/dist /image-api/dist |
||||
|
COPY --from=builder /image-api/node_modules /image-api/node_modules |
||||
|
WORKDIR image-api |
||||
CMD node dist/server.js |
CMD node dist/server.js |
@ -1,45 +0,0 @@ |
|||||
const { DIDResolutionResult } = require('did-resolver'); |
|
||||
/** |
|
||||
* This did:ethr resolver instructs the did-jwt machinery to use the |
|
||||
* EcdsaSecp256k1RecoveryMethod2020Uses verification method which adds the recovery bit to the |
|
||||
* signature to recover the DID's public key from a signature. |
|
||||
* |
|
||||
* This effectively hard codes the did:ethr DID resolver to use the address as the public key. |
|
||||
* @param did : string |
|
||||
* @returns {Promise<DIDResolutionResult>} |
|
||||
* |
|
||||
* Similar code resides in endorser-ch |
|
||||
*/ |
|
||||
export const didEthLocalResolver = async(did) => { |
|
||||
const didRegex = /^did:ethr:(0x[0-9a-fA-F]{40})$/; |
|
||||
const match = did.match(didRegex); |
|
||||
|
|
||||
if (match) { |
|
||||
const address = match[1]; // Extract eth address: 0x...
|
|
||||
const publicKeyHex = address; // Use the address directly as a public key placeholder
|
|
||||
|
|
||||
return { |
|
||||
didDocumentMetadata: {}, |
|
||||
didResolutionMetadata: { |
|
||||
contentType: "application/did+ld+json" |
|
||||
}, |
|
||||
didDocument: { |
|
||||
'@context': [ |
|
||||
'https://www.w3.org/ns/did/v1', |
|
||||
"https://w3id.org/security/suites/secp256k1recovery-2020/v2" |
|
||||
], |
|
||||
id: did, |
|
||||
verificationMethod: [{ |
|
||||
id: `${did}#controller`, |
|
||||
type: 'EcdsaSecp256k1RecoveryMethod2020', |
|
||||
controller: did, |
|
||||
blockchainAccountId: "eip155:1:" + publicKeyHex, |
|
||||
}], |
|
||||
authentication: [`${did}#controller`], |
|
||||
assertionMethod: [`${did}#controller`], |
|
||||
}, |
|
||||
}; |
|
||||
} |
|
||||
|
|
||||
throw new Error(`Unsupported DID format: ${did}`); |
|
||||
}; |
|
@ -1,5 +1,46 @@ |
|||||
import {DIDResolutionResult} from "did-resolver"; |
import {DIDResolutionResult} from "did-resolver"; |
||||
|
|
||||
declare module './did-eth-local-resolver.js' { |
/** |
||||
export function didEthLocalResolver(jwt: string): Promise<DIDResolutionResult>; |
* This did:ethr resolver instructs the did-jwt machinery to use the |
||||
} |
* EcdsaSecp256k1RecoveryMethod2020Uses verification method which adds the recovery bit to the |
||||
|
* signature to recover the DID's public key from a signature. |
||||
|
* |
||||
|
* This effectively hard codes the did:ethr DID resolver to use the address as the public key. |
||||
|
* @param did : string |
||||
|
* @returns {Promise<DIDResolutionResult>} |
||||
|
* |
||||
|
* Similar code resides in endorser-ch |
||||
|
*/ |
||||
|
export const didEthLocalResolver = async(did: string): Promise<DIDResolutionResult> => { |
||||
|
const didRegex = /^did:ethr:(0x[0-9a-fA-F]{40})$/; |
||||
|
const match = did.match(didRegex); |
||||
|
|
||||
|
if (match) { |
||||
|
const address = match[1]; // Extract eth address: 0x...
|
||||
|
const publicKeyHex = address; // Use the address directly as a public key placeholder
|
||||
|
|
||||
|
return { |
||||
|
didDocumentMetadata: {}, |
||||
|
didResolutionMetadata: { |
||||
|
contentType: "application/did+ld+json" |
||||
|
}, |
||||
|
didDocument: { |
||||
|
'@context': [ |
||||
|
'https://www.w3.org/ns/did/v1', |
||||
|
"https://w3id.org/security/suites/secp256k1recovery-2020/v2" |
||||
|
], |
||||
|
id: did, |
||||
|
verificationMethod: [{ |
||||
|
id: `${did}#controller`, |
||||
|
type: 'EcdsaSecp256k1RecoveryMethod2020', |
||||
|
controller: did, |
||||
|
blockchainAccountId: "eip155:1:" + publicKeyHex, |
||||
|
}], |
||||
|
authentication: [`${did}#controller`], |
||||
|
assertionMethod: [`${did}#controller`], |
||||
|
}, |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
throw new Error(`Unsupported DID format: ${did}`); |
||||
|
}; |
||||
|
After Width: | Height: | Size: 5.6 KiB |
Loading…
Reference in new issue