@flarcos/kiota-authentication-gnap 0.1.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 +192 -0
- package/dist/contentDigest.d.ts +17 -0
- package/dist/contentDigest.d.ts.map +1 -0
- package/dist/contentDigest.js +23 -0
- package/dist/contentDigest.js.map +1 -0
- package/dist/errors.d.ts +25 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +46 -0
- package/dist/errors.js.map +1 -0
- package/dist/gnapAccessTokenProvider.d.ts +50 -0
- package/dist/gnapAccessTokenProvider.d.ts.map +1 -0
- package/dist/gnapAccessTokenProvider.js +176 -0
- package/dist/gnapAccessTokenProvider.js.map +1 -0
- package/dist/gnapAuthenticationProvider.d.ts +68 -0
- package/dist/gnapAuthenticationProvider.d.ts.map +1 -0
- package/dist/gnapAuthenticationProvider.js +216 -0
- package/dist/gnapAuthenticationProvider.js.map +1 -0
- package/dist/gnapTokenStore.d.ts +11 -0
- package/dist/gnapTokenStore.d.ts.map +1 -0
- package/dist/gnapTokenStore.js +27 -0
- package/dist/gnapTokenStore.js.map +1 -0
- package/dist/httpMessageSigner.d.ts +41 -0
- package/dist/httpMessageSigner.d.ts.map +1 -0
- package/dist/httpMessageSigner.js +74 -0
- package/dist/httpMessageSigner.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/keyManagement.d.ts +36 -0
- package/dist/keyManagement.d.ts.map +1 -0
- package/dist/keyManagement.js +75 -0
- package/dist/keyManagement.js.map +1 -0
- package/dist/types.d.ts +145 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +44 -0
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GNAP (RFC 9635) types for grant requests, responses, and token management.
|
|
3
|
+
* @see https://www.rfc-editor.org/rfc/rfc9635.html
|
|
4
|
+
*/
|
|
5
|
+
export interface GnapClientKey {
|
|
6
|
+
/** JWK representation of the client's public key */
|
|
7
|
+
jwk: JsonWebKey;
|
|
8
|
+
/** Key proof method — we use "httpsig" for RFC 9421 */
|
|
9
|
+
proof: "httpsig" | "mtls" | "jwsd" | "jws";
|
|
10
|
+
}
|
|
11
|
+
export interface GnapClientInstance {
|
|
12
|
+
/** Client key for proving possession */
|
|
13
|
+
key: GnapClientKey;
|
|
14
|
+
/** Client identifier (e.g. wallet address URL) */
|
|
15
|
+
class_id?: string;
|
|
16
|
+
/** Display information */
|
|
17
|
+
display?: {
|
|
18
|
+
name?: string;
|
|
19
|
+
uri?: string;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
export interface GnapAccessRight {
|
|
23
|
+
/** Type of resource (e.g. "incoming-payment", "outgoing-payment", "quote") */
|
|
24
|
+
type: string;
|
|
25
|
+
/** Permitted actions (e.g. ["create", "read"]) */
|
|
26
|
+
actions: string[];
|
|
27
|
+
/** Resource owner identifier (e.g. wallet address URL) */
|
|
28
|
+
identifier?: string;
|
|
29
|
+
/** Specific limits on the access */
|
|
30
|
+
limits?: Record<string, unknown>;
|
|
31
|
+
}
|
|
32
|
+
export interface GnapGrantRequest {
|
|
33
|
+
/** Requested access token(s) */
|
|
34
|
+
access_token: {
|
|
35
|
+
access: GnapAccessRight[];
|
|
36
|
+
};
|
|
37
|
+
/** Client instance identification */
|
|
38
|
+
client: string | GnapClientInstance;
|
|
39
|
+
/** Interaction modes */
|
|
40
|
+
interact?: {
|
|
41
|
+
start: ("redirect" | "app" | "user_code" | "user_code_uri")[];
|
|
42
|
+
finish?: {
|
|
43
|
+
method: "redirect" | "push";
|
|
44
|
+
uri: string;
|
|
45
|
+
nonce: string;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export interface GnapAccessToken {
|
|
50
|
+
/** Opaque access token value */
|
|
51
|
+
value: string;
|
|
52
|
+
/** Token management URL */
|
|
53
|
+
manage?: string;
|
|
54
|
+
/** Access rights granted */
|
|
55
|
+
access: GnapAccessRight[];
|
|
56
|
+
/** Seconds until expiration */
|
|
57
|
+
expires_in?: number;
|
|
58
|
+
/** Token flags */
|
|
59
|
+
flags?: string[];
|
|
60
|
+
}
|
|
61
|
+
export interface GnapGrantResponse {
|
|
62
|
+
/** Access token (for non-interactive grants or after continuation) */
|
|
63
|
+
access_token?: GnapAccessToken;
|
|
64
|
+
/** Continuation information */
|
|
65
|
+
continue?: {
|
|
66
|
+
uri: string;
|
|
67
|
+
wait?: number;
|
|
68
|
+
access_token: {
|
|
69
|
+
value: string;
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
/** Interaction information */
|
|
73
|
+
interact?: {
|
|
74
|
+
redirect?: string;
|
|
75
|
+
app?: string;
|
|
76
|
+
user_code?: string;
|
|
77
|
+
user_code_uri?: string;
|
|
78
|
+
finish?: string;
|
|
79
|
+
};
|
|
80
|
+
/** Dynamically bound instance identifier */
|
|
81
|
+
instance_id?: string;
|
|
82
|
+
/** Error response */
|
|
83
|
+
error?: {
|
|
84
|
+
code: string;
|
|
85
|
+
description?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export interface StoredGnapToken {
|
|
89
|
+
/** The access token */
|
|
90
|
+
token: GnapAccessToken;
|
|
91
|
+
/** When the token was acquired (epoch ms) */
|
|
92
|
+
acquiredAt: number;
|
|
93
|
+
/** The authorization server URL this token was issued from */
|
|
94
|
+
authServerUrl: string;
|
|
95
|
+
/** The continue URI for this grant (if applicable) */
|
|
96
|
+
continueUri?: string;
|
|
97
|
+
/** The continue access token */
|
|
98
|
+
continueAccessToken?: string;
|
|
99
|
+
}
|
|
100
|
+
export interface InteractionResult {
|
|
101
|
+
/** The interact_ref returned by the AS after user consent */
|
|
102
|
+
interactRef: string;
|
|
103
|
+
/** The interaction hash for verification */
|
|
104
|
+
hash: string;
|
|
105
|
+
}
|
|
106
|
+
export interface GnapAuthenticationProviderOptions {
|
|
107
|
+
/** Authorization Server grant endpoint URL */
|
|
108
|
+
authServerUrl: string;
|
|
109
|
+
/** Client's Ed25519 private key in PEM format or as CryptoKey */
|
|
110
|
+
privateKey: CryptoKey | string;
|
|
111
|
+
/** Client's Ed25519 public key in JWK format (derived from private if not provided) */
|
|
112
|
+
publicKeyJwk?: JsonWebKey;
|
|
113
|
+
/** Client identifier (e.g. wallet address URL for Open Payments) */
|
|
114
|
+
clientIdentifier: string;
|
|
115
|
+
/** Access rights to request in the grant */
|
|
116
|
+
accessRights: GnapAccessRight[];
|
|
117
|
+
/** Interaction configuration for interactive grants */
|
|
118
|
+
interact?: {
|
|
119
|
+
start: ("redirect" | "app")[];
|
|
120
|
+
finish?: {
|
|
121
|
+
method: "redirect" | "push";
|
|
122
|
+
uri: string;
|
|
123
|
+
nonce: string;
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
/** Custom interaction handler (for redirect/polling flows) */
|
|
127
|
+
interactionHandler?: InteractionHandler;
|
|
128
|
+
/** Token store implementation (defaults to in-memory) */
|
|
129
|
+
tokenStore?: GnapTokenStore;
|
|
130
|
+
/** Allowed hosts for this auth provider */
|
|
131
|
+
allowedHosts?: string[];
|
|
132
|
+
}
|
|
133
|
+
export interface InteractionHandler {
|
|
134
|
+
/** Handle redirect-based interaction. Called when the AS returns a redirect URL. */
|
|
135
|
+
handleRedirect(redirectUrl: string, nonce: string): Promise<InteractionResult>;
|
|
136
|
+
}
|
|
137
|
+
export interface GnapTokenStore {
|
|
138
|
+
/** Get a cached token for the given key (typically auth server URL) */
|
|
139
|
+
get(key: string): Promise<StoredGnapToken | undefined>;
|
|
140
|
+
/** Store a token */
|
|
141
|
+
set(key: string, token: StoredGnapToken): Promise<void>;
|
|
142
|
+
/** Delete a token */
|
|
143
|
+
delete(key: string): Promise<void>;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1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"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@flarcos/kiota-authentication-gnap",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "GNAP (RFC 9635) authentication provider for Kiota-generated API clients with RFC 9421 HTTP Message Signatures",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "tsc",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"lint": "eslint src/",
|
|
16
|
+
"prepublishOnly": "npm run build"
|
|
17
|
+
},
|
|
18
|
+
"keywords": [
|
|
19
|
+
"kiota",
|
|
20
|
+
"gnap",
|
|
21
|
+
"rfc9635",
|
|
22
|
+
"rfc9421",
|
|
23
|
+
"http-message-signatures",
|
|
24
|
+
"open-payments",
|
|
25
|
+
"interledger",
|
|
26
|
+
"authentication"
|
|
27
|
+
],
|
|
28
|
+
"author": "flarcos",
|
|
29
|
+
"license": "Apache-2.0",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@microsoft/kiota-abstractions": "^1.0.0-preview.68",
|
|
32
|
+
"http-message-signatures": "^1.0.4",
|
|
33
|
+
"jose": "^5.9.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@interledger/http-signature-utils": "^2.0.3",
|
|
37
|
+
"@types/node": "^22.0.0",
|
|
38
|
+
"typescript": "^5.5.0",
|
|
39
|
+
"vitest": "^2.0.0"
|
|
40
|
+
},
|
|
41
|
+
"engines": {
|
|
42
|
+
"node": ">=18.0.0"
|
|
43
|
+
}
|
|
44
|
+
}
|