@sphereon/ssi-sdk.data-store 0.11.1-next.106

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.
Files changed (192) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +72 -0
  3. package/dist/contact/AbstractContactStore.d.ts +14 -0
  4. package/dist/contact/AbstractContactStore.d.ts.map +1 -0
  5. package/dist/contact/AbstractContactStore.js +7 -0
  6. package/dist/contact/AbstractContactStore.js.map +1 -0
  7. package/dist/contact/ContactStore.d.ts +29 -0
  8. package/dist/contact/ContactStore.d.ts.map +1 -0
  9. package/dist/contact/ContactStore.js +281 -0
  10. package/dist/contact/ContactStore.js.map +1 -0
  11. package/dist/entities/contact/BaseConfigEntity.d.ts +5 -0
  12. package/dist/entities/contact/BaseConfigEntity.d.ts.map +1 -0
  13. package/dist/entities/contact/BaseConfigEntity.js +26 -0
  14. package/dist/entities/contact/BaseConfigEntity.js.map +1 -0
  15. package/dist/entities/contact/ConnectionEntity.d.ts +12 -0
  16. package/dist/entities/contact/ConnectionEntity.d.ts.map +1 -0
  17. package/dist/entities/contact/ConnectionEntity.js +66 -0
  18. package/dist/entities/contact/ConnectionEntity.js.map +1 -0
  19. package/dist/entities/contact/ContactEntity.d.ts +16 -0
  20. package/dist/entities/contact/ContactEntity.d.ts.map +1 -0
  21. package/dist/entities/contact/ContactEntity.js +105 -0
  22. package/dist/entities/contact/ContactEntity.js.map +1 -0
  23. package/dist/entities/contact/CorrelationIdentifierEntity.d.ts +12 -0
  24. package/dist/entities/contact/CorrelationIdentifierEntity.d.ts.map +1 -0
  25. package/dist/entities/contact/CorrelationIdentifierEntity.js +75 -0
  26. package/dist/entities/contact/CorrelationIdentifierEntity.js.map +1 -0
  27. package/dist/entities/contact/DidAuthConfigEntity.d.ts +11 -0
  28. package/dist/entities/contact/DidAuthConfigEntity.d.ts.map +1 -0
  29. package/dist/entities/contact/DidAuthConfigEntity.js +49 -0
  30. package/dist/entities/contact/DidAuthConfigEntity.js.map +1 -0
  31. package/dist/entities/contact/IdentityEntity.d.ts +22 -0
  32. package/dist/entities/contact/IdentityEntity.d.ts.map +1 -0
  33. package/dist/entities/contact/IdentityEntity.js +134 -0
  34. package/dist/entities/contact/IdentityEntity.js.map +1 -0
  35. package/dist/entities/contact/IdentityMetadataItemEntity.d.ts +12 -0
  36. package/dist/entities/contact/IdentityMetadataItemEntity.d.ts.map +1 -0
  37. package/dist/entities/contact/IdentityMetadataItemEntity.js +72 -0
  38. package/dist/entities/contact/IdentityMetadataItemEntity.js.map +1 -0
  39. package/dist/entities/contact/OpenIdConfigEntity.d.ts +15 -0
  40. package/dist/entities/contact/OpenIdConfigEntity.d.ts.map +1 -0
  41. package/dist/entities/contact/OpenIdConfigEntity.js +70 -0
  42. package/dist/entities/contact/OpenIdConfigEntity.js.map +1 -0
  43. package/dist/entities/issuanceBranding/BackgroundAttributesEntity.d.ts +11 -0
  44. package/dist/entities/issuanceBranding/BackgroundAttributesEntity.d.ts.map +1 -0
  45. package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js +74 -0
  46. package/dist/entities/issuanceBranding/BackgroundAttributesEntity.js.map +1 -0
  47. package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.d.ts +18 -0
  48. package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.d.ts.map +1 -0
  49. package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js +120 -0
  50. package/dist/entities/issuanceBranding/BaseLocaleBrandingEntity.js.map +1 -0
  51. package/dist/entities/issuanceBranding/CredentialBrandingEntity.d.ts +15 -0
  52. package/dist/entities/issuanceBranding/CredentialBrandingEntity.d.ts.map +1 -0
  53. package/dist/entities/issuanceBranding/CredentialBrandingEntity.js +102 -0
  54. package/dist/entities/issuanceBranding/CredentialBrandingEntity.js.map +1 -0
  55. package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.d.ts +9 -0
  56. package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.d.ts.map +1 -0
  57. package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js +49 -0
  58. package/dist/entities/issuanceBranding/CredentialLocaleBrandingEntity.js.map +1 -0
  59. package/dist/entities/issuanceBranding/ImageAttributesEntity.d.ts +14 -0
  60. package/dist/entities/issuanceBranding/ImageAttributesEntity.d.ts.map +1 -0
  61. package/dist/entities/issuanceBranding/ImageAttributesEntity.js +92 -0
  62. package/dist/entities/issuanceBranding/ImageAttributesEntity.js.map +1 -0
  63. package/dist/entities/issuanceBranding/ImageDimensionsEntity.d.ts +9 -0
  64. package/dist/entities/issuanceBranding/ImageDimensionsEntity.d.ts.map +1 -0
  65. package/dist/entities/issuanceBranding/ImageDimensionsEntity.js +39 -0
  66. package/dist/entities/issuanceBranding/ImageDimensionsEntity.js.map +1 -0
  67. package/dist/entities/issuanceBranding/IssuerBrandingEntity.d.ts +14 -0
  68. package/dist/entities/issuanceBranding/IssuerBrandingEntity.d.ts.map +1 -0
  69. package/dist/entities/issuanceBranding/IssuerBrandingEntity.js +95 -0
  70. package/dist/entities/issuanceBranding/IssuerBrandingEntity.js.map +1 -0
  71. package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.d.ts +9 -0
  72. package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.d.ts.map +1 -0
  73. package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js +49 -0
  74. package/dist/entities/issuanceBranding/IssuerLocaleBrandingEntity.js.map +1 -0
  75. package/dist/entities/issuanceBranding/TextAttributesEntity.d.ts +9 -0
  76. package/dist/entities/issuanceBranding/TextAttributesEntity.d.ts.map +1 -0
  77. package/dist/entities/issuanceBranding/TextAttributesEntity.js +62 -0
  78. package/dist/entities/issuanceBranding/TextAttributesEntity.js.map +1 -0
  79. package/dist/entities/validators/index.d.ts +7 -0
  80. package/dist/entities/validators/index.d.ts.map +1 -0
  81. package/dist/entities/validators/index.js +27 -0
  82. package/dist/entities/validators/index.js.map +1 -0
  83. package/dist/index.d.ts +27 -0
  84. package/dist/index.d.ts.map +1 -0
  85. package/dist/index.js +99 -0
  86. package/dist/index.js.map +1 -0
  87. package/dist/issuanceBranding/AbstractIssuanceBrandingStore.d.ts +20 -0
  88. package/dist/issuanceBranding/AbstractIssuanceBrandingStore.d.ts.map +1 -0
  89. package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js +7 -0
  90. package/dist/issuanceBranding/AbstractIssuanceBrandingStore.js.map +1 -0
  91. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts +31 -0
  92. package/dist/issuanceBranding/IssuanceBrandingStore.d.ts.map +1 -0
  93. package/dist/issuanceBranding/IssuanceBrandingStore.js +375 -0
  94. package/dist/issuanceBranding/IssuanceBrandingStore.js.map +1 -0
  95. package/dist/migrations/generic/1-CreateContacts.d.ts +7 -0
  96. package/dist/migrations/generic/1-CreateContacts.d.ts.map +1 -0
  97. package/dist/migrations/generic/1-CreateContacts.js +72 -0
  98. package/dist/migrations/generic/1-CreateContacts.js.map +1 -0
  99. package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts +7 -0
  100. package/dist/migrations/generic/1-CreateIssuanceBranding.d.ts.map +1 -0
  101. package/dist/migrations/generic/1-CreateIssuanceBranding.js +72 -0
  102. package/dist/migrations/generic/1-CreateIssuanceBranding.js.map +1 -0
  103. package/dist/migrations/generic/index.d.ts +10 -0
  104. package/dist/migrations/generic/index.d.ts.map +1 -0
  105. package/dist/migrations/generic/index.js +14 -0
  106. package/dist/migrations/generic/index.js.map +1 -0
  107. package/dist/migrations/index.d.ts +2 -0
  108. package/dist/migrations/index.d.ts.map +1 -0
  109. package/dist/migrations/index.js +6 -0
  110. package/dist/migrations/index.js.map +1 -0
  111. package/dist/migrations/internal-migrations-ormconfig.d.ts +6 -0
  112. package/dist/migrations/internal-migrations-ormconfig.d.ts.map +1 -0
  113. package/dist/migrations/internal-migrations-ormconfig.js +29 -0
  114. package/dist/migrations/internal-migrations-ormconfig.js.map +1 -0
  115. package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts +7 -0
  116. package/dist/migrations/postgres/1659463079428-CreateContacts.d.ts.map +1 -0
  117. package/dist/migrations/postgres/1659463079428-CreateContacts.js +55 -0
  118. package/dist/migrations/postgres/1659463079428-CreateContacts.js.map +1 -0
  119. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts +7 -0
  120. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.d.ts.map +1 -0
  121. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js +67 -0
  122. package/dist/migrations/postgres/1685628974232-CreateIssuanceBranding.js.map +1 -0
  123. package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts +7 -0
  124. package/dist/migrations/sqlite/1659463069549-CreateContacts.d.ts.map +1 -0
  125. package/dist/migrations/sqlite/1659463069549-CreateContacts.js +79 -0
  126. package/dist/migrations/sqlite/1659463069549-CreateContacts.js.map +1 -0
  127. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.d.ts +7 -0
  128. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.d.ts.map +1 -0
  129. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js +89 -0
  130. package/dist/migrations/sqlite/1685628973231-CreateIssuanceBranding.js.map +1 -0
  131. package/dist/types/contact/IAbstractContactStore.d.ts +41 -0
  132. package/dist/types/contact/IAbstractContactStore.d.ts.map +1 -0
  133. package/dist/types/contact/IAbstractContactStore.js +3 -0
  134. package/dist/types/contact/IAbstractContactStore.js.map +1 -0
  135. package/dist/types/contact/contact.d.ts +91 -0
  136. package/dist/types/contact/contact.d.ts.map +1 -0
  137. package/dist/types/contact/contact.js +21 -0
  138. package/dist/types/contact/contact.js.map +1 -0
  139. package/dist/types/index.d.ts +5 -0
  140. package/dist/types/index.d.ts.map +1 -0
  141. package/dist/types/index.js +21 -0
  142. package/dist/types/index.js.map +1 -0
  143. package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.d.ts +59 -0
  144. package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.d.ts.map +1 -0
  145. package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js +3 -0
  146. package/dist/types/issuanceBranding/IAbstractIssuanceBrandingStore.js.map +1 -0
  147. package/dist/types/issuanceBranding/issuanceBranding.d.ts +115 -0
  148. package/dist/types/issuanceBranding/issuanceBranding.d.ts.map +1 -0
  149. package/dist/types/issuanceBranding/issuanceBranding.js +3 -0
  150. package/dist/types/issuanceBranding/issuanceBranding.js.map +1 -0
  151. package/package.json +45 -0
  152. package/src/__tests__/contact.entities.test.ts +911 -0
  153. package/src/__tests__/contact.store.test.ts +743 -0
  154. package/src/__tests__/issuanceBranding.entities.test.ts +844 -0
  155. package/src/__tests__/issuanceBranding.store.test.ts +1884 -0
  156. package/src/contact/AbstractContactStore.ts +27 -0
  157. package/src/contact/ContactStore.ts +371 -0
  158. package/src/entities/contact/BaseConfigEntity.ts +8 -0
  159. package/src/entities/contact/ConnectionEntity.ts +48 -0
  160. package/src/entities/contact/ContactEntity.ts +74 -0
  161. package/src/entities/contact/CorrelationIdentifierEntity.ts +41 -0
  162. package/src/entities/contact/DidAuthConfigEntity.ts +31 -0
  163. package/src/entities/contact/IdentityEntity.ts +104 -0
  164. package/src/entities/contact/IdentityMetadataItemEntity.ts +39 -0
  165. package/src/entities/contact/OpenIdConfigEntity.ts +48 -0
  166. package/src/entities/issuanceBranding/BackgroundAttributesEntity.ts +42 -0
  167. package/src/entities/issuanceBranding/BaseLocaleBrandingEntity.ts +86 -0
  168. package/src/entities/issuanceBranding/CredentialBrandingEntity.ts +78 -0
  169. package/src/entities/issuanceBranding/CredentialLocaleBrandingEntity.ts +33 -0
  170. package/src/entities/issuanceBranding/ImageAttributesEntity.ts +57 -0
  171. package/src/entities/issuanceBranding/ImageDimensionsEntity.ts +22 -0
  172. package/src/entities/issuanceBranding/IssuerBrandingEntity.ts +72 -0
  173. package/src/entities/issuanceBranding/IssuerLocaleBrandingEntity.ts +33 -0
  174. package/src/entities/issuanceBranding/TextAttributesEntity.ts +31 -0
  175. package/src/entities/validators/index.ts +16 -0
  176. package/src/index.ts +82 -0
  177. package/src/issuanceBranding/AbstractIssuanceBrandingStore.ts +41 -0
  178. package/src/issuanceBranding/IssuanceBrandingStore.ts +544 -0
  179. package/src/migrations/generic/1-CreateContacts.ts +54 -0
  180. package/src/migrations/generic/1-CreateIssuanceBranding.ts +54 -0
  181. package/src/migrations/generic/index.ts +11 -0
  182. package/src/migrations/index.ts +1 -0
  183. package/src/migrations/internal-migrations-ormconfig.ts +28 -0
  184. package/src/migrations/postgres/1659463079428-CreateContacts.ts +61 -0
  185. package/src/migrations/postgres/1685628974232-CreateIssuanceBranding.ts +83 -0
  186. package/src/migrations/sqlite/1659463069549-CreateContacts.ts +110 -0
  187. package/src/migrations/sqlite/1685628973231-CreateIssuanceBranding.ts +119 -0
  188. package/src/types/contact/IAbstractContactStore.ts +52 -0
  189. package/src/types/contact/contact.ts +101 -0
  190. package/src/types/index.ts +4 -0
  191. package/src/types/issuanceBranding/IAbstractIssuanceBrandingStore.ts +85 -0
  192. package/src/types/issuanceBranding/issuanceBranding.ts +120 -0
