@pagopa/io-wallet-oid-federation 0.4.1 → 0.5.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 +52 -49
- package/dist/index.d.mts +35747 -0
- package/dist/index.d.ts +35747 -0
- package/dist/index.js +177 -178
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +152 -166
- package/dist/index.mjs.map +1 -1
- package/package.json +8 -8
package/README.md
CHANGED
|
@@ -35,27 +35,33 @@ The primary function of this package is `createItWalletEntityConfiguration`. It
|
|
|
35
35
|
Here is an example of how to create an Entity Configuration for a Credential Issuer:
|
|
36
36
|
|
|
37
37
|
```javascript
|
|
38
|
-
import {
|
|
39
|
-
|
|
38
|
+
import {
|
|
39
|
+
createItWalletEntityConfiguration,
|
|
40
|
+
SignCallback,
|
|
41
|
+
} from "@pagopa/io-wallet-oid-federation";
|
|
40
42
|
|
|
41
|
-
// Define your entity's base URL and
|
|
43
|
+
// Define your entity's base URL and public JWK
|
|
42
44
|
const baseURL = "https://issuer.example.it";
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
+
const publicJwk = {
|
|
46
|
+
kty: "EC",
|
|
47
|
+
crv: "P-256",
|
|
48
|
+
x: "...",
|
|
49
|
+
y: "...",
|
|
50
|
+
kid: "key-1",
|
|
45
51
|
};
|
|
46
|
-
const jwk = jwksRepository.get();
|
|
47
52
|
|
|
48
53
|
// Define a signing callback that uses your private key
|
|
49
54
|
const signJwtCallback: SignCallback = async ({ toBeSigned, jwk }) => {
|
|
50
|
-
// Your signing logic here
|
|
51
|
-
|
|
55
|
+
// Your signing logic here using the jwk parameter
|
|
56
|
+
// Return the signature as Uint8Array
|
|
57
|
+
// ...
|
|
52
58
|
};
|
|
53
59
|
|
|
54
60
|
// Create the Entity Configuration JWT
|
|
55
61
|
const entityConfigurationJwt = await createItWalletEntityConfiguration({
|
|
56
62
|
header: {
|
|
57
63
|
alg: "ES256",
|
|
58
|
-
kid:
|
|
64
|
+
kid: publicJwk.kid,
|
|
59
65
|
typ: "entity-statement+jwt",
|
|
60
66
|
},
|
|
61
67
|
claims: {
|
|
@@ -64,7 +70,7 @@ const entityConfigurationJwt = await createItWalletEntityConfiguration({
|
|
|
64
70
|
exp: Math.floor(Date.now() / 1000) + 3600, // Expires in 1 hour
|
|
65
71
|
iat: Math.floor(Date.now() / 1000),
|
|
66
72
|
jwks: {
|
|
67
|
-
keys: [
|
|
73
|
+
keys: [publicJwk],
|
|
68
74
|
},
|
|
69
75
|
authority_hints: [`${baseURL}/trust_anchor`],
|
|
70
76
|
metadata: {
|
|
@@ -91,63 +97,60 @@ console.log(entityConfigurationJwt);
|
|
|
91
97
|
// This JWT can now be served at `https://issuer.example.it/.well-known/openid-federation`
|
|
92
98
|
```
|
|
93
99
|
|
|
94
|
-
|
|
100
|
+
## API Reference
|
|
95
101
|
|
|
96
|
-
|
|
102
|
+
### Functions
|
|
97
103
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
104
|
+
- **`createItWalletEntityConfiguration(options)`**: Creates and signs an Entity Configuration JWT.
|
|
105
|
+
- **Parameters**:
|
|
106
|
+
- `options.header`: JWT header with algorithm, key id, and type
|
|
107
|
+
- `options.claims`: Entity configuration claims (issuer, subject, metadata, etc.)
|
|
108
|
+
- `options.signJwtCallback`: Callback function to sign the JWT
|
|
109
|
+
- **Returns**: A signed JWT string
|
|
103
110
|
|
|
104
|
-
|
|
105
|
-
const federationResponsePayload = {
|
|
106
|
-
/* ... decoded claims ... */
|
|
107
|
-
};
|
|
111
|
+
### Types
|
|
108
112
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
)
|
|
115
|
-
|
|
116
|
-
console.log("Validation successful:", federationEntity);
|
|
117
|
-
} catch (error) {
|
|
118
|
-
console.error("Validation failed:", error.message);
|
|
119
|
-
}
|
|
120
|
-
```
|
|
113
|
+
- **`SignCallback`**: Function type for signing JWT tokens
|
|
114
|
+
```typescript
|
|
115
|
+
type SignCallback = (options: {
|
|
116
|
+
jwk: JsonWebKey;
|
|
117
|
+
toBeSigned: Uint8Array;
|
|
118
|
+
}) => Promise<Uint8Array>;
|
|
119
|
+
```
|
|
121
120
|
|
|
122
|
-
|
|
121
|
+
- **`JsonWebKey`**: Type for JSON Web Key objects
|
|
123
122
|
|
|
124
|
-
|
|
123
|
+
- **`ItWalletEntityConfigurationClaimsOptions`**: Input type for entity configuration claims
|
|
124
|
+
|
|
125
|
+
- **`ItWalletEntityConfigurationClaims`**: Output type for entity configuration claims
|
|
125
126
|
|
|
126
|
-
|
|
127
|
+
- **`ItWalletEntityStatementClaimsOptions`**: Input type for entity statement claims
|
|
127
128
|
|
|
128
|
-
|
|
129
|
+
- **`ItWalletEntityStatementClaims`**: Output type for entity statement claims
|
|
129
130
|
|
|
130
131
|
### Zod Schemas
|
|
131
132
|
|
|
132
133
|
This package exports a comprehensive set of Zod schemas to validate all parts of the federation artifacts.
|
|
133
134
|
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
#### JWK Schemas:
|
|
136
|
+
- **`jsonWebKeySchema`**: Validates a single JSON Web Key (includes support for x5c certificate chain)
|
|
137
|
+
|
|
138
|
+
- **`jsonWebKeySetSchema`**: Validates a JSON Web Key Set
|
|
136
139
|
|
|
137
|
-
|
|
140
|
+
#### Metadata Schemas:
|
|
141
|
+
- **`itWalletFederationEntityMetadata`**: For `federation_entity` metadata
|
|
138
142
|
|
|
139
|
-
-
|
|
140
|
-
- `itWalletFederationEntityMetadata`: For `federation_entity` metadata.
|
|
143
|
+
- **`itWalletProviderEntityMetadata`**: For `wallet_provider` metadata
|
|
141
144
|
|
|
142
|
-
|
|
145
|
+
- **`itWalletCredentialIssuerMetadata`**: For `openid_credential_issuer` metadata
|
|
143
146
|
|
|
144
|
-
|
|
147
|
+
- **`itWalletCredentialVerifierMetadata`**: For `openid_credential_verifier` metadata
|
|
145
148
|
|
|
146
|
-
|
|
149
|
+
- **`itWalletAuthorizationServerMetadata`**: For `oauth_authorization_server` metadata
|
|
147
150
|
|
|
148
|
-
|
|
151
|
+
- **`itWalletMetadataSchema`**: Combined metadata schema for all entity types
|
|
149
152
|
|
|
150
|
-
|
|
151
|
-
|
|
153
|
+
#### Claims Schemas:
|
|
154
|
+
- **`itWalletEntityStatementClaimsSchema`**: Validates the claims within an Entity Statement
|
|
152
155
|
|
|
153
|
-
|
|
156
|
+
- **`itWalletEntityConfigurationClaimsSchema`**: Validates the claims for an Entity Configuration (where iss must equal sub)
|