@dvai-bridge/android 4.0.0 → 4.0.2
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/android/build.gradle +252 -165
- package/android/gradle.properties +1 -1
- package/android/src/main/java/co/deepvoiceai/bridge/BoundServer.kt +39 -39
- package/android/src/main/java/co/deepvoiceai/bridge/DVAIBridge.kt +642 -642
- package/android/src/main/java/co/deepvoiceai/bridge/DVAIBridgeConfig.kt +119 -119
- package/android/src/main/java/co/deepvoiceai/bridge/license/Audience.kt +134 -134
- package/android/src/main/java/co/deepvoiceai/bridge/license/Discovery.kt +146 -146
- package/android/src/main/java/co/deepvoiceai/bridge/license/LicenseTypes.kt +158 -158
- package/android/src/main/java/co/deepvoiceai/bridge/license/LicenseValidator.kt +400 -400
- package/android/src/main/java/co/deepvoiceai/bridge/license/PublicKeys.kt +91 -91
- package/android/src/test/java/co/deepvoiceai/bridge/license/LicenseValidatorTest.kt +539 -539
- package/package.json +1 -1
- package/LICENSE +0 -51
- package/README.md +0 -199
|
@@ -1,91 +1,91 @@
|
|
|
1
|
-
package co.deepvoiceai.bridge.license
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Public-key registry for DVAI-Bridge license JWT verification.
|
|
5
|
-
*
|
|
6
|
-
* Kotlin port of `packages/dvai-bridge-core/src/license/publicKeys.ts` — semantics
|
|
7
|
-
* and registry contents are 1:1 with the JS side. The same JWT format and the
|
|
8
|
-
* same kids work across the JS, iOS, and Android validators.
|
|
9
|
-
*
|
|
10
|
-
* Each entry is keyed by `kid` (key id, written by the license generator
|
|
11
|
-
* into the JWT header). The SDK looks up the matching entry by kid when
|
|
12
|
-
* verifying a license token. Multiple entries can coexist so that key
|
|
13
|
-
* rotation is non-disruptive: ship the new key in a release alongside
|
|
14
|
-
* the old, leave the old in place for ~12 months while previously-
|
|
15
|
-
* issued licenses naturally expire or get re-issued, then prune.
|
|
16
|
-
*
|
|
17
|
-
* THE PRIVATE KEY DOES NOT LIVE HERE. It belongs in your secrets
|
|
18
|
-
* manager (1Password / AWS Secrets Manager / Vault), accessible only
|
|
19
|
-
* to the license-generator service that produces signed JWTs. The
|
|
20
|
-
* mathematics of ECDSA P-256 guarantee that a holder of the public
|
|
21
|
-
* key alone cannot forge a signature.
|
|
22
|
-
*/
|
|
23
|
-
|
|
24
|
-
/** ES256 (P-256 ECDSA) public key in JWK form. */
|
|
25
|
-
data class DvaiPublicKeyJwk(
|
|
26
|
-
val kty: String = "EC",
|
|
27
|
-
val crv: String = "P-256",
|
|
28
|
-
val x: String,
|
|
29
|
-
val y: String,
|
|
30
|
-
val alg: String? = "ES256",
|
|
31
|
-
val use: String? = "sig",
|
|
32
|
-
val kid: String? = null,
|
|
33
|
-
)
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* `kid` reserved for the placeholder key. The validator refuses to
|
|
37
|
-
* accept tokens signed with this kid unless the caller explicitly opts
|
|
38
|
-
* in (`allowPlaceholderKey = true` passed to the validator constructor,
|
|
39
|
-
* used by tests and by the sample license printed by the keypair-
|
|
40
|
-
* generator script).
|
|
41
|
-
*/
|
|
42
|
-
const val PLACEHOLDER_KID: String = "placeholder-do-not-ship"
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Registry mapping `kid` → public key JWK.
|
|
46
|
-
*
|
|
47
|
-
* The entry below is a **placeholder** — it is a published, well-known
|
|
48
|
-
* test keypair and DOES NOT verify any real production license. Before
|
|
49
|
-
* shipping licenses to customers, replace it with the output of
|
|
50
|
-
* `scripts/license/generate-keypair.mjs`. The SDK refuses to validate
|
|
51
|
-
* licenses against the placeholder kid unless `allowPlaceholderKey` is
|
|
52
|
-
* set (test-only escape hatch).
|
|
53
|
-
*
|
|
54
|
-
* To add a new key for rotation, add a second entry keyed by the new
|
|
55
|
-
* `kid`; old licenses keep verifying against the old key, new licenses
|
|
56
|
-
* (issued by the generator that knows the new private key) verify
|
|
57
|
-
* against the new entry.
|
|
58
|
-
*/
|
|
59
|
-
object DvaiPublicKeys {
|
|
60
|
-
/** Production registry. Mirrors `DVAI_PUBLIC_KEYS` on the JS side. */
|
|
61
|
-
val REGISTRY: Map<String, DvaiPublicKeyJwk> = mapOf(
|
|
62
|
-
// Production key, kid `2026-05`. Generated 2026-05-15 by
|
|
63
|
-
// scripts/license/generate-keypair.mjs. The matching private
|
|
64
|
-
// key lives in the operator's secrets manager.
|
|
65
|
-
"2026-05" to DvaiPublicKeyJwk(
|
|
66
|
-
kty = "EC",
|
|
67
|
-
crv = "P-256",
|
|
68
|
-
x = "2Y8TuhnlE4tiVDtliozYTgc1TAqi4_TBTI6FHe1p_Vw",
|
|
69
|
-
y = "pyxMJHj10HPe2hnpJvMpnZ4AzpYZRfqGEMhpBr1-Oto",
|
|
70
|
-
alg = "ES256",
|
|
71
|
-
use = "sig",
|
|
72
|
-
kid = "2026-05",
|
|
73
|
-
),
|
|
74
|
-
// PLACEHOLDER — used by the SDK's own unit tests and by the
|
|
75
|
-
// sample license printed by `generate-keypair.mjs`. The
|
|
76
|
-
// validator REFUSES to accept tokens signed under this kid
|
|
77
|
-
// unless `allowPlaceholderKey = true` is passed to the
|
|
78
|
-
// validator constructor (test-only escape hatch). Safe to keep
|
|
79
|
-
// in production builds; remove only if you want test fixtures
|
|
80
|
-
// to stop working.
|
|
81
|
-
PLACEHOLDER_KID to DvaiPublicKeyJwk(
|
|
82
|
-
kty = "EC",
|
|
83
|
-
crv = "P-256",
|
|
84
|
-
x = "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
|
|
85
|
-
y = "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
|
|
86
|
-
alg = "ES256",
|
|
87
|
-
use = "sig",
|
|
88
|
-
kid = PLACEHOLDER_KID,
|
|
89
|
-
),
|
|
90
|
-
)
|
|
91
|
-
}
|
|
1
|
+
package co.deepvoiceai.bridge.license
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Public-key registry for DVAI-Bridge license JWT verification.
|
|
5
|
+
*
|
|
6
|
+
* Kotlin port of `packages/dvai-bridge-core/src/license/publicKeys.ts` — semantics
|
|
7
|
+
* and registry contents are 1:1 with the JS side. The same JWT format and the
|
|
8
|
+
* same kids work across the JS, iOS, and Android validators.
|
|
9
|
+
*
|
|
10
|
+
* Each entry is keyed by `kid` (key id, written by the license generator
|
|
11
|
+
* into the JWT header). The SDK looks up the matching entry by kid when
|
|
12
|
+
* verifying a license token. Multiple entries can coexist so that key
|
|
13
|
+
* rotation is non-disruptive: ship the new key in a release alongside
|
|
14
|
+
* the old, leave the old in place for ~12 months while previously-
|
|
15
|
+
* issued licenses naturally expire or get re-issued, then prune.
|
|
16
|
+
*
|
|
17
|
+
* THE PRIVATE KEY DOES NOT LIVE HERE. It belongs in your secrets
|
|
18
|
+
* manager (1Password / AWS Secrets Manager / Vault), accessible only
|
|
19
|
+
* to the license-generator service that produces signed JWTs. The
|
|
20
|
+
* mathematics of ECDSA P-256 guarantee that a holder of the public
|
|
21
|
+
* key alone cannot forge a signature.
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/** ES256 (P-256 ECDSA) public key in JWK form. */
|
|
25
|
+
data class DvaiPublicKeyJwk(
|
|
26
|
+
val kty: String = "EC",
|
|
27
|
+
val crv: String = "P-256",
|
|
28
|
+
val x: String,
|
|
29
|
+
val y: String,
|
|
30
|
+
val alg: String? = "ES256",
|
|
31
|
+
val use: String? = "sig",
|
|
32
|
+
val kid: String? = null,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* `kid` reserved for the placeholder key. The validator refuses to
|
|
37
|
+
* accept tokens signed with this kid unless the caller explicitly opts
|
|
38
|
+
* in (`allowPlaceholderKey = true` passed to the validator constructor,
|
|
39
|
+
* used by tests and by the sample license printed by the keypair-
|
|
40
|
+
* generator script).
|
|
41
|
+
*/
|
|
42
|
+
const val PLACEHOLDER_KID: String = "placeholder-do-not-ship"
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Registry mapping `kid` → public key JWK.
|
|
46
|
+
*
|
|
47
|
+
* The entry below is a **placeholder** — it is a published, well-known
|
|
48
|
+
* test keypair and DOES NOT verify any real production license. Before
|
|
49
|
+
* shipping licenses to customers, replace it with the output of
|
|
50
|
+
* `scripts/license/generate-keypair.mjs`. The SDK refuses to validate
|
|
51
|
+
* licenses against the placeholder kid unless `allowPlaceholderKey` is
|
|
52
|
+
* set (test-only escape hatch).
|
|
53
|
+
*
|
|
54
|
+
* To add a new key for rotation, add a second entry keyed by the new
|
|
55
|
+
* `kid`; old licenses keep verifying against the old key, new licenses
|
|
56
|
+
* (issued by the generator that knows the new private key) verify
|
|
57
|
+
* against the new entry.
|
|
58
|
+
*/
|
|
59
|
+
object DvaiPublicKeys {
|
|
60
|
+
/** Production registry. Mirrors `DVAI_PUBLIC_KEYS` on the JS side. */
|
|
61
|
+
val REGISTRY: Map<String, DvaiPublicKeyJwk> = mapOf(
|
|
62
|
+
// Production key, kid `2026-05`. Generated 2026-05-15 by
|
|
63
|
+
// scripts/license/generate-keypair.mjs. The matching private
|
|
64
|
+
// key lives in the operator's secrets manager.
|
|
65
|
+
"2026-05" to DvaiPublicKeyJwk(
|
|
66
|
+
kty = "EC",
|
|
67
|
+
crv = "P-256",
|
|
68
|
+
x = "2Y8TuhnlE4tiVDtliozYTgc1TAqi4_TBTI6FHe1p_Vw",
|
|
69
|
+
y = "pyxMJHj10HPe2hnpJvMpnZ4AzpYZRfqGEMhpBr1-Oto",
|
|
70
|
+
alg = "ES256",
|
|
71
|
+
use = "sig",
|
|
72
|
+
kid = "2026-05",
|
|
73
|
+
),
|
|
74
|
+
// PLACEHOLDER — used by the SDK's own unit tests and by the
|
|
75
|
+
// sample license printed by `generate-keypair.mjs`. The
|
|
76
|
+
// validator REFUSES to accept tokens signed under this kid
|
|
77
|
+
// unless `allowPlaceholderKey = true` is passed to the
|
|
78
|
+
// validator constructor (test-only escape hatch). Safe to keep
|
|
79
|
+
// in production builds; remove only if you want test fixtures
|
|
80
|
+
// to stop working.
|
|
81
|
+
PLACEHOLDER_KID to DvaiPublicKeyJwk(
|
|
82
|
+
kty = "EC",
|
|
83
|
+
crv = "P-256",
|
|
84
|
+
x = "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4",
|
|
85
|
+
y = "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM",
|
|
86
|
+
alg = "ES256",
|
|
87
|
+
use = "sig",
|
|
88
|
+
kid = PLACEHOLDER_KID,
|
|
89
|
+
),
|
|
90
|
+
)
|
|
91
|
+
}
|