@learncard/openid4vc-plugin 0.0.1

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +592 -0
  3. package/dist/dcql/adapt.d.ts +80 -0
  4. package/dist/dcql/adapt.d.ts.map +1 -0
  5. package/dist/dcql/build.d.ts +122 -0
  6. package/dist/dcql/build.d.ts.map +1 -0
  7. package/dist/dcql/compose.d.ts +78 -0
  8. package/dist/dcql/compose.d.ts.map +1 -0
  9. package/dist/dcql/index.d.ts +18 -0
  10. package/dist/dcql/index.d.ts.map +1 -0
  11. package/dist/dcql/parse.d.ts +16 -0
  12. package/dist/dcql/parse.d.ts.map +1 -0
  13. package/dist/dcql/respond.d.ts +115 -0
  14. package/dist/dcql/respond.d.ts.map +1 -0
  15. package/dist/dcql/select.d.ts +63 -0
  16. package/dist/dcql/select.d.ts.map +1 -0
  17. package/dist/dcql/types.d.ts +93 -0
  18. package/dist/dcql/types.d.ts.map +1 -0
  19. package/dist/index.d.ts +8 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +7 -0
  22. package/dist/offer/index.d.ts +4 -0
  23. package/dist/offer/index.d.ts.map +1 -0
  24. package/dist/offer/normalize.d.ts +15 -0
  25. package/dist/offer/normalize.d.ts.map +1 -0
  26. package/dist/offer/parse.d.ts +24 -0
  27. package/dist/offer/parse.d.ts.map +1 -0
  28. package/dist/offer/types.d.ts +92 -0
  29. package/dist/offer/types.d.ts.map +1 -0
  30. package/dist/openid4vc-plugin.cjs.development.js +27402 -0
  31. package/dist/openid4vc-plugin.cjs.development.js.map +7 -0
  32. package/dist/openid4vc-plugin.cjs.production.min.js +146 -0
  33. package/dist/openid4vc-plugin.cjs.production.min.js.map +7 -0
  34. package/dist/openid4vc-plugin.esm.js +27396 -0
  35. package/dist/openid4vc-plugin.esm.js.map +7 -0
  36. package/dist/plugin.d.ts +12 -0
  37. package/dist/plugin.d.ts.map +1 -0
  38. package/dist/siop/index.d.ts +11 -0
  39. package/dist/siop/index.d.ts.map +1 -0
  40. package/dist/siop/sign.d.ts +92 -0
  41. package/dist/siop/sign.d.ts.map +1 -0
  42. package/dist/types.d.ts +359 -0
  43. package/dist/types.d.ts.map +1 -0
  44. package/dist/vci/accept.d.ts +24 -0
  45. package/dist/vci/accept.d.ts.map +1 -0
  46. package/dist/vci/auth-code.d.ts +148 -0
  47. package/dist/vci/auth-code.d.ts.map +1 -0
  48. package/dist/vci/decode.d.ts +65 -0
  49. package/dist/vci/decode.d.ts.map +1 -0
  50. package/dist/vci/errors.d.ts +22 -0
  51. package/dist/vci/errors.d.ts.map +1 -0
  52. package/dist/vci/index.d.ts +12 -0
  53. package/dist/vci/index.d.ts.map +1 -0
  54. package/dist/vci/metadata.d.ts +25 -0
  55. package/dist/vci/metadata.d.ts.map +1 -0
  56. package/dist/vci/pkce.d.ts +85 -0
  57. package/dist/vci/pkce.d.ts.map +1 -0
  58. package/dist/vci/proof.d.ts +43 -0
  59. package/dist/vci/proof.d.ts.map +1 -0
  60. package/dist/vci/request.d.ts +48 -0
  61. package/dist/vci/request.d.ts.map +1 -0
  62. package/dist/vci/store.d.ts +89 -0
  63. package/dist/vci/store.d.ts.map +1 -0
  64. package/dist/vci/token.d.ts +16 -0
  65. package/dist/vci/token.d.ts.map +1 -0
  66. package/dist/vci/types.d.ts +156 -0
  67. package/dist/vci/types.d.ts.map +1 -0
  68. package/dist/vp/client-id-prefix.d.ts +115 -0
  69. package/dist/vp/client-id-prefix.d.ts.map +1 -0
  70. package/dist/vp/encrypt.d.ts +221 -0
  71. package/dist/vp/encrypt.d.ts.map +1 -0
  72. package/dist/vp/index.d.ts +27 -0
  73. package/dist/vp/index.d.ts.map +1 -0
  74. package/dist/vp/parse.d.ts +60 -0
  75. package/dist/vp/parse.d.ts.map +1 -0
  76. package/dist/vp/pex.d.ts +83 -0
  77. package/dist/vp/pex.d.ts.map +1 -0
  78. package/dist/vp/present.d.ts +126 -0
  79. package/dist/vp/present.d.ts.map +1 -0
  80. package/dist/vp/request-object.d.ts +99 -0
  81. package/dist/vp/request-object.d.ts.map +1 -0
  82. package/dist/vp/select.d.ts +137 -0
  83. package/dist/vp/select.d.ts.map +1 -0
  84. package/dist/vp/sign.d.ts +125 -0
  85. package/dist/vp/sign.d.ts.map +1 -0
  86. package/dist/vp/submit.d.ts +175 -0
  87. package/dist/vp/submit.d.ts.map +1 -0
  88. package/dist/vp/types.d.ts +255 -0
  89. package/dist/vp/types.d.ts.map +1 -0
  90. package/package.json +52 -0
