Skip to content

Commit 8cca2de

Browse files
feat: supporting android and ios rp origins (#121)
* feat: supporting android rp origins * feat: adding ios facet id suppert + tests * chore: added dst files * fix: restoring dist files * feat: restoring main.cjs * fix: reverting main.cjs
1 parent aef3754 commit 8cca2de

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

lib/toolbox.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,23 @@ function derToRaw(signature) {
7777
...extractBigNum(signature, sStart, signature.length, 32),
7878
]);
7979
}
80+
function isAndroidFacetId(str) {
81+
return str.startsWith("android:apk-key-hash:");
82+
}
83+
84+
function isIOSFacetId(str) {
85+
return str.startsWith("ios:bundle-id:");
86+
}
87+
8088

8189
function checkOrigin(str) {
90+
if(!str)
91+
throw new Error("Empty Origin");
92+
93+
if (isAndroidFacetId(str) || isIOSFacetId(str)) {
94+
return str;
95+
}
96+
8297
const originUrl = new URL(str);
8398
const origin = originUrl.origin;
8499

test/parseExpectations.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ describe("parseExpectations", function() {
3838
assert.strictEqual(ret.get("challenge"), exp.challenge);
3939
});
4040

41-
it("throws on invalid origin", function() {
41+
it("throws on invalid url", function() {
4242
const exp = {
4343
origin: "asdf",
4444
challenge: "4BS1YJKRCeCVoLdfG_b66BuSQ-I2n34WsLFvy62fpIVFjrm32_tFRQixX9U8EBVTriTkreAp-1nDvYboRK9WFg",

test/toolbox.test.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,23 @@ describe("toolbox", function() {
2929
checkOrigin(undefined);
3030
},
3131
Error,
32-
"Invalid URL",
32+
"Empty Origin",
3333
);
3434
});
3535

36+
37+
it("accepts android FacetID", function() {
38+
const androidFacetId = "android:apk-key-hash:addf120b430021c36c232c99ef8d926aea2acd6b";
39+
const androidOrigin = checkOrigin(androidFacetId);
40+
assert.strictEqual(androidFacetId, androidOrigin);
41+
});
42+
43+
it("accepts ios FacetID", function() {
44+
const iOSFacetId = "ios:bundle-id:addf120b430021c36c232c99ef8d926aea2acd6b";
45+
const iOSOrigin = checkOrigin(iOSFacetId);
46+
assert.strictEqual(iOSFacetId, iOSOrigin);
47+
});
48+
3649
it("throws invalid url", function() {
3750
assert.throws(
3851
() => {

0 commit comments

Comments
 (0)