@@ -0,0 +1,104 @@
1
+ import {
2
+ BaseEntity,
3
+ CreateDateColumn,
4
+ Entity,
5
+ PrimaryGeneratedColumn,
6
+ UpdateDateColumn,
7
+ OneToOne,
8
+ JoinColumn,
9
+ ManyToOne,
10
+ Column,
11
+ OneToMany,
12
+ BeforeInsert,
13
+ BeforeUpdate,
14
+ } from 'typeorm'
15
+ import { IsNotEmpty, validate, ValidationError } from 'class-validator'
16
+ import { correlationIdentifierEntityFrom, CorrelationIdentifierEntity } from './CorrelationIdentifierEntity'
17
+ import { ConnectionEntity, connectionEntityFrom } from './ConnectionEntity'
18
+ import { IdentityMetadataItemEntity, metadataItemEntityFrom } from './IdentityMetadataItemEntity'
19
+ import { BasicMetadataItem, IBasicIdentity, IdentityRoleEnum } from '../../types'
20
+ import { ContactEntity } from './ContactEntity'
21
+
22
+ @Entity('Identity')
23
+ export class IdentityEntity extends BaseEntity {
24
+ @PrimaryGeneratedColumn('uuid')
25
+ id!: string
26
+
27
+ @Column({
28
+ name: 'alias',
29
+ length: 255,
30
+ nullable: false,
31
+ unique: true,
32
+ })
33
+ @IsNotEmpty({ message: 'Blank aliases are not allowed' })
34
+ alias!: string
35
+
36
+ @Column('simple-array', { name: 'roles', nullable: false })
37
+ roles!: Array<IdentityRoleEnum>
38
+
39
+ @OneToOne(() => CorrelationIdentifierEntity, (identifier: CorrelationIdentifierEntity) => identifier.identity, {
40
+ cascade: true,
41
+ onDelete: 'CASCADE',
42
+ eager: true,
43
+ nullable: false,
44
+ })
45
+ identifier!: CorrelationIdentifierEntity
46
+
47
+ @OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.identity, {
48
+ cascade: true,
49
+ onDelete: 'CASCADE',
50
+ eager: true,
51
+ })
52
+ connection?: ConnectionEntity
53
+
54
+ @OneToMany(() => IdentityMetadataItemEntity, (metadata: IdentityMetadataItemEntity) => metadata.identity, {
55
+ cascade: true,
56
+ onDelete: 'CASCADE',
57
+ eager: true,
58
+ nullable: false,
59
+ })
60
+ @JoinColumn({ name: 'metadataId' })
61
+ metadata!: Array<IdentityMetadataItemEntity>
62
+
63
+ @CreateDateColumn({ name: 'created_at', nullable: false })
64
+ createdAt!: Date
65
+
66
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
67
+ lastUpdatedAt!: Date
68
+
69
+ @ManyToOne(() => ContactEntity, (contact: ContactEntity) => contact.identities, {
70
+ onDelete: 'CASCADE',
71
+ })
72
+ contact!: ContactEntity
73
+
74
+ @Column({ name: 'contactId', nullable: true })
75
+ contactId!: string
76
+
77
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
78
+ @BeforeInsert()
79
+ @BeforeUpdate()
80
+ updateUpdatedDate() {
81
+ this.lastUpdatedAt = new Date()
82
+ }
83
+
84
+ @BeforeInsert()
85
+ @BeforeUpdate()
86
+ async validate() {
87
+ const validation: Array<ValidationError> = await validate(this)
88
+ if (validation.length > 0) {
89
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
90
+ }
91
+ return
92
+ }
93
+ }
94
+
95
+ export const identityEntityFrom = (args: IBasicIdentity): IdentityEntity => {
96
+ const identityEntity = new IdentityEntity()
97
+ identityEntity.alias = args.alias
98
+ identityEntity.roles = args.roles
99
+ identityEntity.identifier = correlationIdentifierEntityFrom(args.identifier)
100
+ identityEntity.connection = args.connection ? connectionEntityFrom(args.connection) : undefined
101
+ identityEntity.metadata = args.metadata ? args.metadata.map((item: BasicMetadataItem) => metadataItemEntityFrom(item)) : []
102
+
103
+ return identityEntity
104
+ }
@@ -0,0 +1,39 @@
1
+ import { Entity, Column, PrimaryGeneratedColumn, BaseEntity, ManyToOne, BeforeInsert, BeforeUpdate } from 'typeorm'
2
+ import { BasicMetadataItem } from '../../types'
3
+ import { IdentityEntity } from './IdentityEntity'
4
+ import { IsNotEmpty, validate, ValidationError } from 'class-validator'
5
+
6
+ @Entity('IdentityMetadata')
7
+ export class IdentityMetadataItemEntity extends BaseEntity {
8
+ @PrimaryGeneratedColumn('uuid')
9
+ id!: string
10
+
11
+ @Column({ name: 'label', length: 255, nullable: false })
12
+ @IsNotEmpty({ message: 'Blank metadata labels are not allowed' })
13
+ label!: string
14
+
15
+ @Column({ name: 'value', length: 255, nullable: false })
16
+ @IsNotEmpty({ message: 'Blank metadata values are not allowed' })
17
+ value!: string
18
+
19
+ @ManyToOne(() => IdentityEntity, (identity: IdentityEntity) => identity.metadata, { cascade: ['insert', 'update'], onDelete: 'CASCADE' })
20
+ identity!: IdentityEntity
21
+
22
+ @BeforeInsert()
23
+ @BeforeUpdate()
24
+ async validate() {
25
+ const validation: Array<ValidationError> = await validate(this)
26
+ if (validation.length > 0) {
27
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
28
+ }
29
+ return
30
+ }
31
+ }
32
+
33
+ export const metadataItemEntityFrom = (item: BasicMetadataItem): IdentityMetadataItemEntity => {
34
+ const metadataItem = new IdentityMetadataItemEntity()
35
+ metadataItem.label = item.label
36
+ metadataItem.value = item.value
37
+
38
+ return metadataItem
39
+ }
@@ -0,0 +1,48 @@
1
+ import { ChildEntity, Column, JoinColumn, OneToOne } from 'typeorm'
2
+ import { BaseConfigEntity } from './BaseConfigEntity'
3
+ import { BasicOpenIdConfig } from '../../types'
4
+ import { ConnectionEntity } from './ConnectionEntity'
5
+
6
+ @ChildEntity('OpenIdConfig')
7
+ export class OpenIdConfigEntity extends BaseConfigEntity {
8
+ @Column({ name: 'client_id', length: 255, nullable: false })
9
+ clientId!: string
10
+
11
+ @Column({ name: 'client_secret', length: 255, nullable: false })
12
+ clientSecret!: string
13
+
14
+ @Column('simple-array', { name: 'scopes', nullable: false })
15
+ scopes!: Array<string>
16
+
17
+ @Column({ name: 'issuer', length: 255, nullable: false })
18
+ issuer!: string
19
+
20
+ @Column('text', { name: 'redirect_url', nullable: false })
21
+ redirectUrl!: string
22
+
23
+ @Column('boolean', { name: 'dangerously_allow_insecure_http_requests', nullable: false })
24
+ dangerouslyAllowInsecureHttpRequests!: boolean
25
+
26
+ @Column('text', { name: 'client_auth_method', nullable: false })
27
+ clientAuthMethod!: 'basic' | 'post' | undefined
28
+
29
+ @OneToOne(() => ConnectionEntity, (connection: ConnectionEntity) => connection.config, {
30
+ cascade: ['insert', 'update'],
31
+ onDelete: 'CASCADE',
32
+ })
33
+ @JoinColumn({ name: 'connectionId' })
34
+ connection?: ConnectionEntity
35
+ }
36
+
37
+ export const openIdConfigEntityFrom = (config: BasicOpenIdConfig): OpenIdConfigEntity => {
38
+ const openIdConfig = new OpenIdConfigEntity()
39
+ openIdConfig.clientId = config.clientId
40
+ openIdConfig.clientSecret = config.clientSecret
41
+ openIdConfig.scopes = config.scopes
42
+ openIdConfig.issuer = config.issuer
43
+ openIdConfig.redirectUrl = config.redirectUrl
44
+ openIdConfig.dangerouslyAllowInsecureHttpRequests = config.dangerouslyAllowInsecureHttpRequests
45
+ openIdConfig.clientAuthMethod = config.clientAuthMethod
46
+
47
+ return openIdConfig
48
+ }
@@ -0,0 +1,42 @@
1
+ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
2
+ import { IBasicBackgroundAttributes } from '../../types'
3
+ import { ImageAttributesEntity, imageAttributesEntityFrom } from './ImageAttributesEntity'
4
+ import { validate, Validate, ValidationError } from 'class-validator'
5
+ import { isEmptyString, IsNonEmptyStringConstraint } from '../validators'
6
+
7
+ @Entity('BackgroundAttributes')
8
+ export class BackgroundAttributesEntity extends BaseEntity {
9
+ @PrimaryGeneratedColumn('uuid')
10
+ id!: string
11
+
12
+ @Column({ name: 'color', length: 255, nullable: true, unique: false })
13
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank background colors are not allowed' })
14
+ color?: string
15
+
16
+ @OneToOne(() => ImageAttributesEntity, {
17
+ cascade: true,
18
+ onDelete: 'CASCADE',
19
+ eager: true,
20
+ nullable: true,
21
+ })
22
+ @JoinColumn({ name: 'imageId' })
23
+ image?: ImageAttributesEntity
24
+
25
+ @BeforeInsert()
26
+ @BeforeUpdate()
27
+ async validate(): Promise<undefined> {
28
+ const validation: Array<ValidationError> = await validate(this)
29
+ if (validation.length > 0) {
30
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
31
+ }
32
+ return
33
+ }
34
+ }
35
+
36
+ export const backgroundAttributesEntityFrom = (args: IBasicBackgroundAttributes): BackgroundAttributesEntity => {
37
+ const backgroundAttributesEntity: BackgroundAttributesEntity = new BackgroundAttributesEntity()
38
+ backgroundAttributesEntity.color = isEmptyString(args.color) ? undefined : args.color
39
+ backgroundAttributesEntity.image = args.image ? imageAttributesEntityFrom(args.image) : undefined
40
+
41
+ return backgroundAttributesEntity
42
+ }
@@ -0,0 +1,86 @@
1
+ import {
2
+ BaseEntity,
3
+ BeforeInsert,
4
+ BeforeUpdate,
5
+ Column,
6
+ CreateDateColumn,
7
+ Entity,
8
+ JoinColumn,
9
+ OneToOne,
10
+ PrimaryGeneratedColumn,
11
+ TableInheritance,
12
+ UpdateDateColumn,
13
+ } from 'typeorm'
14
+ import { ImageAttributesEntity } from './ImageAttributesEntity'
15
+ import { BackgroundAttributesEntity } from './BackgroundAttributesEntity'
16
+ import { TextAttributesEntity } from './TextAttributesEntity'
17
+ import { validate, Validate, ValidationError } from 'class-validator'
18
+ import { IsNonEmptyStringConstraint } from '../validators'
19
+
20
+ @Entity('BaseLocaleBranding')
21
+ @TableInheritance({ column: { type: 'varchar', name: 'type' } })
22
+ export class BaseLocaleBrandingEntity extends BaseEntity {
23
+ @PrimaryGeneratedColumn('uuid')
24
+ id!: string
25
+
26
+ @Column({ name: 'alias', length: 255, nullable: true, unique: false })
27
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank aliases are not allowed' })
28
+ alias?: string
29
+
30
+ @Column({ name: 'locale', length: 255, nullable: false, unique: false })
31
+ locale?: string
32
+
33
+ @OneToOne(() => ImageAttributesEntity, {
34
+ cascade: true,
35
+ onDelete: 'CASCADE',
36
+ eager: true,
37
+ nullable: true,
38
+ })
39
+ @JoinColumn({ name: 'logoId' })
40
+ logo?: ImageAttributesEntity
41
+
42
+ @Column({ name: 'description', length: 255, nullable: true, unique: false })
43
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank descriptions are not allowed' })
44
+ description?: string
45
+
46
+ @OneToOne(() => BackgroundAttributesEntity, {
47
+ cascade: true,
48
+ onDelete: 'CASCADE',
49
+ eager: true,
50
+ nullable: true,
51
+ })
52
+ @JoinColumn({ name: 'backgroundId' })
53
+ background?: BackgroundAttributesEntity
54
+
55
+ @OneToOne(() => TextAttributesEntity, {
56
+ cascade: true,
57
+ onDelete: 'CASCADE',
58
+ eager: true,
59
+ nullable: true,
60
+ })
61
+ @JoinColumn({ name: 'textId' })
62
+ text?: TextAttributesEntity
63
+
64
+ @CreateDateColumn({ name: 'created_at', nullable: false })
65
+ createdAt!: Date
66
+
67
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
68
+ lastUpdatedAt!: Date
69
+
70
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
71
+ @BeforeInsert()
72
+ @BeforeUpdate()
73
+ updateUpdatedDate(): void {
74
+ this.lastUpdatedAt = new Date()
75
+ }
76
+
77
+ @BeforeInsert()
78
+ @BeforeUpdate()
79
+ async validate(): Promise<undefined> {
80
+ const validation: Array<ValidationError> = await validate(this)
81
+ if (validation.length > 0) {
82
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
83
+ }
84
+ return
85
+ }
86
+ }
@@ -0,0 +1,78 @@
1
+ import {
2
+ BaseEntity,
3
+ BeforeInsert,
4
+ BeforeUpdate,
5
+ Column,
6
+ CreateDateColumn,
7
+ Entity,
8
+ Index,
9
+ OneToMany,
10
+ PrimaryGeneratedColumn,
11
+ UpdateDateColumn,
12
+ } from 'typeorm'
13
+ import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
14
+ import { CredentialLocaleBrandingEntity, credentialLocaleBrandingEntityFrom } from './CredentialLocaleBrandingEntity'
15
+ import { IBasicCredentialBranding, IBasicCredentialLocaleBranding } from '../../types'
16
+
17
+ @Entity('CredentialBranding')
18
+ @Index('IDX_CredentialBrandingEntity_vcHash', ['vcHash'])
19
+ @Index('IDX_CredentialBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
20
+ export class CredentialBrandingEntity extends BaseEntity {
21
+ @PrimaryGeneratedColumn('uuid')
22
+ id!: string
23
+
24
+ @Column({ name: 'vcHash', length: 255, nullable: false, unique: true })
25
+ @IsNotEmpty({ message: 'Blank vcHashes are not allowed' })
26
+ vcHash!: string
27
+
28
+ @Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: false })
29
+ @IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
30
+ issuerCorrelationId!: string
31
+
32
+ @OneToMany(
33
+ () => CredentialLocaleBrandingEntity,
34
+ (credentialLocaleBrandingEntity: CredentialLocaleBrandingEntity) => credentialLocaleBrandingEntity.credentialBranding,
35
+ {
36
+ cascade: true,
37
+ onDelete: 'CASCADE',
38
+ eager: true,
39
+ nullable: false,
40
+ }
41
+ )
42
+ @ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
43
+ localeBranding!: Array<CredentialLocaleBrandingEntity>
44
+
45
+ @CreateDateColumn({ name: 'created_at', nullable: false })
46
+ createdAt!: Date
47
+
48
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
49
+ lastUpdatedAt!: Date
50
+
51
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
52
+ @BeforeInsert()
53
+ @BeforeUpdate()
54
+ updateUpdatedDate(): void {
55
+ this.lastUpdatedAt = new Date()
56
+ }
57
+
58
+ @BeforeInsert()
59
+ @BeforeUpdate()
60
+ async validate(): Promise<undefined> {
61
+ const validation: Array<ValidationError> = await validate(this)
62
+ if (validation.length > 0) {
63
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
64
+ }
65
+ return
66
+ }
67
+ }
68
+
69
+ export const credentialBrandingEntityFrom = (args: IBasicCredentialBranding): CredentialBrandingEntity => {
70
+ const credentialBrandingEntity: CredentialBrandingEntity = new CredentialBrandingEntity()
71
+ credentialBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
72
+ credentialBrandingEntity.vcHash = args.vcHash
73
+ credentialBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicCredentialLocaleBranding) =>
74
+ credentialLocaleBrandingEntityFrom(localeBranding)
75
+ )
76
+
77
+ return credentialBrandingEntity
78
+ }
@@ -0,0 +1,33 @@
1
+ import { ChildEntity, Column, JoinColumn, ManyToOne, Index } from 'typeorm'
2
+ import { IBasicCredentialLocaleBranding } from '../../types'
3
+ import { backgroundAttributesEntityFrom } from './BackgroundAttributesEntity'
4
+ import { CredentialBrandingEntity } from './CredentialBrandingEntity'
5
+ import { imageAttributesEntityFrom } from './ImageAttributesEntity'
6
+ import { BaseLocaleBrandingEntity } from './BaseLocaleBrandingEntity'
7
+ import { textAttributesEntityFrom } from './TextAttributesEntity'
8
+ import { isEmptyString } from '../validators'
9
+
10
+ @ChildEntity('CredentialLocaleBranding')
11
+ @Index('IDX_CredentialLocaleBrandingEntity_credentialBranding_locale', ['credentialBranding', 'locale'], { unique: true })
12
+ export class CredentialLocaleBrandingEntity extends BaseLocaleBrandingEntity {
13
+ @ManyToOne(() => CredentialBrandingEntity, (credentialBranding: CredentialBrandingEntity) => credentialBranding.localeBranding, {
14
+ onDelete: 'CASCADE',
15
+ })
16
+ @JoinColumn({ name: 'credentialBrandingId' })
17
+ credentialBranding!: CredentialBrandingEntity
18
+
19
+ @Column({ name: 'credentialBrandingId', nullable: false })
20
+ credentialBrandingId!: string
21
+ }
22
+
23
+ export const credentialLocaleBrandingEntityFrom = (args: IBasicCredentialLocaleBranding): CredentialLocaleBrandingEntity => {
24
+ const credentialLocaleBrandingEntity: CredentialLocaleBrandingEntity = new CredentialLocaleBrandingEntity()
25
+ credentialLocaleBrandingEntity.alias = isEmptyString(args.alias) ? undefined : args.alias
26
+ credentialLocaleBrandingEntity.locale = args.locale ? args.locale : ''
27
+ credentialLocaleBrandingEntity.logo = args.logo ? imageAttributesEntityFrom(args.logo) : undefined
28
+ credentialLocaleBrandingEntity.description = isEmptyString(args.description) ? undefined : args.description
29
+ credentialLocaleBrandingEntity.background = args.background ? backgroundAttributesEntityFrom(args.background) : undefined
30
+ credentialLocaleBrandingEntity.text = args.text ? textAttributesEntityFrom(args.text) : undefined
31
+
32
+ return credentialLocaleBrandingEntity
33
+ }
@@ -0,0 +1,57 @@
1
+ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, JoinColumn, OneToOne, PrimaryGeneratedColumn } from 'typeorm'
2
+ import { IBasicImageAttributes } from '../../types'
3
+ import { ImageDimensionsEntity, imageDimensionsEntityFrom } from './ImageDimensionsEntity'
4
+ import { validate, Validate, ValidationError } from 'class-validator'
5
+ import { isEmptyString, IsNonEmptyStringConstraint } from '../validators'
6
+
7
+ @Entity('ImageAttributes')
8
+ export class ImageAttributesEntity extends BaseEntity {
9
+ @PrimaryGeneratedColumn('uuid')
10
+ id!: string
11
+
12
+ @Column({ name: 'uri', length: 255, nullable: true, unique: false })
13
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank image uri are not allowed' })
14
+ uri?: string
15
+
16
+ @Column({ name: 'dataUri', length: 255, nullable: true, unique: false })
17
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank image data uri are not allowed' })
18
+ dataUri?: string
19
+
20
+ @Column({ name: 'mediaType', length: 255, nullable: true, unique: false })
21
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank image types are not allowed' })
22
+ mediaType?: string
23
+
24
+ @Column({ name: 'alt', length: 255, nullable: true, unique: false })
25
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank image alts are not allowed' })
26
+ alt?: string
27
+
28
+ @OneToOne(() => ImageDimensionsEntity, {
29
+ cascade: true,
30
+ onDelete: 'CASCADE',
31
+ eager: true,
32
+ nullable: true,
33
+ })
34
+ @JoinColumn({ name: 'dimensionsId' })
35
+ dimensions?: ImageDimensionsEntity
36
+
37
+ @BeforeInsert()
38
+ @BeforeUpdate()
39
+ async validate(): Promise<undefined> {
40
+ const validation: Array<ValidationError> = await validate(this)
41
+ if (validation.length > 0) {
42
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
43
+ }
44
+ return
45
+ }
46
+ }
47
+
48
+ export const imageAttributesEntityFrom = (args: IBasicImageAttributes): ImageAttributesEntity => {
49
+ const imageAttributesEntity: ImageAttributesEntity = new ImageAttributesEntity()
50
+ imageAttributesEntity.uri = isEmptyString(args.uri) ? undefined : args.uri
51
+ imageAttributesEntity.dataUri = isEmptyString(args.dataUri) ? undefined : args.dataUri
52
+ imageAttributesEntity.mediaType = isEmptyString(args.mediaType) ? undefined : args.mediaType
53
+ imageAttributesEntity.alt = isEmptyString(args.alt) ? undefined : args.alt
54
+ imageAttributesEntity.dimensions = args.dimensions ? imageDimensionsEntityFrom(args.dimensions) : undefined
55
+
56
+ return imageAttributesEntity
57
+ }
@@ -0,0 +1,22 @@
1
+ import { BaseEntity, Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
2
+ import { IBasicImageDimensions } from '../../types'
3
+
4
+ @Entity('ImageDimensions')
5
+ export class ImageDimensionsEntity extends BaseEntity {
6
+ @PrimaryGeneratedColumn('uuid')
7
+ id!: string
8
+
9
+ @Column({ name: 'width', nullable: false, unique: false })
10
+ width!: number
11
+
12
+ @Column({ name: 'height', nullable: false, unique: false })
13
+ height!: number
14
+ }
15
+
16
+ export const imageDimensionsEntityFrom = (args: IBasicImageDimensions): ImageDimensionsEntity => {
17
+ const imageDimensionsEntity: ImageDimensionsEntity = new ImageDimensionsEntity()
18
+ imageDimensionsEntity.width = args.width
19
+ imageDimensionsEntity.height = args.height
20
+
21
+ return imageDimensionsEntity
22
+ }
@@ -0,0 +1,72 @@
1
+ import {
2
+ BaseEntity,
3
+ BeforeInsert,
4
+ BeforeUpdate,
5
+ Column,
6
+ CreateDateColumn,
7
+ Entity,
8
+ Index,
9
+ OneToMany,
10
+ PrimaryGeneratedColumn,
11
+ UpdateDateColumn,
12
+ } from 'typeorm'
13
+ import { ArrayMinSize, IsNotEmpty, validate, ValidationError } from 'class-validator'
14
+ import { IssuerLocaleBrandingEntity, issuerLocaleBrandingEntityFrom } from './IssuerLocaleBrandingEntity'
15
+ import { IBasicIssuerBranding, IBasicIssuerLocaleBranding } from '../../types'
16
+
17
+ @Entity('IssuerBranding')
18
+ @Index('IDX_IssuerBrandingEntity_issuerCorrelationId', ['issuerCorrelationId'])
19
+ export class IssuerBrandingEntity extends BaseEntity {
20
+ @PrimaryGeneratedColumn('uuid')
21
+ id!: string
22
+
23
+ @Column({ name: 'issuerCorrelationId', length: 255, nullable: false, unique: true })
24
+ @IsNotEmpty({ message: 'Blank issuerCorrelationIds are not allowed' })
25
+ issuerCorrelationId!: string
26
+
27
+ @OneToMany(
28
+ () => IssuerLocaleBrandingEntity,
29
+ (issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity) => issuerLocaleBrandingEntity.issuerBranding,
30
+ {
31
+ cascade: true,
32
+ onDelete: 'CASCADE',
33
+ eager: true,
34
+ nullable: false,
35
+ }
36
+ )
37
+ @ArrayMinSize(1, { message: 'localeBranding cannot be empty' })
38
+ localeBranding!: Array<IssuerLocaleBrandingEntity>
39
+
40
+ @CreateDateColumn({ name: 'created_at', nullable: false })
41
+ createdAt!: Date
42
+
43
+ @UpdateDateColumn({ name: 'last_updated_at', nullable: false })
44
+ lastUpdatedAt!: Date
45
+
46
+ // By default, @UpdateDateColumn in TypeORM updates the timestamp only when the entity's top-level properties change.
47
+ @BeforeInsert()
48
+ @BeforeUpdate()
49
+ updateUpdatedDate(): void {
50
+ this.lastUpdatedAt = new Date()
51
+ }
52
+
53
+ @BeforeInsert()
54
+ @BeforeUpdate()
55
+ async validate(): Promise<undefined> {
56
+ const validation: Array<ValidationError> = await validate(this)
57
+ if (validation.length > 0) {
58
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
59
+ }
60
+ return
61
+ }
62
+ }
63
+
64
+ export const issuerBrandingEntityFrom = (args: IBasicIssuerBranding): IssuerBrandingEntity => {
65
+ const issuerBrandingEntity: IssuerBrandingEntity = new IssuerBrandingEntity()
66
+ issuerBrandingEntity.issuerCorrelationId = args.issuerCorrelationId
67
+ issuerBrandingEntity.localeBranding = args.localeBranding.map((localeBranding: IBasicIssuerLocaleBranding) =>
68
+ issuerLocaleBrandingEntityFrom(localeBranding)
69
+ )
70
+
71
+ return issuerBrandingEntity
72
+ }
@@ -0,0 +1,33 @@
1
+ import { ChildEntity, Column, Index, JoinColumn, ManyToOne } from 'typeorm'
2
+ import { IBasicIssuerLocaleBranding } from '../../types'
3
+ import { backgroundAttributesEntityFrom } from './BackgroundAttributesEntity'
4
+ import { imageAttributesEntityFrom } from './ImageAttributesEntity'
5
+ import { IssuerBrandingEntity } from './IssuerBrandingEntity'
6
+ import { BaseLocaleBrandingEntity } from './BaseLocaleBrandingEntity'
7
+ import { textAttributesEntityFrom } from './TextAttributesEntity'
8
+ import { isEmptyString } from '../validators'
9
+
10
+ @ChildEntity('IssuerLocaleBranding')
11
+ @Index('IDX_IssuerLocaleBrandingEntity_issuerBranding_locale', ['issuerBranding', 'locale'], { unique: true })
12
+ export class IssuerLocaleBrandingEntity extends BaseLocaleBrandingEntity {
13
+ @ManyToOne(() => IssuerBrandingEntity, (issuerBranding: IssuerBrandingEntity) => issuerBranding.localeBranding, {
14
+ onDelete: 'CASCADE',
15
+ })
16
+ @JoinColumn({ name: 'issuerBrandingId' })
17
+ issuerBranding!: IssuerBrandingEntity
18
+
19
+ @Column({ name: 'issuerBrandingId', nullable: false })
20
+ issuerBrandingId!: string
21
+ }
22
+
23
+ export const issuerLocaleBrandingEntityFrom = (args: IBasicIssuerLocaleBranding): IssuerLocaleBrandingEntity => {
24
+ const issuerLocaleBrandingEntity: IssuerLocaleBrandingEntity = new IssuerLocaleBrandingEntity()
25
+ issuerLocaleBrandingEntity.alias = isEmptyString(args.alias) ? undefined : args.alias
26
+ issuerLocaleBrandingEntity.locale = args.locale ? args.locale : ''
27
+ issuerLocaleBrandingEntity.logo = args.logo ? imageAttributesEntityFrom(args.logo) : undefined
28
+ issuerLocaleBrandingEntity.description = isEmptyString(args.description) ? undefined : args.description
29
+ issuerLocaleBrandingEntity.background = args.background ? backgroundAttributesEntityFrom(args.background) : undefined
30
+ issuerLocaleBrandingEntity.text = args.text ? textAttributesEntityFrom(args.text) : undefined
31
+
32
+ return issuerLocaleBrandingEntity
33
+ }
@@ -0,0 +1,31 @@
1
+ import { BaseEntity, BeforeInsert, BeforeUpdate, Column, Entity, PrimaryGeneratedColumn } from 'typeorm'
2
+ import { IBasicTextAttributes } from '../../types'
3
+ import { validate, Validate, ValidationError } from 'class-validator'
4
+ import { isEmptyString, IsNonEmptyStringConstraint } from '../validators'
5
+
6
+ @Entity('TextAttributes')
7
+ export class TextAttributesEntity extends BaseEntity {
8
+ @PrimaryGeneratedColumn('uuid')
9
+ id!: string
10
+
11
+ @Column({ name: 'color', length: 255, nullable: true, unique: false })
12
+ @Validate(IsNonEmptyStringConstraint, { message: 'Blank text colors are not allowed' })
13
+ color?: string
14
+
15
+ @BeforeInsert()
16
+ @BeforeUpdate()
17
+ async validate(): Promise<undefined> {
18
+ const validation: Array<ValidationError> = await validate(this)
19
+ if (validation.length > 0) {
20
+ return Promise.reject(Error(Object.values(validation[0].constraints!)[0]))
21
+ }
22
+ return
23
+ }
24
+ }
25
+
26
+ export const textAttributesEntityFrom = (args: IBasicTextAttributes): TextAttributesEntity => {
27
+ const textAttributesEntity: TextAttributesEntity = new TextAttributesEntity()
28
+ textAttributesEntity.color = isEmptyString(args.color) ? undefined : args.color
29
+
30
+ return textAttributesEntity
31
+ }
@@ -0,0 +1,16 @@
1
+ import { ValidationArguments, ValidatorConstraint, ValidatorConstraintInterface } from 'class-validator'
2
+
3
+ @ValidatorConstraint({ name: 'isNonEmptyString', async: false })
4
+ export class IsNonEmptyStringConstraint implements ValidatorConstraintInterface {
5
+ validate(value: string, args: ValidationArguments): boolean {
6
+ return !isEmptyString(value)
7
+ }
8
+
9
+ defaultMessage(args: ValidationArguments): string {
10
+ return `${args.property} must not be an empty string.`
11
+ }
12
+ }
13
+
14
+ export const isEmptyString = (value: any): boolean => {
15
+ return typeof value === 'string' && value.trim().length === 0
16
+ }