תחילת העבודה
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
סקירה
ה-API והפרוטוקול של Digital Asset Links מאפשרים לאפליקציה או לאתר לפרסם הצהרות ציבוריות וניתנות לאימות לגבי אפליקציות או אתרים אחרים. לדוגמה, אתר יכול להצהיר שהוא משויך לאפליקציה ספציפית ל-Android, או להצהיר שהוא רוצה לשתף את פרטי הכניסה של המשתמש עם אתר אחר.
לפניכם כמה שימושים אפשריים בקישורים לנכסים דיגיטליים:
- אתר א' מצהיר שהקישורים לאתר שלו צריכים להיפתח באפליקציה ייעודית
במכשירים ניידים, אם היא מותקנת.
- אתר א' מצהיר שהוא יכול לשתף את פרטי הכניסה של משתמש Chrome עם אתר
ב' כדי שהמשתמש לא יצטרך להתחבר לאתר ב' אם הוא מחובר לאתר א'.
- אפליקציה א' מצהירה שהיא יכולה לשתף עם אתר ב' את הגדרות המכשיר, כמו המיקום.
מונחי מפתח
- חשבון משתמש: חשבון המשתמש הוא האפליקציה או האתר שמהם מוגשת ההצהרה. בקישורים לנכסים דיגיטליים, חשבון המשתמש הוא תמיד האפליקציה או האתר שמארחים את רשימת דפי החשבון.
- רשימת דפי חשבון: ההצהרות נכללות ברשימת דפי חשבון שמכילה הצהרה אחת או יותר. רשימת הצהרות היא טקסט ברור ונגישה לכולם, במיקום בשליטת חשבון המשתמש וקשה לזייף אותו או לשנות אותו.
הקובץ יכול להיות קובץ עומד או קטע של פריט אחר גדול יותר. לדוגמה, באתר אינטרנט, זהו קובץ שלם. באפליקציה ל-Android, זהו קטע בקובץ המניפסט של האפליקציה.
כל אחד יכול לראות ולאמת הצהרות בשיטות לא קנייניות. מידע נוסף זמין במסמכי התיעוד של רשימת דפי החשבון.
- הצהרה: הצהרה היא מבנה JSON מובנה היטב שמורכב מrelation (מה שנאמר בהצהרה, לדוגמה: הפעלת שיתוף פרטי כניסה) וrelation (האתר או האפליקציה שעליהם חל הקשר). לכן, כל הצהרה דומה למשפט, כאשר principal מציין את הקשר לגבי target.
- צרכן דפי חשבון: צרכן של הצהרה מבקש להציג רשימת דפי חשבון מחשבון משתמש, בודק אם קיימת הצהרה כנגד חשבון משתמש מסוים, ואם הוא קיים, יכול לבצע את הפעולה שצוינה. מידע נוסף זמין במסמכי התיעוד בנושא כתיבת התנאים.
דוגמה לשימוש מהיר
דוגמה פשוטה מאוד לאופן שבו האתר www.example.com יכול להשתמש ב-Digital Asset Links כדי לציין שכל קישור לכתובות URL באתר הזה צריך להיפתח באפליקציה ייעודית ולא בדפדפן:
- האתר www.example.com מפרסם רשימת הצהרות בכתובת
https://www.example.com/.well-known/assetlinks.json. אלה
השם והמיקום הרשמיים של רשימת הצהרות באתר. רשימות של דפי חשבון בנק
במיקום אחר או בכל שם אחר לא תקפות לאתר הזה. בדוגמה שלנו, רשימת ההצהרות מורכבת מהצהרה אחת, שמעניקה
לאפליקציית Android שלה את ההרשאה לפתוח קישורים באתר שלה:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app",
"sha256_cert_fingerprints": ["hash_of_app_certificate"] }
}]
רשימת הצהרות תומכת במערך של הצהרות בתוך הסימונים [ ], אבל
הקובץ לדוגמה שלנו מכיל רק הצהרה אחת.
sha256_cert_fingerprints
הוא טביעות האצבע מסוג SHA256 של אישור החתימה של האפליקציה.
פרטים נוספים זמינים במסמכי התיעוד בנושא קישורים לאפליקציות ל-Android.
- באפליקציה ל-Android שמופיעה בהצהרה שלמעלה יש מסנן Intent שמציין את הסכמה, המארח ודפוס הנתיב של כתובות ה-URL שבהן היא רוצה לטפל: במקרה הזה, https://www.example.com. מסנן Intent כולל מאפיין מיוחד
android:autoVerify
, חדש ב-Android M, שמציין שמערכת Android צריכה לאמת את ההצהרה באתר שמתואר במסנן Intent כשהאפליקציה מותקנת.
- משתמש מתקין את האפליקציה. מערכת Android רואה את מסנן Intent עם המאפיין
autoVerify
ובודקת את נוכחות רשימת דפי החשבון באתר שצוין. אם היא קיימת, מערכת Android בודקת
אם הקובץ כולל הצהרה שמעניקה טיפול בקישורים לאפליקציה, ומאמתת את האפליקציה מול ההצהרה באמצעות גיבוב (hash) של אישור. אם לא נמצאו שגיאות, מערכת Android תעביר כל Intent של https://www.example.com לאפליקציית example.com.
- המשתמש לוחץ על קישור לכתובת https://www.example.com/puPPes במכשיר שלו. הקישור הזה יכול להיות בכל מקום: בדפדפן, בהצעה של Google Search Appliance או בכל מקום אחר. מערכת Android מעבירה את הכוונה לאפליקציית example.com.
- האפליקציה example.com מקבלת את הכוונה ובוחרת לטפל בה, ולפתוח את הדף של הגורים באפליקציה. אם מסיבה כלשהי האפליקציה סירבה לטפל בקישור, או אם האפליקציה לא נמצאת במכשיר, הקישור היה נשלח ל-handler הבא שמוגדר כברירת מחדל ותואם לדפוס הכוונה הזה (בדרך כלל הדפדפן).
שיקולים ומגבלות חשובים:
- הפרוטוקול לא מאמת את חשבון המשתמש שמבצע את ההצהרה, אבל ההצהרה נמצאת במיקום ספציפי שמשויך אליו מאוד, ונמצאת בשליטת חשבון המשתמש.
- הפרוטוקול לא מאמת את היעד שצוין בהצהרה, אבל הוא מספק אמצעי לאימות היעד (לדוגמה, ההצהרה מזהה יעדים של אפליקציות לנייד לפי גיבוב האישור ושם החבילה).
- הפרוטוקול לא מבצע במקור פעולות כלשהן בהצהרה. במקום זאת, הוא מאפשר לחשוף הצהרות, שאפליקציה צורכת הצהרות צריכה לאמת ולאחר מכן להחליט אם לפעול לגביהן ואיך. מערכת Android M מבצעת באופן מקורי את השלבים האלה.
לדוגמה, אם האתר מעניק גישה לטיפול בקישורים לאפליקציה ספציפית,
מערכת Android בודקת ומאמתת את ההצהרה, מאמתת את אפליקציית היעד ואז מציעה לאפליקציה את האפשרות לטפל בקישור הנתון.
- הפרוטוקול לא מאפשר להצהיר הצהרות בנוגע לשני
צדדים שלישיים: כלומר, אתר א' יכול להצהיר הצהרה לגבי אתר ב',
אבל אתר א' לא יכול להצהיר הצהרה לגבי הקשר של אתר ב'
לאתר ג'. עם זאת, אם אתר ב' סומכים על אתר א', הוא יכול לבדוק
באתר א' אם יש הצהרה שמעניקה הרשאה לאתר ג', ולהחליט ליישם את ההצהרה הזו.
השלבים הבאים
- כדאי לבדוק אם יש תיעוד מפורש של התרחיש לדוגמה שלכם.
- מידע נוסף על יצירת הצהרה
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2024-06-26 (שעון UTC).
[null,null,["עדכון אחרון: 2024-06-26 (שעון UTC)."],[[["\u003cp\u003eDigital Asset Links enable apps and websites to make verifiable statements about their relationships with other apps and websites, such as link handling or credential sharing.\u003c/p\u003e\n"],["\u003cp\u003eThese statements are stored in a publicly accessible statement list, typically an "assetlinks.json" file hosted by the app or website making the statement.\u003c/p\u003e\n"],["\u003cp\u003eAndroid M and above automatically uses Digital Asset Links to verify website-to-app associations and direct links to the appropriate app if installed.\u003c/p\u003e\n"],["\u003cp\u003eThe protocol provides a foundation for trust and delegation between digital entities but relies on consumers to validate and act upon the statements.\u003c/p\u003e\n"]]],[],null,["# Getting Started\n\nOverview\n--------\n\nThe Digital Asset Links protocol and API enable an app or website to make public,\nverifiable *statements* about other apps or websites. For example, a website\ncan declare that it is associated with a specific Android app, or it can declare that\nit wants to share user credentials with another website.\n\nHere are some possible uses for Digital Asset Links:\n\n- Website A declares that links to its site should open in a designated app on mobile devices, if the app is installed.\n- Website A declares that it can share its Chrome user credentials with website B so that the user won't have to log in to website B if it is logged into website A.\n- App A declares that it can share device settings, such as location, with website B.\n\n### Key terms\n\n- **Principal:** The principal is the app or website making the statement. In Digital Asset Links, the principal is always the app or website that hosts the statement list.\n- **Statement list** : Statements are contained in a *statement list* that contains one or more statements. A statement list is cleartext and publicly accessible, in a location that is controlled by the principal and difficult to spoof or tamper with. It can be a free-standing file, or a section of another, larger item. For example, on a website, it is an entire file; in an Android app, it is a section in the app manifest. Statements can be viewed and verified by anyone, using non-proprietary methods. [See the statement list documentation for more information](/digital-asset-links/v1/create-statement).\n- **Statement:** A statement is a tightly structured JSON construct that consists of a *relation* (what the statement says to do, for example: Enable sharing credentials) and a *target* (the website or app that the relation applies to). Therefore, each statement is like a sentence, where *principal* says *relation* about *target* . \n- **Statement consumer:** A statement consumer requests a statement list from a principal, checks for the presence of a statement against a given principal, and if it exists, can perform the action specified. [See the statement comsuming documentation for more information](/digital-asset-links/v1/consuming)*.*\n\nQuick usage example\n-------------------\n\nHere's a very simplified example of how the website www.example.com could\nuse Digital Asset Links to specify that any links to URLs in that site should\nopen in a designated app rather than the browser:\n\n1. The website www.example.com publishes a statement list at https://www.example.com/.well-known/assetlinks.json. This is the official name and location for a statement list on a site; statement lists in any other location, or with any other name, are not valid for this site. In our example, the statement list consists of one statement, granting its Android app the permission to open links on its site: \n\n ```\n [{\n \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n \"target\" : { \"namespace\": \"android_app\", \"package_name\": \"com.example.app\",\n \"sha256_cert_fingerprints\": [\"hash_of_app_certificate\"] }\n }]\n ```\n A statement list supports an array of statements within the \\[ \\] marks, but our example file contains only one statement. `sha256_cert_fingerprints` is the SHA256 fingerprints of your app's signing certificate. Find more details in the [Android App Links documentation](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc).\n2. The Android app listed in the statement above has an intent filter that specifies the scheme, host, and path pattern of URLs that it wants to handle: in this case, https://www.example.com. The intent filter includes a special attribute `android:autoVerify`, new to Android M, which indicates that Android should verify the statement on the website described in the intent filter when the app is installed.\n3. A user installs the app. Android sees the intent filter with the `autoVerify` attribute and checks for the presence of the statement list at the specified site; if present, Android checks whether that file includes a statement granting link handling to the app, and verifies the app against the statement by certificate hash. If everything checks out, Android will then forward any https://www.example.com intents to the example.com app.\n4. The user clicks a link to https://www.example.com/puppies on their device. This link could be anywhere: in a browser, in a Google Search Appliance suggestion, or anywhere else. Android forwards the intent to the example.com app.\n5. The example.com app receives the intent and chooses to handle it, opening the puppies page in the app. If for some reason the app had declined to handle the link, or if the app were not on the device, then the link would have been sent to the next default intent handler matching that intent pattern (often the browser).\n\nImportant considerations and limitations:\n-----------------------------------------\n\n- The protocol does not authenticate the principal making the statement, but the statement is located in a specific location strongly associated with the principal, and under control of the principal.\n- The protocol does not authenticate the statement target, but it provides a means for the caller to authenticate the target (for example, a statement identifies mobile app targets by certificate hash and package name).\n- The protocol does not natively perform any statement actions; rather, it enables the ability to expose statements, which a consuming application must validate and then decide whether and how to act upon. Android M natively performs these steps for you; for example, if a website delegates link handling to a specific app, Android checks and verifies the statement, verifies the target app, and then offers the app the option to handle the given link.\n- The protocol does not enable making statements about two third parties: that is, website A can make a statement about website B, but website A cannot make a statement about website B's relationship to website C. However, if website B trusts website A, it can check website A for a statement granting permission to website C, and decide to implement that.\n\nNext steps\n----------\n\n1. [See if there is explicit documentation for your use case.](/digital-asset-links/v1/using)\n2. [Learn about creating a statement.](/digital-asset-links/v1/create-statement)"]]