@celo/buy-identity 0.3.0 → 0.4.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.
@@ -0,0 +1,118 @@
1
+ # Third-party notices
2
+
3
+ `@celo/buy-identity` bundles portions of the following packages. Their license
4
+ terms apply to those portions; the package's Apache-2.0 license applies only to
5
+ the original buy code.
6
+
7
+ | Package | Version | License |
8
+ | --- | --- | --- |
9
+ | `@adraffy/ens-normalize` | 1.10.1 | MIT |
10
+ | `@noble/curves` | 1.2.0 | MIT |
11
+ | `@noble/hashes` | 1.3.2 | MIT |
12
+ | `@selfxyz/common` | 0.0.9 | MIT |
13
+ | `@selfxyz/core` | 1.1.0-beta.7 | MIT |
14
+ | `@selfxyz/sdk-common` | 1.0.1 | ISC |
15
+ | `aes-js` | 4.0.0-beta.5 | MIT |
16
+ | `ethers` | 6.16.0 | MIT |
17
+ | `js-sha1` | 0.7.0 | MIT |
18
+ | `js-sha256` | 0.11.1 | MIT |
19
+ | `js-sha512` | 0.9.0 | MIT |
20
+ | `node-forge` | 1.3.2-0 | BSD-3-Clause OR GPL-2.0 |
21
+ | `poseidon-lite` | 0.2.1 | MIT |
22
+ | `uuid` | 13.0.2 | MIT |
23
+ | `ws` | 8.21.0 | MIT |
24
+
25
+ ## Copyright and attribution notices
26
+
27
+ The following notices are reproduced from the license files distributed with
28
+ the bundled packages:
29
+
30
+ - `@adraffy/ens-normalize`: Copyright (c) 2021 Andrew Raffensperger
31
+ - `@noble/curves`: Copyright (c) 2022 Paul Miller
32
+ (https://paulmillr.com)
33
+ - `@noble/hashes`: Copyright (c) 2022 Paul Miller
34
+ (https://paulmillr.com)
35
+ - `aes-js`: Copyright (c) 2022 Richard Moore
36
+ - `ethers`: Copyright (c) 2016-2025 Richard Moore
37
+ - `js-sha1`: Copyright 2014-2024 Chen, Yi-Cyuan
38
+ - `js-sha256`: Copyright (c) 2014-2025 Chen, Yi-Cyuan
39
+ - `js-sha512`: Copyright 2014-2024 Chen, Yi-Cyuan
40
+ - `node-forge`: Copyright (c) 2010, Digital Bazaar, Inc.
41
+ - `uuid`: Copyright (c) 2010-2020 Robert Kieffer and other contributors
42
+ - `ws`: Copyright (c) 2011 Einar Otto Stangvik <einaros@gmail.com>; Copyright
43
+ (c) 2013 Arnout Kazemier and contributors; Copyright (c) 2016 Luigi Pinca and
44
+ contributors
45
+
46
+ Four published package archives do not include a license file or copyright
47
+ notice. Their npm metadata nevertheless declares the license shown above. For
48
+ attribution, that metadata names the Selfxyz Team as the author of
49
+ `@selfxyz/common` and motemotech as the author of `@selfxyz/core`.
50
+ `@selfxyz/sdk-common` does not name an author and is published in the
51
+ `@selfxyz` npm scope by its listed maintainers. The `poseidon-lite` archive does
52
+ not name an author; its npm maintainer is jchancehud and its README states that
53
+ versions 0.2.0 and later are MIT licensed.
54
+
55
+ The bundled JavaScript additionally retains license and copyright comments
56
+ supplied by upstream source files. Source repositories and complete package
57
+ metadata are available from the corresponding package pages on npm.
58
+
59
+ ## MIT License
60
+
61
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
62
+ this software and associated documentation files (the "Software"), to deal in
63
+ the Software without restriction, including without limitation the rights to
64
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
65
+ the Software, and to permit persons to whom the Software is furnished to do so,
66
+ subject to the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be included in all
69
+ copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
72
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
73
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
74
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
75
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
76
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
77
+
78
+ ## ISC License
79
+
80
+ Permission to use, copy, modify, and/or distribute this software for any
81
+ purpose with or without fee is hereby granted, provided that the above
82
+ copyright notice and this permission notice appear in all copies.
83
+
84
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
85
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
86
+ FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
87
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
88
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
89
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
90
+ PERFORMANCE OF THIS SOFTWARE.
91
+
92
+ ## node-forge BSD License
93
+
94
+ Copyright (c) 2010, Digital Bazaar, Inc.
95
+ All rights reserved.
96
+
97
+ Redistribution and use in source and binary forms, with or without
98
+ modification, are permitted provided that the following conditions are met:
99
+
100
+ 1. Redistributions of source code must retain the above copyright notice,
101
+ this list of conditions and the following disclaimer.
102
+ 2. Redistributions in binary form must reproduce the above copyright notice,
103
+ this list of conditions and the following disclaimer in the documentation
104
+ and/or other materials provided with the distribution.
105
+ 3. Neither the name of Digital Bazaar, Inc. nor the names of its contributors
106
+ may be used to endorse or promote products derived from this software
107
+ without specific prior written permission.
108
+
109
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
110
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
111
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
112
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
113
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
114
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
115
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
116
+ ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
117
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
118
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/dist/config.d.ts CHANGED
@@ -3,16 +3,8 @@ import type { SoftKycRequirements, VerificationRequest } from './types.js';
3
3
  * Build a Self verification request and return the universal link the mobile
4
4
  * app understands. The link is what gets rendered as a QR code in the terminal.
5
5
  *
6
- * ASYNC, and importing `@selfxyz/qrcode` LAZILY, because that module prints
7
- * `[WebSocket] Initializing websocket module.` to STDOUT the moment it is
8
- * loaded. At the top of this file that banner landed on every single `buy`
9
- * invocation — `main.ts` imports all commands eagerly, so merely having a
10
- * `verify` command polluted `buy fetch`'s stdout, which is the response body.
11
- * `buy fetch … | jq` was parsing that line as the first thing in the payload.
12
- *
13
- * Nothing in this package can stop a dependency writing to stdout, so the only
14
- * fix is not to load it until it is genuinely needed — i.e. inside the one
15
- * function that builds a QR link.
6
+ * The builder comes from Self's framework-neutral package. Importing the UI
7
+ * package here used to initialize its WebSocket client on every CLI startup.
16
8
  */
17
9
  export declare function buildVerificationLink(request: VerificationRequest): Promise<string>;
18
10
  /** Exposed for tests — pure function, no Self SDK calls. */
@@ -0,0 +1,90 @@
1
+ import type { Verification } from '@celo/buy-keystore';
2
+ import type { VerificationRequest } from './types.js';
3
+ /**
4
+ * The wire protocol between a client and a gateway that hosts the Self
5
+ * receiver for it (celo-org/cpay#63).
6
+ *
7
+ * These live in the shared package rather than beside either end because they
8
+ * describe a TRUST BOUNDARY. The gateway recovers a signature over
9
+ * `sessionMintMessage`; the client produces one. If the two strings ever drift
10
+ * the failure is a 401 with no indication that the message format is why, so
11
+ * there is exactly one definition and both sides import it.
12
+ *
13
+ * The challenge itself is deliberately NOT here: it is an HMAC under a secret
14
+ * only the gateway holds, and a client that could compute one could mint its
15
+ * own. The client receives a challenge and echoes it back, nothing more.
16
+ */
17
+ /** Where a client asks the gateway for a verification session. */
18
+ export declare const SELF_SESSION_ROUTE = "/self/session";
19
+ /** Where a client asks for a challenge to sign. */
20
+ export declare const SELF_CHALLENGE_ROUTE = "/self/session/challenge";
21
+ /** Where a verified wallet fetches its own attestation back. */
22
+ export declare const SELF_ATTESTATION_ROUTE = "/self/attestation";
23
+ /**
24
+ * What a wallet signs to mint a verification session.
25
+ *
26
+ * Domain-separated and versioned so a signature harvested here cannot be
27
+ * replayed as anything else, and bound to a CHALLENGE so it cannot be replayed
28
+ * as this either — without one the message is constant for a given
29
+ * (address, scope) and a single captured signature mints sessions forever.
30
+ */
31
+ export declare function sessionMintMessage(address: string, scope: string, challenge: string, gatewayOrigin: string): string;
32
+ /**
33
+ * What a wallet signs to fetch its own attestation back.
34
+ *
35
+ * A DIFFERENT prefix from `sessionMintMessage` on purpose. The two routes are
36
+ * signed by the same key for the same scope, so without domain separation a
37
+ * signature captured from one is a valid signature for the other.
38
+ *
39
+ * BOUND TO THE GATEWAY, which is what stops a relay. Any resource server can
40
+ * put its own URL in `selfRequirements.endpoint`, and the printed remedy tells
41
+ * the user to run `buy verify hosted --endpoint <that url>` — so a hostile one
42
+ * can proxy a real gateway's challenge, answer `verified` without any proof
43
+ * existing, and collect a signature. Without the origin in the string that
44
+ * signature is valid at the REAL gateway, and replaying it returns the
45
+ * victim's disclosed age, nationality, OFAC standing and raw proof payload.
46
+ * With it, a signature produced for one gateway is meaningless at another.
47
+ */
48
+ export declare function attestationFetchMessage(address: string, scope: string, challenge: string, gatewayOrigin: string): string;
49
+ /**
50
+ * The gateway origin a pinned receiver URL belongs to.
51
+ *
52
+ * The 402 pins the RECEIVER (`https://gw.example/self/api/verify`); the session
53
+ * and attestation routes hang off the gateway ROOT. Deriving one from the other
54
+ * means a client is never asked to configure two URLs that must agree.
55
+ */
56
+ export declare function gatewayOriginFor(receiverUrl: string): string;
57
+ export type MintedSession = {
58
+ readonly sessionId: string;
59
+ readonly endpoint: string;
60
+ readonly endpointType: VerificationRequest['endpointType'];
61
+ readonly scope: string;
62
+ readonly userDefinedData: string;
63
+ readonly disclosures?: {
64
+ readonly minimumAge?: number;
65
+ readonly ofac?: boolean;
66
+ };
67
+ };
68
+ /**
69
+ * The whole gateway handshake, with its I/O injected.
70
+ *
71
+ * Split from the command because the command's other half — resolving an
72
+ * account and loading its key — reaches the OS keyring, which a temporary
73
+ * `BUY_HOME` does NOT isolate. Everything security-relevant here is the
74
+ * protocol (which message is signed, whether a fresh challenge is taken, what
75
+ * happens when the session expires), so that part takes a `sign` function and
76
+ * can be exercised against a real gateway without touching a keychain.
77
+ */
78
+ export type HostedVerificationDeps = {
79
+ readonly origin: string;
80
+ readonly address: string;
81
+ readonly scope: string;
82
+ readonly sign: (message: string) => Promise<string>;
83
+ readonly timeoutMs: number;
84
+ readonly pollMs: number;
85
+ /** Called once the session exists, with everything a QR needs. */
86
+ readonly onSession?: (minted: MintedSession) => void | Promise<void>;
87
+ readonly now?: () => number;
88
+ readonly sleep?: (ms: number) => Promise<void>;
89
+ };
90
+ export declare function runHostedVerification(deps: HostedVerificationDeps): Promise<Verification>;
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from './types.js';
2
2
  export * from './config.js';
3
3
  export * from './verify.js';
4
+ export * from './receiver.js';
5
+ export * from './hosted.js';
4
6
  export { renderQrToTerminal } from './qr.js';