@@ -0,0 +1,15 @@
1
+ import { CredentialOffer } from './types';
2
+ /**
3
+ * Normalize a raw credential-offer JSON payload (Draft 11 or Draft 13)
4
+ * into the Draft 13 shape the rest of the plugin consumes.
5
+ *
6
+ * - `credentials` (Draft 11) → `credential_configuration_ids` (Draft 13).
7
+ * - `user_pin_required: true` (Draft 11) → synthetic `tx_code: {}` (Draft 13).
8
+ *
9
+ * Draft 11 `credentials` entries that are objects (in-line format metadata
10
+ * rather than configuration ids) are preserved as their `id` or `types[0]`
11
+ * fall-back string, with a warning logged. Wallets that need the full inline
12
+ * metadata should fetch the issuer metadata and match by `format`.
13
+ */
14
+ export declare const normalizeCredentialOffer: (raw: unknown) => CredentialOffer;
15
+ //# sourceMappingURL=normalize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize.d.ts","sourceRoot":"","sources":["../../src/offer/normalize.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,eAAe,EAMlB,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,wBAAwB,QAAS,OAAO,KAAG,eA+EvD,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { ParsedCredentialOfferUri } from './types';
2
+ /**
3
+ * Parse an OpenID4VCI Credential Offer URI.
4
+ *
5
+ * Accepts:
6
+ * - `openid-credential-offer://?credential_offer=<url-encoded JSON>`
7
+ * - `openid-credential-offer://?credential_offer_uri=<url-encoded https URL>`
8
+ * - `haip://` variants of the above
9
+ * - A bare query string (`?credential_offer=...` or `credential_offer=...`)
10
+ *
11
+ * Does not hit the network. For `by_reference` offers, use
12
+ * {@link resolveCredentialOfferByReference} with a fetch implementation.
13
+ *
14
+ * @throws {CredentialOfferParseError}
15
+ */
16
+ export declare const parseCredentialOfferUri: (input: string) => ParsedCredentialOfferUri;
17
+ /**
18
+ * Fetch a by-reference credential offer and normalize it.
19
+ *
20
+ * @param fetchImpl - Defaults to `globalThis.fetch` when available.
21
+ * @throws {CredentialOfferParseError}
22
+ */
23
+ export declare const resolveCredentialOfferByReference: (uri: string, fetchImpl?: typeof fetch) => Promise<ParsedCredentialOfferUri>;
24
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/offer/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAEH,wBAAwB,EAC3B,MAAM,SAAS,CAAC;AAGjB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,uBAAuB,UAAW,MAAM,KAAG,wBA+CvD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,iCAAiC,QACrC,MAAM,cACA,OAAO,KAAK,KACxB,OAAO,CAAC,wBAAwB,CA6ClC,CAAC"}
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Domain types for OpenID4VCI Credential Offers.
3
+ *
4
+ * Normalized to OID4VCI Draft 13. Draft 11 offers (still widely deployed)
5
+ * are accepted at parse time and normalized to the Draft 13 shape, so the
6
+ * rest of the wallet only has to reason about one shape.
7
+ *
8
+ * Spec: https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html
9
+ */
10
+ /** OID4VCI Draft 13 pre-authorized code grant-type URN. */
11
+ export declare const PRE_AUTHORIZED_CODE_GRANT = "urn:ietf:params:oauth:grant-type:pre-authorized_code";
12
+ /** Transaction-code metadata (replaces Draft 11's boolean `user_pin_required`). */
13
+ export interface TxCode {
14
+ /** `numeric` or `text`. Defaults to `numeric`. */
15
+ input_mode?: 'numeric' | 'text';
16
+ /** Expected length of the transaction code. Optional. */
17
+ length?: number;
18
+ /** Human-readable hint shown to the user. Optional. */
19
+ description?: string;
20
+ }
21
+ export interface PreAuthorizedCodeGrant {
22
+ /** The pre-authorized code the wallet exchanges for an access token. */
23
+ 'pre-authorized_code': string;
24
+ /** If present, the wallet must collect a tx code from the user. */
25
+ tx_code?: TxCode;
26
+ /** Minimum seconds the wallet should wait between deferred polls. */
27
+ interval?: number;
28
+ /** Authorization server to use if the issuer delegates token issuance. */
29
+ authorization_server?: string;
30
+ }
31
+ export interface AuthorizationCodeGrant {
32
+ /** Opaque state the wallet must forward in the authorization request. */
33
+ issuer_state?: string;
34
+ /** Authorization server to use if the issuer delegates authorization. */
35
+ authorization_server?: string;
36
+ }
37
+ export interface CredentialOfferGrants {
38
+ [PRE_AUTHORIZED_CODE_GRANT]?: PreAuthorizedCodeGrant;
39
+ authorization_code?: AuthorizationCodeGrant;
40
+ }
41
+ /**
42
+ * Normalized Draft 13 Credential Offer.
43
+ *
44
+ * `credential_configuration_ids` is the Draft 13 field name. Draft 11
45
+ * `credentials` (array of strings or objects) is normalized into this field
46
+ * by {@link normalizeCredentialOffer}.
47
+ */
48
+ export interface CredentialOffer {
49
+ credential_issuer: string;
50
+ credential_configuration_ids: string[];
51
+ grants?: CredentialOfferGrants;
52
+ }
53
+ /**
54
+ * Raw Draft 11 shape accepted at parse time. Everything else downstream
55
+ * should consume the normalized {@link CredentialOffer}.
56
+ */
57
+ export interface RawDraft11CredentialOffer {
58
+ credential_issuer: string;
59
+ credentials: Array<string | {
60
+ format: string;
61
+ types?: string[];
62
+ [k: string]: unknown;
63
+ }>;
64
+ grants?: {
65
+ [PRE_AUTHORIZED_CODE_GRANT]?: {
66
+ 'pre-authorized_code': string;
67
+ user_pin_required?: boolean;
68
+ interval?: number;
69
+ };
70
+ authorization_code?: AuthorizationCodeGrant;
71
+ };
72
+ }
73
+ /** Result of parsing an `openid-credential-offer://` URI. */
74
+ export type ParsedCredentialOfferUri = {
75
+ kind: 'by_value';
76
+ offer: CredentialOffer;
77
+ } | {
78
+ kind: 'by_reference';
79
+ uri: string;
80
+ };
81
+ /** Schemes recognized as carrying OID4VCI credential offers. */
82
+ export declare const CREDENTIAL_OFFER_SCHEMES: readonly ["openid-credential-offer", "haip"];
83
+ export type CredentialOfferScheme = (typeof CREDENTIAL_OFFER_SCHEMES)[number];
84
+ /**
85
+ * Thrown when an offer URI or payload is malformed. Carries a stable `code`
86
+ * so UI layers can map to friendly copy without string-matching messages.
87
+ */
88
+ export declare class CredentialOfferParseError extends Error {
89
+ readonly code: 'invalid_uri' | 'missing_offer' | 'both_offer_and_uri' | 'invalid_json' | 'missing_issuer' | 'missing_credentials' | 'invalid_grants';
90
+ constructor(code: CredentialOfferParseError['code'], message: string);
91
+ }
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/offer/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,2DAA2D;AAC3D,eAAO,MAAM,yBAAyB,yDACoB,CAAC;AAE3D,mFAAmF;AACnF,MAAM,WAAW,MAAM;IACnB,kDAAkD;IAClD,UAAU,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAChC,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACnC,wEAAwE;IACxE,qBAAqB,EAAE,MAAM,CAAC;IAC9B,mEAAmE;IACnE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,qEAAqE;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0EAA0E;IAC1E,oBAAoB,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IACnC,yEAAyE;IACzE,YAAY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