@owf/eudi-wrprc 0.0.0

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/README.md ADDED
@@ -0,0 +1,264 @@
1
+ # @owf/eudi-wrprc
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@owf/eudi-wrprc)](https://npmjs.com/package/@owf/eudi-wrprc)
4
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE)
5
+
6
+ Implementation of **ETSI TS 119 475 v1.2.1** - Wallet-Relying Party Registration Certificates (WRPRC) for [Identity Common TypeScript](https://github.com/openwallet-foundation-labs/identity-common-ts).
7
+
8
+ ## Overview
9
+
10
+ This package provides:
11
+
12
+ - **Zod schemas** for validating WRPRC payloads and headers
13
+ - **TypeScript types** derived from the schemas
14
+ - **Entitlement constants** per ETSI TS 119 475 Annex A
15
+ - **Fluent builder API** for creating WRPRC payloads
16
+ - **Validators** implementing ETSI requirements
17
+ - **Signer** for creating signed JWT WRPRCs
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ # Using npm
23
+ npm install @owf/eudi-wrprc
24
+
25
+ # Using pnpm
26
+ pnpm add @owf/eudi-wrprc
27
+
28
+ # Using yarn
29
+ yarn add @owf/eudi-wrprc
30
+ ```
31
+
32
+ ## Usage
33
+
34
+ ### Creating a WRPRC with the Fluent Builder
35
+
36
+ ```typescript
37
+ import { wrprc, WRP_ENTITLEMENTS } from '@owf/eudi-wrprc'
38
+
39
+ const payload = wrprc()
40
+ .name('Example Service')
41
+ .legalName('Example Inc.')
42
+ .identifier('LEIXG-529900T8BM49AURSDO55')
43
+ .country('DE')
44
+ .registryUri('https://registry.example.com/api')
45
+ .addEntitlement(WRP_ENTITLEMENTS.SERVICE_PROVIDER)
46
+ .addEntitlement(WRP_ENTITLEMENTS.QEAA_PROVIDER)
47
+ .privacyPolicy('https://example.com/privacy')
48
+ .build()
49
+ ```
50
+
51
+ ### Creating a WRPRC for a Natural Person
52
+
53
+ ```typescript
54
+ import { wrprc, WRP_ENTITLEMENTS } from '@owf/eudi-wrprc'
55
+
56
+ const payload = wrprc()
57
+ .name('Self-Employed Consultant')
58
+ .givenName('Maria')
59
+ .familyName('Rossi')
60
+ .identifier('TINIT-RSSMRA85T10A562S')
61
+ .country('IT')
62
+ .registryUri('https://registry.example.it/api')
63
+ .addEntitlement(WRP_ENTITLEMENTS.SERVICE_PROVIDER)
64
+ .build()
65
+ ```
66
+
67
+ ### Using Factory Functions
68
+
69
+ ```typescript
70
+ import { createLegalPersonWRPRC, WRP_ENTITLEMENTS } from '@owf/eudi-wrprc'
71
+
72
+ const payload = createLegalPersonWRPRC({
73
+ name: 'Example Service',
74
+ legalName: 'Example Inc.',
75
+ identifier: 'LEIXG-529900T8BM49AURSDO55',
76
+ country: 'DE',
77
+ registryUri: 'https://registry.example.com/api',
78
+ entitlements: [WRP_ENTITLEMENTS.SERVICE_PROVIDER],
79
+ })
80
+ ```
81
+
82
+ ### Specifying Credentials to Request
83
+
84
+ ```typescript
85
+ import { wrprc, credential, WRP_ENTITLEMENTS } from '@owf/eudi-wrprc'
86
+
87
+ const payload = wrprc()
88
+ .name('Verification Service')
89
+ .legalName('VerifyCo Ltd.')
90
+ .identifier('LEIXG-123456789ABCDEFGH')
91
+ .country('NL')
92
+ .registryUri('https://registry.example.nl/api')
93
+ .addEntitlement(WRP_ENTITLEMENTS.SERVICE_PROVIDER)
94
+ .addCredential(
95
+ credential()
96
+ .format('dc+sd-jwt')
97
+ .meta({ vct: 'https://example.com/credentials/identity' })
98
+ .addPathClaim('given_name')
99
+ .addPathClaim('family_name')
100
+ .build()
101
+ )
102
+ .build()
103
+ ```
104
+
105
+ ### Signing a WRPRC
106
+
107
+ ```typescript
108
+ import { signWRPRC, wrprc, WRP_ENTITLEMENTS } from '@owf/eudi-wrprc'
109
+ import { getSigner } from '@owf/crypto'
110
+
111
+ const payload = wrprc()
112
+ .name('Example Service')
113
+ .legalName('Example Inc.')
114
+ .identifier('LEIXG-529900T8BM49AURSDO55')
115
+ .country('DE')
116
+ .registryUri('https://registry.example.com/api')
117
+ .addEntitlement(WRP_ENTITLEMENTS.SERVICE_PROVIDER)
118
+ .build()
119
+
120
+ const signer = await ES256.getSigner(privateKeyJWK)
121
+
122
+ const signed = await signWRPRC({
123
+ payload,
124
+ algorithm: 'ES256',
125
+ certificates: [certificatePEM],
126
+ signer,
127
+ })
128
+
129
+ console.log(signed.jws) // Compact JWS string
130
+ ```
131
+
132
+ ### Decoding a WRPRC
133
+
134
+ ```typescript
135
+ import { decodeWRPRC } from '@owf/eudi-wrprc'
136
+
137
+ const jwsString = 'eyJ0eXAiOiJyYy13cnArand0Ii...'
138
+ const decoded = decodeWRPRC(jwsString)
139
+
140
+ console.log(decoded.header) // { typ: 'rc-wrp+jwt', alg: 'ES256', ... }
141
+ console.log(decoded.payload) // { name: '...', sub: '...', ... }
142
+ ```
143
+
144
+ ### Validating a WRPRC
145
+
146
+ ```typescript
147
+ import { validateWRPRCPayload } from '@owf/eudi-wrprc'
148
+
149
+ const result = validateWRPRCPayload(payload)
150
+
151
+ if (result.valid) {
152
+ console.log('WRPRC is valid')
153
+ } else {
154
+ console.log('Errors:', result.errors)
155
+ }
156
+
157
+ // Warnings are returned even for valid payloads
158
+ if (result.warnings.length > 0) {
159
+ console.log('Warnings:', result.warnings)
160
+ }
161
+ ```
162
+
163
+ ### Entitlement Constants
164
+
165
+ The package exports all entitlement URIs from ETSI TS 119 475 Annex A:
166
+
167
+ ```typescript
168
+ import { WRP_ENTITLEMENTS, PSP_SUB_ENTITLEMENTS } from '@owf/eudi-wrprc'
169
+
170
+ // Main entitlements
171
+ WRP_ENTITLEMENTS.SERVICE_PROVIDER // Basic service provider
172
+ WRP_ENTITLEMENTS.QEAA_PROVIDER // Qualified EAA provider
173
+ WRP_ENTITLEMENTS.NON_Q_EAA_PROVIDER // Non-qualified EAA provider
174
+ WRP_ENTITLEMENTS.PUB_EAA_PROVIDER // Public EAA provider
175
+ WRP_ENTITLEMENTS.PID_PROVIDER // Person Identification Data provider
176
+ WRP_ENTITLEMENTS.QCERT_FOR_ESEAL_PROVIDER // Qualified cert for e-seal issuer
177
+ WRP_ENTITLEMENTS.QCERT_FOR_ESIG_PROVIDER // Qualified cert for e-sig issuer
178
+ WRP_ENTITLEMENTS.RQSEALCDS_PROVIDER // Remote qualified seal creation device
179
+ WRP_ENTITLEMENTS.RQSIGCDS_PROVIDER // Remote qualified sig creation device
180
+ WRP_ENTITLEMENTS.ESIG_ESEAL_CREATION_PROVIDER // Non-qualified e-sig/seal creation
181
+
182
+ // PSP sub-entitlements (require SERVICE_PROVIDER)
183
+ PSP_SUB_ENTITLEMENTS.PAYMENT_INITIATION // Payment initiation services
184
+ PSP_SUB_ENTITLEMENTS.ACCOUNT_INFORMATION // Account information services
185
+ PSP_SUB_ENTITLEMENTS.ACCOUNT_SERVICING // Account servicing provider
186
+ PSP_SUB_ENTITLEMENTS.CARD_BASED // Card-based payment instruments
187
+ ```
188
+
189
+ ## ETSI TS 119 475 Compliance
190
+
191
+ This implementation follows ETSI TS 119 475 v1.2.1 requirements:
192
+
193
+ - **GEN-5.2.2**: JWT/CWT headers with `typ: "rc-wrp+jwt"` or `typ: "rc-wrp+cwt"`
194
+ - **GEN-5.2.4-03**: At least one entitlement must be specified
195
+ - **GEN-5.2.4-04**: Sub-entitlements require the base entitlement
196
+ - **GEN-5.2.4-05**: Attestation providers should specify `provides_attestations`
197
+
198
+ ### Semantic Identifiers
199
+
200
+ Subject identifiers (`sub`) follow ETSI EN 319 412-1:
201
+
202
+ | Type | Prefix | Country | Example |
203
+ |------|--------|---------|---------|
204
+ | LEI | `LEI` | `XG` | `LEIXG-529900T8BM49AURSDO55` |
205
+ | VAT | `VAT` | 2-letter | `VATDE-123456789` |
206
+ | TIN | `TIN` | 2-letter | `TINIT-RSSMRA85T10A562S` |
207
+ | NTR | `NTR` | 2-letter | `NTRNL-12345678` |
208
+ | PAS | `PAS` | 2-letter | `PASDE-C01X00T47` |
209
+ | IDC | `IDC` | 2-letter | `IDCIT-AX1234567` |
210
+
211
+ ## Platform Support
212
+
213
+ This library is **platform agnostic** and works in:
214
+
215
+ - ✅ Node.js (>=20)
216
+ - ✅ Browsers (modern browsers with ES2020 support)
217
+ - ✅ React Native
218
+
219
+ ## API Reference
220
+
221
+ ### Schemas
222
+
223
+ - `WRPRCPayloadSchema` - Full WRPRC payload validation
224
+ - `WRPRCJWTHeaderSchema` - JWT header validation
225
+ - `WRPRCCWTHeaderSchema` - CWT header validation
226
+ - `CredentialSchema` - Credential specification validation
227
+ - `ClaimSchema` - Claim specification validation
228
+ - `MultiLangStringSchema` - Multilingual string validation
229
+
230
+ ### Types
231
+
232
+ - `WRPRCPayload` - WRPRC payload type
233
+ - `WRPRCJWTHeader` - JWT header type
234
+ - `SignedWRPRC` - Signed WRPRC with JWS string
235
+ - `Credential` - Credential specification type
236
+ - `Claim` - Claim specification type
237
+
238
+ ### Builders
239
+
240
+ - `WRPRCBuilder` - Fluent builder for WRPRC payloads
241
+ - `CredentialBuilder` - Fluent builder for credential specifications
242
+ - `wrprc()` - Factory function for WRPRCBuilder
243
+ - `credential()` - Factory function for CredentialBuilder
244
+
245
+ ### Validators
246
+
247
+ - `validateWRPRCPayload(payload)` - Validate WRPRC payload
248
+ - `validateWRPRCJWTHeader(header)` - Validate JWT header
249
+ - `validateWRPRC(header, payload)` - Validate complete WRPRC
250
+ - `assertValidWRPRCPayload(payload)` - Assert or throw
251
+
252
+ ### Signer
253
+
254
+ - `signWRPRC(options)` - Sign a WRPRC payload to JWT
255
+ - `decodeWRPRC(jws)` - Decode a signed WRPRC
256
+ - `parseWRPRC(jws)` - Parse without validation
257
+
258
+ ## Contributing
259
+
260
+ See the [Contributing Guide](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/CONTRIBUTING.md) for details on how to contribute to this project.
261
+
262
+ ## License
263
+
264
+ This project is licensed under the [Apache License Version 2.0](https://github.com/openwallet-foundation-labs/identity-common-ts/blob/main/LICENSE) (Apache-2.0).