@twin.org/identity-models 0.0.1-next.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/cjs/index.cjs +71 -0
- package/dist/esm/index.mjs +66 -0
- package/dist/types/factories/identityConnectorFactory.d.ts +6 -0
- package/dist/types/factories/identityProfileConnectorFactory.d.ts +6 -0
- package/dist/types/index.d.ts +18 -0
- package/dist/types/models/IIdentityComponent.d.ts +13 -0
- package/dist/types/models/IIdentityConnector.d.ts +145 -0
- package/dist/types/models/IIdentityProfileComponent.d.ts +72 -0
- package/dist/types/models/IIdentityProfileConnector.d.ts +70 -0
- package/dist/types/models/api/IIdentityProfileCreateRequest.d.ts +19 -0
- package/dist/types/models/api/IIdentityProfileGetPublicRequest.d.ts +23 -0
- package/dist/types/models/api/IIdentityProfileGetPublicResponse.d.ts +17 -0
- package/dist/types/models/api/IIdentityProfileGetRequest.d.ts +18 -0
- package/dist/types/models/api/IIdentityProfileGetResponse.d.ts +23 -0
- package/dist/types/models/api/IIdentityProfileListRequest.d.ts +26 -0
- package/dist/types/models/api/IIdentityProfileListResponse.d.ts +28 -0
- package/dist/types/models/api/IIdentityProfileUpdateRequest.d.ts +19 -0
- package/dist/types/models/api/IIdentityResolveRequest.d.ts +14 -0
- package/dist/types/models/api/IIdentityResolveResponse.d.ts +10 -0
- package/dist/types/models/identityRole.d.ts +21 -0
- package/dist/types/utils/documentHelper.d.ts +14 -0
- package/docs/changelog.md +5 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/DocumentHelper.md +41 -0
- package/docs/reference/index.md +32 -0
- package/docs/reference/interfaces/IIdentityComponent.md +27 -0
- package/docs/reference/interfaces/IIdentityConnector.md +495 -0
- package/docs/reference/interfaces/IIdentityProfileComponent.md +197 -0
- package/docs/reference/interfaces/IIdentityProfileConnector.md +177 -0
- package/docs/reference/interfaces/IIdentityProfileCreateRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetPublicRequest.md +31 -0
- package/docs/reference/interfaces/IIdentityProfileGetPublicResponse.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileGetResponse.md +29 -0
- package/docs/reference/interfaces/IIdentityProfileListRequest.md +35 -0
- package/docs/reference/interfaces/IIdentityProfileListResponse.md +23 -0
- package/docs/reference/interfaces/IIdentityProfileUpdateRequest.md +23 -0
- package/docs/reference/interfaces/IIdentityResolveRequest.md +17 -0
- package/docs/reference/interfaces/IIdentityResolveResponse.md +11 -0
- package/docs/reference/type-aliases/IdentityRole.md +5 -0
- package/docs/reference/variables/IdentityConnectorFactory.md +5 -0
- package/docs/reference/variables/IdentityProfileConnectorFactory.md +5 -0
- package/docs/reference/variables/IdentityRole.md +25 -0
- package/locales/en.json +13 -0
- package/package.json +42 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { IComponent } from "@twin.org/core";
|
|
2
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
3
|
+
/**
|
|
4
|
+
* Interface describing a contract which provides profile operations.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentityProfileConnector<T extends IJsonLdDocument = IJsonLdDocument, U extends IJsonLdDocument = IJsonLdDocument> extends IComponent {
|
|
7
|
+
/**
|
|
8
|
+
* Create the profile properties for an identity.
|
|
9
|
+
* @param identity The identity of the profile to create.
|
|
10
|
+
* @param publicProfile The public profile data as JSON-LD.
|
|
11
|
+
* @param privateProfile The private profile data as JSON-LD.
|
|
12
|
+
* @returns Nothing.
|
|
13
|
+
*/
|
|
14
|
+
create(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
|
|
15
|
+
/**
|
|
16
|
+
* Get the profile properties for an identity.
|
|
17
|
+
* @param identity The identity of the item to get.
|
|
18
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
19
|
+
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
20
|
+
* @returns The identity profile, will only return private data if you have correct permissions.
|
|
21
|
+
*/
|
|
22
|
+
get(identity: string, publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[]): Promise<{
|
|
23
|
+
publicProfile: Partial<T>;
|
|
24
|
+
privateProfile: Partial<U>;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Update the profile properties of an identity.
|
|
28
|
+
* @param identity The identity to update.
|
|
29
|
+
* @param publicProfile The public profile data as JSON-LD.
|
|
30
|
+
* @param privateProfile The private profile data as JSON-LD.
|
|
31
|
+
* @returns Nothing.
|
|
32
|
+
*/
|
|
33
|
+
update(identity: string, publicProfile?: T, privateProfile?: U): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Delete the profile for an identity.
|
|
36
|
+
* @param identity The identity to delete.
|
|
37
|
+
* @returns Nothing.
|
|
38
|
+
*/
|
|
39
|
+
remove(identity: string): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Get a list of the requested identities.
|
|
42
|
+
* @param publicFilters The filters to apply to the identities public profiles.
|
|
43
|
+
* @param privateFilters The filters to apply to the identities private profiles.
|
|
44
|
+
* @param publicPropertyNames The public properties to get for the profile, defaults to all.
|
|
45
|
+
* @param privatePropertyNames The private properties to get for the profile, defaults to all.
|
|
46
|
+
* @param cursor The cursor for paged requests.
|
|
47
|
+
* @param pageSize The maximum number of items in a page.
|
|
48
|
+
* @returns The list of items and cursor for paging.
|
|
49
|
+
*/
|
|
50
|
+
list(publicFilters?: {
|
|
51
|
+
propertyName: string;
|
|
52
|
+
propertyValue: unknown;
|
|
53
|
+
}[], privateFilters?: {
|
|
54
|
+
propertyName: string;
|
|
55
|
+
propertyValue: unknown;
|
|
56
|
+
}[], publicPropertyNames?: (keyof T)[], privatePropertyNames?: (keyof U)[], cursor?: string, pageSize?: number): Promise<{
|
|
57
|
+
/**
|
|
58
|
+
* The identity profiles.
|
|
59
|
+
*/
|
|
60
|
+
items: {
|
|
61
|
+
identity: string;
|
|
62
|
+
publicProfile?: Partial<T>;
|
|
63
|
+
privateProfile?: Partial<U>;
|
|
64
|
+
}[];
|
|
65
|
+
/**
|
|
66
|
+
* An optional cursor, when defined can be used to call find to get more entities.
|
|
67
|
+
*/
|
|
68
|
+
cursor?: string;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
2
|
+
/**
|
|
3
|
+
* Request to create an identity profile.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIdentityProfileCreateRequest {
|
|
6
|
+
/**
|
|
7
|
+
* The data for the request.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The public profile data.
|
|
12
|
+
*/
|
|
13
|
+
publicProfile?: IJsonLdDocument;
|
|
14
|
+
/**
|
|
15
|
+
* The private profile data.
|
|
16
|
+
*/
|
|
17
|
+
privateProfile?: IJsonLdDocument;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the public profile for an identity.
|
|
3
|
+
*/
|
|
4
|
+
export interface IIdentityProfileGetPublicRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The path parameters.
|
|
7
|
+
*/
|
|
8
|
+
pathParams: {
|
|
9
|
+
/**
|
|
10
|
+
* The identity to get the profile for.
|
|
11
|
+
*/
|
|
12
|
+
identity: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* The query parameters.
|
|
16
|
+
*/
|
|
17
|
+
query?: {
|
|
18
|
+
/**
|
|
19
|
+
* The properties to get for the public profile, defaults to all, should be a comma separated list.
|
|
20
|
+
*/
|
|
21
|
+
propertyNames?: string;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
2
|
+
import type { HeaderTypes, MimeTypes } from "@twin.org/web";
|
|
3
|
+
/**
|
|
4
|
+
* Response to get an identity public profile.
|
|
5
|
+
*/
|
|
6
|
+
export interface IIdentityProfileGetPublicResponse {
|
|
7
|
+
/**
|
|
8
|
+
* The response headers.
|
|
9
|
+
*/
|
|
10
|
+
headers: {
|
|
11
|
+
[HeaderTypes.ContentType]: typeof MimeTypes.JsonLd;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* The response payload.
|
|
15
|
+
*/
|
|
16
|
+
body: Partial<IJsonLdDocument>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Get the profile for an identity.
|
|
3
|
+
*/
|
|
4
|
+
export interface IIdentityProfileGetRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The query parameters.
|
|
7
|
+
*/
|
|
8
|
+
query?: {
|
|
9
|
+
/**
|
|
10
|
+
* The public properties to get for the profile, defaults to all, should be a comma separated list.
|
|
11
|
+
*/
|
|
12
|
+
publicPropertyNames?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The private properties to get for the profile, defaults to all, should be a comma separated list.
|
|
15
|
+
*/
|
|
16
|
+
privatePropertyNames?: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
2
|
+
/**
|
|
3
|
+
* Response to get an identity details.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIdentityProfileGetResponse {
|
|
6
|
+
/**
|
|
7
|
+
* The response payload.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The identity of the profile, this is the authenticated user identity.
|
|
12
|
+
*/
|
|
13
|
+
identity: string;
|
|
14
|
+
/**
|
|
15
|
+
* The public profile data.
|
|
16
|
+
*/
|
|
17
|
+
publicProfile?: Partial<IJsonLdDocument>;
|
|
18
|
+
/**
|
|
19
|
+
* The private profile data.
|
|
20
|
+
*/
|
|
21
|
+
privateProfile?: Partial<IJsonLdDocument>;
|
|
22
|
+
};
|
|
23
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Request to get a list of identities.
|
|
3
|
+
*/
|
|
4
|
+
export interface IIdentityProfileListRequest {
|
|
5
|
+
/**
|
|
6
|
+
* The query parameters.
|
|
7
|
+
*/
|
|
8
|
+
query?: {
|
|
9
|
+
/**
|
|
10
|
+
* The public filters to apply to the list, comma separated list with color between key and value for each pair e.g. prop1:value1,prop2:value2.
|
|
11
|
+
*/
|
|
12
|
+
publicFilters?: string;
|
|
13
|
+
/**
|
|
14
|
+
* The public properties to get for the profile, defaults to all, should be a comma separated list.
|
|
15
|
+
*/
|
|
16
|
+
publicPropertyNames?: string;
|
|
17
|
+
/**
|
|
18
|
+
* The cursor for paged requests.
|
|
19
|
+
*/
|
|
20
|
+
cursor?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Number of items to return.
|
|
23
|
+
*/
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
};
|
|
26
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
2
|
+
/**
|
|
3
|
+
* Response to get a list of identities.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIdentityProfileListResponse {
|
|
6
|
+
/**
|
|
7
|
+
* The response payload.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The identities.
|
|
12
|
+
*/
|
|
13
|
+
items: {
|
|
14
|
+
/**
|
|
15
|
+
* The identity.
|
|
16
|
+
*/
|
|
17
|
+
identity: string;
|
|
18
|
+
/**
|
|
19
|
+
* The public profile data.
|
|
20
|
+
*/
|
|
21
|
+
publicProfile?: Partial<IJsonLdDocument>;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* An optional cursor, when defined can be used to call find to get more entities.
|
|
25
|
+
*/
|
|
26
|
+
cursor?: string;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { IJsonLdDocument } from "@twin.org/data-json-ld";
|
|
2
|
+
/**
|
|
3
|
+
* Request to update an identity profile.
|
|
4
|
+
*/
|
|
5
|
+
export interface IIdentityProfileUpdateRequest {
|
|
6
|
+
/**
|
|
7
|
+
* The data for the request.
|
|
8
|
+
*/
|
|
9
|
+
body: {
|
|
10
|
+
/**
|
|
11
|
+
* The public profile data.
|
|
12
|
+
*/
|
|
13
|
+
publicProfile?: IJsonLdDocument;
|
|
14
|
+
/**
|
|
15
|
+
* The private profile data.
|
|
16
|
+
*/
|
|
17
|
+
privateProfile?: IJsonLdDocument;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The roles that an identity can have.
|
|
3
|
+
*/
|
|
4
|
+
export declare const IdentityRole: {
|
|
5
|
+
/**
|
|
6
|
+
* Node.
|
|
7
|
+
*/
|
|
8
|
+
readonly Node: "node";
|
|
9
|
+
/**
|
|
10
|
+
* Organization.
|
|
11
|
+
*/
|
|
12
|
+
readonly Organization: "organization";
|
|
13
|
+
/**
|
|
14
|
+
* User.
|
|
15
|
+
*/
|
|
16
|
+
readonly User: "user";
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* The roles that an identity can have.
|
|
20
|
+
*/
|
|
21
|
+
export type IdentityRole = (typeof IdentityRole)[keyof typeof IdentityRole];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper methods for documents.
|
|
3
|
+
*/
|
|
4
|
+
export declare class DocumentHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Parse the document id into its parts.
|
|
7
|
+
* @param documentId The full document id.
|
|
8
|
+
* @returns The parsed document id.
|
|
9
|
+
*/
|
|
10
|
+
static parse(documentId: string): {
|
|
11
|
+
id: string;
|
|
12
|
+
hash: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
}
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @twin.org/identity-service-models - Examples
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Class: DocumentHelper
|
|
2
|
+
|
|
3
|
+
Helper methods for documents.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### new DocumentHelper()
|
|
8
|
+
|
|
9
|
+
> **new DocumentHelper**(): [`DocumentHelper`](DocumentHelper.md)
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
[`DocumentHelper`](DocumentHelper.md)
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### parse()
|
|
18
|
+
|
|
19
|
+
> `static` **parse**(`documentId`): `object`
|
|
20
|
+
|
|
21
|
+
Parse the document id into its parts.
|
|
22
|
+
|
|
23
|
+
#### Parameters
|
|
24
|
+
|
|
25
|
+
• **documentId**: `string`
|
|
26
|
+
|
|
27
|
+
The full document id.
|
|
28
|
+
|
|
29
|
+
#### Returns
|
|
30
|
+
|
|
31
|
+
`object`
|
|
32
|
+
|
|
33
|
+
The parsed document id.
|
|
34
|
+
|
|
35
|
+
##### id
|
|
36
|
+
|
|
37
|
+
> **id**: `string`
|
|
38
|
+
|
|
39
|
+
##### hash
|
|
40
|
+
|
|
41
|
+
> **hash**: `undefined` \| `string`
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @twin.org/identity-models
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [DocumentHelper](classes/DocumentHelper.md)
|
|
6
|
+
|
|
7
|
+
## Interfaces
|
|
8
|
+
|
|
9
|
+
- [IIdentityComponent](interfaces/IIdentityComponent.md)
|
|
10
|
+
- [IIdentityConnector](interfaces/IIdentityConnector.md)
|
|
11
|
+
- [IIdentityProfileComponent](interfaces/IIdentityProfileComponent.md)
|
|
12
|
+
- [IIdentityProfileConnector](interfaces/IIdentityProfileConnector.md)
|
|
13
|
+
- [IIdentityProfileCreateRequest](interfaces/IIdentityProfileCreateRequest.md)
|
|
14
|
+
- [IIdentityProfileGetPublicRequest](interfaces/IIdentityProfileGetPublicRequest.md)
|
|
15
|
+
- [IIdentityProfileGetPublicResponse](interfaces/IIdentityProfileGetPublicResponse.md)
|
|
16
|
+
- [IIdentityProfileGetRequest](interfaces/IIdentityProfileGetRequest.md)
|
|
17
|
+
- [IIdentityProfileGetResponse](interfaces/IIdentityProfileGetResponse.md)
|
|
18
|
+
- [IIdentityProfileListRequest](interfaces/IIdentityProfileListRequest.md)
|
|
19
|
+
- [IIdentityProfileListResponse](interfaces/IIdentityProfileListResponse.md)
|
|
20
|
+
- [IIdentityProfileUpdateRequest](interfaces/IIdentityProfileUpdateRequest.md)
|
|
21
|
+
- [IIdentityResolveRequest](interfaces/IIdentityResolveRequest.md)
|
|
22
|
+
- [IIdentityResolveResponse](interfaces/IIdentityResolveResponse.md)
|
|
23
|
+
|
|
24
|
+
## Type Aliases
|
|
25
|
+
|
|
26
|
+
- [IdentityRole](type-aliases/IdentityRole.md)
|
|
27
|
+
|
|
28
|
+
## Variables
|
|
29
|
+
|
|
30
|
+
- [IdentityConnectorFactory](variables/IdentityConnectorFactory.md)
|
|
31
|
+
- [IdentityProfileConnectorFactory](variables/IdentityProfileConnectorFactory.md)
|
|
32
|
+
- [IdentityRole](variables/IdentityRole.md)
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Interface: IIdentityComponent
|
|
2
|
+
|
|
3
|
+
Interface describing a contract which provides identity operations.
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### resolve()
|
|
12
|
+
|
|
13
|
+
> **resolve**(`documentId`): `Promise`\<`IDidDocument`\>
|
|
14
|
+
|
|
15
|
+
Resolve an identity.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
• **documentId**: `string`
|
|
20
|
+
|
|
21
|
+
The id of the document to resolve.
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`Promise`\<`IDidDocument`\>
|
|
26
|
+
|
|
27
|
+
The resolved document.
|