Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 10 additions & 14 deletions src/@types/DDO4/Credentials.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
/* eslint-disable no-unused-vars */
export enum CREDENTIALS_TYPES {
ADDRESS = 'address',
ACCESS_LIST = 'accessList',
POLICY_SERVER_SPECIFIC = 'PS-specific Type' // externally handled type
}
export type MATCH_RULES = 'any' | 'all';

export const KNOWN_CREDENTIALS_TYPES = [
CREDENTIALS_TYPES.ADDRESS,
CREDENTIALS_TYPES.ACCESS_LIST
];
export interface CredentialAddressBased {
type: 'address';
values: string[];
}

export interface Credential {
type?: CREDENTIALS_TYPES;
values?: string[];
export interface CredentialAccessListBased {
type: 'accessList';
chainId: number;
accessList: string;
}

export type MATCH_RULES = 'any' | 'all';
export type Credential = CredentialAddressBased | CredentialAccessListBased;

export interface Credentials {
match_allow?: MATCH_RULES; // any => it's enough to have one rule matched, all => all allow rules should match, default: 'all'
Expand Down
46 changes: 27 additions & 19 deletions src/@types/DDO5/Credential.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,45 @@
/* eslint-disable no-use-before-define */

export type MATCH_RULES = 'any' | 'all';
export interface Credential {
match_allow?: MATCH_RULES; // any => it's enough to have one rule matched, all => all allow rules should match, default: 'all'
match_deny?: MATCH_RULES; // same pattern as above, default is 'any'
allow?: (CredentialAddressBased | CredentialPolicyBased)[];
deny?: (CredentialAddressBased | CredentialPolicyBased)[];
}

export interface CredentialAddressBased {
type: 'address';
values: string[];
}

export interface CredentialPolicyBased {
type: 'verifiableCredential';
requestCredentials: RequestCredential[];
export interface CredentialAccessListBased {
type: 'accessList';
chainId: number;
accessList: string;
}

export type RequestCredential = string | DetailedCredential;
export interface PolicyArgs {
type: string;
}
export interface PolicyDetail {
policy: string;
args: PolicyArgs;
}

export type Policy = string | PolicyDetail;

export interface DetailedCredential {
credential?: string;
policies?: Policy[];
}
export type RequestCredential = string | DetailedCredential;

export type Policy = string | PolicyDetail;

export interface PolicyDetail {
policy: string;
args: PolicyArgs;
export interface CredentialPolicyBased {
type: 'verifiableCredential';
requestCredentials: RequestCredential[];
}

export interface PolicyArgs {
type: string;
export type Credential =
| CredentialAddressBased
| CredentialAccessListBased
| CredentialPolicyBased;

export interface Credentials {
match_allow?: MATCH_RULES; // any => it's enough to have one rule matched, all => all allow rules should match, default: 'all'
match_deny?: MATCH_RULES; // same pattern as above, default is 'any'
allow?: Credential[];
deny?: Credential[];
}
1 change: 1 addition & 0 deletions src/@types/DDO5/CredentialSubject.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Event } from './Event.js';
import { Metadata } from './Metadata.js';
import { Service } from './Service.js';
import { Credential } from './Credential.js';

export interface CredentialSubject {
id?: string; // DID:
Expand Down
Loading