Skip to content

Commit

Permalink
feat(indy-sdk): add indy-sdk package (#1200)
Browse files Browse the repository at this point in the history
Co-authored-by: Karim Stekelenburg <[email protected]>
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra and karimStekelenburg authored Jan 11, 2023
1 parent da7abde commit 9933b35
Show file tree
Hide file tree
Showing 83 changed files with 5,940 additions and 557 deletions.
7 changes: 2 additions & 5 deletions packages/action-menu/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,10 @@
"dependencies": {
"class-transformer": "0.5.1",
"class-validator": "0.13.1",
"rxjs": "^7.2.0"
},
"peerDependencies": {
"@aries-framework/core": "0.2.5"
"rxjs": "^7.2.0",
"@aries-framework/core": "0.3.2"
},
"devDependencies": {
"@aries-framework/node": "0.3.2",
"reflect-metadata": "^0.1.13",
"rimraf": "~3.0.2",
"typescript": "~4.3.0"
Expand Down
6 changes: 3 additions & 3 deletions packages/anoncreds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@aries-framework/anoncreds",
"main": "build/index",
"types": "build/index",
"version": "0.2.5",
"version": "0.3.2",
"files": [
"build"
],
Expand All @@ -25,10 +25,10 @@
"test": "jest"
},
"dependencies": {
"@aries-framework/core": "*"
"@aries-framework/core": "0.3.2"
},
"peerDependencies": {},
"devDependencies": {
"rimraf": "~3.0.2",
"typescript": "~4.3.0"
}
}
2 changes: 1 addition & 1 deletion packages/anoncreds/src/models/exchange.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface AnonCredsProofRequest {
string,
{
name?: string
names?: string
names?: string[]
restrictions?: WalletQuery[]
non_revoked?: NonRevokedInterval
}
Expand Down
6 changes: 3 additions & 3 deletions packages/anoncreds/src/models/internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,22 @@ export interface CredentialInfo {
}
schemaId: string
credentialDefinitionId: string
revocationRegistryId?: number | undefined
revocationRegistryId?: string | undefined
credentialRevocationId?: string | undefined
}

export interface RequestedAttribute {
credentialId: string
timestamp?: number
revealed: boolean
credentialInfo?: CredentialInfo
credentialInfo: CredentialInfo
revoked?: boolean
}

export interface RequestedPredicate {
credentialId: string
timestamp?: number
credentialInfo?: CredentialInfo
credentialInfo: CredentialInfo
revoked?: boolean
}

Expand Down
5 changes: 4 additions & 1 deletion packages/anoncreds/src/models/registry.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
export interface AnonCredsSchema {
issuerId: string
name: string
version: string
attrNames: string[]
}

export interface AnonCredsCredentialDefinition {
issuerId: string
schemaId: string
type: 'CL'
tag: string
Expand All @@ -16,6 +18,7 @@ export interface AnonCredsCredentialDefinition {
}

export interface AnonCredsRevocationRegistryDefinition {
issuerId: string
type: 'CL_ACCUM'
credDefId: string
tag: string
Expand All @@ -30,7 +33,7 @@ export interface AnonCredsRevocationRegistryDefinition {
}

export interface AnonCredsRevocationList {
// TODO: this is a new property, but do we keep abbreviation or not?
issuerId: string
revRegId: string
revocationList: number[]
currentAccumulator: string
Expand Down
11 changes: 3 additions & 8 deletions packages/anoncreds/src/services/AnonCredsHolderService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ import type {
import type { AgentContext } from '@aries-framework/core'

export interface AnonCredsHolderService {
createProof(
agentContext: AgentContext,
options: CreateProofOptions,
metadata?: Record<string, unknown>
): Promise<AnonCredsProof>
createProof(agentContext: AgentContext, options: CreateProofOptions): Promise<AnonCredsProof>
storeCredential(
agentContext: AgentContext,
options: StoreCredentialOptions,
Expand All @@ -28,13 +24,12 @@ export interface AnonCredsHolderService {

createCredentialRequest(
agentContext: AgentContext,
options: CreateCredentialRequestOptions,
metadata?: Record<string, unknown>
options: CreateCredentialRequestOptions
): Promise<CreateCredentialRequestReturn>

deleteCredential(agentContext: AgentContext, credentialId: string): Promise<void>
getCredentialsForProofRequest(
agentContext: AgentContext,
options: GetCredentialsForProofRequestOptions
): Promise<GetCredentialsForProofRequestReturn[]>
): Promise<GetCredentialsForProofRequestReturn>
}
14 changes: 9 additions & 5 deletions packages/anoncreds/src/services/AnonCredsHolderServiceOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@ export interface CreateProofOptions {
credentialDefinitions: {
[credentialDefinitionId: string]: AnonCredsCredentialDefinition
}
revocationStates: {
revocationRegistries: {
[revocationRegistryDefinitionId: string]: {
// tails file MUST already be downloaded on a higher level and stored
tailsFilePath: string
definition: AnonCredsRevocationRegistryDefinition
revocationLists: {
[timestamp: string]: AnonCredsRevocationList
Expand All @@ -45,8 +47,10 @@ export interface StoreCredentialOptions {
credentialDefinition: AnonCredsCredentialDefinition
credentialDefinitionId: string
credentialId?: string
revocationRegistryDefinition?: AnonCredsRevocationRegistryDefinition
revocationRegistryDefinitionId: string
revocationRegistry?: {
id: string
definition: AnonCredsRevocationRegistryDefinition
}
}

export interface GetCredentialOptions {
Expand All @@ -61,10 +65,10 @@ export interface GetCredentialsForProofRequestOptions {
extraQuery?: ReferentWalletQuery
}

export interface GetCredentialsForProofRequestReturn {
export type GetCredentialsForProofRequestReturn = Array<{
credentialInfo: CredentialInfo
interval?: NonRevokedInterval
}
}>

export interface CreateCredentialRequestOptions {
// TODO: Why is this needed? It is just used as context in Ursa, can be any string. Should we remove it?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,11 @@ export interface CreateSchemaOptions {

export interface CreateCredentialDefinitionOptions {
issuerId: string
tag: string // TODO: this was initially defined as optional, is that the case?
tag: string
supportRevocation?: boolean

// If schema doesn't include the id, we need to add it as a separate input parameter
schema: {
value: AnonCredsSchema
id: string
}
schemaId: string
schema: AnonCredsSchema
}

export interface CreateCredentialOfferOptions {
Expand Down
41 changes: 0 additions & 41 deletions packages/anoncreds/src/services/AnonCredsRegistry.ts

This file was deleted.

47 changes: 0 additions & 47 deletions packages/anoncreds/src/services/AnonCredsRegistryOptions.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface VerifyProofOptions {
// this means we need to retrieve _ALL_ deltas from the ledger to verify a proof. While currently we
// only need to fetch the registry.
revocationLists: {
[timestamp: string]: AnonCredsRevocationList
[timestamp: number]: AnonCredsRevocationList
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions packages/anoncreds/src/services/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './AnonCredsHolderService'
export * from './AnonCredsHolderServiceOptions'
export * from './AnonCredsIssuerService'
export * from './AnonCredsIssuerServiceOptions'
export * from './AnonCredsRegistry'
export * from './AnonCredsRegistryOptions'
export * from './registry'
export * from './AnonCredsVerifierService'
export * from './AnonCredsVerifierServiceOptions'
48 changes: 48 additions & 0 deletions packages/anoncreds/src/services/registry/AnonCredsRegistry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type {
GetCredentialDefinitionReturn,
RegisterCredentialDefinitionOptions,
RegisterCredentialDefinitionReturn,
} from './CredentialDefinitionOptions'
import type { GetRevocationListReturn } from './RevocationListOptions'
import type { GetRevocationRegistryDefinitionReturn } from './RevocationRegistryDefinitionOptions'
import type { GetSchemaReturn, RegisterSchemaOptions, RegisterSchemaReturn } from './SchemaOptions'
import type { AgentContext } from '@aries-framework/core'

// This service can be registered multiple times in a single AFJ instance.
export interface AnonCredsRegistry {
getSchema(agentContext: AgentContext, schemaId: string): Promise<GetSchemaReturn>
registerSchema(agentContext: AgentContext, options: RegisterSchemaOptions): Promise<RegisterSchemaReturn>

getCredentialDefinition(
agentContext: AgentContext,
credentialDefinitionId: string
): Promise<GetCredentialDefinitionReturn>
registerCredentialDefinition(
agentContext: AgentContext,
options: RegisterCredentialDefinitionOptions
): Promise<RegisterCredentialDefinitionReturn>

getRevocationRegistryDefinition(
agentContext: AgentContext,
revocationRegistryDefinitionId: string
): Promise<GetRevocationRegistryDefinitionReturn>

// TODO: issuance of revocable credentials
// registerRevocationRegistryDefinition(
// agentContext: AgentContext,
// options: RegisterRevocationRegistryDefinitionOptions
// ): Promise<RegisterRevocationRegistryDefinitionReturn>

// TODO: The name of this data model is still tbd.
getRevocationList(
agentContext: AgentContext,
revocationRegistryId: string,
timestamp: number
): Promise<GetRevocationListReturn>

// TODO: issuance of revocable credentials
// registerRevocationList(
// agentContext: AgentContext,
// options: RegisterRevocationListOptions
// ): Promise<RegisterRevocationListReturn>
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import type { AnonCredsCredentialDefinition } from '../../models/registry'
import type {
AnonCredsResolutionMetadata,
Extensible,
AnonCredsOperationStateFailed,
AnonCredsOperationStateFinished,
AnonCredsOperationState,
} from './base'

export interface GetCredentialDefinitionReturn {
credentialDefinition: AnonCredsCredentialDefinition | null
credentialDefinitionId: string
resolutionMetadata: AnonCredsResolutionMetadata
credentialDefinitionMetadata: Extensible
}

export interface RegisterCredentialDefinitionOptions {
credentialDefinition: AnonCredsCredentialDefinition
options: Extensible
}

export interface RegisterCredentialDefinitionReturnStateFailed extends AnonCredsOperationStateFailed {
credentialDefinition: AnonCredsCredentialDefinition
credentialDefinitionId?: string
}

export interface RegisterCredentialDefinitionReturnStateFinished extends AnonCredsOperationStateFinished {
credentialDefinition: AnonCredsCredentialDefinition
credentialDefinitionId?: string
}

export interface RegisterCredentialDefinitionReturnState extends AnonCredsOperationState {
credentialDefinition: AnonCredsCredentialDefinition
credentialDefinitionId?: string
}

export interface RegisterCredentialDefinitionReturn {
jobId?: string
credentialDefinitionState:
| RegisterCredentialDefinitionReturnState
| RegisterCredentialDefinitionReturnStateFinished
| RegisterCredentialDefinitionReturnStateFailed
credentialDefinitionMetadata: Extensible
registrationMetadata: AnonCredsResolutionMetadata
}
Loading

0 comments on commit 9933b35

Please sign in to comment.